chore(client) convert to esm

This commit is contained in:
coderaiser 2020-12-24 19:06:35 +02:00
parent d475790257
commit 18dc5d3a4c
91 changed files with 587 additions and 805 deletions

View file

@ -1,23 +1,21 @@
/* global CloudCmd, filepicker */
'use strict';
const exec = require('execon');
const currify = require('currify');
const load = require('load.js');
import exec from 'execon';
import currify from 'currify';
import load from 'load.js';
const {log} = CloudCmd;
const {ajax} = require('../dom/load');
const Files = require('../dom/files');
const Images = require('../dom/images');
import {ajax} from '../dom/load.js';
import Files from '../dom/files.js';
import Images from '../dom/images.js';
const upload = currify(_upload);
const Name = 'Cloud';
CloudCmd[Name] = module.exports;
module.exports.init = async () => {
export const init = async () => {
const [modules] = await loadFiles();
const {key} = modules.data.FilePicker;
@ -25,7 +23,7 @@ module.exports.init = async () => {
Images.hide();
};
module.exports.uploadFile = (filename, data) => {
export const uploadFile = (filename, data) => {
const mimetype = '';
filepicker.store(data, {
@ -36,7 +34,7 @@ module.exports.uploadFile = (filename, data) => {
});
};
module.exports.saveFile = (callback) => {
export const saveFile = (callback) => {
filepicker.pick(upload(callback));
};

View file

@ -1,28 +1,29 @@
'use strict';
/* global CloudCmd, DOM, io */
require('../../../css/config.css');
import('../../../css/config.css');
const rendy = require('rendy');
const currify = require('currify');
const wraptile = require('wraptile');
const squad = require('squad');
const {promisify} = require('es6-promisify');
const tryToCatch = require('try-to-catch');
const load = require('load.js');
const createElement = require('@cloudcmd/create-element');
import rendy from 'rendy';
import currify from 'currify';
import wraptile from 'wraptile';
import squad from 'squad';
import {promisify} from 'es6-promisify';
import tryToCatch from 'try-to-catch';
import load from 'load.js';
import createElement from '@cloudcmd/create-element';
const input = require('./input');
const Images = require('../../dom/images');
const Events = require('../../dom/events');
const Files = require('../../dom/files');
import input from './input.js';
import Images from '../../dom/images.js';
import Events from '../../dom/events/index.js';
import Files from '../../dom/files.js';
const {getTitle} = require('../../../common/cloudfunc');
import {getTitle} from '../../../common/cloudfunc.js';
const {Dialog, setTitle} = DOM;
const Name = 'Config';
CloudCmd[Name] = module.exports;
CloudCmd.Config = {
init,
show,
hide,
};
const loadSocket = promisify(DOM.loadSocket);
@ -46,7 +47,7 @@ let Template;
const loadCSS = load.css;
module.exports.init = async () => {
export async function init() {
if (!CloudCmd.config('configDialog'))
return;
@ -62,7 +63,7 @@ module.exports.init = async () => {
]);
initSocket();
};
}
const {
config,
@ -125,9 +126,7 @@ function authCheck(socket) {
Config.save = saveHttp;
module.exports.show = show;
async function show() {
export async function show() {
if (!CloudCmd.config('configDialog'))
return;
@ -184,9 +183,7 @@ async function fillTemplate() {
});
}
module.exports.hide = hide;
function hide() {
export function hide() {
CloudCmd.View.hide();
}

View file

@ -1,6 +1,4 @@
'use strict';
const currify = require('currify');
import currify from 'currify';
const isType = currify((type, object, name) => {
return typeof object[name] === type;
@ -8,16 +6,14 @@ const isType = currify((type, object, name) => {
const isBool = isType('boolean');
module.exports.getElementByName = getElementByName;
function getElementByName(selector, element) {
export function getElementByName(selector, element) {
const str = `[data-name="js-${selector}"]`;
return element
.querySelector(str);
}
module.exports.getName = (element) => {
export const getName = (element) => {
const name = element
.getAttribute('data-name')
.replace(/^js-/, '');
@ -25,7 +21,7 @@ module.exports.getName = (element) => {
return name;
};
module.exports.convert = (config) => {
export const convert = (config) => {
const result = config;
const array = Object.keys(config);
@ -46,7 +42,7 @@ function setState(state) {
return '';
}
module.exports.getValue = (name, element) => {
export const getValue = (name, element) => {
const el = getElementByName(name, element);
const {type} = el;
@ -62,7 +58,7 @@ module.exports.getValue = (name, element) => {
}
};
module.exports.setValue = (name, value, element) => {
export const setValue = (name, value, element) => {
const el = getElementByName(name, element);
const {type} = el;

View file

@ -1,20 +1,15 @@
/* global CloudCmd */
/* global DOM */
'use strict';
CloudCmd.Contact = exports;
const olark = require('@cloudcmd/olark');
const Images = require('../dom/images');
import olark from '@cloudcmd/olark';
import Images from '../dom/images.js';
const {Events} = DOM;
const {Key} = CloudCmd;
module.exports.show = show;
module.exports.hide = hide;
module.exports.init = () => {
export const init = () => {
Events.addKey(onKey);
olark.identify('6216-545-10-4223');
@ -23,14 +18,14 @@ module.exports.init = () => {
olark('api.box.onShrink', hide);
};
function show() {
export function show() {
Key.unsetBind();
Images.hide();
olark('api.box.expand');
}
function hide() {
export function hide() {
Key.setBind();
olark('api.box.hide');
}

View file

@ -1,10 +1,8 @@
'use strict';
/* global CloudCmd */
CloudCmd.EditFileVim = exports;
const Events = require('../dom/events');
import Events from '../dom/events.js';
const {Key} = CloudCmd;
@ -16,11 +14,11 @@ const ConfigView = {
},
};
module.exports.init = async () => {
export const init = async () => {
await CloudCmd.EditFile();
};
module.exports.show = () => {
export const show = () => {
Events.addKey(listener);
CloudCmd.EditFile
@ -29,9 +27,7 @@ module.exports.show = () => {
.setKeyMap('vim');
};
module.exports.hide = hide;
function hide() {
export function hide() {
CloudCmd.Edit.hide();
}

View file

@ -1,13 +1,11 @@
'use strict';
/* global CloudCmd, DOM*/
CloudCmd.EditFile = exports;
const Format = require('format-io');
const fullstore = require('fullstore');
const exec = require('execon');
const supermenu = require('supermenu');
import Format from 'format-io';
import fullstore from 'fullstore';
import exec from 'execon';
import supermenu from 'supermenu';
const Info = DOM.CurrentInfo;
@ -30,7 +28,7 @@ const ConfigView = {
},
};
module.exports.init = async () => {
export const init = async () => {
isLoading(true);
await CloudCmd.Edit();
@ -51,7 +49,7 @@ function getName() {
return name;
}
module.exports.show = (options) => {
export const show = (options) => {
if (isLoading())
return;
@ -90,9 +88,7 @@ module.exports.show = (options) => {
return CloudCmd.Edit;
};
module.exports.hide = hide;
function hide() {
export function hide() {
CloudCmd.Edit.hide();
}
@ -178,9 +174,7 @@ function setMsgChanged(name) {
MSG_CHANGED = 'Do you want to save changes to ' + name + '?';
}
module.exports.isChanged = isChanged;
async function isChanged() {
export async function isChanged() {
const editor = CloudCmd.Edit.getEditor();
const is = editor.isChanged();

View file

@ -1,10 +1,8 @@
'use strict';
/* global CloudCmd */
CloudCmd.EditNamesVim = exports;
const Events = require('../dom/events');
import Events from '../dom/events.js';
const {Key} = CloudCmd;
const ConfigView = {
@ -15,11 +13,11 @@ const ConfigView = {
},
};
module.exports.init = async () => {
export const init = async () => {
await CloudCmd.EditNames();
};
module.exports.show = () => {
export const show = () => {
Events.addKey(listener);
CloudCmd.EditNames
@ -28,9 +26,7 @@ module.exports.show = () => {
.setKeyMap('vim');
};
module.exports.hide = hide;
function hide() {
export function hide() {
CloudCmd.Edit.hide();
}

View file

@ -1,13 +1,11 @@
'use strict';
/* global CloudCmd, DOM */
CloudCmd.EditNames = exports;
const currify = require('currify');
const exec = require('execon');
const supermenu = require('supermenu');
const multiRename = require('multi-rename');
import currify from 'currify';
import exec from 'execon';
import supermenu from 'supermenu';
import multiRename from 'multi-rename';
const reject = Promise.reject.bind(Promise);
@ -27,13 +25,13 @@ const ConfigView = {
},
};
module.exports.init = async () => {
export const init = async () => {
await CloudCmd.Edit();
setListeners();
};
module.exports.show = (options) => {
export const show = (options) => {
const names = getActiveNames().join('\n');
const config = {
...ConfigView,
@ -85,9 +83,7 @@ function getActiveNames() {
return DOM.getFilenames(DOM.getActiveFiles());
}
module.exports.hide = hide;
function hide() {
export function hide() {
CloudCmd.Edit.hide();
}
@ -205,9 +201,7 @@ function setMenu(event) {
Menu.show(position.x, position.y);
}
module.exports.isChanged = isChanged;
async function isChanged() {
export async function isChanged() {
const editor = CloudCmd.Edit.getEditor();
const msg = 'Apply new names?';

View file

@ -1,15 +1,13 @@
/* global CloudCmd */
'use strict';
const {promisify} = require('es6-promisify');
const tryToCatch = require('try-to-catch');
const createElement = require('@cloudcmd/create-element');
const load = require('load.js');
import {promisify} from 'es6-promisify';
import tryToCatch from 'try-to-catch';
import createElement from '@cloudcmd/create-element';
import load from 'load.js';
const loadJS = load.js;
const {MAX_FILE_SIZE: maxSize} = require('../../common/cloudfunc');
const {time, timeEnd} = require('../../common/util');
import {MAX_FILE_SIZE as maxSize} from '../../common/cloudfunc.js';
import {time, timeEnd} from '../../common/util.js';
const Name = 'Edit';
@ -29,7 +27,7 @@ const ConfigView = {
},
};
module.exports.init = async () => {
export const init = async () => {
const element = create();
await CloudCmd.View();
@ -76,7 +74,7 @@ function initConfig(options = {}) {
return config;
}
module.exports.show = (options) => {
export const show = (options) => {
if (Loading)
return;
@ -88,17 +86,15 @@ module.exports.show = (options) => {
});
};
module.exports.getEditor = getEditor;
function getEditor() {
export function getEditor() {
return editor;
}
module.exports.getElement = () => {
export const getElement = () => {
return Element;
};
module.exports.hide = () => {
export const hide = () => {
CloudCmd.View.hide();
};

View file

@ -1,19 +1,14 @@
'use strict';
/* global CloudCmd */
CloudCmd.Help = exports;
const Images = require('../dom/images');
import Images from '../dom/images.js';
module.exports.init = () => {
export const init = () => {
Images.show.load('top');
};
module.exports.show = show;
module.exports.hide = hide;
function show() {
export function show() {
const positionLoad = 'top';
const relative = true;
@ -25,7 +20,7 @@ function show() {
});
}
function hide() {
export function hide() {
CloudCmd.View.hide();
}

View file

@ -1,5 +1,3 @@
'use strict';
/* global CloudCmd */
/* global Util */
/* global DOM */
@ -7,13 +5,13 @@
CloudCmd.Konsole = exports;
const exec = require('execon');
const currify = require('currify');
const tryToCatch = require('try-to-catch');
import exec from 'execon';
import currify from 'currify';
import tryToCatch from 'try-to-catch';
const loadJS = require('load.js').js;
const createElement = require('@cloudcmd/create-element');
import createElement from '@cloudcmd/create-element';
const Images = require('../dom/images');
import Images from '../dom/images.js';
const {
Dialog,
CurrentInfo:Info,
@ -31,7 +29,7 @@ const Name = 'Konsole';
let Element;
let Loaded;
module.exports.init = async () => {
export const init = async () => {
if (!config('console'))
return;
@ -42,11 +40,11 @@ module.exports.init = async () => {
await create();
};
module.exports.hide = () => {
export const hide = () => {
CloudCmd.View.hide();
};
module.exports.clear = () => {
export const clear = () => {
konsole.clear();
};
@ -121,7 +119,7 @@ function authCheck(konsole) {
});
}
module.exports.show = (callback) => {
export const show = (callback) => {
if (!Loaded)
return;

View file

@ -1,27 +1,23 @@
'use strict';
/* global CloudCmd */
CloudCmd.Markdown = exports;
const createElement = require('@cloudcmd/create-element');
import createElement from '@cloudcmd/create-element';
const Images = require('../dom/images');
const {Markdown} = require('../dom/rest');
const {alert} = require('../dom/dialog');
import Images from '../dom/images.js';
import {Markdown} from '../dom/rest.js';
import {alert} from '../dom/dialog.js';
module.exports.init = async () => {
export const init = async () => {
Images.show.load('top');
await CloudCmd.View();
};
module.exports.show = show;
module.exports.hide = () => {
export const hide = () => {
CloudCmd.View.hide();
};
async function show(name, options = {}) {
export async function show(name, options = {}) {
const relativeQuery = '?relative';
const {
positionLoad,

View file

@ -1,15 +1,13 @@
/* global CloudCmd, DOM */
'use strict';
import exec from 'execon';
import wrap from 'wraptile';
import supermenu from 'supermenu';
import createElement from '@cloudcmd/create-element';
const exec = require('execon');
const wrap = require('wraptile');
const supermenu = require('supermenu');
const createElement = require('@cloudcmd/create-element');
const {FS} = require('../../common/cloudfunc');
const {getIdBySrc} = require('../dom/load');
const RESTful = require('../dom/rest');
import {FS} from '../../common/cloudfunc.js';
import {getIdBySrc} from '../dom/load.js';
import RESTful from '../dom/rest.js';
const {
config,
@ -31,11 +29,15 @@ let MenuShowedName;
let MenuContext;
let MenuContextFile;
module.exports.ENABLED = false;
export const ENABLED = false;
CloudCmd.Menu = exports;
CloudCmd.Menu = {
init,
show,
hide,
};
module.exports.init = () => {
export function init() {
const {
isAuth,
menuDataFile,
@ -53,23 +55,21 @@ module.exports.init = () => {
MenuContextFile.addContextMenuListener();
Events.addKey(listener);
};
}
module.exports.hide = hide;
function hide() {
export function hide() {
MenuContext.hide();
MenuContextFile.hide();
}
module.exports.show = (position) => {
export function show(position) {
const {x, y} = getPosition(position);
MenuContext.show(x, y);
MenuContextFile.show(x, y);
Images.hide();
};
}
function getPosition(position) {
if (position)

View file

@ -1,6 +1,4 @@
'use strict';
module.exports = (operation, from, to) => {
export default (operation, from, to) => {
if (!to)
return `${operation} ${from}`;

View file

@ -1,11 +1,9 @@
'use strict';
const currify = require('currify');
import currify from 'currify';
const not = currify((array, value) => !array.includes(value));
const notOneOf = currify((a, b) => a.filter(not(b)));
module.exports = (currentName, names, removedNames) => {
export default (currentName, names, removedNames) => {
const i = names.indexOf(currentName);
const nextNames = notOneOf(names, removedNames);

View file

@ -3,25 +3,20 @@
/* global DOM */
/* global fileop */
'use strict';
import currify from 'currify';
import wraptile from 'wraptile';
import {promisify} from 'es6-promisify';
import exec from 'execon';
import load from 'load.js';
import tryToCatch from 'try-to-catch';
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');
import {encode} from '../../../common/entity.js';
import removeExtension from './remove-extension.js';
import setListeners from './set-listeners.js';
import getNextCurrentName from './get-next-current-name.js';
const removeQuery = (a) => a.replace(/\?.*/, '');
const Name = 'Operation';
CloudCmd[Name] = exports;
const {config} = CloudCmd;
const {Dialog, Images} = DOM;
@ -52,7 +47,7 @@ const noFilesCheck = () => {
return is;
};
module.exports.init = promisify((callback) => {
export const init = promisify((callback) => {
showLoad();
exec.series([
@ -77,6 +72,12 @@ module.exports.init = promisify((callback) => {
], callback);
});
CloudCmd.Operation = {
init,
show,
hide,
};
function _authCheck(spawn, ok) {
const accept = wraptile(ok);
const alertDialog = wraptile(Dialog.alert);
@ -190,11 +191,11 @@ function getPacker(type) {
return packTarFn;
}
module.exports.hide = () => {
export function hide() {
CloudCmd.View.hide();
};
}
module.exports.show = (operation, data) => {
export function show(operation, data) {
if (!Loaded)
return;
@ -215,7 +216,7 @@ module.exports.show = (operation, data) => {
if (operation === 'extract')
return Operation.extract();
};
}
Operation.copy = processFiles({
type: 'copy',

View file

@ -1,8 +1,6 @@
'use strict';
import {getExt} from '../../../common/util.js';
const {getExt} = require('../../../common/util');
module.exports = (name) => {
export default (name) => {
const ext = getExtension(name);
return name.replace(ext, '');

View file

@ -1,7 +1,5 @@
'use strict';
const test = require('supertape');
const removeExtension = require(`./remove-extension`);
import test from 'supertape';
import removeExtension from './remove-extension.js';
test('cloudcmd: client: modules: operation: removeExtension: .tar.gz', (t) => {
const name = 'hello';

View file

@ -1,5 +1,3 @@
'use strict';
/* global DOM */
const {
@ -7,12 +5,12 @@ const {
Images,
} = DOM;
const forEachKey = require('for-each-key');
const wraptile = require('wraptile');
import forEachKey from 'for-each-key';
import wraptile from 'wraptile';
const format = require('./format');
import format from './format.js';
module.exports = (options) => (emitter) => {
export default (options) => (emitter) => {
const {
operation,
callback,

View file

@ -1,10 +1,8 @@
'use strict';
/* global DOM */
require('domtokenlist-shim');
import 'domtokenlist-shim';
import scrollIntoViewIfNeeded from 'scroll-into-view-if-needed';
const scrollIntoViewIfNeeded = require('scroll-into-view-if-needed').default;
DOM.scrollIntoViewIfNeeded = (el) => scrollIntoViewIfNeeded(el, {
block: 'nearest',
});

View file

@ -1,8 +1,6 @@
'use strict';
const test = require('supertape');
const mockRequire = require('mock-require');
const stub = require('@cloudcmd/stub');
import test from 'supertape';
import mockRequire from 'mock-require';
import stub from '@cloudcmd/stub';
test('cloudcmd: client: polyfill: scrollIntoViewIfNeaded', (t) => {
const {DOM} = global;

View file

@ -1,17 +1,15 @@
'use strict';
/* global CloudCmd, gritty */
const {promisify} = require('es6-promisify');
const tryToCatch = require('try-to-catch');
const fullstore = require('fullstore');
import '../../css/terminal.css';
require('../../css/terminal.css');
import {promisify} from 'es6-promisify';
import tryToCatch from 'try-to-catch';
import fullstore from 'fullstore';
const exec = require('execon');
const load = require('load.js');
const DOM = require('../dom');
const Images = require('../dom/images');
import exec from 'execon';
import load from 'load.js';
import DOM from '../dom/index.js';
import Images from '../dom/images.js';
const {Dialog} = DOM;
const {
@ -19,7 +17,11 @@ const {
config,
} = CloudCmd;
CloudCmd.TerminalRun = exports;
CloudCmd.TerminalRun = {
init,
show,
hide,
};
let Loaded;
let Terminal;
@ -44,7 +46,7 @@ const loadAll = async () => {
Loaded = true;
};
module.exports.init = async () => {
export async function init() {
if (!config('terminal'))
return;
@ -52,9 +54,9 @@ module.exports.init = async () => {
await CloudCmd.View();
await loadAll();
};
}
module.exports.show = promisify((options = {}, fn) => {
export const show = promisify((options = {}, fn) => {
if (!Loaded)
return;
@ -73,9 +75,7 @@ module.exports.show = promisify((options = {}, fn) => {
});
});
module.exports.hide = hide;
function hide() {
export function hide() {
CloudCmd.View.hide();
}

View file

@ -1,16 +1,14 @@
'use strict';
/* global CloudCmd */
/* global gritty */
const tryToCatch = require('try-to-catch');
import tryToCatch from 'try-to-catch';
require('../../css/terminal.css');
import('../../css/terminal.css');
const exec = require('execon');
const load = require('load.js');
const DOM = require('../dom');
const Images = require('../dom/images');
import exec from 'execon';
import load from 'load.js';
import DOM from '../dom/index.js';
import Images from '../dom/images.js';
const loadParallel = load.parallel;
@ -20,7 +18,11 @@ const {
config,
} = CloudCmd;
CloudCmd.Terminal = exports;
CloudCmd.Terminal = {
init,
show,
hide,
};
let Loaded;
let Terminal;
@ -43,7 +45,7 @@ const loadAll = async () => {
Loaded = true;
};
module.exports.init = async () => {
export async function init() {
if (!config('terminal'))
return;
@ -52,12 +54,9 @@ module.exports.init = async () => {
await CloudCmd.View();
await loadAll();
await create();
};
}
module.exports.show = show;
module.exports.hide = hide;
function hide() {
export function hide() {
CloudCmd.View.hide();
}
@ -110,7 +109,7 @@ function authCheck(spawn) {
});
}
function show() {
export function show() {
if (!Loaded)
return;

View file

@ -1,23 +1,22 @@
/* global CloudCmd, DOM */
'use strict';
import Files from '../dom/files.js';
import Images from '../dom/images.js';
import uploadFiles from '../dom/upload-files.js';
import createElement from '@cloudcmd/create-element';
CloudCmd.Upload = exports;
const Files = require('../dom/files');
const Images = require('../dom/images');
const uploadFiles = require('../dom/upload-files');
const createElement = require('@cloudcmd/create-element');
module.exports.init = async () => {
Images.show.load('top');
await CloudCmd.View();
CloudCmd.Upload = {
init,
show,
hide,
};
module.exports.show = show;
module.exports.hide = hide;
export async function init() {
Images.show.load('top');
await CloudCmd.View();
}
async function show() {
export async function show() {
Images.show.load('top');
const innerHTML = await Files.get('upload');
@ -49,7 +48,7 @@ async function show() {
});
}
function hide() {
export function hide() {
CloudCmd.View.hide();
}

View file

@ -1,6 +1,4 @@
'use strict';
module.exports = (menuFn) => {
export default (menuFn) => {
const module = {};
const fn = Function('module', menuFn);

View file

@ -1,7 +1,5 @@
'use strict';
const test = require('supertape');
const getUserMenu = require('./get-user-menu');
import test from 'supertape';
import getUserMenu from './get-user-menu.js';
test('user-menu: getUserMenu', (t) => {
const menu = `module.exports = {

View file

@ -1,47 +1,45 @@
'use strict';
/* global CloudCmd, DOM */
require('../../../css/user-menu.css');
import('../../../css/user-menu.css');
const currify = require('currify');
const wraptile = require('wraptile');
const fullstore = require('fullstore');
const load = require('load.js');
const createElement = require('@cloudcmd/create-element');
const tryCatch = require('try-catch');
const tryToCatch = require('try-to-catch');
const {codeFrameColumns} = require('@babel/code-frame');
import currify from 'currify';
import wraptile from 'wraptile';
import fullstore from 'fullstore';
import load from 'load.js';
import createElement from '@cloudcmd/create-element';
import tryCatch from 'try-catch';
import tryToCatch from 'try-to-catch';
import {codeFrameColumns} from '@babel/code-frame';
const Images = require('../../dom/images');
const Dialog = require('../../dom/dialog');
const getUserMenu = require('./get-user-menu');
const navigate = require('./navigate');
const parseError = require('./parse-error');
const parseUserMenu = require('./parse-user-menu');
const {runSelected} = require('./run');
import Images from '../../dom/images.js';
import Dialog from '../../dom/dialog.js';
import getUserMenu from './get-user-menu.js';
import navigate from './navigate.js';
import parseError from './parse-error.js';
import parseUserMenu from './parse-user-menu.js';
import {runSelected} from './run.js';
const loadCSS = load.css;
const sourceStore = fullstore();
const Name = 'UserMenu';
CloudCmd[Name] = module.exports;
CloudCmd.UserMenu = {
init,
show,
hide,
};
const {Key} = CloudCmd;
module.exports.init = async () => {
export async function init() {
await Promise.all([
loadCSS(`${CloudCmd.prefix}/dist/user-menu.css`),
CloudCmd.View(),
]);
};
module.exports.show = show;
module.exports.hide = hide;
}
const {CurrentInfo} = DOM;
async function show() {
export async function show() {
Images.show.load('top');
const {dirPath} = CurrentInfo;
@ -104,7 +102,7 @@ function fillTemplate(options) {
return result.join('');
}
function hide() {
export function hide() {
CloudCmd.View.hide();
}

View file

@ -1,13 +1,6 @@
'use strict';
import {J, K, UP, DOWN} from '../../key/key.js';
const {
J,
K,
UP,
DOWN,
} = require('../../key/key.js');
module.exports = (el, {keyCode}) => {
export default (el, {keyCode}) => {
if (keyCode === DOWN || keyCode === J)
return down(el);

View file

@ -1,14 +1,7 @@
'use strict';
import test from 'supertape';
import navigate from './navigate.js';
const test = require('supertape');
const navigate = require('./navigate');
const {
UP,
DOWN,
J,
K,
} = require('../../key/key.js');
import {UP, DOWN, J, K} from '../../key/key.js';
test('cloudcmd: user-menu: navigate: DOWN', (t) => {
const el = {

View file

@ -1,8 +1,6 @@
'use strict';
const isNumber = (a) => typeof a === 'number';
module.exports = (error) => {
export default (error) => {
const {
lineNumber,
columnNumber,

View file

@ -1,7 +1,5 @@
'use strict';
const test = require('supertape');
const parseError = require('./parse-error');
import test from 'supertape';
import parseError from './parse-error.js';
test('user-menu: parse-error', (t) => {
const result = parseError({

View file

@ -1,8 +1,6 @@
'use strict';
const {entries, assign} = Object;
module.exports = (userMenu) => {
export default (userMenu) => {
const names = [];
const keys = {};
const items = {};

View file

@ -1,8 +1,6 @@
'use strict';
const test = require('supertape');
const stub = require('@cloudcmd/stub');
const parse = require('./parse-user-menu');
import test from 'supertape';
import stub from '@cloudcmd/stub';
import parse from './parse-user-menu.js';
test('cloudcmd: user menu: parse', (t) => {
const fn = stub();

View file

@ -1,6 +1,4 @@
'use strict';
module.exports.runSelected = async (selectedItems, items, runUserMenu) => {
export const runSelected = async (selectedItems, items, runUserMenu) => {
for (const selected of selectedItems) {
await runUserMenu(items[selected]);
}

View file

@ -1,8 +1,6 @@
'use strict';
const test = require('supertape');
const stub = require('@cloudcmd/stub');
const {runSelected} = require('./run');
import test from 'supertape';
import stub from '@cloudcmd/stub';
import {runSelected} from './run.js';
test('cloudcmd: client: user menu: run', async (t) => {
const runUserMenu = stub();

View file

@ -1,26 +1,23 @@
'use strict';
/* global CloudCmd, DOM */
require('../../css/view.css');
import('../../css/view.css');
const rendy = require('rendy');
const currify = require('currify');
const wraptile = require('wraptile');
const tryToCatch = require('try-to-catch');
import rendy from 'rendy';
import currify from 'currify';
import wraptile from 'wraptile';
import tryToCatch from 'try-to-catch';
const modal = require('@cloudcmd/modal');
const createElement = require('@cloudcmd/create-element');
import modal from '@cloudcmd/modal';
import createElement from '@cloudcmd/create-element';
const {time} = require('../../common/util');
const {FS} = require('../../common/cloudfunc');
import {FS} from '../../common/cloudfunc.js';
const Files = require('../dom/files');
const Events = require('../dom/events');
const load = require('load.js');
const Images = require('../dom/images');
import Files from '../dom/files.js';
import Events from '../dom/events/index.js';
import load from 'load.js';
import Images from '../dom/images.js';
const {encode} = require('../../common/entity');
import {encode} from '../../common/entity.js';
const {assign} = Object;
const {isArray} = Array;
@ -40,13 +37,13 @@ const getRegExp = (ext) => RegExp(`\\.${ext}$`, 'i');
const loadCSS = load.css;
module.exports.show = show;
module.exports.hide = hide;
let Loading = false;
const Name = 'View';
CloudCmd[Name] = module.exports;
CloudCmd.View = {
init,
show,
hide,
};
const Info = DOM.CurrentInfo;
const {Key} = CloudCmd;
@ -80,7 +77,7 @@ const Config = {
},
};
module.exports.init = async () => {
export async function init() {
await loadAll();
const events = [
@ -89,9 +86,9 @@ module.exports.init = async () => {
];
events.forEach(addEvent(Overlay, onOverlayClick));
};
}
async function show(data, options) {
export async function show(data, options) {
const prefixURL = CloudCmd.prefixURL + FS;
if (Loading)
@ -195,7 +192,7 @@ function viewFile() {
const copy = (a) => assign({}, a);
module.exports._initConfig = initConfig;
export const _initConfig = initConfig;
function initConfig(options) {
const config = copy(Config);
@ -219,7 +216,7 @@ function initConfig(options) {
return config;
}
function hide() {
export function hide() {
modal.close();
}
@ -339,8 +336,6 @@ function check(src) {
async function loadAll() {
const {prefix} = CloudCmd;
time(Name + ' load');
Loading = true;
await loadCSS(`${prefix}/dist/view.css`);
Loading = false;

View file

@ -1,9 +1,7 @@
'use strict';
import('css-modules-require-hook/preset');
require('css-modules-require-hook/preset');
const test = require('supertape');
const {reRequire} = require('mock-require');
import test from 'supertape';
import {reRequire} from 'mock-require';
test('cloudcmd: client: view: initConfig', (t) => {
let config;