Skip to content

Commit d574a93

Browse files
committed
feature: client: key: migrate to ESM
1 parent 8a769fd commit d574a93

6 files changed

Lines changed: 252 additions & 256 deletions

File tree

client/client.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import currify from 'currify';
1212
import Images from './dom/images.js';
1313
import {unregisterSW} from './sw/register.js';
1414
import {getJsonFromFileTable} from './get-json-from-file-table.mjs';
15-
import Key from './key/index.js';
15+
import {Key} from './key/index.mjs';
1616
import {
1717
apiURL,
1818
formatMsg,

client/dom/buffer.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
/* global CloudCmd */
1+
/* global CloudCmd*/
22
import tryToPromiseAll from '../../common/try-to-promise-all.js';
33
import Storage from './storage.js';
4-
import DOM from './index.js';
54

6-
const Info = DOM.CurrentInfo;
75
const CLASS = 'cut-file';
86
const COPY = 'copy';
97
const CUT = 'cut';
@@ -57,6 +55,7 @@ async function readBuffer() {
5755
}
5856

5957
export const copy = checkEnabled(async () => {
58+
const Info = globalThis.DOM.CurrentInfo;
6059
const names = getNames();
6160
const from = Info.dirPath;
6261

@@ -73,6 +72,7 @@ export const copy = checkEnabled(async () => {
7372
});
7473

7574
export const cut = checkEnabled(async () => {
75+
const Info = globalThis.DOM.CurrentInfo;
7676
const names = getNames();
7777
const from = Info.dirPath;
7878

@@ -97,6 +97,7 @@ export const clear = checkEnabled(async () => {
9797
});
9898

9999
export const paste = checkEnabled(async () => {
100+
const Info = globalThis.DOM.CurrentInfo;
100101
const [error, cp, ct] = await readBuffer();
101102

102103
if (error || !cp && !ct)
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
'use strict';
2-
31
/* global CloudCmd, DOM */
4-
const clipboard = require('@cloudcmd/clipboard');
5-
const {fullstore} = require('fullstore');
6-
7-
const Buffer = require('../dom/buffer.mjs');
8-
const Events = require('#dom/events');
9-
const KEY = require('./key');
10-
11-
const _vim = require('./vim');
12-
const setCurrentByChar = require('./set-current-by-char');
13-
const {createBinder} = require('./binder');
2+
import clipboard from '@cloudcmd/clipboard';
3+
import {fullstore} from 'fullstore';
4+
import * as Events from '#dom/events';
5+
import * as Buffer from '../dom/buffer.mjs';
6+
import KEY from './key.js';
7+
import _vim from './vim/index.js';
8+
import setCurrentByChar from './set-current-by-char.js';
9+
import {createBinder} from './binder.js';
1410

1511
const Chars = fullstore();
1612

@@ -28,13 +24,16 @@ Chars([]);
2824
const {assign} = Object;
2925
const binder = createBinder();
3026

31-
module.exports = assign(binder, KEY);
32-
module.exports.bind = () => {
27+
const bind = () => {
3328
Events.addKey(listener, true);
3429
binder.setBind();
3530
};
3631

37-
module.exports._listener = listener;
32+
export const Key = assign(binder, KEY, {
33+
bind,
34+
});
35+
36+
export const _listener = listener;
3837

3938
function getChar(event) {
4039
/*

client/key/index.spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const supertape = require('supertape');
77

88
const {ESC} = require('./key');
99

10-
const {_listener, setBind} = require('.');
10+
const {Key, _listener} = require('./index.mjs');
11+
1112
const {getDOM, getCloudCmd} = require('./vim/globals.fixture');
1213
const test = autoGlobals(supertape);
1314
const {stub} = supertape;
@@ -26,7 +27,7 @@ test('cloudcmd: client: key: enable vim', async (t) => {
2627
altKey: false,
2728
};
2829

29-
setBind();
30+
Key.setBind();
3031

3132
await _listener(event, {
3233
vim,
@@ -48,7 +49,7 @@ test('cloudcmd: client: key: disable vim', async (t) => {
4849
altKey: false,
4950
};
5051

51-
setBind();
52+
Key.setBind();
5253
await _listener(event, {
5354
config,
5455
_config,

client/modules/operation/index.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,8 @@ async function _processFiles(options, data) {
403403
to,
404404
names,
405405
};
406-
debugger;
407406

408407
operation(files, async () => {
409-
console.log('sssss');
410-
debugger;
411408
await DOM.Storage.remove(from);
412409

413410
const {panel, panelPassive} = Info;

0 commit comments

Comments
 (0)