From d574a93d6d9652d8e528ceb11f800078a1ddbd25 Mon Sep 17 00:00:00 2001 From: coderiaser Date: Tue, 20 Jan 2026 23:11:14 +0200 Subject: [PATCH] feature: client: key: migrate to ESM --- client/client.mjs | 2 +- client/dom/buffer.mjs | 7 +- client/key/{index.js => index.mjs} | 29 +- client/key/index.spec.js | 7 +- client/modules/operation/index.mjs | 3 - package.json | 460 ++++++++++++++--------------- 6 files changed, 252 insertions(+), 256 deletions(-) rename client/key/{index.js => index.mjs} (96%) diff --git a/client/client.mjs b/client/client.mjs index b1d9edd6..e7a4f87d 100644 --- a/client/client.mjs +++ b/client/client.mjs @@ -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, diff --git a/client/dom/buffer.mjs b/client/dom/buffer.mjs index a75b4f2f..d7faf043 100644 --- a/client/dom/buffer.mjs +++ b/client/dom/buffer.mjs @@ -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) diff --git a/client/key/index.js b/client/key/index.mjs similarity index 96% rename from client/key/index.js rename to client/key/index.mjs index c13f9d41..64fd1bc3 100644 --- a/client/key/index.js +++ b/client/key/index.mjs @@ -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) { /* diff --git a/client/key/index.spec.js b/client/key/index.spec.js index 3e52e5ac..d8167079 100644 --- a/client/key/index.spec.js +++ b/client/key/index.spec.js @@ -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, diff --git a/client/modules/operation/index.mjs b/client/modules/operation/index.mjs index 48b6fa02..8e8149e5 100644 --- a/client/modules/operation/index.mjs +++ b/client/modules/operation/index.mjs @@ -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; diff --git a/package.json b/package.json index 09ea9725..94eecb56 100644 --- a/package.json +++ b/package.json @@ -1,233 +1,231 @@ { - "name": "cloudcmd", - "version": "19.1.7", - "type": "commonjs", - "author": "coderaiser (https://github.com/coderaiser)", - "description": "File manager for the web with console and editor", - "homepage": "http://cloudcmd.io", - "funding": "https://opencollective.com/cloudcmd", - "repository": { - "type": "git", - "url": "git+https://github.com/coderaiser/cloudcmd.git" - }, - "main": "server/cloudcmd.mjs", - "keywords": [ - "console", - "terminal", - "edit", - "editor", - "file", - "file manager", - "folder", - "orthodox", - "view", - "viewer", - "copy", - "rename", - "move", - "rm", - "mv", - "cp", - "delete", - "delete file", - "delete directory", - "remove", - "remove file", - "remove directory", - "file operation", - "pack", - "server" - ], - "bin": { - "cloudcmd": "bin/cloudcmd.mjs" - }, - "scripts": { - "start": "madrun start", - "start:dev": "madrun start:dev", - "build:start": "madrun build:start", - "build:start:dev": "madrun build:start:dev", - "lint:all": "madrun lint:all", - "lint": "madrun lint", - "lint:progress": "madrun lint:progress", - "watch:lint": "madrun watch:lint", - "fresh:lint": "madrun fresh:lint", - "lint:fresh": "madrun lint:fresh", - "fix:lint": "madrun fix:lint", - "lint:stream": "madrun lint:stream", - "test": "madrun test", - "test:client": "madrun test:client", - "test:server": "madrun test:server", - "wisdom": "madrun wisdom", - "wisdom:type": "madrun wisdom:type", - "coverage": "madrun coverage", - "coverage:report": "madrun coverage:report", - "report": "madrun report", - "6to5": "madrun 6to5", - "6to5:client": "madrun 6to5:client", - "6to5:client:dev": "madrun 6to5:client:dev", - "watch:client": "madrun watch:client", - "watch:client:dev": "madrun watch:client:dev", - "watch:server": "madrun watch:server", - "watch:test": "madrun watch:test", - "watch:test:client": "madrun watch:test:client", - "watch:test:server": "madrun watch:test:server", - "watch:coverage": "madrun watch:coverage", - "build": "madrun build", - "build:dev": "madrun build:dev", - "build:client": "madrun build:client", - "build:client:dev": "madrun build:client:dev", - "heroku-postbuild": "madrun heroku-postbuild" - }, - "directories": { - "man": "man" - }, - "subdomain": "cloudcmd", - "dependencies": { - "@babel/plugin-transform-optional-chaining": "^7.21.0", - "@cloudcmd/dropbox": "^5.0.1", - "@cloudcmd/fileop": "^8.0.0", - "@cloudcmd/move-files": "^8.0.0", - "@cloudcmd/read-files-sync": "^2.0.0", - "@putout/cli-validate-args": "^2.0.0", - "aleman": "^1.16.5", - "apart": "^2.0.0", - "chalk": "^5.3.0", - "compression": "^1.7.4", - "console-io": "^14.0.0", - "copymitter": "^9.0.0", - "criton": "^2.0.0", - "currify": "^4.0.0", - "deepmerge": "^4.0.0", - "deepword": "^10.0.0", - "dword": "^15.0.0", - "edward": "^15.0.0", - "es6-promisify": "^7.0.0", - "execon": "^1.2.0", - "express": "^5.1.0", - "files-io": "^4.0.0", - "find-up": "^8.0.0", - "for-each-key": "^2.0.0", - "format-io": "^2.0.0", - "fullstore": "^4.0.0", - "http-auth": "^4.2.1", - "inly": "^5.0.0", - "jaguar": "^6.0.0", - "jju": "^1.3.0", - "jonny": "^3.0.0", - "just-snake-case": "^3.2.0", - "markdown-it": "^14.0.0", - "mellow": "^3.0.0", - "mime-types": "^3.0.1", - "montag": "^1.2.1", - "nano-memoize": "^3.0.16", - "nomine": "^4.0.0", - "object.omit": "^3.0.0", - "once": "^1.4.0", - "onezip": "^6.0.1", - "open": "^11.0.0", - "package-json": "^10.0.0", - "pipe-io": "^4.0.1", - "ponse": "^7.0.0", - "pullout": "^5.0.0", - "putout": "^41.0.0", - "redzip": "^3.0.0", - "rendy": "^4.1.3", - "restafary": "^12.0.0", - "restbox": "^4.0.0", - "shortdate": "^2.0.0", - "simport": "^1.0.1", - "socket.io": "^4.0.0", - "socket.io-client": "^4.0.1", - "squad": "^3.0.0", - "table": "^6.0.1", - "try-catch": "^4.0.4", - "try-to-catch": "^4.0.0", - "tryrequire": "^3.0.0", - "win32": "^7.0.0", - "wraptile": "^3.0.0", - "writejson": "^3.0.0", - "yargs-parser": "^22.0.0" - }, - "devDependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/core": "^7.22.5", - "@babel/preset-env": "^7.0.0", - "@cloudcmd/clipboard": "^2.0.0", - "@cloudcmd/create-element": "^2.0.0", - "@cloudcmd/modal": "^3.0.0", - "@cloudcmd/olark": "^3.0.2", - "@cloudcmd/stub": "^5.0.0", - "@iocmd/wait": "^2.1.0", - "@putout/eslint-flat": "^3.0.1", - "@putout/plugin-cloudcmd": "^4.0.0", - "@types/node-fetch": "^2.6.11", - "auto-globals": "^4.0.0", - "babel-loader": "^10.0.0", - "babel-plugin-macros": "^3.0.0", - "c8": "^10.1.2", - "cheerio": "^1.0.0-rc.5", - "clean-css-loader": "^4.2.1", - "codegen.macro": "^4.0.0", - "css-loader": "^7.1.2", - "css-modules-require-hook": "^4.2.3", - "cssnano-preset-default": "^7.0.10", - "domtokenlist-shim": "^1.2.0", - "emitify": "^4.0.1", - "eslint": "^9.23.0", - "eslint-plugin-n": "^17.0.0-4", - "eslint-plugin-putout": "^30.0.0", - "globals": "^17.0.0", - "gritty": "^9.0.0", - "gunzip-maybe": "^1.3.1", - "html-webpack-plugin": "^5.6.3", - "inherits": "^2.0.3", - "itype": "^3.0.1", - "just-capitalize": "^3.2.0", - "just-pascal-case": "^3.2.0", - "limier": "^3.0.0", - "load.js": "^3.0.0", - "madrun": "^12.1.0", - "memfs": "^4.2.0", - "mini-css-extract-plugin": "^2.9.2", - "minor": "^1.2.2", - "mock-require": "^3.0.1", - "morgan": "^1.6.1", - "multi-rename": "^3.0.0", - "nodemon": "^3.0.1", - "optimize-css-assets-webpack-plugin": "^6.0.1", - "path-browserify": "^1.0.1", - "philip": "^3.0.0", - "place": "^1.1.4", - "postcss": "^8.5.3", - "process": "^0.11.10", - "readjson": "^2.0.1", - "redlint": "^5.0.0", - "request": "^2.76.0", - "rimraf": "^6.0.1", - "scroll-into-view-if-needed": "^3.0.4", - "serve-once": "^3.0.1", - "smalltalk": "^4.0.0", - "style-loader": "^4.0.0", - "supermenu": "^4.0.1", - "supertape": "^12.0.0", - "tar-stream": "^3.0.0", - "unionfs": "^4.0.0", - "url-loader": "^4.0.0", - "webpack": "^5.99.9", - "webpack-cli": "^6.0.1", - "webpack-merge": "^6.0.1", - "webpackbar": "^7.0.0" - }, - "imports": { - "#dom/events": { - "default": "./client/dom/events/index.mjs" - } - }, - "engines": { - "node": ">=22" - }, - "license": "MIT", - "publishConfig": { - "access": "public" - } + "name": "cloudcmd", + "version": "19.1.7", + "type": "commonjs", + "author": "coderaiser (https://github.com/coderaiser)", + "description": "File manager for the web with console and editor", + "homepage": "http://cloudcmd.io", + "funding": "https://opencollective.com/cloudcmd", + "repository": { + "type": "git", + "url": "git+https://github.com/coderaiser/cloudcmd.git" + }, + "main": "server/cloudcmd.mjs", + "keywords": [ + "console", + "terminal", + "edit", + "editor", + "file", + "file manager", + "folder", + "orthodox", + "view", + "viewer", + "copy", + "rename", + "move", + "rm", + "mv", + "cp", + "delete", + "delete file", + "delete directory", + "remove", + "remove file", + "remove directory", + "file operation", + "pack", + "server" + ], + "bin": { + "cloudcmd": "bin/cloudcmd.mjs" + }, + "scripts": { + "start": "madrun start", + "start:dev": "madrun start:dev", + "build:start": "madrun build:start", + "build:start:dev": "madrun build:start:dev", + "lint:all": "madrun lint:all", + "lint": "madrun lint", + "lint:progress": "madrun lint:progress", + "watch:lint": "madrun watch:lint", + "fresh:lint": "madrun fresh:lint", + "lint:fresh": "madrun lint:fresh", + "fix:lint": "madrun fix:lint", + "lint:stream": "madrun lint:stream", + "test": "madrun test", + "test:client": "madrun test:client", + "test:server": "madrun test:server", + "wisdom": "madrun wisdom", + "wisdom:type": "madrun wisdom:type", + "coverage": "madrun coverage", + "coverage:report": "madrun coverage:report", + "report": "madrun report", + "6to5": "madrun 6to5", + "6to5:client": "madrun 6to5:client", + "6to5:client:dev": "madrun 6to5:client:dev", + "watch:client": "madrun watch:client", + "watch:client:dev": "madrun watch:client:dev", + "watch:server": "madrun watch:server", + "watch:test": "madrun watch:test", + "watch:test:client": "madrun watch:test:client", + "watch:test:server": "madrun watch:test:server", + "watch:coverage": "madrun watch:coverage", + "build": "madrun build", + "build:dev": "madrun build:dev", + "build:client": "madrun build:client", + "build:client:dev": "madrun build:client:dev", + "heroku-postbuild": "madrun heroku-postbuild" + }, + "directories": { + "man": "man" + }, + "subdomain": "cloudcmd", + "dependencies": { + "@babel/plugin-transform-optional-chaining": "^7.21.0", + "@cloudcmd/dropbox": "^5.0.1", + "@cloudcmd/fileop": "^8.0.0", + "@cloudcmd/move-files": "^8.0.0", + "@cloudcmd/read-files-sync": "^2.0.0", + "@putout/cli-validate-args": "^2.0.0", + "aleman": "^1.16.5", + "apart": "^2.0.0", + "chalk": "^5.3.0", + "compression": "^1.7.4", + "console-io": "^14.0.0", + "copymitter": "^9.0.0", + "criton": "^2.0.0", + "currify": "^4.0.0", + "deepmerge": "^4.0.0", + "deepword": "^10.0.0", + "dword": "^15.0.0", + "edward": "^15.0.0", + "es6-promisify": "^7.0.0", + "execon": "^1.2.0", + "express": "^5.1.0", + "files-io": "^4.0.0", + "find-up": "^8.0.0", + "for-each-key": "^2.0.0", + "format-io": "^2.0.0", + "fullstore": "^4.0.0", + "http-auth": "^4.2.1", + "inly": "^5.0.0", + "jaguar": "^6.0.0", + "jju": "^1.3.0", + "jonny": "^3.0.0", + "just-snake-case": "^3.2.0", + "markdown-it": "^14.0.0", + "mellow": "^3.0.0", + "mime-types": "^3.0.1", + "montag": "^1.2.1", + "nano-memoize": "^3.0.16", + "nomine": "^4.0.0", + "object.omit": "^3.0.0", + "once": "^1.4.0", + "onezip": "^6.0.1", + "open": "^11.0.0", + "package-json": "^10.0.0", + "pipe-io": "^4.0.1", + "ponse": "^7.0.0", + "pullout": "^5.0.0", + "putout": "^41.0.0", + "redzip": "^3.0.0", + "rendy": "^4.1.3", + "restafary": "^12.0.0", + "restbox": "^4.0.0", + "shortdate": "^2.0.0", + "simport": "^1.0.1", + "socket.io": "^4.0.0", + "socket.io-client": "^4.0.1", + "squad": "^3.0.0", + "table": "^6.0.1", + "try-catch": "^4.0.4", + "try-to-catch": "^4.0.0", + "tryrequire": "^3.0.0", + "win32": "^7.0.0", + "wraptile": "^3.0.0", + "writejson": "^3.0.0", + "yargs-parser": "^22.0.0" + }, + "devDependencies": { + "@babel/code-frame": "^7.22.5", + "@babel/core": "^7.22.5", + "@babel/preset-env": "^7.0.0", + "@cloudcmd/clipboard": "^2.0.0", + "@cloudcmd/create-element": "^2.0.0", + "@cloudcmd/modal": "^3.0.0", + "@cloudcmd/olark": "^3.0.2", + "@cloudcmd/stub": "^5.0.0", + "@iocmd/wait": "^2.1.0", + "@putout/eslint-flat": "^3.0.1", + "@putout/plugin-cloudcmd": "^4.0.0", + "@types/node-fetch": "^2.6.11", + "auto-globals": "^4.0.0", + "babel-loader": "^10.0.0", + "babel-plugin-macros": "^3.0.0", + "c8": "^10.1.2", + "cheerio": "^1.0.0-rc.5", + "clean-css-loader": "^4.2.1", + "codegen.macro": "^4.0.0", + "css-loader": "^7.1.2", + "css-modules-require-hook": "^4.2.3", + "cssnano-preset-default": "^7.0.10", + "domtokenlist-shim": "^1.2.0", + "emitify": "^4.0.1", + "eslint": "^9.23.0", + "eslint-plugin-n": "^17.0.0-4", + "eslint-plugin-putout": "^30.0.0", + "globals": "^17.0.0", + "gritty": "^9.0.0", + "gunzip-maybe": "^1.3.1", + "html-webpack-plugin": "^5.6.3", + "inherits": "^2.0.3", + "itype": "^3.0.1", + "just-capitalize": "^3.2.0", + "just-pascal-case": "^3.2.0", + "limier": "^3.0.0", + "load.js": "^3.0.0", + "madrun": "^12.1.0", + "memfs": "^4.2.0", + "mini-css-extract-plugin": "^2.9.2", + "minor": "^1.2.2", + "mock-require": "^3.0.1", + "morgan": "^1.6.1", + "multi-rename": "^3.0.0", + "nodemon": "^3.0.1", + "optimize-css-assets-webpack-plugin": "^6.0.1", + "path-browserify": "^1.0.1", + "philip": "^3.0.0", + "place": "^1.1.4", + "postcss": "^8.5.3", + "process": "^0.11.10", + "readjson": "^2.0.1", + "redlint": "^5.0.0", + "request": "^2.76.0", + "rimraf": "^6.0.1", + "scroll-into-view-if-needed": "^3.0.4", + "serve-once": "^3.0.1", + "smalltalk": "^4.0.0", + "style-loader": "^4.0.0", + "supermenu": "^4.0.1", + "supertape": "^12.0.0", + "tar-stream": "^3.0.0", + "unionfs": "^4.0.0", + "url-loader": "^4.0.0", + "webpack": "^5.99.9", + "webpack-cli": "^6.0.1", + "webpack-merge": "^6.0.1", + "webpackbar": "^7.0.0" + }, + "imports": { + "#dom/events": "./client/dom/events/index.mjs" + }, + "engines": { + "node": ">=22" + }, + "license": "MIT", + "publishConfig": { + "access": "public" + } }