cloudcmd 19.0.17 → 19.1.1

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.
Files changed (64) hide show
  1. package/ChangeLog +18 -0
  2. package/HELP.md +3 -1
  3. package/README.md +1 -1
  4. package/bin/cloudcmd.mjs +1 -1
  5. package/common/try-to-promise-all.js +1 -1
  6. package/dist/cloudcmd.common.js +2 -2
  7. package/dist/cloudcmd.common.js.map +1 -1
  8. package/dist/cloudcmd.js +1 -1
  9. package/dist/cloudcmd.js.map +1 -1
  10. package/dist/modules/cloud.js +1 -1
  11. package/dist/modules/cloud.js.map +1 -1
  12. package/dist/modules/command-line.js +1 -1
  13. package/dist/modules/command-line.js.map +1 -1
  14. package/dist/modules/config.js +1 -1
  15. package/dist/modules/config.js.map +1 -1
  16. package/dist/modules/contact.js +1 -1
  17. package/dist/modules/contact.js.map +1 -1
  18. package/dist/modules/edit-file-vim.js +1 -1
  19. package/dist/modules/edit-file-vim.js.map +1 -1
  20. package/dist/modules/edit-file.js +1 -1
  21. package/dist/modules/edit-file.js.map +1 -1
  22. package/dist/modules/edit-names-vim.js +1 -1
  23. package/dist/modules/edit-names-vim.js.map +1 -1
  24. package/dist/modules/edit-names.js +1 -1
  25. package/dist/modules/edit-names.js.map +1 -1
  26. package/dist/modules/edit.js +1 -1
  27. package/dist/modules/edit.js.map +1 -1
  28. package/dist/modules/help.js +1 -1
  29. package/dist/modules/help.js.map +1 -1
  30. package/dist/modules/konsole.js +1 -1
  31. package/dist/modules/konsole.js.map +1 -1
  32. package/dist/modules/markdown.js +1 -1
  33. package/dist/modules/markdown.js.map +1 -1
  34. package/dist/modules/menu.js +1 -1
  35. package/dist/modules/menu.js.map +1 -1
  36. package/dist/modules/operation.js +1 -1
  37. package/dist/modules/operation.js.map +1 -1
  38. package/dist/modules/polyfill.js +1 -1
  39. package/dist/modules/polyfill.js.map +1 -1
  40. package/dist/modules/terminal-run.js +1 -1
  41. package/dist/modules/terminal-run.js.map +1 -1
  42. package/dist/modules/terminal.js +1 -1
  43. package/dist/modules/terminal.js.map +1 -1
  44. package/dist/modules/upload.js +1 -1
  45. package/dist/modules/upload.js.map +1 -1
  46. package/dist/modules/user-menu.js +1 -1
  47. package/dist/modules/user-menu.js.map +1 -1
  48. package/dist/modules/view.js +1 -1
  49. package/dist/modules/view.js.map +1 -1
  50. package/dist/sw.js +1 -1
  51. package/dist/sw.js.map +1 -1
  52. package/dist-dev/cloudcmd.common.js +101 -36
  53. package/dist-dev/sw.js +43 -3
  54. package/package.json +9 -9
  55. package/server/cloudcmd.mjs +1 -1
  56. package/server/columns.mjs +4 -3
  57. package/server/config.js +2 -2
  58. package/server/distribute/import.mjs +1 -1
  59. package/server/route.mjs +1 -1
  60. package/server/server.mjs +1 -1
  61. package/server/terminal.js +1 -1
  62. package/server/theme.mjs +3 -4
  63. package/server/user-menu.mjs +1 -1
  64. package/server/validate.mjs +1 -1
@@ -15,7 +15,7 @@
15
15
  (module, __unused_webpack_exports, __webpack_require__) {
16
16
 
17
17
  "use strict";
18
- eval("{\n\nconst process = __webpack_require__(/*! node:process */ \"./node_modules/process/browser.js\");\n\n/* global DOM */\nconst Emitify = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\nconst inherits = __webpack_require__(/*! inherits */ \"./node_modules/inherits/inherits_browser.js\");\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n addSlashToEnd\n} = __webpack_require__(/*! format-io */ \"./node_modules/format-io/lib/format.js\");\nconst pascalCase = __webpack_require__(/*! just-pascal-case */ \"./node_modules/just-pascal-case/index.cjs\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst Images = __webpack_require__(/*! ./dom/images */ \"./client/dom/images.js\");\nconst {\n unregisterSW\n} = __webpack_require__(/*! ./sw/register */ \"./client/sw/register.js\");\nconst getJsonFromFileTable = __webpack_require__(/*! ./get-json-from-file-table */ \"./client/get-json-from-file-table.js\");\nconst Key = __webpack_require__(/*! ./key */ \"./client/key/index.js\");\nconst {\n apiURL,\n formatMsg,\n buildFromJSON\n} = __webpack_require__(/*! ../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst loadModule = __webpack_require__(/*! ./load-module */ \"./client/load-module.js\");\nconst noJS = a => a.replace(/.js$/, '');\nconst isDev = process.env.NODE_ENV === '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});\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 this.log = (...a) => {\n if (!isDev) return;\n console.log(...a);\n };\n this.prefix = '';\n this.prefixSocket = '';\n this.prefixURL = '';\n this.MIN_ONE_PANEL_WIDTH = DOM.getCSSVar('min-one-panel-width');\n this.HOST = location.origin || location.protocol + '//' + location.host;\n this.sort = {\n left: 'name',\n right: 'name'\n };\n this.order = {\n left: 'asc',\n right: 'asc'\n };\n this.changeDir = async (path, overrides = {}) => {\n const {\n isRefresh,\n panel,\n history = true,\n noCurrent,\n currentName\n } = overrides;\n const refresh = isRefresh;\n let panelChanged;\n if (!noCurrent && panel && panel !== Info.panel) {\n DOM.changePanel();\n panelChanged = true;\n }\n let imgPosition;\n if (panelChanged || refresh || !history) imgPosition = 'top';\n Images.show.load(imgPosition, panel);\n\n /* загружаем содержимое каталога */\n await ajaxLoad(addSlashToEnd(path), {\n refresh,\n history,\n noCurrent,\n currentName,\n showDotFiles: CloudCmd.config('showDotFiles')\n }, panel);\n };\n\n /**\n * Конструктор CloudClient, который\n * выполняет весь функционал по\n * инициализации\n */\n this.init = async (prefix, config) => {\n CloudCmd.prefix = prefix;\n CloudCmd.prefixURL = `${prefix}${apiURL}`;\n CloudCmd.prefixSocket = config.prefixSocket;\n CloudCmd.DIR_DIST = `${prefix}/dist`;\n CloudCmd.DIR_MODULES = `${this.DIR_DIST}/modules`;\n CloudCmd.config = key => config[key];\n CloudCmd.config.if = currify((key, fn, a) => config[key] && fn(a));\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 if (config.oneFilePanel) CloudCmd.MIN_ONE_PANEL_WIDTH = Infinity;\n if (!document.body.scrollIntoViewIfNeeded) await load.js(`${CloudCmd.DIR_MODULES}/polyfill.js`);\n await initModules();\n await baseInit();\n CloudCmd.route(location.hash);\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;\n const current = DOM.getCurrentByName(file);\n if (file && !current) {\n const msg = formatMsg('set current file', file, 'error');\n CloudCmd.log(msg);\n return;\n }\n DOM.setCurrentFile(current);\n CloudCmd.execFromModule(module, 'show');\n };\n this.logOut = async () => {\n const url = CloudCmd.prefix + '/logout';\n const error = () => document.location.reload();\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 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 const load = (name, path, dobefore) => {\n loadModule({\n name,\n path,\n dobefore\n });\n };\n if (!modules) return;\n for (const module of modules.local) {\n load(null, module, doBefore[module]);\n }\n };\n async function saveCurrentName(currentName) {\n await Storage.set('current-name', currentName);\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 ({\n Listeners\n } = CloudCmd);\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 function getPanels() {\n const panels = ['left'];\n if (CloudCmd.config('oneFilePanel')) return panels;\n return [...panels, 'right'];\n }\n this.execFromModule = async (moduleName, funcName, ...args) => {\n await CloudCmd[moduleName]();\n const func = CloudCmd[moduleName][funcName];\n func(...args);\n };\n this.refresh = async (options = {}) => {\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 === null || options === void 0 ? void 0 : options.noCurrent;\n await CloudCmd.changeDir(path, {\n isRefresh,\n history,\n panel,\n noCurrent,\n currentName\n });\n };\n\n /**\n * Функция загружает json-данные о Файловой Системе\n * через ajax-запрос.\n * @param path - каталог для чтения\n * @param options\n * { refresh, history } - необходимость обновить данные о каталоге\n * @param panel\n *\n */\n async function ajaxLoad(path, options = {}, panel) {\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)\n // that's OK, error handled by RESTful\n return;\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 * Функция строит файловую таблицу\n * @param data - данные о файлах\n * @param panelParam\n * @param options - history, noCurrent, showDotFiles\n */\n async function createFileTable(data, panelParam, options) {\n const {\n history,\n noCurrent,\n showDotFiles\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 while (i--) panel.removeChild(panel.lastChild);\n panel.innerHTML = buildFromJSON({\n sort: options.sort,\n order: options.order,\n data,\n id: panel.id,\n prefix,\n showDotFiles,\n template: {\n file,\n path,\n pathLink,\n link\n }\n });\n Listeners.setOnPanel(panel);\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 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.changeDir(path);\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\n}");
18
+ eval("{\n\nconst process = __webpack_require__(/*! node:process */ \"./node_modules/process/browser.js\");\n\n/* global DOM */\nconst Emitify = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\nconst inherits = __webpack_require__(/*! inherits */ \"./node_modules/inherits/inherits_browser.js\");\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst {\n addSlashToEnd\n} = __webpack_require__(/*! format-io */ \"./node_modules/format-io/lib/format.js\");\nconst pascalCase = __webpack_require__(/*! just-pascal-case */ \"./node_modules/just-pascal-case/index.cjs\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst Images = __webpack_require__(/*! ./dom/images */ \"./client/dom/images.js\");\nconst {\n unregisterSW\n} = __webpack_require__(/*! ./sw/register */ \"./client/sw/register.js\");\nconst getJsonFromFileTable = __webpack_require__(/*! ./get-json-from-file-table */ \"./client/get-json-from-file-table.js\");\nconst Key = __webpack_require__(/*! ./key */ \"./client/key/index.js\");\nconst {\n apiURL,\n formatMsg,\n buildFromJSON\n} = __webpack_require__(/*! ../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst loadModule = __webpack_require__(/*! ./load-module */ \"./client/load-module.js\");\nconst noJS = a => a.replace(/.js$/, '');\nconst isDev = process.env.NODE_ENV === '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});\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 this.log = (...a) => {\n if (!isDev) return;\n console.log(...a);\n };\n this.prefix = '';\n this.prefixSocket = '';\n this.prefixURL = '';\n this.MIN_ONE_PANEL_WIDTH = DOM.getCSSVar('min-one-panel-width');\n this.HOST = location.origin || location.protocol + '//' + location.host;\n this.sort = {\n left: 'name',\n right: 'name'\n };\n this.order = {\n left: 'asc',\n right: 'asc'\n };\n this.changeDir = async (path, overrides = {}) => {\n const {\n isRefresh,\n panel,\n history = true,\n noCurrent,\n currentName\n } = overrides;\n const refresh = isRefresh;\n let panelChanged;\n if (!noCurrent && panel && panel !== Info.panel) {\n DOM.changePanel();\n panelChanged = true;\n }\n let imgPosition;\n if (panelChanged || refresh || !history) imgPosition = 'top';\n Images.show.load(imgPosition, panel);\n\n /* загружаем содержимое каталога */\n await ajaxLoad(addSlashToEnd(path), {\n refresh,\n history,\n noCurrent,\n currentName,\n showDotFiles: CloudCmd.config('showDotFiles')\n }, panel);\n };\n\n /**\n * Конструктор CloudClient, который\n * выполняет весь функционал по\n * инициализации\n */\n this.init = async (prefix, config) => {\n CloudCmd.prefix = prefix;\n CloudCmd.prefixURL = `${prefix}${apiURL}`;\n CloudCmd.prefixSocket = config.prefixSocket;\n CloudCmd.DIR_DIST = `${prefix}/dist`;\n CloudCmd.DIR_MODULES = `${this.DIR_DIST}/modules`;\n CloudCmd.config = key => config[key];\n CloudCmd.config.if = currify((key, fn, a) => config[key] && fn(a));\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 if (config.oneFilePanel) CloudCmd.MIN_ONE_PANEL_WIDTH = Infinity;\n if (!document.body.scrollIntoViewIfNeeded) await load.js(`${CloudCmd.DIR_MODULES}/polyfill.js`);\n await initModules();\n await baseInit();\n CloudCmd.route(location.hash);\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;\n const current = DOM.getCurrentByName(file);\n if (file && !current) {\n const msg = formatMsg('set current file', file, 'error');\n CloudCmd.log(msg);\n return;\n }\n DOM.setCurrentFile(current);\n CloudCmd.execFromModule(module, 'show');\n };\n this.logOut = async () => {\n const url = CloudCmd.prefix + '/logout';\n const error = () => document.location.reload();\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 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 const load = (name, path, dobefore) => {\n loadModule({\n name,\n path,\n dobefore\n });\n };\n if (!modules) return;\n for (const module of modules.local) {\n load(null, module, doBefore[module]);\n }\n };\n async function saveCurrentName(currentName) {\n await Storage.set('current-name', currentName);\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 ({\n Listeners\n } = CloudCmd);\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 function getPanels() {\n const panels = ['left'];\n if (CloudCmd.config('oneFilePanel')) return panels;\n return [...panels, 'right'];\n }\n this.execFromModule = async (moduleName, funcName, ...args) => {\n await CloudCmd[moduleName]();\n const func = CloudCmd[moduleName][funcName];\n func(...args);\n };\n this.refresh = async (options = {}) => {\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 === null || options === void 0 ? void 0 : options.noCurrent;\n await CloudCmd.changeDir(path, {\n isRefresh,\n history,\n panel,\n noCurrent,\n currentName\n });\n };\n\n /**\n * Функция загружает json-данные о Файловой Системе\n * через ajax-запрос.\n * @param path - каталог для чтения\n * @param options\n * { refresh, history } - необходимость обновить данные о каталоге\n * @param panel\n *\n */\n async function ajaxLoad(path, options = {}, panel) {\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)\n // that's OK, error handled by RESTful\n return;\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 * Функция строит файловую таблицу\n * @param data - данные о файлах\n * @param panelParam\n * @param options - history, noCurrent, showDotFiles\n */\n async function createFileTable(data, panelParam, options) {\n const {\n history,\n noCurrent,\n showDotFiles\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 while (i--) panel.removeChild(panel.lastChild);\n panel.innerHTML = buildFromJSON({\n sort: options.sort,\n order: options.order,\n data,\n id: panel.id,\n prefix,\n showDotFiles,\n template: {\n file,\n path,\n pathLink,\n link\n }\n });\n Listeners.setOnPanel(panel);\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 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.changeDir(path);\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\n}");
19
19
 
20
20
  /***/ },
21
21
 
