From 0eb802e7bd5ad96ca8f65575ab3986519de205dc Mon Sep 17 00:00:00 2001 From: coderiaser Date: Thu, 29 Jan 2026 14:18:34 +0200 Subject: [PATCH] feature: client: dom: dialog: migrate to ESM --- .madrun.mjs | 2 +- client/dom/dialog.js | 26 ------------------------- client/dom/dialog.mjs | 18 +++++++++++++++++ client/dom/directory.js | 2 +- client/dom/index.js | 2 +- client/dom/operations/rename-current.js | 2 +- client/dom/rest.js | 2 +- client/dom/select-by-pattern.js | 2 +- client/dom/upload-files.js | 2 +- client/modules/command-line.js | 2 +- client/modules/markdown.js | 2 +- client/modules/user-menu/index.js | 2 +- package.json | 3 ++- 13 files changed, 30 insertions(+), 37 deletions(-) delete mode 100644 client/dom/dialog.js create mode 100644 client/dom/dialog.mjs diff --git a/.madrun.mjs b/.madrun.mjs index f088463f..930d468b 100644 --- a/.madrun.mjs +++ b/.madrun.mjs @@ -36,7 +36,7 @@ export default { 'test': () => [testEnv, `tape 'test/**/*.{js,mjs}' '{client,static,common,server}/**/*.spec.{js,mjs}' -f fail`], 'test:client': () => `tape 'test/client/**/*.js'`, 'test:server': () => `tape 'test/**/*.js' 'server/**/*.spec.js' 'common/**/*.spec.js'`, - 'wisdom': () => run(['lint:all', 'build', 'test'], null, { + 'wisdom': async () => await run(['lint:all', 'build', 'test'], null, { CI: 1, }), 'wisdom:type': () => 'bin/release.mjs', diff --git a/client/dom/dialog.js b/client/dom/dialog.js deleted file mode 100644 index eb342221..00000000 --- a/client/dom/dialog.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -const {tryToCatch} = require('try-to-catch'); - -const { - alert, - prompt, - confirm, - progress, -} = require('smalltalk'); - -const title = 'Cloud Commander'; - -module.exports.alert = (...a) => alert(title, ...a, { - cancel: false, -}); - -module.exports.prompt = (...a) => tryToCatch(prompt, title, ...a); -module.exports.confirm = (...a) => tryToCatch(confirm, title, ...a); -module.exports.progress = (...a) => progress(title, ...a); - -module.exports.alert.noFiles = () => { - return alert(title, 'No files selected!', { - cancel: false, - }); -}; diff --git a/client/dom/dialog.mjs b/client/dom/dialog.mjs new file mode 100644 index 00000000..0a1e449c --- /dev/null +++ b/client/dom/dialog.mjs @@ -0,0 +1,18 @@ +import {tryToCatch} from 'try-to-catch'; +import smalltalk from 'smalltalk'; + +const title = 'Cloud Commander'; + +export const alert = (...a) => smalltalk.alert(title, ...a, { + cancel: false, +}); + +export const prompt = (...a) => tryToCatch(smalltalk.prompt, title, ...a); +export const confirm = (...a) => tryToCatch(smalltalk.confirm, title, ...a); +export const progress = (...a) => smalltalk.progress(title, ...a); + +alert.noFiles = () => { + return smalltalk.alert(title, 'No files selected!', { + cancel: false, + }); +}; diff --git a/client/dom/directory.js b/client/dom/directory.js index bedb7e95..ad966c3d 100644 --- a/client/dom/directory.js +++ b/client/dom/directory.js @@ -6,7 +6,7 @@ const philip = require('philip'); const Images = require('./images.mjs'); const {FS} = require('../../common/cloudfunc.mjs'); const DOM = require('.'); -const Dialog = require('./dialog'); +const Dialog = require('#dom/dialog'); const {getCurrentDirPath: getPathWhenRootEmpty} = DOM; diff --git a/client/dom/index.js b/client/dom/index.js index 7dbd7a0e..336463ac 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -26,7 +26,7 @@ DOM.Files = require('./files'); DOM.RESTful = RESTful; DOM.IO = require('./io'); DOM.Storage = Storage; -DOM.Dialog = require('./dialog'); +DOM.Dialog = require('#dom/dialog'); DOM.CurrentInfo = CurrentInfo; module.exports = DOM; diff --git a/client/dom/operations/rename-current.js b/client/dom/operations/rename-current.js index ab658edf..07a038c5 100644 --- a/client/dom/operations/rename-current.js +++ b/client/dom/operations/rename-current.js @@ -3,7 +3,7 @@ /* global CloudCmd */ const capitalize = require('just-capitalize'); -const _Dialog = require('../dialog'); +const _Dialog = require('#dom/dialog'); const Storage = require('../storage'); const RESTful = require('../rest'); diff --git a/client/dom/rest.js b/client/dom/rest.js index 7596f620..d9ee6c13 100644 --- a/client/dom/rest.js +++ b/client/dom/rest.js @@ -6,7 +6,7 @@ const {encode} = require('../../common/entity'); const Images = require('./images.mjs'); const IO = require('./io'); -const Dialog = require('./dialog'); +const Dialog = require('#dom/dialog'); const handleError = (promise) => async (...args) => { const [e, data] = await tryToCatch(promise, ...args); diff --git a/client/dom/select-by-pattern.js b/client/dom/select-by-pattern.js index 2f2cb22d..389003e0 100644 --- a/client/dom/select-by-pattern.js +++ b/client/dom/select-by-pattern.js @@ -3,7 +3,7 @@ let SelectType = '*.*'; const {getRegExp} = require('../../common/util'); -const {alert, prompt} = require('./dialog'); +const {alert, prompt} = require('#dom/dialog'); const DOM = require('.'); diff --git a/client/dom/upload-files.js b/client/dom/upload-files.js index 01d4a777..2fa9f571 100644 --- a/client/dom/upload-files.js +++ b/client/dom/upload-files.js @@ -6,7 +6,7 @@ const wraptile = require('wraptile'); const load = require('#dom/load'); const Images = require('./images.mjs'); -const {alert} = require('./dialog'); +const {alert} = require('#dom/dialog'); const {FS} = require('../../common/cloudfunc.mjs'); diff --git a/client/modules/command-line.js b/client/modules/command-line.js index a0c000d9..89a562fa 100644 --- a/client/modules/command-line.js +++ b/client/modules/command-line.js @@ -3,7 +3,7 @@ /* global CloudCmd */ CloudCmd.CommandLine = exports; -const Dialog = require('../dom/dialog'); +const Dialog = require('#dom/dialog'); const noop = () => {}; diff --git a/client/modules/markdown.js b/client/modules/markdown.js index 9dc224af..16d73546 100644 --- a/client/modules/markdown.js +++ b/client/modules/markdown.js @@ -7,7 +7,7 @@ const createElement = require('@cloudcmd/create-element'); const Images = require('../dom/images.mjs'); const {Markdown} = require('../dom/rest'); -const {alert} = require('../dom/dialog'); +const {alert} = require('#dom/dialog'); module.exports.init = async () => { Images.show.load('top'); diff --git a/client/modules/user-menu/index.js b/client/modules/user-menu/index.js index 1dba5d23..19d7e064 100644 --- a/client/modules/user-menu/index.js +++ b/client/modules/user-menu/index.js @@ -13,7 +13,7 @@ const {tryToCatch} = require('try-to-catch'); const {codeFrameColumns} = require('@babel/code-frame'); const Images = require('../../dom/images.mjs'); -const Dialog = require('../../dom/dialog'); +const Dialog = require('#dom/dialog'); const getUserMenu = require('./get-user-menu'); const navigate = require('./navigate'); const parseError = require('./parse-error'); diff --git a/package.json b/package.json index e9d44302..401f5f0c 100644 --- a/package.json +++ b/package.json @@ -219,7 +219,8 @@ }, "imports": { "#dom/events": "./client/dom/events/index.mjs", - "#dom/load": "./client/dom/load.mjs" + "#dom/load": "./client/dom/load.mjs", + "#dom/dialog": "./client/dom/dialog.mjs" }, "engines": { "node": ">=22"