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

@ -5,7 +5,8 @@
"fontello.json" "fontello.json"
], ],
"rules": { "rules": {
"convert-commonjs-to-esm": "on" "convert-commonjs-to-esm": "on",
"remove-empty/import": "off"
}, },
"match": { "match": {
"{import.spec.js,console.js}": { "{import.spec.js,console.js}": {

View file

@ -1,35 +1,29 @@
'use strict';
/* 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 pascalCase = require('just-pascal-case'); import pascalCase from 'just-pascal-case';
const isDev = process.env.NODE_ENV === 'development'; const isDev = process.env.NODE_ENV === 'development';
const Images = require('./dom/images'); import Images from './dom/images.js';
const {unregisterSW} = require('./sw/register'); import {unregisterSW} from './sw/register.js';
const getJsonFromFileTable = require('./get-json-from-file-table'); import getJsonFromFileTable from './get-json-from-file-table.js';
const currify = require('currify'); import currify from 'currify';
const noJS = (a) => a.replace(/.js$/, ''); const noJS = (a) => a.replace(/.js$/, '');
const { import {apiURL, formatMsg, buildFromJSON} from '../common/cloudfunc.js';
apiURL,
formatMsg,
buildFromJSON,
} = require('../common/cloudfunc');
const loadModule = require('./load-module'); import loadModule from './load-module.js';
inherits(CloudCmdProto, Emitify); inherits(CloudCmdProto, Emitify);
module.exports = new CloudCmdProto(DOM); export default 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`;

View file

@ -1,37 +1,34 @@
'use strict'; import('../css/main.css');
import('../css/nojs.css');
import('../css/columns/name-size-date.css');
import('../css/columns/name-size.css');
require('../css/main.css'); import wraptile from 'wraptile';
require('../css/nojs.css'); import load from 'load.js';
require('../css/columns/name-size-date.css');
require('../css/columns/name-size.css');
const wraptile = require('wraptile');
const load = require('load.js');
const isDev = process.env.NODE_ENV === 'development'; const isDev = process.env.NODE_ENV === 'development';
const { import {registerSW, listenSW} from './sw/register.js';
registerSW,
listenSW,
} = require('./sw/register');
// prevent additional loading of emitify // prevent additional loading of emitify
window.Emitify = require('emitify'); window.Emitify = await import('emitify');
module.exports = window.CloudCmd = async (config) => { export default window.CloudCmd = async (config) => {
window.Util = require('../common/util'); window.Util = await import('../common/util');
window.CloudFunc = require('../common/cloudfunc'); window.CloudFunc = await iimport('../common/cloudfunc');
const DOM = require('./dom'); const DOM = await import('./dom');
window.DOM = DOM; window.DOM = DOM;
window.CloudCmd = require('./client'); window.CloudCmd = require('./client');
await register(config); await register(config);
require('./listeners'); await Promise.all([
require('./key'); import('./listeners'),
require('./sort'); import('./key');
import('./sort');
]);
const prefix = getPrefix(config.prefix); const prefix = getPrefix(config.prefix);

View file

@ -1,12 +1,10 @@
'use strict';
/* global CloudCmd */ /* global CloudCmd */
const tryToPromiseAll = require('../../common/try-to-promise-all'); import tryToPromiseAll from '../../common/try-to-promise-all.js';
const Storage = require('./storage'); import Storage from './storage.js';
const DOM = require('./'); import DOM from './.js';
module.exports = new BufferProto(); export default new BufferProto();
function BufferProto() { function BufferProto() {
const Info = DOM.CurrentInfo; const Info = DOM.CurrentInfo;

View file

@ -1,20 +1,12 @@
'use strict';
/* global DOM */ /* global DOM */
/* global CloudCmd */ /* global CloudCmd */
const btoa = require('../../common/btoa'); import btoa from '../../common/btoa.js';
const createElement = require('@cloudcmd/create-element'); import createElement from '@cloudcmd/create-element';
const { import {encode, decode} from '../../common/entity.js';
encode,
decode,
} = require('../../common/entity');
const { import {getTitle, FS} from '../../common/cloudfunc.js';
getTitle,
FS,
} = require('../../common/cloudfunc');
let Title; let Title;
@ -22,7 +14,7 @@ const CURRENT_FILE = 'current-file';
const NBSP_REG = RegExp(String.fromCharCode(160), 'g'); const NBSP_REG = RegExp(String.fromCharCode(160), 'g');
const SPACE = ' '; const SPACE = ' ';
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
@ -30,7 +22,7 @@ module.exports._CURRENT_FILE = CURRENT_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;
@ -52,7 +44,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)
@ -70,7 +62,7 @@ module.exports.getCurrentName = (currentFile) => {
/** /**
* 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
.replace(NBSP_REG, SPACE); .replace(NBSP_REG, SPACE);
@ -81,7 +73,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;
@ -97,7 +89,7 @@ module.exports.getCurrentPath = (currentFile) => {
/** /**
* get current direcotory name * get current direcotory name
*/ */
module.exports.getCurrentDirName = () => { export const getCurrentDirName = () => {
const href = DOM.getCurrentDirPath() const href = DOM.getCurrentDirPath()
.replace(/\/$/, ''); .replace(/\/$/, '');
@ -110,7 +102,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);
@ -124,7 +116,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,
}); });
@ -137,14 +129,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(name)); const dataName = 'js-file-' + btoa(encodeURI(name));
return DOM.getByDataName(dataName, panel); return DOM.getByDataName(dataName, panel);
}; };
@ -166,7 +158,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();
@ -223,7 +215,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) => {
@ -255,7 +247,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;
@ -268,7 +260,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,
@ -285,14 +277,14 @@ 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 fileType = DOM.getCurrentType(current); const fileType = DOM.getCurrentType(current);
return /^directory(-link)?/.test(fileType); return /^directory(-link)?/.test(fileType);
}; };
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

View file

