mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature: client: migrate to ESM
This commit is contained in:
parent
0ccd109a50
commit
3bdf47a5bb
4 changed files with 36 additions and 36 deletions
|
|
@ -1,30 +1,24 @@
|
||||||
'use strict';
|
import process from 'node:process';
|
||||||
|
|
||||||
const process = require('node:process');
|
|
||||||
|
|
||||||
/* global DOM */
|
/* global DOM */
|
||||||
const Emitify = require('emitify');
|
import Emitify from 'emitify';
|
||||||
const inherits = require('inherits');
|
import inherits from 'inherits';
|
||||||
const rendy = require('rendy');
|
import rendy from 'rendy';
|
||||||
const load = require('load.js');
|
import load from 'load.js';
|
||||||
const {tryToCatch} = require('try-to-catch');
|
import {tryToCatch} from 'try-to-catch';
|
||||||
const {addSlashToEnd} = require('format-io');
|
import {addSlashToEnd} from 'format-io';
|
||||||
const pascalCase = require('just-pascal-case');
|
import pascalCase from 'just-pascal-case';
|
||||||
const currify = require('currify');
|
import currify from 'currify';
|
||||||
|
import Images from './dom/images.js';
|
||||||
const Images = require('./dom/images');
|
import {unregisterSW} from './sw/register.js';
|
||||||
|
import {getJsonFromFileTable} from './get-json-from-file-table.mjs';
|
||||||
const {unregisterSW} = require('./sw/register');
|
import Key from './key/index.js';
|
||||||
const {getJsonFromFileTable} = require('./get-json-from-file-table.mjs');
|
import {
|
||||||
const Key = require('./key');
|
|
||||||
|
|
||||||
const {
|
|
||||||
apiURL,
|
apiURL,
|
||||||
formatMsg,
|
formatMsg,
|
||||||
buildFromJSON,
|
buildFromJSON,
|
||||||
} = require('../common/cloudfunc.mjs');
|
} from '../common/cloudfunc.mjs';
|
||||||
|
import {loadModule} from './load-module.mjs';
|
||||||
const {loadModule} = require('./load-module.mjs');
|
|
||||||
|
|
||||||
const noJS = (a) => a.replace(/.js$/, '');
|
const noJS = (a) => a.replace(/.js$/, '');
|
||||||
|
|
||||||
|
|
@ -32,7 +26,9 @@ const isDev = process.env.NODE_ENV === 'development';
|
||||||
|
|
||||||
inherits(CloudCmdProto, Emitify);
|
inherits(CloudCmdProto, Emitify);
|
||||||
|
|
||||||
module.exports = new CloudCmdProto(DOM);
|
export const createCloudCmd = (DOM) => {
|
||||||
|
return new CloudCmdProto(DOM);
|
||||||
|
};
|
||||||
|
|
||||||
load.addErrorListener((e, src) => {
|
load.addErrorListener((e, src) => {
|
||||||
const msg = `file ${src} could not be loaded`;
|
const msg = `file ${src} could not be loaded`;
|
||||||
|
|
@ -49,11 +45,9 @@ function CloudCmdProto(DOM) {
|
||||||
|
|
||||||
const {Storage, Files} = DOM;
|
const {Storage, Files} = DOM;
|
||||||
|
|
||||||
this.log = (...a) => {
|
this.log = () => {
|
||||||
if (!isDev)
|
if (!isDev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
console.log(...a);
|
|
||||||
};
|
};
|
||||||
this.prefix = '';
|
this.prefix = '';
|
||||||
this.prefixSocket = '';
|
this.prefixSocket = '';
|
||||||
|
|
@ -8,15 +8,20 @@ const load = require('load.js');
|
||||||
|
|
||||||
const {registerSW, listenSW} = require('./sw/register');
|
const {registerSW, listenSW} = require('./sw/register');
|
||||||
const {initSortPanel, sortPanel} = require('./sort.mjs');
|
const {initSortPanel, sortPanel} = require('./sort.mjs');
|
||||||
|
const Util = require('../common/util');
|
||||||
|
const CloudFunc = require('../common/cloudfunc.mjs');
|
||||||
|
const DOM = require('./dom');
|
||||||
|
const {createCloudCmd} = require('./client.mjs');
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === 'development';
|
const isDev = process.env.NODE_ENV === 'development';
|
||||||
|
|
||||||
module.exports = async (config) => {
|
module.exports = init;
|
||||||
globalThis.Util = require('../common/util');
|
|
||||||
globalThis.CloudFunc = require('../common/cloudfunc.mjs');
|
async function init(config) {
|
||||||
|
globalThis.CloudCmd = createCloudCmd(DOM);
|
||||||
globalThis.DOM = require('./dom');
|
globalThis.DOM = DOM;
|
||||||
globalThis.CloudCmd = require('./client');
|
globalThis.Util = Util;
|
||||||
|
globalThis.CloudFunc = CloudFunc;
|
||||||
|
|
||||||
await register(config);
|
await register(config);
|
||||||
|
|
||||||
|
|
@ -34,8 +39,9 @@ module.exports = async (config) => {
|
||||||
import('https://esm.sh/@putout/processor-html');
|
import('https://esm.sh/@putout/processor-html');
|
||||||
import('https://esm.sh/@putout/bundle');
|
import('https://esm.sh/@putout/bundle');
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
}
|
||||||
globalThis.CloudCmd = module.exports;
|
|
||||||
|
globalThis.CloudCmd = init;
|
||||||
|
|
||||||
function getPrefix(prefix) {
|
function getPrefix(prefix) {
|
||||||
if (!prefix)
|
if (!prefix)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ const _vim = require('./vim');
|
||||||
const setCurrentByChar = require('./set-current-by-char');
|
const setCurrentByChar = require('./set-current-by-char');
|
||||||
const {createBinder} = require('./binder');
|
const {createBinder} = require('./binder');
|
||||||
|
|
||||||
const Info = DOM.CurrentInfo;
|
|
||||||
const Chars = fullstore();
|
const Chars = fullstore();
|
||||||
|
|
||||||
const toggleVim = (keyCode, overrides = {}) => {
|
const toggleVim = (keyCode, overrides = {}) => {
|
||||||
|
|
@ -124,6 +123,7 @@ function fromCharCode(keyIdentifier) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function _switchKey(event) {
|
async function _switchKey(event) {
|
||||||
|
const Info = DOM.CurrentInfo;
|
||||||
let i;
|
let i;
|
||||||
let isSelected;
|
let isSelected;
|
||||||
let prev;
|
let prev;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {escapeRegExp} = require('../../common/util');
|
const {escapeRegExp} = require('../../common/util');
|
||||||
const Info = DOM.CurrentInfo;
|
|
||||||
|
|
||||||
module.exports = function setCurrentByChar(char, charStore) {
|
module.exports = function setCurrentByChar(char, charStore) {
|
||||||
|
const Info = DOM.CurrentInfo;
|
||||||
let firstByName;
|
let firstByName;
|
||||||
let skipCount = 0;
|
let skipCount = 0;
|
||||||
let setted = false;
|
let setted = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue