feature: client: dom: dialog: migrate to ESM

This commit is contained in:
coderiaser 2026-01-29 14:18:34 +02:00
parent 8223800ac6
commit 0eb802e7bd
13 changed files with 30 additions and 37 deletions

View file

@ -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',

View file

@ -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,
});
};

18
client/dom/dialog.mjs Normal file
View file

@ -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,
});
};

View file

@ -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;

View file

@ -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;

View file

@ -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');

View file

@ -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);

View file

@ -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('.');

View file

@ -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');

View file

@ -3,7 +3,7 @@
/* global CloudCmd */
CloudCmd.CommandLine = exports;
const Dialog = require('../dom/dialog');
const Dialog = require('#dom/dialog');
const noop = () => {};

View file

@ -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');

View file

@ -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');

View file

@ -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"