@ -1,13 +1,11 @@
'use strict'; import test from 'supertape';
import {create} from 'auto-globals';
const test = require('supertape'); import stub from '@cloudcmd/stub';
const {create} = require('auto-globals');
const stub = require('@cloudcmd/stub');
const id = (a) => a; const id = (a) => a;
const wraptile = require('wraptile'); import wraptile from 'wraptile';
const returns = wraptile(id); const returns = wraptile(id);
const currentFile = require('./current-file'); import currentFile from './current-file.js';
const {_CURRENT_FILE} = currentFile; const {_CURRENT_FILE} = currentFile;
test('current-file: setCurrentName: setAttribute', (t) => { test('current-file: setCurrentName: setAttribute', (t) => {

View file

@ -1,27 +1,25 @@
'use strict'; import tryToCatch from 'try-to-catch';
const tryToCatch = require('try-to-catch'); import {alert, prompt, confirm, progress} from 'smalltalk';
const {
alert,
prompt,
confirm,
progress,
} = require('smalltalk');
const title = 'Cloud Commander'; const title = 'Cloud Commander';
module.exports.alert = (...a) => alert(title, ...a, { const customAlert = (...a) => alert(title, ...a, {
cancel: false, cancel: false,
}); });
module.exports.prompt = (...a) => tryToCatch(prompt, title, ...a); customAlert.noFiles = () => {
module.exports.confirm = (...a) => tryToCatch(confirm, title, ...a);
module.exports.progress = (...a) => progress(title, ...a);
module.exports.alert.noFiles = () => {
return alert(title, 'No files selected!', { return alert(title, 'No files selected!', {
cancel: false, cancel: false,
}); });
}; };
const customPrompt = (...a) => tryToCatch(prompt, title, ...a);
const customConfirm = (...a) => tryToCatch(confirm, title, ...a);
const customProgress = (...a) => progress(title, ...a);
export {
customAlert as alert,
customPrompt as prompt,
customConfirm as confirm,
customProgress as progress,
}

View file

@ -1,17 +1,15 @@
'use strict';
/* global CloudCmd */ /* global CloudCmd */
const philip = require('philip'); import philip from 'philip';
const Images = require('./images'); import Images from './images.js';
const {FS} = require('../../common/cloudfunc'); import {FS} from '../../common/cloudfunc.js';
const DOM = require('.'); import DOM from '.';
const Dialog = require('./dialog'); import Dialog from './dialog.js';
const {getCurrentDirPath: getPathWhenRootEmpty} = DOM; const {getCurrentDirPath: getPathWhenRootEmpty} = DOM;
module.exports = (items) => { export default (items) => {
if (items.length) if (items.length)
Images.show('top'); Images.show('top');

View file

@ -1,6 +1,4 @@
'use strict'; import currify from 'currify';
const currify = require('currify');
const DOM = module.exports; const DOM = module.exports;
@ -10,6 +8,12 @@ const DOM = module.exports;
* @param element * @param element
* @param className * @param className
*/ */
export /**
* check class of element
*
* @param element
* @param className
*/
const isContainClass = (element, className) => { const isContainClass = (element, className) => {
if (!element) if (!element)
throw Error('element could not be empty!'); throw Error('element could not be empty!');
@ -25,14 +29,12 @@ const isContainClass = (element, className) => {
return classList.contains(className); return classList.contains(className);
}; };
module.exports.isContainClass = isContainClass;
/** /**
* Function search element by tag * Function search element by tag
* @param tag - className * @param tag - className
* @param element - element * @param element - element
*/ */
module.exports.getByTag = (tag, element = document) => { export const getByTag = (tag, element = document) => {
return element.getElementsByTagName(tag); return element.getElementsByTagName(tag);
}; };
@ -40,7 +42,7 @@ module.exports.getByTag = (tag, element = document) => {
* Function search element by id * Function search element by id
* @param Id - id * @param Id - id
*/ */
module.exports.getById = (id, element = document) => { export const getById = (id, element = document) => {
return element.querySelector('#' + id); return element.querySelector('#' + id);
}; };
@ -49,11 +51,11 @@ module.exports.getById = (id, element = document) => {
* @param className - className * @param className - className
* @param element - element * @param element - element
*/ */
module.exports.getByClass = (className, element = document) => { export const getByClass = (className, element = document) => {
return DOM.getByClassAll(className, element)[0]; return DOM.getByClassAll(className, element)[0];
}; };
module.exports.getByDataName = (attribute, element = document) => { export const getByDataName = (attribute, element = document) => {
const selector = '[' + 'data-name="' + attribute + '"]'; const selector = '[' + 'data-name="' + attribute + '"]';
return element.querySelector(selector); return element.querySelector(selector);
}; };
@ -63,7 +65,7 @@ module.exports.getByDataName = (attribute, element = document) => {
* @param pClass - className * @param pClass - className
* @param element - element * @param element - element
*/ */
module.exports.getByClassAll = (className, element) => { export const getByClassAll = (className, element) => {
return (element || document).getElementsByClassName(className); return (element || document).getElementsByClassName(className);
}; };
@ -72,12 +74,12 @@ module.exports.getByClassAll = (className, element) => {
* *
* @param element * @param element
*/ */
module.exports.hide = (element) => { export const hide = (element) => {
element.classList.add('hidden'); element.classList.add('hidden');
return DOM; return DOM;
}; };
module.exports.show = (element) => { export const show = (element) => {
element.classList.remove('hidden'); element.classList.remove('hidden');
return DOM; return DOM;
}; };

View file

@ -1,10 +1,8 @@
'use strict'; import test from 'supertape';
import {create} from 'auto-globals';
import tryCatch from 'try-catch';
const test = require('supertape'); import {isContainClass} from './dom-tree.js';
const {create} = require('auto-globals');
const tryCatch = require('try-catch');
const {isContainClass} = require('./dom-tree');
test('dom: isContainClass: no element', (t) => { test('dom: isContainClass: no element', (t) => {
const [e] = tryCatch(isContainClass); const [e] = tryCatch(isContainClass);

View file

@ -1,8 +1,6 @@
'use strict';
let list = []; let list = [];
module.exports.add = (el, name, fn) => { export const add = (el, name, fn) => {
list.push([ list.push([
el, el,
name, name,
@ -10,11 +8,11 @@ module.exports.add = (el, name, fn) => {
]); ]);
}; };
module.exports.clear = () => { export const clear = () => {
list = []; list = [];
}; };
module.exports.get = () => { export const get = () => {
return list; return list;
}; };

View file

@ -1,7 +1,5 @@
'use strict'; import test from 'supertape';
import eventStore from './event-store.js';
const test = require('supertape');
const eventStore = require('./event-store');
test('event-store: get', (t) => { test('event-store: get', (t) => {
const el = {}; const el = {};

View file

@ -1,9 +1,7 @@
'use strict'; import itype from 'itype';
import EventStore from './event-store.js';
const itype = require('itype'); export default new EventsProto();
const EventStore = require('./event-store');
module.exports = new EventsProto();
function EventsProto() { function EventsProto() {
const Events = this; const Events = this;

View file

@ -1,12 +1,10 @@
'use strict';
/* global CloudCmd */ /* global CloudCmd */
const itype = require('itype'); import itype from 'itype';
const {promisify} = require('es6-promisify'); import {promisify} from 'es6-promisify';
const load = require('./load'); import load from './load.js';
const RESTful = require('./rest'); import RESTful from './rest.js';
const Promises = {}; const Promises = {};
const FILES_JSON = 'config|modules'; const FILES_JSON = 'config|modules';
@ -17,7 +15,7 @@ const DIR_HTML_FS = DIR_HTML + 'fs/';
const DIR_JSON = '/json/'; const DIR_JSON = '/json/';
const timeout = getTimeoutOnce(2000); const timeout = getTimeoutOnce(2000);
module.exports.get = getFile; export const get = getFile;
async function getFile(name) { async function getFile(name) {
const type = itype(name); const type = itype(name);

View file

@ -1,8 +1,6 @@
/* global DOM */ /* global DOM */
'use strict'; import createElement from '@cloudcmd/create-element';
const createElement = require('@cloudcmd/create-element');
const Images = module.exports; const Images = module.exports;
@ -14,7 +12,7 @@ function getLoadingType() {
return isSVG() ? '-svg' : '-gif'; return isSVG() ? '-svg' : '-gif';
} }
module.exports.get = getElement; export const get = getElement;
/** /**
* check SVG SMIL animation support * check SVG SMIL animation support
@ -43,7 +41,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();
@ -55,7 +53,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();
@ -66,14 +64,17 @@ module.exports.error = () => {
return element; return element;
}; };
module.exports.show = show;
module.exports.show.load = show; module.exports.show.load = show;
module.exports.show.error = error; module.exports.show.error = showError;
/** /**
* Function shows loading spinner * Function shows loading spinner
* position = {top: true}; * position = {top: true};
*/ */
export /**
* Function shows loading spinner
* position = {top: true};
*/
function show(position, panel) { function show(position, panel) {
const image = Images.loading(); const image = Images.loading();
const parent = image.parentElement; const parent = image.parentElement;
@ -100,7 +101,7 @@ function show(position, panel) {
return image; return image;
} }
function error(text) { function showError(text) {
const image = Images.error(); const image = Images.error();
DOM.show(image); DOM.show(image);
@ -112,7 +113,7 @@ function error(text) {
/** /**
* 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);
@ -120,7 +121,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();
@ -135,7 +136,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();

View file

@ -1,23 +1,21 @@
/* global CloudCmd */ /* global CloudCmd */
'use strict'; import tryToPromiseAll from '../../common/try-to-promise-all.js';
const tryToPromiseAll = require('../../common/try-to-promise-all'); import Util from '../../common/util.js';
import callbackify from '../../common/callbackify.js';
const Util = require('../../common/util'); import Images from './images.js';
const callbackify = require('../../common/callbackify'); import load from './load.js';
import Files from './files.js';
import RESTful from './rest.js';
import IO from './io.js';
import Storage from './storage.js';
import Dialog from './dialog.js';
import renameCurrent from './operations/rename-current.js';
const Images = require('./images'); import CurrentFile from './current-file.js';
const load = require('./load'); import DOMTree from './dom-tree.js';
const Files = require('./files');
const RESTful = require('./rest');
const IO = require('./io');
const Storage = require('./storage');
const Dialog = require('./dialog');
const renameCurrent = require('./operations/rename-current');
const CurrentFile = require('./current-file');
const DOMTree = require('./dom-tree');
const DOM = { const DOM = {
...DOMTree, ...DOMTree,
@ -33,14 +31,14 @@ DOM.IO = IO;
DOM.Storage = Storage; DOM.Storage = Storage;
DOM.Dialog = Dialog; DOM.Dialog = Dialog;
module.exports = DOM; export default DOM;
DOM.uploadDirectory = require('./directory'); DOM.uploadDirectory = require('./directory');
DOM.Buffer = require('./buffer'); DOM.Buffer = require('./buffer');
DOM.Events = require('./events'); DOM.Events = require('./events');
const loadRemote = require('./load-remote'); import loadRemote from './load-remote.js';
const selectByPattern = require('./select-by-pattern'); import selectByPattern from './select-by-pattern.js';
function CmdProto() { function CmdProto() {
const CurrentInfo = {}; const CurrentInfo = {};

View file

@ -1,13 +1,11 @@
'use strict'; import {FS} from '../../../common/cloudfunc.js';
import sendRequest from './send-request.js';
const {FS} = require('../../../common/cloudfunc');
const sendRequest = require('./send-request');
const imgPosition = { const imgPosition = {
top: true, top: true,
}; };
module.exports.delete = async (url, data) => { export const remove = async (url, data) => {
return await sendRequest({ return await sendRequest({
method : 'DELETE', method : 'DELETE',
url : FS + url, url : FS + url,
@ -18,7 +16,7 @@ module.exports.delete = async (url, data) => {
}); });
}; };
module.exports.patch = async (url, data) => { export const patch = async (url, data) => {
return await sendRequest({ return await sendRequest({
method: 'PATCH', method: 'PATCH',
url: FS + url, url: FS + url,
@ -27,7 +25,7 @@ module.exports.patch = async (url, data) => {
}); });
}; };
module.exports.write = async (url, data) => { export const write = async (url, data) => {
return await sendRequest({ return await sendRequest({
method: 'PUT', method: 'PUT',
url: FS + url, url: FS + url,
@ -36,7 +34,7 @@ module.exports.write = async (url, data) => {
}); });
}; };
module.exports.createDirectory = async (url) => { export const createDirectory = async (url) => {
return await sendRequest({ return await sendRequest({
method: 'PUT', method: 'PUT',
url: `${FS}${url}?dir`, url: `${FS}${url}?dir`,
@ -44,7 +42,7 @@ module.exports.createDirectory = async (url) => {
}); });
}; };
module.exports.read = async (url, dataType = 'text') => { export const read = async (url, dataType = 'text') => {
const notLog = !url.includes('?'); const notLog = !url.includes('?');
return await sendRequest({ return await sendRequest({
@ -55,7 +53,7 @@ module.exports.read = async (url, dataType = 'text') => {
}); });
}; };
module.exports.copy = async (from, to, names) => { export const copy = async (from, to, names) => {
return await sendRequest({ return await sendRequest({
method: 'PUT', method: 'PUT',
url: '/copy', url: '/copy',
@ -68,7 +66,7 @@ module.exports.copy = async (from, to, names) => {
}); });
}; };
module.exports.pack = async (data) => { export const pack = async (data) => {
return await sendRequest({ return await sendRequest({
method: 'PUT', method: 'PUT',
url: '/pack', url: '/pack',
@ -76,7 +74,7 @@ module.exports.pack = async (data) => {
}); });
}; };
module.exports.extract = async (data) => { export const extract = async (data) => {
return await sendRequest({ return await sendRequest({
method: 'PUT', method: 'PUT',
url: '/extract', url: '/extract',
@ -84,7 +82,7 @@ module.exports.extract = async (data) => {
}); });
}; };
module.exports.move = async (from, to, names) => { export const move = async (from, to, names) => {
return await sendRequest({ return await sendRequest({
method: 'PUT', method: 'PUT',
url: '/move', url: '/move',
@ -97,7 +95,7 @@ module.exports.move = async (from, to, names) => {
}); });
}; };
module.exports.rename = async (from, to) => { export const rename = async (from, to) => {
return await sendRequest({ return await sendRequest({
method: 'PUT', method: 'PUT',
url: '/rename', url: '/rename',
@ -109,7 +107,7 @@ module.exports.rename = async (from, to) => {
}); });
}; };
module.exports.Config = { export const Config = {
read: async () => { read: async () => {
return await sendRequest({ return await sendRequest({
method: 'GET', method: 'GET',
@ -129,7 +127,7 @@ module.exports.Config = {
}, },
}; };
module.exports.Markdown = { export const Markdown = {
read: async (url) => { read: async (url) => {
return await sendRequest({ return await sendRequest({
method: 'GET', method: 'GET',

View file

@ -1,8 +1,6 @@
'use strict'; import test from 'supertape';
import stub from '@cloudcmd/stub';
const test = require('supertape'); import mockRequire from 'mock-require';
const stub = require('@cloudcmd/stub');
const mockRequire = require('mock-require');
const {reRequire} = mockRequire; const {reRequire} = mockRequire;

View file

@ -1,13 +1,11 @@
'use strict';
/* global CloudCmd */ /* global CloudCmd */
const {promisify} = require('es6-promisify'); import {promisify} from 'es6-promisify';
const Images = require('../images'); import Images from '../images.js';
const load = require('../load'); import load from '../load.js';
module.exports = promisify((params, callback) => { export default promisify((params, callback) => {
const p = params; const p = params;
const {prefixURL} = CloudCmd; const {prefixURL} = CloudCmd;
@ -44,7 +42,7 @@ module.exports = promisify((params, callback) => {
}); });
}); });
module.exports._replaceHash = replaceHash; export const _replaceHash = replaceHash;
function replaceHash(url) { function replaceHash(url) {
/* /*
* if we send ajax request - * if we send ajax request -

View file

@ -1,7 +1,5 @@
'use strict'; import test from 'supertape';
import {_replaceHash} from './send-request.js';
const test = require('supertape');
const {_replaceHash} = require('./send-request');
test('cloudcmd: client: io: replaceHash', (t) => { test('cloudcmd: client: io: replaceHash', (t) => {
const url = '/hello/####world'; const url = '/hello/####world';

View file

@ -1,17 +1,15 @@
'use strict';
/* global CloudCmd */ /* global CloudCmd */
const rendy = require('rendy'); import rendy from 'rendy';
const itype = require('itype'); import itype from 'itype';
const load = require('load.js'); import load from 'load.js';
const tryToCatch = require('try-to-catch'); import tryToCatch from 'try-to-catch';
const {findObjByNameInArr} = require('../../common/util'); import {findObjByNameInArr} from '../../common/util.js';
const Files = require('./files'); import Files from './files.js';
module.exports = (name, options, callback = options) => { export default (name, options, callback = options) => {
const {prefix, config} = CloudCmd; const {prefix, config} = CloudCmd;
const o = options; const o = options;

View file

@ -1,12 +1,8 @@
'use strict'; import itype from 'itype';
import jonny from 'jonny';
const itype = require('itype'); import Emitify from 'emitify';
const jonny = require('jonny'); import exec from 'execon';
const Emitify = require('emitify'); import Images from './images.js';
const exec = require('execon');
const Images = require('./images');
module.exports.getIdBySrc = getIdBySrc;
/** /**
* Function gets id by src * Function gets id by src
@ -14,6 +10,12 @@ module.exports.getIdBySrc = getIdBySrc;
* *
* Example: http://domain.com/1.js -> 1_js * Example: http://domain.com/1.js -> 1_js
*/ */
export /**
* Function gets id by src
* @param src
*
* Example: http://domain.com/1.js -> 1_js
*/
function getIdBySrc(src) { function getIdBySrc(src) {
const isStr = itype.string(src); const isStr = itype.string(src);
@ -37,7 +39,7 @@ function getIdBySrc(src) {
* *
* @param params * @param params
*/ */
module.exports.ajax = (params) => { export const ajax = (params) => {
const p = params; const p = params;
const isObject = itype.object(p.data); const isObject = itype.object(p.data);
const isArray = itype.array(p.data); const isArray = itype.array(p.data);
@ -94,7 +96,7 @@ module.exports.ajax = (params) => {
xhr.send(data); xhr.send(data);
}; };
module.exports.put = (url, body) => { export const put = (url, body) => {
const emitter = Emitify(); const emitter = Emitify();
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();

View file

@ -1,23 +1,13 @@
'use strict';
/* global CloudCmd */ /* global CloudCmd */
const capitalize = require('just-capitalize'); import capitalize from 'just-capitalize';
const Dialog = require('../dialog'); import Dialog from '../dialog.js';
const Storage = require('../storage'); import Storage from '../storage.js';
const RESTful = require('../rest'); import RESTful from '../rest.js';
const { import {isCurrentFile, getCurrentName, getCurrentFile, getCurrentByName, getCurrentType, getCurrentDirPath, setCurrentName} from '../current-file.js';
isCurrentFile,
getCurrentName,
getCurrentFile,
getCurrentByName,
getCurrentType,
getCurrentDirPath,
setCurrentName,
} = require('../current-file');
module.exports = async (current) => { export default async (current) => {
if (!isCurrentFile(current)) if (!isCurrentFile(current))
current = getCurrentFile(); current = getCurrentFile();

View file

@ -1,8 +1,6 @@
'use strict'; import test from 'supertape';
import stub from '@cloudcmd/stub';
const test = require('supertape'); import mockRequire from 'mock-require';
const stub = require('@cloudcmd/stub');
const mockRequire = require('mock-require');
const {reRequire} = mockRequire; const {reRequire} = mockRequire;

View file

@ -1,12 +1,10 @@
'use strict'; import tryToCatch from 'try-to-catch';
const tryToCatch = require('try-to-catch'); import {encode} from '../../common/entity.js';
const {encode} = require('../../common/entity'); import Images from './images.js';
import IO from './io.js';
const Images = require('./images'); import Dialog from './dialog.js';
const IO = require('./io');
const Dialog = require('./dialog');
const handleError = (promise) => async (...args) => { const handleError = (promise) => async (...args) => {
const [e, data] = await tryToCatch(promise, ...args); const [e, data] = await tryToCatch(promise, ...args);
@ -22,23 +20,23 @@ const handleError = (promise) => async (...args) => {
return [e, data]; return [e, data];
}; };
module.exports.delete = handleError(IO.delete); export const remove = handleError(IO.remove);
module.exports.patch = handleError(IO.patch); export const patch = handleError(IO.patch);
module.exports.write = handleError(IO.write); export const write = handleError(IO.write);
module.exports.createDirectory = handleError(IO.createDirectory); export const createDirectory = handleError(IO.createDirectory);
module.exports.read = handleError(IO.read); export const read = handleError(IO.read);
module.exports.copy = handleError(IO.copy); export const copy = handleError(IO.copy);
module.exports.pack = handleError(IO.pack); export const pack = handleError(IO.pack);
module.exports.extract = handleError(IO.extract); export const extract = handleError(IO.extract);
module.exports.move = handleError(IO.move); export const move = handleError(IO.move);
module.exports.rename = handleError(IO.rename); export const rename = handleError(IO.rename);
module.exports.Config = { export const Config = {
read: handleError(IO.Config.read), read: handleError(IO.Config.read),
write: handleError(IO.Config.write), write: handleError(IO.Config.write),
}; };
module.exports.Markdown = { export const Markdown = {
read: handleError(IO.Markdown.read), read: handleError(IO.Markdown.read),
render: handleError(IO.Markdown.render), render: handleError(IO.Markdown.render),
}; };

View file

@ -1,16 +1,11 @@
'use strict';
let SelectType = '*.*'; let SelectType = '*.*';
const {getRegExp} = require('../../common/util'); import {getRegExp} from '../../common/util.js';
const { import {alert, prompt} from './dialog.js';
alert,
prompt,
} = require('./dialog');
const DOM = require('.'); import DOM from '.';
module.exports = async (msg, files) => { export default async (msg, files) => {
if (!files) if (!files)
return; return;

View file

@ -1,29 +1,27 @@
'use strict';
const {parse, stringify} = JSON; const {parse, stringify} = JSON;
module.exports.set = async (name, data) => { export const set = async (name, data) => {
localStorage.setItem(name, data); localStorage.setItem(name, data);
}; };
module.exports.setJson = async (name, data) => { export const setJson = async (name, data) => {
localStorage.setItem(name, stringify(data)); localStorage.setItem(name, stringify(data));
}; };
module.exports.get = async (name) => { export const get = async (name) => {
return localStorage.getItem(name); return localStorage.getItem(name);
}; };
module.exports.getJson = async (name) => { export const getJson = async (name) => {
const data = localStorage.getItem(name); const data = localStorage.getItem(name);
return parse(data); return parse(data);
}; };
module.exports.clear = () => { export const clear = () => {
localStorage.clear(); localStorage.clear();
}; };
module.exports.remove = (item) => { export const remove = (item) => {
localStorage.removeItem(item); localStorage.removeItem(item);
}; };

View file

@ -1,8 +1,6 @@
'use strict'; import test from 'supertape';
import stub from '@cloudcmd/stub';
const test = require('supertape'); import storage from './storage.js';
const stub = require('@cloudcmd/stub');
const storage = require('./storage');
const {stringify} = JSON; const {stringify} = JSON;

View file

@ -1,22 +1,20 @@
'use strict';
/* global CloudCmd */ /* global CloudCmd */
const {eachSeries} = require('execon'); import {eachSeries} from 'execon';
const wraptile = require('wraptile'); import wraptile from 'wraptile';
const load = require('./load'); import load from './load.js';
const Images = require('./images'); import Images from './images.js';
const {alert} = require('./dialog'); import {alert} from './dialog.js';
const {FS} = require('../../common/cloudfunc'); import {FS} from '../../common/cloudfunc.js';
const onEnd = wraptile(_onEnd); const onEnd = wraptile(_onEnd);
const loadFile = wraptile(_loadFile); const loadFile = wraptile(_loadFile);
const {getCurrentDirPath: getPathWhenRootEmpty} = require('.'); import {getCurrentDirPath as getPathWhenRootEmpty} from '.';
module.exports = (dir, files) => { export default (dir, files) => {
if (!files) { if (!files) {
files = dir; files = dir;
dir = getPathWhenRootEmpty(); dir = getPathWhenRootEmpty();

View file

@ -1,5 +1,3 @@
'use strict';
/* global DOM */ /* global DOM */
const Info = DOM.CurrentInfo; const Info = DOM.CurrentInfo;
@ -8,7 +6,7 @@ const Info = DOM.CurrentInfo;
* Функция генерирует JSON из html-таблицы файлов и * Функция генерирует JSON из html-таблицы файлов и
* используеться при первом заходе в корень * используеться при первом заходе в корень
*/ */
module.exports = () => { export default () => {
const path = DOM.getCurrentDirPath(); const path = DOM.getCurrentDirPath();
const infoFiles = Info.files || []; const infoFiles = Info.files || [];

View file

@ -1,18 +1,16 @@
/* global CloudCmd, DOM */ /* global CloudCmd, DOM */
'use strict';
const Info = DOM.CurrentInfo; const Info = DOM.CurrentInfo;
const exec = require('execon'); import exec from 'execon';
const clipboard = require('@cloudcmd/clipboard'); import clipboard from '@cloudcmd/clipboard';
const Events = require('../dom/events'); import Events from '../dom/events.js';
const Buffer = require('../dom/buffer'); import Buffer from '../dom/buffer.js';
const KEY = require('./key'); import KEY from './key.js';
const vim = require('./vim'); import vim from './vim.js';
const setCurrentByChar = require('./set-current-by-char'); import setCurrentByChar from './set-current-by-char.js';
const fullstore = require('fullstore'); import fullstore from 'fullstore';
const Chars = fullstore(); const Chars = fullstore();
Chars([]); Chars([]);

View file

@ -1,6 +1,4 @@
'use strict'; export default {
module.exports = {
BACKSPACE : 8, BACKSPACE : 8,
TAB : 9, TAB : 9,
ENTER : 13, ENTER : 13,

View file

@ -1,11 +1,9 @@
/* global DOM */ /* global DOM */
'use strict';
const Info = DOM.CurrentInfo; const Info = DOM.CurrentInfo;
const {escapeRegExp} = require('../../common/util'); import {escapeRegExp} from '../../common/util.js';
module.exports = function setCurrentByChar(char, charStore) { export default function setCurrentByChar(char, charStore) {
let firstByName; let firstByName;
let skipCount = 0; let skipCount = 0;
let setted = false; let setted = false;
@ -55,5 +53,5 @@ module.exports = function setCurrentByChar(char, charStore) {
DOM.setCurrentFile(firstByName); DOM.setCurrentFile(firstByName);
charStore([char]); charStore([char]);
} }
}; }

View file

@ -1,12 +1,10 @@
'use strict'; import fullstore from 'fullstore';
import limier from 'limier';
const fullstore = require('fullstore');
const limier = require('limier');
const searchStore = fullstore([]); const searchStore = fullstore([]);
const searchIndex = fullstore(0); const searchIndex = fullstore(0);
module.exports.find = (value, names) => { export const find = (value, names) => {
const result = limier(value, names); const result = limier(value, names);
searchStore(result); searchStore(result);
@ -15,7 +13,7 @@ module.exports.find = (value, names) => {
return result; return result;
}; };
module.exports.findNext = () => { export const findNext = () => {
const names = searchStore(); const names = searchStore();
const index = next(searchIndex(), names.length); const index = next(searchIndex(), names.length);
@ -23,7 +21,7 @@ module.exports.findNext = () => {
return names[searchIndex()]; return names[searchIndex()];
}; };
module.exports.findPrevious = () => { export const findPrevious = () => {
const names = searchStore(); const names = searchStore();
const index = previous(searchIndex(), names.length); const index = previous(searchIndex(), names.length);
@ -31,8 +29,8 @@ module.exports.findPrevious = () => {
return names[index]; return names[index];
}; };
module.exports._next = next; export const _next = next;
module.exports._previous = previous; export const _previous = previous;
function next(index, length) { function next(index, length) {
if (index === length - 1) if (index === length - 1)

View file

@ -1,16 +1,10 @@
'use strict'; import test from 'supertape';
const test = require('supertape'); import {getDOM} from './globals.fixture.js';
const dir = './';
const {getDOM} = require('./globals.fixture');
global.DOM = getDOM(); global.DOM = getDOM();
const { import {_next, _previous} from './find.js';
_next,
_previous,
} = require(dir + 'find');
test('cloudcmd: client: vim: _next', (t) => { test('cloudcmd: client: vim: _next', (t) => {
const result = _next(1, 2); const result = _next(1, 2);

View file

@ -1,6 +1,4 @@
'use strict'; export const getDOM = () => {
module.exports.getDOM = () => {
const prompt = Promise.resolve.bind(Promise); const prompt = Promise.resolve.bind(Promise);
const CurrentInfo = { const CurrentInfo = {
element: {}, element: {},
@ -31,7 +29,7 @@ module.exports.getDOM = () => {
}; };
}; };
module.exports.getCloudCmd = () => { export const getCloudCmd = () => {
const show = () => {}; const show = () => {};
return { return {

View file

@ -1,15 +1,13 @@
'use strict';
/* global CloudCmd */ /* global CloudCmd */
/* global DOM */ /* global DOM */
const vim = require('./vim'); import vim from './vim.js';
const finder = require('./find'); import finder from './find.js';
const Info = DOM.CurrentInfo; const Info = DOM.CurrentInfo;
const {Dialog} = DOM; const {Dialog} = DOM;
module.exports = async (key, event) => { export default async (key, event) => {
const operations = getOperations(event); const operations = getOperations(event);
await vim(key, operations); await vim(key, operations);
}; };
@ -66,9 +64,7 @@ const getOperations = (event) => {
}; };
}; };
module.exports.selectFile = selectFile; export function selectFile(current) {
function selectFile(current) {
const name = DOM.getCurrentName(current); const name = DOM.getCurrentName(current);
if (name === '..') if (name === '..')

View file

@ -1,10 +1,10 @@
'use strict'; import {join} from 'path';
const {join} = require('path'); import test from 'supertape';
import stub from '@cloudcmd/stub';
import mockRequire from 'mock-require';
import vim from './index.js';
const test = require('supertape');
const stub = require('@cloudcmd/stub');
const mockRequire = require('mock-require');
const {reRequire, stopAll} = mockRequire; const {reRequire, stopAll} = mockRequire;
const dir = '../'; const dir = '../';
@ -12,10 +12,7 @@ const dir = '../';
const pathVim = join(dir, 'vim'); const pathVim = join(dir, 'vim');
const pathFind = join(dir, 'vim', 'find'); const pathFind = join(dir, 'vim', 'find');
const { import {getDOM, getCloudCmd} from './globals.fixture.js';
getDOM,
getCloudCmd,
} = require('./globals.fixture');
global.DOM = getDOM(); global.DOM = getDOM();
global.CloudCmd = getCloudCmd(); global.CloudCmd = getCloudCmd();
@ -23,8 +20,6 @@ global.CloudCmd = getCloudCmd();
const {DOM} = global; const {DOM} = global;
const {Buffer} = DOM; const {Buffer} = DOM;
const vim = require(pathVim);
test('cloudcmd: client: key: set next file: no', (t) => { test('cloudcmd: client: key: set next file: no', (t) => {
const element = { const element = {
}; };

View file

@ -1,6 +1,4 @@
'use strict'; import fullstore from 'fullstore';
const fullstore = require('fullstore');
const store = fullstore(''); const store = fullstore('');
const visual = fullstore(false); const visual = fullstore(false);
@ -21,7 +19,7 @@ const rmFirst = (a) => {
const noop = () => {}; const noop = () => {};
module.exports = (key, operations) => { export default (key, operations) => {
const prevStore = store(); const prevStore = store();
const isVisual = visual(); const isVisual = visual();
const value = store(prevStore.concat(key)); const value = store(prevStore.concat(key));

View file

@ -1,9 +1,7 @@
'use strict'; import test from 'supertape';
import stub from '@cloudcmd/stub';
const test = require('supertape'); import vim from './vim.js';
const stub = require('@cloudcmd/stub');
const vim = require('./vim');
test('vim: no operations', (t) => { test('vim: no operations', (t) => {
const result = vim('hello', {}); const result = vim('hello', {});

View file

@ -1,6 +1,4 @@
'use strict'; export default (array, item) => {
module.exports = (array, item) => {
const index = array.indexOf(item); const index = array.indexOf(item);
if (!~index) if (!~index)

View file

@ -1,6 +1,4 @@
'use strict'; export default (indexFrom, indexTo, files) => {
module.exports = (indexFrom, indexTo, files) => {
if (indexFrom < indexTo) if (indexFrom < indexTo)
return files.slice(indexFrom, indexTo + 1); return files.slice(indexFrom, indexTo + 1);

View file

@ -1,23 +1,21 @@
/* global DOM, CloudCmd */ /* global DOM, CloudCmd */
'use strict'; import exec from 'execon';
import itype from 'itype';
import currify from 'currify';
import tryToCatch from 'try-to-catch';
import clipboard from '@cloudcmd/clipboard';
const exec = require('execon'); import getRange from './get-range.js';
const itype = require('itype');
const currify = require('currify');
const tryToCatch = require('try-to-catch');
const clipboard = require('@cloudcmd/clipboard');
const getRange = require('./get-range');
const getIndex = currify(require('./get-index')); const getIndex = currify(require('./get-index'));
const uploadFiles = require('../dom/upload-files'); import uploadFiles from '../dom/upload-files.js';
const {FS} = require('../../common/cloudfunc'); import {FS} from '../../common/cloudfunc.js';
const NBSP_REG = RegExp(String.fromCharCode(160), 'g'); const NBSP_REG = RegExp(String.fromCharCode(160), 'g');
const SPACE = ' '; const SPACE = ' ';
module.exports.init = async () => { export const init = async () => {
await Promise.all([ await Promise.all([
contextMenu(), contextMenu(),
dragndrop(), dragndrop(),
@ -108,7 +106,7 @@ async function config() {
EXT = DOM.getPackerExt(type); EXT = DOM.getPackerExt(type);
} }
module.exports.initKeysPanel = () => { export const initKeysPanel = () => {
const keysElement = DOM.getById('js-keyspanel'); const keysElement = DOM.getById('js-keyspanel');
if (!keysElement) if (!keysElement)
@ -154,7 +152,7 @@ const getPanel = (side) => {
return DOM.getByDataName('js-' + side); return DOM.getByDataName('js-' + side);
}; };
module.exports.setOnPanel = (side) => { export const setOnPanel = (side) => {
const panel = getPanel(side); const panel = getPanel(side);
const filesElement = DOM.getByDataName('js-files', panel); const filesElement = DOM.getByDataName('js-files', panel);

View file

@ -1,19 +1,17 @@
'use strict';
/* global CloudCmd */ /* global CloudCmd */
const exec = require('execon'); import exec from 'execon';
const tryToCatch = require('try-to-catch'); import tryToCatch from 'try-to-catch';
const loadJS = require('load.js').js; const loadJS = require('load.js').js;
const pascalCase = require('just-pascal-case'); import pascalCase from 'just-pascal-case';
const noJS = (a) => a.replace(/.js$/, ''); const noJS = (a) => a.replace(/.js$/, '');
/** /**
* function load modules * function load modules
* @params = {name, path, func, dobefore, arg} * @params = {name, path, func, dobefore, arg}
*/ */
module.exports = function loadModule(params) { export default function loadModule(params) {
if (!params) if (!params)
return; return;
@ -56,5 +54,5 @@ module.exports = function loadModule(params) {
await a.show(...args); await a.show(...args);
}; };
}; }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,11 +1,9 @@
'use strict'; import currify from 'currify';
const currify = require('currify');
const not = currify((array, value) => !array.includes(value)); const not = currify((array, value) => !array.includes(value));
const notOneOf = currify((a, b) => a.filter(not(b))); 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 i = names.indexOf(currentName);
const nextNames = notOneOf(names, removedNames); const nextNames = notOneOf(names, removedNames);

View file

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

View file

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

View file

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

View file

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

View file

@ -1,10 +1,8 @@
'use strict';
/* global DOM */ /* 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, { DOM.scrollIntoViewIfNeeded = (el) => scrollIntoViewIfNeeded(el, {
block: 'nearest', block: 'nearest',
}); });

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,5 @@
'use strict';
/* global CloudCmd */ /* global CloudCmd */
const DOM = require('./dom'); import DOM from './dom.js';
const Info = DOM.CurrentInfo; const Info = DOM.CurrentInfo;

View file

@ -1,13 +1,8 @@
'use strict'; export const listenSW = (sw, ...args) => {
module.exports.registerSW = registerSW;
module.exports.unregisterSW = unregisterSW;
module.exports.listenSW = (sw, ...args) => {
sw && sw.addEventListener(...args); sw && sw.addEventListener(...args);
}; };
async function registerSW(prefix) { export async function registerSW(prefix) {
if (!navigator.serviceWorker) if (!navigator.serviceWorker)
return; return;
@ -19,7 +14,7 @@ async function registerSW(prefix) {
return await navigator.serviceWorker.register(`${prefix}/sw.js`); return await navigator.serviceWorker.register(`${prefix}/sw.js`);
} }
async function unregisterSW(prefix) { export async function unregisterSW(prefix) {
const reg = await registerSW(prefix); const reg = await registerSW(prefix);
reg && reg.unregister(prefix); reg && reg.unregister(prefix);
} }

View file

@ -1,13 +1,11 @@
'use strict'; import autoGlobals from 'auto-globals';
import tape from 'supertape';
const autoGlobals = require('auto-globals');
const tape = require('supertape');
const test = autoGlobals(tape); const test = autoGlobals(tape);
const stub = require('@cloudcmd/stub'); import stub from '@cloudcmd/stub';
const tryCatch = require('try-catch'); import tryCatch from 'try-catch';
const {reRequire} = require('mock-require'); import {reRequire} from 'mock-require';
test('sw: listen', (t) => { test('sw: listen', (t) => {
const {listenSW} = reRequire('./register'); const {listenSW} = reRequire('./register');

View file

@ -1,8 +1,6 @@
'use strict'; import codegen from 'codegen.macro';
import tryToCatch from 'try-to-catch';
const codegen = require('codegen.macro'); import currify from 'currify';
const tryToCatch = require('try-to-catch');
const currify = require('currify');
const isDev = process.env.NODE_ENV === 'development'; const isDev = process.env.NODE_ENV === 'development';

View file

@ -192,6 +192,7 @@
"html-looks-like": "^1.0.2", "html-looks-like": "^1.0.2",
"html-webpack-plugin": "^4.0.1", "html-webpack-plugin": "^4.0.1",
"inherits": "^2.0.3", "inherits": "^2.0.3",
"itype": "^3.0.1",
"just-capitalize": "^1.0.0", "just-capitalize": "^1.0.0",
"just-pascal-case": "^1.1.0", "just-pascal-case": "^1.1.0",
"limier": "^3.0.0", "limier": "^3.0.0",
@ -220,8 +221,8 @@
"tar-stream": "^2.0.0", "tar-stream": "^2.0.0",
"unionfs": "^4.0.0", "unionfs": "^4.0.0",
"url-loader": "^4.0.0", "url-loader": "^4.0.0",
"webpack": "^4.0.0", "webpack": "^5.11.0",
"webpack-cli": "^3.0.1", "webpack-cli": "^4.2.0",
"webpack-merge": "^5.0.8", "webpack-merge": "^5.0.8",
"yaspeller": "^7.0.0" "yaspeller": "^7.0.0"
}, },

14
webpack.config.cjs Normal file
View file

@ -0,0 +1,14 @@
'use strict';
const {merge} = require('webpack-merge');
const htmlConfig = require('./.webpack/html.cjs');
const cssConfig = require('./.webpack/css.cjs');
const jsConfig = require('./.webpack/js.cjs');
module.exports = merge([
jsConfig,
htmlConfig,
cssConfig,
]);

View file

@ -1,14 +0,0 @@
'use strict';
const {merge} = require('webpack-merge');
const htmlConfig = require('./.webpack/html');
const cssConfig = require('./.webpack/css');
const jsConfig = require('./.webpack/js');
module.exports = merge([
jsConfig,
htmlConfig,
cssConfig,
]);