feature: client: key: migrate to ESM

This commit is contained in:
coderiaser 2026-01-20 23:11:14 +02:00
parent 8a769fd512
commit d574a93d6d
6 changed files with 252 additions and 256 deletions

View file

@ -12,7 +12,7 @@ import currify from 'currify';
import Images from './dom/images.js';
import {unregisterSW} from './sw/register.js';
import {getJsonFromFileTable} from './get-json-from-file-table.mjs';
import Key from './key/index.js';
import {Key} from './key/index.mjs';
import {
apiURL,
formatMsg,

View file

@ -1,9 +1,7 @@
/* global CloudCmd */
/* global CloudCmd*/
import tryToPromiseAll from '../../common/try-to-promise-all.js';
import Storage from './storage.js';
import DOM from './index.js';
const Info = DOM.CurrentInfo;
const CLASS = 'cut-file';
const COPY = 'copy';
const CUT = 'cut';
@ -57,6 +55,7 @@ async function readBuffer() {
}
export const copy = checkEnabled(async () => {
const Info = globalThis.DOM.CurrentInfo;
const names = getNames();
const from = Info.dirPath;
@ -73,6 +72,7 @@ export const copy = checkEnabled(async () => {
});
export const cut = checkEnabled(async () => {
const Info = globalThis.DOM.CurrentInfo;
const names = getNames();
const from = Info.dirPath;
@ -97,6 +97,7 @@ export const clear = checkEnabled(async () => {
});
export const paste = checkEnabled(async () => {
const Info = globalThis.DOM.CurrentInfo;
const [error, cp, ct] = await readBuffer();
if (error || !cp && !ct)

View file

@ -1,16 +1,12 @@
'use strict';
/* global CloudCmd, DOM */
const clipboard = require('@cloudcmd/clipboard');
const {fullstore} = require('fullstore');
const Buffer = require('../dom/buffer.mjs');
const Events = require('#dom/events');
const KEY = require('./key');
const _vim = require('./vim');
const setCurrentByChar = require('./set-current-by-char');
const {createBinder} = require('./binder');
import clipboard from '@cloudcmd/clipboard';
import {fullstore} from 'fullstore';
import * as Events from '#dom/events';
import * as Buffer from '../dom/buffer.mjs';
import KEY from './key.js';
import _vim from './vim/index.js';
import setCurrentByChar from './set-current-by-char.js';
import {createBinder} from './binder.js';
const Chars = fullstore();
@ -28,13 +24,16 @@ Chars([]);
const {assign} = Object;
const binder = createBinder();
module.exports = assign(binder, KEY);
module.exports.bind = () => {
const bind = () => {
Events.addKey(listener, true);
binder.setBind();
};
module.exports._listener = listener;
export const Key = assign(binder, KEY, {
bind,
});
export const _listener = listener;
function getChar(event) {
/*

View file

@ -7,7 +7,8 @@ const supertape = require('supertape');
const {ESC} = require('./key');
const {_listener, setBind} = require('.');
const {Key, _listener} = require('./index.mjs');
const {getDOM, getCloudCmd} = require('./vim/globals.fixture');
const test = autoGlobals(supertape);
const {stub} = supertape;
@ -26,7 +27,7 @@ test('cloudcmd: client: key: enable vim', async (t) => {
altKey: false,
};
setBind();
Key.setBind();
await _listener(event, {
vim,
@ -48,7 +49,7 @@ test('cloudcmd: client: key: disable vim', async (t) => {
altKey: false,
};
setBind();
Key.setBind();
await _listener(event, {
config,
_config,

View file

@ -403,11 +403,8 @@ async function _processFiles(options, data) {
to,
names,
};
debugger;
operation(files, async () => {
console.log('sssss');
debugger;
await DOM.Storage.remove(from);
const {panel, panelPassive} = Info;