Skip to content

Commit 3b40907

Browse files
committed
feature: client: modules: operation: migrate to ESM
1 parent 3b6b0b5 commit 3b40907

2 files changed

Lines changed: 27 additions & 26 deletions

File tree

.webpack/js.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default {
127127
[`${modules}/config`]: `${dirModules}/config/index.js`,
128128
[`${modules}/contact`]: `${dirModules}/contact.js`,
129129
[`${modules}/upload`]: `${dirModules}/upload.js`,
130-
[`${modules}/operation`]: `${dirModules}/operation/index.js`,
130+
[`${modules}/operation`]: `${dirModules}/operation/index.mjs`,
131131
[`${modules}/konsole`]: `${dirModules}/konsole.js`,
132132
[`${modules}/terminal`]: `${dirModules}/terminal.js`,
133133
[`${modules}/terminal-run`]: `${dirModules}/terminal-run.js`,
Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
/* global CloudCmd */
2-
/* global Util */
3-
/* global DOM */
4-
/* global fileop */
5-
6-
'use strict';
7-
8-
const currify = require('currify');
9-
const wraptile = require('wraptile');
10-
const {promisify} = require('es6-promisify');
11-
const exec = require('execon');
12-
const load = require('load.js');
13-
const {tryToCatch} = require('try-to-catch');
14-
15-
const {encode} = require('../../../common/entity');
16-
const removeExtension = require('./remove-extension');
17-
const setListeners = require('./set-listeners');
18-
const getNextCurrentName = require('./get-next-current-name');
1+
import currify from 'currify';
2+
import wraptile from 'wraptile';
3+
import {promisify} from 'es6-promisify';
4+
import exec from 'execon';
5+
import load from 'load.js';
6+
import {tryToCatch} from 'try-to-catch';
7+
import {encode} from '../../../common/entity.js';
8+
import removeExtension from './remove-extension.js';
9+
import setListeners from './set-listeners.js';
10+
import getNextCurrentName from './get-next-current-name.js';
11+
12+
const {DOM, CloudCmd} = globalThis;
1913

2014
const removeQuery = (a) => a.replace(/\?.*/, '');
2115

2216
const Name = 'Operation';
2317

24-
CloudCmd[Name] = exports;
25-
2618
const {config} = CloudCmd;
2719
const {Dialog, Images} = DOM;
2820

@@ -53,7 +45,7 @@ const noFilesCheck = () => {
5345
return is;
5446
};
5547

56-
module.exports.init = promisify((callback) => {
48+
export const init = promisify((callback) => {
5749
showLoad();
5850

5951
exec.series([
@@ -92,7 +84,7 @@ const onConnect = currify((fn, operator) => {
9284
async function initOperations(prefix, socketPrefix, fn) {
9385
socketPrefix = `${socketPrefix}/fileop`;
9486

95-
const operator = await fileop({
87+
const operator = await globalThis.fileop({
9688
prefix,
9789
socketPrefix,
9890
});
@@ -198,11 +190,11 @@ function getPacker(type) {
198190
return packTarFn;
199191
}
200192

201-
module.exports.hide = () => {
193+
export const hide = () => {
202194
CloudCmd.View.hide();
203195
};
204196

205-
module.exports.show = (operation, data) => {
197+
export const show = (operation, data) => {
206198
if (!Loaded)
207199
return;
208200

@@ -411,8 +403,11 @@ async function _processFiles(options, data) {
411403
to,
412404
names,
413405
};
406+
debugger;
414407

415408
operation(files, async () => {
409+
console.log('sssss');
410+
debugger;
416411
await DOM.Storage.remove(from);
417412

418413
const {panel, panelPassive} = Info;
@@ -505,8 +500,14 @@ async function prompt(msg, to, names) {
505500
return await Dialog.prompt(msg, to);
506501
}
507502

503+
globalThis.CloudCmd[Name] = {
504+
init,
505+
hide,
506+
show,
507+
};
508+
508509
async function loadAll() {
509-
const {prefix} = CloudCmd;
510+
const {prefix} = globalThis.CloudCmd;
510511
const file = `${prefix}/fileop/fileop.js`;
511512

512513
const [error] = await tryToCatch(load.js, file);

0 commit comments

Comments
 (0)