@@ -48,7 +48,7 @@ eval("{\n\n/* global CloudCmd */\nconst tryToPromiseAll = __webpack_require__(/*
48
48
  (module, __unused_webpack_exports, __webpack_require__) {
49
49
 
50
50
  "use strict";
51
- eval("{\n\n/* global DOM */\n/* global CloudCmd */\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n atob,\n btoa\n} = __webpack_require__(/*! ../../common/base64 */ \"./common/base64.js\");\nconst {\n encode,\n decode\n} = __webpack_require__(/*! ../../common/entity */ \"./common/entity.js\");\nconst {\n getTitle,\n FS\n} = __webpack_require__(/*! ../../common/cloudfunc */ \"./common/cloudfunc.js\");\nlet Title;\nconst CURRENT_FILE = 'current-file';\nconst encodeNBSP = a => a === null || a === void 0 ? void 0 : a.replace('\\xa0', ' ');\nconst decodeNBSP = a => a === null || a === void 0 ? void 0 : a.replace(' ', '\\xa0');\nmodule.exports._CURRENT_FILE = CURRENT_FILE;\n/**\n * set name from current (or param) file\n *\n * @param name\n * @param current\n */\nmodule.exports.setCurrentName = (name, current) => {\n const Info = DOM.CurrentInfo;\n const {\n link\n } = Info;\n const {\n prefix\n } = CloudCmd;\n const dir = prefix + FS + Info.dirPath;\n const encoded = encode(name);\n link.title = encoded;\n link.href = dir + encoded;\n link.innerHTML = encoded;\n current.setAttribute('data-name', createNameAttribute(name));\n CloudCmd.emit('current-file', current);\n return link;\n};\n\n/**\n * get name from current (or param) file\n *\n * @param currentFile\n */\nmodule.exports.getCurrentName = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n if (!current) return '';\n return parseNameAttribute(current.getAttribute('data-name'));\n};\n\n/**\n * Generate a `data-name` attribute for the given filename\n * @param name The string name to encode\n */\nconst createNameAttribute = name => {\n const encoded = btoa(encodeURI(name));\n return `js-file-${encoded}`;\n};\n\n/**\n * Parse a `data-name` attribute string back into the original filename\n * @param attribute The string we wish to decode\n */\nconst parseNameAttribute = attribute => {\n attribute = attribute.replace('js-file-', '');\n return decodeNBSP(decodeURI(atob(attribute)));\n};\nmodule.exports._parseNameAttribute = parseNameAttribute;\nconst parseHrefAttribute = (prefix, attribute) => {\n attribute = attribute.replace(RegExp('^' + prefix + FS), '');\n return decode(decodeNBSP(attribute));\n};\nmodule.exports._parseHrefAttribute = parseHrefAttribute;\n/**\n * get current direcotory path\n */\nmodule.exports.getCurrentDirPath = (panel = DOM.getPanel()) => {\n const path = DOM.getByDataName('js-path', panel);\n return path.textContent;\n};\n\n/**\n * get link from current (or param) file\n *\n * @param currentFile - current file by default\n */\nmodule.exports.getCurrentPath = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const [element] = DOM.getByTag('a', current);\n const {\n prefix\n } = CloudCmd;\n return parseHrefAttribute(prefix, element.getAttribute('href'));\n};\n\n/**\n * get current direcotory name\n */\nmodule.exports.getCurrentDirName = () => {\n const href = DOM.getCurrentDirPath().replace(/\\/$/, '');\n const substr = href.substr(href, href.lastIndexOf('/'));\n return href.replace(`${substr}/`, '') || '/';\n};\n\n/**\n * get current direcotory path\n */\nmodule.exports.getParentDirPath = panel => {\n const path = DOM.getCurrentDirPath(panel);\n const dirName = DOM.getCurrentDirName() + '/';\n const index = path.lastIndexOf(dirName);\n if (path === '/') return path;\n return path.slice(0, index);\n};\n\n/**\n * get not current direcotory path\n */\nmodule.exports.getNotCurrentDirPath = () => {\n const panel = DOM.getPanel({\n active: false\n });\n return DOM.getCurrentDirPath(panel);\n};\n\n/**\n * unified way to get current file\n *\n * @currentFile\n */\nmodule.exports.getCurrentFile = () => {\n return DOM.getByClass(CURRENT_FILE);\n};\n\n/**\n * get current file by name\n */\nmodule.exports.getCurrentByName = (name, panel = DOM.CurrentInfo.panel) => {\n const dataName = 'js-file-' + btoa(encodeURI(encodeNBSP(name)));\n return DOM.getByDataName(dataName, panel);\n};\n\n/**\n * private function thet unset currentfile\n *\n * @currentFile\n */\nfunction unsetCurrentFile(currentFile) {\n const is = DOM.isCurrentFile(currentFile);\n if (!is) return;\n currentFile.classList.remove(CURRENT_FILE);\n}\n\n/**\n * unified way to set current file\n */\nmodule.exports.setCurrentFile = (currentFile, options) => {\n const o = options;\n const currentFileWas = DOM.getCurrentFile();\n if (!currentFile) return DOM;\n let pathWas = '';\n if (currentFileWas) {\n pathWas = DOM.getCurrentDirPath();\n unsetCurrentFile(currentFileWas);\n }\n currentFile.classList.add(CURRENT_FILE);\n const path = DOM.getCurrentDirPath();\n const name = CloudCmd.config('name');\n if (path !== pathWas) {\n DOM.setTitle(getTitle({\n name,\n path\n }));\n\n /* history could be present\n * but it should be false\n * to prevent default behavior\n */\n if (!o || o.history) {\n const historyPath = path === '/' ? path : FS + path;\n DOM.setHistory(historyPath, null, historyPath);\n }\n }\n\n /* scrolling to current file */\n const CENTER = true;\n DOM.scrollIntoViewIfNeeded(currentFile, CENTER);\n CloudCmd.emit('current-file', currentFile);\n CloudCmd.emit('current-path', path);\n CloudCmd.emit('current-name', DOM.getCurrentName(currentFile));\n return DOM;\n};\nthis.setCurrentByName = name => {\n const current = DOM.getCurrentByName(name);\n return DOM.setCurrentFile(current);\n};\n\n/*\n * set current file by position\n *\n * @param layer - element\n * @param - position {x, y}\n */\nmodule.exports.getCurrentByPosition = ({\n x,\n y\n}) => {\n const element = document.elementFromPoint(x, y);\n const getEl = el => {\n const {\n tagName\n } = el;\n const isChild = /A|SPAN|LI/.test(tagName);\n if (!isChild) return null;\n if (tagName === 'A') return el.parentElement.parentElement;\n if (tagName === 'SPAN') return el.parentElement;\n return el;\n };\n const el = getEl(element);\n if (el && el.tagName !== 'LI') return null;\n return el;\n};\n\n/**\n * current file check\n *\n * @param currentFile\n */\nmodule.exports.isCurrentFile = currentFile => {\n if (!currentFile) return false;\n return DOM.isContainClass(currentFile, CURRENT_FILE);\n};\n\n/**\n * set title or create title element\n *\n * @param name\n */\nmodule.exports.setTitle = name => {\n if (!Title) Title = DOM.getByTag('title')[0] || createElement('title', {\n innerHTML: name,\n parent: document.head\n });\n Title.textContent = name;\n return DOM;\n};\n\n/**\n * check is current file is a directory\n *\n * @param currentFile\n */\nmodule.exports.isCurrentIsDir = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const path = DOM.getCurrentPath(current);\n const fileType = DOM.getCurrentType(current);\n const isZip = /\\.zip$/.test(path);\n const isDir = /^directory(-link)?/.test(fileType);\n return isDir || isZip;\n};\nmodule.exports.getCurrentType = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const el = DOM.getByDataName('js-type', current);\n const type = el.className.split(' ').pop();\n return type;\n};\n\n//# sourceURL=file://cloudcmd/client/dom/current-file.js\n}");
51
+ eval("{\n\n/* global DOM */\n/* global CloudCmd */\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n atob,\n btoa\n} = __webpack_require__(/*! ../../common/base64 */ \"./common/base64.js\");\nconst {\n encode,\n decode\n} = __webpack_require__(/*! ../../common/entity */ \"./common/entity.js\");\nconst {\n getTitle,\n FS\n} = __webpack_require__(/*! ../../common/cloudfunc */ \"./common/cloudfunc.js\");\nlet Title;\nconst CURRENT_FILE = 'current-file';\nconst encodeNBSP = a => a === null || a === void 0 ? void 0 : a.replace('\\xa0', ' ');\nconst decodeNBSP = a => a === null || a === void 0 ? void 0 : a.replace(' ', '\\xa0');\nmodule.exports._CURRENT_FILE = CURRENT_FILE;\n/**\n * set name from current (or param) file\n *\n * @param name\n * @param current\n */\nmodule.exports.setCurrentName = (name, current) => {\n const Info = DOM.CurrentInfo;\n const {\n link\n } = Info;\n const {\n prefix\n } = CloudCmd;\n const dir = prefix + FS + Info.dirPath;\n const encoded = encode(name);\n link.title = encoded;\n link.href = dir + encoded;\n link.innerHTML = encoded;\n current.setAttribute('data-name', createNameAttribute(name));\n CloudCmd.emit('current-file', current);\n return link;\n};\n\n/**\n * get name from current (or param) file\n *\n * @param currentFile\n */\nmodule.exports.getCurrentName = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n if (!current) return '';\n return parseNameAttribute(current.getAttribute('data-name'));\n};\n\n/**\n * Generate a `data-name` attribute for the given filename\n * @param name The string name to encode\n */\nconst createNameAttribute = name => {\n const encoded = btoa(encodeURI(name));\n return `js-file-${encoded}`;\n};\n\n/**\n * Parse a `data-name` attribute string back into the original filename\n * @param attribute The string we wish to decode\n */\nconst parseNameAttribute = attribute => {\n attribute = attribute.replace('js-file-', '');\n return decodeNBSP(decodeURI(atob(attribute)));\n};\nmodule.exports._parseNameAttribute = parseNameAttribute;\nconst parseHrefAttribute = (prefix, attribute) => {\n attribute = attribute.replace(RegExp('^' + prefix + FS), '');\n return decode(decodeNBSP(attribute));\n};\nmodule.exports._parseHrefAttribute = parseHrefAttribute;\n/**\n * get current direcotory path\n */\nmodule.exports.getCurrentDirPath = (panel = DOM.getPanel()) => {\n const path = DOM.getByDataName('js-path', panel);\n return path.textContent;\n};\n\n/**\n * get link from current (or param) file\n *\n * @param currentFile - current file by default\n */\nmodule.exports.getCurrentPath = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const [element] = DOM.getByTag('a', current);\n const {\n prefix\n } = CloudCmd;\n return parseHrefAttribute(prefix, element.getAttribute('href'));\n};\n\n/**\n * get current direcotory name\n */\nmodule.exports.getCurrentDirName = () => {\n const href = DOM.getCurrentDirPath().replace(/\\/$/, '');\n const substr = href.substr(href, href.lastIndexOf('/'));\n return href.replace(`${substr}/`, '') || '/';\n};\n\n/**\n * get current direcotory path\n */\nmodule.exports.getParentDirPath = panel => {\n const path = DOM.getCurrentDirPath(panel);\n const dirName = DOM.getCurrentDirName() + '/';\n const index = path.lastIndexOf(dirName);\n if (path === '/') return path;\n return path.slice(0, index);\n};\n\n/**\n * get not current direcotory path\n */\nmodule.exports.getNotCurrentDirPath = () => {\n const panel = DOM.getPanel({\n active: false\n });\n return DOM.getCurrentDirPath(panel);\n};\n\n/**\n * unified way to get current file\n *\n * @currentFile\n */\nmodule.exports.getCurrentFile = () => {\n return DOM.getByClass(CURRENT_FILE);\n};\n\n/**\n * get current file by name\n */\nmodule.exports.getCurrentByName = (name, panel = DOM.CurrentInfo.panel) => {\n const dataName = 'js-file-' + btoa(encodeURI(encodeNBSP(name)));\n return DOM.getByDataName(dataName, panel);\n};\n\n/**\n * private function thet unset currentfile\n *\n * @currentFile\n */\nfunction unsetCurrentFile(currentFile) {\n const is = DOM.isCurrentFile(currentFile);\n if (!is) return;\n currentFile.classList.remove(CURRENT_FILE);\n}\n\n/**\n * unified way to set current file\n */\nmodule.exports.setCurrentFile = (currentFile, options) => {\n const o = options;\n const currentFileWas = DOM.getCurrentFile();\n if (!currentFile) return DOM;\n let pathWas = '';\n if (currentFileWas) {\n pathWas = DOM.getCurrentDirPath();\n unsetCurrentFile(currentFileWas);\n }\n currentFile.classList.add(CURRENT_FILE);\n const path = DOM.getCurrentDirPath();\n const name = CloudCmd.config('name');\n if (path !== pathWas) {\n DOM.setTitle(getTitle({\n name,\n path\n }));\n\n /* history could be present\n * but it should be false\n * to prevent default behavior\n */\n if (!o || o.history) {\n const historyPath = path === '/' ? path : FS + path;\n DOM.setHistory(historyPath, null, historyPath);\n }\n }\n\n /* scrolling to current file */\n const CENTER = true;\n DOM.scrollIntoViewIfNeeded(currentFile, CENTER);\n CloudCmd.emit('current-file', currentFile);\n CloudCmd.emit('current-path', path);\n CloudCmd.emit('current-name', DOM.getCurrentName(currentFile));\n return DOM;\n};\nthis.setCurrentByName = name => {\n const current = DOM.getCurrentByName(name);\n return DOM.setCurrentFile(current);\n};\n\n/*\n * set current file by position\n *\n * @param layer - element\n * @param - position {x, y}\n */\nmodule.exports.getCurrentByPosition = ({\n x,\n y\n}) => {\n const element = document.elementFromPoint(x, y);\n const getEl = el => {\n const {\n tagName\n } = el;\n const isChild = /A|SPAN|LI/.test(tagName);\n if (!isChild) return null;\n if (tagName === 'A') return el.parentElement.parentElement;\n if (tagName === 'SPAN') return el.parentElement;\n return el;\n };\n const el = getEl(element);\n if (el && el.tagName !== 'LI') return null;\n return el;\n};\n\n/**\n * current file check\n *\n * @param currentFile\n */\nmodule.exports.isCurrentFile = currentFile => {\n if (!currentFile) return false;\n return DOM.isContainClass(currentFile, CURRENT_FILE);\n};\n\n/**\n * set title or create title element\n *\n * @param name\n */\nmodule.exports.setTitle = name => {\n if (!Title) Title = DOM.getByTag('title')[0] || createElement('title', {\n innerHTML: name,\n parent: document.head\n });\n Title.textContent = name;\n return DOM;\n};\n\n/**\n * check is current file is a directory\n *\n * @param currentFile\n */\nmodule.exports.isCurrentIsDir = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const path = DOM.getCurrentPath(current);\n const fileType = DOM.getCurrentType(current);\n const isZip = path.endsWith('.zip');\n const isDir = /^directory(-link)?/.test(fileType);\n return isDir || isZip;\n};\nmodule.exports.getCurrentType = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const el = DOM.getByDataName('js-type', current);\n const type = el.className.split(' ').pop();\n return type;\n};\n\n//# sourceURL=file://cloudcmd/client/dom/current-file.js\n}");
52
52
 
53
53
  /***/ },
54
54
 
@@ -59,7 +59,7 @@ eval("{\n\n/* global DOM */\n/* global CloudCmd */\nconst createElement = __webp
59
59
  (module, __unused_webpack_exports, __webpack_require__) {
60
60
 
61
61
  "use strict";
62
- eval("{\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n alert,\n prompt,\n confirm,\n progress\n} = __webpack_require__(/*! smalltalk */ \"./node_modules/smalltalk/lib/smalltalk.js\");\nconst title = 'Cloud Commander';\nmodule.exports.alert = (...a) => alert(title, ...a, {\n cancel: false\n});\nmodule.exports.prompt = (...a) => tryToCatch(prompt, title, ...a);\nmodule.exports.confirm = (...a) => tryToCatch(confirm, title, ...a);\nmodule.exports.progress = (...a) => progress(title, ...a);\nmodule.exports.alert.noFiles = () => {\n return alert(title, 'No files selected!', {\n cancel: false\n });\n};\n\n//# sourceURL=file://cloudcmd/client/dom/dialog.js\n}");
62
+ eval("{\n\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst {\n alert,\n prompt,\n confirm,\n progress\n} = __webpack_require__(/*! smalltalk */ \"./node_modules/smalltalk/lib/smalltalk.js\");\nconst title = 'Cloud Commander';\nmodule.exports.alert = (...a) => alert(title, ...a, {\n cancel: false\n});\nmodule.exports.prompt = (...a) => tryToCatch(prompt, title, ...a);\nmodule.exports.confirm = (...a) => tryToCatch(confirm, title, ...a);\nmodule.exports.progress = (...a) => progress(title, ...a);\nmodule.exports.alert.noFiles = () => {\n return alert(title, 'No files selected!', {\n cancel: false\n });\n};\n\n//# sourceURL=file://cloudcmd/client/dom/dialog.js\n}");
63
63
 
64
64
  /***/ },
65
65
 
@@ -136,7 +136,7 @@ eval("{/* global DOM */\n\n\n\nconst createElement = __webpack_require__(/*! @cl
136
136
  (module, __unused_webpack_exports, __webpack_require__) {
137
137
 
138
138
  "use strict";
139
- eval("{\n\n/* global CloudCmd */\nconst Util = __webpack_require__(/*! ../../common/util */ \"./common/util.js\");\nconst Images = __webpack_require__(/*! ./images */ \"./client/dom/images.js\");\nconst RESTful = __webpack_require__(/*! ./rest */ \"./client/dom/rest.js\");\nconst Storage = __webpack_require__(/*! ./storage */ \"./client/dom/storage.js\");\nconst renameCurrent = __webpack_require__(/*! ./operations/rename-current */ \"./client/dom/operations/rename-current.js\");\nconst CurrentFile = __webpack_require__(/*! ./current-file */ \"./client/dom/current-file.js\");\nconst DOMTree = __webpack_require__(/*! ./dom-tree */ \"./client/dom/dom-tree.js\");\nconst Cmd = module.exports;\nconst DOM = {\n ...DOMTree,\n ...CurrentFile,\n ...Cmd\n};\nconst CurrentInfo = {};\nDOM.Images = Images;\nDOM.load = __webpack_require__(/*! ./load */ \"./client/dom/load.js\");\nDOM.Files = __webpack_require__(/*! ./files */ \"./client/dom/files.js\");\nDOM.RESTful = RESTful;\nDOM.IO = __webpack_require__(/*! ./io */ \"./client/dom/io/index.js\");\nDOM.Storage = Storage;\nDOM.Dialog = __webpack_require__(/*! ./dialog */ \"./client/dom/dialog.js\");\nDOM.CurrentInfo = CurrentInfo;\nmodule.exports = DOM;\nDOM.uploadDirectory = __webpack_require__(/*! ./directory */ \"./client/dom/directory.js\");\nDOM.Buffer = __webpack_require__(/*! ./buffer */ \"./client/dom/buffer.js\");\nDOM.Events = __webpack_require__(/*! ./events */ \"./client/dom/events/index.js\");\nconst loadRemote = __webpack_require__(/*! ./load-remote */ \"./client/dom/load-remote.js\");\nconst selectByPattern = __webpack_require__(/*! ./select-by-pattern */ \"./client/dom/select-by-pattern.js\");\nconst isString = a => typeof a === 'string';\nconst SELECTED_FILE = 'selected-file';\nconst TabPanel = {\n 'js-left': null,\n 'js-right': null\n};\nmodule.exports.loadRemote = (name, options, callback) => {\n loadRemote(name, options, callback);\n return DOM;\n};\nmodule.exports.loadSocket = callback => {\n DOM.loadRemote('socket', {\n name: 'io'\n }, callback);\n return DOM;\n};\n\n/**\n * create new folder\n *\n */\nmodule.exports.promptNewDir = async function () {\n await promptNew('directory');\n};\n\n/**\n * create new file\n *\n * @typeName\n * @type\n */\nmodule.exports.promptNewFile = async () => {\n await promptNew('file');\n};\nasync function promptNew(typeName) {\n const {\n Dialog\n } = DOM;\n const dir = DOM.getCurrentDirPath();\n const msg = `New ${typeName}` || 'File';\n const getName = () => {\n const name = DOM.getCurrentName();\n if (name === '..') return '';\n return name;\n };\n const name = getName();\n const [cancel, currentName] = await Dialog.prompt(msg, name);\n if (cancel) return;\n const path = `${dir}${currentName}`;\n if (typeName === 'directory') await RESTful.createDirectory(path);else await RESTful.write(path);\n await CloudCmd.refresh({\n currentName\n });\n}\n\n/**\n * get current direcotory name\n */\nmodule.exports.getCurrentDirName = () => {\n const href = DOM.getCurrentDirPath().replace(/\\/$/, '');\n const substr = href.substr(href, href.lastIndexOf('/'));\n return href.replace(`${substr}/`, '') || '/';\n};\n\n/**\n * get current direcotory path\n */\nmodule.exports.getParentDirPath = panel => {\n const path = DOM.getCurrentDirPath(panel);\n const dirName = DOM.getCurrentDirName() + '/';\n const index = path.lastIndexOf(dirName);\n if (path !== '/') return path.slice(0, index);\n return path;\n};\n\n/**\n * get not current direcotory path\n */\nmodule.exports.getNotCurrentDirPath = () => {\n const panel = DOM.getPanel({\n active: false\n });\n return DOM.getCurrentDirPath(panel);\n};\n\n/**\n * unified way to get selected files\n *\n * @currentFile\n */\nmodule.exports.getSelectedFiles = () => {\n const panel = DOM.getPanel();\n const selected = DOM.getByClassAll(SELECTED_FILE, panel);\n return Array.from(selected);\n};\n\n/*\n * unselect all files\n */\nmodule.exports.unselectFiles = files => {\n files = files || DOM.getSelectedFiles();\n Array.from(files).forEach(DOM.toggleSelectedFile);\n};\n\n/**\n * get all selected files or current when none selected\n *\n * @currentFile\n */\nmodule.exports.getActiveFiles = () => {\n const current = DOM.getCurrentFile();\n const files = DOM.getSelectedFiles();\n const name = DOM.getCurrentName(current);\n if (!files.length && name !== '..') return [current];\n return files;\n};\nmodule.exports.getCurrentDate = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n return DOM.getByDataName('js-date', current).textContent;\n};\n\n/**\n * get size\n * @currentFile\n */\nmodule.exports.getCurrentSize = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n\n /* если это папка - возвращаем слово dir вместо размера*/\n const size = DOM.getByDataName('js-size', current).textContent.replace(/^<|>$/g, '');\n return size;\n};\n\n/**\n * get size\n * @currentFile\n */\nmodule.exports.loadCurrentSize = async currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const query = '?size';\n const link = DOM.getCurrentPath(current);\n Images.show.load();\n if (name === '..') return;\n const [, size] = await RESTful.read(link + query);\n DOM.setCurrentSize(size, current);\n Images.hide();\n return current;\n};\n\n/**\n * load hash\n * @callback\n * @currentFile\n */\nmodule.exports.loadCurrentHash = async currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const query = '?hash';\n const link = DOM.getCurrentPath(current);\n const [, data] = await RESTful.read(link + query);\n return data;\n};\n\n/**\n * set size\n * @currentFile\n */\nmodule.exports.setCurrentSize = (size, currentFile) => {\n const current = currentFile || DOM.getCurrentFile();\n const sizeElement = DOM.getByDataName('js-size', current);\n sizeElement.textContent = size;\n};\n\n/**\n * @currentFile\n */\nmodule.exports.getCurrentMode = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const mode = DOM.getByDataName('js-mode', current);\n return mode.textContent;\n};\n\n/**\n * @currentFile\n */\nmodule.exports.getCurrentOwner = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const owner = DOM.getByDataName('js-owner', current);\n return owner.textContent;\n};\n\n/**\n * unified way to get current file content\n *\n * @param currentFile\n */\nmodule.exports.getCurrentData = async currentFile => {\n const {\n Dialog\n } = DOM;\n const Info = DOM.CurrentInfo;\n const current = currentFile || DOM.getCurrentFile();\n const path = DOM.getCurrentPath(current);\n const isDir = DOM.isCurrentIsDir(current);\n if (Info.name === '..') {\n Dialog.alert.noFiles();\n return [Error('No Files')];\n }\n if (isDir) return await RESTful.read(path);\n const [hashNew, hash] = await DOM.checkStorageHash(path);\n if (!hashNew) return [Error(`Can't get hash of a file`)];\n if (hash === hashNew) return [null, await Storage.get(`${path}-data`)];\n const [e, data] = await RESTful.read(path);\n if (e) return [e, null];\n const ONE_MEGABYTE = 1024 ** 2 * 1024;\n const {\n length\n } = data;\n if (hash && length < ONE_MEGABYTE) await DOM.saveDataToStorage(path, data, hashNew);\n return [null, data];\n};\n\n/**\n * unified way to get RefreshButton\n */\nmodule.exports.getRefreshButton = (panel = DOM.getPanel()) => {\n return DOM.getByDataName('js-refresh', panel);\n};\n\n/**\n * select current file\n * @param currentFile\n */\nmodule.exports.selectFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n current.classList.add(SELECTED_FILE);\n return Cmd;\n};\nmodule.exports.unselectFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n current.classList.remove(SELECTED_FILE);\n return Cmd;\n};\nmodule.exports.toggleSelectedFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const name = DOM.getCurrentName(current);\n if (name === '..') return Cmd;\n current.classList.toggle(SELECTED_FILE);\n return Cmd;\n};\nmodule.exports.toggleAllSelectedFiles = () => {\n DOM.getAllFiles().map(DOM.toggleSelectedFile);\n return Cmd;\n};\nmodule.exports.selectAllFiles = () => {\n DOM.getAllFiles().map(DOM.selectFile);\n return Cmd;\n};\nmodule.exports.getAllFiles = () => {\n const panel = DOM.getPanel();\n const files = DOM.getFiles(panel);\n const name = DOM.getCurrentName(files[0]);\n const from = a => a === '..' ? 1 : 0;\n const i = from(name);\n return Array.from(files).slice(i);\n};\n\n/**\n * open dialog with expand selection\n */\nmodule.exports.expandSelection = () => {\n const msg = 'expand';\n const {\n files\n } = CurrentInfo;\n selectByPattern(msg, files);\n};\n\n/**\n * open dialog with shrink selection\n */\nmodule.exports.shrinkSelection = () => {\n const msg = 'shrink';\n const {\n files\n } = CurrentInfo;\n selectByPattern(msg, files);\n};\n\n/**\n * setting history wrapper\n */\nmodule.exports.setHistory = (data, title, url) => {\n const ret = window.history;\n const {\n prefix\n } = CloudCmd;\n url = prefix + url;\n if (ret) history.pushState(data, title, url);\n return ret;\n};\n\n/**\n * selected file check\n *\n * @param currentFile\n */\nmodule.exports.isSelected = selected => {\n if (!selected) return false;\n return DOM.isContainClass(selected, SELECTED_FILE);\n};\n\n/**\n * get link from current (or param) file\n *\n * @param currentFile - current file by default\n */\nmodule.exports.getCurrentLink = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const link = DOM.getByTag('a', current);\n return link[0];\n};\nmodule.exports.getFilenames = files => {\n if (!files) throw Error('AllFiles could not be empty');\n const first = files[0] || DOM.getCurrentFile();\n const name = DOM.getCurrentName(first);\n const allFiles = Array.from(files);\n if (name === '..') allFiles.shift();\n const names = allFiles.map(current => {\n return DOM.getCurrentName(current);\n });\n return names;\n};\n\n/**\n * check storage hash\n */\nmodule.exports.checkStorageHash = async name => {\n const nameHash = `${name}-hash`;\n if (!isString(name)) throw Error('name should be a string!');\n const [loadHash, storeHash] = await Promise.all([DOM.loadCurrentHash(), Storage.get(nameHash)]);\n return [loadHash, storeHash];\n};\n\n/**\n * save data to storage\n *\n * @param name\n * @param data\n * @param hash\n * @param callback\n */\nmodule.exports.saveDataToStorage = async (name, data, hash) => {\n const isDir = DOM.isCurrentIsDir();\n if (isDir) return;\n hash = hash || (await DOM.loadCurrentHash());\n const nameHash = `${name}-hash`;\n const nameData = `${name}-data`;\n await Storage.set(nameHash, hash);\n await Storage.set(nameData, data);\n return hash;\n};\nmodule.exports.getFM = () => DOM.getPanel().parentElement;\nmodule.exports.getPanelPosition = panel => {\n panel = panel || DOM.getPanel();\n return panel.dataset.name.replace('js-', '');\n};\nmodule.exports.getCSSVar = (name, {\n body = document.body\n} = {}) => {\n const bodyStyle = getComputedStyle(body);\n return bodyStyle.getPropertyValue(`--${name}`);\n};\n\n/** function getting panel active, or passive\n * @param options = {active: true}\n */\nmodule.exports.getPanel = options => {\n let files;\n let panel;\n let isLeft;\n let dataName = 'js-';\n const current = DOM.getCurrentFile();\n if (!current) {\n panel = DOM.getByDataName('js-left');\n } else {\n files = current.parentElement;\n panel = files.parentElement;\n isLeft = panel.getAttribute('data-name') === 'js-left';\n }\n\n /* if {active : false} getting passive panel */\n if (options && !options.active) {\n dataName += isLeft ? 'right' : 'left';\n panel = DOM.getByDataName(dataName);\n }\n\n /* if two panels showed\n * then always work with passive\n * panel\n */\n if (window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH) panel = DOM.getByDataName('js-left');\n if (!panel) throw Error('can not find Active Panel!');\n return panel;\n};\nmodule.exports.getFiles = element => {\n const files = DOM.getByDataName('js-files', element);\n return files.children || [];\n};\n\n/**\n * shows panel right or left (or active)\n */\nmodule.exports.showPanel = active => {\n const panel = DOM.getPanel({\n active\n });\n if (!panel) return false;\n DOM.show(panel);\n return true;\n};\n\n/**\n * hides panel right or left (or active)\n */\nmodule.exports.hidePanel = active => {\n const panel = DOM.getPanel({\n active\n });\n if (!panel) return false;\n return DOM.hide(panel);\n};\n\n/**\n * remove child of element\n * @param pChild\n * @param element\n */\nmodule.exports.remove = (child, element) => {\n const parent = element || document.body;\n parent.removeChild(child);\n return DOM;\n};\n\n/**\n * remove current file from file table\n * @param current\n *\n */\nmodule.exports.deleteCurrent = current => {\n if (!current) DOM.getCurrentFile();\n const parent = current === null || current === void 0 ? void 0 : current.parentElement;\n const name = DOM.getCurrentName(current);\n if (current && name !== '..') {\n const next = current.nextSibling;\n const prev = current.previousSibling;\n DOM.setCurrentFile(next || prev);\n parent.removeChild(current);\n }\n};\n\n/**\n * remove selected files from file table\n * @Selected\n */\nmodule.exports.deleteSelected = selected => {\n selected = selected || DOM.getSelectedFiles();\n if (!selected) return;\n selected.map(DOM.deleteCurrent);\n};\n\n/**\n * rename current file\n *\n * @currentFile\n */\nmodule.exports.renameCurrent = renameCurrent;\n/**\n * unified way to scrollIntoViewIfNeeded\n * (native suporte by webkit only)\n * @param element\n * @param center - to scroll as small as possible param should be false\n */\nmodule.exports.scrollIntoViewIfNeeded = (element, center = false) => {\n if (!element || !element.scrollIntoViewIfNeeded) return;\n element.scrollIntoViewIfNeeded(center);\n};\n\n/* scroll on one page */\nmodule.exports.scrollByPages = (element, pPages) => {\n const ret = (element === null || element === void 0 ? void 0 : element.scrollByPages) && pPages;\n if (ret) element.scrollByPages(pPages);\n return ret;\n};\nmodule.exports.changePanel = () => {\n const Info = CurrentInfo;\n let panel = DOM.getPanel();\n CloudCmd.emit('passive-dir', Info.dirPath);\n const panelPassive = DOM.getPanel({\n active: false\n });\n let name = DOM.getCurrentName();\n const filesPassive = DOM.getFiles(panelPassive);\n let dataName = panel.getAttribute('data-name');\n TabPanel[dataName] = name;\n panel = panelPassive;\n dataName = panel.getAttribute('data-name');\n name = TabPanel[dataName];\n let files;\n let current;\n if (name) {\n current = DOM.getCurrentByName(name, panel);\n if (current) files = current.parentElement;\n }\n if (!files || !files.parentElement) {\n current = DOM.getCurrentByName(name, panel);\n if (!current) [current] = filesPassive;\n }\n DOM.setCurrentFile(current, {\n history: true\n });\n CloudCmd.emit('active-dir', Info.dirPath);\n return DOM;\n};\nmodule.exports.getPackerExt = type => {\n if (type === 'zip') return '.zip';\n return '.tar.gz';\n};\nmodule.exports.goToDirectory = async () => {\n const msg = 'Go to directory:';\n const {\n Dialog\n } = DOM;\n const {\n dirPath\n } = CurrentInfo;\n const [cancel, path = dirPath] = await Dialog.prompt(msg, dirPath);\n if (cancel) return;\n await CloudCmd.changeDir(path);\n};\nmodule.exports.duplicatePanel = async () => {\n const Info = CurrentInfo;\n const {\n isDir\n } = Info;\n const panel = Info.panelPassive;\n const noCurrent = !Info.isOnePanel;\n const getPath = isDir => {\n if (isDir) return Info.path;\n return Info.dirPath;\n };\n const path = getPath(isDir);\n await CloudCmd.changeDir(path, {\n panel,\n noCurrent\n });\n};\nmodule.exports.swapPanels = async () => {\n const Info = CurrentInfo;\n const {\n panel,\n files,\n element,\n panelPassive\n } = Info;\n const path = DOM.getCurrentDirPath();\n const dirPathPassive = DOM.getNotCurrentDirPath();\n let currentIndex = files.indexOf(element);\n await CloudCmd.changeDir(path, {\n panel: panelPassive,\n noCurrent: true\n });\n await CloudCmd.changeDir(dirPathPassive, {\n panel\n });\n const length = Info.files.length - 1;\n if (currentIndex > length) currentIndex = length;\n const el = Info.files[currentIndex];\n DOM.setCurrentFile(el);\n};\nmodule.exports.CurrentInfo = CurrentInfo;\nmodule.exports.updateCurrentInfo = currentFile => {\n const info = DOM.CurrentInfo;\n const current = currentFile || DOM.getCurrentFile();\n const files = current.parentElement;\n const panelPassive = DOM.getPanel({\n active: false\n });\n const filesPassive = DOM.getFiles(panelPassive);\n const name = DOM.getCurrentName(current);\n info.dir = DOM.getCurrentDirName();\n info.dirPath = DOM.getCurrentDirPath();\n info.parentDirPath = DOM.getParentDirPath();\n info.element = current;\n info.ext = Util.getExt(name);\n info.files = Array.from(files.children);\n info.filesPassive = Array.from(filesPassive);\n info.first = files.firstChild;\n info.getData = DOM.getCurrentData;\n info.last = files.lastChild;\n info.link = DOM.getCurrentLink(current);\n info.mode = DOM.getCurrentMode(current);\n info.name = name;\n info.path = DOM.getCurrentPath(current);\n info.panel = files.parentElement || DOM.getPanel();\n info.panelPassive = panelPassive;\n info.size = DOM.getCurrentSize(current);\n info.isDir = DOM.isCurrentIsDir();\n info.isSelected = DOM.isSelected(current);\n info.panelPosition = DOM.getPanel().dataset.name.replace('js-', '');\n info.isOnePanel = info.panel.getAttribute('data-name') === info.panelPassive.getAttribute('data-name');\n};\n\n//# sourceURL=file://cloudcmd/client/dom/index.js\n}");
139
+ eval("{\n\n/* global CloudCmd */\nconst Util = __webpack_require__(/*! ../../common/util */ \"./common/util.js\");\nconst Images = __webpack_require__(/*! ./images */ \"./client/dom/images.js\");\nconst RESTful = __webpack_require__(/*! ./rest */ \"./client/dom/rest.js\");\nconst Storage = __webpack_require__(/*! ./storage */ \"./client/dom/storage.js\");\nconst renameCurrent = __webpack_require__(/*! ./operations/rename-current */ \"./client/dom/operations/rename-current.js\");\nconst CurrentFile = __webpack_require__(/*! ./current-file */ \"./client/dom/current-file.js\");\nconst DOMTree = __webpack_require__(/*! ./dom-tree */ \"./client/dom/dom-tree.js\");\nconst Cmd = module.exports;\nconst DOM = {\n ...DOMTree,\n ...CurrentFile,\n ...Cmd\n};\nconst CurrentInfo = {};\nDOM.Images = Images;\nDOM.load = __webpack_require__(/*! ./load */ \"./client/dom/load.js\");\nDOM.Files = __webpack_require__(/*! ./files */ \"./client/dom/files.js\");\nDOM.RESTful = RESTful;\nDOM.IO = __webpack_require__(/*! ./io */ \"./client/dom/io/index.js\");\nDOM.Storage = Storage;\nDOM.Dialog = __webpack_require__(/*! ./dialog */ \"./client/dom/dialog.js\");\nDOM.CurrentInfo = CurrentInfo;\nmodule.exports = DOM;\nDOM.uploadDirectory = __webpack_require__(/*! ./directory */ \"./client/dom/directory.js\");\nDOM.Buffer = __webpack_require__(/*! ./buffer */ \"./client/dom/buffer.js\");\nDOM.Events = __webpack_require__(/*! ./events */ \"./client/dom/events/index.js\");\nconst loadRemote = __webpack_require__(/*! ./load-remote */ \"./client/dom/load-remote.js\");\nconst selectByPattern = __webpack_require__(/*! ./select-by-pattern */ \"./client/dom/select-by-pattern.js\");\nconst isString = a => typeof a === 'string';\nconst SELECTED_FILE = 'selected-file';\nconst TabPanel = {\n 'js-left': null,\n 'js-right': null\n};\nmodule.exports.loadRemote = (name, options, callback) => {\n loadRemote(name, options, callback);\n return DOM;\n};\nmodule.exports.loadSocket = callback => {\n DOM.loadRemote('socket', {\n name: 'io'\n }, callback);\n return DOM;\n};\n\n/**\n * create new folder\n *\n */\nmodule.exports.promptNewDir = async function () {\n await promptNew('directory');\n};\n\n/**\n * create new file\n *\n * @typeName\n * @type\n */\nmodule.exports.promptNewFile = async () => {\n await promptNew('file');\n};\nasync function promptNew(typeName) {\n const {\n Dialog\n } = DOM;\n const dir = DOM.getCurrentDirPath();\n const msg = `New ${typeName}` || 'File';\n const getName = () => {\n const name = DOM.getCurrentName();\n if (name === '..') return '';\n return name;\n };\n const name = getName();\n const [cancel, currentName] = await Dialog.prompt(msg, name);\n if (cancel) return;\n const path = `${dir}${currentName}`;\n if (typeName === 'directory') await RESTful.createDirectory(path);else await RESTful.write(path);\n await CloudCmd.refresh({\n currentName\n });\n}\n\n/**\n * get current direcotory name\n */\nmodule.exports.getCurrentDirName = () => {\n const href = DOM.getCurrentDirPath().replace(/\\/$/, '');\n const substr = href.substr(href, href.lastIndexOf('/'));\n return href.replace(`${substr}/`, '') || '/';\n};\n\n/**\n * get current direcotory path\n */\nmodule.exports.getParentDirPath = panel => {\n const path = DOM.getCurrentDirPath(panel);\n const dirName = DOM.getCurrentDirName() + '/';\n const index = path.lastIndexOf(dirName);\n if (path !== '/') return path.slice(0, index);\n return path;\n};\n\n/**\n * get not current direcotory path\n */\nmodule.exports.getNotCurrentDirPath = () => {\n const panel = DOM.getPanel({\n active: false\n });\n return DOM.getCurrentDirPath(panel);\n};\n\n/**\n * unified way to get selected files\n *\n * @currentFile\n */\nmodule.exports.getSelectedFiles = () => {\n const panel = DOM.getPanel();\n const selected = DOM.getByClassAll(SELECTED_FILE, panel);\n return Array.from(selected);\n};\n\n/*\n * unselect all files\n */\nmodule.exports.unselectFiles = files => {\n files = files || DOM.getSelectedFiles();\n Array.from(files).forEach(DOM.toggleSelectedFile);\n};\n\n/**\n * get all selected files or current when none selected\n *\n * @currentFile\n */\nmodule.exports.getActiveFiles = () => {\n const current = DOM.getCurrentFile();\n const files = DOM.getSelectedFiles();\n const name = DOM.getCurrentName(current);\n if (!files.length && name !== '..') return [current];\n return files;\n};\nmodule.exports.getCurrentDate = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n return DOM.getByDataName('js-date', current).textContent;\n};\n\n/**\n * get size\n * @currentFile\n */\nmodule.exports.getCurrentSize = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n\n /* если это папка - возвращаем слово dir вместо размера*/\n const size = DOM.getByDataName('js-size', current).textContent.replace(/^<|>$/g, '');\n return size;\n};\n\n/**\n * get size\n * @currentFile\n */\nmodule.exports.loadCurrentSize = async currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const query = '?size';\n const link = DOM.getCurrentPath(current);\n Images.show.load();\n if (name === '..') return;\n const [, size] = await RESTful.read(link + query);\n DOM.setCurrentSize(size, current);\n Images.hide();\n return current;\n};\n\n/**\n * load hash\n * @callback\n * @currentFile\n */\nmodule.exports.loadCurrentHash = async currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const query = '?hash';\n const link = DOM.getCurrentPath(current);\n const [, data] = await RESTful.read(link + query);\n return data;\n};\n\n/**\n * set size\n * @currentFile\n */\nmodule.exports.setCurrentSize = (size, currentFile) => {\n const current = currentFile || DOM.getCurrentFile();\n const sizeElement = DOM.getByDataName('js-size', current);\n sizeElement.textContent = size;\n};\n\n/**\n * @currentFile\n */\nmodule.exports.getCurrentMode = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const mode = DOM.getByDataName('js-mode', current);\n return mode.textContent;\n};\n\n/**\n * @currentFile\n */\nmodule.exports.getCurrentOwner = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const owner = DOM.getByDataName('js-owner', current);\n return owner.textContent;\n};\n\n/**\n * unified way to get current file content\n *\n * @param currentFile\n */\nmodule.exports.getCurrentData = async currentFile => {\n const {\n Dialog\n } = DOM;\n const Info = DOM.CurrentInfo;\n const current = currentFile || DOM.getCurrentFile();\n const path = DOM.getCurrentPath(current);\n const isDir = DOM.isCurrentIsDir(current);\n if (Info.name === '..') {\n Dialog.alert.noFiles();\n return [Error('No Files')];\n }\n if (isDir) return await RESTful.read(path);\n const [hashNew, hash] = await DOM.checkStorageHash(path);\n if (!hashNew) return [Error(`Can't get hash of a file`)];\n if (hash === hashNew) return [null, await Storage.get(`${path}-data`)];\n const [e, data] = await RESTful.read(path);\n if (e) return [e, null];\n const ONE_MEGABYTE = 1024 ** 2 * 1024;\n const {\n length\n } = data;\n if (hash && length < ONE_MEGABYTE) await DOM.saveDataToStorage(path, data, hashNew);\n return [null, data];\n};\n\n/**\n * unified way to get RefreshButton\n */\nmodule.exports.getRefreshButton = (panel = DOM.getPanel()) => {\n return DOM.getByDataName('js-refresh', panel);\n};\n\n/**\n * select current file\n * @param currentFile\n */\nmodule.exports.selectFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n current.classList.add(SELECTED_FILE);\n return Cmd;\n};\nmodule.exports.unselectFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n current.classList.remove(SELECTED_FILE);\n return Cmd;\n};\nmodule.exports.toggleSelectedFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const name = DOM.getCurrentName(current);\n if (name === '..') return Cmd;\n current.classList.toggle(SELECTED_FILE);\n return Cmd;\n};\nmodule.exports.toggleAllSelectedFiles = () => {\n DOM.getAllFiles().map(DOM.toggleSelectedFile);\n return Cmd;\n};\nmodule.exports.selectAllFiles = () => {\n DOM.getAllFiles().map(DOM.selectFile);\n return Cmd;\n};\nmodule.exports.getAllFiles = () => {\n const panel = DOM.getPanel();\n const files = DOM.getFiles(panel);\n const name = DOM.getCurrentName(files[0]);\n const from = a => a === '..' ? 1 : 0;\n const i = from(name);\n return Array.from(files).slice(i);\n};\n\n/**\n * open dialog with expand selection\n */\nmodule.exports.expandSelection = () => {\n const msg = 'expand';\n const {\n files\n } = CurrentInfo;\n selectByPattern(msg, files);\n};\n\n/**\n * open dialog with shrink selection\n */\nmodule.exports.shrinkSelection = () => {\n const msg = 'shrink';\n const {\n files\n } = CurrentInfo;\n selectByPattern(msg, files);\n};\n\n/**\n * setting history wrapper\n */\nmodule.exports.setHistory = (data, title, url) => {\n const ret = window.history;\n const {\n prefix\n } = CloudCmd;\n url = prefix + url;\n if (ret) history.pushState(data, title, url);\n return ret;\n};\n\n/**\n * selected file check\n *\n * @param currentFile\n */\nmodule.exports.isSelected = selected => {\n if (!selected) return false;\n return DOM.isContainClass(selected, SELECTED_FILE);\n};\n\n/**\n * get link from current (or param) file\n *\n * @param currentFile - current file by default\n */\nmodule.exports.getCurrentLink = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const link = DOM.getByTag('a', current);\n return link[0];\n};\nmodule.exports.getFilenames = files => {\n if (!files) throw Error('AllFiles could not be empty');\n const first = files[0] || DOM.getCurrentFile();\n const name = DOM.getCurrentName(first);\n const allFiles = Array.from(files);\n if (name === '..') allFiles.shift();\n const names = allFiles.map(current => {\n return DOM.getCurrentName(current);\n });\n return names;\n};\n\n/**\n * check storage hash\n */\nmodule.exports.checkStorageHash = async name => {\n const nameHash = `${name}-hash`;\n if (!isString(name)) throw Error('name should be a string!');\n const [loadHash, storeHash] = await Promise.all([DOM.loadCurrentHash(), Storage.get(nameHash)]);\n return [loadHash, storeHash];\n};\n\n/**\n * save data to storage\n *\n * @param name\n * @param data\n * @param hash\n * @param callback\n */\nmodule.exports.saveDataToStorage = async (name, data, hash) => {\n const isDir = DOM.isCurrentIsDir();\n if (isDir) return;\n hash = hash || (await DOM.loadCurrentHash());\n const nameHash = `${name}-hash`;\n const nameData = `${name}-data`;\n await Storage.set(nameHash, hash);\n await Storage.set(nameData, data);\n return hash;\n};\nmodule.exports.getFM = () => DOM.getPanel().parentElement;\nmodule.exports.getPanelPosition = panel => {\n panel = panel || DOM.getPanel();\n return panel.dataset.name.replace('js-', '');\n};\nmodule.exports.getCSSVar = (name, {\n body = document.body\n} = {}) => {\n const bodyStyle = getComputedStyle(body);\n return bodyStyle.getPropertyValue(`--${name}`);\n};\n\n/** function getting panel active, or passive\n * @param options = {active: true}\n */\nmodule.exports.getPanel = options => {\n let files;\n let panel;\n let isLeft;\n let dataName = 'js-';\n const current = DOM.getCurrentFile();\n if (!current) {\n panel = DOM.getByDataName('js-left');\n } else {\n files = current.parentElement;\n panel = files.parentElement;\n isLeft = panel.getAttribute('data-name') === 'js-left';\n }\n\n /* if {active : false} getting passive panel */\n if (options && !options.active) {\n dataName += isLeft ? 'right' : 'left';\n panel = DOM.getByDataName(dataName);\n }\n\n /* if two panels showed\n * then always work with passive\n * panel\n */\n if (window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH) panel = DOM.getByDataName('js-left');\n if (!panel) throw Error('can not find Active Panel!');\n return panel;\n};\nmodule.exports.getFiles = element => {\n const files = DOM.getByDataName('js-files', element);\n return files.children || [];\n};\n\n/**\n * shows panel right or left (or active)\n */\nmodule.exports.showPanel = active => {\n const panel = DOM.getPanel({\n active\n });\n if (!panel) return false;\n DOM.show(panel);\n return true;\n};\n\n/**\n * hides panel right or left (or active)\n */\nmodule.exports.hidePanel = active => {\n const panel = DOM.getPanel({\n active\n });\n if (!panel) return false;\n return DOM.hide(panel);\n};\n\n/**\n * remove child of element\n * @param pChild\n * @param element\n */\nmodule.exports.remove = (child, element) => {\n const parent = element || document.body;\n parent.removeChild(child);\n return DOM;\n};\n\n/**\n * remove current file from file table\n * @param current\n *\n */\nmodule.exports.deleteCurrent = current => {\n if (!current) DOM.getCurrentFile();\n const parent = current === null || current === void 0 ? void 0 : current.parentElement;\n const name = DOM.getCurrentName(current);\n if (current && name !== '..') {\n const next = current.nextSibling;\n const prev = current.previousSibling;\n DOM.setCurrentFile(next || prev);\n parent.removeChild(current);\n }\n};\n\n/**\n * remove selected files from file table\n * @Selected\n */\nmodule.exports.deleteSelected = selected => {\n selected = selected || DOM.getSelectedFiles();\n if (!selected) return;\n selected.map(DOM.deleteCurrent);\n};\n\n/**\n * rename current file\n *\n * @currentFile\n */\nmodule.exports.renameCurrent = renameCurrent;\n/**\n * unified way to scrollIntoViewIfNeeded\n * (native suporte by webkit only)\n * @param element\n * @param center - to scroll as small as possible param should be false\n */\nmodule.exports.scrollIntoViewIfNeeded = (element, center = false) => {\n if (!element || !element.scrollIntoViewIfNeeded) return;\n element.scrollIntoViewIfNeeded(center);\n};\n\n/* scroll on one page */\nmodule.exports.scrollByPages = (element, pPages) => {\n const ret = (element === null || element === void 0 ? void 0 : element.scrollByPages) && pPages;\n if (ret) element.scrollByPages(pPages);\n return ret;\n};\nmodule.exports.changePanel = () => {\n const Info = CurrentInfo;\n let panel = DOM.getPanel();\n CloudCmd.emit('passive-dir', Info.dirPath);\n const panelPassive = DOM.getPanel({\n active: false\n });\n let name = DOM.getCurrentName();\n const filesPassive = DOM.getFiles(panelPassive);\n let dataName = panel.getAttribute('data-name');\n TabPanel[dataName] = name;\n panel = panelPassive;\n dataName = panel.getAttribute('data-name');\n name = TabPanel[dataName];\n let files;\n let current;\n if (name) {\n current = DOM.getCurrentByName(name, panel);\n if (current) files = current.parentElement;\n }\n if (!files || !files.parentElement) {\n current = DOM.getCurrentByName(name, panel);\n if (!current) [current] = filesPassive;\n }\n DOM.setCurrentFile(current, {\n history: true\n });\n CloudCmd.emit('active-dir', Info.dirPath);\n return DOM;\n};\nmodule.exports.getPackerExt = type => {\n if (type === 'zip') return '.zip';\n return '.tar.gz';\n};\nmodule.exports.goToDirectory = async (overrides = {}) => {\n const {\n Dialog\n } = DOM;\n const {\n prompt = Dialog.prompt,\n changeDir = CloudCmd.changeDir\n } = overrides;\n const msg = 'Go to directory:';\n const {\n dirPath\n } = CurrentInfo;\n const [cancel, path = dirPath] = await prompt(msg, dirPath);\n if (cancel) return;\n await changeDir(path);\n};\nmodule.exports.duplicatePanel = async () => {\n const Info = CurrentInfo;\n const {\n isDir\n } = Info;\n const panel = Info.panelPassive;\n const noCurrent = !Info.isOnePanel;\n const getPath = isDir => {\n if (isDir) return Info.path;\n return Info.dirPath;\n };\n const path = getPath(isDir);\n await CloudCmd.changeDir(path, {\n panel,\n noCurrent\n });\n};\nmodule.exports.swapPanels = async () => {\n const Info = CurrentInfo;\n const {\n panel,\n files,\n element,\n panelPassive\n } = Info;\n const path = DOM.getCurrentDirPath();\n const dirPathPassive = DOM.getNotCurrentDirPath();\n let currentIndex = files.indexOf(element);\n await CloudCmd.changeDir(path, {\n panel: panelPassive,\n noCurrent: true\n });\n await CloudCmd.changeDir(dirPathPassive, {\n panel\n });\n const length = Info.files.length - 1;\n if (currentIndex > length) currentIndex = length;\n const el = Info.files[currentIndex];\n DOM.setCurrentFile(el);\n};\nmodule.exports.CurrentInfo = CurrentInfo;\nmodule.exports.updateCurrentInfo = currentFile => {\n const info = DOM.CurrentInfo;\n const current = currentFile || DOM.getCurrentFile();\n const files = current.parentElement;\n const panelPassive = DOM.getPanel({\n active: false\n });\n const filesPassive = DOM.getFiles(panelPassive);\n const name = DOM.getCurrentName(current);\n info.dir = DOM.getCurrentDirName();\n info.dirPath = DOM.getCurrentDirPath();\n info.parentDirPath = DOM.getParentDirPath();\n info.element = current;\n info.ext = Util.getExt(name);\n info.files = Array.from(files.children);\n info.filesPassive = Array.from(filesPassive);\n info.first = files.firstChild;\n info.getData = DOM.getCurrentData;\n info.last = files.lastChild;\n info.link = DOM.getCurrentLink(current);\n info.mode = DOM.getCurrentMode(current);\n info.name = name;\n info.path = DOM.getCurrentPath(current);\n info.panel = files.parentElement || DOM.getPanel();\n info.panelPassive = panelPassive;\n info.size = DOM.getCurrentSize(current);\n info.isDir = DOM.isCurrentIsDir();\n info.isSelected = DOM.isSelected(current);\n info.panelPosition = DOM.getPanel().dataset.name.replace('js-', '');\n info.isOnePanel = info.panel.getAttribute('data-name') === info.panelPassive.getAttribute('data-name');\n};\n\n//# sourceURL=file://cloudcmd/client/dom/index.js\n}");
140
140
 
141
141
  /***/ },
142
142
 
@@ -169,7 +169,7 @@ eval("{\n\n/* global CloudCmd */\nconst {\n promisify\n} = __webpack_require__(
169
169
  (module, __unused_webpack_exports, __webpack_require__) {
170
170
 
171
171
  "use strict";
172
- eval("{\n\n/* global CloudCmd */\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n findObjByNameInArr\n} = __webpack_require__(/*! ../../common/util */ \"./common/util.js\");\nconst Files = __webpack_require__(/*! ./files */ \"./client/dom/files.js\");\nmodule.exports = (name, options, callback = options) => {\n const {\n prefix,\n config\n } = CloudCmd;\n const o = options;\n if (o.name && window[o.name]) return callback();\n Files.get('modules').then(async modules => {\n const online = config('online') && navigator.onLine;\n const module = findObjByNameInArr(modules.remote, name);\n const isArray = itype.array(module.local);\n const {\n version\n } = module;\n let remoteTmpls;\n let local;\n if (isArray) {\n remoteTmpls = module.remote;\n ({\n local\n } = module);\n } else {\n remoteTmpls = [module.remote];\n local = [module.local];\n }\n const localURL = local.map(url => prefix + url);\n const remoteURL = remoteTmpls.map(tmpl => {\n return rendy(tmpl, {\n version\n });\n });\n if (online) {\n const [e] = await tryToCatch(load.parallel, remoteURL);\n if (!e) return callback();\n }\n const [e] = await tryToCatch(load.parallel, localURL);\n callback(e);\n });\n};\n\n//# sourceURL=file://cloudcmd/client/dom/load-remote.js\n}");
172
+ eval("{\n\n/* global CloudCmd */\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst {\n findObjByNameInArr\n} = __webpack_require__(/*! ../../common/util */ \"./common/util.js\");\nconst Files = __webpack_require__(/*! ./files */ \"./client/dom/files.js\");\nmodule.exports = (name, options, callback = options) => {\n const {\n prefix,\n config\n } = CloudCmd;\n const o = options;\n if (o.name && window[o.name]) return callback();\n Files.get('modules').then(async modules => {\n const online = config('online') && navigator.onLine;\n const module = findObjByNameInArr(modules.remote, name);\n const isArray = itype.array(module.local);\n const {\n version\n } = module;\n let remoteTmpls;\n let local;\n if (isArray) {\n remoteTmpls = module.remote;\n ({\n local\n } = module);\n } else {\n remoteTmpls = [module.remote];\n local = [module.local];\n }\n const localURL = local.map(url => prefix + url);\n const remoteURL = remoteTmpls.map(tmpl => {\n return rendy(tmpl, {\n version\n });\n });\n if (online) {\n const [e] = await tryToCatch(load.parallel, remoteURL);\n if (!e) return callback();\n }\n const [e] = await tryToCatch(load.parallel, localURL);\n callback(e);\n });\n};\n\n//# sourceURL=file://cloudcmd/client/dom/load-remote.js\n}");
173
173
 
174
174
  /***/ },
175
175
 
@@ -202,7 +202,7 @@ eval("{\n\n/* global CloudCmd */\nconst capitalize = __webpack_require__(/*! jus
202
202
  (module, __unused_webpack_exports, __webpack_require__) {
203
203
 
204
204
  "use strict";
205
- eval("{\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n encode\n} = __webpack_require__(/*! ../../common/entity */ \"./common/entity.js\");\nconst Images = __webpack_require__(/*! ./images */ \"./client/dom/images.js\");\nconst IO = __webpack_require__(/*! ./io */ \"./client/dom/io/index.js\");\nconst Dialog = __webpack_require__(/*! ./dialog */ \"./client/dom/dialog.js\");\nconst handleError = promise => async (...args) => {\n const [e, data] = await tryToCatch(promise, ...args);\n if (!e) return [e, data];\n const encoded = encode(e.message);\n Images.show.error(encoded);\n Dialog.alert(encoded);\n return [e, data];\n};\nmodule.exports[\"delete\"] = handleError(IO.delete);\nmodule.exports.patch = handleError(IO.patch);\nmodule.exports.write = handleError(IO.write);\nmodule.exports.createDirectory = handleError(IO.createDirectory);\nmodule.exports.read = handleError(IO.read);\nmodule.exports.copy = handleError(IO.copy);\nmodule.exports.pack = handleError(IO.pack);\nmodule.exports.extract = handleError(IO.extract);\nmodule.exports.move = handleError(IO.move);\nmodule.exports.rename = handleError(IO.rename);\nmodule.exports.Config = {\n read: handleError(IO.Config.read),\n write: handleError(IO.Config.write)\n};\nmodule.exports.Markdown = {\n read: handleError(IO.Markdown.read),\n render: handleError(IO.Markdown.render)\n};\n\n//# sourceURL=file://cloudcmd/client/dom/rest.js\n}");
205
+ eval("{\n\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst {\n encode\n} = __webpack_require__(/*! ../../common/entity */ \"./common/entity.js\");\nconst Images = __webpack_require__(/*! ./images */ \"./client/dom/images.js\");\nconst IO = __webpack_require__(/*! ./io */ \"./client/dom/io/index.js\");\nconst Dialog = __webpack_require__(/*! ./dialog */ \"./client/dom/dialog.js\");\nconst handleError = promise => async (...args) => {\n const [e, data] = await tryToCatch(promise, ...args);\n if (!e) return [e, data];\n const encoded = encode(e.message);\n Images.show.error(encoded);\n Dialog.alert(encoded);\n return [e, data];\n};\nmodule.exports[\"delete\"] = handleError(IO.delete);\nmodule.exports.patch = handleError(IO.patch);\nmodule.exports.write = handleError(IO.write);\nmodule.exports.createDirectory = handleError(IO.createDirectory);\nmodule.exports.read = handleError(IO.read);\nmodule.exports.copy = handleError(IO.copy);\nmodule.exports.pack = handleError(IO.pack);\nmodule.exports.extract = handleError(IO.extract);\nmodule.exports.move = handleError(IO.move);\nmodule.exports.rename = handleError(IO.rename);\nmodule.exports.Config = {\n read: handleError(IO.Config.read),\n write: handleError(IO.Config.write)\n};\nmodule.exports.Markdown = {\n read: handleError(IO.Markdown.read),\n render: handleError(IO.Markdown.render)\n};\n\n//# sourceURL=file://cloudcmd/client/dom/rest.js\n}");
206
206
 
207
207
  /***/ },
208
208
 
@@ -268,7 +268,7 @@ eval("{\n\nmodule.exports.createBinder = () => {\n let binded = false;\n retur
268
268
  (module, __unused_webpack_exports, __webpack_require__) {
269
269
 
270
270
  "use strict";
271
- eval("{\n\n/* global CloudCmd, DOM */\nconst clipboard = __webpack_require__(/*! @cloudcmd/clipboard */ \"./node_modules/@cloudcmd/clipboard/lib/clipboard.js\");\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\nconst Buffer = __webpack_require__(/*! ../dom/buffer */ \"./client/dom/buffer.js\");\nconst Events = __webpack_require__(/*! ../dom/events */ \"./client/dom/events/index.js\");\nconst KEY = __webpack_require__(/*! ./key */ \"./client/key/key.js\");\nconst vim = __webpack_require__(/*! ./vim */ \"./client/key/vim/index.js\");\nconst setCurrentByChar = __webpack_require__(/*! ./set-current-by-char */ \"./client/key/set-current-by-char.js\");\nconst {\n createBinder\n} = __webpack_require__(/*! ./binder */ \"./client/key/binder.js\");\nconst Info = DOM.CurrentInfo;\nconst Chars = fullstore();\nconst toggleVim = keyCode => {\n const {\n _config,\n config\n } = CloudCmd;\n if (keyCode === KEY.ESC) _config('vim', !config('vim'));\n};\nconst isUndefined = a => typeof a === 'undefined';\nChars([]);\nconst {\n assign\n} = Object;\nconst binder = createBinder();\nmodule.exports = assign(binder, KEY);\nmodule.exports.bind = () => {\n Events.addKey(listener, true);\n binder.setBind();\n};\nmodule.exports._listener = listener;\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}\nasync function listener(event) {\n const {\n keyCode\n } = event;\n\n // strange chrome bug calles listener twice\n // in second time event misses a lot fields\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}\nfunction getSymbol(shift, keyCode) {\n switch (keyCode) {\n case KEY.DOT:\n return '.';\n case KEY.HYPHEN:\n return shift ? '_' : '-';\n case KEY.EQUAL:\n return shift ? '+' : '=';\n }\n return '';\n}\nfunction fromCharCode(keyIdentifier) {\n const code = keyIdentifier.substring(2);\n const hex = parseInt(code, 16);\n return String.fromCharCode(hex);\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 changeDir,\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 if (current) {\n prev = current.previousSibling;\n next = current.nextSibling;\n }\n switch (keyCode) {\n case KEY.TAB:\n DOM.changePanel();\n event.preventDefault();\n break;\n case KEY.INSERT:\n DOM.toggleSelectedFile(current).setCurrentFile(next);\n break;\n case KEY.INSERT_MAC:\n DOM.toggleSelectedFile(current).setCurrentFile(next);\n break;\n case KEY.DELETE:\n if (shift) Operation.show('delete:silent');else Operation.show('delete');\n break;\n case KEY.ASTERISK:\n DOM.toggleAllSelectedFiles(current);\n break;\n case KEY.PLUS:\n DOM.expandSelection();\n event.preventDefault();\n break;\n case KEY.MINUS:\n DOM.shrinkSelection();\n event.preventDefault();\n break;\n case KEY.F1:\n CloudCmd.Help.show();\n event.preventDefault();\n break;\n case KEY.F2:\n CloudCmd.UserMenu.show();\n break;\n case KEY.F3:\n event.preventDefault();\n if (Info.isDir) await changeDir(path);else if (shift) CloudCmd.View.show(null, {\n raw: true\n });else if (ctrlMeta) CloudCmd.sortPanel('name');else CloudCmd.View.show();\n break;\n case KEY.F4:\n if (config('vim')) CloudCmd.EditFileVim.show();else CloudCmd.EditFile.show();\n event.preventDefault();\n break;\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 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 case KEY.F7:\n if (shift) DOM.promptNewFile();else DOM.promptNewDir();\n event.preventDefault();\n break;\n case KEY.F8:\n Operation.show('delete');\n event.preventDefault();\n break;\n case KEY.F9:\n if (alt) Operation.show('extract');else CloudCmd.Menu.show();\n event.preventDefault();\n break;\n case KEY.F10:\n CloudCmd.Config.show();\n event.preventDefault();\n break;\n case KEY.TRA:\n event.preventDefault();\n if (shift) return CloudCmd.Terminal.show();\n CloudCmd.Konsole.show();\n break;\n case KEY.BRACKET_CLOSE:\n CloudCmd.Konsole.show();\n event.preventDefault();\n break;\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 case KEY.U:\n if (ctrlMeta) {\n DOM.swapPanels();\n event.preventDefault();\n }\n break;\n\n /* navigation on file table: *\n * in case of pressing button 'up', *\n * select previous row */\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 case KEY.DOWN:\n if (shift) DOM.toggleSelectedFile(current);\n DOM.setCurrentFile(next);\n event.preventDefault();\n break;\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 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 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 case KEY.END:\n DOM.setCurrentFile(Info.last);\n event.preventDefault();\n break;\n\n /* если нажали клавишу page down проматываем экран */\n case KEY.PAGE_DOWN:\n DOM.scrollByPages(panel, 1);\n for (i = 0; i < 30; i++) {\n if (!current.nextSibling) break;\n current = current.nextSibling;\n }\n DOM.setCurrentFile(current);\n event.preventDefault();\n break;\n\n /* если нажали клавишу page up проматываем экран */\n case KEY.PAGE_UP:\n DOM.scrollByPages(panel, -1);\n for (i = 0; i < 30; i++) {\n if (!current.previousSibling) break;\n current = current.previousSibling;\n }\n DOM.setCurrentFile(current);\n event.preventDefault();\n break;\n case KEY.ENTER:\n if (Info.isDir) await changeDir(path);else CloudCmd.View.show();\n break;\n case KEY.BACKSPACE:\n CloudCmd.goToParentDir();\n event.preventDefault();\n break;\n case KEY.BACKSLASH:\n if (ctrlMeta) await changeDir('/');\n break;\n case KEY.A:\n if (ctrlMeta) {\n DOM.selectAllFiles();\n event.preventDefault();\n }\n break;\n case KEY.G:\n if (alt) {\n DOM.goToDirectory();\n event.preventDefault();\n }\n break;\n case KEY.M:\n if (ctrlMeta) {\n if (config('vim')) CloudCmd.EditNamesVim.show();else CloudCmd.EditNames.show();\n event.preventDefault();\n }\n break;\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 case KEY.R:\n if (ctrlMeta) {\n CloudCmd.log('reloading page...\\n');\n CloudCmd.refresh();\n event.preventDefault();\n }\n break;\n case KEY.C:\n if (ctrlMeta) Buffer.copy();\n break;\n case KEY.X:\n if (ctrlMeta) Buffer.cut();\n break;\n case KEY.V:\n if (ctrlMeta) Buffer.paste();\n break;\n case KEY.Z:\n if (ctrlMeta) Buffer.clear();\n break;\n case KEY.COLON:\n CloudCmd.CommandLine.show();\n event.preventDefault();\n break;\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 break;\n case KEY.DOT:\n if (meta && shift) {\n const showDotFiles = !CloudCmd.config('showDotFiles');\n CloudCmd._config('showDotFiles', showDotFiles);\n CloudCmd.refresh();\n await DOM.RESTful.Config.write({\n showDotFiles\n });\n }\n break;\n }\n}\n\n//# sourceURL=file://cloudcmd/client/key/index.js\n}");
271
+ eval("{\n\n/* global CloudCmd, DOM */\nconst clipboard = __webpack_require__(/*! @cloudcmd/clipboard */ \"./node_modules/@cloudcmd/clipboard/lib/clipboard.js\");\nconst {\n fullstore\n} = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.cjs\");\nconst Buffer = __webpack_require__(/*! ../dom/buffer */ \"./client/dom/buffer.js\");\nconst Events = __webpack_require__(/*! ../dom/events */ \"./client/dom/events/index.js\");\nconst KEY = __webpack_require__(/*! ./key */ \"./client/key/key.js\");\nconst vim = __webpack_require__(/*! ./vim */ \"./client/key/vim/index.js\");\nconst setCurrentByChar = __webpack_require__(/*! ./set-current-by-char */ \"./client/key/set-current-by-char.js\");\nconst {\n createBinder\n} = __webpack_require__(/*! ./binder */ \"./client/key/binder.js\");\nconst Info = DOM.CurrentInfo;\nconst Chars = fullstore();\nconst toggleVim = keyCode => {\n const {\n _config,\n config\n } = CloudCmd;\n if (keyCode === KEY.ESC) _config('vim', !config('vim'));\n};\nconst isUndefined = a => typeof a === 'undefined';\nChars([]);\nconst {\n assign\n} = Object;\nconst binder = createBinder();\nmodule.exports = assign(binder, KEY);\nmodule.exports.bind = () => {\n Events.addKey(listener, true);\n binder.setBind();\n};\nmodule.exports._listener = listener;\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}\nasync function listener(event) {\n const {\n keyCode\n } = event;\n\n // strange chrome bug calles listener twice\n // in second time event misses a lot fields\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}\nfunction getSymbol(shift, keyCode) {\n switch (keyCode) {\n case KEY.DOT:\n return '.';\n case KEY.HYPHEN:\n return shift ? '_' : '-';\n case KEY.EQUAL:\n return shift ? '+' : '=';\n }\n return '';\n}\nfunction fromCharCode(keyIdentifier) {\n const code = keyIdentifier.substring(2);\n const hex = parseInt(code, 16);\n return String.fromCharCode(hex);\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 changeDir,\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 if (current) {\n prev = current.previousSibling;\n next = current.nextSibling;\n }\n switch (keyCode) {\n case KEY.TAB:\n DOM.changePanel();\n event.preventDefault();\n break;\n case KEY.INSERT:\n DOM.toggleSelectedFile(current).setCurrentFile(next);\n break;\n case KEY.INSERT_MAC:\n DOM.toggleSelectedFile(current).setCurrentFile(next);\n break;\n case KEY.DELETE:\n if (shift) Operation.show('delete:silent');else Operation.show('delete');\n break;\n case KEY.ASTERISK:\n DOM.toggleAllSelectedFiles(current);\n break;\n case KEY.PLUS:\n DOM.expandSelection();\n event.preventDefault();\n break;\n case KEY.MINUS:\n DOM.shrinkSelection();\n event.preventDefault();\n break;\n case KEY.F1:\n CloudCmd.Help.show();\n event.preventDefault();\n break;\n case KEY.F2:\n CloudCmd.UserMenu.show();\n break;\n case KEY.F3:\n event.preventDefault();\n if (Info.isDir) await changeDir(path);else if (shift) CloudCmd.View.show(null, {\n raw: true\n });else if (ctrlMeta) CloudCmd.sortPanel('name');else CloudCmd.View.show();\n break;\n case KEY.F4:\n if (config('vim')) CloudCmd.EditFileVim.show();else CloudCmd.EditFile.show();\n event.preventDefault();\n break;\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 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 case KEY.F7:\n if (shift) DOM.promptNewFile();else DOM.promptNewDir();\n event.preventDefault();\n break;\n case KEY.F8:\n Operation.show('delete');\n event.preventDefault();\n break;\n case KEY.F9:\n if (alt) Operation.show('extract');else CloudCmd.Menu.show();\n event.preventDefault();\n break;\n case KEY.F10:\n CloudCmd.Config.show();\n event.preventDefault();\n break;\n case KEY.TRA:\n event.preventDefault();\n if (shift) return CloudCmd.Terminal.show();\n CloudCmd.Konsole.show();\n break;\n case KEY.BRACKET_CLOSE:\n CloudCmd.Konsole.show();\n event.preventDefault();\n break;\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 case KEY.U:\n if (ctrlMeta) {\n DOM.swapPanels();\n event.preventDefault();\n }\n break;\n\n /* navigation on file table: *\n * in case of pressing button 'up', *\n * select previous row */\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 case KEY.DOWN:\n if (shift) DOM.toggleSelectedFile(current);\n DOM.setCurrentFile(next);\n event.preventDefault();\n break;\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 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 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 case KEY.END:\n DOM.setCurrentFile(Info.last);\n event.preventDefault();\n break;\n\n /* если нажали клавишу page down проматываем экран */\n case KEY.PAGE_DOWN:\n DOM.scrollByPages(panel, 1);\n for (i = 0; i < 30; i++) {\n if (!current.nextSibling) break;\n current = current.nextSibling;\n }\n DOM.setCurrentFile(current);\n event.preventDefault();\n break;\n\n /* если нажали клавишу page up проматываем экран */\n case KEY.PAGE_UP:\n DOM.scrollByPages(panel, -1);\n for (i = 0; i < 30; i++) {\n if (!current.previousSibling) break;\n current = current.previousSibling;\n }\n DOM.setCurrentFile(current);\n event.preventDefault();\n break;\n case KEY.ENTER:\n if (Info.isDir) await changeDir(path);else CloudCmd.View.show();\n break;\n case KEY.BACKSPACE:\n CloudCmd.goToParentDir();\n event.preventDefault();\n break;\n case KEY.BACKSLASH:\n if (ctrlMeta) await changeDir('/');\n break;\n case KEY.A:\n if (ctrlMeta) {\n DOM.selectAllFiles();\n event.preventDefault();\n }\n break;\n case KEY.G:\n if (alt) {\n DOM.goToDirectory();\n event.preventDefault();\n }\n break;\n case KEY.M:\n if (ctrlMeta) {\n if (config('vim')) CloudCmd.EditNamesVim.show();else CloudCmd.EditNames.show();\n event.preventDefault();\n }\n break;\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 case KEY.R:\n if (ctrlMeta) {\n CloudCmd.log('reloading page...\\n');\n CloudCmd.refresh();\n event.preventDefault();\n }\n break;\n case KEY.C:\n if (ctrlMeta) Buffer.copy();\n break;\n case KEY.X:\n if (ctrlMeta) Buffer.cut();\n break;\n case KEY.V:\n if (ctrlMeta) Buffer.paste();\n break;\n case KEY.Z:\n if (ctrlMeta) Buffer.clear();\n break;\n case KEY.COLON:\n CloudCmd.CommandLine.show();\n event.preventDefault();\n break;\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 break;\n case KEY.DOT:\n if (meta && shift) {\n const showDotFiles = !CloudCmd.config('showDotFiles');\n CloudCmd._config('showDotFiles', showDotFiles);\n CloudCmd.refresh();\n await DOM.RESTful.Config.write({\n showDotFiles\n });\n }\n break;\n }\n}\n\n//# sourceURL=file://cloudcmd/client/key/index.js\n}");
272
272
 
273
273
  /***/ },
274
274
 
@@ -301,7 +301,7 @@ eval("{/* global DOM */\n\n\n\nconst {\n escapeRegExp\n} = __webpack_require__(
301
301
  (module, __unused_webpack_exports, __webpack_require__) {
302
302
 
303
303
  "use strict";
304
- eval("{\n\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\nconst limier = __webpack_require__(/*! limier */ \"./node_modules/limier/lib/limier.js\");\nconst searchStore = fullstore([]);\nconst searchIndex = fullstore(0);\nmodule.exports.find = (value, names) => {\n const result = limier(value, names);\n searchStore(result);\n searchIndex(0);\n return result;\n};\nmodule.exports.findNext = () => {\n const names = searchStore();\n const index = next(searchIndex(), names.length);\n searchIndex(index);\n return names[searchIndex()];\n};\nmodule.exports.findPrevious = () => {\n const names = searchStore();\n const index = previous(searchIndex(), names.length);\n searchIndex(index);\n return names[index];\n};\nmodule.exports._next = next;\nmodule.exports._previous = previous;\nfunction next(index, length) {\n if (index === length - 1) return 0;\n return ++index;\n}\nfunction previous(index, length) {\n if (!index) return length - 1;\n return --index;\n}\n\n//# sourceURL=file://cloudcmd/client/key/vim/find.js\n}");
304
+ eval("{\n\nconst {\n fullstore\n} = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.cjs\");\nconst limier = __webpack_require__(/*! limier */ \"./node_modules/limier/lib/limier.js\");\nconst searchStore = fullstore([]);\nconst searchIndex = fullstore(0);\nmodule.exports.find = (value, names) => {\n const result = limier(value, names);\n searchStore(result);\n searchIndex(0);\n return result;\n};\nmodule.exports.findNext = () => {\n const names = searchStore();\n const index = next(searchIndex(), names.length);\n searchIndex(index);\n return names[searchIndex()];\n};\nmodule.exports.findPrevious = () => {\n const names = searchStore();\n const index = previous(searchIndex(), names.length);\n searchIndex(index);\n return names[index];\n};\nmodule.exports._next = next;\nmodule.exports._previous = previous;\nfunction next(index, length) {\n if (index === length - 1) return 0;\n return ++index;\n}\nfunction previous(index, length) {\n if (!index) return length - 1;\n return --index;\n}\n\n//# sourceURL=file://cloudcmd/client/key/vim/find.js\n}");
305
305
 
306
306
  /***/ },
307
307
 
@@ -334,7 +334,7 @@ eval("{\n\n/* global DOM */\nmodule.exports.selectFileNotParent = selectFileNotP
334
334
  (module, __unused_webpack_exports, __webpack_require__) {
335
335
 
336
336
  "use strict";
337
- eval("{\n\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\nconst store = fullstore('');\nconst visual = fullstore(false);\nconst stopVisual = () => {\n visual(false);\n};\nconst end = () => {\n store('');\n};\nconst rmFirst = a => {\n return a.split('').slice(1).join('');\n};\nconst noop = () => {};\nmodule.exports = (key, operations = {}) => {\n const prevStore = store();\n const isVisual = visual();\n const value = store(prevStore.concat(key));\n const {\n escape = noop,\n moveNext = noop,\n movePrevious = noop,\n remove = noop,\n copy = noop,\n paste = noop,\n select = noop,\n find = noop,\n findNext = noop,\n findPrevious = noop,\n makeFile = noop,\n makeDirectory = noop,\n terminal = noop,\n edit = noop\n } = operations;\n if (key === 'Enter') return end();\n if (key === 'Escape') {\n visual(false);\n escape();\n return end();\n }\n if (key === 'j' || key === 'w') {\n const {\n count,\n isDelete,\n isVisual\n } = handleDelete(prevStore);\n !isNaN(count) && moveNext({\n count,\n isVisual,\n isDelete\n });\n return end();\n }\n if (key === 'k' || key === 'b') {\n const {\n count,\n isDelete,\n isVisual\n } = handleDelete(prevStore);\n !isNaN(count) && movePrevious({\n count,\n isVisual,\n isDelete\n });\n return end();\n }\n if (value === 'gg' || key === '^') {\n const {\n isDelete,\n isVisual\n } = handleDelete(prevStore);\n movePrevious({\n count: Infinity,\n isVisual,\n isDelete\n });\n return end();\n }\n if (value === 'md') {\n makeDirectory();\n return end();\n }\n if (value === 'tt') {\n terminal();\n return end();\n }\n if (value === 'e') {\n edit();\n return end();\n }\n if (value === 'mf') {\n makeFile();\n return end();\n }\n if (key === 'd' && (visual() || prevStore === 'd')) {\n stopVisual();\n remove();\n return end();\n }\n if (key === 'G' || key === '$') {\n moveNext({\n count: Infinity,\n isVisual\n });\n return end();\n }\n if (key === 'y') {\n if (!visual()) return end();\n stopVisual();\n copy();\n return end();\n }\n if (/^p$/i.test(key)) {\n paste();\n return end();\n }\n if (/^v$/i.test(key)) {\n visual(!visual());\n select();\n return end();\n }\n if (key === '/') {\n find();\n return end();\n }\n if (key === 'n') {\n findNext();\n return end();\n }\n if (key === 'N') {\n findPrevious();\n return end();\n }\n if (key === ' ') return end();\n};\nfunction handleDelete(prevStore) {\n const isDelete = prevStore[0] === 'd';\n if (isDelete) {\n visual(true);\n prevStore = rmFirst(prevStore);\n }\n const count = getNumber(prevStore);\n const isVisual = visual();\n return {\n count,\n isDelete,\n isVisual\n };\n}\nfunction getNumber(value) {\n if (!value) return 1;\n if (value === 'g') return 1;\n return parseInt(value);\n}\n\n//# sourceURL=file://cloudcmd/client/key/vim/vim.js\n}");
337
+ eval("{\n\nconst {\n fullstore\n} = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.cjs\");\nconst store = fullstore('');\nconst visual = fullstore(false);\nconst stopVisual = () => {\n visual(false);\n};\nconst end = () => {\n store('');\n};\nconst rmFirst = a => {\n return a.split('').slice(1).join('');\n};\nconst noop = () => {};\nmodule.exports = (key, operations = {}) => {\n const prevStore = store();\n const isVisual = visual();\n const value = store(prevStore.concat(key));\n const {\n escape = noop,\n moveNext = noop,\n movePrevious = noop,\n remove = noop,\n copy = noop,\n paste = noop,\n select = noop,\n find = noop,\n findNext = noop,\n findPrevious = noop,\n makeFile = noop,\n makeDirectory = noop,\n terminal = noop,\n edit = noop\n } = operations;\n if (key === 'Enter') return end();\n if (key === 'Escape') {\n visual(false);\n escape();\n return end();\n }\n if (key === 'j' || key === 'w') {\n const {\n count,\n isDelete,\n isVisual\n } = handleDelete(prevStore);\n !isNaN(count) && moveNext({\n count,\n isVisual,\n isDelete\n });\n return end();\n }\n if (key === 'k' || key === 'b') {\n const {\n count,\n isDelete,\n isVisual\n } = handleDelete(prevStore);\n !isNaN(count) && movePrevious({\n count,\n isVisual,\n isDelete\n });\n return end();\n }\n if (value === 'gg' || key === '^') {\n const {\n isDelete,\n isVisual\n } = handleDelete(prevStore);\n movePrevious({\n count: Infinity,\n isVisual,\n isDelete\n });\n return end();\n }\n if (value === 'md') {\n makeDirectory();\n return end();\n }\n if (value === 'tt') {\n terminal();\n return end();\n }\n if (value === 'e') {\n edit();\n return end();\n }\n if (value === 'mf') {\n makeFile();\n return end();\n }\n if (key === 'd' && (visual() || prevStore === 'd')) {\n stopVisual();\n remove();\n return end();\n }\n if (key === 'G' || key === '$') {\n moveNext({\n count: Infinity,\n isVisual\n });\n return end();\n }\n if (key === 'y') {\n if (!visual()) return end();\n stopVisual();\n copy();\n return end();\n }\n if (/^p$/i.test(key)) {\n paste();\n return end();\n }\n if (/^v$/i.test(key)) {\n visual(!visual());\n select();\n return end();\n }\n if (key === '/') {\n find();\n return end();\n }\n if (key === 'n') {\n findNext();\n return end();\n }\n if (key === 'N') {\n findPrevious();\n return end();\n }\n if (key === ' ') return end();\n};\nfunction handleDelete(prevStore) {\n const isDelete = prevStore[0] === 'd';\n if (isDelete) {\n visual(true);\n prevStore = rmFirst(prevStore);\n }\n const count = getNumber(prevStore);\n const isVisual = visual();\n return {\n count,\n isDelete,\n isVisual\n };\n}\nfunction getNumber(value) {\n if (!value) return 1;\n if (value === 'g') return 1;\n return parseInt(value);\n}\n\n//# sourceURL=file://cloudcmd/client/key/vim/vim.js\n}");
338
338
 
339
339
  /***/ },
340
340
 
@@ -367,7 +367,7 @@ eval("{\n\nmodule.exports = (indexFrom, indexTo, files) => {\n if (indexFrom <
367
367
  (module, __unused_webpack_exports, __webpack_require__) {
368
368
 
369
369
  "use strict";
370
- eval("{/* global DOM, CloudCmd */\n\n\n\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst clipboard = __webpack_require__(/*! @cloudcmd/clipboard */ \"./node_modules/@cloudcmd/clipboard/lib/clipboard.js\");\nconst getRange = __webpack_require__(/*! ./get-range */ \"./client/listeners/get-range.js\");\nconst uploadFiles = __webpack_require__(/*! ../dom/upload-files */ \"./client/dom/upload-files.js\");\nconst {\n FS\n} = __webpack_require__(/*! ../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst getIndex = currify(__webpack_require__(/*! ./get-index */ \"./client/listeners/get-index.js\"));\nconst NBSP_REG = RegExp(String.fromCharCode(160), 'g');\nconst SPACE = ' ';\nmodule.exports.init = async () => {\n await Promise.all([contextMenu(), dragndrop(), unload(), pop(), resize(), header(), config()]);\n};\nCloudCmd.Listeners = module.exports;\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};\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, exec.with(execIfNotMobile, unselect)]),\n dragstart: exec.with(execIfNotUL, onDragStart),\n dblclick: exec.with(execIfNotUL, onDblClick),\n touchstart: exec.with(execIfNotUL, onTouch)\n};\nlet EXT;\nfunction header() {\n const fm = DOM.getFM();\n const isDataset = el => el.dataset;\n const isPanel = el => {\n return /^js-(left|right)$/.test(el.dataset.name);\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}\nfunction getPath(el, path = []) {\n if (!el) return path;\n return getPath(el.parentElement, path.concat(el));\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}\nmodule.exports.initKeysPanel = () => {\n const keysElement = DOM.getById('js-keyspanel');\n if (!keysElement) return;\n Events.addClick(keysElement, event => {\n const {\n target\n } = event;\n const {\n id\n } = target;\n const operation = name => {\n const {\n Operation\n } = CloudCmd;\n return Operation.show.bind(null, name);\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': () => {\n event.stopPropagation();\n CloudCmd.Menu.show();\n },\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};\nconst getPanel = side => {\n if (!itype.string(side)) return side;\n return DOM.getByDataName(`js-${side}`);\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};\nfunction getPathListener(panel) {\n return onPathElementClick.bind(null, panel);\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}\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}\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.changeDir(path, {\n isRefresh: false,\n panel: noCurrent ? panel : Info.panel\n });\n}\nfunction copyPath(el) {\n clipboard.writeText(el.parentElement.title).then(CloudCmd.log).catch(CloudCmd.log);\n}\nfunction execIfNotMobile(callback, event) {\n const isMobile = DOM.getCSSVar('is-mobile');\n if (!isMobile) callback(event);\n}\nfunction execIfNotUL(callback, event) {\n const {\n target\n } = event;\n const {\n tagName\n } = target;\n if (tagName !== 'UL') callback(event);\n}\nfunction onClick(event) {\n event.preventDefault();\n changePanel(event.target);\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) return DOM.toggleSelectedFile(file);\n if (key.shift) return files.map(DOM.selectFile);\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}\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.changeDir(path);\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.changeDir(DOM.getCurrentPath(current));\n}\n\n/*\n * download file from browser to desktop\n * in Chrome (HTML5)\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\n /* if it's directory - adding json extension */\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 event.dataTransfer.setData('DownloadURL', 'application/octet-stream' + ':' + name + ':' + link);\n}\nfunction getLIElement(element) {\n if (!element) return element;\n while (element.tagName !== 'LI') element = element.parentElement;\n return element;\n}\nfunction getULElement(element) {\n while (element.tagName !== 'UL') element = element.parentElement;\n return element;\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}\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}\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}\nfunction dragndrop() {\n const panels = DOM.getByClassAll('panel');\n const select = ({\n target\n }) => {\n target.classList.add('selected-panel');\n };\n const unselect = ({\n target\n }) => {\n target.classList.remove('selected-panel');\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 const isFile = item => item.kind === 'file';\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 /**\n * In macOS Chrome dropEffect = 'none'\n * so drop do not firing up when try\n * to upload file from download bar\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 for (const panel of panels) Events.add('dragover', panel, onDragOver).add('drop', panel, onDrop).add('dragenter', select).add(['dragleave', 'drop'], unselect);\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}\nfunction pop() {\n Events.add('popstate', async ({\n state\n }) => {\n const path = (state || '').replace(FS, '');\n if (!path) return CloudCmd.route(location.hash);\n const history = false;\n await CloudCmd.changeDir(path, {\n history\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\n}");
370
+ eval("{/* global DOM, CloudCmd */\n\n\n\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst clipboard = __webpack_require__(/*! @cloudcmd/clipboard */ \"./node_modules/@cloudcmd/clipboard/lib/clipboard.js\");\nconst getRange = __webpack_require__(/*! ./get-range */ \"./client/listeners/get-range.js\");\nconst uploadFiles = __webpack_require__(/*! ../dom/upload-files */ \"./client/dom/upload-files.js\");\nconst {\n FS\n} = __webpack_require__(/*! ../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst getIndex = currify(__webpack_require__(/*! ./get-index */ \"./client/listeners/get-index.js\"));\nconst NBSP_REG = RegExp(String.fromCharCode(160), 'g');\nconst SPACE = ' ';\nmodule.exports.init = async () => {\n await Promise.all([contextMenu(), dragndrop(), unload(), pop(), resize(), header(), config()]);\n};\nCloudCmd.Listeners = module.exports;\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};\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, exec.with(execIfNotMobile, unselect)]),\n dragstart: exec.with(execIfNotUL, onDragStart),\n dblclick: exec.with(execIfNotUL, onDblClick),\n touchstart: exec.with(execIfNotUL, onTouch)\n};\nlet EXT;\nfunction header() {\n const fm = DOM.getFM();\n const isDataset = el => el.dataset;\n const isPanel = el => {\n return /^js-(left|right)$/.test(el.dataset.name);\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}\nfunction getPath(el, path = []) {\n if (!el) return path;\n return getPath(el.parentElement, path.concat(el));\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}\nmodule.exports.initKeysPanel = () => {\n const keysElement = DOM.getById('js-keyspanel');\n if (!keysElement) return;\n Events.addClick(keysElement, event => {\n const {\n target\n } = event;\n const {\n id\n } = target;\n const operation = name => {\n const {\n Operation\n } = CloudCmd;\n return Operation.show.bind(null, name);\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': () => {\n event.stopPropagation();\n CloudCmd.Menu.show();\n },\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};\nconst getPanel = side => {\n if (!itype.string(side)) return side;\n return DOM.getByDataName(`js-${side}`);\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};\nfunction getPathListener(panel) {\n return onPathElementClick.bind(null, panel);\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}\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}\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.changeDir(path, {\n isRefresh: false,\n panel: noCurrent ? panel : Info.panel\n });\n}\nfunction copyPath(el) {\n clipboard.writeText(el.parentElement.title).then(CloudCmd.log).catch(CloudCmd.log);\n}\nfunction execIfNotMobile(callback, event) {\n const isMobile = DOM.getCSSVar('is-mobile');\n if (!isMobile) callback(event);\n}\nfunction execIfNotUL(callback, event) {\n const {\n target\n } = event;\n const {\n tagName\n } = target;\n if (tagName !== 'UL') callback(event);\n}\nfunction onClick(event) {\n event.preventDefault();\n changePanel(event.target);\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) return DOM.toggleSelectedFile(file);\n if (key.shift) return files.map(DOM.selectFile);\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}\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.changeDir(path);\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.changeDir(DOM.getCurrentPath(current));\n}\n\n/*\n * download file from browser to desktop\n * in Chrome (HTML5)\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\n /* if it's directory - adding json extension */\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 event.dataTransfer.setData('DownloadURL', 'application/octet-stream' + ':' + name + ':' + link);\n}\nfunction getLIElement(element) {\n if (!element) return element;\n while (element.tagName !== 'LI') element = element.parentElement;\n return element;\n}\nfunction getULElement(element) {\n while (element.tagName !== 'UL') element = element.parentElement;\n return element;\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}\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}\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}\nfunction dragndrop() {\n const panels = DOM.getByClassAll('panel');\n const select = ({\n target\n }) => {\n target.classList.add('selected-panel');\n };\n const unselect = ({\n target\n }) => {\n target.classList.remove('selected-panel');\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 const isFile = item => item.kind === 'file';\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 /**\n * In macOS Chrome dropEffect = 'none'\n * so drop do not firing up when try\n * to upload file from download bar\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 for (const panel of panels) Events.add('dragover', panel, onDragOver).add('drop', panel, onDrop).add('dragenter', select).add(['dragleave', 'drop'], unselect);\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}\nfunction pop() {\n Events.add('popstate', async ({\n state\n }) => {\n const path = (state || '').replace(FS, '');\n if (!path) return CloudCmd.route(location.hash);\n const history = false;\n await CloudCmd.changeDir(path, {\n history\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\n}");
371
371
 
372
372
  /***/ },
373
373
 
@@ -378,7 +378,7 @@ eval("{/* global DOM, CloudCmd */\n\n\n\nconst exec = __webpack_require__(/*! ex
378
378
  (module, __unused_webpack_exports, __webpack_require__) {
379
379
 
380
380
  "use strict";
381
- eval("{\n\n/* global CloudCmd */\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst loadJS = (__webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\").js);\nconst pascalCase = __webpack_require__(/*! just-pascal-case */ \"./node_modules/just-pascal-case/index.cjs\");\nconst noJS = a => a.replace(/.js$/, '');\n\n/**\n * function load modules\n * @params = {name, path, func, dobefore, arg}\n */\nmodule.exports = function loadModule(params) {\n if (!params) return;\n const {\n path\n } = params;\n const name = path && noJS(pascalCase(path));\n const doBefore = params.dobefore;\n if (CloudCmd[name]) return;\n CloudCmd[name] = async () => {\n exec(doBefore);\n const {\n DIR_MODULES\n } = CloudCmd;\n const pathFull = `${DIR_MODULES}/${path}.js`;\n await loadJS(pathFull);\n const newModule = async f => f && f();\n const module = CloudCmd[name];\n Object.assign(newModule, module);\n CloudCmd[name] = newModule;\n CloudCmd.log('init', name);\n await module.init();\n return newModule;\n };\n CloudCmd[name].show = async (...args) => {\n CloudCmd.log('show', name, args);\n const m = CloudCmd[name];\n const [e, a] = await tryToCatch(m);\n if (e) return console.error(e);\n return await a.show(...args);\n };\n};\n\n//# sourceURL=file://cloudcmd/client/load-module.js\n}");
381
+ eval("{\n\n/* global CloudCmd */\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst loadJS = (__webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\").js);\nconst pascalCase = __webpack_require__(/*! just-pascal-case */ \"./node_modules/just-pascal-case/index.cjs\");\nconst noJS = a => a.replace(/.js$/, '');\n\n/**\n * function load modules\n * @params = {name, path, func, dobefore, arg}\n */\nmodule.exports = function loadModule(params) {\n if (!params) return;\n const {\n path\n } = params;\n const name = path && noJS(pascalCase(path));\n const doBefore = params.dobefore;\n if (CloudCmd[name]) return;\n CloudCmd[name] = async () => {\n exec(doBefore);\n const {\n DIR_MODULES\n } = CloudCmd;\n const pathFull = `${DIR_MODULES}/${path}.js`;\n await loadJS(pathFull);\n const newModule = async f => f && f();\n const module = CloudCmd[name];\n Object.assign(newModule, module);\n CloudCmd[name] = newModule;\n CloudCmd.log('init', name);\n await module.init();\n return newModule;\n };\n CloudCmd[name].show = async (...args) => {\n CloudCmd.log('show', name, args);\n const m = CloudCmd[name];\n const [e, a] = await tryToCatch(m);\n if (e) return console.error(e);\n return await a.show(...args);\n };\n};\n\n//# sourceURL=file://cloudcmd/client/load-module.js\n}");
382
382
 
383
383
  /***/ },
384
384
 
@@ -411,7 +411,7 @@ eval("{\n\n/* global CloudCmd */\nCloudCmd.CommandLine = exports;\nconst Dialog
411
411
  (module, __unused_webpack_exports, __webpack_require__) {
412
412
 
413
413
  "use strict";
414
- eval("{\n\n/* global CloudCmd, DOM, io */\n__webpack_require__(/*! ../../../css/config.css */ \"./css/config.css\");\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst squad = __webpack_require__(/*! squad */ \"./node_modules/squad/lib/squad.js\");\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst input = __webpack_require__(/*! ./input */ \"./client/modules/config/input.js\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\nconst Events = __webpack_require__(/*! ../../dom/events */ \"./client/dom/events/index.js\");\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\nconst {\n getTitle\n} = __webpack_require__(/*! ../../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst {\n Dialog,\n setTitle\n} = DOM;\nconst Name = 'Config';\nCloudCmd[Name] = module.exports;\nconst loadSocket = promisify(DOM.loadSocket);\nconst showLoad = () => {\n Images.show.load('top');\n};\nconst addKey = currify((fn, input) => {\n Events.addKey(input, fn);\n return input;\n});\nconst addChange = currify((fn, input) => {\n Events.add('change', input, fn);\n return input;\n});\nconst Config = {};\nlet Template;\nconst loadCSS = load.css;\nmodule.exports.init = async () => {\n if (!CloudCmd.config('configDialog')) return;\n showLoad();\n const {\n DIR_DIST\n } = CloudCmd;\n [Template] = await Promise.all([Files.get('config-tmpl'), loadSocket(), loadCSS(`${DIR_DIST}/config.css`), CloudCmd.View()]);\n initSocket();\n};\nconst {\n config,\n Key\n} = CloudCmd;\nlet Element;\nfunction getHost() {\n const {\n host,\n origin,\n protocol\n } = location;\n return origin || `${protocol}//${host}`;\n}\nfunction initSocket() {\n const href = getHost();\n const {\n prefixSocket,\n prefix\n } = CloudCmd;\n const ONE_MINUTE = 60 * 1000;\n const socket = io.connect(href + prefixSocket + '/config', {\n reconnectionAttempts: Infinity,\n reconnectionDelay: ONE_MINUTE,\n path: `${prefix}/socket.io`\n });\n const save = data => {\n onSave(data);\n socket.send(data);\n };\n authCheck(socket);\n socket.on('connect', () => {\n Config.save = save;\n });\n socket.on('message', onSave);\n socket.on('log', CloudCmd.log);\n socket.on('disconnect', () => {\n Config.save = saveHttp;\n });\n socket.on('err', Dialog.alert);\n}\nfunction authCheck(socket) {\n socket.emit('auth', config('username'), config('password'));\n socket.on('reject', wraptile(Dialog.alert, 'Wrong credentials!'));\n}\nConfig.save = saveHttp;\nmodule.exports.show = show;\nasync function show() {\n if (!CloudCmd.config('configDialog')) return;\n await fillTemplate();\n}\nasync function fillTemplate() {\n const [error, config] = await tryToCatch(Files.get, 'config');\n if (error) return Dialog.alert('Could not load config!');\n const {\n editor,\n menu,\n packer,\n columns,\n theme,\n configAuth,\n ...obj\n } = input.convert(config);\n obj[`${menu}-selected`] = 'selected';\n obj[`${editor}-selected`] = 'selected';\n obj[`${packer}-selected`] = 'selected';\n obj[`${columns}-selected`] = 'selected';\n obj[`${theme}-selected`] = 'selected';\n obj.configAuth = configAuth ? '' : 'hidden';\n const innerHTML = rendy(Template, obj);\n Element = createElement('form', {\n className: 'config',\n innerHTML\n });\n const inputs = document.querySelectorAll('input, select', Element);\n const [inputFirst] = inputs;\n let afterShow;\n if (inputFirst) {\n onAuthChange(inputFirst.checked);\n afterShow = inputFirst.focus.bind(inputFirst);\n }\n const getTarget = ({\n target\n }) => target;\n const handleChange = squad(onChange, getTarget);\n Array.from(inputs).map(addKey(onKey)).map(addChange(handleChange));\n const autoSize = true;\n CloudCmd.View.show(Element, {\n autoSize,\n afterShow\n });\n}\nmodule.exports.hide = hide;\nfunction hide() {\n CloudCmd.View.hide();\n}\nasync function onChange(el) {\n const obj = {};\n const name = input.getName(el);\n const data = input.getValue(name, Element);\n if (name === 'name') onNameChange(data);else if (name === 'auth') onAuthChange(data);\n obj[name] = data;\n await Config.save(obj);\n}\nfunction onSave(obj) {\n for (const name of Object.keys(obj)) {\n const data = obj[name];\n CloudCmd._config(name, data);\n input.setValue(name, data, Element);\n }\n}\nasync function saveHttp(obj) {\n const {\n RESTful\n } = DOM;\n const [e] = await RESTful.Config.write(obj);\n if (e) return;\n onSave(obj);\n}\nfunction onAuthChange(checked) {\n const elUsername = input.getElementByName('username', Element);\n const elPassword = input.getElementByName('password', Element);\n elUsername.disabled = !checked;\n elPassword.disabled = !checked;\n}\nfunction onNameChange(name) {\n setTitle(getTitle({\n name\n }));\n}\nasync function onKey({\n keyCode,\n target\n}) {\n switch (keyCode) {\n case Key.ESC:\n return hide();\n case Key.ENTER:\n return await onChange(target);\n }\n}\n\n//# sourceURL=file://cloudcmd/client/modules/config/index.js\n}");
414
+ eval("{\n\n/* global CloudCmd, DOM, io */\n__webpack_require__(/*! ../../../css/config.css */ \"./css/config.css\");\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst squad = __webpack_require__(/*! squad */ \"./node_modules/squad/lib/squad.js\");\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst input = __webpack_require__(/*! ./input */ \"./client/modules/config/input.js\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\nconst Events = __webpack_require__(/*! ../../dom/events */ \"./client/dom/events/index.js\");\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\nconst {\n getTitle\n} = __webpack_require__(/*! ../../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst {\n Dialog,\n setTitle\n} = DOM;\nconst Name = 'Config';\nCloudCmd[Name] = module.exports;\nconst loadSocket = promisify(DOM.loadSocket);\nconst showLoad = () => {\n Images.show.load('top');\n};\nconst addKey = currify((fn, input) => {\n Events.addKey(input, fn);\n return input;\n});\nconst addChange = currify((fn, input) => {\n Events.add('change', input, fn);\n return input;\n});\nconst Config = {};\nlet Template;\nconst loadCSS = load.css;\nmodule.exports.init = async () => {\n if (!CloudCmd.config('configDialog')) return;\n showLoad();\n const {\n DIR_DIST\n } = CloudCmd;\n [Template] = await Promise.all([Files.get('config-tmpl'), loadSocket(), loadCSS(`${DIR_DIST}/config.css`), CloudCmd.View()]);\n initSocket();\n};\nconst {\n config,\n Key\n} = CloudCmd;\nlet Element;\nfunction getHost() {\n const {\n host,\n origin,\n protocol\n } = location;\n return origin || `${protocol}//${host}`;\n}\nfunction initSocket() {\n const href = getHost();\n const {\n prefixSocket,\n prefix\n } = CloudCmd;\n const ONE_MINUTE = 60 * 1000;\n const socket = io.connect(href + prefixSocket + '/config', {\n reconnectionAttempts: Infinity,\n reconnectionDelay: ONE_MINUTE,\n path: `${prefix}/socket.io`\n });\n const save = data => {\n onSave(data);\n socket.send(data);\n };\n authCheck(socket);\n socket.on('connect', () => {\n Config.save = save;\n });\n socket.on('message', onSave);\n socket.on('log', CloudCmd.log);\n socket.on('disconnect', () => {\n Config.save = saveHttp;\n });\n socket.on('err', Dialog.alert);\n}\nfunction authCheck(socket) {\n socket.emit('auth', config('username'), config('password'));\n socket.on('reject', wraptile(Dialog.alert, 'Wrong credentials!'));\n}\nConfig.save = saveHttp;\nmodule.exports.show = show;\nasync function show() {\n if (!CloudCmd.config('configDialog')) return;\n await fillTemplate();\n}\nasync function fillTemplate() {\n const [error, config] = await tryToCatch(Files.get, 'config');\n if (error) return Dialog.alert('Could not load config!');\n const {\n editor,\n menu,\n packer,\n columns,\n theme,\n configAuth,\n ...obj\n } = input.convert(config);\n obj[`${menu}-selected`] = 'selected';\n obj[`${editor}-selected`] = 'selected';\n obj[`${packer}-selected`] = 'selected';\n obj[`${columns}-selected`] = 'selected';\n obj[`${theme}-selected`] = 'selected';\n obj.configAuth = configAuth ? '' : 'hidden';\n const innerHTML = rendy(Template, obj);\n Element = createElement('form', {\n className: 'config',\n innerHTML\n });\n const inputs = document.querySelectorAll('input, select', Element);\n const [inputFirst] = inputs;\n let afterShow;\n if (inputFirst) {\n onAuthChange(inputFirst.checked);\n afterShow = inputFirst.focus.bind(inputFirst);\n }\n const getTarget = ({\n target\n }) => target;\n const handleChange = squad(onChange, getTarget);\n Array.from(inputs).map(addKey(onKey)).map(addChange(handleChange));\n const autoSize = true;\n CloudCmd.View.show(Element, {\n autoSize,\n afterShow\n });\n}\nmodule.exports.hide = hide;\nfunction hide() {\n CloudCmd.View.hide();\n}\nasync function onChange(el) {\n const obj = {};\n const name = input.getName(el);\n const data = input.getValue(name, Element);\n if (name === 'name') onNameChange(data);else if (name === 'auth') onAuthChange(data);\n obj[name] = data;\n await Config.save(obj);\n}\nfunction onSave(obj) {\n for (const name of Object.keys(obj)) {\n const data = obj[name];\n CloudCmd._config(name, data);\n input.setValue(name, data, Element);\n }\n}\nasync function saveHttp(obj) {\n const {\n RESTful\n } = DOM;\n const [e] = await RESTful.Config.write(obj);\n if (e) return;\n onSave(obj);\n}\nfunction onAuthChange(checked) {\n const elUsername = input.getElementByName('username', Element);\n const elPassword = input.getElementByName('password', Element);\n elUsername.disabled = !checked;\n elPassword.disabled = !checked;\n}\nfunction onNameChange(name) {\n setTitle(getTitle({\n name\n }));\n}\nasync function onKey({\n keyCode,\n target\n}) {\n switch (keyCode) {\n case Key.ESC:\n return hide();\n case Key.ENTER:\n return await onChange(target);\n }\n}\n\n//# sourceURL=file://cloudcmd/client/modules/config/index.js\n}");
415
415
 
416
416
  /***/ },
417
417
 
@@ -455,7 +455,7 @@ eval("{\n\n/* global CloudCmd */\nCloudCmd.EditFileVim = exports;\nconst Events
455
455
  (module, exports, __webpack_require__) {
456
456
 
457
457
  "use strict";
458
- eval("{\n\n/* global CloudCmd, DOM*/\nCloudCmd.EditFile = exports;\nconst Format = __webpack_require__(/*! format-io */ \"./node_modules/format-io/lib/format.js\");\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst supermenu = __webpack_require__(/*! supermenu */ \"./node_modules/supermenu/lib/supermenu.js\");\nconst Info = DOM.CurrentInfo;\nconst {\n Dialog,\n Images\n} = DOM;\nconst {\n config\n} = CloudCmd;\nlet Menu;\nlet MSG_CHANGED;\nconst isLoading = fullstore();\nconst ConfigView = {\n beforeClose: async () => {\n exec.ifExist(Menu, 'hide');\n await isChanged();\n }\n};\nmodule.exports.init = async () => {\n isLoading(true);\n await CloudCmd.Edit();\n const editor = CloudCmd.Edit.getEditor();\n authCheck(editor);\n setListeners(editor);\n isLoading(false);\n};\nfunction getName() {\n const {\n name,\n isDir\n } = Info;\n if (isDir) return `${name}.json`;\n return name;\n}\nmodule.exports.show = async options => {\n if (isLoading()) return;\n const optionsEdit = {\n ...ConfigView,\n ...options\n };\n if (CloudCmd.config('showFileName')) optionsEdit.title = Info.name;\n Images.show.load();\n CloudCmd.Edit.getEditor().setOption('keyMap', 'default');\n const [error, data] = await Info.getData();\n if (error) {\n Images.hide();\n return CloudCmd.Edit;\n }\n const {\n path\n } = Info;\n const name = getName();\n setMsgChanged(name);\n CloudCmd.Edit.getEditor().setValueFirst(path, data).setModeForPath(name).enableKey();\n CloudCmd.Edit.show(optionsEdit);\n return CloudCmd.Edit;\n};\nmodule.exports.hide = hide;\nfunction hide() {\n CloudCmd.Edit.hide();\n}\nfunction setListeners(editor) {\n const element = CloudCmd.Edit.getElement();\n DOM.Events.addOnce('contextmenu', element, setMenu);\n editor.on('save', value => {\n DOM.setCurrentSize(Format.size(value));\n });\n}\nfunction authCheck(spawn) {\n spawn.emit('auth', config('username'), config('password'));\n spawn.on('reject', () => {\n Dialog.alert('Wrong credentials!');\n });\n}\nfunction setMenu(event) {\n const position = {\n x: event.clientX,\n y: event.clientY\n };\n event.preventDefault();\n if (Menu) return;\n const options = {\n beforeShow: params => {\n params.x -= 18;\n params.y -= 27;\n },\n afterClick: () => {\n CloudCmd.Edit.getEditor().focus();\n }\n };\n const element = CloudCmd.Edit.getElement();\n Menu = supermenu(element, options, getMenuData());\n Menu.addContextMenuListener();\n Menu.show(position.x, position.y);\n}\nfunction getMenuData() {\n const editor = CloudCmd.Edit.getEditor();\n return {\n 'Save Ctrl+S': () => {\n editor.save();\n },\n 'Go To Line Ctrl+G': () => {\n editor.goToLine();\n },\n 'Cut Ctrl+X': () => {\n editor.cutToClipboard();\n },\n 'Copy Ctrl+C': () => {\n editor.copyToClipboard();\n },\n 'Paste Ctrl+V': () => {\n editor.pasteFromClipboard();\n },\n 'Delete Del': () => {\n editor.remove('right');\n },\n 'Select All Ctrl+A': () => {\n editor.selectAll();\n },\n 'Close Esc': hide\n };\n}\nfunction setMsgChanged(name) {\n MSG_CHANGED = `Do you want to save changes to ${name}?`;\n}\nmodule.exports.isChanged = isChanged;\nasync function isChanged() {\n const editor = CloudCmd.Edit.getEditor();\n const is = editor.isChanged();\n if (!is) return;\n const [cancel] = await Dialog.confirm(MSG_CHANGED);\n if (cancel) return;\n editor.save();\n}\n\n//# sourceURL=file://cloudcmd/client/modules/edit-file.js\n}");
458
+ eval("{\n\n/* global CloudCmd, DOM*/\nCloudCmd.EditFile = exports;\nconst Format = __webpack_require__(/*! format-io */ \"./node_modules/format-io/lib/format.js\");\nconst {\n fullstore\n} = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.cjs\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst supermenu = __webpack_require__(/*! supermenu */ \"./node_modules/supermenu/lib/supermenu.js\");\nconst Info = DOM.CurrentInfo;\nconst {\n Dialog,\n Images\n} = DOM;\nconst {\n config\n} = CloudCmd;\nlet Menu;\nlet MSG_CHANGED;\nconst isLoading = fullstore();\nconst ConfigView = {\n beforeClose: async () => {\n exec.ifExist(Menu, 'hide');\n await isChanged();\n }\n};\nmodule.exports.init = async () => {\n isLoading(true);\n await CloudCmd.Edit();\n const editor = CloudCmd.Edit.getEditor();\n authCheck(editor);\n setListeners(editor);\n isLoading(false);\n};\nfunction getName() {\n const {\n name,\n isDir\n } = Info;\n if (isDir) return `${name}.json`;\n return name;\n}\nmodule.exports.show = async options => {\n if (isLoading()) return;\n const optionsEdit = {\n ...ConfigView,\n ...options\n };\n if (CloudCmd.config('showFileName')) optionsEdit.title = Info.name;\n Images.show.load();\n CloudCmd.Edit.getEditor().setOption('keyMap', 'default');\n const [error, data] = await Info.getData();\n if (error) {\n Images.hide();\n return CloudCmd.Edit;\n }\n const {\n path\n } = Info;\n const name = getName();\n setMsgChanged(name);\n CloudCmd.Edit.getEditor().setValueFirst(path, data).setModeForPath(name).enableKey();\n CloudCmd.Edit.show(optionsEdit);\n return CloudCmd.Edit;\n};\nmodule.exports.hide = hide;\nfunction hide() {\n CloudCmd.Edit.hide();\n}\nfunction setListeners(editor) {\n const element = CloudCmd.Edit.getElement();\n DOM.Events.addOnce('contextmenu', element, setMenu);\n editor.on('save', value => {\n DOM.setCurrentSize(Format.size(value));\n });\n}\nfunction authCheck(spawn) {\n spawn.emit('auth', config('username'), config('password'));\n spawn.on('reject', () => {\n Dialog.alert('Wrong credentials!');\n });\n}\nfunction setMenu(event) {\n const position = {\n x: event.clientX,\n y: event.clientY\n };\n event.preventDefault();\n if (Menu) return;\n const options = {\n beforeShow: params => {\n params.x -= 18;\n params.y -= 27;\n },\n afterClick: () => {\n CloudCmd.Edit.getEditor().focus();\n }\n };\n const element = CloudCmd.Edit.getElement();\n Menu = supermenu(element, options, getMenuData());\n Menu.addContextMenuListener();\n Menu.show(position.x, position.y);\n}\nfunction getMenuData() {\n const editor = CloudCmd.Edit.getEditor();\n return {\n 'Save Ctrl+S': () => {\n editor.save();\n },\n 'Go To Line Ctrl+G': () => {\n editor.goToLine();\n },\n 'Cut Ctrl+X': () => {\n editor.cutToClipboard();\n },\n 'Copy Ctrl+C': () => {\n editor.copyToClipboard();\n },\n 'Paste Ctrl+V': () => {\n editor.pasteFromClipboard();\n },\n 'Delete Del': () => {\n editor.remove('right');\n },\n 'Select All Ctrl+A': () => {\n editor.selectAll();\n },\n 'Close Esc': hide\n };\n}\nfunction setMsgChanged(name) {\n MSG_CHANGED = `Do you want to save changes to ${name}?`;\n}\nmodule.exports.isChanged = isChanged;\nasync function isChanged() {\n const editor = CloudCmd.Edit.getEditor();\n const is = editor.isChanged();\n if (!is) return;\n const [cancel] = await Dialog.confirm(MSG_CHANGED);\n if (cancel) return;\n editor.save();\n}\n\n//# sourceURL=file://cloudcmd/client/modules/edit-file.js\n}");
459
459
 
460
460
  /***/ },
461
461
 
@@ -488,7 +488,7 @@ eval("{\n\n/* global CloudCmd, DOM */\nCloudCmd.EditNames = exports;\nconst curr
488
488
  (module, exports, __webpack_require__) {
489
489
 
490
490
  "use strict";
491
- eval("{/* global CloudCmd */\n\n\n\nconst montag = __webpack_require__(/*! montag */ \"./node_modules/montag/lib/montag.js\");\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n MAX_FILE_SIZE: maxSize\n} = __webpack_require__(/*! ../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst {\n time,\n timeEnd\n} = __webpack_require__(/*! ../../common/util */ \"./common/util.js\");\nconst getEditor = () => editor;\nconst isFn = a => typeof a === 'function';\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};\nmodule.exports.init = async () => {\n const element = create();\n await CloudCmd.View();\n await loadFiles(element);\n};\nfunction create() {\n const element = createElement('div', {\n style: montag`\n width: 100%;\n height: 100%;\n font-family: \"Droid Sans Mono\";\n `,\n notAppend: true\n });\n Element = element;\n return element;\n}\nfunction checkFn(name, fn) {\n if (!isFn(fn)) throw Error(`${name} should be a function!`);\n}\nfunction initConfig(options = {}) {\n const config = {\n ...options,\n ...ConfigView\n };\n if (!options.afterShow) return config;\n checkFn('options.afterShow', options.afterShow);\n config.afterShow = () => {\n ConfigView.afterShow();\n options.afterShow();\n };\n return config;\n}\nmodule.exports.show = options => {\n if (Loading) return;\n CloudCmd.View.show(Element, initConfig(options));\n getEditor().setOptions({\n fontSize: 16\n });\n};\nmodule.exports.getEditor = getEditor;\nmodule.exports.getElement = () => Element;\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\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\n}");
491
+ eval("{/* global CloudCmd */\n\n\n\nconst montag = __webpack_require__(/*! montag */ \"./node_modules/montag/lib/montag.js\");\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n MAX_FILE_SIZE: maxSize\n} = __webpack_require__(/*! ../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst {\n time,\n timeEnd\n} = __webpack_require__(/*! ../../common/util */ \"./common/util.js\");\nconst getEditor = () => editor;\nconst isFn = a => typeof a === 'function';\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};\nmodule.exports.init = async () => {\n const element = create();\n await CloudCmd.View();\n await loadFiles(element);\n};\nfunction create() {\n const element = createElement('div', {\n style: montag`\n width: 100%;\n height: 100%;\n font-family: \"Droid Sans Mono\";\n `,\n notAppend: true\n });\n Element = element;\n return element;\n}\nfunction checkFn(name, fn) {\n if (!isFn(fn)) throw Error(`${name} should be a function!`);\n}\nfunction initConfig(options = {}) {\n const config = {\n ...options,\n ...ConfigView\n };\n if (!options.afterShow) return config;\n checkFn('options.afterShow', options.afterShow);\n config.afterShow = () => {\n ConfigView.afterShow();\n options.afterShow();\n };\n return config;\n}\nmodule.exports.show = options => {\n if (Loading) return;\n CloudCmd.View.show(Element, initConfig(options));\n getEditor().setOptions({\n fontSize: 16\n });\n};\nmodule.exports.getEditor = getEditor;\nmodule.exports.getElement = () => Element;\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\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\n}");
492
492
 
493
493
  /***/ },
494
494
 
@@ -510,7 +510,7 @@ eval("{\n\n/* global CloudCmd */\nCloudCmd.Help = exports;\nconst Images = __web
510
510
  (module, exports, __webpack_require__) {
511
511
 
512
512
  "use strict";
513
- eval("{\n\n/* global CloudCmd */\n/* global Util */\n/* global DOM */\n/* global Console */\nCloudCmd.Konsole = exports;\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst loadJS = (__webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\").js);\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.js\");\nconst {\n Dialog,\n CurrentInfo: Info\n} = DOM;\nconst rmLastSlash = a => a.replace(/\\/$/, '') || '/';\nlet konsole;\nconst {\n config\n} = CloudCmd;\nconst cd = currify((fn, dir) => fn(`cd ${rmLastSlash(dir)}`));\nconst Name = 'Konsole';\nlet Element;\nlet Loaded;\nmodule.exports.init = async () => {\n if (!config('console')) return;\n Images.show.load('top');\n await CloudCmd.View();\n await load();\n await create();\n};\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\nmodule.exports.clear = () => {\n konsole.clear();\n};\nconst getPrefix = () => CloudCmd.prefix + '/console';\nfunction getPrefixSocket() {\n return CloudCmd.prefixSocket + '/console';\n}\nconst getEnv = () => ({\n ACTIVE_DIR: DOM.getCurrentDirPath.bind(DOM),\n PASSIVE_DIR: DOM.getNotCurrentDirPath.bind(DOM),\n CURRENT_NAME: DOM.getCurrentName.bind(DOM),\n CURRENT_PATH: () => Info.path\n});\nasync function onPath(path) {\n if (Info.dirPath === path) return;\n await CloudCmd.changeDir(path);\n}\nconst getDirPath = () => {\n if (config('syncConsolePath')) return Info.dirPath;\n};\nconst create = async () => {\n const options = {\n cwd: getDirPath(),\n env: getEnv(),\n prefix: getPrefix(),\n prefixSocket: getPrefixSocket(),\n socketPath: CloudCmd.prefix\n };\n Element = createElement('div', {\n className: 'console'\n });\n konsole = await Console(Element, options);\n konsole.on('connect', exec.with(authCheck, konsole));\n konsole.on('path', config.if('syncConsolePath', onPath));\n CloudCmd.on('active-dir', config.if('syncConsolePath', cd(konsole.handler)));\n konsole.addShortCuts({\n P: () => {\n const command = konsole.getPromptText();\n const path = DOM.getCurrentDirPath();\n konsole.setPromptText(command + path);\n }\n });\n};\nfunction authCheck(konsole) {\n konsole.emit('auth', config('username'), config('password'));\n konsole.on('reject', () => {\n Dialog.alert('Wrong credentials!');\n });\n}\nmodule.exports.show = callback => {\n if (!Loaded) return;\n if (!config('console')) return;\n CloudCmd.View.show(Element, {\n afterShow: () => {\n konsole.focus();\n exec(callback);\n }\n });\n};\nconst load = async () => {\n Util.time(`${Name} load`);\n const prefix = getPrefix();\n const url = `${prefix}/console.js`;\n const [error] = await tryToCatch(loadJS, url);\n Loaded = true;\n Util.timeEnd(`${Name} load`);\n if (error) return Dialog.alert(error.message, {\n cancel: false\n });\n};\n\n//# sourceURL=file://cloudcmd/client/modules/konsole.js\n}");
513
+ eval("{\n\n/* global CloudCmd */\n/* global Util */\n/* global DOM */\n/* global Console */\nCloudCmd.Konsole = exports;\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst loadJS = (__webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\").js);\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.js\");\nconst {\n Dialog,\n CurrentInfo: Info\n} = DOM;\nconst rmLastSlash = a => a.replace(/\\/$/, '') || '/';\nlet konsole;\nconst {\n config\n} = CloudCmd;\nconst cd = currify((fn, dir) => fn(`cd ${rmLastSlash(dir)}`));\nconst Name = 'Konsole';\nlet Element;\nlet Loaded;\nmodule.exports.init = async () => {\n if (!config('console')) return;\n Images.show.load('top');\n await CloudCmd.View();\n await load();\n await create();\n};\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\nmodule.exports.clear = () => {\n konsole.clear();\n};\nconst getPrefix = () => CloudCmd.prefix + '/console';\nfunction getPrefixSocket() {\n return CloudCmd.prefixSocket + '/console';\n}\nconst getEnv = () => ({\n ACTIVE_DIR: DOM.getCurrentDirPath.bind(DOM),\n PASSIVE_DIR: DOM.getNotCurrentDirPath.bind(DOM),\n CURRENT_NAME: DOM.getCurrentName.bind(DOM),\n CURRENT_PATH: () => Info.path\n});\nasync function onPath(path) {\n if (Info.dirPath === path) return;\n await CloudCmd.changeDir(path);\n}\nconst getDirPath = () => {\n if (config('syncConsolePath')) return Info.dirPath;\n};\nconst create = async () => {\n const options = {\n cwd: getDirPath(),\n env: getEnv(),\n prefix: getPrefix(),\n prefixSocket: getPrefixSocket(),\n socketPath: CloudCmd.prefix\n };\n Element = createElement('div', {\n className: 'console'\n });\n konsole = await Console(Element, options);\n konsole.on('connect', exec.with(authCheck, konsole));\n konsole.on('path', config.if('syncConsolePath', onPath));\n CloudCmd.on('active-dir', config.if('syncConsolePath', cd(konsole.handler)));\n konsole.addShortCuts({\n P: () => {\n const command = konsole.getPromptText();\n const path = DOM.getCurrentDirPath();\n konsole.setPromptText(command + path);\n }\n });\n};\nfunction authCheck(konsole) {\n konsole.emit('auth', config('username'), config('password'));\n konsole.on('reject', () => {\n Dialog.alert('Wrong credentials!');\n });\n}\nmodule.exports.show = callback => {\n if (!Loaded) return;\n if (!config('console')) return;\n CloudCmd.View.show(Element, {\n afterShow: () => {\n konsole.focus();\n exec(callback);\n }\n });\n};\nconst load = async () => {\n Util.time(`${Name} load`);\n const prefix = getPrefix();\n const url = `${prefix}/console.js`;\n const [error] = await tryToCatch(loadJS, url);\n Loaded = true;\n Util.timeEnd(`${Name} load`);\n if (error) return Dialog.alert(error.message, {\n cancel: false\n });\n};\n\n//# sourceURL=file://cloudcmd/client/modules/konsole.js\n}");
514
514
 
515
515
  /***/ },
516
516
 
@@ -576,7 +576,7 @@ eval("{\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/c
576
576
  (module, exports, __webpack_require__) {
577
577
 
578
578
  "use strict";
579
- eval("{/* global CloudCmd */\n/* global Util */\n/* global DOM */\n/* global fileop */\n\n\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\nconst removeExtension = __webpack_require__(/*! ./remove-extension */ \"./client/modules/operation/remove-extension.js\");\nconst setListeners = __webpack_require__(/*! ./set-listeners */ \"./client/modules/operation/set-listeners.js\");\nconst getNextCurrentName = __webpack_require__(/*! ./get-next-current-name */ \"./client/modules/operation/get-next-current-name.js\");\nconst removeQuery = a => a.replace(/\\?.*/, '');\nconst Name = 'Operation';\nCloudCmd[Name] = exports;\nconst {\n config\n} = CloudCmd;\nconst {\n Dialog,\n Images\n} = DOM;\nconst authCheck = wraptile(_authCheck);\nconst Operation = {};\nlet Loaded;\nlet copyFn;\nlet moveFn;\nlet deleteFn;\nlet extractFn;\nlet packZipFn;\nlet packTarFn;\nconst Info = DOM.CurrentInfo;\nconst showLoad = Images.show.load.bind(null, 'top');\nconst processFiles = currify(_processFiles);\nconst noFilesCheck = () => {\n const {\n length\n } = DOM.getActiveFiles();\n const is = Boolean(!length);\n if (is) return Dialog.alert.noFiles();\n return is;\n};\nmodule.exports.init = promisify(callback => {\n showLoad();\n exec.series([DOM.loadSocket, async callback => {\n if (config('dropbox')) return callback();\n const {\n prefix,\n prefixSocket\n } = CloudCmd;\n await loadAll();\n await initOperations(prefix, prefixSocket, callback);\n }, callback => {\n Loaded = true;\n Images.hide();\n callback();\n }], callback);\n});\nfunction _authCheck(spawn, ok) {\n const accept = wraptile(ok);\n const alertDialog = wraptile(Dialog.alert);\n spawn.on('accept', accept(spawn));\n spawn.on('reject', alertDialog('Wrong credentials!'));\n spawn.emit('auth', config('username'), config('password'));\n}\nconst onConnect = currify((fn, operator) => {\n setOperations(operator);\n fn();\n});\nasync function initOperations(prefix, socketPrefix, fn) {\n socketPrefix = `${socketPrefix}/fileop`;\n const operator = await fileop({\n prefix,\n socketPrefix\n });\n operator.on('connect', authCheck(operator, onConnect(fn)));\n}\nfunction setOperations(operator) {\n packTarFn = ({\n from,\n to,\n names\n }, callback) => {\n const operation = 'Tar';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.tar(from, to, names).then(listen);\n };\n packZipFn = ({\n from,\n to,\n names\n }, callback) => {\n const operation = 'Zip';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.zip(from, to, names).then(listen);\n };\n deleteFn = (from, files, callback) => {\n from = removeQuery(from);\n const operation = 'Delete';\n const listen = setListeners({\n operation,\n callback,\n from\n });\n operator.remove(from, files).then(listen);\n };\n copyFn = ({\n from,\n to,\n names\n }, callback) => {\n const operation = 'Copy';\n const listen = setListeners({\n operation,\n callback,\n from,\n to,\n names\n });\n operator.copy(from, to, names).then(listen);\n };\n moveFn = ({\n from,\n to,\n names\n }, callback) => {\n const operation = 'Move';\n const listen = setListeners({\n operation,\n callback,\n from,\n to\n });\n operator.move(from, to, names).then(listen);\n };\n extractFn = ({\n from,\n to\n }, callback) => {\n const operation = 'Extract';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.extract(from, to).then(listen);\n };\n}\nfunction getPacker(type) {\n if (type === 'zip') return packZipFn;\n return packTarFn;\n}\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\nmodule.exports.show = (operation, data) => {\n if (!Loaded) return;\n if (operation === 'copy') return Operation.copy(data);\n if (operation === 'move') return Operation.move(data);\n if (operation === 'delete') return Operation.delete();\n if (operation === 'delete:silent') return Operation.deleteSilent();\n if (operation === 'pack') return Operation.pack();\n if (operation === 'extract') return Operation.extract();\n};\nOperation.copy = processFiles({\n type: 'copy'\n});\nOperation.move = processFiles({\n type: 'move'\n});\nOperation.delete = promptDelete;\nOperation.deleteSilent = deleteSilent;\nOperation.pack = () => {\n const isZip = config('packer') === 'zip';\n twopack('pack', isZip ? 'zip' : 'tar');\n};\nOperation.extract = () => {\n twopack('extract');\n};\n\n/**\n * prompt and delete current file or selected files\n *\n * @currentFile\n */\nasync function promptDelete() {\n if (noFilesCheck()) return;\n const msgAsk = 'Do you really want to delete the ';\n const msgSel = 'selected ';\n const files = DOM.getActiveFiles();\n const names = DOM.getFilenames(files);\n const n = names.length;\n let msg;\n if (n) {\n let name = '';\n for (let i = 0; i < 5 && i < n; i++) name += '\\n' + names[i];\n if (n >= 5) name += '\\n...';\n msg = msgAsk + msgSel + n + ' files/directories?\\n' + encode(name);\n } else {\n const current = DOM.getCurrentFile();\n const isDir = DOM.isCurrentIsDir(current);\n const getType = isDir => isDir ? 'directory' : 'file';\n const type = getType(isDir) + ' ';\n const name = DOM.getCurrentName(current);\n msg = msgAsk + msgSel + type + name + '?';\n }\n const [cancel] = await Dialog.confirm(msg);\n if (cancel) return;\n deleteSilent(files);\n}\n\n/**\n * delete current or selected files\n *\n * @files\n */\nfunction deleteSilent(files = DOM.getActiveFiles()) {\n const query = '?files';\n const path = Info.dirPath;\n if (noFilesCheck()) return;\n showLoad();\n const removedNames = DOM.getFilenames(files);\n const names = DOM.CurrentInfo.files.map(DOM.getCurrentName);\n const currentName = DOM.getCurrentName();\n const nextCurrentName = getNextCurrentName(currentName, names, removedNames);\n deleteFn(path + query, removedNames, async () => {\n await CloudCmd.refresh();\n const names = Info.files.map(DOM.getCurrentName);\n const isCurrent = names.includes(currentName);\n const name = isCurrent ? currentName : nextCurrentName;\n DOM.setCurrentByName(name);\n });\n}\n\n/*\n * process files (copy or move)\n * @param data\n * @param operation\n */\nasync function _processFiles(options, data) {\n let selFiles;\n let files;\n let panel;\n let shouldAsk;\n let ok;\n let from = '';\n let to = '';\n let names = [];\n if (data) {\n ({\n from,\n to,\n names\n } = data);\n ({\n panel\n } = Info);\n } else {\n from = Info.dirPath;\n to = DOM.getNotCurrentDirPath();\n selFiles = DOM.getSelectedFiles();\n names = DOM.getFilenames(selFiles);\n data = {};\n shouldAsk = true;\n panel = Info.panelPassive;\n }\n if (!names.length) names.push(DOM.getCurrentName());\n const [name] = names;\n const sameName = DOM.getCurrentByName(name, panel);\n if (!data && noFilesCheck()) return;\n const {\n type\n } = options;\n const isCopy = type === 'copy';\n const option = isCopy ? 'confirmCopy' : 'confirmMove';\n const title = isCopy ? 'Copy' : 'Rename/Move';\n const operation = isCopy ? copyFn : moveFn;\n if (shouldAsk && config(option)) {\n const [cancel, newTo] = await prompt(title, to, names.map(encode));\n if (!cancel) ask(newTo);\n return;\n }\n ask(to);\n function ask(to) {\n ok = from !== to && to;\n if (ok && !shouldAsk || !sameName) return go();\n const str = `\"${name}\" already exist. Overwrite?`;\n const cancel = false;\n Dialog.confirm(str, {\n cancel\n }).then(go);\n function go() {\n showLoad();\n files = {\n from,\n to,\n names\n };\n operation(files, async () => {\n await DOM.Storage.remove(from);\n const {\n panel,\n panelPassive\n } = Info;\n if (!Info.isOnePanel) CloudCmd.refresh({\n panel: panelPassive,\n noCurrent: true\n });\n CloudCmd.refresh({\n panel\n });\n });\n }\n }\n}\nfunction checkEmpty(name, operation) {\n if (!operation) throw Error(`${name} could not be empty!`);\n}\nfunction twopack(operation, type) {\n let op;\n let fileFrom;\n let currentName = Info.name;\n const {\n path,\n dirPath\n } = Info;\n const activeFiles = DOM.getActiveFiles();\n const names = DOM.getFilenames(activeFiles);\n checkEmpty('operation', operation);\n if (!names.length) return Dialog.alert.noFiles();\n switch (operation) {\n case 'extract':\n op = extractFn;\n fileFrom = {\n from: path,\n to: dirPath\n };\n currentName = removeExtension(currentName);\n break;\n case 'pack':\n op = getPacker(type);\n if (names.length > 1) currentName = Info.dir;\n currentName += DOM.getPackerExt(type);\n fileFrom = {\n from: dirPath,\n to: dirPath + currentName,\n names\n };\n break;\n }\n showLoad();\n op(fileFrom, error => {\n !error && CloudCmd.refresh({\n currentName\n });\n });\n}\nasync function prompt(msg, to, names) {\n const n = names.length;\n const [name] = names;\n msg += ' ';\n if (names.length > 1) msg += `${n} file(s)`;else msg += `\"${name}\"`;\n msg += ' to';\n return await Dialog.prompt(msg, to);\n}\nasync function loadAll() {\n const {\n prefix\n } = CloudCmd;\n const file = `${prefix}/fileop/fileop.js`;\n const [error] = await tryToCatch(load.js, file);\n if (error) Dialog.alert(error.message);\n Loaded = true;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/operation/index.js\n}");
579
+ eval("{/* global CloudCmd */\n/* global Util */\n/* global DOM */\n/* global fileop */\n\n\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\nconst removeExtension = __webpack_require__(/*! ./remove-extension */ \"./client/modules/operation/remove-extension.js\");\nconst setListeners = __webpack_require__(/*! ./set-listeners */ \"./client/modules/operation/set-listeners.js\");\nconst getNextCurrentName = __webpack_require__(/*! ./get-next-current-name */ \"./client/modules/operation/get-next-current-name.js\");\nconst removeQuery = a => a.replace(/\\?.*/, '');\nconst Name = 'Operation';\nCloudCmd[Name] = exports;\nconst {\n config\n} = CloudCmd;\nconst {\n Dialog,\n Images\n} = DOM;\nconst authCheck = wraptile(_authCheck);\nconst Operation = {};\nlet Loaded;\nlet copyFn;\nlet moveFn;\nlet deleteFn;\nlet extractFn;\nlet packZipFn;\nlet packTarFn;\nconst Info = DOM.CurrentInfo;\nconst showLoad = Images.show.load.bind(null, 'top');\nconst processFiles = currify(_processFiles);\nconst noFilesCheck = () => {\n const {\n length\n } = DOM.getActiveFiles();\n const is = Boolean(!length);\n if (is) return Dialog.alert.noFiles();\n return is;\n};\nmodule.exports.init = promisify(callback => {\n showLoad();\n exec.series([DOM.loadSocket, async callback => {\n if (config('dropbox')) return callback();\n const {\n prefix,\n prefixSocket\n } = CloudCmd;\n await loadAll();\n await initOperations(prefix, prefixSocket, callback);\n }, callback => {\n Loaded = true;\n Images.hide();\n callback();\n }], callback);\n});\nfunction _authCheck(spawn, ok) {\n const accept = wraptile(ok);\n const alertDialog = wraptile(Dialog.alert);\n spawn.on('accept', accept(spawn));\n spawn.on('reject', alertDialog('Wrong credentials!'));\n spawn.emit('auth', config('username'), config('password'));\n}\nconst onConnect = currify((fn, operator) => {\n setOperations(operator);\n fn();\n});\nasync function initOperations(prefix, socketPrefix, fn) {\n socketPrefix = `${socketPrefix}/fileop`;\n const operator = await fileop({\n prefix,\n socketPrefix\n });\n operator.on('connect', authCheck(operator, onConnect(fn)));\n}\nfunction setOperations(operator) {\n packTarFn = ({\n from,\n to,\n names\n }, callback) => {\n const operation = 'Tar';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.tar(from, to, names).then(listen);\n };\n packZipFn = ({\n from,\n to,\n names\n }, callback) => {\n const operation = 'Zip';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.zip(from, to, names).then(listen);\n };\n deleteFn = (from, files, callback) => {\n from = removeQuery(from);\n const operation = 'Delete';\n const listen = setListeners({\n operation,\n callback,\n from\n });\n operator.remove(from, files).then(listen);\n };\n copyFn = ({\n from,\n to,\n names\n }, callback) => {\n const operation = 'Copy';\n const listen = setListeners({\n operation,\n callback,\n from,\n to,\n names\n });\n operator.copy(from, to, names).then(listen);\n };\n moveFn = ({\n from,\n to,\n names\n }, callback) => {\n const operation = 'Move';\n const listen = setListeners({\n operation,\n callback,\n from,\n to\n });\n operator.move(from, to, names).then(listen);\n };\n extractFn = ({\n from,\n to\n }, callback) => {\n const operation = 'Extract';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.extract(from, to).then(listen);\n };\n}\nfunction getPacker(type) {\n if (type === 'zip') return packZipFn;\n return packTarFn;\n}\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\nmodule.exports.show = (operation, data) => {\n if (!Loaded) return;\n if (operation === 'copy') return Operation.copy(data);\n if (operation === 'move') return Operation.move(data);\n if (operation === 'delete') return Operation.delete();\n if (operation === 'delete:silent') return Operation.deleteSilent();\n if (operation === 'pack') return Operation.pack();\n if (operation === 'extract') return Operation.extract();\n};\nOperation.copy = processFiles({\n type: 'copy'\n});\nOperation.move = processFiles({\n type: 'move'\n});\nOperation.delete = promptDelete;\nOperation.deleteSilent = deleteSilent;\nOperation.pack = () => {\n const isZip = config('packer') === 'zip';\n twopack('pack', isZip ? 'zip' : 'tar');\n};\nOperation.extract = () => {\n twopack('extract');\n};\n\n/**\n * prompt and delete current file or selected files\n *\n * @currentFile\n */\nasync function promptDelete() {\n if (noFilesCheck()) return;\n const msgAsk = 'Do you really want to delete the ';\n const msgSel = 'selected ';\n const files = DOM.getActiveFiles();\n const names = DOM.getFilenames(files);\n const n = names.length;\n let msg;\n if (n) {\n let name = '';\n for (let i = 0; i < 5 && i < n; i++) name += '\\n' + names[i];\n if (n >= 5) name += '\\n...';\n msg = msgAsk + msgSel + n + ' files/directories?\\n' + encode(name);\n } else {\n const current = DOM.getCurrentFile();\n const isDir = DOM.isCurrentIsDir(current);\n const getType = isDir => isDir ? 'directory' : 'file';\n const type = getType(isDir) + ' ';\n const name = DOM.getCurrentName(current);\n msg = msgAsk + msgSel + type + name + '?';\n }\n const [cancel] = await Dialog.confirm(msg);\n if (cancel) return;\n deleteSilent(files);\n}\n\n/**\n * delete current or selected files\n *\n * @files\n */\nfunction deleteSilent(files = DOM.getActiveFiles()) {\n const query = '?files';\n const path = Info.dirPath;\n if (noFilesCheck()) return;\n showLoad();\n const removedNames = DOM.getFilenames(files);\n const names = DOM.CurrentInfo.files.map(DOM.getCurrentName);\n const currentName = DOM.getCurrentName();\n const nextCurrentName = getNextCurrentName(currentName, names, removedNames);\n deleteFn(path + query, removedNames, async () => {\n await CloudCmd.refresh();\n const names = Info.files.map(DOM.getCurrentName);\n const isCurrent = names.includes(currentName);\n const name = isCurrent ? currentName : nextCurrentName;\n DOM.setCurrentByName(name);\n });\n}\n\n/*\n * process files (copy or move)\n * @param data\n * @param operation\n */\nasync function _processFiles(options, data) {\n let selFiles;\n let files;\n let panel;\n let shouldAsk;\n let ok;\n let from = '';\n let to = '';\n let names = [];\n if (data) {\n ({\n from,\n to,\n names\n } = data);\n ({\n panel\n } = Info);\n } else {\n from = Info.dirPath;\n to = DOM.getNotCurrentDirPath();\n selFiles = DOM.getSelectedFiles();\n names = DOM.getFilenames(selFiles);\n data = {};\n shouldAsk = true;\n panel = Info.panelPassive;\n }\n if (!names.length) names.push(DOM.getCurrentName());\n const [name] = names;\n const sameName = DOM.getCurrentByName(name, panel);\n if (!data && noFilesCheck()) return;\n const {\n type\n } = options;\n const isCopy = type === 'copy';\n const option = isCopy ? 'confirmCopy' : 'confirmMove';\n const title = isCopy ? 'Copy' : 'Rename/Move';\n const operation = isCopy ? copyFn : moveFn;\n if (shouldAsk && config(option)) {\n const [cancel, newTo] = await prompt(title, to, names.map(encode));\n if (!cancel) ask(newTo);\n return;\n }\n ask(to);\n function ask(to) {\n ok = from !== to && to;\n if (ok && !shouldAsk || !sameName) return go();\n const str = `\"${name}\" already exist. Overwrite?`;\n const cancel = false;\n Dialog.confirm(str, {\n cancel\n }).then(go);\n function go() {\n showLoad();\n files = {\n from,\n to,\n names\n };\n operation(files, async () => {\n await DOM.Storage.remove(from);\n const {\n panel,\n panelPassive\n } = Info;\n if (!Info.isOnePanel) CloudCmd.refresh({\n panel: panelPassive,\n noCurrent: true\n });\n CloudCmd.refresh({\n panel\n });\n });\n }\n }\n}\nfunction checkEmpty(name, operation) {\n if (!operation) throw Error(`${name} could not be empty!`);\n}\nfunction twopack(operation, type) {\n let op;\n let fileFrom;\n let currentName = Info.name;\n const {\n path,\n dirPath\n } = Info;\n const activeFiles = DOM.getActiveFiles();\n const names = DOM.getFilenames(activeFiles);\n checkEmpty('operation', operation);\n if (!names.length) return Dialog.alert.noFiles();\n switch (operation) {\n case 'extract':\n op = extractFn;\n fileFrom = {\n from: path,\n to: dirPath\n };\n currentName = removeExtension(currentName);\n break;\n case 'pack':\n op = getPacker(type);\n if (names.length > 1) currentName = Info.dir;\n currentName += DOM.getPackerExt(type);\n fileFrom = {\n from: dirPath,\n to: dirPath + currentName,\n names\n };\n break;\n }\n showLoad();\n op(fileFrom, error => {\n !error && CloudCmd.refresh({\n currentName\n });\n });\n}\nasync function prompt(msg, to, names) {\n const n = names.length;\n const [name] = names;\n msg += ' ';\n if (names.length > 1) msg += `${n} file(s)`;else msg += `\"${name}\"`;\n msg += ' to';\n return await Dialog.prompt(msg, to);\n}\nasync function loadAll() {\n const {\n prefix\n } = CloudCmd;\n const file = `${prefix}/fileop/fileop.js`;\n const [error] = await tryToCatch(load.js, file);\n if (error) Dialog.alert(error.message);\n Loaded = true;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/operation/index.js\n}");
580
580
 
581
581
  /***/ },
582
582
 
@@ -587,7 +587,7 @@ eval("{/* global CloudCmd */\n/* global Util */\n/* global DOM */\n/* global fil
587
587
  (module, __unused_webpack_exports, __webpack_require__) {
588
588
 
589
589
  "use strict";
590
- eval("{\n\nconst {\n getExt\n} = __webpack_require__(/*! ../../../common/util */ \"./common/util.js\");\nmodule.exports = name => {\n const ext = getExtension(name);\n return name.replace(ext, '');\n};\nfunction getExtension(name) {\n if (/\\.tar\\.gz$/.test(name)) return '.tar.gz';\n if (/\\.tar\\.bz2$/.test(name)) return '.tar.bz2';\n return getExt(name);\n}\n\n//# sourceURL=file://cloudcmd/client/modules/operation/remove-extension.js\n}");
590
+ eval("{\n\nconst {\n getExt\n} = __webpack_require__(/*! ../../../common/util */ \"./common/util.js\");\nmodule.exports = name => {\n const ext = getExtension(name);\n return name.replace(ext, '');\n};\nfunction getExtension(name) {\n if (name.endsWith('.tar.gz')) return '.tar.gz';\n if (name.endsWith('.tar.bz2')) return '.tar.bz2';\n return getExt(name);\n}\n\n//# sourceURL=file://cloudcmd/client/modules/operation/remove-extension.js\n}");
591
591
 
592
592
  /***/ },
593
593
 
@@ -620,7 +620,7 @@ eval("{\n\n/* global DOM */\n__webpack_require__(/*! domtokenlist-shim */ \"./no
620
620
  (module, exports, __webpack_require__) {
621
621
 
622
622
  "use strict";
623
- eval("{\n\n/* global CloudCmd, gritty */\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n__webpack_require__(/*! ../../css/terminal.css */ \"./css/terminal.css\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst DOM = __webpack_require__(/*! ../dom */ \"./client/dom/index.js\");\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.js\");\nconst {\n Dialog\n} = DOM;\nconst {\n Key,\n config\n} = CloudCmd;\nCloudCmd.TerminalRun = exports;\nlet Loaded;\nlet Terminal;\nlet Socket;\nconst exitCodeStore = fullstore();\nconst loadAll = async () => {\n const {\n prefix\n } = CloudCmd;\n const prefixGritty = getPrefix();\n const js = `${prefixGritty}/gritty.js`;\n const css = `${prefix}/dist/terminal.css`;\n const [e] = await tryToCatch(load.parallel, [js, css]);\n if (e) {\n const src = e.target.src.replace(window.location.href, '');\n return Dialog.alert(`file ${src} could not be loaded`);\n }\n Loaded = true;\n};\nmodule.exports.init = async () => {\n if (!config('terminal')) return;\n Images.show.load('top');\n await CloudCmd.View();\n await loadAll();\n};\nmodule.exports.show = promisify((options = {}, fn) => {\n if (!Loaded) return fn(null, -1);\n if (!config('terminal')) return;\n create(options);\n CloudCmd.View.show(Terminal.element, {\n afterShow: () => {\n Terminal.focus();\n },\n afterClose: (/* exec.series args */\n ) => {\n fn(null, exitCodeStore());\n }\n });\n});\nmodule.exports.hide = hide;\nfunction hide() {\n CloudCmd.View.hide();\n}\nconst getPrefix = () => CloudCmd.prefix + '/gritty';\nfunction getPrefixSocket() {\n return CloudCmd.prefixSocket + '/gritty';\n}\nconst getEnv = () => ({\n ACTIVE_DIR: DOM.getCurrentDirPath,\n PASSIVE_DIR: DOM.getNotCurrentDirPath,\n CURRENT_NAME: DOM.getCurrentName,\n CURRENT_PATH: DOM.getCurrentPath\n});\nfunction create(createOptions) {\n const {\n cwd = DOM.getCurrentDirPath(),\n command,\n autoClose,\n closeMessage = 'Press any key to close Terminal...'\n } = createOptions;\n const options = {\n cwd,\n env: getEnv(),\n prefix: getPrefixSocket(),\n socketPath: CloudCmd.prefix,\n fontFamily: 'Droid Sans Mono',\n command,\n autoRestart: false\n };\n let commandExit = false;\n const {\n socket,\n terminal\n } = gritty(document.body, options);\n Socket = socket;\n Terminal = terminal;\n Terminal.onKey(({\n domEvent\n }) => {\n const {\n keyCode,\n shiftKey\n } = domEvent;\n if (commandExit) hide();\n if (shiftKey && keyCode === Key.ESC) hide();\n });\n Socket.on('exit', code => {\n exitCodeStore(code);\n if (autoClose) return hide();\n terminal.write(`\\n${closeMessage}`);\n commandExit = true;\n });\n Socket.on('connect', exec.with(authCheck, socket));\n}\nfunction authCheck(spawn) {\n spawn.emit('auth', config('username'), config('password'));\n spawn.on('reject', () => {\n Dialog.alert('Wrong credentials!');\n });\n}\n\n//# sourceURL=file://cloudcmd/client/modules/terminal-run.js\n}");
623
+ eval("{\n\n/* global CloudCmd, gritty */\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst {\n fullstore\n} = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.cjs\");\n__webpack_require__(/*! ../../css/terminal.css */ \"./css/terminal.css\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst DOM = __webpack_require__(/*! ../dom */ \"./client/dom/index.js\");\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.js\");\nconst {\n Dialog\n} = DOM;\nconst {\n Key,\n config\n} = CloudCmd;\nCloudCmd.TerminalRun = exports;\nlet Loaded;\nlet Terminal;\nlet Socket;\nconst exitCodeStore = fullstore();\nconst loadAll = async () => {\n const {\n prefix\n } = CloudCmd;\n const prefixGritty = getPrefix();\n const js = `${prefixGritty}/gritty.js`;\n const css = `${prefix}/dist/terminal.css`;\n const [e] = await tryToCatch(load.parallel, [js, css]);\n if (e) {\n const src = e.target.src.replace(window.location.href, '');\n return Dialog.alert(`file ${src} could not be loaded`);\n }\n Loaded = true;\n};\nmodule.exports.init = async () => {\n if (!config('terminal')) return;\n Images.show.load('top');\n await CloudCmd.View();\n await loadAll();\n};\nmodule.exports.show = promisify((options = {}, fn) => {\n if (!Loaded) return fn(null, -1);\n if (!config('terminal')) return;\n create(options);\n CloudCmd.View.show(Terminal.element, {\n afterShow: () => {\n Terminal.focus();\n },\n afterClose: (/* exec.series args */\n ) => {\n fn(null, exitCodeStore());\n }\n });\n});\nmodule.exports.hide = hide;\nfunction hide() {\n CloudCmd.View.hide();\n}\nconst getPrefix = () => CloudCmd.prefix + '/gritty';\nfunction getPrefixSocket() {\n return CloudCmd.prefixSocket + '/gritty';\n}\nconst getEnv = () => ({\n ACTIVE_DIR: DOM.getCurrentDirPath,\n PASSIVE_DIR: DOM.getNotCurrentDirPath,\n CURRENT_NAME: DOM.getCurrentName,\n CURRENT_PATH: DOM.getCurrentPath\n});\nfunction create(createOptions) {\n const {\n cwd = DOM.getCurrentDirPath(),\n command,\n autoClose,\n closeMessage = 'Press any key to close Terminal...'\n } = createOptions;\n const options = {\n cwd,\n env: getEnv(),\n prefix: getPrefixSocket(),\n socketPath: CloudCmd.prefix,\n fontFamily: 'Droid Sans Mono',\n command,\n autoRestart: false\n };\n let commandExit = false;\n const {\n socket,\n terminal\n } = gritty(document.body, options);\n Socket = socket;\n Terminal = terminal;\n Terminal.onKey(({\n domEvent\n }) => {\n const {\n keyCode,\n shiftKey\n } = domEvent;\n if (commandExit) hide();\n if (shiftKey && keyCode === Key.ESC) hide();\n });\n Socket.on('exit', code => {\n exitCodeStore(code);\n if (autoClose) return hide();\n terminal.write(`\\n${closeMessage}`);\n commandExit = true;\n });\n Socket.on('connect', exec.with(authCheck, socket));\n}\nfunction authCheck(spawn) {\n spawn.emit('auth', config('username'), config('password'));\n spawn.on('reject', () => {\n Dialog.alert('Wrong credentials!');\n });\n}\n\n//# sourceURL=file://cloudcmd/client/modules/terminal-run.js\n}");
624
624
 
625
625
  /***/ },
626
626
 
@@ -631,7 +631,7 @@ eval("{\n\n/* global CloudCmd, gritty */\nconst {\n promisify\n} = __webpack_re
631
631
  (module, exports, __webpack_require__) {
632
632
 
633
633
  "use strict";
634
- eval("{\n\n/* global CloudCmd */\n/* global gritty */\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n__webpack_require__(/*! ../../css/terminal.css */ \"./css/terminal.css\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst DOM = __webpack_require__(/*! ../dom */ \"./client/dom/index.js\");\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.js\");\nconst loadParallel = load.parallel;\nconst {\n Dialog\n} = DOM;\nconst {\n Key,\n config\n} = CloudCmd;\nCloudCmd.Terminal = exports;\nlet Loaded;\nlet Terminal;\nlet Socket;\nconst loadAll = async () => {\n const {\n prefix\n } = CloudCmd;\n const prefixGritty = getPrefix();\n const js = `${prefixGritty}/gritty.js`;\n const css = `${prefix}/dist/terminal.css`;\n const [e] = await tryToCatch(loadParallel, [js, css]);\n if (e) {\n const src = e.target.src.replace(window.location.href, '');\n return Dialog.alert(`file ${src} could not be loaded`);\n }\n Loaded = true;\n};\nmodule.exports.init = async () => {\n if (!config('terminal')) return;\n Images.show.load('top');\n await CloudCmd.View();\n await loadAll();\n create();\n};\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nfunction hide() {\n CloudCmd.View.hide();\n}\nconst getPrefix = () => CloudCmd.prefix + '/gritty';\nfunction getPrefixSocket() {\n return CloudCmd.prefixSocket + '/gritty';\n}\nconst getEnv = () => ({\n ACTIVE_DIR: DOM.getCurrentDirPath,\n PASSIVE_DIR: DOM.getNotCurrentDirPath,\n CURRENT_NAME: DOM.getCurrentName,\n CURRENT_PATH: DOM.getCurrentPath\n});\nfunction create() {\n const options = {\n env: getEnv(),\n prefix: getPrefixSocket(),\n socketPath: CloudCmd.prefix,\n fontFamily: 'Droid Sans Mono'\n };\n const {\n socket,\n terminal\n } = gritty(document.body, options);\n Socket = socket;\n Terminal = terminal;\n Terminal.onKey(({\n domEvent\n }) => {\n const {\n keyCode,\n shiftKey\n } = domEvent;\n if (shiftKey && keyCode === Key.ESC) hide();\n });\n Socket.on('connect', exec.with(authCheck, socket));\n}\nfunction authCheck(spawn) {\n spawn.emit('auth', config('username'), config('password'));\n spawn.on('reject', () => {\n Dialog.alert('Wrong credentials!');\n });\n}\nfunction show() {\n if (!Loaded) return;\n if (!config('terminal')) return;\n CloudCmd.View.show(Terminal.element, {\n afterShow: () => {\n Terminal.focus();\n }\n });\n}\n\n//# sourceURL=file://cloudcmd/client/modules/terminal.js\n}");
634
+ eval("{\n\n/* global CloudCmd */\n/* global gritty */\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\n__webpack_require__(/*! ../../css/terminal.css */ \"./css/terminal.css\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst DOM = __webpack_require__(/*! ../dom */ \"./client/dom/index.js\");\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.js\");\nconst loadParallel = load.parallel;\nconst {\n Dialog\n} = DOM;\nconst {\n Key,\n config\n} = CloudCmd;\nCloudCmd.Terminal = exports;\nlet Loaded;\nlet Terminal;\nlet Socket;\nconst loadAll = async () => {\n const {\n prefix\n } = CloudCmd;\n const prefixGritty = getPrefix();\n const js = `${prefixGritty}/gritty.js`;\n const css = `${prefix}/dist/terminal.css`;\n const [e] = await tryToCatch(loadParallel, [js, css]);\n if (e) {\n const src = e.target.src.replace(window.location.href, '');\n return Dialog.alert(`file ${src} could not be loaded`);\n }\n Loaded = true;\n};\nmodule.exports.init = async () => {\n if (!config('terminal')) return;\n Images.show.load('top');\n await CloudCmd.View();\n await loadAll();\n create();\n};\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nfunction hide() {\n CloudCmd.View.hide();\n}\nconst getPrefix = () => CloudCmd.prefix + '/gritty';\nfunction getPrefixSocket() {\n return CloudCmd.prefixSocket + '/gritty';\n}\nconst getEnv = () => ({\n ACTIVE_DIR: DOM.getCurrentDirPath,\n PASSIVE_DIR: DOM.getNotCurrentDirPath,\n CURRENT_NAME: DOM.getCurrentName,\n CURRENT_PATH: DOM.getCurrentPath\n});\nfunction create() {\n const options = {\n env: getEnv(),\n prefix: getPrefixSocket(),\n socketPath: CloudCmd.prefix,\n fontFamily: 'Droid Sans Mono'\n };\n const {\n socket,\n terminal\n } = gritty(document.body, options);\n Socket = socket;\n Terminal = terminal;\n Terminal.onKey(({\n domEvent\n }) => {\n const {\n keyCode,\n shiftKey\n } = domEvent;\n if (shiftKey && keyCode === Key.ESC) hide();\n });\n Socket.on('connect', exec.with(authCheck, socket));\n}\nfunction authCheck(spawn) {\n spawn.emit('auth', config('username'), config('password'));\n spawn.on('reject', () => {\n Dialog.alert('Wrong credentials!');\n });\n}\nfunction show() {\n if (!Loaded) return;\n if (!config('terminal')) return;\n CloudCmd.View.show(Terminal.element, {\n afterShow: () => {\n Terminal.focus();\n }\n });\n}\n\n//# sourceURL=file://cloudcmd/client/modules/terminal.js\n}");
635
635
 
636
636
  /***/ },
637
637
 
@@ -664,7 +664,7 @@ eval("{\n\nmodule.exports = menuFn => {\n const module = {};\n const fn = Func
664
664
  (module, __unused_webpack_exports, __webpack_require__) {
665
665
 
666
666
  "use strict";
667
- eval("{\n\n/* global CloudCmd, DOM */\n__webpack_require__(/*! ../../../css/user-menu.css */ \"./css/user-menu.css\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst tryCatch = __webpack_require__(/*! try-catch */ \"./node_modules/try-catch/lib/try-catch.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n codeFrameColumns\n} = __webpack_require__(/*! @babel/code-frame */ \"./node_modules/@babel/code-frame/lib/index.js\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\nconst Dialog = __webpack_require__(/*! ../../dom/dialog */ \"./client/dom/dialog.js\");\nconst getUserMenu = __webpack_require__(/*! ./get-user-menu */ \"./client/modules/user-menu/get-user-menu.js\");\nconst navigate = __webpack_require__(/*! ./navigate */ \"./client/modules/user-menu/navigate.js\");\nconst parseError = __webpack_require__(/*! ./parse-error */ \"./client/modules/user-menu/parse-error.js\");\nconst parseUserMenu = __webpack_require__(/*! ./parse-user-menu */ \"./client/modules/user-menu/parse-user-menu.js\");\nconst {\n runSelected\n} = __webpack_require__(/*! ./run */ \"./client/modules/user-menu/run.js\");\nconst loadCSS = load.css;\nconst sourceStore = fullstore();\nconst Name = 'UserMenu';\nCloudCmd[Name] = module.exports;\nconst {\n Key\n} = CloudCmd;\nmodule.exports.init = async () => {\n await Promise.all([loadCSS(`${CloudCmd.prefix}/dist/user-menu.css`), CloudCmd.View()]);\n};\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nconst {\n CurrentInfo\n} = DOM;\nasync function show() {\n Images.show.load('top');\n const {\n dirPath\n } = CurrentInfo;\n const res = await fetch(`${CloudCmd.prefix}/api/v1/user-menu?dir=${dirPath}`);\n const source = await res.text();\n const [error, userMenu] = tryCatch(getUserMenu, source);\n Images.hide();\n if (error) return Dialog.alert(getCodeFrame({\n error,\n source\n }));\n sourceStore(source);\n const {\n names,\n keys,\n items,\n settings\n } = parseUserMenu(userMenu);\n if (settings.run) return runSelected(settings.select, items, runUserMenu);\n const button = createElement('button', {\n className: 'cloudcmd-user-menu-button',\n innerText: 'User Menu',\n notAppend: true\n });\n const select = createElement('select', {\n className: 'cloudcmd-user-menu',\n innerHTML: fillTemplate(names),\n notAppend: true,\n size: 10\n });\n button.addEventListener('click', onButtonClick(userMenu, select));\n select.addEventListener('dblclick', onDblClick(userMenu));\n select.addEventListener('keydown', onKeyDown({\n keys,\n userMenu\n }));\n const afterShow = () => select.focus();\n const autoSize = true;\n CloudCmd.View.show([button, select], {\n autoSize,\n afterShow\n });\n}\nfunction fillTemplate(options) {\n const result = [];\n for (const option of options) result.push(`<option>${option}</option>`);\n return result.join('');\n}\nfunction hide() {\n CloudCmd.View.hide();\n}\nconst onDblClick = currify(async (items, e) => {\n const {\n value\n } = e.target;\n await runUserMenu(items[value]);\n});\nconst onButtonClick = wraptile(async (items, {\n value\n}) => {\n await runUserMenu(items[value]);\n});\nconst onKeyDown = currify(async ({\n keys,\n userMenu\n}, e) => {\n const {\n keyCode,\n target\n } = e;\n const keyName = e.key.toUpperCase();\n e.preventDefault();\n e.stopPropagation();\n let value;\n if (keyCode === Key.ESC) return hide();\n if (keyCode === Key.ENTER) value = userMenu[target.value];else if (keys[keyName]) value = keys[keyName];else return navigate(target, e);\n await runUserMenu(value);\n});\nconst runUserMenu = async fn => {\n hide();\n const [error] = await tryToCatch(fn, {\n DOM,\n CloudCmd,\n tryToCatch\n });\n if (!error) return;\n const source = sourceStore();\n return Dialog.alert(getCodeFrame({\n error,\n source\n }));\n};\nfunction getCodeFrame({\n error,\n source\n}) {\n const {\n code\n } = error;\n if (!code || code === 'frame') return error.message;\n const [line, column] = parseError(error);\n const start = {\n line,\n column\n };\n const location = {\n start\n };\n const frame = codeFrameColumns(source, location, {\n message: error.message,\n highlightCode: false\n });\n return `<pre>${frame}</pre>`;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/user-menu/index.js\n}");
667
+ eval("{\n\n/* global CloudCmd, DOM */\n__webpack_require__(/*! ../../../css/user-menu.css */ \"./css/user-menu.css\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst {\n fullstore\n} = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.cjs\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n tryCatch\n} = __webpack_require__(/*! try-catch */ \"./node_modules/try-catch/lib/try-catch.cjs\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst {\n codeFrameColumns\n} = __webpack_require__(/*! @babel/code-frame */ \"./node_modules/@babel/code-frame/lib/index.js\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\nconst Dialog = __webpack_require__(/*! ../../dom/dialog */ \"./client/dom/dialog.js\");\nconst getUserMenu = __webpack_require__(/*! ./get-user-menu */ \"./client/modules/user-menu/get-user-menu.js\");\nconst navigate = __webpack_require__(/*! ./navigate */ \"./client/modules/user-menu/navigate.js\");\nconst parseError = __webpack_require__(/*! ./parse-error */ \"./client/modules/user-menu/parse-error.js\");\nconst parseUserMenu = __webpack_require__(/*! ./parse-user-menu */ \"./client/modules/user-menu/parse-user-menu.js\");\nconst {\n runSelected\n} = __webpack_require__(/*! ./run */ \"./client/modules/user-menu/run.js\");\nconst loadCSS = load.css;\nconst sourceStore = fullstore();\nconst Name = 'UserMenu';\nCloudCmd[Name] = module.exports;\nconst {\n Key\n} = CloudCmd;\nmodule.exports.init = async () => {\n await Promise.all([loadCSS(`${CloudCmd.prefix}/dist/user-menu.css`), CloudCmd.View()]);\n};\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nconst {\n CurrentInfo\n} = DOM;\nasync function show() {\n Images.show.load('top');\n const {\n dirPath\n } = CurrentInfo;\n const res = await fetch(`${CloudCmd.prefix}/api/v1/user-menu?dir=${dirPath}`);\n const source = await res.text();\n const [error, userMenu] = tryCatch(getUserMenu, source);\n Images.hide();\n if (error) return Dialog.alert(getCodeFrame({\n error,\n source\n }));\n sourceStore(source);\n const {\n names,\n keys,\n items,\n settings\n } = parseUserMenu(userMenu);\n if (settings.run) return runSelected(settings.select, items, runUserMenu);\n const button = createElement('button', {\n className: 'cloudcmd-user-menu-button',\n innerText: 'User Menu',\n notAppend: true\n });\n const select = createElement('select', {\n className: 'cloudcmd-user-menu',\n innerHTML: fillTemplate(names),\n notAppend: true,\n size: 10\n });\n button.addEventListener('click', onButtonClick(userMenu, select));\n select.addEventListener('dblclick', onDblClick(userMenu));\n select.addEventListener('keydown', onKeyDown({\n keys,\n userMenu\n }));\n const afterShow = () => select.focus();\n const autoSize = true;\n CloudCmd.View.show([button, select], {\n autoSize,\n afterShow\n });\n}\nfunction fillTemplate(options) {\n const result = [];\n for (const option of options) result.push(`<option>${option}</option>`);\n return result.join('');\n}\nfunction hide() {\n CloudCmd.View.hide();\n}\nconst onDblClick = currify(async (items, e) => {\n const {\n value\n } = e.target;\n await runUserMenu(items[value]);\n});\nconst onButtonClick = wraptile(async (items, {\n value\n}) => {\n await runUserMenu(items[value]);\n});\nconst onKeyDown = currify(async ({\n keys,\n userMenu\n}, e) => {\n const {\n keyCode,\n target\n } = e;\n const keyName = e.key.toUpperCase();\n e.preventDefault();\n e.stopPropagation();\n let value;\n if (keyCode === Key.ESC) return hide();\n if (keyCode === Key.ENTER) value = userMenu[target.value];else if (keys[keyName]) value = keys[keyName];else return navigate(target, e);\n await runUserMenu(value);\n});\nconst runUserMenu = async fn => {\n hide();\n const [error] = await tryToCatch(fn, {\n DOM,\n CloudCmd,\n tryToCatch\n });\n if (!error) return;\n const source = sourceStore();\n return Dialog.alert(getCodeFrame({\n error,\n source\n }));\n};\nfunction getCodeFrame({\n error,\n source\n}) {\n const {\n code\n } = error;\n if (!code || code === 'frame') return error.message;\n const [line, column] = parseError(error);\n const start = {\n line,\n column\n };\n const location = {\n start\n };\n const frame = codeFrameColumns(source, location, {\n message: error.message,\n highlightCode: false\n });\n return `<pre>${frame}</pre>`;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/user-menu/index.js\n}");
668
668
 
669
669
  /***/ },
670
670
 
@@ -675,7 +675,7 @@ eval("{\n\n/* global CloudCmd, DOM */\n__webpack_require__(/*! ../../../css/user
675
675
  (module, __unused_webpack_exports, __webpack_require__) {
676
676
 
677
677
  "use strict";
678
- eval("{\n\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\nconst {\n J,\n K,\n UP,\n DOWN\n} = __webpack_require__(/*! ../../key/key.js */ \"./client/key/key.js\");\nconst store = fullstore(1);\nconst isDigit = a => /^\\d+$/.test(a);\nmodule.exports = (el, {\n key,\n keyCode\n}) => {\n if (isDigit(key)) store(Number(key));\n if (keyCode === DOWN || keyCode === J) {\n const count = store();\n store(1);\n return down(el, count);\n }\n if (keyCode === UP || keyCode === K) {\n const count = store();\n store(1);\n return up(el, count);\n }\n};\nfunction down(el, count) {\n const {\n length\n } = el;\n if (el.selectedIndex === length - 1) el.selectedIndex = 0;else el.selectedIndex += count;\n if (el.selectedIndex < 0) el.selectedIndex = length - 1;\n}\nfunction up(el, count) {\n const {\n length\n } = el;\n if (!el.selectedIndex) el.selectedIndex = length - 1;else el.selectedIndex -= count;\n if (el.selectedIndex < 0) el.selectedIndex = 0;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/user-menu/navigate.js\n}");
678
+ eval("{\n\nconst {\n fullstore\n} = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.cjs\");\nconst {\n J,\n K,\n UP,\n DOWN\n} = __webpack_require__(/*! ../../key/key.js */ \"./client/key/key.js\");\nconst store = fullstore(1);\nconst isDigit = a => /^\\d+$/.test(a);\nmodule.exports = (el, {\n key,\n keyCode\n}) => {\n if (isDigit(key)) store(Number(key));\n if (keyCode === DOWN || keyCode === J) {\n const count = store();\n store(1);\n return down(el, count);\n }\n if (keyCode === UP || keyCode === K) {\n const count = store();\n store(1);\n return up(el, count);\n }\n};\nfunction down(el, count) {\n const {\n length\n } = el;\n if (el.selectedIndex === length - 1) el.selectedIndex = 0;else el.selectedIndex += count;\n if (el.selectedIndex < 0) el.selectedIndex = length - 1;\n}\nfunction up(el, count) {\n const {\n length\n } = el;\n if (!el.selectedIndex) el.selectedIndex = length - 1;else el.selectedIndex -= count;\n if (el.selectedIndex < 0) el.selectedIndex = 0;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/user-menu/navigate.js\n}");
679
679
 
680
680
  /***/ },
681
681
 
@@ -719,7 +719,7 @@ eval("{\n\nmodule.exports.runSelected = async (selectedItems, items, runUserMenu
719
719
  (module, __unused_webpack_exports, __webpack_require__) {
720
720
 
721
721
  "use strict";
722
- eval("{/* global CloudCmd, DOM */\n\n\n\n__webpack_require__(/*! ../../../css/view.css */ \"./css/view.css\");\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst modal = __webpack_require__(/*! @cloudcmd/modal */ \"./node_modules/@cloudcmd/modal/lib/modal.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n time\n} = __webpack_require__(/*! ../../../common/util */ \"./common/util.js\");\nconst {\n FS\n} = __webpack_require__(/*! ../../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst {\n isImage,\n isAudio,\n getType\n} = __webpack_require__(/*! ./types */ \"./client/modules/view/types.js\");\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\nconst Events = __webpack_require__(/*! ../../dom/events */ \"./client/dom/events/index.js\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\nconst isString = a => typeof a === 'string';\nconst {\n assign\n} = Object;\nconst {\n isArray\n} = Array;\nconst lifo = currify((fn, el, cb, name) => fn(name, el, cb));\nconst series = wraptile((...a) => {\n for (const f of a) f();\n});\nconst isFn = a => typeof a === 'function';\nconst noop = () => {};\nconst addEvent = lifo(Events.add);\nconst loadCSS = load.css;\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nlet Loading = false;\nconst Name = 'View';\nCloudCmd[Name] = module.exports;\nconst Info = DOM.CurrentInfo;\nconst {\n Key\n} = CloudCmd;\nconst basename = a => a.split('/').pop();\nlet El;\nlet TemplateAudio;\nlet Overlay;\nconst Config = {\n beforeShow: () => {\n Images.hide();\n Key.unsetBind();\n },\n beforeClose: () => {\n Events.rmKey(listener);\n Key.setBind();\n },\n afterShow: () => {\n El.focus();\n },\n onOverlayClick,\n afterClose: noop,\n autoSize: false,\n helpers: {\n title: {}\n }\n};\nmodule.exports._Config = Config;\nmodule.exports.init = async () => {\n await loadAll();\n const events = ['click', 'contextmenu'];\n events.forEach(addEvent(Overlay, onOverlayClick));\n};\nasync function show(data, options = {}) {\n const prefixURL = CloudCmd.prefixURL + FS;\n if (Loading) return;\n if (!options || options.bindKeys !== false) Events.addKey(listener);\n El = createElement('div', {\n className: 'view',\n notAppend: true\n });\n El.tabIndex = 0;\n if (data) {\n if (isArray(data)) El.append(...data);else El.append(data);\n modal.open(El, initConfig(options));\n return;\n }\n Images.show.load();\n const path = prefixURL + Info.path;\n const type = options.raw ? '' : await getType(path);\n switch (type) {\n default:\n return await viewFile();\n case 'markdown':\n return await CloudCmd.Markdown.show(Info.path);\n case 'html':\n return viewHtml(path);\n case 'image':\n return viewImage(Info.path, prefixURL);\n case 'media':\n return await viewMedia(path);\n case 'pdf':\n return viewPDF(path);\n }\n}\nmodule.exports._createIframe = createIframe;\nfunction createIframe(src) {\n const element = createElement('iframe', {\n src,\n width: '100%',\n height: '100%'\n });\n element.addEventListener('load', () => {\n element.contentWindow.addEventListener('keydown', listener);\n });\n return element;\n}\nmodule.exports._viewHtml = viewHtml;\nfunction viewHtml(src) {\n modal.open(createIframe(src), Config);\n}\nfunction viewPDF(src) {\n const element = createIframe(src);\n const options = assign({}, Config);\n if (CloudCmd.config('showFileName')) options.title = Info.name;\n modal.open(element, options);\n}\nasync function viewMedia(path) {\n const [e, element] = await getMediaElement(path);\n if (e) return alert(e);\n const allConfig = {\n ...Config,\n ...{\n autoSize: true,\n afterShow: () => {\n element.querySelector('audio, video').focus();\n }\n }\n };\n modal.open(element, allConfig);\n}\nasync function viewFile() {\n const [error, data] = await Info.getData();\n if (error) return Images.hide();\n const element = document.createTextNode(data);\n const options = Config;\n if (CloudCmd.config('showFileName')) options.title = Info.name;\n El.append(element);\n modal.open(El, options);\n}\nconst copy = a => assign({}, a);\nmodule.exports._initConfig = initConfig;\nfunction initConfig(options) {\n const config = copy(Config);\n if (!options) return config;\n const names = Object.keys(options);\n for (const name of names) {\n const isConfig = Boolean(config[name]);\n const item = options[name];\n if (!isFn(item) || !isConfig) {\n config[name] = options[name];\n continue;\n }\n const fn = config[name];\n config[name] = series(fn, item);\n }\n return config;\n}\nfunction hide() {\n modal.close();\n}\nfunction viewImage(path, prefixURL) {\n const isSupportedImage = a => isImage(a) || a === path;\n const makeTitle = path => ({\n href: `${prefixURL}${path}`,\n title: encode(basename(path))\n });\n const names = Info.files.map(DOM.getCurrentPath).filter(isSupportedImage);\n const titles = names.map(makeTitle);\n const index = names.indexOf(Info.path);\n const imageConfig = {\n index,\n autoSize: true,\n arrows: true,\n keys: true,\n helpers: {\n title: {}\n }\n };\n const config = {\n ...Config,\n ...imageConfig\n };\n modal.open(titles, config);\n}\nasync function getMediaElement(src) {\n check(src);\n const [error, template] = await tryToCatch(Files.get, 'view/media-tmpl');\n if (error) return [error];\n const {\n name\n } = Info;\n if (!TemplateAudio) TemplateAudio = template;\n const is = isAudio(name);\n const type = is ? 'audio' : 'video';\n const innerHTML = rendy(TemplateAudio, {\n src,\n type,\n name\n });\n const element = createElement('div', {\n innerHTML\n });\n return [null, element];\n}\nfunction check(src) {\n if (!isString(src)) throw Error('src should be a string!');\n}\nasync function loadAll() {\n const {\n DIR_DIST\n } = CloudCmd;\n time(`${Name} load`);\n Loading = true;\n await loadCSS(`${DIR_DIST}/view.css`);\n Loading = false;\n}\nfunction onOverlayClick(event) {\n const position = {\n x: event.clientX,\n y: event.clientY\n };\n setCurrentByPosition(position);\n}\nfunction setCurrentByPosition(position) {\n const element = DOM.getCurrentByPosition(position);\n if (!element) return;\n const {\n files,\n filesPassive\n } = Info;\n const isFiles = files.includes(element);\n const isFilesPassive = filesPassive.includes(element);\n if (!isFiles && !isFilesPassive) return;\n const isCurrent = DOM.isCurrentFile(element);\n if (isCurrent) return;\n DOM.setCurrentFile(element);\n}\nfunction listener({\n keyCode\n}) {\n if (keyCode === Key.ESC) hide();\n}\n\n//# sourceURL=file://cloudcmd/client/modules/view/index.js\n}");
722
+ eval("{/* global CloudCmd, DOM */\n\n\n\n__webpack_require__(/*! ../../../css/view.css */ \"./css/view.css\");\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst modal = __webpack_require__(/*! @cloudcmd/modal */ \"./node_modules/@cloudcmd/modal/lib/modal.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n time\n} = __webpack_require__(/*! ../../../common/util */ \"./common/util.js\");\nconst {\n FS\n} = __webpack_require__(/*! ../../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst {\n isImage,\n isAudio,\n getType\n} = __webpack_require__(/*! ./types */ \"./client/modules/view/types.js\");\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\nconst Events = __webpack_require__(/*! ../../dom/events */ \"./client/dom/events/index.js\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\nconst isString = a => typeof a === 'string';\nconst {\n assign\n} = Object;\nconst {\n isArray\n} = Array;\nconst lifo = currify((fn, el, cb, name) => fn(name, el, cb));\nconst series = wraptile((...a) => {\n for (const f of a) f();\n});\nconst isFn = a => typeof a === 'function';\nconst noop = () => {};\nconst addEvent = lifo(Events.add);\nconst loadCSS = load.css;\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nlet Loading = false;\nconst Name = 'View';\nCloudCmd[Name] = module.exports;\nconst Info = DOM.CurrentInfo;\nconst {\n Key\n} = CloudCmd;\nconst basename = a => a.split('/').pop();\nlet El;\nlet TemplateAudio;\nlet Overlay;\nconst Config = {\n beforeShow: () => {\n Images.hide();\n Key.unsetBind();\n },\n beforeClose: () => {\n Events.rmKey(listener);\n Key.setBind();\n },\n afterShow: () => {\n El.focus();\n },\n onOverlayClick,\n afterClose: noop,\n autoSize: false,\n helpers: {\n title: {}\n }\n};\nmodule.exports._Config = Config;\nmodule.exports.init = async () => {\n await loadAll();\n const events = ['click', 'contextmenu'];\n events.forEach(addEvent(Overlay, onOverlayClick));\n};\nasync function show(data, options = {}) {\n const prefixURL = CloudCmd.prefixURL + FS;\n if (Loading) return;\n if (!options || options.bindKeys !== false) Events.addKey(listener);\n El = createElement('div', {\n className: 'view',\n notAppend: true\n });\n El.tabIndex = 0;\n if (data) {\n if (isArray(data)) El.append(...data);else El.append(data);\n modal.open(El, initConfig(options));\n return;\n }\n Images.show.load();\n const path = prefixURL + Info.path;\n const type = options.raw ? '' : await getType(path);\n switch (type) {\n default:\n return await viewFile();\n case 'markdown':\n return await CloudCmd.Markdown.show(Info.path);\n case 'html':\n return viewHtml(path);\n case 'image':\n return viewImage(Info.path, prefixURL);\n case 'media':\n return await viewMedia(path);\n case 'pdf':\n return viewPDF(path);\n }\n}\nmodule.exports._createIframe = createIframe;\nfunction createIframe(src) {\n const element = createElement('iframe', {\n src,\n width: '100%',\n height: '100%'\n });\n element.addEventListener('load', () => {\n element.contentWindow.addEventListener('keydown', listener);\n });\n return element;\n}\nmodule.exports._viewHtml = viewHtml;\nfunction viewHtml(src) {\n modal.open(createIframe(src), Config);\n}\nfunction viewPDF(src) {\n const element = createIframe(src);\n const options = assign({}, Config);\n if (CloudCmd.config('showFileName')) options.title = Info.name;\n modal.open(element, options);\n}\nasync function viewMedia(path) {\n const [e, element] = await getMediaElement(path);\n if (e) return alert(e);\n const allConfig = {\n ...Config,\n ...{\n autoSize: true,\n afterShow: () => {\n element.querySelector('audio, video').focus();\n }\n }\n };\n modal.open(element, allConfig);\n}\nasync function viewFile() {\n const [error, data] = await Info.getData();\n if (error) return Images.hide();\n const element = document.createTextNode(data);\n const options = Config;\n if (CloudCmd.config('showFileName')) options.title = Info.name;\n El.append(element);\n modal.open(El, options);\n}\nconst copy = a => assign({}, a);\nmodule.exports._initConfig = initConfig;\nfunction initConfig(options) {\n const config = copy(Config);\n if (!options) return config;\n const names = Object.keys(options);\n for (const name of names) {\n const isConfig = Boolean(config[name]);\n const item = options[name];\n if (!isFn(item) || !isConfig) {\n config[name] = options[name];\n continue;\n }\n const fn = config[name];\n config[name] = series(fn, item);\n }\n return config;\n}\nfunction hide() {\n modal.close();\n}\nfunction viewImage(path, prefixURL) {\n const isSupportedImage = a => isImage(a) || a === path;\n const makeTitle = path => ({\n href: `${prefixURL}${path}`,\n title: encode(basename(path))\n });\n const names = Info.files.map(DOM.getCurrentPath).filter(isSupportedImage);\n const titles = names.map(makeTitle);\n const index = names.indexOf(Info.path);\n const imageConfig = {\n index,\n autoSize: true,\n arrows: true,\n keys: true,\n helpers: {\n title: {}\n }\n };\n const config = {\n ...Config,\n ...imageConfig\n };\n modal.open(titles, config);\n}\nasync function getMediaElement(src) {\n check(src);\n const [error, template] = await tryToCatch(Files.get, 'view/media-tmpl');\n if (error) return [error];\n const {\n name\n } = Info;\n if (!TemplateAudio) TemplateAudio = template;\n const is = isAudio(name);\n const type = is ? 'audio' : 'video';\n const innerHTML = rendy(TemplateAudio, {\n src,\n type,\n name\n });\n const element = createElement('div', {\n innerHTML\n });\n return [null, element];\n}\nfunction check(src) {\n if (!isString(src)) throw Error('src should be a string!');\n}\nasync function loadAll() {\n const {\n DIR_DIST\n } = CloudCmd;\n time(`${Name} load`);\n Loading = true;\n await loadCSS(`${DIR_DIST}/view.css`);\n Loading = false;\n}\nfunction onOverlayClick(event) {\n const position = {\n x: event.clientX,\n y: event.clientY\n };\n setCurrentByPosition(position);\n}\nfunction setCurrentByPosition(position) {\n const element = DOM.getCurrentByPosition(position);\n if (!element) return;\n const {\n files,\n filesPassive\n } = Info;\n const isFiles = files.includes(element);\n const isFilesPassive = filesPassive.includes(element);\n if (!isFiles && !isFilesPassive) return;\n const isCurrent = DOM.isCurrentFile(element);\n if (isCurrent) return;\n DOM.setCurrentFile(element);\n}\nfunction listener({\n keyCode\n}) {\n if (keyCode === Key.ESC) hide();\n}\n\n//# sourceURL=file://cloudcmd/client/modules/view/index.js\n}");
723
723
 
724
724
  /***/ },
725
725
 
@@ -730,7 +730,7 @@ eval("{/* global CloudCmd, DOM */\n\n\n\n__webpack_require__(/*! ../../../css/vi
730
730
  (module, __unused_webpack_exports, __webpack_require__) {
731
731
 
732
732
  "use strict";
733
- eval("{\n\nconst {\n extname\n} = __webpack_require__(/*! node:path */ \"./node_modules/path-browserify/index.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst isAudio = name => /\\.(mp3|ogg|m4a)$/i.test(name);\nconst testRegExp = currify((name, reg) => reg.test(name));\nconst getRegExp = ext => RegExp(`\\\\.${ext}$`, 'i');\nconst isPDF = a => /\\.pdf$/i.test(a);\nconst isHTML = a => /\\.html$/.test(a);\nconst isMarkdown = a => /.\\.md$/.test(a);\nmodule.exports.getType = async path => {\n const ext = extname(path);\n if (!ext) path = await detectType(path);\n if (isPDF(path)) return 'pdf';\n if (isImage(path)) return 'image';\n if (isMedia(path)) return 'media';\n if (isHTML(path)) return 'html';\n if (isMarkdown(path)) return 'markdown';\n};\nmodule.exports.isImage = isImage;\nfunction isImage(name) {\n const images = ['jp(e|g|eg)', 'gif', 'png', 'bmp', 'webp', 'svg', 'ico'];\n return images.map(getRegExp).some(testRegExp(name));\n}\nfunction isMedia(name) {\n return isAudio(name) || isVideo(name);\n}\nmodule.exports.isAudio = isAudio;\nfunction isVideo(name) {\n return /\\.(mp4|avi|webm)$/i.test(name);\n}\nmodule.exports._detectType = detectType;\nasync function detectType(path) {\n const {\n headers\n } = await fetch(path, {\n method: 'HEAD'\n });\n for (const [name, value] of headers) {\n if (name === 'content-type') return `.${value.split('/').pop()}`;\n }\n return '';\n}\n\n//# sourceURL=file://cloudcmd/client/modules/view/types.js\n}");
733
+ eval("{\n\nconst {\n extname\n} = __webpack_require__(/*! node:path */ \"./node_modules/path-browserify/index.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst isAudio = name => /\\.(mp3|ogg|m4a)$/i.test(name);\nconst testRegExp = currify((name, reg) => reg.test(name));\nconst getRegExp = ext => RegExp(`\\\\.${ext}$`, 'i');\nconst isPDF = a => /\\.pdf$/i.test(a);\nconst isHTML = a => a.endsWith('.html');\nconst isMarkdown = a => /.\\.md$/.test(a);\nmodule.exports.getType = async path => {\n const ext = extname(path);\n if (!ext) path = await detectType(path);\n if (isPDF(path)) return 'pdf';\n if (isImage(path)) return 'image';\n if (isMedia(path)) return 'media';\n if (isHTML(path)) return 'html';\n if (isMarkdown(path)) return 'markdown';\n};\nmodule.exports.isImage = isImage;\nfunction isImage(name) {\n const images = ['jp(e|g|eg)', 'gif', 'png', 'bmp', 'webp', 'svg', 'ico'];\n return images.map(getRegExp).some(testRegExp(name));\n}\nfunction isMedia(name) {\n return isAudio(name) || isVideo(name);\n}\nmodule.exports.isAudio = isAudio;\nfunction isVideo(name) {\n return /\\.(mp4|avi|webm)$/i.test(name);\n}\nmodule.exports._detectType = detectType;\nasync function detectType(path) {\n const {\n headers\n } = await fetch(path, {\n method: 'HEAD'\n });\n for (const [name, value] of headers) {\n if (name === 'content-type') return `.${value.split('/').pop()}`;\n }\n return '';\n}\n\n//# sourceURL=file://cloudcmd/client/modules/view/types.js\n}");
734
734
 
735
735
  /***/ },
736
736
 
@@ -752,7 +752,7 @@ eval("{\n\n/* global CloudCmd */\nconst DOM = __webpack_require__(/*! ./dom */ \
752
752
  (module, __unused_webpack_exports, __webpack_require__) {
753
753
 
754
754
  "use strict";
755
- eval("{\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nmodule.exports.registerSW = registerSW;\nmodule.exports.unregisterSW = unregisterSW;\nmodule.exports.listenSW = (sw, ...args) => {\n sw === null || sw === void 0 || sw.addEventListener(...args);\n};\nasync function registerSW(prefix) {\n if (!navigator.serviceWorker) return;\n const isHTTPS = location.protocol === 'https:';\n const isLocalhost = location.hostname === 'localhost';\n if (!isHTTPS && !isLocalhost) return;\n const {\n serviceWorker\n } = navigator;\n const register = serviceWorker.register.bind(serviceWorker);\n const [e, sw] = await tryToCatch(register, `${prefix}/sw.js`);\n if (e) return null;\n return sw;\n}\nasync function unregisterSW(prefix) {\n const reg = await registerSW(prefix);\n reg === null || reg === void 0 || reg.unregister(prefix);\n}\n\n//# sourceURL=file://cloudcmd/client/sw/register.js\n}");
755
+ eval("{\n\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nmodule.exports.registerSW = registerSW;\nmodule.exports.unregisterSW = unregisterSW;\nmodule.exports.listenSW = (sw, ...args) => {\n sw === null || sw === void 0 || sw.addEventListener(...args);\n};\nasync function registerSW(prefix) {\n if (!navigator.serviceWorker) return;\n const isHTTPS = location.protocol === 'https:';\n const isLocalhost = location.hostname === 'localhost';\n if (!isHTTPS && !isLocalhost) return;\n const {\n serviceWorker\n } = navigator;\n const register = serviceWorker.register.bind(serviceWorker);\n const [e, sw] = await tryToCatch(register, `${prefix}/sw.js`);\n if (e) return null;\n return sw;\n}\nasync function unregisterSW(prefix) {\n const reg = await registerSW(prefix);\n reg === null || reg === void 0 || reg.unregister(prefix);\n}\n\n//# sourceURL=file://cloudcmd/client/sw/register.js\n}");
756
756
 
757
757
  /***/ },
758
758
 
@@ -774,7 +774,7 @@ eval("{\n\nmodule.exports.btoa = str => {\n if (typeof btoa === 'function') ret
774
774
  (module, __unused_webpack_exports, __webpack_require__) {
775
775
 
776
776
  "use strict";
777
- eval("{\n\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst store = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\nconst {\n encode\n} = __webpack_require__(/*! ./entity */ \"./common/entity.js\");\nconst {\n btoa\n} = __webpack_require__(/*! ./base64 */ \"./common/base64.js\");\nconst getHeaderField = currify(_getHeaderField);\n\n/* КОНСТАНТЫ (общие для клиента и сервера)*/\n/* название программы */\nconst NAME = 'Cloud Commander';\nconst FS = '/fs';\nconst Path = store();\nPath('/');\nconst filterOutDotFiles = ({\n showDotFiles\n}) => ({\n name\n}) => {\n if (showDotFiles) return true;\n return !name.startsWith('.');\n};\nmodule.exports.FS = FS;\nmodule.exports.apiURL = '/api/v1';\nmodule.exports.MAX_FILE_SIZE = 500 * 1024;\nmodule.exports.getHeaderField = getHeaderField;\nmodule.exports.getPathLink = getPathLink;\nmodule.exports.getDotDot = getDotDot;\nmodule.exports.formatMsg = (msg, name, status) => {\n status = status || 'ok';\n name = name || '';\n if (name) name = `(\"${name}\")`;\n return `${msg}: ${status}${name}`;\n};\n\n/**\n * Функция возвращает заголовок веб страницы\n * @path\n */\nmodule.exports.getTitle = options => {\n options = options || {};\n const {\n path = Path(),\n name\n } = options;\n const array = [name || NAME, path];\n return array.filter(Boolean).join(' - ');\n};\n\n/** Функция получает адреса каждого каталога в пути\n * возвращаеться массив каталогов\n * @param url - адрес каталога\n */\nfunction getPathLink(url, prefix, template) {\n if (!url) throw Error('url could not be empty!');\n if (!template) throw Error('template could not be empty!');\n const names = url.split('/').slice(1, -1);\n const allNames = ['/', ...names];\n const lines = [];\n const n = allNames.length;\n let path = '/';\n for (let i = 0; i < n; i++) {\n const name = allNames[i];\n const isLast = i === n - 1;\n if (i) path += `${name}/`;\n if (i && isLast) {\n lines.push(`${name}/`);\n continue;\n }\n const slash = i ? '/' : '';\n lines.push(rendy(template, {\n path,\n name,\n slash,\n prefix\n }));\n }\n return lines.join('');\n}\nconst getDataName = name => {\n const encoded = btoa(encodeURI(name));\n return `data-name=\"js-file-${encoded}\" `;\n};\n\n/**\n * Функция строит таблицу файлв из JSON-информации о файлах\n * @param params - информация о файлах\n *\n */\nmodule.exports.buildFromJSON = params => {\n const {\n prefix,\n template,\n sort = 'name',\n order = 'asc',\n showDotFiles\n } = params;\n const templateFile = template.file;\n const templateLink = template.link;\n const json = params.data;\n const path = encode(json.path);\n const {\n files\n } = json;\n\n /*\n * Строим путь каталога в котором мы находимся\n * со всеми подкаталогами\n */\n const htmlPath = getPathLink(path, prefix, template.pathLink);\n let fileTable = rendy(template.path, {\n link: prefix + FS + path,\n fullPath: path,\n path: htmlPath\n });\n const owner = 'owner';\n const mode = 'mode';\n const getFieldName = getHeaderField(sort, order);\n const name = getFieldName('name');\n const size = getFieldName('size');\n const date = getFieldName('date');\n const header = rendy(templateFile, {\n tag: 'div',\n attribute: 'data-name=\"js-fm-header\" ',\n className: 'fm-header',\n type: '',\n name,\n size,\n date,\n owner,\n mode\n });\n\n /* сохраняем путь */\n Path(path);\n fileTable += `${header}<ul data-name=\"js-files\" class=\"files\">`;\n\n /* Если мы не в корне */\n if (path !== '/') {\n const dotDot = getDotDot(path);\n const link = prefix + FS + dotDot;\n const linkResult = rendy(template.link, {\n link,\n title: '..',\n name: '..'\n });\n const dataName = getDataName('..');\n const attribute = `draggable=\"true\" ${dataName}`;\n\n /* Сохраняем путь к каталогу верхнего уровня*/\n fileTable += rendy(template.file, {\n tag: 'li',\n attribute,\n className: '',\n type: 'directory',\n name: linkResult,\n size: '&lt;dir&gt;',\n date: '--.--.----',\n owner: '.',\n mode: '--- --- ---'\n });\n }\n fileTable += files.filter(filterOutDotFiles({\n showDotFiles\n })).map(updateField).map(file => {\n const name = encode(file.name);\n const link = prefix + FS + path + name;\n const {\n type,\n mode,\n date,\n owner,\n size\n } = file;\n const linkResult = rendy(templateLink, {\n link,\n title: name,\n name,\n attribute: getAttribute(file.type)\n });\n const dataName = getDataName(file.name);\n const attribute = `draggable=\"true\" ${dataName}`;\n return rendy(templateFile, {\n tag: 'li',\n attribute,\n className: '',\n type,\n name: linkResult,\n size,\n date,\n owner,\n mode\n });\n }).join('');\n fileTable += '</ul>';\n return fileTable;\n};\nconst updateField = file => ({\n ...file,\n date: file.date || '--.--.----',\n owner: file.owner || 'root',\n size: getSize(file)\n});\nfunction getAttribute(type) {\n if (type === 'directory') return '';\n return 'target=\"_blank\" ';\n}\nmodule.exports._getSize = getSize;\nfunction getSize({\n size,\n type\n}) {\n if (type === 'directory') return '&lt;dir&gt;';\n if (/link/.test(type)) return '&lt;link&gt;';\n return size;\n}\nfunction _getHeaderField(sort, order, name) {\n const arrow = order === 'asc' ? '↑' : '↓';\n if (sort !== name) return name;\n if (sort === 'name' && order === 'asc') return name;\n return `${name}${arrow}`;\n}\nfunction getDotDot(path) {\n // убираем последний слеш и каталог в котором мы сейчас находимся\n const lastSlash = path.substr(path, path.lastIndexOf('/'));\n const dotDot = lastSlash.substr(lastSlash, lastSlash.lastIndexOf('/'));\n if (!dotDot) return '/';\n return dotDot;\n}\n\n//# sourceURL=file://cloudcmd/common/cloudfunc.js\n}");
777
+ eval("{\n\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst store = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.cjs\");\nconst {\n encode\n} = __webpack_require__(/*! ./entity */ \"./common/entity.js\");\nconst {\n btoa\n} = __webpack_require__(/*! ./base64 */ \"./common/base64.js\");\nconst getHeaderField = currify(_getHeaderField);\n\n/* КОНСТАНТЫ (общие для клиента и сервера)*/\n/* название программы */\nconst NAME = 'Cloud Commander';\nconst FS = '/fs';\nconst Path = store();\nPath('/');\nconst filterOutDotFiles = ({\n showDotFiles\n}) => ({\n name\n}) => {\n if (showDotFiles) return true;\n return !name.startsWith('.');\n};\nmodule.exports.FS = FS;\nmodule.exports.apiURL = '/api/v1';\nmodule.exports.MAX_FILE_SIZE = 500 * 1024;\nmodule.exports.getHeaderField = getHeaderField;\nmodule.exports.getPathLink = getPathLink;\nmodule.exports.getDotDot = getDotDot;\nmodule.exports.formatMsg = (msg, name, status) => {\n status = status || 'ok';\n name = name || '';\n if (name) name = `(\"${name}\")`;\n return `${msg}: ${status}${name}`;\n};\n\n/**\n * Функция возвращает заголовок веб страницы\n * @path\n */\nmodule.exports.getTitle = options => {\n options = options || {};\n const {\n path = Path(),\n name\n } = options;\n const array = [name || NAME, path];\n return array.filter(Boolean).join(' - ');\n};\n\n/** Функция получает адреса каждого каталога в пути\n * возвращаеться массив каталогов\n * @param url - адрес каталога\n */\nfunction getPathLink(url, prefix, template) {\n if (!url) throw Error('url could not be empty!');\n if (!template) throw Error('template could not be empty!');\n const names = url.split('/').slice(1, -1);\n const allNames = ['/', ...names];\n const lines = [];\n const n = allNames.length;\n let path = '/';\n for (let i = 0; i < n; i++) {\n const name = allNames[i];\n const isLast = i === n - 1;\n if (i) path += `${name}/`;\n if (i && isLast) {\n lines.push(`${name}/`);\n continue;\n }\n const slash = i ? '/' : '';\n lines.push(rendy(template, {\n path,\n name,\n slash,\n prefix\n }));\n }\n return lines.join('');\n}\nconst getDataName = name => {\n const encoded = btoa(encodeURI(name));\n return `data-name=\"js-file-${encoded}\" `;\n};\n\n/**\n * Функция строит таблицу файлв из JSON-информации о файлах\n * @param params - информация о файлах\n *\n */\nmodule.exports.buildFromJSON = params => {\n const {\n prefix,\n template,\n sort = 'name',\n order = 'asc',\n showDotFiles\n } = params;\n const templateFile = template.file;\n const templateLink = template.link;\n const json = params.data;\n const path = encode(json.path);\n const {\n files\n } = json;\n\n /*\n * Строим путь каталога в котором мы находимся\n * со всеми подкаталогами\n */\n const htmlPath = getPathLink(path, prefix, template.pathLink);\n let fileTable = rendy(template.path, {\n link: prefix + FS + path,\n fullPath: path,\n path: htmlPath\n });\n const owner = 'owner';\n const mode = 'mode';\n const getFieldName = getHeaderField(sort, order);\n const name = getFieldName('name');\n const size = getFieldName('size');\n const date = getFieldName('date');\n const header = rendy(templateFile, {\n tag: 'div',\n attribute: 'data-name=\"js-fm-header\" ',\n className: 'fm-header',\n type: '',\n name,\n size,\n date,\n owner,\n mode\n });\n\n /* сохраняем путь */\n Path(path);\n fileTable += `${header}<ul data-name=\"js-files\" class=\"files\">`;\n\n /* Если мы не в корне */\n if (path !== '/') {\n const dotDot = getDotDot(path);\n const link = prefix + FS + dotDot;\n const linkResult = rendy(template.link, {\n link,\n title: '..',\n name: '..'\n });\n const dataName = getDataName('..');\n const attribute = `draggable=\"true\" ${dataName}`;\n\n /* Сохраняем путь к каталогу верхнего уровня*/\n fileTable += rendy(template.file, {\n tag: 'li',\n attribute,\n className: '',\n type: 'directory',\n name: linkResult,\n size: '&lt;dir&gt;',\n date: '--.--.----',\n owner: '.',\n mode: '--- --- ---'\n });\n }\n fileTable += files.filter(filterOutDotFiles({\n showDotFiles\n })).map(updateField).map(file => {\n const name = encode(file.name);\n const link = prefix + FS + path + name;\n const {\n type,\n mode,\n date,\n owner,\n size\n } = file;\n const linkResult = rendy(templateLink, {\n link,\n title: name,\n name,\n attribute: getAttribute(file.type)\n });\n const dataName = getDataName(file.name);\n const attribute = `draggable=\"true\" ${dataName}`;\n return rendy(templateFile, {\n tag: 'li',\n attribute,\n className: '',\n type,\n name: linkResult,\n size,\n date,\n owner,\n mode\n });\n }).join('');\n fileTable += '</ul>';\n return fileTable;\n};\nconst updateField = file => ({\n ...file,\n date: file.date || '--.--.----',\n owner: file.owner || 'root',\n size: getSize(file)\n});\nfunction getAttribute(type) {\n if (type === 'directory') return '';\n return 'target=\"_blank\" ';\n}\nmodule.exports._getSize = getSize;\nfunction getSize({\n size,\n type\n}) {\n if (type === 'directory') return '&lt;dir&gt;';\n if (/link/.test(type)) return '&lt;link&gt;';\n return size;\n}\nfunction _getHeaderField(sort, order, name) {\n const arrow = order === 'asc' ? '↑' : '↓';\n if (sort !== name) return name;\n if (sort === 'name' && order === 'asc') return name;\n return `${name}${arrow}`;\n}\nfunction getDotDot(path) {\n // убираем последний слеш и каталог в котором мы сейчас находимся\n const lastSlash = path.substr(path, path.lastIndexOf('/'));\n const dotDot = lastSlash.substr(lastSlash, lastSlash.lastIndexOf('/'));\n if (!dotDot) return '/';\n return dotDot;\n}\n\n//# sourceURL=file://cloudcmd/common/cloudfunc.js\n}");
778
778
 
779
779
  /***/ },
780
780
 
@@ -796,7 +796,7 @@ eval("{\n\nconst Entities = {\n // '&nbsp;': ' ',\n '&lt;': '<',\n '&gt;':
796
796
  (module, __unused_webpack_exports, __webpack_require__) {
797
797
 
798
798
  "use strict";
799
- eval("{\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst all = Promise.all.bind(Promise);\nmodule.exports = async a => {\n const [e, result = []] = await tryToCatch(all, a);\n return [e, ...result];\n};\n\n//# sourceURL=file://cloudcmd/common/try-to-promise-all.js\n}");
799
+ eval("{\n\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.cjs\");\nconst all = Promise.all.bind(Promise);\nmodule.exports = async a => {\n const [e, result = []] = await tryToCatch(all, a);\n return [e, ...result];\n};\n\n//# sourceURL=file://cloudcmd/common/try-to-promise-all.js\n}");
800
800
 
801
801
  /***/ },
802
802
 
@@ -961,7 +961,7 @@ eval("{\n\nmodule.exports = ({autoSize, isTitle}) => {\n const classNames = [
961
961
  (module, __unused_webpack_exports, __webpack_require__) {
962
962
 
963
963
  "use strict";
964
- eval("{\n\nconst store = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\n__webpack_require__(/*! ../css/modal.css */ \"./node_modules/@cloudcmd/modal/css/modal.css\");\nconst parseImages = __webpack_require__(/*! ./parse-images */ \"./node_modules/@cloudcmd/modal/lib/parse-images.js\");\nconst showTitle = __webpack_require__(/*! ./show-title */ \"./node_modules/@cloudcmd/modal/lib/show-title.js\");\nconst query = __webpack_require__(/*! ./query */ \"./node_modules/@cloudcmd/modal/lib/query.js\");\nconst getClassName = __webpack_require__(/*! ./get-class-name */ \"./node_modules/@cloudcmd/modal/lib/get-class-name.js\");\n\nconst noop = () => {};\n\nconst optionsStore = store({});\n\nconst innerHTML = `\n <div class=\"modal-child\" data-name=\"modal-child\">\n <div class=\"modal-close\" data-name=\"modal-close\"></div>\n </div>\n`;\n\nconst addEvent = currify((el, fn, name) => query(el).addEventListener(name, fn));\nconst addAllEvents = (el, fn, names) => names.map(addEvent(el, fn));\n\nconst {isArray} = Array;\n\nmodule.exports.open = (inner, options = {}) => {\n check(inner);\n \n if (query('main'))\n return;\n \n const {\n beforeShow = noop,\n beforeClose = noop,\n afterShow = noop,\n afterClose = noop,\n onOverlayClick = noop,\n autoSize = false,\n index = 0,\n helpers = {},\n title = '',\n } = options;\n \n optionsStore({\n beforeClose,\n afterClose,\n });\n \n beforeShow();\n \n const isImage = isArray(inner);\n const isTitle = helpers.title && title || isImage;\n \n const className = getClassName({autoSize, isTitle});\n \n const el = createElement('div', {\n innerHTML,\n className,\n dataName: 'modal-main',\n });\n \n addAllEvents('main', onMainClick(onOverlayClick), [\n 'click',\n 'contextmenu',\n ]);\n \n query('close').addEventListener('click', close);\n \n const child = query('child');\n \n if (isImage)\n return parseImages(child, inner, {\n index,\n afterShow,\n helpers,\n });\n \n child.appendChild(inner);\n \n if (isTitle)\n showTitle(title, child);\n \n afterShow();\n \n return el;\n};\n\nconst onMainClick = currify((overlayClick, event) => {\n if (event.target !== query('main'))\n return;\n \n close(event);\n overlayClick(event);\n});\n\nconst close = (event) => {\n if (event)\n event.stopPropagation();\n \n const el = query('main');\n \n const {\n beforeClose = noop,\n afterClose = noop,\n } = optionsStore();\n \n if (!el)\n return;\n \n beforeClose();\n \n document.body.removeChild(el);\n \n afterClose();\n};\n\nmodule.exports.close = close;\n\nmodule.exports._optionsStore = optionsStore;\nmodule.exports._onMainClick = onMainClick;\n\nfunction check(inner) {\n if (!inner)\n throw Error('inner should be DOM-element!');\n}\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/@cloudcmd/modal/lib/modal.js\n}");
964
+ eval("{\n\nconst store = __webpack_require__(/*! fullstore */ \"./node_modules/@cloudcmd/modal/node_modules/fullstore/lib/fullstore.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\n__webpack_require__(/*! ../css/modal.css */ \"./node_modules/@cloudcmd/modal/css/modal.css\");\nconst parseImages = __webpack_require__(/*! ./parse-images */ \"./node_modules/@cloudcmd/modal/lib/parse-images.js\");\nconst showTitle = __webpack_require__(/*! ./show-title */ \"./node_modules/@cloudcmd/modal/lib/show-title.js\");\nconst query = __webpack_require__(/*! ./query */ \"./node_modules/@cloudcmd/modal/lib/query.js\");\nconst getClassName = __webpack_require__(/*! ./get-class-name */ \"./node_modules/@cloudcmd/modal/lib/get-class-name.js\");\n\nconst noop = () => {};\n\nconst optionsStore = store({});\n\nconst innerHTML = `\n <div class=\"modal-child\" data-name=\"modal-child\">\n <div class=\"modal-close\" data-name=\"modal-close\"></div>\n </div>\n`;\n\nconst addEvent = currify((el, fn, name) => query(el).addEventListener(name, fn));\nconst addAllEvents = (el, fn, names) => names.map(addEvent(el, fn));\n\nconst {isArray} = Array;\n\nmodule.exports.open = (inner, options = {}) => {\n check(inner);\n \n if (query('main'))\n return;\n \n const {\n beforeShow = noop,\n beforeClose = noop,\n afterShow = noop,\n afterClose = noop,\n onOverlayClick = noop,\n autoSize = false,\n index = 0,\n helpers = {},\n title = '',\n } = options;\n \n optionsStore({\n beforeClose,\n afterClose,\n });\n \n beforeShow();\n \n const isImage = isArray(inner);\n const isTitle = helpers.title && title || isImage;\n \n const className = getClassName({autoSize, isTitle});\n \n const el = createElement('div', {\n innerHTML,\n className,\n dataName: 'modal-main',\n });\n \n addAllEvents('main', onMainClick(onOverlayClick), [\n 'click',\n 'contextmenu',\n ]);\n \n query('close').addEventListener('click', close);\n \n const child = query('child');\n \n if (isImage)\n return parseImages(child, inner, {\n index,\n afterShow,\n helpers,\n });\n \n child.appendChild(inner);\n \n if (isTitle)\n showTitle(title, child);\n \n afterShow();\n \n return el;\n};\n\nconst onMainClick = currify((overlayClick, event) => {\n if (event.target !== query('main'))\n return;\n \n close(event);\n overlayClick(event);\n});\n\nconst close = (event) => {\n if (event)\n event.stopPropagation();\n \n const el = query('main');\n \n const {\n beforeClose = noop,\n afterClose = noop,\n } = optionsStore();\n \n if (!el)\n return;\n \n beforeClose();\n \n document.body.removeChild(el);\n \n afterClose();\n};\n\nmodule.exports.close = close;\n\nmodule.exports._optionsStore = optionsStore;\nmodule.exports._onMainClick = onMainClick;\n\nfunction check(inner) {\n if (!inner)\n throw Error('inner should be DOM-element!');\n}\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/@cloudcmd/modal/lib/modal.js\n}");
965
965
 
966
966
  /***/ },
967
967
 
@@ -972,7 +972,7 @@ eval("{\n\nconst store = __webpack_require__(/*! fullstore */ \"./node_modules/f
972
972
  (module, __unused_webpack_exports, __webpack_require__) {
973
973
 
974
974
  "use strict";
975
- eval("{\n\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst store = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst showTitle = __webpack_require__(/*! ./show-title */ \"./node_modules/@cloudcmd/modal/lib/show-title.js\");\nconst query = __webpack_require__(/*! ./query */ \"./node_modules/@cloudcmd/modal/lib/query.js\");\n\nconst indexStore = store();\nconst helpersStore = store();\n\nconst next = wraptile((img, images) => setImage(indexStore() + 1, img, images));\nconst prev = wraptile((img, images) => setImage(indexStore() - 1, img, images));\n\nconst onload = wraptile((parent, afterShow) => {\n parent.hidden = false;\n afterShow();\n});\n\nconst onKeydown = (img, images) => function keydownListener(e) {\n let i = indexStore();\n \n const ArrowLeft = 37;\n const ArrowRight = 39;\n const Esc = 27;\n \n const {keyCode} = e;\n \n if (keyCode === ArrowLeft)\n --i;\n else if (keyCode === ArrowRight)\n ++i;\n else {\n if (keyCode === Esc)\n return document.body.removeEventListener('keydown', keydownListener);\n \n return;\n }\n \n setImage(i, img, images);\n};\n\nfunction setImage(i, img, images) {\n const n = images.length - 1;\n \n if (i < 0 || i > n)\n return;\n \n indexStore(i);\n \n query('nav-left').hidden = !i;\n query('nav-right').hidden = i === n;\n \n const {\n href,\n title,\n } = images[i];\n \n img.src = href;\n img.title = title;\n img.href = title;\n img.alt = title;\n \n if (helpersStore().title)\n showTitle(title, query('child'));\n}\n\nmodule.exports = parseImages;\n\nfunction parseImages(parent, images, {afterShow, helpers, index}) {\n indexStore(index);\n helpersStore(helpers);\n \n const img = createImage();\n parent.appendChild(img);\n \n parent.hidden = true;\n \n parent.appendChild(createElement('div', {\n className: 'modal-nav modal-nav-left',\n dataName: 'modal-nav-left',\n innerHTML: '<span></span>',\n }));\n \n parent.appendChild(createElement('div', {\n className: 'modal-nav modal-nav-right',\n dataName: 'modal-nav-right',\n innerHTML: '<span data-name=\"modal-next\"></span>',\n }));\n \n setImage(index, img, images);\n addListenerOnce(img, 'load', onload(parent, afterShow));\n \n query('nav-left')\n .addEventListener('click', prev(img, images));\n \n query('nav-right')\n .addEventListener('click', next(img, images));\n \n document.body.addEventListener('keydown', onKeydown(img, images));\n}\n\nfunction createImage() {\n const el = document.createElement('img');\n \n el.className = 'modal-image';\n \n return el;\n}\n\nmodule.exports._rmListener = rmListener;\nfunction rmListener(el, name, fn) {\n return function f(e) {\n fn(e);\n el.removeEventListener(name, f);\n };\n}\n\nmodule.exports._addListenerOnce = addListenerOnce;\nfunction addListenerOnce(el, name, fn) {\n el.addEventListener(name, rmListener(el, name, fn));\n}\n\nmodule.exports._onKeydown = onKeydown;\nmodule.exports._indexStore = indexStore;\nmodule.exports._helpersStore = helpersStore;\nmodule.exports._onload = onload;\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/@cloudcmd/modal/lib/parse-images.js\n}");
975
+ eval("{\n\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst store = __webpack_require__(/*! fullstore */ \"./node_modules/@cloudcmd/modal/node_modules/fullstore/lib/fullstore.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst showTitle = __webpack_require__(/*! ./show-title */ \"./node_modules/@cloudcmd/modal/lib/show-title.js\");\nconst query = __webpack_require__(/*! ./query */ \"./node_modules/@cloudcmd/modal/lib/query.js\");\n\nconst indexStore = store();\nconst helpersStore = store();\n\nconst next = wraptile((img, images) => setImage(indexStore() + 1, img, images));\nconst prev = wraptile((img, images) => setImage(indexStore() - 1, img, images));\n\nconst onload = wraptile((parent, afterShow) => {\n parent.hidden = false;\n afterShow();\n});\n\nconst onKeydown = (img, images) => function keydownListener(e) {\n let i = indexStore();\n \n const ArrowLeft = 37;\n const ArrowRight = 39;\n const Esc = 27;\n \n const {keyCode} = e;\n \n if (keyCode === ArrowLeft)\n --i;\n else if (keyCode === ArrowRight)\n ++i;\n else {\n if (keyCode === Esc)\n return document.body.removeEventListener('keydown', keydownListener);\n \n return;\n }\n \n setImage(i, img, images);\n};\n\nfunction setImage(i, img, images) {\n const n = images.length - 1;\n \n if (i < 0 || i > n)\n return;\n \n indexStore(i);\n \n query('nav-left').hidden = !i;\n query('nav-right').hidden = i === n;\n \n const {\n href,\n title,\n } = images[i];\n \n img.src = href;\n img.title = title;\n img.href = title;\n img.alt = title;\n \n if (helpersStore().title)\n showTitle(title, query('child'));\n}\n\nmodule.exports = parseImages;\n\nfunction parseImages(parent, images, {afterShow, helpers, index}) {\n indexStore(index);\n helpersStore(helpers);\n \n const img = createImage();\n parent.appendChild(img);\n \n parent.hidden = true;\n \n parent.appendChild(createElement('div', {\n className: 'modal-nav modal-nav-left',\n dataName: 'modal-nav-left',\n innerHTML: '<span></span>',\n }));\n \n parent.appendChild(createElement('div', {\n className: 'modal-nav modal-nav-right',\n dataName: 'modal-nav-right',\n innerHTML: '<span data-name=\"modal-next\"></span>',\n }));\n \n setImage(index, img, images);\n addListenerOnce(img, 'load', onload(parent, afterShow));\n \n query('nav-left')\n .addEventListener('click', prev(img, images));\n \n query('nav-right')\n .addEventListener('click', next(img, images));\n \n document.body.addEventListener('keydown', onKeydown(img, images));\n}\n\nfunction createImage() {\n const el = document.createElement('img');\n \n el.className = 'modal-image';\n \n return el;\n}\n\nmodule.exports._rmListener = rmListener;\nfunction rmListener(el, name, fn) {\n return function f(e) {\n fn(e);\n el.removeEventListener(name, f);\n };\n}\n\nmodule.exports._addListenerOnce = addListenerOnce;\nfunction addListenerOnce(el, name, fn) {\n el.addEventListener(name, rmListener(el, name, fn));\n}\n\nmodule.exports._onKeydown = onKeydown;\nmodule.exports._indexStore = indexStore;\nmodule.exports._helpersStore = helpersStore;\nmodule.exports._onload = onload;\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/@cloudcmd/modal/lib/parse-images.js\n}");
976
976
 
977
977
  /***/ },
978
978
 
@@ -998,6 +998,17 @@ eval("{\n\nconst createElement = __webpack_require__(/*! @cloudcmd/create-elemen
998
998
 
999
999
  /***/ },
1000
1000
 
1001
+ /***/ "./node_modules/@cloudcmd/modal/node_modules/fullstore/lib/fullstore.js"
1002
+ /*!******************************************************************************!*\
1003
+ !*** ./node_modules/@cloudcmd/modal/node_modules/fullstore/lib/fullstore.js ***!
1004
+ \******************************************************************************/
1005
+ (module) {
1006
+
1007
+ "use strict";
1008
+ eval("{\n\nmodule.exports = (value) => {\n const data = {\n value,\n };\n \n return (...args) => {\n const [value] = args;\n \n if (!args.length)\n return data.value;\n \n data.value = value;\n \n return value;\n };\n};\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/@cloudcmd/modal/node_modules/fullstore/lib/fullstore.js\n}");
1009
+
1010
+ /***/ },
1011
+
1001
1012
  /***/ "./node_modules/@cloudcmd/olark/index.js"
1002
1013
  /*!***********************************************!*\
1003
1014
  !*** ./node_modules/@cloudcmd/olark/index.js ***!
@@ -1149,14 +1160,24 @@ eval("{\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/c
1149
1160
 
1150
1161
  /***/ },
1151
1162
 
1163
+ /***/ "./node_modules/fullstore/lib/fullstore.cjs"
1164
+ /*!**************************************************!*\
1165
+ !*** ./node_modules/fullstore/lib/fullstore.cjs ***!
1166
+ \**************************************************/
1167
+ (module, __unused_webpack_exports, __webpack_require__) {
1168
+
1169
+ eval("{const {fullstore} = __webpack_require__(/*! ./fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n\nmodule.exports = fullstore;\nmodule.exports.fullstore = fullstore;\n\n\n//# sourceURL=file://cloudcmd/node_modules/fullstore/lib/fullstore.cjs\n}");
1170
+
1171
+ /***/ },
1172
+
1152
1173
  /***/ "./node_modules/fullstore/lib/fullstore.js"
1153
1174
  /*!*************************************************!*\
1154
1175
  !*** ./node_modules/fullstore/lib/fullstore.js ***!
1155
1176
  \*************************************************/
1156
- (module) {
1177
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1157
1178
 
1158
1179
  "use strict";
1159
- eval("{\n\nmodule.exports = (value) => {\n const data = {\n value,\n };\n \n return (...args) => {\n const [value] = args;\n \n if (!args.length)\n return data.value;\n \n data.value = value;\n \n return value;\n };\n};\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/fullstore/lib/fullstore.js\n}");
1180
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ fullstore: () => (/* binding */ fullstore)\n/* harmony export */ });\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (fullstore);\n\nfunction fullstore(value) {\n const data = {\n value,\n };\n \n return (...args) => {\n const [value] = args;\n \n if (!args.length)\n return data.value;\n \n data.value = value;\n \n return value;\n };\n};\n\n\n//# sourceURL=file://cloudcmd/node_modules/fullstore/lib/fullstore.js\n}");
1160
1181
 
1161
1182
  /***/ },
1162
1183
 
@@ -1199,7 +1220,18 @@ eval("{\n\nmodule.exports = type;\n\nfor (const name of ['null', 'arrayBuffer',
1199
1220
  (module, __unused_webpack_exports, __webpack_require__) {
1200
1221
 
1201
1222
  "use strict";
1202
- eval("{\n\nconst tryCatch = __webpack_require__(/*! try-catch */ \"./node_modules/try-catch/lib/try-catch.js\");\n\nconst {\n parse,\n stringify,\n} = JSON;\n\nmodule.exports.parse = (...args) => {\n const [, data] = tryCatch(parse, ...args);\n \n return data;\n};\n\nmodule.exports.stringify = (...args) => {\n const [, data] = tryCatch(stringify, ...args);\n \n return data;\n};\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/jonny/lib/jonny.js\n}");
1223
+ eval("{\n\nconst tryCatch = __webpack_require__(/*! try-catch */ \"./node_modules/jonny/node_modules/try-catch/lib/try-catch.js\");\n\nconst {\n parse,\n stringify,\n} = JSON;\n\nmodule.exports.parse = (...args) => {\n const [, data] = tryCatch(parse, ...args);\n \n return data;\n};\n\nmodule.exports.stringify = (...args) => {\n const [, data] = tryCatch(stringify, ...args);\n \n return data;\n};\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/jonny/lib/jonny.js\n}");
1224
+
1225
+ /***/ },
1226
+
1227
+ /***/ "./node_modules/jonny/node_modules/try-catch/lib/try-catch.js"
1228
+ /*!********************************************************************!*\
1229
+ !*** ./node_modules/jonny/node_modules/try-catch/lib/try-catch.js ***!
1230
+ \********************************************************************/
1231
+ (module) {
1232
+
1233
+ "use strict";
1234
+ eval("{\n\nmodule.exports = (fn, ...args) => {\n try {\n return [null, fn(...args)];\n } catch(e) {\n return [e];\n }\n};\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/jonny/node_modules/try-catch/lib/try-catch.js\n}");
1203
1235
 
1204
1236
  /***/ },
1205
1237
 
@@ -1381,7 +1413,18 @@ eval("{__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-ext
1381
1413
  (module, __unused_webpack_exports, __webpack_require__) {
1382
1414
 
1383
1415
  "use strict";
1384
- eval("{\n\n__webpack_require__(/*! ../css/smalltalk.css */ \"./node_modules/smalltalk/css/smalltalk.css\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst store = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst isBool = (a) => typeof a === 'boolean';\n\nconst keyDown = currify(keyDown_);\n\nconst BUTTON_OK = {\n ok: 'OK',\n};\n\nconst BUTTON_OK_CANCEL = {\n ok: 'OK',\n cancel: 'Cancel',\n};\n\nconst zIndex = store(100);\n\nmodule.exports.alert = (title, msg, options) => {\n const buttons = getButtons(options) || BUTTON_OK;\n return showDialog(title, msg, '', buttons, options);\n};\n\nmodule.exports.prompt = (title, msg, value = '', options) => {\n const type = getType(options);\n const val = String(value).replace(/\"/g, '&quot;');\n \n const valueStr = `<input type=\"${type}\" value=\"${val}\" data-name=\"js-input\">`;\n const buttons = getButtons(options) || BUTTON_OK_CANCEL;\n \n return showDialog(title, msg, valueStr, buttons, options);\n};\n\nmodule.exports.confirm = (title, msg, options) => {\n const buttons = getButtons(options) || BUTTON_OK_CANCEL;\n \n return showDialog(title, msg, '', buttons, options);\n};\n\nmodule.exports.progress = (title, message, options) => {\n const valueStr = `\n <progress value=\"0\" data-name=\"js-progress\" class=\"progress\" max=\"100\"></progress>\n <span data-name=\"js-counter\">0%</span>\n `;\n \n const buttons = {\n cancel: 'Abort',\n };\n \n const promise = showDialog(title, message, valueStr, buttons, options);\n const {ok, dialog} = promise;\n const resolve = ok();\n \n for (const el of find(dialog, ['cancel'])) {\n el.focus();\n }\n \n Object.assign(promise, {\n setProgress(count) {\n const [elProgress] = find(dialog, ['progress']);\n const [elCounter] = find(dialog, ['counter']);\n \n elProgress.value = count;\n elCounter.textContent = `${count}%`;\n \n if (count === 100) {\n remove(dialog);\n resolve();\n }\n },\n \n remove() {\n remove(dialog);\n },\n });\n \n return promise;\n};\n\nfunction getButtons(options = {}) {\n const {buttons} = options;\n \n if (!buttons)\n return null;\n \n return buttons;\n}\n\nfunction getType(options = {}) {\n const {type} = options;\n \n if (type === 'password')\n return 'password';\n \n return 'text';\n}\n\nfunction getTemplate(title, msg, value, buttons) {\n const encodedMsg = msg.replace(/\\n/g, '<br>');\n \n return `<div class=\"page\">\n <div data-name=\"js-close\" class=\"close-button\"></div>\n <header>${title}</header>\n <div class=\"content-area\">${encodedMsg}${value}</div>\n <div class=\"action-area\">\n <div class=\"button-strip\">\n ${parseButtons(buttons)}\n </div>\n </div>\n </div>`;\n}\n\nfunction parseButtons(buttons) {\n const names = Object.keys(buttons);\n const parse = currify((buttons, name, i) => `<button\n tabindex=${i}\n data-name=\"js-${name.toLowerCase()}\">\n ${buttons[name]}\n </button>`);\n \n return names\n .map(parse(buttons))\n .join('');\n}\n\nfunction showDialog(title, msg, value, buttons, options) {\n const ok = store();\n const cancel = store();\n \n const closeButtons = [\n 'cancel',\n 'close',\n 'ok',\n ];\n \n const promise = new Promise((resolve, reject) => {\n const noCancel = options && isBool(options.cancel) && !options.cancel;\n const empty = () => {};\n const rejectError = () => reject(Error());\n \n ok(resolve);\n cancel(noCancel ? empty : rejectError);\n });\n \n const innerHTML = getTemplate(title, msg, value, buttons);\n \n const dialog = createElement('div', {\n innerHTML,\n className: 'smalltalk',\n style: `z-index: ${zIndex(zIndex() + 1)}`,\n });\n \n for (const el of find(dialog, ['ok', 'input']))\n el.focus();\n \n for (const el of find(dialog, ['input'])) {\n el.setSelectionRange(0, value.length);\n }\n \n addListenerAll('click', dialog, closeButtons, (event) => {\n closeDialog(event.target, dialog, ok(), cancel());\n });\n \n for (const event of ['click', 'contextmenu'])\n dialog.addEventListener(event, (e) => {\n e.stopPropagation();\n \n for (const el of find(dialog, ['ok', 'input']))\n el.focus();\n });\n \n dialog.addEventListener('keydown', keyDown(dialog, ok(), cancel()));\n \n return Object.assign(promise, {\n dialog,\n ok,\n });\n}\n\nfunction keyDown_(dialog, ok, cancel, event) {\n const KEY = {\n ENTER: 13,\n ESC: 27,\n TAB: 9,\n LEFT: 37,\n UP: 38,\n RIGHT: 39,\n DOWN: 40,\n };\n \n const {keyCode} = event;\n const el = event.target;\n \n const namesAll = [\n 'ok',\n 'cancel',\n 'input',\n ];\n const names = find(dialog, namesAll).map(getDataName);\n \n switch(keyCode) {\n case KEY.ENTER:\n closeDialog(el, dialog, ok, cancel);\n event.preventDefault();\n break;\n \n case KEY.ESC:\n remove(dialog);\n cancel();\n break;\n \n case KEY.TAB:\n if (event.shiftKey)\n tab(dialog, names);\n \n tab(dialog, names);\n event.preventDefault();\n break;\n \n default:\n [\n 'left',\n 'right',\n 'up',\n 'down',\n ]\n .filter((name) => keyCode === KEY[name.toUpperCase()])\n .forEach(() => {\n changeButtonFocus(dialog, names);\n });\n \n break;\n }\n \n event.stopPropagation();\n}\n\nfunction getDataName(el) {\n return el\n .getAttribute('data-name')\n .replace('js-', '');\n}\n\nconst getName = (activeName) => {\n if (activeName === 'cancel')\n return 'ok';\n \n return 'cancel';\n};\n\nfunction changeButtonFocus(dialog, names) {\n const active = document.activeElement;\n const activeName = getDataName(active);\n const isButton = /ok|cancel/.test(activeName);\n const count = names.length - 1;\n \n if (activeName === 'input' || !count || !isButton)\n return;\n \n const name = getName(activeName);\n \n for (const el of find(dialog, [name])) {\n el.focus();\n }\n}\n\nconst getIndex = (count, index) => {\n if (index === count)\n return 0;\n \n return index + 1;\n};\n\nfunction tab(dialog, names) {\n const active = document.activeElement;\n const activeName = getDataName(active);\n const count = names.length - 1;\n \n const activeIndex = names.indexOf(activeName);\n const index = getIndex(count, activeIndex);\n \n const name = names[index];\n \n for (const el of find(dialog, [name]))\n el.focus();\n}\n\nfunction closeDialog(el, dialog, ok, cancel) {\n const name = el\n .getAttribute('data-name')\n .replace('js-', '');\n \n if (/close|cancel/.test(name)) {\n cancel();\n remove(dialog);\n \n return;\n }\n \n let value = null;\n \n for (const el of find(dialog, ['input'])) {\n value = el.value;\n }\n \n ok(value);\n remove(dialog);\n}\n\nconst query = currify((element, name) => element.querySelector(`[data-name=\"js-${name}\"]`));\n\nfunction find(element, names) {\n const elements = names\n .map(query(element))\n .filter(Boolean);\n \n return elements;\n}\n\nfunction addListenerAll(event, parent, elements, fn) {\n for (const el of find(parent, elements)) {\n el.addEventListener(event, fn);\n }\n}\n\nfunction remove(dialog) {\n const {parentElement} = dialog;\n \n if (parentElement)\n parentElement.removeChild(dialog);\n}\n\n\n//# sourceURL=file://cloudcmd/node_modules/smalltalk/lib/smalltalk.js\n}");
1416
+ eval("{\n\n__webpack_require__(/*! ../css/smalltalk.css */ \"./node_modules/smalltalk/css/smalltalk.css\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst store = __webpack_require__(/*! fullstore */ \"./node_modules/smalltalk/node_modules/fullstore/lib/fullstore.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst isBool = (a) => typeof a === 'boolean';\n\nconst keyDown = currify(keyDown_);\n\nconst BUTTON_OK = {\n ok: 'OK',\n};\n\nconst BUTTON_OK_CANCEL = {\n ok: 'OK',\n cancel: 'Cancel',\n};\n\nconst zIndex = store(100);\n\nmodule.exports.alert = (title, msg, options) => {\n const buttons = getButtons(options) || BUTTON_OK;\n return showDialog(title, msg, '', buttons, options);\n};\n\nmodule.exports.prompt = (title, msg, value = '', options) => {\n const type = getType(options);\n const val = String(value).replace(/\"/g, '&quot;');\n \n const valueStr = `<input type=\"${type}\" value=\"${val}\" data-name=\"js-input\">`;\n const buttons = getButtons(options) || BUTTON_OK_CANCEL;\n \n return showDialog(title, msg, valueStr, buttons, options);\n};\n\nmodule.exports.confirm = (title, msg, options) => {\n const buttons = getButtons(options) || BUTTON_OK_CANCEL;\n \n return showDialog(title, msg, '', buttons, options);\n};\n\nmodule.exports.progress = (title, message, options) => {\n const valueStr = `\n <progress value=\"0\" data-name=\"js-progress\" class=\"progress\" max=\"100\"></progress>\n <span data-name=\"js-counter\">0%</span>\n `;\n \n const buttons = {\n cancel: 'Abort',\n };\n \n const promise = showDialog(title, message, valueStr, buttons, options);\n const {ok, dialog} = promise;\n const resolve = ok();\n \n for (const el of find(dialog, ['cancel'])) {\n el.focus();\n }\n \n Object.assign(promise, {\n setProgress(count) {\n const [elProgress] = find(dialog, ['progress']);\n const [elCounter] = find(dialog, ['counter']);\n \n elProgress.value = count;\n elCounter.textContent = `${count}%`;\n \n if (count === 100) {\n remove(dialog);\n resolve();\n }\n },\n \n remove() {\n remove(dialog);\n },\n });\n \n return promise;\n};\n\nfunction getButtons(options = {}) {\n const {buttons} = options;\n \n if (!buttons)\n return null;\n \n return buttons;\n}\n\nfunction getType(options = {}) {\n const {type} = options;\n \n if (type === 'password')\n return 'password';\n \n return 'text';\n}\n\nfunction getTemplate(title, msg, value, buttons) {\n const encodedMsg = msg.replace(/\\n/g, '<br>');\n \n return `<div class=\"page\">\n <div data-name=\"js-close\" class=\"close-button\"></div>\n <header>${title}</header>\n <div class=\"content-area\">${encodedMsg}${value}</div>\n <div class=\"action-area\">\n <div class=\"button-strip\">\n ${parseButtons(buttons)}\n </div>\n </div>\n </div>`;\n}\n\nfunction parseButtons(buttons) {\n const names = Object.keys(buttons);\n const parse = currify((buttons, name, i) => `<button\n tabindex=${i}\n data-name=\"js-${name.toLowerCase()}\">\n ${buttons[name]}\n </button>`);\n \n return names\n .map(parse(buttons))\n .join('');\n}\n\nfunction showDialog(title, msg, value, buttons, options) {\n const ok = store();\n const cancel = store();\n \n const closeButtons = [\n 'cancel',\n 'close',\n 'ok',\n ];\n \n const promise = new Promise((resolve, reject) => {\n const noCancel = options && isBool(options.cancel) && !options.cancel;\n const empty = () => {};\n const rejectError = () => reject(Error());\n \n ok(resolve);\n cancel(noCancel ? empty : rejectError);\n });\n \n const innerHTML = getTemplate(title, msg, value, buttons);\n \n const dialog = createElement('div', {\n innerHTML,\n className: 'smalltalk',\n style: `z-index: ${zIndex(zIndex() + 1)}`,\n });\n \n for (const el of find(dialog, ['ok', 'input']))\n el.focus();\n \n for (const el of find(dialog, ['input'])) {\n el.setSelectionRange(0, value.length);\n }\n \n addListenerAll('click', dialog, closeButtons, (event) => {\n closeDialog(event.target, dialog, ok(), cancel());\n });\n \n for (const event of ['click', 'contextmenu'])\n dialog.addEventListener(event, (e) => {\n e.stopPropagation();\n \n for (const el of find(dialog, ['ok', 'input']))\n el.focus();\n });\n \n dialog.addEventListener('keydown', keyDown(dialog, ok(), cancel()));\n \n return Object.assign(promise, {\n dialog,\n ok,\n });\n}\n\nfunction keyDown_(dialog, ok, cancel, event) {\n const KEY = {\n ENTER: 13,\n ESC: 27,\n TAB: 9,\n LEFT: 37,\n UP: 38,\n RIGHT: 39,\n DOWN: 40,\n };\n \n const {keyCode} = event;\n const el = event.target;\n \n const namesAll = [\n 'ok',\n 'cancel',\n 'input',\n ];\n const names = find(dialog, namesAll).map(getDataName);\n \n switch(keyCode) {\n case KEY.ENTER:\n closeDialog(el, dialog, ok, cancel);\n event.preventDefault();\n break;\n \n case KEY.ESC:\n remove(dialog);\n cancel();\n break;\n \n case KEY.TAB:\n if (event.shiftKey)\n tab(dialog, names);\n \n tab(dialog, names);\n event.preventDefault();\n break;\n \n default:\n [\n 'left',\n 'right',\n 'up',\n 'down',\n ]\n .filter((name) => keyCode === KEY[name.toUpperCase()])\n .forEach(() => {\n changeButtonFocus(dialog, names);\n });\n \n break;\n }\n \n event.stopPropagation();\n}\n\nfunction getDataName(el) {\n return el\n .getAttribute('data-name')\n .replace('js-', '');\n}\n\nconst getName = (activeName) => {\n if (activeName === 'cancel')\n return 'ok';\n \n return 'cancel';\n};\n\nfunction changeButtonFocus(dialog, names) {\n const active = document.activeElement;\n const activeName = getDataName(active);\n const isButton = /ok|cancel/.test(activeName);\n const count = names.length - 1;\n \n if (activeName === 'input' || !count || !isButton)\n return;\n \n const name = getName(activeName);\n \n for (const el of find(dialog, [name])) {\n el.focus();\n }\n}\n\nconst getIndex = (count, index) => {\n if (index === count)\n return 0;\n \n return index + 1;\n};\n\nfunction tab(dialog, names) {\n const active = document.activeElement;\n const activeName = getDataName(active);\n const count = names.length - 1;\n \n const activeIndex = names.indexOf(activeName);\n const index = getIndex(count, activeIndex);\n \n const name = names[index];\n \n for (const el of find(dialog, [name]))\n el.focus();\n}\n\nfunction closeDialog(el, dialog, ok, cancel) {\n const name = el\n .getAttribute('data-name')\n .replace('js-', '');\n \n if (/close|cancel/.test(name)) {\n cancel();\n remove(dialog);\n \n return;\n }\n \n let value = null;\n \n for (const el of find(dialog, ['input'])) {\n value = el.value;\n }\n \n ok(value);\n remove(dialog);\n}\n\nconst query = currify((element, name) => element.querySelector(`[data-name=\"js-${name}\"]`));\n\nfunction find(element, names) {\n const elements = names\n .map(query(element))\n .filter(Boolean);\n \n return elements;\n}\n\nfunction addListenerAll(event, parent, elements, fn) {\n for (const el of find(parent, elements)) {\n el.addEventListener(event, fn);\n }\n}\n\nfunction remove(dialog) {\n const {parentElement} = dialog;\n \n if (parentElement)\n parentElement.removeChild(dialog);\n}\n\n\n//# sourceURL=file://cloudcmd/node_modules/smalltalk/lib/smalltalk.js\n}");
1417
+
1418
+ /***/ },
1419
+
1420
+ /***/ "./node_modules/smalltalk/node_modules/fullstore/lib/fullstore.js"
1421
+ /*!************************************************************************!*\
1422
+ !*** ./node_modules/smalltalk/node_modules/fullstore/lib/fullstore.js ***!
1423
+ \************************************************************************/
1424
+ (module) {
1425
+
1426
+ "use strict";
1427
+ eval("{\n\nmodule.exports = (value) => {\n const data = {\n value,\n };\n \n return (...args) => {\n const [value] = args;\n \n if (!args.length)\n return data.value;\n \n data.value = value;\n \n return value;\n };\n};\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/smalltalk/node_modules/fullstore/lib/fullstore.js\n}");
1385
1428
 
1386
1429
  /***/ },
1387
1430
 
@@ -1462,14 +1505,36 @@ eval("{\n\nmodule.exports.MAIN = '<ul data-name=\"js-menu\" class=\"menu menu-hi
1462
1505
 
1463
1506
  /***/ },
1464
1507
 
1508
+ /***/ "./node_modules/try-catch/lib/try-catch.cjs"
1509
+ /*!**************************************************!*\
1510
+ !*** ./node_modules/try-catch/lib/try-catch.cjs ***!
1511
+ \**************************************************/
1512
+ (module, __unused_webpack_exports, __webpack_require__) {
1513
+
1514
+ "use strict";
1515
+ eval("{\n\nconst {tryCatch} = __webpack_require__(/*! ./try-catch.js */ \"./node_modules/try-catch/lib/try-catch.js\");\n\nmodule.exports = tryCatch;\nmodule.exports.tryCatch = tryCatch;\n\n\n//# sourceURL=file://cloudcmd/node_modules/try-catch/lib/try-catch.cjs\n}");
1516
+
1517
+ /***/ },
1518
+
1465
1519
  /***/ "./node_modules/try-catch/lib/try-catch.js"
1466
1520
  /*!*************************************************!*\
1467
1521
  !*** ./node_modules/try-catch/lib/try-catch.js ***!
1468
1522
  \*************************************************/
1469
- (module) {
1523
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1524
+
1525
+ "use strict";
1526
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ tryCatch: () => (/* binding */ tryCatch)\n/* harmony export */ });\nconst tryCatch = (fn, ...args) => {\n try {\n return [null, fn(...args)];\n } catch(e) {\n return [e];\n }\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (tryCatch);\n\n\n//# sourceURL=file://cloudcmd/node_modules/try-catch/lib/try-catch.js\n}");
1527
+
1528
+ /***/ },
1529
+
1530
+ /***/ "./node_modules/try-to-catch/lib/try-to-catch.cjs"
1531
+ /*!********************************************************!*\
1532
+ !*** ./node_modules/try-to-catch/lib/try-to-catch.cjs ***!
1533
+ \********************************************************/
1534
+ (module, __unused_webpack_exports, __webpack_require__) {
1470
1535
 
1471
1536
  "use strict";
1472
- eval("{\n\nmodule.exports = (fn, ...args) => {\n try {\n return [null, fn(...args)];\n } catch(e) {\n return [e];\n }\n};\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/try-catch/lib/try-catch.js\n}");
1537
+ eval("{\n\nconst {tryToCatch} = __webpack_require__(/*! ./try-to-catch.js */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nmodule.exports = tryToCatch;\nmodule.exports.tryToCatch = tryToCatch;\n\n\n//# sourceURL=file://cloudcmd/node_modules/try-to-catch/lib/try-to-catch.cjs\n}");
1473
1538
 
1474
1539
  /***/ },
1475
1540
 
@@ -1477,10 +1542,10 @@ eval("{\n\nmodule.exports = (fn, ...args) => {\n try {\n return [null,
1477
1542
  /*!*******************************************************!*\
1478
1543
  !*** ./node_modules/try-to-catch/lib/try-to-catch.js ***!
1479
1544
  \*******************************************************/
1480
- (module) {
1545
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1481
1546
 
1482
1547
  "use strict";
1483
- eval("{\n\nmodule.exports = async (fn, ...args) => {\n check(fn);\n \n try {\n return [null, await fn(...args)];\n } catch(e) {\n return [e];\n }\n};\n\nfunction check(fn) {\n if (typeof fn !== 'function')\n throw Error('fn should be a function!');\n}\n\n\n\n//# sourceURL=file://cloudcmd/node_modules/try-to-catch/lib/try-to-catch.js\n}");
1548
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ tryToCatch: () => (/* binding */ tryToCatch)\n/* harmony export */ });\nconst isFn = (a) => typeof a === 'function';\n\nconst tryToCatch = async (fn, ...args) => {\n check(fn);\n \n try {\n return [null, await fn(...args)];\n } catch(e) {\n return [e];\n }\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (tryToCatch);\n\nfunction check(fn) {\n if (!isFn(fn))\n throw Error('fn should be a function!');\n}\n\n\n//# sourceURL=file://cloudcmd/node_modules/try-to-catch/lib/try-to-catch.js\n}");
1484
1549
 
1485
1550
  /***/ },
1486
1551