cloudcmd 19.1.8 → 19.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +14 -0
- package/HELP.md +3 -1
- package/README.md +1 -1
- package/dist/cloudcmd.common.js +2 -2
- package/dist/cloudcmd.common.js.map +1 -1
- package/dist/sw.js +1 -1
- package/dist-dev/cloudcmd.common.js +33 -33
- package/dist-dev/sw.js +1 -1
- package/package.json +3 -3
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
16
16
|
|
|
17
17
|
"use strict";
|
|
18
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createCloudCmd: () => (/* binding */ createCloudCmd)\n/* harmony export */ });\n/* harmony import */ var node_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node:process */ \"./node_modules/process/browser.js\");\n/* harmony import */ var emitify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\n/* harmony import */ var inherits__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! inherits */ \"./node_modules/inherits/inherits_browser.js\");\n/* harmony import */ var rendy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\n/* harmony import */ var load_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var try_to_catch__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n/* harmony import */ var format_io__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! format-io */ \"./node_modules/format-io/lib/format.js\");\n/* harmony import */ var just_pascal_case__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! just-pascal-case */ \"./node_modules/just-pascal-case/index.mjs\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n/* harmony import */ var _dom_images_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./dom/images.js */ \"./client/dom/images.js\");\n/* harmony import */ var _sw_register_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sw/register.js */ \"./client/sw/register.js\");\n/* harmony import */ var _get_json_from_file_table_mjs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./get-json-from-file-table.mjs */ \"./client/get-json-from-file-table.mjs\");\n/* harmony import */ var _key_index_mjs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./key/index.mjs */ \"./client/key/index.mjs\");\n/* harmony import */ var _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\n/* harmony import */ var _load_module_mjs__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./load-module.mjs */ \"./client/load-module.mjs\");\n\n\n/* global DOM */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst noJS = (a) => a.replace(/.js$/, '');\n\nconst isDev = \"development\" === 'development';\n\ninherits__WEBPACK_IMPORTED_MODULE_2__(CloudCmdProto, emitify__WEBPACK_IMPORTED_MODULE_1__);\n\nconst createCloudCmd = ({DOM, Listeners}) => {\n return new CloudCmdProto({\n DOM,\n Listeners,\n });\n};\n\nload_js__WEBPACK_IMPORTED_MODULE_4__.addErrorListener((e, src) => {\n const msg = `file ${src} could not be loaded`;\n _dom_images_js__WEBPACK_IMPORTED_MODULE_9__.show.error(msg);\n});\n\nfunction CloudCmdProto({DOM, Listeners}) {\n emitify__WEBPACK_IMPORTED_MODULE_1__.call(this);\n \n const CloudCmd = this;\n const Info = DOM.CurrentInfo;\n \n const {Storage, Files} = DOM;\n \n this.log = () => {\n if (!isDev)\n return;\n };\n this.prefix = '';\n this.prefixSocket = '';\n this.prefixURL = '';\n \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 \n this.order = {\n left: 'asc',\n right: 'asc',\n };\n \n this.changeDir = async (path, overrides = {}) => {\n const {\n isRefresh,\n panel,\n history = true,\n noCurrent,\n currentName,\n } = overrides;\n \n const refresh = isRefresh;\n let panelChanged;\n \n if (!noCurrent && panel && panel !== Info.panel) {\n DOM.changePanel();\n panelChanged = true;\n }\n \n let imgPosition;\n \n if (panelChanged || refresh || !history)\n imgPosition = 'top';\n \n _dom_images_js__WEBPACK_IMPORTED_MODULE_9__.show.load(imgPosition, panel);\n \n /* загружаем содержимое каталога */\n await ajaxLoad((0,format_io__WEBPACK_IMPORTED_MODULE_6__.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}${_common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_13__.apiURL}`;\n CloudCmd.prefixSocket = config.prefixSocket;\n CloudCmd.DIR_DIST = `${prefix}/dist`;\n CloudCmd.DIR_MODULES = `${this.DIR_DIST}/modules`;\n \n CloudCmd.config = (key) => config[key];\n CloudCmd.config.if = currify__WEBPACK_IMPORTED_MODULE_8__((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')\n return;\n \n config[key] = value;\n };\n \n if (config.oneFilePanel)\n CloudCmd.MIN_ONE_PANEL_WIDTH = Infinity;\n \n if (!document.body.scrollIntoViewIfNeeded)\n await load_js__WEBPACK_IMPORTED_MODULE_4__.js(`${CloudCmd.DIR_MODULES}/polyfill.js`);\n \n await initModules();\n await baseInit();\n \n CloudCmd.route(location.hash);\n };\n \n this.route = (path) => {\n const query = path.split('/');\n \n if (!path)\n return;\n \n const [kebabModule] = query;\n const module = noJS((0,just_pascal_case__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(kebabModule.slice(1)));\n \n const [, file] = query;\n const current = DOM.getCurrentByName(file);\n \n if (file && !current) {\n const msg = (0,_common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_13__.formatMsg)('set current file', file, 'error');\n CloudCmd.log(msg);\n \n return;\n }\n \n DOM.setCurrentFile(current);\n CloudCmd.execFromModule(module, 'show');\n };\n \n this.logOut = async () => {\n const url = CloudCmd.prefix + '/logout';\n const error = () => document.location.reload();\n const {prefix} = CloudCmd;\n \n await DOM.Storage.clear();\n (0,_sw_register_js__WEBPACK_IMPORTED_MODULE_10__.unregisterSW)(prefix);\n DOM.load.ajax({\n url,\n error,\n });\n };\n \n const initModules = async () => {\n CloudCmd.Key = _key_index_mjs__WEBPACK_IMPORTED_MODULE_12__.Key;\n CloudCmd.Key.bind();\n \n const [, modules] = await (0,try_to_catch__WEBPACK_IMPORTED_MODULE_5__.tryToCatch)(Files.get, 'modules');\n const showLoad = _dom_images_js__WEBPACK_IMPORTED_MODULE_9__.show.load;\n \n const doBefore = {\n edit: showLoad,\n menu: showLoad,\n };\n \n const load = (name, path, dobefore) => {\n (0,_load_module_mjs__WEBPACK_IMPORTED_MODULE_14__.loadModule)({\n name,\n path,\n dobefore,\n });\n };\n \n if (!modules)\n return;\n \n for (const module of modules.local) {\n load(null, module, doBefore[module]);\n }\n };\n \n async function saveCurrentName(currentName) {\n await Storage.set('current-name', currentName);\n }\n \n async function baseInit() {\n const files = DOM.getFiles();\n \n CloudCmd.on('current-file', DOM.updateCurrentInfo);\n CloudCmd.on('current-name', saveCurrentName);\n \n const name = await Storage.get('current-name');\n const currentFile = name && DOM.getCurrentByName(name) || files[0];\n \n /* выделяем строку с первым файлом */\n if (files)\n 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 \n const dirPath = DOM.getCurrentDirPath();\n \n Listeners.init();\n \n const panels = getPanels();\n panels.forEach(Listeners.setOnPanel);\n \n Listeners.initKeysPanel();\n \n if (!CloudCmd.config('dirStorage'))\n return;\n \n const data = await Storage.get(dirPath);\n \n if (!data)\n await Storage.setJson(dirPath, (0,_get_json_from_file_table_mjs__WEBPACK_IMPORTED_MODULE_11__.getJsonFromFileTable)());\n }\n \n function getPanels() {\n const panels = ['left'];\n \n if (CloudCmd.config('oneFilePanel'))\n return panels;\n \n return [\n ...panels,\n 'right',\n ];\n }\n \n this.execFromModule = async (moduleName, funcName, ...args) => {\n await CloudCmd[moduleName]();\n \n const func = CloudCmd[moduleName][funcName];\n func(...args);\n };\n \n this.refresh = async (options = {}) => {\n const {panel = Info.panel, currentName} = options;\n \n const path = DOM.getCurrentDirPath(panel);\n \n const isRefresh = true;\n const history = false;\n const noCurrent = options?.noCurrent;\n \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 {RESTful} = DOM;\n \n CloudCmd.log(`reading dir: \"${path}\";`);\n \n const dirStorage = CloudCmd.config('dirStorage');\n const json = dirStorage && await Storage.getJson(path);\n \n const name = options.currentName || Info.name;\n const {noCurrent, refresh} = options;\n \n if (!refresh && json)\n return await createFileTable(json, panel, options);\n \n const position = DOM.getPanelPosition(panel);\n const sort = CloudCmd.sort[position];\n const order = CloudCmd.order[position];\n \n const query = rendy__WEBPACK_IMPORTED_MODULE_3__('?sort={{ sort }}&order={{ order }}', {\n sort,\n order,\n });\n \n const [, newObj] = await RESTful.read(path + query, 'json');\n \n if (!newObj)\n // that's OK, error handled by RESTful\n return;\n \n options.sort = sort;\n options.order = order;\n \n await createFileTable(newObj, panel, options);\n \n if (refresh && !noCurrent)\n DOM.setCurrentByName(name);\n \n if (!CloudCmd.config('dirStorage'))\n return;\n \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 \n const names = [\n 'file',\n 'path',\n 'link',\n 'pathLink',\n ];\n \n const [error, [file, path, link, pathLink]] = await (0,try_to_catch__WEBPACK_IMPORTED_MODULE_5__.tryToCatch)(Files.get, names);\n \n if (error)\n return DOM.Dialog.alert(error.responseText);\n \n const panel = panelParam || DOM.getPanel();\n const {prefix} = CloudCmd;\n \n const {dir, name} = Info;\n \n const {childNodes} = panel;\n let i = childNodes.length;\n \n while (i--)\n panel.removeChild(panel.lastChild);\n \n panel.innerHTML = (0,_common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_13__.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 \n Listeners.setOnPanel(panel);\n \n if (!noCurrent) {\n let current;\n \n if (name === '..' && dir !== '/')\n current = DOM.getCurrentByName(dir);\n \n if (!current)\n [current] = DOM.getFiles(panel);\n \n DOM.setCurrentFile(current, {\n history,\n });\n \n CloudCmd.emit('active-dir', Info.dirPath);\n }\n }\n \n this.goToParentDir = async () => {\n const {\n dir,\n dirPath,\n parentDirPath,\n panel,\n } = Info;\n \n if (dirPath === parentDirPath)\n return;\n \n const path = parentDirPath;\n \n await CloudCmd.changeDir(path);\n \n const current = DOM.getCurrentByName(dir);\n const [first] = DOM.getFiles(panel);\n \n DOM.setCurrentFile(current || first, {\n history,\n });\n };\n}\n\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/client.mjs\n}");
|
|
18
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createCloudCmd: () => (/* binding */ createCloudCmd)\n/* harmony export */ });\n/* harmony import */ var node_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node:process */ \"./node_modules/process/browser.js\");\n/* harmony import */ var emitify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\n/* harmony import */ var inherits__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! inherits */ \"./node_modules/inherits/inherits_browser.js\");\n/* harmony import */ var rendy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\n/* harmony import */ var load_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var try_to_catch__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n/* harmony import */ var format_io__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! format-io */ \"./node_modules/format-io/lib/format.js\");\n/* harmony import */ var just_pascal_case__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! just-pascal-case */ \"./node_modules/just-pascal-case/index.mjs\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n/* harmony import */ var _dom_images_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./dom/images.mjs */ \"./client/dom/images.mjs\");\n/* harmony import */ var _sw_register_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./sw/register.js */ \"./client/sw/register.js\");\n/* harmony import */ var _get_json_from_file_table_mjs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./get-json-from-file-table.mjs */ \"./client/get-json-from-file-table.mjs\");\n/* harmony import */ var _key_index_mjs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./key/index.mjs */ \"./client/key/index.mjs\");\n/* harmony import */ var _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\n/* harmony import */ var _load_module_mjs__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./load-module.mjs */ \"./client/load-module.mjs\");\n\n\n/* global DOM */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst noJS = (a) => a.replace(/.js$/, '');\n\nconst isDev = \"development\" === 'development';\n\ninherits__WEBPACK_IMPORTED_MODULE_2__(CloudCmdProto, emitify__WEBPACK_IMPORTED_MODULE_1__);\n\nconst createCloudCmd = ({DOM, Listeners}) => {\n return new CloudCmdProto({\n DOM,\n Listeners,\n });\n};\n\nload_js__WEBPACK_IMPORTED_MODULE_4__.addErrorListener((e, src) => {\n const msg = `file ${src} could not be loaded`;\n _dom_images_mjs__WEBPACK_IMPORTED_MODULE_9__.show.error(msg);\n});\n\nfunction CloudCmdProto({DOM, Listeners}) {\n emitify__WEBPACK_IMPORTED_MODULE_1__.call(this);\n \n const CloudCmd = this;\n const Info = DOM.CurrentInfo;\n \n const {Storage, Files} = DOM;\n \n this.log = () => {\n if (!isDev)\n return;\n };\n this.prefix = '';\n this.prefixSocket = '';\n this.prefixURL = '';\n \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 \n this.order = {\n left: 'asc',\n right: 'asc',\n };\n \n this.changeDir = async (path, overrides = {}) => {\n const {\n isRefresh,\n panel,\n history = true,\n noCurrent,\n currentName,\n } = overrides;\n \n const refresh = isRefresh;\n let panelChanged;\n \n if (!noCurrent && panel && panel !== Info.panel) {\n DOM.changePanel();\n panelChanged = true;\n }\n \n let imgPosition;\n \n if (panelChanged || refresh || !history)\n imgPosition = 'top';\n \n _dom_images_mjs__WEBPACK_IMPORTED_MODULE_9__.show.load(imgPosition, panel);\n \n /* загружаем содержимое каталога */\n await ajaxLoad((0,format_io__WEBPACK_IMPORTED_MODULE_6__.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}${_common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_13__.apiURL}`;\n CloudCmd.prefixSocket = config.prefixSocket;\n CloudCmd.DIR_DIST = `${prefix}/dist`;\n CloudCmd.DIR_MODULES = `${this.DIR_DIST}/modules`;\n \n CloudCmd.config = (key) => config[key];\n CloudCmd.config.if = currify__WEBPACK_IMPORTED_MODULE_8__((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')\n return;\n \n config[key] = value;\n };\n \n if (config.oneFilePanel)\n CloudCmd.MIN_ONE_PANEL_WIDTH = Infinity;\n \n if (!document.body.scrollIntoViewIfNeeded)\n await load_js__WEBPACK_IMPORTED_MODULE_4__.js(`${CloudCmd.DIR_MODULES}/polyfill.js`);\n \n await initModules();\n await baseInit();\n \n CloudCmd.route(location.hash);\n };\n \n this.route = (path) => {\n const query = path.split('/');\n \n if (!path)\n return;\n \n const [kebabModule] = query;\n const module = noJS((0,just_pascal_case__WEBPACK_IMPORTED_MODULE_7__[\"default\"])(kebabModule.slice(1)));\n \n const [, file] = query;\n const current = DOM.getCurrentByName(file);\n \n if (file && !current) {\n const msg = (0,_common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_13__.formatMsg)('set current file', file, 'error');\n CloudCmd.log(msg);\n \n return;\n }\n \n DOM.setCurrentFile(current);\n CloudCmd.execFromModule(module, 'show');\n };\n \n this.logOut = async () => {\n const url = CloudCmd.prefix + '/logout';\n const error = () => document.location.reload();\n const {prefix} = CloudCmd;\n \n await DOM.Storage.clear();\n (0,_sw_register_js__WEBPACK_IMPORTED_MODULE_10__.unregisterSW)(prefix);\n DOM.load.ajax({\n url,\n error,\n });\n };\n \n const initModules = async () => {\n CloudCmd.Key = _key_index_mjs__WEBPACK_IMPORTED_MODULE_12__.Key;\n CloudCmd.Key.bind();\n \n const [, modules] = await (0,try_to_catch__WEBPACK_IMPORTED_MODULE_5__.tryToCatch)(Files.get, 'modules');\n const showLoad = _dom_images_mjs__WEBPACK_IMPORTED_MODULE_9__.show.load;\n \n const doBefore = {\n edit: showLoad,\n menu: showLoad,\n };\n \n const load = (name, path, dobefore) => {\n (0,_load_module_mjs__WEBPACK_IMPORTED_MODULE_14__.loadModule)({\n name,\n path,\n dobefore,\n });\n };\n \n if (!modules)\n return;\n \n for (const module of modules.local) {\n load(null, module, doBefore[module]);\n }\n };\n \n async function saveCurrentName(currentName) {\n await Storage.set('current-name', currentName);\n }\n \n async function baseInit() {\n const files = DOM.getFiles();\n \n CloudCmd.on('current-file', DOM.updateCurrentInfo);\n CloudCmd.on('current-name', saveCurrentName);\n \n const name = await Storage.get('current-name');\n const currentFile = name && DOM.getCurrentByName(name) || files[0];\n \n /* выделяем строку с первым файлом */\n if (files)\n 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 \n const dirPath = DOM.getCurrentDirPath();\n \n Listeners.init();\n \n const panels = getPanels();\n panels.forEach(Listeners.setOnPanel);\n \n Listeners.initKeysPanel();\n \n if (!CloudCmd.config('dirStorage'))\n return;\n \n const data = await Storage.get(dirPath);\n \n if (!data)\n await Storage.setJson(dirPath, (0,_get_json_from_file_table_mjs__WEBPACK_IMPORTED_MODULE_11__.getJsonFromFileTable)());\n }\n \n function getPanels() {\n const panels = ['left'];\n \n if (CloudCmd.config('oneFilePanel'))\n return panels;\n \n return [\n ...panels,\n 'right',\n ];\n }\n \n this.execFromModule = async (moduleName, funcName, ...args) => {\n await CloudCmd[moduleName]();\n \n const func = CloudCmd[moduleName][funcName];\n func(...args);\n };\n \n this.refresh = async (options = {}) => {\n const {panel = Info.panel, currentName} = options;\n \n const path = DOM.getCurrentDirPath(panel);\n \n const isRefresh = true;\n const history = false;\n const noCurrent = options?.noCurrent;\n \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 {RESTful} = DOM;\n \n CloudCmd.log(`reading dir: \"${path}\";`);\n \n const dirStorage = CloudCmd.config('dirStorage');\n const json = dirStorage && await Storage.getJson(path);\n \n const name = options.currentName || Info.name;\n const {noCurrent, refresh} = options;\n \n if (!refresh && json)\n return await createFileTable(json, panel, options);\n \n const position = DOM.getPanelPosition(panel);\n const sort = CloudCmd.sort[position];\n const order = CloudCmd.order[position];\n \n const query = rendy__WEBPACK_IMPORTED_MODULE_3__('?sort={{ sort }}&order={{ order }}', {\n sort,\n order,\n });\n \n const [, newObj] = await RESTful.read(path + query, 'json');\n \n if (!newObj)\n // that's OK, error handled by RESTful\n return;\n \n options.sort = sort;\n options.order = order;\n \n await createFileTable(newObj, panel, options);\n \n if (refresh && !noCurrent)\n DOM.setCurrentByName(name);\n \n if (!CloudCmd.config('dirStorage'))\n return;\n \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 \n const names = [\n 'file',\n 'path',\n 'link',\n 'pathLink',\n ];\n \n const [error, [file, path, link, pathLink]] = await (0,try_to_catch__WEBPACK_IMPORTED_MODULE_5__.tryToCatch)(Files.get, names);\n \n if (error)\n return DOM.Dialog.alert(error.responseText);\n \n const panel = panelParam || DOM.getPanel();\n const {prefix} = CloudCmd;\n \n const {dir, name} = Info;\n \n const {childNodes} = panel;\n let i = childNodes.length;\n \n while (i--)\n panel.removeChild(panel.lastChild);\n \n panel.innerHTML = (0,_common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_13__.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 \n Listeners.setOnPanel(panel);\n \n if (!noCurrent) {\n let current;\n \n if (name === '..' && dir !== '/')\n current = DOM.getCurrentByName(dir);\n \n if (!current)\n [current] = DOM.getFiles(panel);\n \n DOM.setCurrentFile(current, {\n history,\n });\n \n CloudCmd.emit('active-dir', Info.dirPath);\n }\n }\n \n this.goToParentDir = async () => {\n const {\n dir,\n dirPath,\n parentDirPath,\n panel,\n } = Info;\n \n if (dirPath === parentDirPath)\n return;\n \n const path = parentDirPath;\n \n await CloudCmd.changeDir(path);\n \n const current = DOM.getCurrentByName(dir);\n const [first] = DOM.getFiles(panel);\n \n DOM.setCurrentFile(current || first, {\n history,\n });\n };\n}\n\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/client.mjs\n}");
|
|
19
19
|
|
|
20
20
|
/***/ },
|
|
21
21
|
|
|
@@ -41,14 +41,14 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
41
41
|
|
|
42
42
|
/***/ },
|
|
43
43
|
|
|
44
|
-
/***/ "./client/dom/current-file.
|
|
45
|
-
|
|
46
|
-
!*** ./client/dom/current-file.
|
|
47
|
-
|
|
48
|
-
(
|
|
44
|
+
/***/ "./client/dom/current-file.mjs"
|
|
45
|
+
/*!*************************************!*\
|
|
46
|
+
!*** ./client/dom/current-file.mjs ***!
|
|
47
|
+
\*************************************/
|
|
48
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
49
49
|
|
|
50
50
|
"use strict";
|
|
51
|
-
eval("{\n\n/*
|
|
51
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ _CURRENT_FILE: () => (/* binding */ _CURRENT_FILE),\n/* harmony export */ _parseHrefAttribute: () => (/* binding */ _parseHrefAttribute),\n/* harmony export */ _parseNameAttribute: () => (/* binding */ _parseNameAttribute),\n/* harmony export */ getCurrentByName: () => (/* binding */ getCurrentByName),\n/* harmony export */ getCurrentByPosition: () => (/* binding */ getCurrentByPosition),\n/* harmony export */ getCurrentDirName: () => (/* binding */ getCurrentDirName),\n/* harmony export */ getCurrentDirPath: () => (/* binding */ getCurrentDirPath),\n/* harmony export */ getCurrentFile: () => (/* binding */ getCurrentFile),\n/* harmony export */ getCurrentName: () => (/* binding */ getCurrentName),\n/* harmony export */ getCurrentPath: () => (/* binding */ getCurrentPath),\n/* harmony export */ getCurrentType: () => (/* binding */ getCurrentType),\n/* harmony export */ getNotCurrentDirPath: () => (/* binding */ getNotCurrentDirPath),\n/* harmony export */ getParentDirPath: () => (/* binding */ getParentDirPath),\n/* harmony export */ isCurrentFile: () => (/* binding */ isCurrentFile),\n/* harmony export */ isCurrentIsDir: () => (/* binding */ isCurrentIsDir),\n/* harmony export */ setCurrentByName: () => (/* binding */ setCurrentByName),\n/* harmony export */ setCurrentFile: () => (/* binding */ setCurrentFile),\n/* harmony export */ setCurrentName: () => (/* binding */ setCurrentName),\n/* harmony export */ setTitle: () => (/* binding */ setTitle)\n/* harmony export */ });\n/* harmony import */ var _cloudcmd_create_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n/* harmony import */ var _common_entity_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../common/entity.js */ \"./common/entity.js\");\n/* harmony import */ var _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\n/* global DOM */\n/* global CloudCmd */\n\n\n\n\nlet Title;\n\nconst CURRENT_FILE = 'current-file';\nconst encodeNBSP = (a) => a?.replace('\\xa0', ' ');\nconst decodeNBSP = (a) => a?.replace(' ', '\\xa0');\n\nconst _CURRENT_FILE = CURRENT_FILE;\n\n/**\n * set name from current (or param) file\n *\n * @param name\n * @param current\n */\nconst setCurrentName = (name, current) => {\n const Info = DOM.CurrentInfo;\n const {link} = Info;\n const {prefix} = CloudCmd;\n const dir = prefix + _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_2__.FS + Info.dirPath;\n const encoded = (0,_common_entity_js__WEBPACK_IMPORTED_MODULE_1__.encode)(name);\n \n link.title = encoded;\n link.href = dir + encoded;\n link.innerHTML = encoded;\n \n current.setAttribute('data-name', createNameAttribute(name));\n CloudCmd.emit('current-file', current);\n \n return link;\n};\n\n/**\n * get name from current (or param) file\n *\n * @param currentFile\n */\nconst getCurrentName = (currentFile) => {\n const current = currentFile || DOM.getCurrentFile();\n \n if (!current)\n return '';\n \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};\n\nconst _parseNameAttribute = parseNameAttribute;\n\nconst parseHrefAttribute = (prefix, attribute) => {\n attribute = attribute.replace(RegExp('^' + prefix + _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_2__.FS), '');\n return (0,_common_entity_js__WEBPACK_IMPORTED_MODULE_1__.decode)(decodeNBSP(attribute));\n};\n\nconst _parseHrefAttribute = parseHrefAttribute;\n\n/**\n * get current direcotory path\n */\nconst 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 */\nconst getCurrentPath = (currentFile) => {\n const current = currentFile || DOM.getCurrentFile();\n const [element] = DOM.getByTag('a', current);\n const {prefix} = CloudCmd;\n \n return parseHrefAttribute(prefix, element.getAttribute('href'));\n};\n\n/**\n * get current direcotory name\n */\nconst getCurrentDirName = () => {\n const href = DOM\n .getCurrentDirPath()\n .replace(/\\/$/, '');\n \n const substr = href.substr(href, href.lastIndexOf('/'));\n \n return href.replace(`${substr}/`, '') || '/';\n};\n\n/**\n * get current direcotory path\n */\nconst getParentDirPath = (panel) => {\n const path = DOM.getCurrentDirPath(panel);\n const dirName = DOM.getCurrentDirName() + '/';\n const index = path.lastIndexOf(dirName);\n \n if (path === '/')\n return path;\n \n return path.slice(0, index);\n};\n\n/**\n * get not current direcotory path\n */\nconst getNotCurrentDirPath = () => {\n const panel = DOM.getPanel({\n active: false,\n });\n \n return DOM.getCurrentDirPath(panel);\n};\n\n/**\n * unified way to get current file\n *\n * @currentFile\n */\nconst getCurrentFile = () => {\n return DOM.getByClass(CURRENT_FILE);\n};\n\n/**\n * get current file by name\n */\nconst 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 \n if (!is)\n return;\n \n currentFile.classList.remove(CURRENT_FILE);\n}\n\n/**\n * unified way to set current file\n */\nconst setCurrentFile = (currentFile, options) => {\n const o = options;\n const currentFileWas = DOM.getCurrentFile();\n \n if (!currentFile)\n return DOM;\n \n let pathWas = '';\n \n if (currentFileWas) {\n pathWas = DOM.getCurrentDirPath();\n unsetCurrentFile(currentFileWas);\n }\n \n currentFile.classList.add(CURRENT_FILE);\n \n const path = DOM.getCurrentDirPath();\n const name = CloudCmd.config('name');\n \n if (path !== pathWas) {\n DOM.setTitle((0,_common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_2__.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 : _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_2__.FS + path;\n DOM.setHistory(historyPath, null, historyPath);\n }\n }\n \n /* scrolling to current file */\n const CENTER = true;\n \n DOM.scrollIntoViewIfNeeded(currentFile, CENTER);\n \n CloudCmd.emit('current-file', currentFile);\n CloudCmd.emit('current-path', path);\n CloudCmd.emit('current-name', DOM.getCurrentName(currentFile));\n \n return DOM;\n};\n\nconst 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 */\nconst getCurrentByPosition = ({x, y}) => {\n const element = document.elementFromPoint(x, y);\n \n const getEl = (el) => {\n const {tagName} = el;\n const isChild = /A|SPAN|LI/.test(tagName);\n \n if (!isChild)\n return null;\n \n if (tagName === 'A')\n return el.parentElement.parentElement;\n \n if (tagName === 'SPAN')\n return el.parentElement;\n \n return el;\n };\n \n const el = getEl(element);\n \n if (el && el.tagName !== 'LI')\n return null;\n \n return el;\n};\n\n/**\n * current file check\n *\n * @param currentFile\n */\nconst isCurrentFile = (currentFile) => {\n if (!currentFile)\n return false;\n \n return DOM.isContainClass(currentFile, CURRENT_FILE);\n};\n\n/**\n * set title or create title element\n *\n * @param name\n */\nconst setTitle = (name) => {\n if (!Title)\n Title = DOM.getByTag('title')[0] || _cloudcmd_create_element__WEBPACK_IMPORTED_MODULE_0__('title', {\n innerHTML: name,\n parent: document.head,\n });\n \n Title.textContent = name;\n \n return DOM;\n};\n\n/**\n * check is current file is a directory\n *\n * @param currentFile\n */\nconst isCurrentIsDir = (currentFile) => {\n const current = currentFile || DOM.getCurrentFile();\n const path = DOM.getCurrentPath(current);\n const fileType = DOM.getCurrentType(current);\n \n const isZip = path.endsWith('.zip');\n const isDir = /^directory(-link)?/.test(fileType);\n \n return isDir || isZip;\n};\n\nconst getCurrentType = (currentFile) => {\n const current = currentFile || DOM.getCurrentFile();\n const el = DOM.getByDataName('js-type', current);\n const type = el.className\n .split(' ')\n .pop();\n \n return type;\n};\n\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/current-file.mjs\n}");
|
|
52
52
|
|
|
53
53
|
/***/ },
|
|
54
54
|
|
|
@@ -70,7 +70,7 @@ eval("{\n\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"
|
|
|
70
70
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
71
71
|
|
|
72
72
|
"use strict";
|
|
73
|
-
eval("{\n\n/* global CloudCmd */\nconst philip = __webpack_require__(/*! philip */ \"./node_modules/philip/lib/philip.js\");\nconst Images = __webpack_require__(/*! ./images */ \"./client/dom/images.
|
|
73
|
+
eval("{\n\n/* global CloudCmd */\nconst philip = __webpack_require__(/*! philip */ \"./node_modules/philip/lib/philip.js\");\nconst Images = __webpack_require__(/*! ./images.mjs */ \"./client/dom/images.mjs\");\nconst {\n FS\n} = __webpack_require__(/*! ../../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\nconst DOM = __webpack_require__(/*! . */ \"./client/dom/index.js\");\nconst Dialog = __webpack_require__(/*! ./dialog */ \"./client/dom/dialog.js\");\nconst {\n getCurrentDirPath: getPathWhenRootEmpty\n} = DOM;\nmodule.exports = items => {\n if (items.length) Images.show('top');\n const entries = Array.from(items).map(item => item.webkitGetAsEntry());\n const dirPath = getPathWhenRootEmpty();\n const path = dirPath.replace(/\\/$/, '');\n const progress = Dialog.progress('Uploading...');\n progress.catch(() => {\n Dialog.alert('Upload aborted');\n uploader.abort();\n });\n const uploader = philip(entries, (type, name, data, i, n, callback) => {\n const {\n prefixURL\n } = CloudCmd;\n const full = prefixURL + FS + path + name;\n let upload;\n switch (type) {\n case 'file':\n upload = uploadFile(full, data);\n break;\n case 'directory':\n upload = uploadDir(full);\n break;\n }\n upload.on('end', callback);\n upload.on('progress', count => {\n const current = percent(i, n);\n const next = percent(i + 1, n);\n const max = next - current;\n const value = current + percent(count, 100, max);\n progress.setProgress(value);\n });\n });\n uploader.on('error', error => {\n Dialog.alert(error);\n uploader.abort();\n });\n uploader.on('end', CloudCmd.refresh);\n};\nconst percent = (i, n, per = 100) => Math.round(i * per / n);\nconst uploadFile = (url, data) => DOM.load.put(url, data);\nconst uploadDir = url => DOM.load.put(`${url}?dir`);\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/directory.js\n}");
|
|
74
74
|
|
|
75
75
|
/***/ },
|
|
76
76
|
|
|
@@ -118,14 +118,14 @@ eval("{\n\n/* global CloudCmd */\nconst itype = __webpack_require__(/*! itype */
|
|
|
118
118
|
|
|
119
119
|
/***/ },
|
|
120
120
|
|
|
121
|
-
/***/ "./client/dom/images.
|
|
122
|
-
|
|
123
|
-
!*** ./client/dom/images.
|
|
124
|
-
|
|
125
|
-
(
|
|
121
|
+
/***/ "./client/dom/images.mjs"
|
|
122
|
+
/*!*******************************!*\
|
|
123
|
+
!*** ./client/dom/images.mjs ***!
|
|
124
|
+
\*******************************/
|
|
125
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
126
126
|
|
|
127
127
|
"use strict";
|
|
128
|
-
eval("{/*
|
|
128
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clearProgress: () => (/* binding */ clearProgress),\n/* harmony export */ error: () => (/* binding */ error),\n/* harmony export */ get: () => (/* binding */ get),\n/* harmony export */ hide: () => (/* binding */ hide),\n/* harmony export */ loading: () => (/* binding */ loading),\n/* harmony export */ setProgress: () => (/* binding */ setProgress),\n/* harmony export */ show: () => (/* binding */ show)\n/* harmony export */ });\n/* harmony import */ var _cloudcmd_create_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n/* global DOM */\n\n\nconst LOADING = 'loading';\nconst HIDDEN = 'hidden';\nconst ERROR = 'error';\n\nconst getLoadingType = () => isSVG() ? '-svg' : '-gif';\n\nconst get = getElement;\n\n/**\n * check SVG SMIL animation support\n */\nfunction isSVG() {\n const createNS = document.createElementNS;\n const SVG_URL = 'http://www.w3.org/2000/svg';\n \n if (!createNS)\n return false;\n \n const create = createNS.bind(document);\n const svgNode = create(SVG_URL, 'animate');\n const name = svgNode.toString();\n \n return /SVGAnimate/.test(name);\n}\n\nfunction getElement() {\n return _cloudcmd_create_element__WEBPACK_IMPORTED_MODULE_0__('span', {\n id: 'js-status-image',\n className: 'icon',\n dataName: 'progress',\n notAppend: true,\n });\n}\n\n/* Функция создаёт картинку загрузки */\nconst loading = () => {\n const element = getElement();\n const {classList} = element;\n const loadingImage = LOADING + getLoadingType();\n \n classList.add(LOADING, loadingImage);\n classList.remove(ERROR, HIDDEN);\n \n return element;\n};\n\n/* Функция создаёт картинку ошибки загрузки */\nconst error = () => {\n const element = getElement();\n const {classList} = element;\n const loadingImage = LOADING + getLoadingType();\n \n classList.add(ERROR);\n classList.remove(HIDDEN, LOADING, loadingImage);\n \n return element;\n};\n\nshow.load = show;\nshow.error = (text) => {\n const image = Images.error();\n \n DOM.show(image);\n image.title = text;\n \n return image;\n};\n\n/**\n* Function shows loading spinner\n* position = {top: true};\n*/\nfunction show(position, panel) {\n const image = Images.loading();\n const parent = image.parentElement;\n const refreshButton = DOM.getRefreshButton(panel);\n \n let current;\n \n if (position === 'top') {\n current = refreshButton.parentElement;\n } else {\n current = DOM.getCurrentFile();\n \n if (current)\n current = DOM.getByDataName('js-name', current);\n else\n current = refreshButton.parentElement;\n }\n \n if (!parent || parent && parent !== current)\n current.appendChild(image);\n \n DOM.show(image);\n \n return image;\n}\n\n/**\n* hide load image\n*/\nconst hide = () => {\n const element = Images.get();\n \n DOM.hide(element);\n \n return Images;\n};\n\nconst setProgress = (value, title) => {\n const DATA = 'data-progress';\n const element = Images.get();\n \n if (!element)\n return Images;\n \n element.setAttribute(DATA, `${value}%`);\n \n if (title)\n element.title = title;\n \n return Images;\n};\n\nconst clearProgress = () => {\n const DATA = 'data-progress';\n const element = Images.get();\n \n if (!element)\n return Images;\n \n element.setAttribute(DATA, '');\n element.title = '';\n \n return Images;\n};\n\nconst Images = {\n clearProgress,\n setProgress,\n show,\n hide,\n get,\n error,\n loading,\n};\n\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/images.mjs\n}");
|
|
129
129
|
|
|
130
130
|
/***/ },
|
|
131
131
|
|
|
@@ -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.mjs */ \"./client/dom/buffer.mjs\");\nDOM.Events = __webpack_require__(/*! #dom/events */ \"./client/dom/events/index.mjs\");\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 = globalThis.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 (globalThis.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//Users/coderaiser/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.mjs */ \"./client/dom/images.mjs\");\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.mjs */ \"./client/dom/current-file.mjs\");\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.mjs */ \"./client/dom/buffer.mjs\");\nDOM.Events = __webpack_require__(/*! #dom/events */ \"./client/dom/events/index.mjs\");\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 = globalThis.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 (globalThis.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//Users/coderaiser/cloudcmd/client/dom/index.js\n}");
|
|
140
140
|
|
|
141
141
|
/***/ },
|
|
142
142
|
|
|
@@ -158,7 +158,7 @@ eval("{\n\nconst {\n FS\n} = __webpack_require__(/*! ../../../common/cloudfunc.
|
|
|
158
158
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
159
159
|
|
|
160
160
|
"use strict";
|
|
161
|
-
eval("{\n\n/* global CloudCmd */\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst Images = __webpack_require__(/*! ../images */ \"./client/dom/images.
|
|
161
|
+
eval("{\n\n/* global CloudCmd */\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst Images = __webpack_require__(/*! ../images.mjs */ \"./client/dom/images.mjs\");\nconst load = __webpack_require__(/*! ../load */ \"./client/dom/load.js\");\nmodule.exports = promisify((params, callback) => {\n const p = params;\n const {\n prefixURL\n } = CloudCmd;\n p.url = prefixURL + p.url;\n p.url = encodeURI(p.url);\n p.url = replaceHash(p.url);\n load.ajax({\n method: p.method,\n url: p.url,\n data: p.data,\n dataType: p.dataType,\n error: jqXHR => {\n const response = jqXHR.responseText;\n const {\n statusText,\n status\n } = jqXHR;\n const text = status === 404 ? response : statusText;\n callback(Error(text));\n },\n success: data => {\n Images.hide();\n if (!p.notLog) CloudCmd.log(data);\n callback(null, data);\n }\n });\n});\nmodule.exports._replaceHash = replaceHash;\nfunction replaceHash(url) {\n /*\n * if we send ajax request -\n * no need in hash so we escape #\n */\n return url.replace(/#/g, '%23');\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/io/send-request.js\n}");
|
|
162
162
|
|
|
163
163
|
/***/ },
|
|
164
164
|
|
|
@@ -180,7 +180,7 @@ eval("{\n\n/* global CloudCmd */\nconst rendy = __webpack_require__(/*! rendy */
|
|
|
180
180
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
181
181
|
|
|
182
182
|
"use strict";
|
|
183
|
-
eval("{\n\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\nconst jonny = __webpack_require__(/*! jonny */ \"./node_modules/jonny/lib/jonny.js\");\nconst Emitify = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst Images = __webpack_require__(/*! ./images */ \"./client/dom/images.
|
|
183
|
+
eval("{\n\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\nconst jonny = __webpack_require__(/*! jonny */ \"./node_modules/jonny/lib/jonny.js\");\nconst Emitify = __webpack_require__(/*! emitify */ \"./node_modules/emitify/lib/emitify.js\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst Images = __webpack_require__(/*! ./images.mjs */ \"./client/dom/images.mjs\");\nmodule.exports.getIdBySrc = getIdBySrc;\n/**\n * Function gets id by src\n * @param src\n *\n * Example: http://domain.com/1.js -> 1_js\n */\nfunction getIdBySrc(src) {\n const isStr = itype.string(src);\n if (!isStr) return;\n if (src.includes(':')) src += '-join';\n const num = src.lastIndexOf('/') + 1;\n const sub = src.substr(src, num);\n const id = src.replace(sub, '').replace(/\\./g, '-');\n return id;\n}\n\n/**\n * load file countent via ajax\n *\n * @param params\n */\nmodule.exports.ajax = params => {\n const p = params;\n const isObject = itype.object(p.data);\n const isArray = itype.array(p.data);\n const isArrayBuf = itype(p.data) === 'arraybuffer';\n const type = p.type || p.method || 'GET';\n const {\n headers = {}\n } = p;\n const xhr = new XMLHttpRequest();\n xhr.open(type, p.url, true);\n for (const name of Object.keys(headers)) {\n const value = headers[name];\n xhr.setRequestHeader(name, value);\n }\n if (p.responseType) xhr.responseType = p.responseType;\n let data;\n if (!isArrayBuf && isObject || isArray) data = jonny.stringify(p.data);else ({\n data\n } = p);\n xhr.onreadystatechange = event => {\n const xhr = event.target;\n const OK = 200;\n if (xhr.readyState !== xhr.DONE) return;\n Images.clearProgress();\n const TYPE_JSON = 'application/json';\n const type = xhr.getResponseHeader('content-type');\n if (xhr.status !== OK) return exec(p.error, xhr);\n const notText = p.dataType !== 'text';\n const isContain = type.includes(TYPE_JSON);\n let data = xhr.response;\n if (type && isContain && notText) data = jonny.parse(xhr.response) || xhr.response;\n exec(p.success, data, xhr.statusText, xhr);\n };\n xhr.send(data);\n};\nmodule.exports.put = (url, body) => {\n const emitter = Emitify();\n const xhr = new XMLHttpRequest();\n url = encodeURI(url).replace(/#/g, '%23');\n xhr.open('put', url, true);\n xhr.upload.onprogress = event => {\n if (!event.lengthComputable) return;\n const percent = event.loaded / event.total * 100;\n const count = Math.round(percent);\n emitter.emit('progress', count);\n };\n xhr.onreadystatechange = () => {\n const over = xhr.readyState === xhr.DONE;\n const OK = 200;\n if (!over) return;\n if (xhr.status === OK) {\n emitter.emit('progress', 100);\n return emitter.emit('end');\n }\n const error = Error(xhr.responseText);\n emitter.emit('error', error);\n };\n xhr.send(body);\n return emitter;\n};\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/load.js\n}");
|
|
184
184
|
|
|
185
185
|
/***/ },
|
|
186
186
|
|
|
@@ -191,7 +191,7 @@ eval("{\n\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype
|
|
|
191
191
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
192
192
|
|
|
193
193
|
"use strict";
|
|
194
|
-
eval("{\n\n/* global CloudCmd */\nconst capitalize = __webpack_require__(/*! just-capitalize */ \"./node_modules/just-capitalize/index.cjs\");\nconst _Dialog = __webpack_require__(/*! ../dialog */ \"./client/dom/dialog.js\");\nconst Storage = __webpack_require__(/*! ../storage */ \"./client/dom/storage.js\");\nconst RESTful = __webpack_require__(/*! ../rest */ \"./client/dom/rest.js\");\nconst _currentFile = __webpack_require__(/*! ../current-file */ \"./client/dom/current-file.
|
|
194
|
+
eval("{\n\n/* global CloudCmd */\nconst capitalize = __webpack_require__(/*! just-capitalize */ \"./node_modules/just-capitalize/index.cjs\");\nconst _Dialog = __webpack_require__(/*! ../dialog */ \"./client/dom/dialog.js\");\nconst Storage = __webpack_require__(/*! ../storage */ \"./client/dom/storage.js\");\nconst RESTful = __webpack_require__(/*! ../rest */ \"./client/dom/rest.js\");\nconst _currentFile = __webpack_require__(/*! ../current-file.mjs */ \"./client/dom/current-file.mjs\");\nmodule.exports = async (current, overrides = {}) => {\n const {\n refresh = CloudCmd.refresh,\n Dialog = _Dialog,\n currentFile = _currentFile\n } = overrides;\n const {\n isCurrentFile,\n getCurrentName,\n getCurrentFile,\n getCurrentByName,\n getCurrentType,\n getCurrentDirPath,\n setCurrentName\n } = currentFile;\n if (!isCurrentFile(current)) current = getCurrentFile();\n const from = getCurrentName(current);\n if (from === '..') return Dialog.alert.noFiles();\n const [cancel, to] = await Dialog.prompt('Rename', from);\n if (cancel) return;\n const nextFile = getCurrentByName(to);\n if (nextFile) {\n const type = getCurrentType(nextFile);\n const msg = `${capitalize(type)} \"${to}\" already exists. Proceed?`;\n const [cancel] = await Dialog.confirm(msg);\n if (cancel) return;\n }\n if (from === to) return;\n const dirPath = getCurrentDirPath();\n const fromFull = `${dirPath}${from}`;\n const toFull = `${dirPath}${to}`;\n const [e] = await RESTful.rename(fromFull, toFull);\n if (e) return;\n setCurrentName(to, current);\n Storage.remove(dirPath);\n refresh();\n};\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/operations/rename-current.js\n}");
|
|
195
195
|
|
|
196
196
|
/***/ },
|
|
197
197
|
|
|
@@ -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 {\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.
|
|
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.mjs */ \"./client/dom/images.mjs\");\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//Users/coderaiser/cloudcmd/client/dom/rest.js\n}");
|
|
206
206
|
|
|
207
207
|
/***/ },
|
|
208
208
|
|
|
@@ -235,7 +235,7 @@ eval("{\n\nconst {\n parse,\n stringify\n} = JSON;\nmodule.exports.set = async
|
|
|
235
235
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
236
236
|
|
|
237
237
|
"use strict";
|
|
238
|
-
eval("{\n\n/* global CloudCmd */\nconst {\n eachSeries\n} = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst load = __webpack_require__(/*! ./load */ \"./client/dom/load.js\");\nconst Images = __webpack_require__(/*! ./images */ \"./client/dom/images.
|
|
238
|
+
eval("{\n\n/* global CloudCmd */\nconst {\n eachSeries\n} = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst load = __webpack_require__(/*! ./load */ \"./client/dom/load.js\");\nconst Images = __webpack_require__(/*! ./images.mjs */ \"./client/dom/images.mjs\");\nconst {\n alert\n} = __webpack_require__(/*! ./dialog */ \"./client/dom/dialog.js\");\nconst {\n FS\n} = __webpack_require__(/*! ../../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\nconst {\n getCurrentDirPath: getPathWhenRootEmpty\n} = __webpack_require__(/*! . */ \"./client/dom/index.js\");\nconst loadFile = wraptile(_loadFile);\nconst onEnd = wraptile(_onEnd);\nmodule.exports = (dir, files) => {\n if (!files) {\n files = dir;\n dir = getPathWhenRootEmpty();\n }\n const n = files.length;\n if (!n) return;\n const array = Array.from(files);\n const {\n name\n } = files[0];\n eachSeries(array, loadFile(dir, n), onEnd(name));\n};\nfunction _onEnd(currentName) {\n CloudCmd.refresh({\n currentName\n });\n}\nfunction _loadFile(dir, n, file, callback) {\n let i = 0;\n const {\n name\n } = file;\n const path = dir + name;\n const {\n prefixURL\n } = CloudCmd;\n const api = prefixURL + FS;\n const percent = (i, n, per = 100) => {\n return Math.round(i * per / n);\n };\n const step = n => 100 / n;\n ++i;\n load.put(api + path, file).on('error', showError).on('end', callback).on('progress', count => {\n const max = step(n);\n const value = (i - 1) * max + percent(count, 100, max);\n Images.show.load('top');\n Images.setProgress(Math.round(value));\n });\n}\nfunction showError({\n message\n}) {\n alert(message);\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/upload-files.js\n}");
|
|
239
239
|
|
|
240
240
|
/***/ },
|
|
241
241
|
|
|
@@ -312,7 +312,7 @@ eval("{\n\nconst {\n fullstore\n} = __webpack_require__(/*! fullstore */ \"./no
|
|
|
312
312
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
313
313
|
|
|
314
314
|
"use strict";
|
|
315
|
-
eval("{\n\n/* global CloudCmd */\n/* global DOM */\nconst vim = __webpack_require__(/*! ./vim */ \"./client/key/vim/vim.js\");\nconst finder = __webpack_require__(/*! ./find */ \"./client/key/vim/find.js\");\nconst {\n setCurrent,\n selectFileNotParent\n} = __webpack_require__(/*! ./set-current */ \"./client/key/vim/set-current.js\");\nmodule.exports = (key, event, overrides = {}) => {\n const defaults = {\n ...globalThis.DOM,\n ...globalThis.CloudCmd\n };\n const deps = {\n ...defaults,\n ...overrides\n };\n const operations = getOperations(event, deps);\n vim(key, operations, deps);\n};\nconst getOperations = (event, deps) => {\n var _event$preventDefault;\n const {\n Info = globalThis.DOM.CurrentInfo,\n CloudCmd = globalThis.CloudCmd,\n Operation,\n unselectFiles,\n setCurrentFile,\n setCurrentByName,\n getCurrentName,\n prompt = globalThis.DOM.Dialog.prompt,\n preventDefault = event === null || event === void 0 || (_event$preventDefault = event.preventDefault) === null || _event$preventDefault === void 0 ? void 0 : _event$preventDefault.bind(event),\n toggleSelectedFile,\n Buffer = {}\n } = deps;\n return {\n escape: unselectFiles,\n remove: () => {\n Operation.show('delete');\n },\n makeDirectory: () => {\n event.stopImmediatePropagation();\n event.preventDefault();\n DOM.promptNewDir();\n },\n makeFile: () => {\n event.stopImmediatePropagation();\n event.preventDefault();\n DOM.promptNewFile();\n },\n terminal: () => {\n CloudCmd.Terminal.show();\n },\n edit: () => {\n CloudCmd.EditFileVim.show();\n },\n copy: () => {\n Buffer.copy();\n unselectFiles();\n },\n select: () => {\n const current = Info.element;\n toggleSelectedFile(current);\n },\n paste: Buffer.paste,\n moveNext: ({\n count,\n isVisual,\n isDelete\n }) => {\n setCurrent('next', {\n count,\n isVisual,\n isDelete\n }, {\n Info,\n setCurrentFile,\n unselectFiles,\n Operation\n });\n },\n movePrevious: ({\n count,\n isVisual,\n isDelete\n }) => {\n setCurrent('previous', {\n count,\n isVisual,\n isDelete\n }, {\n Info,\n setCurrentFile,\n unselectFiles,\n Operation\n });\n },\n find: async () => {\n preventDefault();\n const [, value] = await prompt('Find', '');\n if (!value) return;\n const names = Info.files.map(getCurrentName);\n const [result] = finder.find(value, names);\n setCurrentByName(result);\n }
|
|
315
|
+
eval("{\n\n/* global CloudCmd */\n/* global DOM */\nconst vim = __webpack_require__(/*! ./vim */ \"./client/key/vim/vim.js\");\nconst finder = __webpack_require__(/*! ./find */ \"./client/key/vim/find.js\");\nconst {\n setCurrent,\n selectFileNotParent\n} = __webpack_require__(/*! ./set-current */ \"./client/key/vim/set-current.js\");\nmodule.exports = (key, event, overrides = {}) => {\n const defaults = {\n ...globalThis.DOM,\n ...globalThis.CloudCmd\n };\n const deps = {\n ...defaults,\n ...overrides\n };\n const operations = getOperations(event, deps);\n vim(key, operations, deps);\n};\nconst getOperations = (event, deps) => {\n var _event$preventDefault;\n const {\n Info = globalThis.DOM.CurrentInfo,\n CloudCmd = globalThis.CloudCmd,\n Operation,\n unselectFiles,\n setCurrentFile,\n setCurrentByName,\n getCurrentName,\n prompt = globalThis.DOM.Dialog.prompt,\n preventDefault = event === null || event === void 0 || (_event$preventDefault = event.preventDefault) === null || _event$preventDefault === void 0 ? void 0 : _event$preventDefault.bind(event),\n toggleSelectedFile,\n Buffer = {},\n createFindNext = _createFindNext,\n createFindPrevious = _createFindPrevious\n } = deps;\n return {\n findNext: createFindNext({\n setCurrentByName\n }),\n findPrevious: createFindPrevious({\n setCurrentByName\n }),\n escape: unselectFiles,\n remove: () => {\n Operation.show('delete');\n },\n makeDirectory: () => {\n event.stopImmediatePropagation();\n event.preventDefault();\n DOM.promptNewDir();\n },\n makeFile: () => {\n event.stopImmediatePropagation();\n event.preventDefault();\n DOM.promptNewFile();\n },\n terminal: () => {\n CloudCmd.Terminal.show();\n },\n edit: () => {\n CloudCmd.EditFileVim.show();\n },\n copy: () => {\n Buffer.copy();\n unselectFiles();\n },\n select: () => {\n const current = Info.element;\n toggleSelectedFile(current);\n },\n paste: Buffer.paste,\n moveNext: ({\n count,\n isVisual,\n isDelete\n }) => {\n setCurrent('next', {\n count,\n isVisual,\n isDelete\n }, {\n Info,\n setCurrentFile,\n unselectFiles,\n Operation\n });\n },\n movePrevious: ({\n count,\n isVisual,\n isDelete\n }) => {\n setCurrent('previous', {\n count,\n isVisual,\n isDelete\n }, {\n Info,\n setCurrentFile,\n unselectFiles,\n Operation\n });\n },\n find: async () => {\n preventDefault();\n const [, value] = await prompt('Find', '');\n if (!value) return;\n const names = Info.files.map(getCurrentName);\n const [result] = finder.find(value, names);\n setCurrentByName(result);\n }\n };\n};\nmodule.exports.selectFile = selectFileNotParent;\nconst _createFindPrevious = (overrides = {}) => () => {\n const {\n setCurrentByName\n } = overrides;\n const name = finder.findPrevious();\n setCurrentByName(name);\n};\nconst _createFindNext = (overrides = {}) => () => {\n const {\n setCurrentByName\n } = overrides;\n const name = finder.findNext();\n setCurrentByName(name);\n};\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/key/vim/index.js\n}");
|
|
316
316
|
|
|
317
317
|
/***/ },
|
|
318
318
|
|
|
@@ -389,7 +389,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
389
389
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
390
390
|
|
|
391
391
|
"use strict";
|
|
392
|
-
eval("{/* global CloudCmd, filepicker */\n\n\n\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n ajax\n} = __webpack_require__(/*! ../dom/load */ \"./client/dom/load.js\");\nconst Files = __webpack_require__(/*! ../dom/files */ \"./client/dom/files.js\");\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.
|
|
392
|
+
eval("{/* global CloudCmd, filepicker */\n\n\n\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n ajax\n} = __webpack_require__(/*! ../dom/load */ \"./client/dom/load.js\");\nconst Files = __webpack_require__(/*! ../dom/files */ \"./client/dom/files.js\");\nconst Images = __webpack_require__(/*! ../dom/images.mjs */ \"./client/dom/images.mjs\");\nconst {\n log\n} = CloudCmd;\nconst upload = currify(_upload);\nconst Name = 'Cloud';\nCloudCmd[Name] = module.exports;\nmodule.exports.init = async () => {\n const [modules] = await loadFiles();\n const {\n key\n } = modules.data.FilePicker;\n filepicker.setKey(key);\n Images.hide();\n};\nmodule.exports.uploadFile = (filename, data) => {\n const mimetype = '';\n filepicker.store(data, {\n mimetype,\n filename\n }, fpFile => {\n filepicker.exportFile(fpFile, log, log);\n });\n};\nmodule.exports.saveFile = callback => {\n filepicker.pick(upload(callback));\n};\nfunction _upload(callback, file) {\n const {\n url,\n filename\n } = file;\n const responseType = 'arraybuffer';\n const success = exec.with(callback, filename);\n ajax({\n url,\n responseType,\n success\n });\n}\nfunction loadFiles() {\n const js = '//api.filepicker.io/v2/filepicker.js';\n return Promise.all([Files.get('modules'), load.js(js)]);\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/cloud.js\n}");
|
|
393
393
|
|
|
394
394
|
/***/ },
|
|
395
395
|
|
|
@@ -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 {\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.
|
|
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.mjs */ \"./client/dom/images.mjs\");\nconst Events = __webpack_require__(/*! #dom/events */ \"./client/dom/events/index.mjs\");\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\nconst {\n getTitle\n} = __webpack_require__(/*! ../../../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\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//Users/coderaiser/cloudcmd/client/modules/config/index.js\n}");
|
|
415
415
|
|
|
416
416
|
/***/ },
|
|
417
417
|
|
|
@@ -433,7 +433,7 @@ eval("{\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/c
|
|
|
433
433
|
(module, exports, __webpack_require__) {
|
|
434
434
|
|
|
435
435
|
"use strict";
|
|
436
|
-
eval("{/* global CloudCmd */\n/* global DOM */\n\n\n\nCloudCmd.Contact = exports;\nconst olark = __webpack_require__(/*! @cloudcmd/olark */ \"./node_modules/@cloudcmd/olark/index.js\");\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.
|
|
436
|
+
eval("{/* global CloudCmd */\n/* global DOM */\n\n\n\nCloudCmd.Contact = exports;\nconst olark = __webpack_require__(/*! @cloudcmd/olark */ \"./node_modules/@cloudcmd/olark/index.js\");\nconst Images = __webpack_require__(/*! ../dom/images.mjs */ \"./client/dom/images.mjs\");\nconst {\n Events\n} = DOM;\nconst {\n Key\n} = CloudCmd;\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nmodule.exports.init = () => {\n Events.addKey(onKey);\n olark.identify('6216-545-10-4223');\n olark('api.box.onExpand', show);\n olark('api.box.onShow', show);\n olark('api.box.onShrink', hide);\n};\nfunction show() {\n Key.unsetBind();\n Images.hide();\n olark('api.box.expand');\n}\nfunction hide() {\n Key.setBind();\n olark('api.box.hide');\n}\nfunction onKey({\n keyCode\n}) {\n if (keyCode === Key.ESC) hide();\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/contact.js\n}");
|
|
437
437
|
|
|
438
438
|
/***/ },
|
|
439
439
|
|
|
@@ -499,7 +499,7 @@ eval("{/* global CloudCmd */\n\n\n\nconst montag = __webpack_require__(/*! monta
|
|
|
499
499
|
(module, exports, __webpack_require__) {
|
|
500
500
|
|
|
501
501
|
"use strict";
|
|
502
|
-
eval("{\n\n/* global CloudCmd */\nCloudCmd.Help = exports;\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.
|
|
502
|
+
eval("{\n\n/* global CloudCmd */\nCloudCmd.Help = exports;\nconst Images = __webpack_require__(/*! ../dom/images.mjs */ \"./client/dom/images.mjs\");\nmodule.exports.init = () => {\n Images.show.load('top');\n};\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nfunction show() {\n const positionLoad = 'top';\n const relative = true;\n CloudCmd.Markdown.show('/HELP.md', {\n positionLoad,\n relative\n });\n}\nfunction hide() {\n CloudCmd.View.hide();\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/help.js\n}");
|
|
503
503
|
|
|
504
504
|
/***/ },
|
|
505
505
|
|
|
@@ -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 {\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.
|
|
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.mjs */ \"./client/dom/images.mjs\");\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//Users/coderaiser/cloudcmd/client/modules/konsole.js\n}");
|
|
514
514
|
|
|
515
515
|
/***/ },
|
|
516
516
|
|
|
@@ -521,7 +521,7 @@ eval("{\n\n/* global CloudCmd */\n/* global Util */\n/* global DOM */\n/* global
|
|
|
521
521
|
(module, exports, __webpack_require__) {
|
|
522
522
|
|
|
523
523
|
"use strict";
|
|
524
|
-
eval("{\n\n/* global CloudCmd */\nCloudCmd.Markdown = exports;\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.
|
|
524
|
+
eval("{\n\n/* global CloudCmd */\nCloudCmd.Markdown = exports;\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst Images = __webpack_require__(/*! ../dom/images.mjs */ \"./client/dom/images.mjs\");\nconst {\n Markdown\n} = __webpack_require__(/*! ../dom/rest */ \"./client/dom/rest.js\");\nconst {\n alert\n} = __webpack_require__(/*! ../dom/dialog */ \"./client/dom/dialog.js\");\nmodule.exports.init = async () => {\n Images.show.load('top');\n await CloudCmd.View();\n};\nmodule.exports.show = show;\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\nasync function show(name, options = {}) {\n const {\n positionLoad,\n relative\n } = options;\n Images.show.load(positionLoad);\n if (relative) name += '?relative';\n const [error, innerHTML] = await Markdown.read(name);\n Images.hide();\n if (error) return alert(error.message, {\n cancel: false\n });\n const className = 'help';\n const div = createElement('div', {\n className,\n innerHTML\n });\n CloudCmd.View.show(div);\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/markdown.js\n}");
|
|
525
525
|
|
|
526
526
|
/***/ },
|
|
527
527
|
|
|
@@ -598,7 +598,7 @@ eval("{\n\nconst {\n getExt\n} = __webpack_require__(/*! ../../../common/util *
|
|
|
598
598
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
599
599
|
|
|
600
600
|
"use strict";
|
|
601
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ setListeners: () => (/* binding */ setListeners)\n/* harmony export */ });\n/* harmony import */ var for_each_key__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! for-each-key */ \"./node_modules/for-each-key/lib/for-each-key.js\");\n/* harmony import */ var wraptile__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n/* harmony import */ var _format_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./format.js */ \"./client/modules/operation/format.js\");\n/* global DOM */\n\n\n\n\nconst {Dialog, Images} = DOM;\n\nconst setListeners = (options) => (emitter) => {\n const {\n operation,\n callback,\n noContinue,\n from,\n to,\n } = options;\n \n let done;\n let lastError;\n \n const onAbort = wraptile__WEBPACK_IMPORTED_MODULE_1__(({emitter, operation}) => {\n emitter.abort();\n \n const msg = `${operation} aborted`;\n \n lastError = true;\n \n Dialog.alert(msg, {\n cancel: false,\n });\n });\n \n const removeListener = emitter.removeListener.bind(emitter);\n const on = emitter.on.bind(emitter);\n \n const message = _format_js__WEBPACK_IMPORTED_MODULE_2__(operation, from, to);\n const progress = Dialog.progress(message);\n \n progress.catch(onAbort({\n emitter,\n operation,\n }));\n \n let noProgress = true;\n const listeners = {\n progress: (value) => {\n done = value === 100;\n progress.setProgress(value);\n noProgress = false;\n },\n \n end: () => {\n Images.hide();\n for_each_key__WEBPACK_IMPORTED_MODULE_0__(removeListener, listeners);\n progress.remove();\n \n if (lastError || done || noProgress)\n callback();\n },\n \n error: async (error) => {\n lastError = error;\n \n if (noContinue) {\n listeners.end(error);\n Dialog.alert(error);\n progress.remove();\n \n return;\n }\n \n const [cancel] = await Dialog.confirm(`${error}\n Continue?`);\n \n if (!done && !cancel)\n return emitter.continue();\n \n emitter.abort();\n progress.remove();\n },\n };\n \n for_each_key__WEBPACK_IMPORTED_MODULE_0__(on, listeners);\n};\n\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/operation/set-listeners.mjs\n}");
|
|
601
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ setListeners: () => (/* binding */ setListeners)\n/* harmony export */ });\n/* harmony import */ var for_each_key__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! for-each-key */ \"./node_modules/for-each-key/lib/for-each-key.js\");\n/* harmony import */ var wraptile__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n/* harmony import */ var _format_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./format.js */ \"./client/modules/operation/format.js\");\n/* global DOM */\n\n\n\n\nconst {Dialog, Images} = DOM;\n\nconst setListeners = (options) => (emitter) => {\n const {\n operation,\n callback,\n noContinue,\n from,\n to,\n } = options;\n \n let done;\n let lastError;\n \n const onAbort = wraptile__WEBPACK_IMPORTED_MODULE_1__(({emitter, operation}) => {\n emitter.abort();\n \n const msg = `${operation} aborted`;\n \n lastError = true;\n \n Dialog.alert(msg, {\n cancel: false,\n });\n });\n \n const removeListener = emitter.removeListener.bind(emitter);\n const on = emitter.on.bind(emitter);\n \n const message = _format_js__WEBPACK_IMPORTED_MODULE_2__(operation, from, to);\n const progress = Dialog.progress(message);\n \n progress.catch(onAbort({\n emitter,\n operation,\n }));\n \n let noProgress = true;\n \n const listeners = {\n progress: (value) => {\n done = value === 100;\n progress.setProgress(value);\n noProgress = false;\n },\n \n end: () => {\n Images.hide();\n for_each_key__WEBPACK_IMPORTED_MODULE_0__(removeListener, listeners);\n progress.remove();\n \n if (lastError || done || noProgress)\n callback();\n },\n \n error: async (error) => {\n lastError = error;\n \n if (noContinue) {\n listeners.end(error);\n Dialog.alert(error);\n progress.remove();\n \n return;\n }\n \n const [cancel] = await Dialog.confirm(`${error}\n Continue?`);\n \n if (!done && !cancel)\n return emitter.continue();\n \n emitter.abort();\n progress.remove();\n },\n };\n \n for_each_key__WEBPACK_IMPORTED_MODULE_0__(on, listeners);\n};\n\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/operation/set-listeners.mjs\n}");
|
|
602
602
|
|
|
603
603
|
/***/ },
|
|
604
604
|
|
|
@@ -620,7 +620,7 @@ eval("{\n\n__webpack_require__(/*! domtokenlist-shim */ \"./node_modules/domtoke
|
|
|
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 {\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.
|
|
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.mjs */ \"./client/dom/images.mjs\");\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(globalThis.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//Users/coderaiser/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 {\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.
|
|
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.mjs */ \"./client/dom/images.mjs\");\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(globalThis.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//Users/coderaiser/cloudcmd/client/modules/terminal.js\n}");
|
|
635
635
|
|
|
636
636
|
/***/ },
|
|
637
637
|
|
|
@@ -642,7 +642,7 @@ eval("{\n\n/* global CloudCmd */\n/* global gritty */\nconst {\n tryToCatch\n}
|
|
|
642
642
|
(module, exports, __webpack_require__) {
|
|
643
643
|
|
|
644
644
|
"use strict";
|
|
645
|
-
eval("{/* global CloudCmd, DOM */\n\n\n\nCloudCmd.Upload = exports;\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst Files = __webpack_require__(/*! ../dom/files */ \"./client/dom/files.js\");\nconst Images = __webpack_require__(/*! ../dom/images */ \"./client/dom/images.
|
|
645
|
+
eval("{/* global CloudCmd, DOM */\n\n\n\nCloudCmd.Upload = exports;\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst Files = __webpack_require__(/*! ../dom/files */ \"./client/dom/files.js\");\nconst Images = __webpack_require__(/*! ../dom/images.mjs */ \"./client/dom/images.mjs\");\nconst uploadFiles = __webpack_require__(/*! ../dom/upload-files */ \"./client/dom/upload-files.js\");\nmodule.exports.init = async () => {\n Images.show.load('top');\n await CloudCmd.View();\n};\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nasync function show() {\n Images.show.load('top');\n const innerHTML = await Files.get('upload');\n const autoSize = true;\n const el = createElement('div', {\n innerHTML\n });\n CloudCmd.View.show(el, {\n autoSize,\n afterShow\n });\n const fontFamily = ['\"Droid Sans Mono\"', '\"Ubuntu Mono\"', '\"Consolas\"', 'monospace'].join(', ');\n createElement('style', {\n dataName: 'upload-css',\n innerText: `[data-name=js-upload-file-button] {\n font-family: ${fontFamily};\n font-size: 16px;\n margin: 10px 0 10px 0;\n }`\n });\n}\nfunction hide() {\n CloudCmd.View.hide();\n}\nfunction afterShow() {\n const button = DOM.getByDataName('js-upload-file-button');\n Images.hide();\n DOM.Events.add('change', button, ({\n target\n }) => {\n const {\n files\n } = target;\n hide();\n uploadFiles(files);\n });\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/upload.js\n}");
|
|
646
646
|
|
|
647
647
|
/***/ },
|
|
648
648
|
|
|
@@ -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 {\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.
|
|
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.mjs */ \"./client/dom/images.mjs\");\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//Users/coderaiser/cloudcmd/client/modules/user-menu/index.js\n}");
|
|
668
668
|
|
|
669
669
|
/***/ },
|
|
670
670
|
|
|
@@ -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\nconst CloudCmd = globalThis.CloudCmd || {};\nconst DOM = globalThis.DOM || {};\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.mjs */ \"./common/cloudfunc.mjs\");\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.mjs\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.
|
|
722
|
+
eval("{/* global CloudCmd, DOM */\n\n\n\nconst CloudCmd = globalThis.CloudCmd || {};\nconst DOM = globalThis.DOM || {};\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.mjs */ \"./common/cloudfunc.mjs\");\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.mjs\");\nconst Images = __webpack_require__(/*! ../../dom/images.mjs */ \"./client/dom/images.mjs\");\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, overrides = {}) {\n const {\n createElement = _createElement\n } = overrides;\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, overrides = {}) {\n const {\n modal = _modal\n } = overrides;\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//Users/coderaiser/cloudcmd/client/modules/view/index.js\n}");
|
|
723
723
|
|
|
724
724
|
/***/ },
|
|
725
725
|
|