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"
],
"rules": {
"convert-commonjs-to-esm": "on"
"convert-commonjs-to-esm": "on",
"remove-empty/import": "off"
},
"match": {
"{import.spec.js,console.js}": {

View file

@ -1,35 +1,29 @@
'use strict';
/* global DOM */
const Emitify = require('emitify');
const inherits = require('inherits');
const rendy = require('rendy');
const load = require('load.js');
const tryToCatch = require('try-to-catch');
import Emitify from 'emitify';
import inherits from 'inherits';
import rendy from 'rendy';
import load from 'load.js';
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 Images = require('./dom/images');
const {unregisterSW} = require('./sw/register');
const getJsonFromFileTable = require('./get-json-from-file-table');
import Images from './dom/images.js';
import {unregisterSW} from './sw/register.js';
import getJsonFromFileTable from './get-json-from-file-table.js';
const currify = require('currify');
import currify from 'currify';
const noJS = (a) => a.replace(/.js$/, '');
const {
apiURL,
formatMsg,
buildFromJSON,
} = require('../common/cloudfunc');
import {apiURL, formatMsg, buildFromJSON} from '../common/cloudfunc.js';
const loadModule = require('./load-module');
import loadModule from './load-module.js';
inherits(CloudCmdProto, Emitify);
module.exports = new CloudCmdProto(DOM);
export default new CloudCmdProto(DOM);
load.addErrorListener((e, src) => {
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');
require('../css/nojs.css');
require('../css/columns/name-size-date.css');
require('../css/columns/name-size.css');
const wraptile = require('wraptile');
const load = require('load.js');
import wraptile from 'wraptile';
import load from 'load.js';
const isDev = process.env.NODE_ENV === 'development';
const {
registerSW,
listenSW,
} = require('./sw/register');
import {registerSW, listenSW} from './sw/register.js';
// prevent additional loading of emitify
window.Emitify = require('emitify');
window.Emitify = await import('emitify');
module.exports = window.CloudCmd = async (config) => {
window.Util = require('../common/util');
window.CloudFunc = require('../common/cloudfunc');
export default window.CloudCmd = async (config) => {
window.Util = await import('../common/util');
window.CloudFunc = await iimport('../common/cloudfunc');
const DOM = require('./dom');
const DOM = await import('./dom');
window.DOM = DOM;
window.CloudCmd = require('./client');
await register(config);
require('./listeners');
require('./key');
require('./sort');
await Promise.all([
import('./listeners'),
import('./key');
import('./sort');
]);
const prefix = getPrefix(config.prefix);

View file

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

View file

@ -1,20 +1,12 @@
'use strict';
/* global DOM */
/* global CloudCmd */
const btoa = require('../../common/btoa');
const createElement = require('@cloudcmd/create-element');
import btoa from '../../common/btoa.js';
import createElement from '@cloudcmd/create-element';
const {
encode,
decode,
} = require('../../common/entity');
import {encode, decode} from '../../common/entity.js';
const {
getTitle,
FS,
} = require('../../common/cloudfunc');
import {getTitle, FS} from '../../common/cloudfunc.js';
let Title;
@ -22,7 +14,7 @@ const CURRENT_FILE = 'current-file';
const NBSP_REG = RegExp(String.fromCharCode(160), 'g');
const SPACE = ' ';
module.exports._CURRENT_FILE = CURRENT_FILE;
export const _CURRENT_FILE = CURRENT_FILE;
/**
* set name from current (or param) file
@ -30,7 +22,7 @@ module.exports._CURRENT_FILE = CURRENT_FILE;
* @param name
* @param current
*/
module.exports.setCurrentName = (name, current) => {
export const setCurrentName = (name, current) => {
const Info = DOM.CurrentInfo;
const {link} = Info;
const {prefix} = CloudCmd;
@ -52,7 +44,7 @@ module.exports.setCurrentName = (name, current) => {
*
* @param currentFile
*/
module.exports.getCurrentName = (currentFile) => {
export const getCurrentName = (currentFile) => {
const current = currentFile || DOM.getCurrentFile();
if (!current)
@ -70,7 +62,7 @@ module.exports.getCurrentName = (currentFile) => {
/**
* get current direcotory path
*/
module.exports.getCurrentDirPath = (panel = DOM.getPanel()) => {
export const getCurrentDirPath = (panel = DOM.getPanel()) => {
const path = DOM.getByDataName('js-path', panel);
return path.textContent
.replace(NBSP_REG, SPACE);
@ -81,7 +73,7 @@ module.exports.getCurrentDirPath = (panel = DOM.getPanel()) => {
*
* @param currentFile - current file by default
*/
module.exports.getCurrentPath = (currentFile) => {
export const getCurrentPath = (currentFile) => {
const current = currentFile || DOM.getCurrentFile();
const [element] = DOM.getByTag('a', current);
const {prefix} = CloudCmd;
@ -97,7 +89,7 @@ module.exports.getCurrentPath = (currentFile) => {
/**
* get current direcotory name
*/
module.exports.getCurrentDirName = () => {
export const getCurrentDirName = () => {
const href = DOM.getCurrentDirPath()
.replace(/\/$/, '');
@ -110,7 +102,7 @@ module.exports.getCurrentDirName = () => {
/**
* get current direcotory path
*/
module.exports.getParentDirPath = (panel) => {
export const getParentDirPath = (panel) => {
const path = DOM.getCurrentDirPath(panel);
const dirName = DOM.getCurrentDirName() + '/';
const index = path.lastIndexOf(dirName);
@ -124,7 +116,7 @@ module.exports.getParentDirPath = (panel) => {
/**
* get not current direcotory path
*/
module.exports.getNotCurrentDirPath = () => {
export const getNotCurrentDirPath = () => {
const panel = DOM.getPanel({
active: false,
});
@ -137,14 +129,14 @@ module.exports.getNotCurrentDirPath = () => {
*
* @currentFile
*/
module.exports.getCurrentFile = () => {
export const getCurrentFile = () => {
return DOM.getByClass(CURRENT_FILE);
};
/**
* 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));
return DOM.getByDataName(dataName, panel);
};
@ -166,7 +158,7 @@ function unsetCurrentFile(currentFile) {
/**
* unified way to set current file
*/
module.exports.setCurrentFile = (currentFile, options) => {
export const setCurrentFile = (currentFile, options) => {
const o = options;
const currentFileWas = DOM.getCurrentFile();
@ -223,7 +215,7 @@ this.setCurrentByName = (name) => {
* @param layer - element
* @param - position {x, y}
*/
module.exports.getCurrentByPosition = ({x, y}) => {
export const getCurrentByPosition = ({x, y}) => {
const element = document.elementFromPoint(x, y);
const getEl = (el) => {
@ -255,7 +247,7 @@ module.exports.getCurrentByPosition = ({x, y}) => {
*
* @param currentFile
*/
module.exports.isCurrentFile = (currentFile) => {
export const isCurrentFile = (currentFile) => {
if (!currentFile)
return false;
@ -268,7 +260,7 @@ module.exports.isCurrentFile = (currentFile) => {
* @param name
*/
module.exports.setTitle = (name) => {
export const setTitle = (name) => {
if (!Title)
Title = DOM.getByTag('title')[0] || createElement('title', {
innerHTML: name,
@ -285,14 +277,14 @@ module.exports.setTitle = (name) => {
*
* @param currentFile
*/
module.exports.isCurrentIsDir = (currentFile) => {
export const isCurrentIsDir = (currentFile) => {
const current = currentFile || DOM.getCurrentFile();
const fileType = DOM.getCurrentType(current);
return /^directory(-link)?/.test(fileType);
};
module.exports.getCurrentType = (currentFile) => {
export const getCurrentType = (currentFile) => {
const current = currentFile || DOM.getCurrentFile();
const el = DOM.getByDataName('js-type', current);
const type = el.className

View file

@ -1,13 +1,11 @@
'use strict';
const test = require('supertape');
const {create} = require('auto-globals');
const stub = require('@cloudcmd/stub');
import test from 'supertape';
import {create} from 'auto-globals';
import stub from '@cloudcmd/stub';
const id = (a) => a;
const wraptile = require('wraptile');
import wraptile from 'wraptile';
const returns = wraptile(id);
const currentFile = require('./current-file');
import currentFile from './current-file.js';
const {_CURRENT_FILE} = currentFile;
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');
const {
alert,
prompt,
confirm,
progress,
} = require('smalltalk');
import {alert, prompt, confirm, progress} from 'smalltalk';
const title = 'Cloud Commander';
module.exports.alert = (...a) => alert(title, ...a, {
const customAlert = (...a) => alert(title, ...a, {
cancel: false,
});
module.exports.prompt = (...a) => tryToCatch(prompt, title, ...a);
module.exports.confirm = (...a) => tryToCatch(confirm, title, ...a);
module.exports.progress = (...a) => progress(title, ...a);
module.exports.alert.noFiles = () => {
customAlert.noFiles = () => {
return alert(title, 'No files selected!', {
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 */
const philip = require('philip');
import philip from 'philip';
const Images = require('./images');
const {FS} = require('../../common/cloudfunc');
const DOM = require('.');
const Dialog = require('./dialog');
import Images from './images.js';
import {FS} from '../../common/cloudfunc.js';
import DOM from '.';
import Dialog from './dialog.js';
const {getCurrentDirPath: getPathWhenRootEmpty} = DOM;
module.exports = (items) => {
export default (items) => {
if (items.length)
Images.show('top');

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,8 +1,6 @@
/* global DOM */
'use strict';
const createElement = require('@cloudcmd/create-element');
import createElement from '@cloudcmd/create-element';
const Images = module.exports;
@ -14,7 +12,7 @@ function getLoadingType() {
return isSVG() ? '-svg' : '-gif';
}
module.exports.get = getElement;
export const get = getElement;
/**
* check SVG SMIL animation support
@ -43,7 +41,7 @@ function getElement() {
}
/* Функция создаёт картинку загрузки */
module.exports.loading = () => {
export const loading = () => {
const element = getElement();
const {classList} = element;
const loadingImage = LOADING + getLoadingType();
@ -55,7 +53,7 @@ module.exports.loading = () => {
};
/* Функция создаёт картинку ошибки загрузки */
module.exports.error = () => {
export const error = () => {
const element = getElement();
const {classList} = element;
const loadingImage = LOADING + getLoadingType();
@ -66,14 +64,17 @@ module.exports.error = () => {
return element;
};
module.exports.show = show;
module.exports.show.load = show;
module.exports.show.error = error;
module.exports.show.error = showError;
/**
* Function shows loading spinner
* position = {top: true};
*/
export /**
* Function shows loading spinner
* position = {top: true};
*/
function show(position, panel) {
const image = Images.loading();
const parent = image.parentElement;
@ -100,7 +101,7 @@ function show(position, panel) {
return image;
}
function error(text) {
function showError(text) {
const image = Images.error();
DOM.show(image);
@ -112,7 +113,7 @@ function error(text) {
/**
* hide load image
*/
module.exports.hide = () => {
export const hide = () => {
const element = Images.get();
DOM.hide(element);
@ -120,7 +121,7 @@ module.exports.hide = () => {
return Images;
};
module.exports.setProgress = (value, title) => {
export const setProgress = (value, title) => {
const DATA = 'data-progress';
const element = Images.get();
@ -135,7 +136,7 @@ module.exports.setProgress = (value, title) => {
return Images;
};
module.exports.clearProgress = () => {
export const clearProgress = () => {
const DATA = 'data-progress';
const element = Images.get();

View file

@ -1,23 +1,21 @@
/* 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');
const callbackify = require('../../common/callbackify');
import Images from './images.js';
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');
const load = require('./load');
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');
import CurrentFile from './current-file.js';
import DOMTree from './dom-tree.js';
const DOM = {
...DOMTree,
@ -33,14 +31,14 @@ DOM.IO = IO;
DOM.Storage = Storage;
DOM.Dialog = Dialog;
module.exports = DOM;
export default DOM;
DOM.uploadDirectory = require('./directory');
DOM.Buffer = require('./buffer');
DOM.Events = require('./events');
const loadRemote = require('./load-remote');
const selectByPattern = require('./select-by-pattern');
import loadRemote from './load-remote.js';
import selectByPattern from './select-by-pattern.js';
function CmdProto() {
const CurrentInfo = {};

View file

@ -1,13 +1,11 @@
'use strict';
const {FS} = require('../../../common/cloudfunc');
const sendRequest = require('./send-request');
import {FS} from '../../../common/cloudfunc.js';
import sendRequest from './send-request.js';
const imgPosition = {
top: true,
};
module.exports.delete = async (url, data) => {
export const remove = async (url, data) => {
return await sendRequest({
method : 'DELETE',
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({
method: 'PATCH',
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({
method: 'PUT',
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({
method: 'PUT',
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('?');
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({
method: 'PUT',
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({
method: 'PUT',
url: '/pack',
@ -76,7 +74,7 @@ module.exports.pack = async (data) => {
});
};
module.exports.extract = async (data) => {
export const extract = async (data) => {
return await sendRequest({
method: 'PUT',
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({
method: 'PUT',
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({
method: 'PUT',
url: '/rename',
@ -109,7 +107,7 @@ module.exports.rename = async (from, to) => {
});
};
module.exports.Config = {
export const Config = {
read: async () => {
return await sendRequest({
method: 'GET',
@ -129,7 +127,7 @@ module.exports.Config = {
},
};
module.exports.Markdown = {
export const Markdown = {
read: async (url) => {
return await sendRequest({
method: 'GET',

View file

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

View file

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

View file

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

View file

@ -1,17 +1,15 @@
'use strict';
/* global CloudCmd */
const rendy = require('rendy');
const itype = require('itype');
const load = require('load.js');
const tryToCatch = require('try-to-catch');
import rendy from 'rendy';
import itype from 'itype';
import load from 'load.js';
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 o = options;

View file

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

View file

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

View file

@ -1,8 +1,6 @@
'use strict';
const test = require('supertape');
const stub = require('@cloudcmd/stub');
const mockRequire = require('mock-require');
import test from 'supertape';
import stub from '@cloudcmd/stub';
import mockRequire from 'mock-require';
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');
const Images = require('./images');
const IO = require('./io');
const Dialog = require('./dialog');
import Images from './images.js';
import IO from './io.js';
import Dialog from './dialog.js';
const handleError = (promise) => async (...args) => {
const [e, data] = await tryToCatch(promise, ...args);
@ -22,23 +20,23 @@ const handleError = (promise) => async (...args) => {
return [e, data];
};
module.exports.delete = handleError(IO.delete);
module.exports.patch = handleError(IO.patch);
module.exports.write = handleError(IO.write);
module.exports.createDirectory = handleError(IO.createDirectory);
module.exports.read = handleError(IO.read);
module.exports.copy = handleError(IO.copy);
module.exports.pack = handleError(IO.pack);
module.exports.extract = handleError(IO.extract);
module.exports.move = handleError(IO.move);
module.exports.rename = handleError(IO.rename);
export const remove = handleError(IO.remove);
export const patch = handleError(IO.patch);
export const write = handleError(IO.write);
export const createDirectory = handleError(IO.createDirectory);
export const read = handleError(IO.read);
export const copy = handleError(IO.copy);
export const pack = handleError(IO.pack);
export const extract = handleError(IO.extract);
export const move = handleError(IO.move);
export const rename = handleError(IO.rename);
module.exports.Config = {
export const Config = {
read: handleError(IO.Config.read),
write: handleError(IO.Config.write),
};
module.exports.Markdown = {
export const Markdown = {
read: handleError(IO.Markdown.read),
render: handleError(IO.Markdown.render),
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,11 +1,9 @@
/* global DOM */
'use strict';
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 skipCount = 0;
let setted = false;
@ -55,5 +53,5 @@ module.exports = function setCurrentByChar(char, charStore) {
DOM.setCurrentFile(firstByName);
charStore([char]);
}
};
}

View file

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

View file

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

View file

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

View file

@ -1,15 +1,13 @@
'use strict';
/* global CloudCmd */
/* global DOM */
const vim = require('./vim');
const finder = require('./find');
import vim from './vim.js';
import finder from './find.js';
const Info = DOM.CurrentInfo;
const {Dialog} = DOM;
module.exports = async (key, event) => {
export default async (key, event) => {
const operations = getOperations(event);
await vim(key, operations);
};
@ -66,9 +64,7 @@ const getOperations = (event) => {
};
};
module.exports.selectFile = selectFile;
function selectFile(current) {
export function selectFile(current) {
const name = DOM.getCurrentName(current);
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 dir = '../';
@ -12,10 +12,7 @@ const dir = '../';
const pathVim = join(dir, 'vim');
const pathFind = join(dir, 'vim', 'find');
const {
getDOM,
getCloudCmd,
} = require('./globals.fixture');
import {getDOM, getCloudCmd} from './globals.fixture.js';
global.DOM = getDOM();
global.CloudCmd = getCloudCmd();
@ -23,8 +20,6 @@ global.CloudCmd = getCloudCmd();
const {DOM} = global;
const {Buffer} = DOM;
const vim = require(pathVim);
test('cloudcmd: client: key: set next file: no', (t) => {
const element = {
};

View file

@ -1,6 +1,4 @@
'use strict';
const fullstore = require('fullstore');
import fullstore from 'fullstore';
const store = fullstore('');
const visual = fullstore(false);
@ -21,7 +19,7 @@ const rmFirst = (a) => {
const noop = () => {};
module.exports = (key, operations) => {
export default (key, operations) => {
const prevStore = store();
const isVisual = visual();
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');
const stub = require('@cloudcmd/stub');
const vim = require('./vim');
import vim from './vim.js';
test('vim: no operations', (t) => {
const result = vim('hello', {});

View file

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

View file

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

View file

@ -1,23 +1,21 @@
/* 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');
const itype = require('itype');
const currify = require('currify');
const tryToCatch = require('try-to-catch');
const clipboard = require('@cloudcmd/clipboard');
const getRange = require('./get-range');
import getRange from './get-range.js';
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 SPACE = ' ';
module.exports.init = async () => {
export const init = async () => {
await Promise.all([
contextMenu(),
dragndrop(),
@ -108,7 +106,7 @@ async function config() {
EXT = DOM.getPackerExt(type);
}
module.exports.initKeysPanel = () => {
export const initKeysPanel = () => {
const keysElement = DOM.getById('js-keyspanel');
if (!keysElement)
@ -154,7 +152,7 @@ const getPanel = (side) => {
return DOM.getByDataName('js-' + side);
};
module.exports.setOnPanel = (side) => {
export const setOnPanel = (side) => {
const panel = getPanel(side);
const filesElement = DOM.getByDataName('js-files', panel);

View file

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

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;

View file

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

View file

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

View file

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

View file

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

View file

@ -192,6 +192,7 @@
"html-looks-like": "^1.0.2",
"html-webpack-plugin": "^4.0.1",
"inherits": "^2.0.3",
"itype": "^3.0.1",
"just-capitalize": "^1.0.0",
"just-pascal-case": "^1.1.0",
"limier": "^3.0.0",
@ -220,8 +221,8 @@
"tar-stream": "^2.0.0",
"unionfs": "^4.0.0",
"url-loader": "^4.0.0",
"webpack": "^4.0.0",
"webpack-cli": "^3.0.1",
"webpack": "^5.11.0",
"webpack-cli": "^4.2.0",
"webpack-merge": "^5.0.8",
"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,
]);