mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
Compare commits
14 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78e87796df | ||
|
|
75ad4415c4 | ||
|
|
c5d9bd7c1f | ||
|
|
f437a52ff0 | ||
|
|
7192a56e94 | ||
|
|
b9dd4f2676 | ||
|
|
e8cf3c92f9 | ||
|
|
d574a93d6d | ||
|
|
8a769fd512 | ||
|
|
3b409074c1 | ||
|
|
3b6b0b5a5b | ||
|
|
8876f050e0 | ||
|
|
8507282d55 | ||
|
|
f61b21eecc |
37 changed files with 298 additions and 289 deletions
|
|
@ -8,7 +8,6 @@
|
||||||
"*.md"
|
"*.md"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"tape/remove-skip": "off",
|
|
||||||
"package-json/add-type": "off"
|
"package-json/add-type": "off"
|
||||||
},
|
},
|
||||||
"match": {
|
"match": {
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ export default {
|
||||||
[`${modules}/config`]: `${dirModules}/config/index.js`,
|
[`${modules}/config`]: `${dirModules}/config/index.js`,
|
||||||
[`${modules}/contact`]: `${dirModules}/contact.js`,
|
[`${modules}/contact`]: `${dirModules}/contact.js`,
|
||||||
[`${modules}/upload`]: `${dirModules}/upload.js`,
|
[`${modules}/upload`]: `${dirModules}/upload.js`,
|
||||||
[`${modules}/operation`]: `${dirModules}/operation/index.js`,
|
[`${modules}/operation`]: `${dirModules}/operation/index.mjs`,
|
||||||
[`${modules}/konsole`]: `${dirModules}/konsole.js`,
|
[`${modules}/konsole`]: `${dirModules}/konsole.js`,
|
||||||
[`${modules}/terminal`]: `${dirModules}/terminal.js`,
|
[`${modules}/terminal`]: `${dirModules}/terminal.js`,
|
||||||
[`${modules}/terminal-run`]: `${dirModules}/terminal-run.js`,
|
[`${modules}/terminal-run`]: `${dirModules}/terminal-run.js`,
|
||||||
|
|
|
||||||
19
ChangeLog
19
ChangeLog
|
|
@ -1,3 +1,22 @@
|
||||||
|
2026.01.21, v19.1.9
|
||||||
|
|
||||||
|
feature:
|
||||||
|
- 75ad4415 cloudcmd: @putout/eslint-flat v4.0.0
|
||||||
|
- c5d9bd7c client: key: vim: get rid of mock-require
|
||||||
|
- f437a52f client: images: migrate to EMS
|
||||||
|
- 7192a56e client: dom: current-file: migrate to ESM
|
||||||
|
|
||||||
|
2026.01.20, v19.1.8
|
||||||
|
|
||||||
|
fix:
|
||||||
|
- 8a769fd5 client: modules: operation: no update after copy
|
||||||
|
|
||||||
|
feature:
|
||||||
|
- d574a93d client: key: migrate to ESM
|
||||||
|
- 3b409074 client: modules: operation: migrate to ESM
|
||||||
|
- 3b6b0b5a client: buffer: migrate to ESM
|
||||||
|
- 8876f050 cloudcmd: eslint-plugin-putout v30.0.0
|
||||||
|
|
||||||
2026.01.17, v19.1.7
|
2026.01.17, v19.1.7
|
||||||
|
|
||||||
feature:
|
feature:
|
||||||
|
|
|
||||||
4
HELP.md
4
HELP.md
|
|
@ -1,4 +1,4 @@
|
||||||
# Cloud Commander v19.1.7
|
# Cloud Commander v19.1.9
|
||||||
|
|
||||||
### [Main][MainURL] [Blog][BlogURL] [Support][SupportURL] [Demo][DemoURL]
|
### [Main][MainURL] [Blog][BlogURL] [Support][SupportURL] [Demo][DemoURL]
|
||||||
|
|
||||||
|
|
@ -1111,6 +1111,8 @@ There are a lot of ways to be involved in `Cloud Commander` development:
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
|
- *2026.01.21*, **[v19.1.9](//github.com/coderaiser/cloudcmd/releases/tag/v19.1.9)**
|
||||||
|
- *2026.01.20*, **[v19.1.8](//github.com/coderaiser/cloudcmd/releases/tag/v19.1.8)**
|
||||||
- *2026.01.17*, **[v19.1.7](//github.com/coderaiser/cloudcmd/releases/tag/v19.1.7)**
|
- *2026.01.17*, **[v19.1.7](//github.com/coderaiser/cloudcmd/releases/tag/v19.1.7)**
|
||||||
- *2026.01.16*, **[v19.1.6](//github.com/coderaiser/cloudcmd/releases/tag/v19.1.6)**
|
- *2026.01.16*, **[v19.1.6](//github.com/coderaiser/cloudcmd/releases/tag/v19.1.6)**
|
||||||
- *2026.01.16*, **[v19.1.5](//github.com/coderaiser/cloudcmd/releases/tag/v19.1.5)**
|
- *2026.01.16*, **[v19.1.5](//github.com/coderaiser/cloudcmd/releases/tag/v19.1.5)**
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Cloud Commander v19.1.7 [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Codacy][CodacyIMG]][CodacyURL] [![Gitter][GitterIMGURL]][GitterURL]
|
# Cloud Commander v19.1.9 [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Codacy][CodacyIMG]][CodacyURL] [![Gitter][GitterIMGURL]][GitterURL]
|
||||||
|
|
||||||
### [Main][MainURL] [Blog][BlogURL] [Support][SupportURL] [Demo][DemoURL]
|
### [Main][MainURL] [Blog][BlogURL] [Support][SupportURL] [Demo][DemoURL]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ import {tryToCatch} from 'try-to-catch';
|
||||||
import {addSlashToEnd} from 'format-io';
|
import {addSlashToEnd} from 'format-io';
|
||||||
import pascalCase from 'just-pascal-case';
|
import pascalCase from 'just-pascal-case';
|
||||||
import currify from 'currify';
|
import currify from 'currify';
|
||||||
import Images from './dom/images.js';
|
import * as Images from './dom/images.mjs';
|
||||||
import {unregisterSW} from './sw/register.js';
|
import {unregisterSW} from './sw/register.js';
|
||||||
import {getJsonFromFileTable} from './get-json-from-file-table.mjs';
|
import {getJsonFromFileTable} from './get-json-from-file-table.mjs';
|
||||||
import Key from './key/index.js';
|
import {Key} from './key/index.mjs';
|
||||||
import {
|
import {
|
||||||
apiURL,
|
apiURL,
|
||||||
formatMsg,
|
formatMsg,
|
||||||
|
|
|
||||||
|
|
@ -1,135 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/* global CloudCmd */
|
|
||||||
const tryToPromiseAll = require('../../common/try-to-promise-all');
|
|
||||||
const Storage = require('./storage');
|
|
||||||
const DOM = require('./');
|
|
||||||
|
|
||||||
module.exports = new BufferProto();
|
|
||||||
|
|
||||||
function BufferProto() {
|
|
||||||
const Info = DOM.CurrentInfo;
|
|
||||||
const CLASS = 'cut-file';
|
|
||||||
const COPY = 'copy';
|
|
||||||
const CUT = 'cut';
|
|
||||||
|
|
||||||
const Buffer = {
|
|
||||||
cut: callIfEnabled.bind(null, cut),
|
|
||||||
copy: callIfEnabled.bind(null, copy),
|
|
||||||
clear: callIfEnabled.bind(null, clear),
|
|
||||||
paste: callIfEnabled.bind(null, paste),
|
|
||||||
};
|
|
||||||
|
|
||||||
function showMessage(msg) {
|
|
||||||
DOM.Dialog.alert(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNames() {
|
|
||||||
const files = DOM.getActiveFiles();
|
|
||||||
|
|
||||||
return DOM.getFilenames(files);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addCutClass() {
|
|
||||||
const files = DOM.getActiveFiles();
|
|
||||||
|
|
||||||
for (const element of files) {
|
|
||||||
element.classList.add(CLASS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function rmCutClass() {
|
|
||||||
const files = DOM.getByClassAll(CLASS);
|
|
||||||
|
|
||||||
for (const element of files) {
|
|
||||||
element.classList.remove(CLASS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function callIfEnabled(callback) {
|
|
||||||
const is = CloudCmd.config('buffer');
|
|
||||||
|
|
||||||
if (is)
|
|
||||||
return callback();
|
|
||||||
|
|
||||||
showMessage('Buffer disabled in config!');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function readBuffer() {
|
|
||||||
const [e, cp, ct] = await tryToPromiseAll([
|
|
||||||
Storage.getJson(COPY),
|
|
||||||
Storage.getJson(CUT),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return [
|
|
||||||
e,
|
|
||||||
cp,
|
|
||||||
ct,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
async function copy() {
|
|
||||||
const names = getNames();
|
|
||||||
const from = Info.dirPath;
|
|
||||||
|
|
||||||
await clear();
|
|
||||||
|
|
||||||
if (!names.length)
|
|
||||||
return;
|
|
||||||
|
|
||||||
await Storage.remove(CUT);
|
|
||||||
await Storage.setJson(COPY, {
|
|
||||||
from,
|
|
||||||
names,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function cut() {
|
|
||||||
const names = getNames();
|
|
||||||
const from = Info.dirPath;
|
|
||||||
|
|
||||||
await clear();
|
|
||||||
|
|
||||||
if (!names.length)
|
|
||||||
return;
|
|
||||||
|
|
||||||
addCutClass();
|
|
||||||
|
|
||||||
await Storage.setJson(CUT, {
|
|
||||||
from,
|
|
||||||
names,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function clear() {
|
|
||||||
await Storage.remove(COPY);
|
|
||||||
await Storage.remove(CUT);
|
|
||||||
|
|
||||||
rmCutClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function paste() {
|
|
||||||
const [error, cp, ct] = await readBuffer();
|
|
||||||
|
|
||||||
if (error || !cp && !ct)
|
|
||||||
return showMessage(error || 'Buffer is empty!');
|
|
||||||
|
|
||||||
const opStr = cp ? 'copy' : 'move';
|
|
||||||
const data = cp || ct;
|
|
||||||
const {Operation} = CloudCmd;
|
|
||||||
const msg = 'Path is same!';
|
|
||||||
const to = Info.dirPath;
|
|
||||||
|
|
||||||
if (data.from === to)
|
|
||||||
return showMessage(msg);
|
|
||||||
|
|
||||||
Operation.show(opStr, {
|
|
||||||
...data,
|
|
||||||
to,
|
|
||||||
});
|
|
||||||
|
|
||||||
await clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Buffer;
|
|
||||||
}
|
|
||||||
124
client/dom/buffer.mjs
Normal file
124
client/dom/buffer.mjs
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
/* global CloudCmd*/
|
||||||
|
import tryToPromiseAll from '../../common/try-to-promise-all.js';
|
||||||
|
import Storage from './storage.js';
|
||||||
|
|
||||||
|
const CLASS = 'cut-file';
|
||||||
|
const COPY = 'copy';
|
||||||
|
const CUT = 'cut';
|
||||||
|
|
||||||
|
function showMessage(msg) {
|
||||||
|
globalThis.DOM.Dialog.alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNames() {
|
||||||
|
const {DOM} = globalThis;
|
||||||
|
const files = DOM.getActiveFiles();
|
||||||
|
|
||||||
|
return DOM.getFilenames(files);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addCutClass() {
|
||||||
|
const {DOM} = globalThis;
|
||||||
|
const files = DOM.getActiveFiles();
|
||||||
|
|
||||||
|
for (const element of files) {
|
||||||
|
element.classList.add(CLASS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function rmCutClass() {
|
||||||
|
const {DOM} = globalThis;
|
||||||
|
const files = DOM.getByClassAll(CLASS);
|
||||||
|
|
||||||
|
for (const element of files) {
|
||||||
|
element.classList.remove(CLASS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkEnabled = (fn) => () => {
|
||||||
|
const is = CloudCmd.config('buffer');
|
||||||
|
|
||||||
|
if (is)
|
||||||
|
return fn();
|
||||||
|
|
||||||
|
showMessage('Buffer disabled in config!');
|
||||||
|
};
|
||||||
|
|
||||||
|
async function readBuffer() {
|
||||||
|
const [e, cp, ct] = await tryToPromiseAll([
|
||||||
|
Storage.getJson(COPY),
|
||||||
|
Storage.getJson(CUT),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return [
|
||||||
|
e,
|
||||||
|
cp,
|
||||||
|
ct,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const copy = checkEnabled(async () => {
|
||||||
|
const Info = globalThis.DOM.CurrentInfo;
|
||||||
|
const names = getNames();
|
||||||
|
const from = Info.dirPath;
|
||||||
|
|
||||||
|
await clear();
|
||||||
|
|
||||||
|
if (!names.length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await Storage.remove(CUT);
|
||||||
|
await Storage.setJson(COPY, {
|
||||||
|
from,
|
||||||
|
names,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
export const cut = checkEnabled(async () => {
|
||||||
|
const Info = globalThis.DOM.CurrentInfo;
|
||||||
|
const names = getNames();
|
||||||
|
const from = Info.dirPath;
|
||||||
|
|
||||||
|
await clear();
|
||||||
|
|
||||||
|
if (!names.length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
addCutClass();
|
||||||
|
|
||||||
|
await Storage.setJson(CUT, {
|
||||||
|
from,
|
||||||
|
names,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
export const clear = checkEnabled(async () => {
|
||||||
|
await Storage.remove(COPY);
|
||||||
|
await Storage.remove(CUT);
|
||||||
|
|
||||||
|
rmCutClass();
|
||||||
|
});
|
||||||
|
|
||||||
|
export const paste = checkEnabled(async () => {
|
||||||
|
const Info = globalThis.DOM.CurrentInfo;
|
||||||
|
const [error, cp, ct] = await readBuffer();
|
||||||
|
|
||||||
|
if (error || !cp && !ct)
|
||||||
|
return showMessage(error || 'Buffer is empty!');
|
||||||
|
|
||||||
|
const opStr = cp ? 'copy' : 'move';
|
||||||
|
const data = cp || ct;
|
||||||
|
const {Operation} = CloudCmd;
|
||||||
|
const msg = 'Path is same!';
|
||||||
|
const to = Info.dirPath;
|
||||||
|
|
||||||
|
if (data.from === to)
|
||||||
|
return showMessage(msg);
|
||||||
|
|
||||||
|
Operation.show(opStr, {
|
||||||
|
...data,
|
||||||
|
to,
|
||||||
|
});
|
||||||
|
|
||||||
|
await clear();
|
||||||
|
});
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/* global DOM */
|
/* global DOM */
|
||||||
/* global CloudCmd */
|
/* global CloudCmd */
|
||||||
const createElement = require('@cloudcmd/create-element');
|
import createElement from '@cloudcmd/create-element';
|
||||||
const {encode, decode} = require('../../common/entity');
|
import {encode, decode} from '../../common/entity.js';
|
||||||
const {getTitle, FS} = require('../../common/cloudfunc.mjs');
|
import {getTitle, FS} from '../../common/cloudfunc.mjs';
|
||||||
|
|
||||||
let Title;
|
let Title;
|
||||||
|
|
||||||
|
|
@ -12,14 +10,15 @@ const CURRENT_FILE = 'current-file';
|
||||||
const encodeNBSP = (a) => a?.replace('\xa0', ' ');
|
const encodeNBSP = (a) => a?.replace('\xa0', ' ');
|
||||||
const decodeNBSP = (a) => a?.replace(' ', '\xa0');
|
const decodeNBSP = (a) => a?.replace(' ', '\xa0');
|
||||||
|
|
||||||
module.exports._CURRENT_FILE = CURRENT_FILE;
|
export const _CURRENT_FILE = CURRENT_FILE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set name from current (or param) file
|
* set name from current (or param) file
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param current
|
* @param current
|
||||||
*/
|
*/
|
||||||
module.exports.setCurrentName = (name, current) => {
|
export const setCurrentName = (name, current) => {
|
||||||
const Info = DOM.CurrentInfo;
|
const Info = DOM.CurrentInfo;
|
||||||
const {link} = Info;
|
const {link} = Info;
|
||||||
const {prefix} = CloudCmd;
|
const {prefix} = CloudCmd;
|
||||||
|
|
@ -41,7 +40,7 @@ module.exports.setCurrentName = (name, current) => {
|
||||||
*
|
*
|
||||||
* @param currentFile
|
* @param currentFile
|
||||||
*/
|
*/
|
||||||
module.exports.getCurrentName = (currentFile) => {
|
export const getCurrentName = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
|
|
||||||
if (!current)
|
if (!current)
|
||||||
|
|
@ -68,18 +67,19 @@ const parseNameAttribute = (attribute) => {
|
||||||
return decodeNBSP(decodeURI(atob(attribute)));
|
return decodeNBSP(decodeURI(atob(attribute)));
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports._parseNameAttribute = parseNameAttribute;
|
export const _parseNameAttribute = parseNameAttribute;
|
||||||
|
|
||||||
const parseHrefAttribute = (prefix, attribute) => {
|
const parseHrefAttribute = (prefix, attribute) => {
|
||||||
attribute = attribute.replace(RegExp('^' + prefix + FS), '');
|
attribute = attribute.replace(RegExp('^' + prefix + FS), '');
|
||||||
return decode(decodeNBSP(attribute));
|
return decode(decodeNBSP(attribute));
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports._parseHrefAttribute = parseHrefAttribute;
|
export const _parseHrefAttribute = parseHrefAttribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get current direcotory path
|
* get current direcotory path
|
||||||
*/
|
*/
|
||||||
module.exports.getCurrentDirPath = (panel = DOM.getPanel()) => {
|
export const getCurrentDirPath = (panel = DOM.getPanel()) => {
|
||||||
const path = DOM.getByDataName('js-path', panel);
|
const path = DOM.getByDataName('js-path', panel);
|
||||||
return path.textContent;
|
return path.textContent;
|
||||||
};
|
};
|
||||||
|
|
@ -89,7 +89,7 @@ module.exports.getCurrentDirPath = (panel = DOM.getPanel()) => {
|
||||||
*
|
*
|
||||||
* @param currentFile - current file by default
|
* @param currentFile - current file by default
|
||||||
*/
|
*/
|
||||||
module.exports.getCurrentPath = (currentFile) => {
|
export const getCurrentPath = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const [element] = DOM.getByTag('a', current);
|
const [element] = DOM.getByTag('a', current);
|
||||||
const {prefix} = CloudCmd;
|
const {prefix} = CloudCmd;
|
||||||
|
|
@ -100,7 +100,7 @@ module.exports.getCurrentPath = (currentFile) => {
|
||||||
/**
|
/**
|
||||||
* get current direcotory name
|
* get current direcotory name
|
||||||
*/
|
*/
|
||||||
module.exports.getCurrentDirName = () => {
|
export const getCurrentDirName = () => {
|
||||||
const href = DOM
|
const href = DOM
|
||||||
.getCurrentDirPath()
|
.getCurrentDirPath()
|
||||||
.replace(/\/$/, '');
|
.replace(/\/$/, '');
|
||||||
|
|
@ -113,7 +113,7 @@ module.exports.getCurrentDirName = () => {
|
||||||
/**
|
/**
|
||||||
* get current direcotory path
|
* get current direcotory path
|
||||||
*/
|
*/
|
||||||
module.exports.getParentDirPath = (panel) => {
|
export const getParentDirPath = (panel) => {
|
||||||
const path = DOM.getCurrentDirPath(panel);
|
const path = DOM.getCurrentDirPath(panel);
|
||||||
const dirName = DOM.getCurrentDirName() + '/';
|
const dirName = DOM.getCurrentDirName() + '/';
|
||||||
const index = path.lastIndexOf(dirName);
|
const index = path.lastIndexOf(dirName);
|
||||||
|
|
@ -127,7 +127,7 @@ module.exports.getParentDirPath = (panel) => {
|
||||||
/**
|
/**
|
||||||
* get not current direcotory path
|
* get not current direcotory path
|
||||||
*/
|
*/
|
||||||
module.exports.getNotCurrentDirPath = () => {
|
export const getNotCurrentDirPath = () => {
|
||||||
const panel = DOM.getPanel({
|
const panel = DOM.getPanel({
|
||||||
active: false,
|
active: false,
|
||||||
});
|
});
|
||||||
|
|
@ -140,14 +140,14 @@ module.exports.getNotCurrentDirPath = () => {
|
||||||
*
|
*
|
||||||
* @currentFile
|
* @currentFile
|
||||||
*/
|
*/
|
||||||
module.exports.getCurrentFile = () => {
|
export const getCurrentFile = () => {
|
||||||
return DOM.getByClass(CURRENT_FILE);
|
return DOM.getByClass(CURRENT_FILE);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get current file by name
|
* get current file by name
|
||||||
*/
|
*/
|
||||||
module.exports.getCurrentByName = (name, panel = DOM.CurrentInfo.panel) => {
|
export const getCurrentByName = (name, panel = DOM.CurrentInfo.panel) => {
|
||||||
const dataName = 'js-file-' + btoa(encodeURI(encodeNBSP(name)));
|
const dataName = 'js-file-' + btoa(encodeURI(encodeNBSP(name)));
|
||||||
return DOM.getByDataName(dataName, panel);
|
return DOM.getByDataName(dataName, panel);
|
||||||
};
|
};
|
||||||
|
|
@ -169,7 +169,7 @@ function unsetCurrentFile(currentFile) {
|
||||||
/**
|
/**
|
||||||
* unified way to set current file
|
* unified way to set current file
|
||||||
*/
|
*/
|
||||||
module.exports.setCurrentFile = (currentFile, options) => {
|
export const setCurrentFile = (currentFile, options) => {
|
||||||
const o = options;
|
const o = options;
|
||||||
const currentFileWas = DOM.getCurrentFile();
|
const currentFileWas = DOM.getCurrentFile();
|
||||||
|
|
||||||
|
|
@ -216,7 +216,7 @@ module.exports.setCurrentFile = (currentFile, options) => {
|
||||||
return DOM;
|
return DOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setCurrentByName = (name) => {
|
export const setCurrentByName = (name) => {
|
||||||
const current = DOM.getCurrentByName(name);
|
const current = DOM.getCurrentByName(name);
|
||||||
return DOM.setCurrentFile(current);
|
return DOM.setCurrentFile(current);
|
||||||
};
|
};
|
||||||
|
|
@ -227,7 +227,7 @@ this.setCurrentByName = (name) => {
|
||||||
* @param layer - element
|
* @param layer - element
|
||||||
* @param - position {x, y}
|
* @param - position {x, y}
|
||||||
*/
|
*/
|
||||||
module.exports.getCurrentByPosition = ({x, y}) => {
|
export const getCurrentByPosition = ({x, y}) => {
|
||||||
const element = document.elementFromPoint(x, y);
|
const element = document.elementFromPoint(x, y);
|
||||||
|
|
||||||
const getEl = (el) => {
|
const getEl = (el) => {
|
||||||
|
|
@ -259,7 +259,7 @@ module.exports.getCurrentByPosition = ({x, y}) => {
|
||||||
*
|
*
|
||||||
* @param currentFile
|
* @param currentFile
|
||||||
*/
|
*/
|
||||||
module.exports.isCurrentFile = (currentFile) => {
|
export const isCurrentFile = (currentFile) => {
|
||||||
if (!currentFile)
|
if (!currentFile)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -271,7 +271,7 @@ module.exports.isCurrentFile = (currentFile) => {
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
module.exports.setTitle = (name) => {
|
export const setTitle = (name) => {
|
||||||
if (!Title)
|
if (!Title)
|
||||||
Title = DOM.getByTag('title')[0] || createElement('title', {
|
Title = DOM.getByTag('title')[0] || createElement('title', {
|
||||||
innerHTML: name,
|
innerHTML: name,
|
||||||
|
|
@ -288,7 +288,7 @@ module.exports.setTitle = (name) => {
|
||||||
*
|
*
|
||||||
* @param currentFile
|
* @param currentFile
|
||||||
*/
|
*/
|
||||||
module.exports.isCurrentIsDir = (currentFile) => {
|
export const isCurrentIsDir = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const path = DOM.getCurrentPath(current);
|
const path = DOM.getCurrentPath(current);
|
||||||
const fileType = DOM.getCurrentType(current);
|
const fileType = DOM.getCurrentType(current);
|
||||||
|
|
@ -299,7 +299,7 @@ module.exports.isCurrentIsDir = (currentFile) => {
|
||||||
return isDir || isZip;
|
return isDir || isZip;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getCurrentType = (currentFile) => {
|
export const getCurrentType = (currentFile) => {
|
||||||
const current = currentFile || DOM.getCurrentFile();
|
const current = currentFile || DOM.getCurrentFile();
|
||||||
const el = DOM.getByDataName('js-type', current);
|
const el = DOM.getByDataName('js-type', current);
|
||||||
const type = el.className
|
const type = el.className
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
'use strict';
|
import {test, stub} from 'supertape';
|
||||||
|
import {create} from 'auto-globals';
|
||||||
|
import wraptile from 'wraptile';
|
||||||
|
import * as currentFile from './current-file.mjs';
|
||||||
|
|
||||||
const {test, stub} = require('supertape');
|
|
||||||
|
|
||||||
const {create} = require('auto-globals');
|
|
||||||
const wraptile = require('wraptile');
|
|
||||||
const currentFile = require('./current-file');
|
|
||||||
const id = (a) => a;
|
const id = (a) => a;
|
||||||
|
|
||||||
const returns = wraptile(id);
|
const returns = wraptile(id);
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
/* global CloudCmd */
|
/* global CloudCmd */
|
||||||
const philip = require('philip');
|
const philip = require('philip');
|
||||||
|
|
||||||
const Images = require('./images');
|
const Images = require('./images.mjs');
|
||||||
const {FS} = require('../../common/cloudfunc.mjs');
|
const {FS} = require('../../common/cloudfunc.mjs');
|
||||||
const DOM = require('.');
|
const DOM = require('.');
|
||||||
const Dialog = require('./dialog');
|
const Dialog = require('./dialog');
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
/* global DOM */
|
/* global DOM */
|
||||||
|
import createElement from '@cloudcmd/create-element';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const createElement = require('@cloudcmd/create-element');
|
|
||||||
|
|
||||||
const Images = module.exports;
|
|
||||||
|
|
||||||
const LOADING = 'loading';
|
const LOADING = 'loading';
|
||||||
const HIDDEN = 'hidden';
|
const HIDDEN = 'hidden';
|
||||||
|
|
@ -12,7 +7,8 @@ const ERROR = 'error';
|
||||||
|
|
||||||
const getLoadingType = () => isSVG() ? '-svg' : '-gif';
|
const getLoadingType = () => isSVG() ? '-svg' : '-gif';
|
||||||
|
|
||||||
module.exports.get = getElement;
|
export const get = getElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check SVG SMIL animation support
|
* check SVG SMIL animation support
|
||||||
*/
|
*/
|
||||||
|
|
@ -40,7 +36,7 @@ function getElement() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Функция создаёт картинку загрузки */
|
/* Функция создаёт картинку загрузки */
|
||||||
module.exports.loading = () => {
|
export const loading = () => {
|
||||||
const element = getElement();
|
const element = getElement();
|
||||||
const {classList} = element;
|
const {classList} = element;
|
||||||
const loadingImage = LOADING + getLoadingType();
|
const loadingImage = LOADING + getLoadingType();
|
||||||
|
|
@ -52,7 +48,7 @@ module.exports.loading = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Функция создаёт картинку ошибки загрузки */
|
/* Функция создаёт картинку ошибки загрузки */
|
||||||
module.exports.error = () => {
|
export const error = () => {
|
||||||
const element = getElement();
|
const element = getElement();
|
||||||
const {classList} = element;
|
const {classList} = element;
|
||||||
const loadingImage = LOADING + getLoadingType();
|
const loadingImage = LOADING + getLoadingType();
|
||||||
|
|
@ -63,14 +59,21 @@ module.exports.error = () => {
|
||||||
return element;
|
return element;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.show = show;
|
show.load = show;
|
||||||
module.exports.show.load = show;
|
show.error = (text) => {
|
||||||
module.exports.show.error = error;
|
const image = Images.error();
|
||||||
|
|
||||||
|
DOM.show(image);
|
||||||
|
image.title = text;
|
||||||
|
|
||||||
|
return image;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function shows loading spinner
|
* Function shows loading spinner
|
||||||
* position = {top: true};
|
* position = {top: true};
|
||||||
*/
|
*/
|
||||||
function show(position, panel) {
|
export function show(position, panel) {
|
||||||
const image = Images.loading();
|
const image = Images.loading();
|
||||||
const parent = image.parentElement;
|
const parent = image.parentElement;
|
||||||
const refreshButton = DOM.getRefreshButton(panel);
|
const refreshButton = DOM.getRefreshButton(panel);
|
||||||
|
|
@ -96,19 +99,10 @@ function show(position, panel) {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
function error(text) {
|
|
||||||
const image = Images.error();
|
|
||||||
|
|
||||||
DOM.show(image);
|
|
||||||
image.title = text;
|
|
||||||
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hide load image
|
* hide load image
|
||||||
*/
|
*/
|
||||||
module.exports.hide = () => {
|
export const hide = () => {
|
||||||
const element = Images.get();
|
const element = Images.get();
|
||||||
|
|
||||||
DOM.hide(element);
|
DOM.hide(element);
|
||||||
|
|
@ -116,7 +110,7 @@ module.exports.hide = () => {
|
||||||
return Images;
|
return Images;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.setProgress = (value, title) => {
|
export const setProgress = (value, title) => {
|
||||||
const DATA = 'data-progress';
|
const DATA = 'data-progress';
|
||||||
const element = Images.get();
|
const element = Images.get();
|
||||||
|
|
||||||
|
|
@ -131,7 +125,7 @@ module.exports.setProgress = (value, title) => {
|
||||||
return Images;
|
return Images;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.clearProgress = () => {
|
export const clearProgress = () => {
|
||||||
const DATA = 'data-progress';
|
const DATA = 'data-progress';
|
||||||
const element = Images.get();
|
const element = Images.get();
|
||||||
|
|
||||||
|
|
@ -143,3 +137,13 @@ module.exports.clearProgress = () => {
|
||||||
|
|
||||||
return Images;
|
return Images;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const Images = {
|
||||||
|
clearProgress,
|
||||||
|
setProgress,
|
||||||
|
show,
|
||||||
|
hide,
|
||||||
|
get,
|
||||||
|
error,
|
||||||
|
loading,
|
||||||
|
};
|
||||||
|
|
@ -3,12 +3,12 @@
|
||||||
/* global CloudCmd */
|
/* global CloudCmd */
|
||||||
const Util = require('../../common/util');
|
const Util = require('../../common/util');
|
||||||
|
|
||||||
const Images = require('./images');
|
const Images = require('./images.mjs');
|
||||||
const RESTful = require('./rest');
|
const RESTful = require('./rest');
|
||||||
const Storage = require('./storage');
|
const Storage = require('./storage');
|
||||||
const renameCurrent = require('./operations/rename-current');
|
const renameCurrent = require('./operations/rename-current');
|
||||||
|
|
||||||
const CurrentFile = require('./current-file');
|
const CurrentFile = require('./current-file.mjs');
|
||||||
const DOMTree = require('./dom-tree');
|
const DOMTree = require('./dom-tree');
|
||||||
|
|
||||||
const Cmd = module.exports;
|
const Cmd = module.exports;
|
||||||
|
|
@ -32,7 +32,7 @@ DOM.CurrentInfo = CurrentInfo;
|
||||||
module.exports = DOM;
|
module.exports = DOM;
|
||||||
|
|
||||||
DOM.uploadDirectory = require('./directory');
|
DOM.uploadDirectory = require('./directory');
|
||||||
DOM.Buffer = require('./buffer');
|
DOM.Buffer = require('./buffer.mjs');
|
||||||
DOM.Events = require('#dom/events');
|
DOM.Events = require('#dom/events');
|
||||||
|
|
||||||
const loadRemote = require('./load-remote');
|
const loadRemote = require('./load-remote');
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
/* global CloudCmd */
|
/* global CloudCmd */
|
||||||
const {promisify} = require('es6-promisify');
|
const {promisify} = require('es6-promisify');
|
||||||
|
|
||||||
const Images = require('../images');
|
const Images = require('../images.mjs');
|
||||||
const load = require('../load');
|
const load = require('../load');
|
||||||
|
|
||||||
module.exports = promisify((params, callback) => {
|
module.exports = promisify((params, callback) => {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ const itype = require('itype');
|
||||||
const jonny = require('jonny');
|
const jonny = require('jonny');
|
||||||
const Emitify = require('emitify');
|
const Emitify = require('emitify');
|
||||||
const exec = require('execon');
|
const exec = require('execon');
|
||||||
const Images = require('./images');
|
const Images = require('./images.mjs');
|
||||||
|
|
||||||
module.exports.getIdBySrc = getIdBySrc;
|
module.exports.getIdBySrc = getIdBySrc;
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ const _Dialog = require('../dialog');
|
||||||
const Storage = require('../storage');
|
const Storage = require('../storage');
|
||||||
const RESTful = require('../rest');
|
const RESTful = require('../rest');
|
||||||
|
|
||||||
const _currentFile = require('../current-file');
|
const _currentFile = require('../current-file.mjs');
|
||||||
|
|
||||||
module.exports = async (current, overrides = {}) => {
|
module.exports = async (current, overrides = {}) => {
|
||||||
const {
|
const {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ const {tryToCatch} = require('try-to-catch');
|
||||||
|
|
||||||
const {encode} = require('../../common/entity');
|
const {encode} = require('../../common/entity');
|
||||||
|
|
||||||
const Images = require('./images');
|
const Images = require('./images.mjs');
|
||||||
const IO = require('./io');
|
const IO = require('./io');
|
||||||
const Dialog = require('./dialog');
|
const Dialog = require('./dialog');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ const {eachSeries} = require('execon');
|
||||||
const wraptile = require('wraptile');
|
const wraptile = require('wraptile');
|
||||||
|
|
||||||
const load = require('./load');
|
const load = require('./load');
|
||||||
const Images = require('./images');
|
const Images = require('./images.mjs');
|
||||||
const {alert} = require('./dialog');
|
const {alert} = require('./dialog');
|
||||||
|
|
||||||
const {FS} = require('../../common/cloudfunc.mjs');
|
const {FS} = require('../../common/cloudfunc.mjs');
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/* global CloudCmd, DOM */
|
/* global CloudCmd, DOM */
|
||||||
const clipboard = require('@cloudcmd/clipboard');
|
import clipboard from '@cloudcmd/clipboard';
|
||||||
const {fullstore} = require('fullstore');
|
import {fullstore} from 'fullstore';
|
||||||
|
import * as Events from '#dom/events';
|
||||||
const Buffer = require('../dom/buffer');
|
import * as Buffer from '../dom/buffer.mjs';
|
||||||
const Events = require('#dom/events');
|
import KEY from './key.js';
|
||||||
const KEY = require('./key');
|
import _vim from './vim/index.js';
|
||||||
|
import setCurrentByChar from './set-current-by-char.js';
|
||||||
const _vim = require('./vim');
|
import {createBinder} from './binder.js';
|
||||||
const setCurrentByChar = require('./set-current-by-char');
|
|
||||||
const {createBinder} = require('./binder');
|
|
||||||
|
|
||||||
const Chars = fullstore();
|
const Chars = fullstore();
|
||||||
|
|
||||||
|
|
@ -28,13 +24,16 @@ Chars([]);
|
||||||
const {assign} = Object;
|
const {assign} = Object;
|
||||||
const binder = createBinder();
|
const binder = createBinder();
|
||||||
|
|
||||||
module.exports = assign(binder, KEY);
|
const bind = () => {
|
||||||
module.exports.bind = () => {
|
|
||||||
Events.addKey(listener, true);
|
Events.addKey(listener, true);
|
||||||
binder.setBind();
|
binder.setBind();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports._listener = listener;
|
export const Key = assign(binder, KEY, {
|
||||||
|
bind,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const _listener = listener;
|
||||||
|
|
||||||
function getChar(event) {
|
function getChar(event) {
|
||||||
/*
|
/*
|
||||||
|
|
@ -7,7 +7,8 @@ const supertape = require('supertape');
|
||||||
|
|
||||||
const {ESC} = require('./key');
|
const {ESC} = require('./key');
|
||||||
|
|
||||||
const {_listener, setBind} = require('.');
|
const {Key, _listener} = require('./index.mjs');
|
||||||
|
|
||||||
const {getDOM, getCloudCmd} = require('./vim/globals.fixture');
|
const {getDOM, getCloudCmd} = require('./vim/globals.fixture');
|
||||||
const test = autoGlobals(supertape);
|
const test = autoGlobals(supertape);
|
||||||
const {stub} = supertape;
|
const {stub} = supertape;
|
||||||
|
|
@ -26,7 +27,7 @@ test('cloudcmd: client: key: enable vim', async (t) => {
|
||||||
altKey: false,
|
altKey: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
setBind();
|
Key.setBind();
|
||||||
|
|
||||||
await _listener(event, {
|
await _listener(event, {
|
||||||
vim,
|
vim,
|
||||||
|
|
@ -48,7 +49,7 @@ test('cloudcmd: client: key: disable vim', async (t) => {
|
||||||
altKey: false,
|
altKey: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
setBind();
|
Key.setBind();
|
||||||
await _listener(event, {
|
await _listener(event, {
|
||||||
config,
|
config,
|
||||||
_config,
|
_config,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ module.exports = (key, event, overrides = {}) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const operations = getOperations(event, deps);
|
const operations = getOperations(event, deps);
|
||||||
|
|
||||||
vim(key, operations, deps);
|
vim(key, operations, deps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -38,9 +39,13 @@ const getOperations = (event, deps) => {
|
||||||
|
|
||||||
toggleSelectedFile,
|
toggleSelectedFile,
|
||||||
Buffer = {},
|
Buffer = {},
|
||||||
|
createFindNext = _createFindNext,
|
||||||
} = deps;
|
} = deps;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
findNext: createFindNext({
|
||||||
|
setCurrentByName,
|
||||||
|
}),
|
||||||
escape: unselectFiles,
|
escape: unselectFiles,
|
||||||
|
|
||||||
remove: () => {
|
remove: () => {
|
||||||
|
|
@ -118,11 +123,6 @@ const getOperations = (event, deps) => {
|
||||||
setCurrentByName(result);
|
setCurrentByName(result);
|
||||||
},
|
},
|
||||||
|
|
||||||
findNext: () => {
|
|
||||||
const name = finder.findNext();
|
|
||||||
setCurrentByName(name);
|
|
||||||
},
|
|
||||||
|
|
||||||
findPrevious: () => {
|
findPrevious: () => {
|
||||||
const name = finder.findPrevious();
|
const name = finder.findPrevious();
|
||||||
setCurrentByName(name);
|
setCurrentByName(name);
|
||||||
|
|
@ -131,3 +131,10 @@ const getOperations = (event, deps) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.selectFile = selectFileNotParent;
|
module.exports.selectFile = selectFileNotParent;
|
||||||
|
|
||||||
|
const _createFindNext = (overrides = {}) => () => {
|
||||||
|
const {setCurrentByName} = overrides;
|
||||||
|
const name = finder.findNext();
|
||||||
|
|
||||||
|
setCurrentByName(name);
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -570,17 +570,13 @@ test('cloudcmd: client: find', (t) => {
|
||||||
|
|
||||||
test('cloudcmd: client: key: n', (t) => {
|
test('cloudcmd: client: key: n', (t) => {
|
||||||
const findNext = stub();
|
const findNext = stub();
|
||||||
|
const createFindNext = stub().returns(findNext);
|
||||||
|
|
||||||
mockRequire(pathFind, {
|
|
||||||
findNext,
|
|
||||||
});
|
|
||||||
|
|
||||||
const vim = reRequire(pathVim);
|
|
||||||
const event = {};
|
const event = {};
|
||||||
|
|
||||||
vim('n', event);
|
vim('n', event, {
|
||||||
|
createFindNext,
|
||||||
stopAll();
|
});
|
||||||
|
|
||||||
t.calledWithNoArgs(findNext, 'should call findNext');
|
t.calledWithNoArgs(findNext, 'should call findNext');
|
||||||
t.end();
|
t.end();
|
||||||
|
|
@ -664,7 +660,7 @@ test('cloudcmd: client: vim: terminal', (t) => {
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('cloudcmd: client: vim: edit', async (t) => {
|
test('cloudcmd: client: vim: edit', async (t) => {
|
||||||
globalThis.DOM = getDOM();
|
globalThis.DOM = getDOM();
|
||||||
globalThis.CloudCmd = getCloudCmd();
|
globalThis.CloudCmd = getCloudCmd();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ const load = require('load.js');
|
||||||
const {ajax} = require('../dom/load');
|
const {ajax} = require('../dom/load');
|
||||||
|
|
||||||
const Files = require('../dom/files');
|
const Files = require('../dom/files');
|
||||||
const Images = require('../dom/images');
|
const Images = require('../dom/images.mjs');
|
||||||
const {log} = CloudCmd;
|
const {log} = CloudCmd;
|
||||||
|
|
||||||
const upload = currify(_upload);
|
const upload = currify(_upload);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ const load = require('load.js');
|
||||||
const createElement = require('@cloudcmd/create-element');
|
const createElement = require('@cloudcmd/create-element');
|
||||||
|
|
||||||
const input = require('./input');
|
const input = require('./input');
|
||||||
const Images = require('../../dom/images');
|
const Images = require('../../dom/images.mjs');
|
||||||
const Events = require('#dom/events');
|
const Events = require('#dom/events');
|
||||||
const Files = require('../../dom/files');
|
const Files = require('../../dom/files');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
CloudCmd.Contact = exports;
|
CloudCmd.Contact = exports;
|
||||||
|
|
||||||
const olark = require('@cloudcmd/olark');
|
const olark = require('@cloudcmd/olark');
|
||||||
const Images = require('../dom/images');
|
const Images = require('../dom/images.mjs');
|
||||||
|
|
||||||
const {Events} = DOM;
|
const {Events} = DOM;
|
||||||
const {Key} = CloudCmd;
|
const {Key} = CloudCmd;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
/* global CloudCmd */
|
/* global CloudCmd */
|
||||||
CloudCmd.Help = exports;
|
CloudCmd.Help = exports;
|
||||||
|
|
||||||
const Images = require('../dom/images');
|
const Images = require('../dom/images.mjs');
|
||||||
|
|
||||||
module.exports.init = () => {
|
module.exports.init = () => {
|
||||||
Images.show.load('top');
|
Images.show.load('top');
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ const {tryToCatch} = require('try-to-catch');
|
||||||
const loadJS = require('load.js').js;
|
const loadJS = require('load.js').js;
|
||||||
const createElement = require('@cloudcmd/create-element');
|
const createElement = require('@cloudcmd/create-element');
|
||||||
|
|
||||||
const Images = require('../dom/images');
|
const Images = require('../dom/images.mjs');
|
||||||
const {Dialog, CurrentInfo: Info} = DOM;
|
const {Dialog, CurrentInfo: Info} = DOM;
|
||||||
|
|
||||||
const rmLastSlash = (a) => a.replace(/\/$/, '') || '/';
|
const rmLastSlash = (a) => a.replace(/\/$/, '') || '/';
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ CloudCmd.Markdown = exports;
|
||||||
|
|
||||||
const createElement = require('@cloudcmd/create-element');
|
const createElement = require('@cloudcmd/create-element');
|
||||||
|
|
||||||
const Images = require('../dom/images');
|
const Images = require('../dom/images.mjs');
|
||||||
const {Markdown} = require('../dom/rest');
|
const {Markdown} = require('../dom/rest');
|
||||||
const {alert} = require('../dom/dialog');
|
const {alert} = require('../dom/dialog');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,20 @@
|
||||||
/* global CloudCmd */
|
import currify from 'currify';
|
||||||
/* global Util */
|
import wraptile from 'wraptile';
|
||||||
/* global DOM */
|
import {promisify} from 'es6-promisify';
|
||||||
/* global fileop */
|
import exec from 'execon';
|
||||||
|
import load from 'load.js';
|
||||||
|
import {tryToCatch} from 'try-to-catch';
|
||||||
|
import {encode} from '../../../common/entity.js';
|
||||||
|
import removeExtension from './remove-extension.js';
|
||||||
|
import {setListeners} from './set-listeners.mjs';
|
||||||
|
import getNextCurrentName from './get-next-current-name.js';
|
||||||
|
|
||||||
'use strict';
|
const {DOM, CloudCmd} = globalThis;
|
||||||
|
|
||||||
const currify = require('currify');
|
|
||||||
const wraptile = require('wraptile');
|
|
||||||
const {promisify} = require('es6-promisify');
|
|
||||||
const exec = require('execon');
|
|
||||||
const load = require('load.js');
|
|
||||||
const {tryToCatch} = require('try-to-catch');
|
|
||||||
|
|
||||||
const {encode} = require('../../../common/entity');
|
|
||||||
const removeExtension = require('./remove-extension');
|
|
||||||
const setListeners = require('./set-listeners');
|
|
||||||
const getNextCurrentName = require('./get-next-current-name');
|
|
||||||
|
|
||||||
const removeQuery = (a) => a.replace(/\?.*/, '');
|
const removeQuery = (a) => a.replace(/\?.*/, '');
|
||||||
|
|
||||||
const Name = 'Operation';
|
const Name = 'Operation';
|
||||||
|
|
||||||
CloudCmd[Name] = exports;
|
|
||||||
|
|
||||||
const {config} = CloudCmd;
|
const {config} = CloudCmd;
|
||||||
const {Dialog, Images} = DOM;
|
const {Dialog, Images} = DOM;
|
||||||
|
|
||||||
|
|
@ -53,7 +45,7 @@ const noFilesCheck = () => {
|
||||||
return is;
|
return is;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.init = promisify((callback) => {
|
export const init = promisify((callback) => {
|
||||||
showLoad();
|
showLoad();
|
||||||
|
|
||||||
exec.series([
|
exec.series([
|
||||||
|
|
@ -92,7 +84,7 @@ const onConnect = currify((fn, operator) => {
|
||||||
async function initOperations(prefix, socketPrefix, fn) {
|
async function initOperations(prefix, socketPrefix, fn) {
|
||||||
socketPrefix = `${socketPrefix}/fileop`;
|
socketPrefix = `${socketPrefix}/fileop`;
|
||||||
|
|
||||||
const operator = await fileop({
|
const operator = await globalThis.fileop({
|
||||||
prefix,
|
prefix,
|
||||||
socketPrefix,
|
socketPrefix,
|
||||||
});
|
});
|
||||||
|
|
@ -198,11 +190,11 @@ function getPacker(type) {
|
||||||
return packTarFn;
|
return packTarFn;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.hide = () => {
|
export const hide = () => {
|
||||||
CloudCmd.View.hide();
|
CloudCmd.View.hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.show = (operation, data) => {
|
export const show = (operation, data) => {
|
||||||
if (!Loaded)
|
if (!Loaded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -505,8 +497,14 @@ async function prompt(msg, to, names) {
|
||||||
return await Dialog.prompt(msg, to);
|
return await Dialog.prompt(msg, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalThis.CloudCmd[Name] = {
|
||||||
|
init,
|
||||||
|
hide,
|
||||||
|
show,
|
||||||
|
};
|
||||||
|
|
||||||
async function loadAll() {
|
async function loadAll() {
|
||||||
const {prefix} = CloudCmd;
|
const {prefix} = globalThis.CloudCmd;
|
||||||
const file = `${prefix}/fileop/fileop.js`;
|
const file = `${prefix}/fileop/fileop.js`;
|
||||||
|
|
||||||
const [error] = await tryToCatch(load.js, file);
|
const [error] = await tryToCatch(load.js, file);
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/* global DOM */
|
/* global DOM */
|
||||||
const forEachKey = require('for-each-key');
|
import forEachKey from 'for-each-key';
|
||||||
|
import wraptile from 'wraptile';
|
||||||
const wraptile = require('wraptile');
|
import format from './format.js';
|
||||||
const format = require('./format');
|
|
||||||
|
|
||||||
const {Dialog, Images} = DOM;
|
const {Dialog, Images} = DOM;
|
||||||
|
|
||||||
module.exports = (options) => (emitter) => {
|
export const setListeners = (options) => (emitter) => {
|
||||||
const {
|
const {
|
||||||
operation,
|
operation,
|
||||||
callback,
|
callback,
|
||||||
|
|
@ -43,10 +40,13 @@ module.exports = (options) => (emitter) => {
|
||||||
operation,
|
operation,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
let noProgress = true;
|
||||||
|
|
||||||
const listeners = {
|
const listeners = {
|
||||||
progress: (value) => {
|
progress: (value) => {
|
||||||
done = value === 100;
|
done = value === 100;
|
||||||
progress.setProgress(value);
|
progress.setProgress(value);
|
||||||
|
noProgress = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
end: () => {
|
end: () => {
|
||||||
|
|
@ -54,7 +54,7 @@ module.exports = (options) => (emitter) => {
|
||||||
forEachKey(removeListener, listeners);
|
forEachKey(removeListener, listeners);
|
||||||
progress.remove();
|
progress.remove();
|
||||||
|
|
||||||
if (lastError || done)
|
if (lastError || done || noProgress)
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -10,7 +10,7 @@ require('../../css/terminal.css');
|
||||||
const exec = require('execon');
|
const exec = require('execon');
|
||||||
const load = require('load.js');
|
const load = require('load.js');
|
||||||
const DOM = require('../dom');
|
const DOM = require('../dom');
|
||||||
const Images = require('../dom/images');
|
const Images = require('../dom/images.mjs');
|
||||||
|
|
||||||
const {Dialog} = DOM;
|
const {Dialog} = DOM;
|
||||||
const {Key, config} = CloudCmd;
|
const {Key, config} = CloudCmd;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ require('../../css/terminal.css');
|
||||||
const exec = require('execon');
|
const exec = require('execon');
|
||||||
const load = require('load.js');
|
const load = require('load.js');
|
||||||
const DOM = require('../dom');
|
const DOM = require('../dom');
|
||||||
const Images = require('../dom/images');
|
const Images = require('../dom/images.mjs');
|
||||||
|
|
||||||
const loadParallel = load.parallel;
|
const loadParallel = load.parallel;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ CloudCmd.Upload = exports;
|
||||||
|
|
||||||
const createElement = require('@cloudcmd/create-element');
|
const createElement = require('@cloudcmd/create-element');
|
||||||
const Files = require('../dom/files');
|
const Files = require('../dom/files');
|
||||||
const Images = require('../dom/images');
|
const Images = require('../dom/images.mjs');
|
||||||
const uploadFiles = require('../dom/upload-files');
|
const uploadFiles = require('../dom/upload-files');
|
||||||
|
|
||||||
module.exports.init = async () => {
|
module.exports.init = async () => {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ const {tryCatch} = require('try-catch');
|
||||||
const {tryToCatch} = require('try-to-catch');
|
const {tryToCatch} = require('try-to-catch');
|
||||||
const {codeFrameColumns} = require('@babel/code-frame');
|
const {codeFrameColumns} = require('@babel/code-frame');
|
||||||
|
|
||||||
const Images = require('../../dom/images');
|
const Images = require('../../dom/images.mjs');
|
||||||
const Dialog = require('../../dom/dialog');
|
const Dialog = require('../../dom/dialog');
|
||||||
const getUserMenu = require('./get-user-menu');
|
const getUserMenu = require('./get-user-menu');
|
||||||
const navigate = require('./navigate');
|
const navigate = require('./navigate');
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ const {
|
||||||
|
|
||||||
const Files = require('../../dom/files');
|
const Files = require('../../dom/files');
|
||||||
const Events = require('#dom/events');
|
const Events = require('#dom/events');
|
||||||
const Images = require('../../dom/images');
|
const Images = require('../../dom/images.mjs');
|
||||||
|
|
||||||
const {encode} = require('../../../common/entity');
|
const {encode} = require('../../../common/entity');
|
||||||
const isString = (a) => typeof a === 'string';
|
const isString = (a) => typeof a === 'string';
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,7 @@ export default defineConfig([
|
||||||
}, {
|
}, {
|
||||||
files: ['{client,common,static}/**/*.js'],
|
files: ['{client,common,static}/**/*.js'],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
globals: {
|
globals: globals.browser,
|
||||||
...globals.browser,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...matchToFlat(match),
|
...matchToFlat(match),
|
||||||
|
|
|
||||||
11
package.json
11
package.json
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "cloudcmd",
|
"name": "cloudcmd",
|
||||||
"version": "19.1.7",
|
"version": "19.1.9",
|
||||||
|
"type": "commonjs",
|
||||||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
||||||
"description": "File manager for the web with console and editor",
|
"description": "File manager for the web with console and editor",
|
||||||
"homepage": "http://cloudcmd.io",
|
"homepage": "http://cloudcmd.io",
|
||||||
|
|
@ -157,7 +158,7 @@
|
||||||
"@cloudcmd/olark": "^3.0.2",
|
"@cloudcmd/olark": "^3.0.2",
|
||||||
"@cloudcmd/stub": "^5.0.0",
|
"@cloudcmd/stub": "^5.0.0",
|
||||||
"@iocmd/wait": "^2.1.0",
|
"@iocmd/wait": "^2.1.0",
|
||||||
"@putout/eslint-flat": "^3.0.1",
|
"@putout/eslint-flat": "^4.0.0",
|
||||||
"@putout/plugin-cloudcmd": "^4.0.0",
|
"@putout/plugin-cloudcmd": "^4.0.0",
|
||||||
"@types/node-fetch": "^2.6.11",
|
"@types/node-fetch": "^2.6.11",
|
||||||
"auto-globals": "^4.0.0",
|
"auto-globals": "^4.0.0",
|
||||||
|
|
@ -174,7 +175,7 @@
|
||||||
"emitify": "^4.0.1",
|
"emitify": "^4.0.1",
|
||||||
"eslint": "^9.23.0",
|
"eslint": "^9.23.0",
|
||||||
"eslint-plugin-n": "^17.0.0-4",
|
"eslint-plugin-n": "^17.0.0-4",
|
||||||
"eslint-plugin-putout": "^29.0.2",
|
"eslint-plugin-putout": "^30.0.0",
|
||||||
"globals": "^17.0.0",
|
"globals": "^17.0.0",
|
||||||
"gritty": "^9.0.0",
|
"gritty": "^9.0.0",
|
||||||
"gunzip-maybe": "^1.3.1",
|
"gunzip-maybe": "^1.3.1",
|
||||||
|
|
@ -218,9 +219,7 @@
|
||||||
"webpackbar": "^7.0.0"
|
"webpackbar": "^7.0.0"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"#dom/events": {
|
"#dom/events": "./client/dom/events/index.mjs"
|
||||||
"default": "./client/dom/events/index.mjs"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=22"
|
"node": ">=22"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue