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