cloudcmd 16.1.1 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +8 -0
- package/HELP.md +2 -1
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/bin/cloudcmd.mjs +13 -12
- package/dist/cloudcmd.common.js +2 -2
- package/dist/cloudcmd.common.js.map +1 -1
- package/dist/cloudcmd.js +1 -1
- package/dist/cloudcmd.js.map +1 -1
- package/dist/modules/cloud.js +1 -1
- package/dist/modules/cloud.js.map +1 -1
- package/dist/modules/config.js +1 -1
- package/dist/modules/edit.js +1 -1
- package/dist/modules/edit.js.map +1 -1
- package/dist/modules/markdown.js +1 -1
- package/dist/modules/markdown.js.map +1 -1
- package/dist/modules/menu.js +1 -1
- package/dist/modules/operation.js +1 -1
- package/dist/modules/operation.js.map +1 -1
- package/dist/modules/terminal-run.js +1 -1
- package/dist/modules/upload.js +1 -1
- package/dist/modules/user-menu.js +1 -1
- package/dist/modules/view.js +1 -1
- package/dist/sw.js +1 -1
- package/dist-dev/cloudcmd.common.js +2 -2
- package/dist-dev/cloudcmd.js +5 -5
- package/dist-dev/modules/cloud.js +1 -1
- package/dist-dev/modules/edit.js +1 -1
- package/dist-dev/modules/markdown.js +1 -1
- package/dist-dev/modules/operation.js +1 -1
- package/dist-dev/sw.js +1 -1
- package/package.json +3 -3
- package/server/cloudcmd.js +5 -5
- package/server/config.js +4 -4
- package/server/distribute/import.js +2 -2
- package/server/markdown/index.js +2 -2
- package/server/route.js +6 -6
- package/server/{server.js → server.mjs} +19 -22
- package/tmpl/config.hbs +2 -2
package/dist-dev/cloudcmd.js
CHANGED
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
/***/ (function(module, exports, __webpack_require__) {
|
|
164
164
|
|
|
165
165
|
"use strict";
|
|
166
|
-
eval("\n/* global DOM */\n\nconst Emitify = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\n\nconst inherits = __webpack_require__(/*! inherits */ \"./node_modules/inherits/inherits_browser.js\");\n\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst {\n addSlashToEnd\n} = __webpack_require__(/*! format-io */ \"./node_modules/format-io/lib/format.js\");\n\nconst pascalCase = __webpack_require__(/*! just-pascal-case */ \"./node_modules/just-pascal-case/index.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst isDev = \"development\" === 'development';\n\nconst Images = __webpack_require__(/*! ./dom/images */ \"./client/dom/images.js\");\n\nconst {\n unregisterSW\n} = __webpack_require__(/*! ./sw/register */ \"./client/sw/register.js\");\n\nconst getJsonFromFileTable = __webpack_require__(/*! ./get-json-from-file-table */ \"./client/get-json-from-file-table.js\");\n\nconst Key = __webpack_require__(/*! ./key */ \"./client/key/index.js\");\n\nconst noJS = a => a.replace(/.js$/, '');\n\nconst {\n apiURL,\n formatMsg,\n buildFromJSON\n} = __webpack_require__(/*! ../common/cloudfunc */ \"./common/cloudfunc.js\");\n\nconst loadModule = __webpack_require__(/*! ./load-module */ \"./client/load-module.js\");\n\ninherits(CloudCmdProto, Emitify);\nmodule.exports = new CloudCmdProto(DOM);\nload.addErrorListener((e, src) => {\n const msg = `file ${src} could not be loaded`;\n Images.show.error(msg);\n});\n\nfunction CloudCmdProto(DOM) {\n let Listeners;\n\n const log = function () {\n if (!isDev) return;\n console.log(...arguments);\n };\n\n Emitify.call(this);\n const CloudCmd = this;\n const Info = DOM.CurrentInfo;\n const {\n Storage,\n Files\n } = DOM;\n this.log = log;\n this.prefix = '';\n this.prefixSocket = '';\n this.prefixURL = '';\n this.DIRCLIENT = '/dist/';\n this.DIRCLIENT_MODULES = this.DIRCLIENT + 'modules/';\n this.MIN_ONE_PANEL_WIDTH = 1155;\n this.HOST = location.origin || location.protocol + '//' + location.host;\n const TITLE = 'Cloud Commander';\n this.TITLE = TITLE;\n this.sort = {\n left: 'name',\n right: 'name'\n };\n this.order = {\n left: 'asc',\n right: 'asc'\n };\n /**\n * Функция привязываеться ко всем ссылкам и\n * загружает содержимое каталогов\n *\n * @param params - {\n * paramLink - ссылка\n * needRefresh - необходимость обязательной загрузки данных с сервера\n * panel\n * }\n * @param callback\n */\n\n this.loadDir = async params => {\n const p = params;\n const refresh = p.isRefresh;\n const {\n panel,\n history = true,\n noCurrent,\n currentName\n } = p;\n let panelChanged;\n\n if (!noCurrent && panel && panel !== Info.panel) {\n DOM.changePanel();\n panelChanged = true;\n }\n\n let imgPosition;\n if (panelChanged || refresh || !history) imgPosition = 'top';\n Images.show.load(imgPosition, panel);\n const path = addSlashToEnd(p.path);\n /* загружаем содержимое каталога */\n\n await ajaxLoad(path, {\n refresh,\n history,\n noCurrent,\n currentName\n }, panel);\n };\n /**\n * Конструктор CloudClient, который\n * выполняет весь функционал по\n * инициализации\n */\n\n\n this.init = async (prefix, config) => {\n CloudCmd.prefix = prefix;\n CloudCmd.prefixURL = `${prefix}${apiURL}`;\n CloudCmd.prefixSocket = config.prefixSocket;\n\n CloudCmd.config = key => config[key];\n\n CloudCmd.config.if = currify((key, fn, a) => config[key] && fn(a));\n\n CloudCmd._config = (key, value) => {\n /*\n * should be called from config.js only\n * after successful update on server\n */\n if (key === 'password') return;\n config[key] = value;\n };\n\n if (config.oneFilePanel) CloudCmd.MIN_ONE_PANEL_WIDTH = Infinity;\n if (!document.body.scrollIntoViewIfNeeded) await load.js(prefix + CloudCmd.DIRCLIENT_MODULES + 'polyfill.js');\n await initModules();\n await baseInit();\n await loadStyle();\n CloudCmd.route(location.hash);\n };\n\n async function loadStyle() {\n const {\n prefix\n } = CloudCmd;\n const name = prefix + '/dist/cloudcmd.common.css';\n await load.css(name);\n }\n\n this.route = path => {\n const query = path.split('/');\n if (!path) return;\n const [kebabModule] = query;\n const module = noJS(pascalCase(kebabModule.slice(1)));\n const file = query[1];\n const current = DOM.getCurrentByName(file);\n\n if (file && !current) {\n const msg = formatMsg('set current file', file, 'error');\n CloudCmd.log(msg);\n return;\n }\n\n DOM.setCurrentFile(current);\n CloudCmd.execFromModule(module, 'show');\n };\n\n this.logOut = async () => {\n const url = CloudCmd.prefix + '/logout';\n\n const error = () => document.location.reload();\n\n const {\n prefix\n } = CloudCmd;\n await DOM.Storage.clear();\n unregisterSW(prefix);\n DOM.load.ajax({\n url,\n error\n });\n };\n\n const initModules = async () => {\n CloudCmd.Key = Key;\n CloudCmd.Key.bind();\n const [, modules] = await tryToCatch(Files.get, 'modules');\n const showLoad = Images.show.load;\n const doBefore = {\n edit: showLoad,\n menu: showLoad\n };\n\n const load = (name, path, dobefore) => {\n loadModule({\n name,\n path,\n dobefore\n });\n };\n\n if (!modules) return;\n\n for (const module of modules.local) {\n load(null, module, doBefore[module]);\n }\n };\n\n async function saveCurrentName(currentName) {\n await Storage.set('current-name', currentName);\n }\n\n async function baseInit() {\n const files = DOM.getFiles();\n CloudCmd.on('current-file', DOM.updateCurrentInfo);\n CloudCmd.on('current-name', saveCurrentName);\n const name = await Storage.get('current-name');\n const currentFile = name && DOM.getCurrentByName(name) || files[0];\n /* выделяем строку с первым файлом */\n\n if (files) DOM.setCurrentFile(currentFile, {\n // when hash is present\n // it should be handled with this.route\n // overwre otherwise\n history: !location.hash\n });\n const dirPath = DOM.getCurrentDirPath();\n Listeners = CloudCmd.Listeners;\n Listeners.init();\n const panels = getPanels();\n panels.forEach(Listeners.setOnPanel);\n Listeners.initKeysPanel();\n if (!CloudCmd.config('dirStorage')) return;\n const data = await Storage.get(dirPath);\n if (!data) await Storage.setJson(dirPath, getJsonFromFileTable());\n }\n\n function getPanels() {\n const panels = ['left'];\n if (CloudCmd.config('oneFilePanel')) return panels;\n return [...panels, 'right'];\n }\n\n this.execFromModule = async function (moduleName, funcName) {\n await CloudCmd[moduleName]();\n const func = CloudCmd[moduleName][funcName];\n\n for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {\n args[_key - 2] = arguments[_key];\n }\n\n func(...args);\n };\n\n this.refresh = async function () {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const {\n panel = Info.panel,\n currentName\n } = options;\n const path = DOM.getCurrentDirPath(panel);\n const isRefresh = true;\n const history = false;\n const noCurrent = options ? options.noCurrent : false;\n await CloudCmd.loadDir({\n path,\n isRefresh,\n history,\n panel,\n noCurrent,\n currentName\n });\n };\n /**\n * Функция загружает json-данные о Файловой Системе\n * через ajax-запрос.\n * @param path - каталог для чтения\n * @param options\n * { refresh, history } - необходимость обновить данные о каталоге\n * @param panel\n * @param callback\n *\n */\n\n\n async function ajaxLoad(path) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n let panel = arguments.length > 2 ? arguments[2] : undefined;\n const {\n RESTful\n } = DOM;\n CloudCmd.log('reading dir: \"' + path + '\";');\n const dirStorage = CloudCmd.config('dirStorage');\n const json = dirStorage && (await Storage.getJson(path));\n const name = options.currentName || Info.name;\n const {\n noCurrent,\n refresh\n } = options;\n if (!refresh && json) return await createFileTable(json, panel, options);\n const position = DOM.getPanelPosition(panel);\n const sort = CloudCmd.sort[position];\n const order = CloudCmd.order[position];\n const query = rendy('?sort={{ sort }}&order={{ order }}', {\n sort,\n order\n });\n const [, newObj] = await RESTful.read(path + query, 'json');\n if (!newObj) return; // that's OK, error handled by RESTful\n\n options.sort = sort;\n options.order = order;\n await createFileTable(newObj, panel, options);\n if (refresh && !noCurrent) DOM.setCurrentByName(name);\n if (!CloudCmd.config('dirStorage')) return;\n Storage.setJson(path, newObj);\n }\n /**\n * Функция строит файловую таблицу\n * @param json - данные о файлах\n * @param panelParam\n * @param history\n * @param callback\n */\n\n\n async function createFileTable(data, panelParam, options) {\n const {\n history,\n noCurrent\n } = options;\n const names = ['file', 'path', 'link', 'pathLink'];\n const [error, [file, path, link, pathLink]] = await tryToCatch(Files.get, names);\n if (error) return DOM.Dialog.alert(error.responseText);\n const panel = panelParam || DOM.getPanel();\n const {\n prefix\n } = CloudCmd;\n const {\n dir,\n name\n } = Info;\n const {\n childNodes\n } = panel;\n let i = childNodes.length;\n\n while (i--) panel.removeChild(panel.lastChild);\n\n panel.innerHTML = buildFromJSON({\n sort: options.sort,\n order: options.order,\n data,\n id: panel.id,\n prefix,\n template: {\n file,\n path,\n pathLink,\n link\n }\n });\n Listeners.setOnPanel(panel);\n\n if (!noCurrent) {\n let current;\n if (name === '..' && dir !== '/') current = DOM.getCurrentByName(dir);\n if (!current) [current] = DOM.getFiles(panel);\n DOM.setCurrentFile(current, {\n history\n });\n CloudCmd.emit('active-dir', Info.dirPath);\n }\n }\n\n this.goToParentDir = async () => {\n const {\n dir,\n dirPath,\n parentDirPath,\n panel\n } = Info;\n if (dirPath === parentDirPath) return;\n const path = parentDirPath;\n await CloudCmd.loadDir({\n path\n });\n const current = DOM.getCurrentByName(dir);\n const [first] = DOM.getFiles(panel);\n DOM.setCurrentFile(current || first, {\n history\n });\n };\n}\n\n//# sourceURL=file://cloudcmd/client/client.js");
|
|
166
|
+
eval("\n/* global DOM */\n\nconst Emitify = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\n\nconst inherits = __webpack_require__(/*! inherits */ \"./node_modules/inherits/inherits_browser.js\");\n\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst {\n addSlashToEnd\n} = __webpack_require__(/*! format-io */ \"./node_modules/format-io/lib/format.js\");\n\nconst pascalCase = __webpack_require__(/*! just-pascal-case */ \"./node_modules/just-pascal-case/index.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst Images = __webpack_require__(/*! ./dom/images */ \"./client/dom/images.js\");\n\nconst {\n unregisterSW\n} = __webpack_require__(/*! ./sw/register */ \"./client/sw/register.js\");\n\nconst getJsonFromFileTable = __webpack_require__(/*! ./get-json-from-file-table */ \"./client/get-json-from-file-table.js\");\n\nconst Key = __webpack_require__(/*! ./key */ \"./client/key/index.js\");\n\nconst {\n apiURL,\n formatMsg,\n buildFromJSON\n} = __webpack_require__(/*! ../common/cloudfunc */ \"./common/cloudfunc.js\");\n\nconst loadModule = __webpack_require__(/*! ./load-module */ \"./client/load-module.js\");\n\nconst noJS = a => a.replace(/.js$/, '');\n\nconst isDev = \"development\" === 'development';\ninherits(CloudCmdProto, Emitify);\nmodule.exports = new CloudCmdProto(DOM);\nload.addErrorListener((e, src) => {\n const msg = `file ${src} could not be loaded`;\n Images.show.error(msg);\n});\n\nfunction CloudCmdProto(DOM) {\n let Listeners;\n Emitify.call(this);\n const CloudCmd = this;\n const Info = DOM.CurrentInfo;\n const {\n Storage,\n Files\n } = DOM;\n\n this.log = function () {\n if (!isDev) return;\n console.log(...arguments);\n };\n\n this.prefix = '';\n this.prefixSocket = '';\n this.prefixURL = '';\n this.DIRCLIENT = '/dist/';\n this.DIRCLIENT_MODULES = this.DIRCLIENT + 'modules/';\n this.MIN_ONE_PANEL_WIDTH = 1155;\n this.HOST = location.origin || location.protocol + '//' + location.host;\n this.TITLE = 'Cloud Commander';\n this.sort = {\n left: 'name',\n right: 'name'\n };\n this.order = {\n left: 'asc',\n right: 'asc'\n };\n /**\n * Функция привязываеться ко всем ссылкам и\n * загружает содержимое каталогов\n *\n * @param params - {\n * paramLink - ссылка\n * needRefresh - необходимость обязательной загрузки данных с сервера\n * panel\n * }\n * @param callback\n */\n\n this.loadDir = async params => {\n const p = params;\n const refresh = p.isRefresh;\n const {\n panel,\n history = true,\n noCurrent,\n currentName\n } = p;\n let panelChanged;\n\n if (!noCurrent && panel && panel !== Info.panel) {\n DOM.changePanel();\n panelChanged = true;\n }\n\n let imgPosition;\n if (panelChanged || refresh || !history) imgPosition = 'top';\n Images.show.load(imgPosition, panel);\n const path = addSlashToEnd(p.path);\n /* загружаем содержимое каталога */\n\n await ajaxLoad(path, {\n refresh,\n history,\n noCurrent,\n currentName\n }, panel);\n };\n /**\n * Конструктор CloudClient, который\n * выполняет весь функционал по\n * инициализации\n */\n\n\n this.init = async (prefix, config) => {\n CloudCmd.prefix = prefix;\n CloudCmd.prefixURL = `${prefix}${apiURL}`;\n CloudCmd.prefixSocket = config.prefixSocket;\n\n CloudCmd.config = key => config[key];\n\n CloudCmd.config.if = currify((key, fn, a) => config[key] && fn(a));\n\n CloudCmd._config = (key, value) => {\n /*\n * should be called from config.js only\n * after successful update on server\n */\n if (key === 'password') return;\n config[key] = value;\n };\n\n if (config.oneFilePanel) CloudCmd.MIN_ONE_PANEL_WIDTH = Infinity;\n if (!document.body.scrollIntoViewIfNeeded) await load.js(prefix + CloudCmd.DIRCLIENT_MODULES + 'polyfill.js');\n await initModules();\n await baseInit();\n await loadStyle();\n CloudCmd.route(location.hash);\n };\n\n async function loadStyle() {\n const {\n prefix\n } = CloudCmd;\n const name = prefix + '/dist/cloudcmd.common.css';\n await load.css(name);\n }\n\n this.route = path => {\n const query = path.split('/');\n if (!path) return;\n const [kebabModule] = query;\n const module = noJS(pascalCase(kebabModule.slice(1)));\n const file = query[1];\n const current = DOM.getCurrentByName(file);\n\n if (file && !current) {\n const msg = formatMsg('set current file', file, 'error');\n CloudCmd.log(msg);\n return;\n }\n\n DOM.setCurrentFile(current);\n CloudCmd.execFromModule(module, 'show');\n };\n\n this.logOut = async () => {\n const url = CloudCmd.prefix + '/logout';\n\n const error = () => document.location.reload();\n\n const {\n prefix\n } = CloudCmd;\n await DOM.Storage.clear();\n unregisterSW(prefix);\n DOM.load.ajax({\n url,\n error\n });\n };\n\n const initModules = async () => {\n CloudCmd.Key = Key;\n CloudCmd.Key.bind();\n const [, modules] = await tryToCatch(Files.get, 'modules');\n const showLoad = Images.show.load;\n const doBefore = {\n edit: showLoad,\n menu: showLoad\n };\n\n const load = (name, path, dobefore) => {\n loadModule({\n name,\n path,\n dobefore\n });\n };\n\n if (!modules) return;\n\n for (const module of modules.local) {\n load(null, module, doBefore[module]);\n }\n };\n\n async function saveCurrentName(currentName) {\n await Storage.set('current-name', currentName);\n }\n\n async function baseInit() {\n const files = DOM.getFiles();\n CloudCmd.on('current-file', DOM.updateCurrentInfo);\n CloudCmd.on('current-name', saveCurrentName);\n const name = await Storage.get('current-name');\n const currentFile = name && DOM.getCurrentByName(name) || files[0];\n /* выделяем строку с первым файлом */\n\n if (files) DOM.setCurrentFile(currentFile, {\n // when hash is present\n // it should be handled with this.route\n // overwre otherwise\n history: !location.hash\n });\n const dirPath = DOM.getCurrentDirPath();\n Listeners = CloudCmd.Listeners;\n Listeners.init();\n const panels = getPanels();\n panels.forEach(Listeners.setOnPanel);\n Listeners.initKeysPanel();\n if (!CloudCmd.config('dirStorage')) return;\n const data = await Storage.get(dirPath);\n if (!data) await Storage.setJson(dirPath, getJsonFromFileTable());\n }\n\n function getPanels() {\n const panels = ['left'];\n if (CloudCmd.config('oneFilePanel')) return panels;\n return [...panels, 'right'];\n }\n\n this.execFromModule = async function (moduleName, funcName) {\n await CloudCmd[moduleName]();\n const func = CloudCmd[moduleName][funcName];\n\n for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {\n args[_key - 2] = arguments[_key];\n }\n\n func(...args);\n };\n\n this.refresh = async function () {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const {\n panel = Info.panel,\n currentName\n } = options;\n const path = DOM.getCurrentDirPath(panel);\n const isRefresh = true;\n const history = false;\n const noCurrent = options ? options.noCurrent : false;\n await CloudCmd.loadDir({\n path,\n isRefresh,\n history,\n panel,\n noCurrent,\n currentName\n });\n };\n /**\n * Функция загружает json-данные о Файловой Системе\n * через ajax-запрос.\n * @param path - каталог для чтения\n * @param options\n * { refresh, history } - необходимость обновить данные о каталоге\n * @param panel\n * @param callback\n *\n */\n\n\n async function ajaxLoad(path) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n let panel = arguments.length > 2 ? arguments[2] : undefined;\n const {\n RESTful\n } = DOM;\n CloudCmd.log('reading dir: \"' + path + '\";');\n const dirStorage = CloudCmd.config('dirStorage');\n const json = dirStorage && (await Storage.getJson(path));\n const name = options.currentName || Info.name;\n const {\n noCurrent,\n refresh\n } = options;\n if (!refresh && json) return await createFileTable(json, panel, options);\n const position = DOM.getPanelPosition(panel);\n const sort = CloudCmd.sort[position];\n const order = CloudCmd.order[position];\n const query = rendy('?sort={{ sort }}&order={{ order }}', {\n sort,\n order\n });\n const [, newObj] = await RESTful.read(path + query, 'json');\n if (!newObj) return; // that's OK, error handled by RESTful\n\n options.sort = sort;\n options.order = order;\n await createFileTable(newObj, panel, options);\n if (refresh && !noCurrent) DOM.setCurrentByName(name);\n if (!CloudCmd.config('dirStorage')) return;\n Storage.setJson(path, newObj);\n }\n /**\n * Функция строит файловую таблицу\n * @param json - данные о файлах\n * @param panelParam\n * @param history\n * @param callback\n */\n\n\n async function createFileTable(data, panelParam, options) {\n const {\n history,\n noCurrent\n } = options;\n const names = ['file', 'path', 'link', 'pathLink'];\n const [error, [file, path, link, pathLink]] = await tryToCatch(Files.get, names);\n if (error) return DOM.Dialog.alert(error.responseText);\n const panel = panelParam || DOM.getPanel();\n const {\n prefix\n } = CloudCmd;\n const {\n dir,\n name\n } = Info;\n const {\n childNodes\n } = panel;\n let i = childNodes.length;\n\n while (i--) panel.removeChild(panel.lastChild);\n\n panel.innerHTML = buildFromJSON({\n sort: options.sort,\n order: options.order,\n data,\n id: panel.id,\n prefix,\n template: {\n file,\n path,\n pathLink,\n link\n }\n });\n Listeners.setOnPanel(panel);\n\n if (!noCurrent) {\n let current;\n if (name === '..' && dir !== '/') current = DOM.getCurrentByName(dir);\n if (!current) [current] = DOM.getFiles(panel);\n DOM.setCurrentFile(current, {\n history\n });\n CloudCmd.emit('active-dir', Info.dirPath);\n }\n }\n\n this.goToParentDir = async () => {\n const {\n dir,\n dirPath,\n parentDirPath,\n panel\n } = Info;\n if (dirPath === parentDirPath) return;\n const path = parentDirPath;\n await CloudCmd.loadDir({\n path\n });\n const current = DOM.getCurrentByName(dir);\n const [first] = DOM.getFiles(panel);\n DOM.setCurrentFile(current || first, {\n history\n });\n };\n}\n\n//# sourceURL=file://cloudcmd/client/client.js");
|
|
167
167
|
|
|
168
168
|
/***/ }),
|
|
169
169
|
|
|
@@ -175,7 +175,7 @@ eval("\n/* global DOM */\n\nconst Emitify = __webpack_require__(/*! emitify */ \
|
|
|
175
175
|
/***/ (function(module, exports, __webpack_require__) {
|
|
176
176
|
|
|
177
177
|
"use strict";
|
|
178
|
-
eval("\n\n__webpack_require__(/*! ../css/main.css */ \"./css/main.css\");\n\n__webpack_require__(/*! ../css/nojs.css */ \"./css/nojs.css\");\n\n__webpack_require__(/*! ../css/columns/name-size-date.css */ \"./css/columns/name-size-date.css\");\n\n__webpack_require__(/*! ../css/columns/name-size.css */ \"./css/columns/name-size.css\");\n\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst
|
|
178
|
+
eval("\n\n__webpack_require__(/*! ../css/main.css */ \"./css/main.css\");\n\n__webpack_require__(/*! ../css/nojs.css */ \"./css/nojs.css\");\n\n__webpack_require__(/*! ../css/columns/name-size-date.css */ \"./css/columns/name-size-date.css\");\n\n__webpack_require__(/*! ../css/columns/name-size.css */ \"./css/columns/name-size.css\");\n\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst {\n registerSW,\n listenSW\n} = __webpack_require__(/*! ./sw/register */ \"./client/sw/register.js\");\n\nconst isDev = \"development\" === 'development'; // prevent additional loading of emitify\n\nwindow.Emitify = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\n\nmodule.exports = window.CloudCmd = async config => {\n window.Util = __webpack_require__(/*! ../common/util */ \"./common/util.js\");\n window.CloudFunc = __webpack_require__(/*! ../common/cloudfunc */ \"./common/cloudfunc.js\");\n window.DOM = __webpack_require__(/*! ./dom */ \"./client/dom/index.js\");\n window.CloudCmd = __webpack_require__(/*! ./client */ \"./client/client.js\");\n await register(config);\n\n __webpack_require__(/*! ./listeners */ \"./client/listeners/index.js\");\n\n __webpack_require__(/*! ./key */ \"./client/key/index.js\");\n\n __webpack_require__(/*! ./sort */ \"./client/sort.js\");\n\n const prefix = getPrefix(config.prefix);\n window.CloudCmd.init(prefix, config);\n};\n\nfunction getPrefix(prefix) {\n if (!prefix) return '';\n if (!prefix.indexOf('/')) return prefix;\n return `/${prefix}`;\n}\n\nconst onUpdateFound = wraptile(async config => {\n if (isDev) return;\n const {\n DOM\n } = window;\n const prefix = getPrefix(config.prefix);\n await load.js(`${prefix}/dist/cloudcmd.common.js`);\n await load.js(`${prefix}/dist/cloudcmd.js`);\n console.log('cloudcmd: sw: updated');\n DOM.Events.removeAll();\n window.CloudCmd(config);\n});\n\nasync function register(config) {\n const {\n prefix\n } = config;\n const sw = await registerSW(prefix);\n listenSW(sw, 'updatefound', onUpdateFound(config));\n}\n\n//# sourceURL=file://cloudcmd/client/cloudcmd.js");
|
|
179
179
|
|
|
180
180
|
/***/ }),
|
|
181
181
|
|
|
@@ -211,7 +211,7 @@ eval("\n\nmodule.exports.createBinder = () => {\n let binded = false;\n return
|
|
|
211
211
|
/***/ (function(module, exports, __webpack_require__) {
|
|
212
212
|
|
|
213
213
|
"use strict";
|
|
214
|
-
eval("\n/* global CloudCmd, DOM */\n\nconst Info = DOM.CurrentInfo;\n\nconst clipboard = __webpack_require__(/*! @cloudcmd/clipboard */ \"./node_modules/@cloudcmd/clipboard/lib/clipboard.js\");\n\nconst Buffer = __webpack_require__(/*! ../dom/buffer */ \"./client/dom/buffer.js\");\n\nconst Events = __webpack_require__(/*! ../dom/events */ \"./client/dom/events/index.js\");\n\nconst KEY = __webpack_require__(/*! ./key */ \"./client/key/key.js\");\n\nconst vim = __webpack_require__(/*! ./vim */ \"./client/key/vim/index.js\");\n\nconst setCurrentByChar = __webpack_require__(/*! ./set-current-by-char */ \"./client/key/set-current-by-char.js\");\n\nconst {\n createBinder\n} = __webpack_require__(/*! ./binder */ \"./client/key/binder.js\");\n\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n\nconst Chars = fullstore();\n\nconst toggleVim = keyCode => {\n const {\n _config,\n config\n } = CloudCmd;\n\n if (keyCode === KEY.ESC) {\n _config('vim', !config('vim'));\n }\n};\n\nconst isUndefined = a => typeof a === 'undefined';\n\nChars([]);\nconst {\n assign\n} = Object;\nconst binder = createBinder();\nmodule.exports = assign(binder, KEY);\n\nmodule.exports.bind = () => {\n Events.addKey(listener, true);\n binder.setBind();\n};\n\nmodule.exports._listener = listener;\n\nfunction getChar(event) {\n /*\n * event.keyIdentifier deprecated in chrome v51\n * but event.key is absent in chrome <= v51\n */\n const {\n key,\n shift,\n keyCode,\n keyIdentifier\n } = event;\n const char = key || fromCharCode(keyIdentifier);\n const symbol = getSymbol(shift, keyCode);\n return [symbol, char];\n}\n\nasync function listener(event) {\n const {\n keyCode\n } = event; // strange chrome bug calles listener twice\n // in second time event misses a lot fields\n\n if (isUndefined(event.altKey)) return;\n const alt = event.altKey;\n const ctrl = event.ctrlKey;\n const meta = event.metaKey;\n const isBetween = keyCode >= KEY.ZERO && keyCode <= KEY.Z;\n const isNumpad = /Numpad/.test(event.code);\n const [symbol, char] = getChar(event);\n if (!binder.isBind()) return;\n toggleVim(keyCode);\n const isVim = CloudCmd.config('vim');\n if (!isVim && !isNumpad && !alt && !ctrl && !meta && (isBetween || symbol)) return setCurrentByChar(char, Chars);\n Chars([]);\n await switchKey(event);\n if (keyCode >= KEY.F1 && keyCode <= KEY.F10) return;\n if (isVim) vim(char, event);\n}\n\nfunction getSymbol(shift, keyCode) {\n switch (keyCode) {\n case KEY.DOT:\n return '.';\n\n case KEY.HYPHEN:\n return shift ? '_' : '-';\n\n case KEY.EQUAL:\n return shift ? '+' : '=';\n }\n\n return '';\n}\n\nfunction fromCharCode(keyIdentifier) {\n const code = keyIdentifier.substring(2);\n const hex = parseInt(code, 16);\n const char = String.fromCharCode(hex);\n return char;\n}\n\nasync function switchKey(event) {\n let i;\n let isSelected;\n let prev;\n let next;\n let current = Info.element;\n let dataName;\n const {\n name,\n panel,\n path,\n isDir\n } = Info;\n const {\n Operation,\n loadDir,\n config\n } = CloudCmd;\n const {\n keyCode\n } = event;\n const alt = event.altKey;\n const shift = event.shiftKey;\n const ctrl = event.ctrlKey;\n const meta = event.metaKey;\n const ctrlMeta = ctrl || meta;\n\n if (current) {\n prev = current.previousSibling;\n next = current.nextSibling;\n }\n\n switch (keyCode) {\n case KEY.TAB:\n DOM.changePanel();\n event.preventDefault();\n break;\n\n case KEY.INSERT:\n DOM.toggleSelectedFile(current).setCurrentFile(next);\n break;\n\n case KEY.INSERT_MAC:\n DOM.toggleSelectedFile(current).setCurrentFile(next);\n break;\n\n case KEY.DELETE:\n if (shift) Operation.show('delete:silent');else Operation.show('delete');\n break;\n\n case KEY.ASTERISK:\n DOM.toggleAllSelectedFiles(current);\n break;\n\n case KEY.PLUS:\n DOM.expandSelection();\n event.preventDefault();\n break;\n\n case KEY.MINUS:\n DOM.shrinkSelection();\n event.preventDefault();\n break;\n\n case KEY.F1:\n CloudCmd.Help.show();\n event.preventDefault();\n break;\n\n case KEY.F2:\n CloudCmd.UserMenu.show();\n break;\n\n case KEY.F3:\n event.preventDefault();\n if (Info.isDir) await loadDir({\n path\n });else if (shift) CloudCmd.View.show(null, {\n raw: true\n });else if (ctrlMeta) CloudCmd.sortPanel('name');else CloudCmd.View.show();\n break;\n\n case KEY.F4:\n if (config('vim')) CloudCmd.EditFileVim.show();else CloudCmd.EditFile.show();\n event.preventDefault();\n break;\n\n case KEY.F5:\n if (ctrlMeta) CloudCmd.sortPanel('date');else if (alt) Operation.show('pack');else Operation.show('copy');\n event.preventDefault();\n break;\n\n case KEY.F6:\n if (ctrlMeta) CloudCmd.sortPanel('size');else if (shift) DOM.renameCurrent(current);else Operation.show('move');\n event.preventDefault();\n break;\n\n case KEY.F7:\n if (shift) DOM.promptNewFile();else DOM.promptNewDir();\n event.preventDefault();\n break;\n\n case KEY.F8:\n Operation.show('delete');\n event.preventDefault();\n break;\n\n case KEY.F9:\n if (alt) Operation.show('extract');else CloudCmd.Menu.show();\n event.preventDefault();\n break;\n\n case KEY.F10:\n CloudCmd.Config.show();\n event.preventDefault();\n break;\n\n case KEY.TRA:\n event.preventDefault();\n if (shift) return CloudCmd.Terminal.show();\n CloudCmd.Konsole.show();\n break;\n\n case KEY.BRACKET_CLOSE:\n CloudCmd.Konsole.show();\n event.preventDefault();\n break;\n\n case KEY.SPACE:\n event.preventDefault();\n if (!isDir || name === '..') isSelected = true;else isSelected = DOM.isSelected(current);\n if (!isSelected) await DOM.loadCurrentSize(current);\n DOM.toggleSelectedFile(current);\n break;\n\n case KEY.U:\n if (ctrlMeta) {\n DOM.swapPanels();\n event.preventDefault();\n }\n\n break;\n\n /* navigation on file table: *\n * in case of pressing button 'up', *\n * select previous row */\n\n case KEY.UP:\n if (shift) DOM.toggleSelectedFile(current);\n DOM.setCurrentFile(prev);\n event.preventDefault();\n break;\n\n /* in case of pressing button 'down', *\n * select next row */\n\n case KEY.DOWN:\n if (shift) DOM.toggleSelectedFile(current);\n DOM.setCurrentFile(next);\n event.preventDefault();\n break;\n\n case KEY.LEFT:\n if (!alt) return;\n event.preventDefault();\n dataName = Info.panel.getAttribute('data-name');\n if (dataName === 'js-right') DOM.duplicatePanel();\n break;\n\n case KEY.RIGHT:\n if (!alt) return;\n event.preventDefault();\n dataName = Info.panel.getAttribute('data-name');\n if (dataName === 'js-left') DOM.duplicatePanel();\n break;\n\n /* in case of pressing button 'Home', *\n * go to top element */\n\n case KEY.HOME:\n DOM.setCurrentFile(Info.first);\n event.preventDefault();\n break;\n\n /* in case of pressing button 'End', select last element */\n\n case KEY.END:\n DOM.setCurrentFile(Info.last);\n event.preventDefault();\n break;\n\n /* если нажали клавишу page down проматываем экран */\n\n case KEY.PAGE_DOWN:\n DOM.scrollByPages(panel, 1);\n\n for (i = 0; i < 30; i++) {\n if (!current.nextSibling) break;\n current = current.nextSibling;\n }\n\n DOM.setCurrentFile(current);\n event.preventDefault();\n break;\n\n /* если нажали клавишу page up проматываем экран */\n\n case KEY.PAGE_UP:\n DOM.scrollByPages(panel, -1);\n\n for (i = 0; i < 30; i++) {\n if (!current.previousSibling) break;\n current = current.previousSibling;\n }\n\n DOM.setCurrentFile(current);\n event.preventDefault();\n break;\n\n case KEY.ENTER:\n if (Info.isDir) await loadDir({\n path\n });else CloudCmd.View.show();\n break;\n\n case KEY.BACKSPACE:\n CloudCmd.goToParentDir();\n event.preventDefault();\n break;\n\n case KEY.BACKSLASH:\n if (ctrlMeta) await loadDir({\n path: '/'\n });\n break;\n\n case KEY.A:\n if (ctrlMeta) {\n DOM.selectAllFiles();\n event.preventDefault();\n }\n\n break;\n\n case KEY.G:\n if (alt) {\n DOM.goToDirectory();\n event.preventDefault();\n }\n\n break;\n\n case KEY.M:\n if (ctrlMeta) {\n if (config('vim')) CloudCmd.EditNamesVim.show();else CloudCmd.EditNames.show();\n event.preventDefault();\n }\n\n break;\n\n case KEY.P:\n if (!ctrlMeta) return;\n event.preventDefault();\n clipboard.writeText(Info.dirPath).catch(CloudCmd.log);\n break;\n\n /**\n * обновляем страницу,\n * загружаем содержимое каталога\n * при этом данные берём всегда с\n * сервера, а не из кэша\n * (обновляем кэш)\n */\n\n case KEY.R:\n if (ctrlMeta) {\n CloudCmd.log('reloading page...\\n');\n CloudCmd.refresh();\n event.preventDefault();\n }\n\n break;\n\n case KEY.C:\n if (ctrlMeta) Buffer.copy();\n break;\n\n case KEY.X:\n if (ctrlMeta) Buffer.cut();\n break;\n\n case KEY.V:\n if (ctrlMeta) Buffer.paste();\n break;\n\n case KEY.Z:\n if (ctrlMeta) Buffer.clear();\n break;\n\n /* чистим хранилище */\n\n case KEY.D:\n if (ctrlMeta) {\n CloudCmd.log('clearing storage...');\n await DOM.Storage.clear();\n CloudCmd.log('storage cleared');\n event.preventDefault();\n }\n\n break;\n }\n}\n\n//# sourceURL=file://cloudcmd/client/key/index.js");
|
|
214
|
+
eval("\n/* global CloudCmd, DOM */\n\nconst clipboard = __webpack_require__(/*! @cloudcmd/clipboard */ \"./node_modules/@cloudcmd/clipboard/lib/clipboard.js\");\n\nconst Buffer = __webpack_require__(/*! ../dom/buffer */ \"./client/dom/buffer.js\");\n\nconst Events = __webpack_require__(/*! ../dom/events */ \"./client/dom/events/index.js\");\n\nconst KEY = __webpack_require__(/*! ./key */ \"./client/key/key.js\");\n\nconst vim = __webpack_require__(/*! ./vim */ \"./client/key/vim/index.js\");\n\nconst setCurrentByChar = __webpack_require__(/*! ./set-current-by-char */ \"./client/key/set-current-by-char.js\");\n\nconst {\n createBinder\n} = __webpack_require__(/*! ./binder */ \"./client/key/binder.js\");\n\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n\nconst Info = DOM.CurrentInfo;\nconst Chars = fullstore();\n\nconst toggleVim = keyCode => {\n const {\n _config,\n config\n } = CloudCmd;\n\n if (keyCode === KEY.ESC) {\n _config('vim', !config('vim'));\n }\n};\n\nconst isUndefined = a => typeof a === 'undefined';\n\nChars([]);\nconst {\n assign\n} = Object;\nconst binder = createBinder();\nmodule.exports = assign(binder, KEY);\n\nmodule.exports.bind = () => {\n Events.addKey(listener, true);\n binder.setBind();\n};\n\nmodule.exports._listener = listener;\n\nfunction getChar(event) {\n /*\n * event.keyIdentifier deprecated in chrome v51\n * but event.key is absent in chrome <= v51\n */\n const {\n key,\n shift,\n keyCode,\n keyIdentifier\n } = event;\n const char = key || fromCharCode(keyIdentifier);\n const symbol = getSymbol(shift, keyCode);\n return [symbol, char];\n}\n\nasync function listener(event) {\n const {\n keyCode\n } = event; // strange chrome bug calles listener twice\n // in second time event misses a lot fields\n\n if (isUndefined(event.altKey)) return;\n const alt = event.altKey;\n const ctrl = event.ctrlKey;\n const meta = event.metaKey;\n const isBetween = keyCode >= KEY.ZERO && keyCode <= KEY.Z;\n const isNumpad = /Numpad/.test(event.code);\n const [symbol, char] = getChar(event);\n if (!binder.isBind()) return;\n toggleVim(keyCode);\n const isVim = CloudCmd.config('vim');\n if (!isVim && !isNumpad && !alt && !ctrl && !meta && (isBetween || symbol)) return setCurrentByChar(char, Chars);\n Chars([]);\n await switchKey(event);\n if (keyCode >= KEY.F1 && keyCode <= KEY.F10) return;\n if (isVim) vim(char, event);\n}\n\nfunction getSymbol(shift, keyCode) {\n switch (keyCode) {\n case KEY.DOT:\n return '.';\n\n case KEY.HYPHEN:\n return shift ? '_' : '-';\n\n case KEY.EQUAL:\n return shift ? '+' : '=';\n }\n\n return '';\n}\n\nfunction fromCharCode(keyIdentifier) {\n const code = keyIdentifier.substring(2);\n const hex = parseInt(code, 16);\n const char = String.fromCharCode(hex);\n return char;\n}\n\nasync function switchKey(event) {\n let i;\n let isSelected;\n let prev;\n let next;\n let current = Info.element;\n let dataName;\n const {\n name,\n panel,\n path,\n isDir\n } = Info;\n const {\n Operation,\n loadDir,\n config\n } = CloudCmd;\n const {\n keyCode\n } = event;\n const alt = event.altKey;\n const shift = event.shiftKey;\n const ctrl = event.ctrlKey;\n const meta = event.metaKey;\n const ctrlMeta = ctrl || meta;\n\n if (current) {\n prev = current.previousSibling;\n next = current.nextSibling;\n }\n\n switch (keyCode) {\n case KEY.TAB:\n DOM.changePanel();\n event.preventDefault();\n break;\n\n case KEY.INSERT:\n DOM.toggleSelectedFile(current).setCurrentFile(next);\n break;\n\n case KEY.INSERT_MAC:\n DOM.toggleSelectedFile(current).setCurrentFile(next);\n break;\n\n case KEY.DELETE:\n if (shift) Operation.show('delete:silent');else Operation.show('delete');\n break;\n\n case KEY.ASTERISK:\n DOM.toggleAllSelectedFiles(current);\n break;\n\n case KEY.PLUS:\n DOM.expandSelection();\n event.preventDefault();\n break;\n\n case KEY.MINUS:\n DOM.shrinkSelection();\n event.preventDefault();\n break;\n\n case KEY.F1:\n CloudCmd.Help.show();\n event.preventDefault();\n break;\n\n case KEY.F2:\n CloudCmd.UserMenu.show();\n break;\n\n case KEY.F3:\n event.preventDefault();\n if (Info.isDir) await loadDir({\n path\n });else if (shift) CloudCmd.View.show(null, {\n raw: true\n });else if (ctrlMeta) CloudCmd.sortPanel('name');else CloudCmd.View.show();\n break;\n\n case KEY.F4:\n if (config('vim')) CloudCmd.EditFileVim.show();else CloudCmd.EditFile.show();\n event.preventDefault();\n break;\n\n case KEY.F5:\n if (ctrlMeta) CloudCmd.sortPanel('date');else if (alt) Operation.show('pack');else Operation.show('copy');\n event.preventDefault();\n break;\n\n case KEY.F6:\n if (ctrlMeta) CloudCmd.sortPanel('size');else if (shift) DOM.renameCurrent(current);else Operation.show('move');\n event.preventDefault();\n break;\n\n case KEY.F7:\n if (shift) DOM.promptNewFile();else DOM.promptNewDir();\n event.preventDefault();\n break;\n\n case KEY.F8:\n Operation.show('delete');\n event.preventDefault();\n break;\n\n case KEY.F9:\n if (alt) Operation.show('extract');else CloudCmd.Menu.show();\n event.preventDefault();\n break;\n\n case KEY.F10:\n CloudCmd.Config.show();\n event.preventDefault();\n break;\n\n case KEY.TRA:\n event.preventDefault();\n if (shift) return CloudCmd.Terminal.show();\n CloudCmd.Konsole.show();\n break;\n\n case KEY.BRACKET_CLOSE:\n CloudCmd.Konsole.show();\n event.preventDefault();\n break;\n\n case KEY.SPACE:\n event.preventDefault();\n if (!isDir || name === '..') isSelected = true;else isSelected = DOM.isSelected(current);\n if (!isSelected) await DOM.loadCurrentSize(current);\n DOM.toggleSelectedFile(current);\n break;\n\n case KEY.U:\n if (ctrlMeta) {\n DOM.swapPanels();\n event.preventDefault();\n }\n\n break;\n\n /* navigation on file table: *\n * in case of pressing button 'up', *\n * select previous row */\n\n case KEY.UP:\n if (shift) DOM.toggleSelectedFile(current);\n DOM.setCurrentFile(prev);\n event.preventDefault();\n break;\n\n /* in case of pressing button 'down', *\n * select next row */\n\n case KEY.DOWN:\n if (shift) DOM.toggleSelectedFile(current);\n DOM.setCurrentFile(next);\n event.preventDefault();\n break;\n\n case KEY.LEFT:\n if (!alt) return;\n event.preventDefault();\n dataName = Info.panel.getAttribute('data-name');\n if (dataName === 'js-right') DOM.duplicatePanel();\n break;\n\n case KEY.RIGHT:\n if (!alt) return;\n event.preventDefault();\n dataName = Info.panel.getAttribute('data-name');\n if (dataName === 'js-left') DOM.duplicatePanel();\n break;\n\n /* in case of pressing button 'Home', *\n * go to top element */\n\n case KEY.HOME:\n DOM.setCurrentFile(Info.first);\n event.preventDefault();\n break;\n\n /* in case of pressing button 'End', select last element */\n\n case KEY.END:\n DOM.setCurrentFile(Info.last);\n event.preventDefault();\n break;\n\n /* если нажали клавишу page down проматываем экран */\n\n case KEY.PAGE_DOWN:\n DOM.scrollByPages(panel, 1);\n\n for (i = 0; i < 30; i++) {\n if (!current.nextSibling) break;\n current = current.nextSibling;\n }\n\n DOM.setCurrentFile(current);\n event.preventDefault();\n break;\n\n /* если нажали клавишу page up проматываем экран */\n\n case KEY.PAGE_UP:\n DOM.scrollByPages(panel, -1);\n\n for (i = 0; i < 30; i++) {\n if (!current.previousSibling) break;\n current = current.previousSibling;\n }\n\n DOM.setCurrentFile(current);\n event.preventDefault();\n break;\n\n case KEY.ENTER:\n if (Info.isDir) await loadDir({\n path\n });else CloudCmd.View.show();\n break;\n\n case KEY.BACKSPACE:\n CloudCmd.goToParentDir();\n event.preventDefault();\n break;\n\n case KEY.BACKSLASH:\n if (ctrlMeta) await loadDir({\n path: '/'\n });\n break;\n\n case KEY.A:\n if (ctrlMeta) {\n DOM.selectAllFiles();\n event.preventDefault();\n }\n\n break;\n\n case KEY.G:\n if (alt) {\n DOM.goToDirectory();\n event.preventDefault();\n }\n\n break;\n\n case KEY.M:\n if (ctrlMeta) {\n if (config('vim')) CloudCmd.EditNamesVim.show();else CloudCmd.EditNames.show();\n event.preventDefault();\n }\n\n break;\n\n case KEY.P:\n if (!ctrlMeta) return;\n event.preventDefault();\n clipboard.writeText(Info.dirPath).catch(CloudCmd.log);\n break;\n\n /**\n * обновляем страницу,\n * загружаем содержимое каталога\n * при этом данные берём всегда с\n * сервера, а не из кэша\n * (обновляем кэш)\n */\n\n case KEY.R:\n if (ctrlMeta) {\n CloudCmd.log('reloading page...\\n');\n CloudCmd.refresh();\n event.preventDefault();\n }\n\n break;\n\n case KEY.C:\n if (ctrlMeta) Buffer.copy();\n break;\n\n case KEY.X:\n if (ctrlMeta) Buffer.cut();\n break;\n\n case KEY.V:\n if (ctrlMeta) Buffer.paste();\n break;\n\n case KEY.Z:\n if (ctrlMeta) Buffer.clear();\n break;\n\n /* чистим хранилище */\n\n case KEY.D:\n if (ctrlMeta) {\n CloudCmd.log('clearing storage...');\n await DOM.Storage.clear();\n CloudCmd.log('storage cleared');\n event.preventDefault();\n }\n\n break;\n }\n}\n\n//# sourceURL=file://cloudcmd/client/key/index.js");
|
|
215
215
|
|
|
216
216
|
/***/ }),
|
|
217
217
|
|
|
@@ -223,7 +223,7 @@ eval("\n/* global CloudCmd, DOM */\n\nconst Info = DOM.CurrentInfo;\n\nconst cli
|
|
|
223
223
|
/***/ (function(module, exports, __webpack_require__) {
|
|
224
224
|
|
|
225
225
|
"use strict";
|
|
226
|
-
eval("/* global DOM */\n\n\nconst
|
|
226
|
+
eval("/* global DOM */\n\n\nconst {\n escapeRegExp\n} = __webpack_require__(/*! ../../common/util */ \"./common/util.js\");\n\nconst Info = DOM.CurrentInfo;\n\nmodule.exports = function setCurrentByChar(char, charStore) {\n let firstByName;\n let skipCount = 0;\n let setted = false;\n let i = 0;\n const escapeChar = escapeRegExp(char);\n const regExp = new RegExp('^' + escapeChar + '.*$', 'i');\n const {\n files\n } = Info;\n const chars = charStore();\n const n = chars.length;\n\n while (i < n && char === chars[i]) i++;\n\n if (!i) charStore([]);\n const skipN = skipCount = i;\n charStore(charStore().concat(char));\n const names = DOM.getFilenames(files);\n\n const isTest = a => regExp.test(a);\n\n const isRoot = a => a === '..';\n\n const not = f => a => !f(a);\n\n const setCurrent = name => {\n const byName = DOM.getCurrentByName(name);\n\n if (!skipCount) {\n setted = true;\n DOM.setCurrentFile(byName);\n return true;\n }\n\n if (skipN === skipCount) firstByName = byName;\n --skipCount;\n };\n\n names.filter(isTest).filter(not(isRoot)).some(setCurrent);\n\n if (!setted) {\n DOM.setCurrentFile(firstByName);\n charStore([char]);\n }\n};\n\n//# sourceURL=file://cloudcmd/client/key/set-current-by-char.js");
|
|
227
227
|
|
|
228
228
|
/***/ }),
|
|
229
229
|
|
|
@@ -295,7 +295,7 @@ eval("\n\nmodule.exports = (indexFrom, indexTo, files) => {\n if (indexFrom < i
|
|
|
295
295
|
/***/ (function(module, exports, __webpack_require__) {
|
|
296
296
|
|
|
297
297
|
"use strict";
|
|
298
|
-
eval("/* global DOM, CloudCmd */\n\n\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst clipboard = __webpack_require__(/*! @cloudcmd/clipboard */ \"./node_modules/@cloudcmd/clipboard/lib/clipboard.js\");\n\nconst getRange = __webpack_require__(/*! ./get-range */ \"./client/listeners/get-range.js\");\n\nconst getIndex = currify(__webpack_require__(/*! ./get-index */ \"./client/listeners/get-index.js\"));\n\nconst uploadFiles = __webpack_require__(/*! ../dom/upload-files */ \"./client/dom/upload-files.js\");\n\nconst {\n FS\n} = __webpack_require__(/*! ../../common/cloudfunc */ \"./common/cloudfunc.js\");\n\nconst NBSP_REG = RegExp(String.fromCharCode(160), 'g');\nconst SPACE = ' ';\n\nmodule.exports.init = async () => {\n await Promise.all([contextMenu(), dragndrop(), unload(), pop(), resize(), header(), config()]);\n};\n\nCloudCmd.Listeners = module.exports;\n\nconst unselect = event => {\n const isMac = /Mac/.test(window.navigator.platform);\n const {\n shiftKey,\n metaKey,\n ctrlKey\n } = event;\n if (shiftKey || isMac && metaKey || ctrlKey) return;\n DOM.unselectFiles();\n};\n\nconst execAll = currify((funcs, event) => {\n for (const fn of funcs) fn(event);\n});\nconst Info = DOM.CurrentInfo;\nconst {\n Events\n} = DOM;\nconst EventsFiles = {\n mousedown: exec.with(execIfNotUL, setCurrentFileByEvent),\n click: execAll([onClick, unselect]),\n dragstart: exec.with(execIfNotUL, onDragStart),\n dblclick: exec.with(execIfNotUL, onDblClick),\n touchstart: exec.with(execIfNotUL, onTouch)\n};\nlet EXT;\n\nfunction header() {\n const fm = DOM.getFM();\n\n const isDataset = el => el.dataset;\n\n const isPanel = el => {\n return /^js-(left|right)$/.test(el.dataset.name);\n };\n\n Events.addClick(fm, event => {\n const el = event.target;\n const parent = el.parentElement;\n if (parent.dataset.name !== 'js-fm-header') return;\n const name = (el.dataset.name || '').replace('js-', '');\n if (!/^(name|size|date)$/.test(name)) return;\n const panel = getPath(el).filter(isDataset).filter(isPanel).pop();\n CloudCmd.sortPanel(name, panel);\n });\n}\n\nfunction getPath(el) {\n let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n if (!el) return path;\n return getPath(el.parentElement, path.concat(el));\n}\n\nasync function config() {\n const [, config] = await tryToCatch(DOM.Files.get, 'config');\n const type = config === null || config === void 0 ? void 0 : config.packer;\n EXT = DOM.getPackerExt(type);\n}\n\nmodule.exports.initKeysPanel = () => {\n const keysElement = DOM.getById('js-keyspanel');\n if (!keysElement) return;\n Events.addClick(keysElement, _ref => {\n let {\n target\n } = _ref;\n const {\n id\n } = target;\n\n const operation = name => {\n const {\n Operation\n } = CloudCmd;\n const fn = Operation.show.bind(null, name);\n return fn;\n };\n\n const clickFuncs = {\n 'f1': CloudCmd.Help.show,\n 'f2': CloudCmd.UserMenu.show,\n 'f3': CloudCmd.View.show,\n 'f4': CloudCmd.EditFile.show,\n 'f5': operation('copy'),\n 'f6': operation('move'),\n 'f7': DOM.promptNewDir,\n 'f8': operation('delete'),\n 'f9': CloudCmd.Menu.show,\n 'f10': CloudCmd.Config.show,\n '~': CloudCmd.Konsole.show,\n 'shift~': CloudCmd.Terminal.show,\n 'contact': CloudCmd.Contact.show\n };\n exec(clickFuncs[id]);\n });\n};\n\nconst getPanel = side => {\n if (!itype.string(side)) return side;\n return DOM.getByDataName('js-' + side);\n};\n\nmodule.exports.setOnPanel = side => {\n const panel = getPanel(side);\n const filesElement = DOM.getByDataName('js-files', panel);\n const pathElement = DOM.getByDataName('js-path', panel);\n /* ставим загрузку гифа на клик*/\n\n Events.addClick(pathElement, getPathListener(panel));\n Events.add(filesElement, EventsFiles);\n};\n\nfunction getPathListener(panel) {\n return onPathElementClick.bind(null, panel);\n}\n\nfunction isNoCurrent(panel) {\n const infoPanel = Info.panel;\n if (!infoPanel) return true;\n const namePanel = panel.getAttribute('data-name');\n const nameInfoPanel = infoPanel.getAttribute('data-name');\n return namePanel !== nameInfoPanel;\n}\n\nfunction decodePath(path) {\n const url = CloudCmd.HOST;\n const {\n prefix\n } = CloudCmd;\n const prefixReg = RegExp('^' + prefix + FS);\n return decodeURI(path).replace(url, '').replace(prefixReg, '') // browser doesn't replace % -> %25% do it for him\n .replace('%%', '%25%').replace(NBSP_REG, SPACE) || '/';\n}\n\nasync function onPathElementClick(panel, event) {\n event.preventDefault();\n const element = event.target;\n const attr = element.getAttribute('data-name');\n const noCurrent = isNoCurrent(panel);\n if (attr === 'js-copy-path') return copyPath(element);\n if (attr === 'js-refresh') return CloudCmd.refresh({\n panel,\n noCurrent\n });\n if (attr !== 'js-path-link') return;\n const {\n href\n } = element;\n const path = decodePath(href);\n await CloudCmd.loadDir({\n path,\n isRefresh: false,\n panel: noCurrent ? panel : Info.panel\n });\n}\n\nfunction copyPath(el) {\n clipboard.writeText(el.parentElement.title).then(CloudCmd.log).catch(CloudCmd.log);\n}\n\nfunction execIfNotUL(callback, event) {\n const {\n target\n } = event;\n const {\n tagName\n } = target;\n if (tagName !== 'UL') callback(event);\n}\n\nfunction onClick(event) {\n event.preventDefault();\n changePanel(event.target);\n}\n\nfunction toggleSelect(key, files) {\n const isMac = /Mac/.test(window.navigator.platform);\n if (!key) throw Error('key should not be undefined!');\n const [file] = files;\n if (isMac && key.meta || key.ctrl) return DOM.toggleSelectedFile(file);\n if (key.shift) return files.map(DOM.selectFile);\n}\n\nfunction changePanel(element) {\n const {\n panel\n } = Info;\n const files = DOM.getByDataName('js-files', panel);\n const ul = getULElement(element);\n if (ul !== files) DOM.changePanel();\n}\n\nasync function onDblClick(event) {\n event.preventDefault();\n const current = getLIElement(event.target);\n const isDir = DOM.isCurrentIsDir(current);\n const path = DOM.getCurrentPath(current);\n if (!isDir) return CloudCmd.View.show();\n await CloudCmd.loadDir({\n path\n });\n}\n\nasync function onTouch(event) {\n const current = getLIElement(event.target);\n const isDir = DOM.isCurrentIsDir(current);\n if (!isDir) return;\n const isCurrent = DOM.isCurrentFile(current);\n if (!isCurrent) return;\n await CloudCmd.loadDir({\n path: DOM.getCurrentPath(current)\n });\n}\n/*\n * download file from browser to desktop\n * in Chrome (HTML5)\n */\n\n\nfunction onDragStart(event) {\n const {\n prefixURL\n } = CloudCmd;\n const element = getLIElement(event.target);\n const {\n isDir\n } = Info;\n let link = DOM.getCurrentLink(element);\n let name = DOM.getCurrentName(element);\n /* if it's directory - adding json extension */\n\n if (isDir) {\n name += EXT;\n link = document.createElement('a');\n link.textContent = name;\n link.href = prefixURL + '/pack' + Info.path + EXT;\n }\n\n event.dataTransfer.setData('DownloadURL', 'application/octet-stream' + ':' + name + ':' + link);\n}\n\nfunction getLIElement(element) {\n if (!element) return element;\n\n while (element.tagName !== 'LI') element = element.parentElement;\n\n return element;\n}\n\nfunction getULElement(element) {\n while (element.tagName !== 'UL') element = element.parentElement;\n\n return element;\n}\n\nfunction setCurrentFileByEvent(event) {\n const BUTTON_LEFT = 0;\n const key = {\n alt: event.altKey,\n ctrl: event.ctrlKey,\n meta: event.metaKey,\n shift: event.shiftKey\n };\n const element = getLIElement(event.target);\n const fromName = Info.name;\n DOM.setCurrentFile(element);\n const toName = Info.name;\n let files = [];\n if (key.shift) files = getFilesRange(fromName, toName);else files.push(Info.element);\n if (event.button === BUTTON_LEFT) toggleSelect(key, files);\n}\n\nfunction getFilesRange(from, to) {\n const files = DOM.getAllFiles();\n const names = DOM.getFilenames(files);\n const getNameIndex = getIndex(names);\n const indexFrom = getNameIndex(from);\n const indexTo = getNameIndex(to);\n return getRange(indexFrom, indexTo, files);\n}\n\nfunction contextMenu() {\n const fm = DOM.getFM();\n Events.addOnce('contextmenu', fm, event => {\n CloudCmd.Menu.show({\n x: event.clientX,\n y: event.clientY\n });\n });\n Events.addContextMenu(fm, event => {\n CloudCmd.Menu.ENABLED || event.preventDefault();\n });\n}\n\nfunction dragndrop() {\n const panels = DOM.getByClassAll('panel');\n\n const select = _ref2 => {\n let {\n target\n } = _ref2;\n target.classList.add('selected-panel');\n };\n\n const unselect = _ref3 => {\n let {\n target\n } = _ref3;\n target.classList.remove('selected-panel');\n };\n\n const onDrop = event => {\n const {\n files,\n items\n } = event.dataTransfer;\n const {\n length: filesCount\n } = files;\n event.preventDefault();\n if (filesCount && (!items || !items.length || !items[0].webkitGetAsEntry)) return uploadFiles(files);\n\n const isFile = item => item.kind === 'file';\n\n const dirFiles = Array.from(items).filter(isFile);\n if (dirFiles.length) return DOM.uploadDirectory(dirFiles);\n const {\n Operation\n } = CloudCmd;\n const operation = event.shiftKey ? 'move' : 'copy';\n return Operation.show(operation);\n };\n /**\n * In Mac OS Chrome dropEffect = 'none'\n * so drop do not firing up when try\n * to upload file from download bar\n */\n\n\n const onDragOver = event => {\n const {\n dataTransfer\n } = event;\n const {\n effectAllowed\n } = dataTransfer;\n if (/move|linkMove/.test(effectAllowed)) dataTransfer.dropEffect = 'move';else dataTransfer.dropEffect = 'copy';\n event.preventDefault();\n };\n\n for (const panel of panels) Events.add('dragover', panel, onDragOver).add('drop', panel, onDrop).add('dragenter', select).add(['dragleave', 'drop'], unselect);\n}\n\nfunction unload() {\n DOM.Events.add(['unload', 'beforeunload'], event => {\n const {\n Key\n } = CloudCmd;\n const isBind = Key === null || Key === void 0 ? void 0 : Key.isBind();\n if (isBind) return;\n event.preventDefault();\n return 'Please make sure that you saved all work.';\n });\n}\n\nfunction pop() {\n Events.add('popstate', async _ref4 => {\n let {\n state\n } = _ref4;\n const path = (state || '').replace(FS, '');\n if (!path) return CloudCmd.route(location.hash);\n const history = false;\n await CloudCmd.loadDir({\n path,\n history\n });\n });\n}\n\nfunction resize() {\n Events.add('resize', () => {\n const is = window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH;\n if (!is) return;\n const {\n panel\n } = Info;\n const isEmptyRoot = !panel;\n if (isEmptyRoot) return;\n const name = panel.getAttribute('data-name');\n const isLeft = name === 'js-left';\n if (isLeft) return;\n DOM.changePanel();\n });\n}\n\n//# sourceURL=file://cloudcmd/client/listeners/index.js");
|
|
298
|
+
eval("/* global DOM, CloudCmd */\n\n\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst clipboard = __webpack_require__(/*! @cloudcmd/clipboard */ \"./node_modules/@cloudcmd/clipboard/lib/clipboard.js\");\n\nconst getRange = __webpack_require__(/*! ./get-range */ \"./client/listeners/get-range.js\");\n\nconst uploadFiles = __webpack_require__(/*! ../dom/upload-files */ \"./client/dom/upload-files.js\");\n\nconst {\n FS\n} = __webpack_require__(/*! ../../common/cloudfunc */ \"./common/cloudfunc.js\");\n\nconst getIndex = currify(__webpack_require__(/*! ./get-index */ \"./client/listeners/get-index.js\"));\nconst NBSP_REG = RegExp(String.fromCharCode(160), 'g');\nconst SPACE = ' ';\n\nmodule.exports.init = async () => {\n await Promise.all([contextMenu(), dragndrop(), unload(), pop(), resize(), header(), config()]);\n};\n\nCloudCmd.Listeners = module.exports;\n\nconst unselect = event => {\n const isMac = /Mac/.test(window.navigator.platform);\n const {\n shiftKey,\n metaKey,\n ctrlKey\n } = event;\n if (shiftKey || isMac && metaKey || ctrlKey) return;\n DOM.unselectFiles();\n};\n\nconst execAll = currify((funcs, event) => {\n for (const fn of funcs) fn(event);\n});\nconst Info = DOM.CurrentInfo;\nconst {\n Events\n} = DOM;\nconst EventsFiles = {\n mousedown: exec.with(execIfNotUL, setCurrentFileByEvent),\n click: execAll([onClick, unselect]),\n dragstart: exec.with(execIfNotUL, onDragStart),\n dblclick: exec.with(execIfNotUL, onDblClick),\n touchstart: exec.with(execIfNotUL, onTouch)\n};\nlet EXT;\n\nfunction header() {\n const fm = DOM.getFM();\n\n const isDataset = el => el.dataset;\n\n const isPanel = el => {\n return /^js-(left|right)$/.test(el.dataset.name);\n };\n\n Events.addClick(fm, event => {\n const el = event.target;\n const parent = el.parentElement;\n if (parent.dataset.name !== 'js-fm-header') return;\n const name = (el.dataset.name || '').replace('js-', '');\n if (!/^(name|size|date)$/.test(name)) return;\n const panel = getPath(el).filter(isDataset).filter(isPanel).pop();\n CloudCmd.sortPanel(name, panel);\n });\n}\n\nfunction getPath(el) {\n let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n if (!el) return path;\n return getPath(el.parentElement, path.concat(el));\n}\n\nasync function config() {\n const [, config] = await tryToCatch(DOM.Files.get, 'config');\n const type = config === null || config === void 0 ? void 0 : config.packer;\n EXT = DOM.getPackerExt(type);\n}\n\nmodule.exports.initKeysPanel = () => {\n const keysElement = DOM.getById('js-keyspanel');\n if (!keysElement) return;\n Events.addClick(keysElement, _ref => {\n let {\n target\n } = _ref;\n const {\n id\n } = target;\n\n const operation = name => {\n const {\n Operation\n } = CloudCmd;\n const fn = Operation.show.bind(null, name);\n return fn;\n };\n\n const clickFuncs = {\n 'f1': CloudCmd.Help.show,\n 'f2': CloudCmd.UserMenu.show,\n 'f3': CloudCmd.View.show,\n 'f4': CloudCmd.EditFile.show,\n 'f5': operation('copy'),\n 'f6': operation('move'),\n 'f7': DOM.promptNewDir,\n 'f8': operation('delete'),\n 'f9': CloudCmd.Menu.show,\n 'f10': CloudCmd.Config.show,\n '~': CloudCmd.Konsole.show,\n 'shift~': CloudCmd.Terminal.show,\n 'contact': CloudCmd.Contact.show\n };\n exec(clickFuncs[id]);\n });\n};\n\nconst getPanel = side => {\n if (!itype.string(side)) return side;\n return DOM.getByDataName('js-' + side);\n};\n\nmodule.exports.setOnPanel = side => {\n const panel = getPanel(side);\n const filesElement = DOM.getByDataName('js-files', panel);\n const pathElement = DOM.getByDataName('js-path', panel);\n /* ставим загрузку гифа на клик*/\n\n Events.addClick(pathElement, getPathListener(panel));\n Events.add(filesElement, EventsFiles);\n};\n\nfunction getPathListener(panel) {\n return onPathElementClick.bind(null, panel);\n}\n\nfunction isNoCurrent(panel) {\n const infoPanel = Info.panel;\n if (!infoPanel) return true;\n const namePanel = panel.getAttribute('data-name');\n const nameInfoPanel = infoPanel.getAttribute('data-name');\n return namePanel !== nameInfoPanel;\n}\n\nfunction decodePath(path) {\n const url = CloudCmd.HOST;\n const {\n prefix\n } = CloudCmd;\n const prefixReg = RegExp('^' + prefix + FS);\n return decodeURI(path).replace(url, '').replace(prefixReg, '') // browser doesn't replace % -> %25% do it for him\n .replace('%%', '%25%').replace(NBSP_REG, SPACE) || '/';\n}\n\nasync function onPathElementClick(panel, event) {\n event.preventDefault();\n const element = event.target;\n const attr = element.getAttribute('data-name');\n const noCurrent = isNoCurrent(panel);\n if (attr === 'js-copy-path') return copyPath(element);\n if (attr === 'js-refresh') return CloudCmd.refresh({\n panel,\n noCurrent\n });\n if (attr !== 'js-path-link') return;\n const {\n href\n } = element;\n const path = decodePath(href);\n await CloudCmd.loadDir({\n path,\n isRefresh: false,\n panel: noCurrent ? panel : Info.panel\n });\n}\n\nfunction copyPath(el) {\n clipboard.writeText(el.parentElement.title).then(CloudCmd.log).catch(CloudCmd.log);\n}\n\nfunction execIfNotUL(callback, event) {\n const {\n target\n } = event;\n const {\n tagName\n } = target;\n if (tagName !== 'UL') callback(event);\n}\n\nfunction onClick(event) {\n event.preventDefault();\n changePanel(event.target);\n}\n\nfunction toggleSelect(key, files) {\n const isMac = /Mac/.test(window.navigator.platform);\n if (!key) throw Error('key should not be undefined!');\n const [file] = files;\n if (isMac && key.meta || key.ctrl) return DOM.toggleSelectedFile(file);\n if (key.shift) return files.map(DOM.selectFile);\n}\n\nfunction changePanel(element) {\n const {\n panel\n } = Info;\n const files = DOM.getByDataName('js-files', panel);\n const ul = getULElement(element);\n if (ul !== files) DOM.changePanel();\n}\n\nasync function onDblClick(event) {\n event.preventDefault();\n const current = getLIElement(event.target);\n const isDir = DOM.isCurrentIsDir(current);\n const path = DOM.getCurrentPath(current);\n if (!isDir) return CloudCmd.View.show();\n await CloudCmd.loadDir({\n path\n });\n}\n\nasync function onTouch(event) {\n const current = getLIElement(event.target);\n const isDir = DOM.isCurrentIsDir(current);\n if (!isDir) return;\n const isCurrent = DOM.isCurrentFile(current);\n if (!isCurrent) return;\n await CloudCmd.loadDir({\n path: DOM.getCurrentPath(current)\n });\n}\n/*\n * download file from browser to desktop\n * in Chrome (HTML5)\n */\n\n\nfunction onDragStart(event) {\n const {\n prefixURL\n } = CloudCmd;\n const element = getLIElement(event.target);\n const {\n isDir\n } = Info;\n let link = DOM.getCurrentLink(element);\n let name = DOM.getCurrentName(element);\n /* if it's directory - adding json extension */\n\n if (isDir) {\n name += EXT;\n link = document.createElement('a');\n link.textContent = name;\n link.href = prefixURL + '/pack' + Info.path + EXT;\n }\n\n event.dataTransfer.setData('DownloadURL', 'application/octet-stream' + ':' + name + ':' + link);\n}\n\nfunction getLIElement(element) {\n if (!element) return element;\n\n while (element.tagName !== 'LI') element = element.parentElement;\n\n return element;\n}\n\nfunction getULElement(element) {\n while (element.tagName !== 'UL') element = element.parentElement;\n\n return element;\n}\n\nfunction setCurrentFileByEvent(event) {\n const BUTTON_LEFT = 0;\n const key = {\n alt: event.altKey,\n ctrl: event.ctrlKey,\n meta: event.metaKey,\n shift: event.shiftKey\n };\n const element = getLIElement(event.target);\n const fromName = Info.name;\n DOM.setCurrentFile(element);\n const toName = Info.name;\n let files = [];\n if (key.shift) files = getFilesRange(fromName, toName);else files.push(Info.element);\n if (event.button === BUTTON_LEFT) toggleSelect(key, files);\n}\n\nfunction getFilesRange(from, to) {\n const files = DOM.getAllFiles();\n const names = DOM.getFilenames(files);\n const getNameIndex = getIndex(names);\n const indexFrom = getNameIndex(from);\n const indexTo = getNameIndex(to);\n return getRange(indexFrom, indexTo, files);\n}\n\nfunction contextMenu() {\n const fm = DOM.getFM();\n Events.addOnce('contextmenu', fm, event => {\n CloudCmd.Menu.show({\n x: event.clientX,\n y: event.clientY\n });\n });\n Events.addContextMenu(fm, event => {\n CloudCmd.Menu.ENABLED || event.preventDefault();\n });\n}\n\nfunction dragndrop() {\n const panels = DOM.getByClassAll('panel');\n\n const select = _ref2 => {\n let {\n target\n } = _ref2;\n target.classList.add('selected-panel');\n };\n\n const unselect = _ref3 => {\n let {\n target\n } = _ref3;\n target.classList.remove('selected-panel');\n };\n\n const onDrop = event => {\n const {\n files,\n items\n } = event.dataTransfer;\n const {\n length: filesCount\n } = files;\n event.preventDefault();\n if (filesCount && (!items || !items.length || !items[0].webkitGetAsEntry)) return uploadFiles(files);\n\n const isFile = item => item.kind === 'file';\n\n const dirFiles = Array.from(items).filter(isFile);\n if (dirFiles.length) return DOM.uploadDirectory(dirFiles);\n const {\n Operation\n } = CloudCmd;\n const operation = event.shiftKey ? 'move' : 'copy';\n return Operation.show(operation);\n };\n /**\n * In Mac OS Chrome dropEffect = 'none'\n * so drop do not firing up when try\n * to upload file from download bar\n */\n\n\n const onDragOver = event => {\n const {\n dataTransfer\n } = event;\n const {\n effectAllowed\n } = dataTransfer;\n if (/move|linkMove/.test(effectAllowed)) dataTransfer.dropEffect = 'move';else dataTransfer.dropEffect = 'copy';\n event.preventDefault();\n };\n\n for (const panel of panels) Events.add('dragover', panel, onDragOver).add('drop', panel, onDrop).add('dragenter', select).add(['dragleave', 'drop'], unselect);\n}\n\nfunction unload() {\n DOM.Events.add(['unload', 'beforeunload'], event => {\n const {\n Key\n } = CloudCmd;\n const isBind = Key === null || Key === void 0 ? void 0 : Key.isBind();\n if (isBind) return;\n event.preventDefault();\n return 'Please make sure that you saved all work.';\n });\n}\n\nfunction pop() {\n Events.add('popstate', async _ref4 => {\n let {\n state\n } = _ref4;\n const path = (state || '').replace(FS, '');\n if (!path) return CloudCmd.route(location.hash);\n const history = false;\n await CloudCmd.loadDir({\n path,\n history\n });\n });\n}\n\nfunction resize() {\n Events.add('resize', () => {\n const is = window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH;\n if (!is) return;\n const {\n panel\n } = Info;\n const isEmptyRoot = !panel;\n if (isEmptyRoot) return;\n const name = panel.getAttribute('data-name');\n const isLeft = name === 'js-left';\n if (isLeft) return;\n DOM.changePanel();\n });\n}\n\n//# sourceURL=file://cloudcmd/client/listeners/index.js");
|
|
299
299
|
|
|
300
300
|
/***/ }),
|
|
301
301
|
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
/***/ (function(module, exports, __webpack_require__) {
|
|
164
164
|
|
|
165
165
|
"use strict";
|
|
166
|
-
eval("/* global CloudCmd, filepicker */\n\n\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst {\n
|
|
166
|
+
eval("/* global CloudCmd, filepicker */\n\n\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst {\n ajax\n} = __webpack_require__(/*! ../dom/load */ \"./client/dom/load.js\");\n\nconst Files = __webpack_require__(/*! ../dom/files */ \"./client/dom/files.js\");\n\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.js\");\n\nconst {\n log\n} = CloudCmd;\nconst upload = currify(_upload);\nconst Name = 'Cloud';\nCloudCmd[Name] = module.exports;\n\nmodule.exports.init = async () => {\n const [modules] = await loadFiles();\n const {\n key\n } = modules.data.FilePicker;\n filepicker.setKey(key);\n Images.hide();\n};\n\nmodule.exports.uploadFile = (filename, data) => {\n const mimetype = '';\n filepicker.store(data, {\n mimetype,\n filename\n }, fpFile => {\n filepicker.exportFile(fpFile, log, log);\n });\n};\n\nmodule.exports.saveFile = callback => {\n filepicker.pick(upload(callback));\n};\n\nfunction _upload(callback, file) {\n const {\n url,\n filename\n } = file;\n const responseType = 'arraybuffer';\n const success = exec.with(callback, filename);\n ajax({\n url,\n responseType,\n success\n });\n}\n\nfunction loadFiles() {\n const js = '//api.filepicker.io/v2/filepicker.js';\n return Promise.all([Files.get('modules'), load.js(js)]);\n}\n\n//# sourceURL=file://cloudcmd/client/modules/cloud.js");
|
|
167
167
|
|
|
168
168
|
/***/ })
|
|
169
169
|
|
package/dist-dev/modules/edit.js
CHANGED
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
/***/ (function(module, exports, __webpack_require__) {
|
|
164
164
|
|
|
165
165
|
"use strict";
|
|
166
|
-
eval("/* global CloudCmd */\n\n\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.mjs\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst
|
|
166
|
+
eval("/* global CloudCmd */\n\n\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.mjs\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst {\n MAX_FILE_SIZE: maxSize\n} = __webpack_require__(/*! ../../common/cloudfunc */ \"./common/cloudfunc.js\");\n\nconst {\n time,\n timeEnd\n} = __webpack_require__(/*! ../../common/util */ \"./common/util.js\");\n\nconst loadJS = load.js;\nconst Name = 'Edit';\nCloudCmd[Name] = exports;\nconst EditorName = CloudCmd.config('editor');\nlet Loading = true;\nlet Element;\nlet editor;\nconst ConfigView = {\n afterShow: () => {\n editor.moveCursorTo(0, 0).focus();\n }\n};\n\nmodule.exports.init = async () => {\n const element = create();\n await CloudCmd.View();\n await loadFiles(element);\n};\n\nfunction create() {\n const element = createElement('div', {\n style: 'width : 100%;' + 'height : 100%;' + 'font-family: \"Droid Sans Mono\";',\n notAppend: true\n });\n Element = element;\n return element;\n}\n\nfunction checkFn(name, fn) {\n if (typeof fn !== 'function') throw Error(name + ' should be a function!');\n}\n\nfunction initConfig() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const config = { ...options,\n ...ConfigView\n };\n if (!options.afterShow) return config;\n checkFn('options.afterShow', options.afterShow);\n const afterShow = {\n config\n };\n\n config.afterShow = () => {\n afterShow();\n options.afterShow();\n };\n\n return config;\n}\n\nmodule.exports.show = options => {\n if (Loading) return;\n CloudCmd.View.show(Element, initConfig(options));\n getEditor().setOptions({\n fontSize: 16\n });\n};\n\nmodule.exports.getEditor = getEditor;\n\nfunction getEditor() {\n return editor;\n}\n\nmodule.exports.getElement = () => Element;\n\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\n\nconst loadFiles = async element => {\n const prefix = `${CloudCmd.prefix}/${EditorName}`;\n const socketPath = CloudCmd.prefix;\n const prefixSocket = `${CloudCmd.prefixSocket}/${EditorName}`;\n const url = `${prefix}/${EditorName}.js`;\n time(Name + ' load');\n await loadJS(url);\n const word = promisify(window[EditorName]);\n const [ed] = await tryToCatch(word, element, {\n maxSize,\n prefix,\n prefixSocket,\n socketPath\n });\n timeEnd(Name + ' load');\n editor = ed;\n Loading = false;\n};\n\n//# sourceURL=file://cloudcmd/client/modules/edit.js");
|
|
167
167
|
|
|
168
168
|
/***/ })
|
|
169
169
|
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
/***/ (function(module, exports, __webpack_require__) {
|
|
164
164
|
|
|
165
165
|
"use strict";
|
|
166
|
-
eval("\n/* global CloudCmd */\n\nCloudCmd.Markdown = exports;\n\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.js\");\n\nconst {\n Markdown\n} = __webpack_require__(/*! ../dom/rest */ \"./client/dom/rest.js\");\n\nconst {\n alert\n} = __webpack_require__(/*! ../dom/dialog */ \"./client/dom/dialog.js\");\n\nmodule.exports.init = async () => {\n Images.show.load('top');\n await CloudCmd.View();\n};\n\nmodule.exports.show = show;\n\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\n\nasync function show(name) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const
|
|
166
|
+
eval("\n/* global CloudCmd */\n\nCloudCmd.Markdown = exports;\n\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.js\");\n\nconst {\n Markdown\n} = __webpack_require__(/*! ../dom/rest */ \"./client/dom/rest.js\");\n\nconst {\n alert\n} = __webpack_require__(/*! ../dom/dialog */ \"./client/dom/dialog.js\");\n\nmodule.exports.init = async () => {\n Images.show.load('top');\n await CloudCmd.View();\n};\n\nmodule.exports.show = show;\n\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\n\nasync function show(name) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const {\n positionLoad,\n relative\n } = options;\n Images.show.load(positionLoad);\n if (relative) name += '?relative';\n const [error, innerHTML] = await Markdown.read(name);\n Images.hide();\n if (error) return alert(error.message, {\n cancel: false\n });\n const className = 'help';\n const div = createElement('div', {\n className,\n innerHTML\n });\n CloudCmd.View.show(div);\n}\n\n//# sourceURL=file://cloudcmd/client/modules/markdown.js");
|
|
167
167
|
|
|
168
168
|
/***/ })
|
|
169
169
|
|
|
@@ -211,7 +211,7 @@ eval("\n\nconst {\n getExt\n} = __webpack_require__(/*! ../../../common/util */
|
|
|
211
211
|
/***/ (function(module, exports, __webpack_require__) {
|
|
212
212
|
|
|
213
213
|
"use strict";
|
|
214
|
-
eval("\n/* global DOM */\n\nconst
|
|
214
|
+
eval("\n/* global DOM */\n\nconst forEachKey = __webpack_require__(/*! for-each-key */ \"./node_modules/for-each-key/lib/for-each-key.js\");\n\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n\nconst format = __webpack_require__(/*! ./format */ \"./client/modules/operation/format.js\");\n\nconst {\n Dialog,\n Images\n} = DOM;\n\nmodule.exports = options => emitter => {\n const {\n operation,\n callback,\n noContinue,\n from,\n to\n } = options;\n let done;\n let lastError;\n const onAbort = wraptile(_ref => {\n let {\n emitter,\n operation\n } = _ref;\n emitter.abort();\n const msg = `${operation} aborted`;\n lastError = true;\n Dialog.alert(msg, {\n cancel: false\n });\n });\n const removeListener = emitter.removeListener.bind(emitter);\n const on = emitter.on.bind(emitter);\n const message = format(operation, from, to);\n const progress = Dialog.progress(message);\n progress.catch(onAbort({\n emitter,\n operation\n }));\n const listeners = {\n progress: value => {\n done = value === 100;\n progress.setProgress(value);\n },\n end: () => {\n Images.hide();\n forEachKey(removeListener, listeners);\n progress.remove();\n if (lastError || done) callback();\n },\n error: async error => {\n lastError = error;\n\n if (noContinue) {\n listeners.end(error);\n Dialog.alert(error);\n progress.remove();\n return;\n }\n\n const [cancel] = await Dialog.confirm(error + '\\n Continue?');\n if (!done && !cancel) return emitter.continue();\n emitter.abort();\n progress.remove();\n }\n };\n forEachKey(on, listeners);\n};\n\n//# sourceURL=file://cloudcmd/client/modules/operation/set-listeners.js");
|
|
215
215
|
|
|
216
216
|
/***/ })
|
|
217
217
|
|
package/dist-dev/sw.js
CHANGED
|
@@ -101,7 +101,7 @@ var serviceWorkerOption = {
|
|
|
101
101
|
/***/ (function(module, exports, __webpack_require__) {
|
|
102
102
|
|
|
103
103
|
"use strict";
|
|
104
|
-
eval("\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst isDev = \"development\" === 'development';\n\nconst isGet = a => a.method === 'GET';\n\nconst isBasic = a => a.type === 'basic';\n\nconst wait = currify((f, e) => e.waitUntil(f()));\nconst respondWith = currify((f, e) => {\n const {\n request\n } = e;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n if (url.endsWith('/') || /\\^\\/fs/.test(pathname)) return;\n if (!isGet(request)) return;\n if (!isBasic(request)) return;\n if (pathname.startsWith('/api')) return;\n if (/^socket.io/.test(pathname)) return;\n e.respondWith(f(e));\n});\n\nconst getPathName = url => new URL(url).pathname;\n\nconst date = \"
|
|
104
|
+
eval("\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst isDev = \"development\" === 'development';\n\nconst isGet = a => a.method === 'GET';\n\nconst isBasic = a => a.type === 'basic';\n\nconst wait = currify((f, e) => e.waitUntil(f()));\nconst respondWith = currify((f, e) => {\n const {\n request\n } = e;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n if (url.endsWith('/') || /\\^\\/fs/.test(pathname)) return;\n if (!isGet(request)) return;\n if (!isBasic(request)) return;\n if (pathname.startsWith('/api')) return;\n if (/^socket.io/.test(pathname)) return;\n e.respondWith(f(e));\n});\n\nconst getPathName = url => new URL(url).pathname;\n\nconst date = \"Fri Jun 17 2022 16:49:49 GMT+0300 (Eastern European Summer Time)\";\nconst NAME = `cloudcmd: ${date}`;\n\nconst createRequest = a => new Request(a, {\n credentials: 'same-origin'\n});\n\nconst getRequest = (a, request) => {\n if (a !== '/') return request;\n return createRequest('/');\n};\n\nself.addEventListener('install', wait(onInstall));\nself.addEventListener('fetch', respondWith(onFetch));\nself.addEventListener('activate', wait(onActivate));\n\nasync function onActivate() {\n console.info(`cloudcmd: sw: activate: ${NAME}`);\n await self.clients.claim();\n const keys = await caches.keys();\n const deleteCache = caches.delete.bind(caches);\n await Promise.all(keys.map(deleteCache));\n}\n\nasync function onInstall() {\n console.info(`cloudcmd: sw: install: ${NAME}`);\n await self.skipWaiting();\n}\n\nasync function onFetch(event) {\n const {\n request\n } = event;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n const newRequest = getRequest(pathname, event.request);\n const cache = await caches.open(NAME);\n const response = await cache.match(request);\n if (!isDev && response) return response;\n const [e, resp] = await tryToCatch(fetch, newRequest, {\n credentials: 'same-origin'\n });\n if (e) return new Response(e.message);\n await addToCache(request, resp.clone());\n return resp;\n}\n\nasync function addToCache(request, response) {\n const cache = await caches.open(NAME);\n return cache.put(request, response);\n}\n\n//# sourceURL=file://cloudcmd/client/sw/sw.js");
|
|
105
105
|
|
|
106
106
|
/***/ }),
|
|
107
107
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcmd",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.2.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "File manager for the web with console and editor",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"jju": "^1.3.0",
|
|
112
112
|
"jonny": "^3.0.0",
|
|
113
113
|
"just-snake-case": "^1.1.0",
|
|
114
|
-
"markdown-it": "^
|
|
114
|
+
"markdown-it": "^13.0.1",
|
|
115
115
|
"mellow": "^3.0.0",
|
|
116
116
|
"nomine": "^4.0.0",
|
|
117
117
|
"object.omit": "^3.0.0",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"socket.io-client": "^4.0.1",
|
|
133
133
|
"squad": "^3.0.0",
|
|
134
134
|
"table": "^6.0.1",
|
|
135
|
-
"thread-it": "^
|
|
135
|
+
"thread-it": "^2.0.0",
|
|
136
136
|
"try-catch": "^3.0.0",
|
|
137
137
|
"try-to-catch": "^3.0.0",
|
|
138
138
|
"tryrequire": "^3.0.0",
|
package/server/cloudcmd.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const DIR = __dirname + '/';
|
|
4
|
-
const DIR_ROOT = DIR + '../';
|
|
5
4
|
const DIR_COMMON = DIR + '../common/';
|
|
6
|
-
|
|
7
5
|
const path = require('path');
|
|
8
|
-
const fs = require('fs');
|
|
9
6
|
|
|
7
|
+
const fs = require('fs');
|
|
10
8
|
const cloudfunc = require(DIR_COMMON + 'cloudfunc');
|
|
9
|
+
|
|
11
10
|
const authentication = require(DIR + 'auth');
|
|
12
11
|
const {
|
|
13
12
|
createConfig,
|
|
14
13
|
configPath,
|
|
15
14
|
} = require(DIR + 'config');
|
|
16
|
-
|
|
17
15
|
const modulas = require(DIR + 'modulas');
|
|
16
|
+
|
|
18
17
|
const userMenu = require(DIR + 'user-menu');
|
|
19
18
|
const rest = require(DIR + 'rest');
|
|
20
19
|
const route = require(DIR + 'route');
|
|
@@ -22,8 +21,8 @@ const validate = require(DIR + 'validate');
|
|
|
22
21
|
const prefixer = require(DIR + 'prefixer');
|
|
23
22
|
const terminal = require(DIR + 'terminal');
|
|
24
23
|
const distribute = require(DIR + 'distribute');
|
|
25
|
-
|
|
26
24
|
const currify = require('currify');
|
|
25
|
+
|
|
27
26
|
const apart = require('apart');
|
|
28
27
|
const ponse = require('ponse');
|
|
29
28
|
const restafary = require('restafary');
|
|
@@ -34,6 +33,7 @@ const dword = require('dword');
|
|
|
34
33
|
const deepword = require('deepword');
|
|
35
34
|
const nomine = require('nomine');
|
|
36
35
|
const fileop = require('@cloudcmd/fileop');
|
|
36
|
+
const DIR_ROOT = DIR + '../';
|
|
37
37
|
|
|
38
38
|
const isDev = process.env.NODE_ENV === 'development';
|
|
39
39
|
const getDist = (isDev) => isDev ? 'dist-dev' : 'dist';
|
package/server/config.js
CHANGED
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
const DIR_SERVER = __dirname + '/';
|
|
4
4
|
const DIR_COMMON = '../common/';
|
|
5
|
-
const DIR = DIR_SERVER + '../';
|
|
6
|
-
|
|
7
5
|
const path = require('path');
|
|
6
|
+
|
|
8
7
|
const fs = require('fs');
|
|
9
8
|
const Emitter = require('events');
|
|
10
9
|
const {homedir} = require('os');
|
|
11
|
-
|
|
12
10
|
const exit = require(DIR_SERVER + 'exit');
|
|
13
|
-
const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
|
14
11
|
|
|
12
|
+
const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
|
15
13
|
const currify = require('currify');
|
|
14
|
+
|
|
16
15
|
const wraptile = require('wraptile');
|
|
17
16
|
const tryToCatch = require('try-to-catch');
|
|
18
17
|
const pullout = require('pullout');
|
|
@@ -22,6 +21,7 @@ const jju = require('jju');
|
|
|
22
21
|
const writejson = require('writejson');
|
|
23
22
|
const tryCatch = require('try-catch');
|
|
24
23
|
const criton = require('criton');
|
|
24
|
+
const DIR = DIR_SERVER + '../';
|
|
25
25
|
const HOME = homedir();
|
|
26
26
|
|
|
27
27
|
const resolve = Promise.resolve.bind(Promise);
|
|
@@ -6,10 +6,10 @@ const squad = require('squad');
|
|
|
6
6
|
const fullstore = require('fullstore');
|
|
7
7
|
|
|
8
8
|
const io = require('socket.io-client');
|
|
9
|
-
const forEachKey = currify(require('for-each-key'));
|
|
10
|
-
|
|
11
9
|
const log = require('./log');
|
|
10
|
+
|
|
12
11
|
const env = require('../env');
|
|
12
|
+
const forEachKey = currify(require('for-each-key'));
|
|
13
13
|
|
|
14
14
|
const {
|
|
15
15
|
importStr,
|
package/server/markdown/index.js
CHANGED
|
@@ -8,10 +8,10 @@ const ponse = require('ponse');
|
|
|
8
8
|
const threadIt = require('thread-it');
|
|
9
9
|
const {read} = require('redzip');
|
|
10
10
|
|
|
11
|
-
const parse = threadIt(join(__dirname, 'worker'));
|
|
12
|
-
|
|
13
11
|
const root = require('../root');
|
|
14
12
|
|
|
13
|
+
const parse = threadIt(join(__dirname, 'worker'));
|
|
14
|
+
|
|
15
15
|
threadIt.init();
|
|
16
16
|
|
|
17
17
|
// warm up
|
package/server/route.js
CHANGED
|
@@ -20,9 +20,11 @@ const root = require(DIR_SERVER + 'root');
|
|
|
20
20
|
const prefixer = require(DIR_SERVER + 'prefixer');
|
|
21
21
|
const CloudFunc = require(DIR_COMMON + 'cloudfunc');
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const Columns = require(`${DIR_SERVER}/columns`);
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const Template = require(`${DIR_SERVER}/template`);
|
|
26
|
+
|
|
27
|
+
const {FS} = CloudFunc;
|
|
26
28
|
|
|
27
29
|
const sendIndex = (params, data) => {
|
|
28
30
|
const ponseParams = {
|
|
@@ -33,10 +35,8 @@ const sendIndex = (params, data) => {
|
|
|
33
35
|
ponse.send(data, ponseParams);
|
|
34
36
|
};
|
|
35
37
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const Columns = require(`${DIR_SERVER}/columns`);
|
|
39
|
-
const Template = require(`${DIR_SERVER}/template`);
|
|
38
|
+
const onceRequire = once(require);
|
|
39
|
+
const getPrefix = (config) => prefixer(config('prefix'));
|
|
40
40
|
|
|
41
41
|
const getReadDir = (config) => {
|
|
42
42
|
if (!config('dropbox'))
|
|
@@ -1,39 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
import cloudcmd from './cloudcmd.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import http from 'http';
|
|
4
|
+
import {promisify} from 'util';
|
|
5
|
+
import currify from 'currify';
|
|
6
|
+
import squad from 'squad';
|
|
7
|
+
import tryToCatch from 'try-to-catch';
|
|
8
|
+
import wraptile from 'wraptile';
|
|
9
|
+
import compression from 'compression';
|
|
10
|
+
import threadIt from 'thread-it';
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const currify = require('currify');
|
|
9
|
-
const squad = require('squad');
|
|
10
|
-
const tryToCatch = require('try-to-catch');
|
|
11
|
-
const wraptile = require('wraptile');
|
|
12
|
-
const compression = require('compression');
|
|
13
|
-
const threadIt = require('thread-it');
|
|
12
|
+
import exit from './exit.js';
|
|
13
|
+
import opn from 'open';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
import express from 'express';
|
|
16
|
+
import {Server} from 'socket.io';
|
|
17
|
+
import tryRequire from 'tryrequire';
|
|
17
18
|
|
|
18
|
-
const exitPort = two(exit, 'cloudcmd --port: %s');
|
|
19
19
|
const bind = (f, self) => f.bind(self);
|
|
20
|
-
const promisifySelf = squad(promisify, bind);
|
|
21
20
|
|
|
21
|
+
const two = currify((f, a, b) => f(a, b));
|
|
22
22
|
const shutdown = wraptile(async (promises) => {
|
|
23
23
|
console.log('closing cloudcmd...');
|
|
24
24
|
await Promise.all(promises);
|
|
25
25
|
threadIt.terminate();
|
|
26
26
|
process.exit(0);
|
|
27
27
|
});
|
|
28
|
+
const promisifySelf = squad(promisify, bind);
|
|
28
29
|
|
|
29
|
-
const
|
|
30
|
-
const express = require('express');
|
|
31
|
-
const io = require('socket.io');
|
|
32
|
-
|
|
33
|
-
const tryRequire = require('tryrequire');
|
|
30
|
+
const exitPort = two(exit, 'cloudcmd --port: %s');
|
|
34
31
|
const logger = tryRequire('morgan');
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
export default async (options, config) => {
|
|
37
34
|
const prefix = config('prefix');
|
|
38
35
|
const port = process.env.PORT /* c9 */
|
|
39
36
|
|| config('port');
|
|
@@ -51,7 +48,7 @@ module.exports = async (options, config) => {
|
|
|
51
48
|
if (prefix)
|
|
52
49
|
app.get('/', (req, res) => res.redirect(prefix + '/'));
|
|
53
50
|
|
|
54
|
-
const socketServer =
|
|
51
|
+
const socketServer = new Server(server, {
|
|
55
52
|
path: `${prefix}/socket.io`,
|
|
56
53
|
});
|
|
57
54
|
|
package/tmpl/config.hbs
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
Diff
|
|
35
35
|
</label>
|
|
36
36
|
</li>
|
|
37
|
-
<li title="Pack text data
|
|
37
|
+
<li title="Pack text data transferred by an Editor">
|
|
38
38
|
<label>
|
|
39
39
|
<input
|
|
40
40
|
data-name="js-zip"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
Zip
|
|
44
44
|
</label>
|
|
45
45
|
</li>
|
|
46
|
-
<li title="Visible
|
|
46
|
+
<li title="Visible Columns">
|
|
47
47
|
<select data-name="js-columns" class="form-control full-width" title="Visible Columns">
|
|
48
48
|
<option {{ name-size-date-owner-mode-selected }}>name-size-date-owner-mode</option>
|
|
49
49
|
<option {{ name-size-date-selected }}>name-size-date</option>
|