cloudcmd 19.1.15 → 19.1.17
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 +16 -0
- package/HELP.md +3 -1
- package/README.md +1 -1
- package/common/{util.js → util.mjs} +7 -9
- package/dist/3cdc9fd954ca40bafbbb.svg +21 -0
- package/dist/455c6a5c9b2a52a48e22.svg +17 -0
- package/dist/74eabceeb58ee6f61f3f.svg +74 -0
- package/dist/89c10a315f32997af10b.svg +21 -0
- package/dist/b480a80939f4e9bca26a.svg +21 -0
- package/dist/cloudcmd.common.css +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/3cdc9fd954ca40bafbbb.svg +21 -0
- package/dist-dev/455c6a5c9b2a52a48e22.svg +17 -0
- package/dist-dev/74eabceeb58ee6f61f3f.svg +74 -0
- package/dist-dev/89c10a315f32997af10b.svg +21 -0
- package/dist-dev/b480a80939f4e9bca26a.svg +21 -0
- package/dist-dev/cloudcmd.common.css +90 -90
- package/dist-dev/cloudcmd.common.js +71 -60
- package/dist-dev/sw.js +1 -1
- package/package.json +5 -2
|
@@ -26,7 +26,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
26
26
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
27
27
|
|
|
28
28
|
"use strict";
|
|
29
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\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 wraptile__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n/* harmony import */ var load_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var
|
|
29
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\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 wraptile__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n/* harmony import */ var load_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var _common_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! #common/util */ \"./common/util.mjs\");\n/* harmony import */ var _css_main_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../css/main.css */ \"./css/main.css\");\n/* harmony import */ var _sw_register_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sw/register.mjs */ \"./client/sw/register.mjs\");\n/* harmony import */ var _sort_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./sort.mjs */ \"./client/sort.mjs\");\n/* harmony import */ var _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\n/* harmony import */ var _dom_index_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./dom/index.mjs */ \"./client/dom/index.mjs\");\n/* harmony import */ var _client_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./client.mjs */ \"./client/client.mjs\");\n/* harmony import */ var _listeners_index_mjs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./listeners/index.mjs */ \"./client/listeners/index.mjs\");\n\n\n\n\n\n\n\n\n\n\n\nconst isDev = \"development\" === 'development';\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (init);\nglobalThis.CloudCmd = init;\nasync function init(config) {\n globalThis.CloudCmd = (0,_client_mjs__WEBPACK_IMPORTED_MODULE_9__.createCloudCmd)({\n DOM: _dom_index_mjs__WEBPACK_IMPORTED_MODULE_8__[\"default\"],\n Listeners: _listeners_index_mjs__WEBPACK_IMPORTED_MODULE_10__\n });\n globalThis.DOM = _dom_index_mjs__WEBPACK_IMPORTED_MODULE_8__[\"default\"];\n globalThis.Util = _common_util__WEBPACK_IMPORTED_MODULE_3__;\n globalThis.CloudFunc = _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_7__;\n await register(config);\n (0,_sort_mjs__WEBPACK_IMPORTED_MODULE_6__.initSortPanel)();\n globalThis.CloudCmd.sortPanel = _sort_mjs__WEBPACK_IMPORTED_MODULE_6__.sortPanel;\n const prefix = getPrefix(config.prefix);\n globalThis.CloudCmd.init(prefix, config);\n if (globalThis.CloudCmd.config('menu') === 'aleman') setTimeout(() => {\n Promise.resolve(/*! import() */).then(__webpack_require__.bind(__webpack_require__, /*! https://esm.sh/@putout/processor-html */ \"https://esm.sh/@putout/processor-html\"));\n Promise.resolve(/*! import() */).then(__webpack_require__.bind(__webpack_require__, /*! https://esm.sh/@putout/bundle */ \"https://esm.sh/@putout/bundle\"));\n }, 100);\n}\nfunction getPrefix(prefix) {\n if (!prefix) return '';\n if (!prefix.indexOf('/')) return prefix;\n return `/${prefix}`;\n}\nconst onUpdateFound = wraptile__WEBPACK_IMPORTED_MODULE_1__(async config => {\n if (isDev) return;\n const {\n DOM\n } = globalThis;\n const prefix = getPrefix(config.prefix);\n await load_js__WEBPACK_IMPORTED_MODULE_2__.js(`${prefix}/dist/cloudcmd.common.js`);\n await load_js__WEBPACK_IMPORTED_MODULE_2__.js(`${prefix}/dist/cloudcmd.js`);\n console.log('cloudcmd: sw: updated');\n DOM.Events.removeAll();\n globalThis.CloudCmd(config);\n});\nasync function register(config) {\n const {\n prefix\n } = config;\n const sw = await (0,_sw_register_mjs__WEBPACK_IMPORTED_MODULE_5__.registerSW)(prefix);\n (0,_sw_register_mjs__WEBPACK_IMPORTED_MODULE_5__.listenSW)(sw, 'updatefound', onUpdateFound(config));\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/cloudcmd.mjs\n}");
|
|
30
30
|
|
|
31
31
|
/***/ },
|
|
32
32
|
|
|
@@ -41,6 +41,17 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
41
41
|
|
|
42
42
|
/***/ },
|
|
43
43
|
|
|
44
|
+
/***/ "./client/dom/cmd.mjs"
|
|
45
|
+
/*!****************************!*\
|
|
46
|
+
!*** ./client/dom/cmd.mjs ***!
|
|
47
|
+
\****************************/
|
|
48
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
49
|
+
|
|
50
|
+
"use strict";
|
|
51
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getSelectedFiles: () => (/* binding */ getSelectedFiles),\n/* harmony export */ isSelected: () => (/* binding */ isSelected),\n/* harmony export */ selectAllFiles: () => (/* binding */ selectAllFiles),\n/* harmony export */ selectFile: () => (/* binding */ selectFile),\n/* harmony export */ toggleAllSelectedFiles: () => (/* binding */ toggleAllSelectedFiles),\n/* harmony export */ toggleSelectedFile: () => (/* binding */ toggleSelectedFile),\n/* harmony export */ unselectFile: () => (/* binding */ unselectFile)\n/* harmony export */ });\n/* global DOM */\nconst SELECTED_FILE = 'selected-file';\nconst Cmd = {\n getSelectedFiles,\n isSelected,\n unselectFile,\n selectFile,\n selectAllFiles,\n toggleSelectedFile,\n toggleAllSelectedFiles\n};\n\n/**\n * selected file check\n *\n * @param currentFile\n */\nfunction isSelected(currentFile) {\n if (!currentFile) return false;\n return DOM.isContainClass(currentFile, SELECTED_FILE);\n}\n\n/**\n * select current file\n * @param currentFile\n */\nfunction selectFile(currentFile) {\n const current = currentFile || DOM.getCurrentFile();\n current.classList.add(SELECTED_FILE);\n return Cmd;\n}\nfunction unselectFile(currentFile) {\n const current = currentFile || DOM.getCurrentFile();\n current.classList.remove(SELECTED_FILE);\n return Cmd;\n}\nfunction 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}\nfunction toggleAllSelectedFiles() {\n DOM.getAllFiles().map(DOM.toggleSelectedFile);\n return Cmd;\n}\nfunction selectAllFiles() {\n DOM.getAllFiles().map(DOM.selectFile);\n return Cmd;\n}\n\n/**\n * unified way to get selected files\n *\n * @currentFile\n */\nfunction getSelectedFiles() {\n const panel = DOM.getPanel();\n const selected = DOM.getByClassAll(SELECTED_FILE, panel);\n return Array.from(selected);\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/cmd.mjs\n}");
|
|
52
|
+
|
|
53
|
+
/***/ },
|
|
54
|
+
|
|
44
55
|
/***/ "./client/dom/current-file.mjs"
|
|
45
56
|
/*!*************************************!*\
|
|
46
57
|
!*** ./client/dom/current-file.mjs ***!
|
|
@@ -52,36 +63,36 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
52
63
|
|
|
53
64
|
/***/ },
|
|
54
65
|
|
|
55
|
-
/***/ "./client/dom/dialog.
|
|
56
|
-
|
|
57
|
-
!*** ./client/dom/dialog.
|
|
58
|
-
|
|
59
|
-
(
|
|
66
|
+
/***/ "./client/dom/dialog.mjs"
|
|
67
|
+
/*!*******************************!*\
|
|
68
|
+
!*** ./client/dom/dialog.mjs ***!
|
|
69
|
+
\*******************************/
|
|
70
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
60
71
|
|
|
61
72
|
"use strict";
|
|
62
|
-
eval("{
|
|
73
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ alert: () => (/* binding */ alert),\n/* harmony export */ confirm: () => (/* binding */ confirm),\n/* harmony export */ progress: () => (/* binding */ progress),\n/* harmony export */ prompt: () => (/* binding */ prompt)\n/* harmony export */ });\n/* harmony import */ var try_to_catch__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n/* harmony import */ var smalltalk__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! smalltalk */ \"./node_modules/smalltalk/lib/smalltalk.js\");\n\n\nconst title = 'Cloud Commander';\nconst alert = (...a) => smalltalk__WEBPACK_IMPORTED_MODULE_1__.alert(title, ...a, {\n cancel: false\n});\nconst prompt = (...a) => (0,try_to_catch__WEBPACK_IMPORTED_MODULE_0__.tryToCatch)(smalltalk__WEBPACK_IMPORTED_MODULE_1__.prompt, title, ...a);\nconst confirm = (...a) => (0,try_to_catch__WEBPACK_IMPORTED_MODULE_0__.tryToCatch)(smalltalk__WEBPACK_IMPORTED_MODULE_1__.confirm, title, ...a);\nconst progress = (...a) => smalltalk__WEBPACK_IMPORTED_MODULE_1__.progress(title, ...a);\nalert.noFiles = () => {\n return smalltalk__WEBPACK_IMPORTED_MODULE_1__.alert(title, 'No files selected!', {\n cancel: false\n });\n};\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/dialog.mjs\n}");
|
|
63
74
|
|
|
64
75
|
/***/ },
|
|
65
76
|
|
|
66
|
-
/***/ "./client/dom/directory.
|
|
67
|
-
|
|
68
|
-
!*** ./client/dom/directory.
|
|
69
|
-
|
|
70
|
-
(
|
|
77
|
+
/***/ "./client/dom/directory.mjs"
|
|
78
|
+
/*!**********************************!*\
|
|
79
|
+
!*** ./client/dom/directory.mjs ***!
|
|
80
|
+
\**********************************/
|
|
81
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
71
82
|
|
|
72
83
|
"use strict";
|
|
73
|
-
eval("{\n\n/*
|
|
84
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ uploadDirectory: () => (/* binding */ uploadDirectory)\n/* harmony export */ });\n/* harmony import */ var philip__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! philip */ \"./node_modules/philip/lib/philip.js\");\n/* harmony import */ var _dom_dialog__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #dom/dialog */ \"./client/dom/dialog.mjs\");\n/* harmony import */ var _images_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./images.mjs */ \"./client/dom/images.mjs\");\n/* harmony import */ var _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\n/* global DOM, CloudCmd */\n\n\n\n\nconst uploadDirectory = items => {\n if (items.length) _images_mjs__WEBPACK_IMPORTED_MODULE_2__.show('top');\n const entries = Array.from(items).map(item => item.webkitGetAsEntry());\n const dirPath = DOM.getCurrentDirPath();\n const path = dirPath.replace(/\\/$/, '');\n const progress = _dom_dialog__WEBPACK_IMPORTED_MODULE_1__.progress('Uploading...');\n progress.catch(() => {\n _dom_dialog__WEBPACK_IMPORTED_MODULE_1__.alert('Upload aborted');\n uploader.abort();\n });\n const uploader = philip__WEBPACK_IMPORTED_MODULE_0__(entries, (type, name, data, i, n, callback) => {\n const {\n prefixURL\n } = CloudCmd;\n const full = prefixURL + _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_3__.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 _dom_dialog__WEBPACK_IMPORTED_MODULE_1__.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.mjs\n}");
|
|
74
85
|
|
|
75
86
|
/***/ },
|
|
76
87
|
|
|
77
|
-
/***/ "./client/dom/dom-tree.
|
|
78
|
-
|
|
79
|
-
!*** ./client/dom/dom-tree.
|
|
80
|
-
|
|
81
|
-
(
|
|
88
|
+
/***/ "./client/dom/dom-tree.mjs"
|
|
89
|
+
/*!*********************************!*\
|
|
90
|
+
!*** ./client/dom/dom-tree.mjs ***!
|
|
91
|
+
\*********************************/
|
|
92
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
82
93
|
|
|
83
94
|
"use strict";
|
|
84
|
-
eval("{\n\
|
|
95
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getByClass: () => (/* binding */ getByClass),\n/* harmony export */ getByClassAll: () => (/* binding */ getByClassAll),\n/* harmony export */ getByDataName: () => (/* binding */ getByDataName),\n/* harmony export */ getById: () => (/* binding */ getById),\n/* harmony export */ getByTag: () => (/* binding */ getByTag),\n/* harmony export */ hide: () => (/* binding */ hide),\n/* harmony export */ isContainClass: () => (/* binding */ isContainClass),\n/* harmony export */ show: () => (/* binding */ show)\n/* harmony export */ });\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst DOM = {\n show,\n hide,\n getByClass,\n getByClassAll,\n getByDataName,\n getById,\n getByTag,\n isContainClass\n};\n\n/**\n * check class of element\n *\n * @param element\n * @param className\n */\nfunction isContainClass(element, className) {\n if (!element) throw Error('element could not be empty!');\n if (!className) throw Error('className could not be empty!');\n if (Array.isArray(className)) return className.some(currify__WEBPACK_IMPORTED_MODULE_0__(isContainClass, element));\n const {\n classList\n } = element;\n return classList.contains(className);\n}\n\n/**\n * Function search element by tag\n * @param tag - className\n * @param element - element\n */\nfunction getByTag(tag, element = document) {\n return element.getElementsByTagName(tag);\n}\n\n/**\n * Function search element by id\n * @param id\n * @param element\n */\nfunction getById(id, element = document) {\n return element.querySelector(`#${id}`);\n}\n\n/**\n * Function search first element by class name\n * @param className - className\n * @param element - element\n */\nfunction getByClass(className, element = document) {\n return DOM.getByClassAll(className, element)[0];\n}\nfunction getByDataName(attribute, element = document) {\n const selector = '[' + 'data-name=\"' + attribute + '\"]';\n return element.querySelector(selector);\n}\n\n/**\n * Function search element by class name\n * @param className\n * @param element\n */\nfunction getByClassAll(className, element) {\n return (element || document).getElementsByClassName(className);\n}\n\n/**\n * add class=hidden to element\n *\n * @param element\n */\nfunction hide(element) {\n element.classList.add('hidden');\n return DOM;\n}\nfunction show(element) {\n element.classList.remove('hidden');\n return DOM;\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/dom-tree.mjs\n}");
|
|
85
96
|
|
|
86
97
|
/***/ },
|
|
87
98
|
|
|
@@ -107,14 +118,14 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
107
118
|
|
|
108
119
|
/***/ },
|
|
109
120
|
|
|
110
|
-
/***/ "./client/dom/files.
|
|
111
|
-
|
|
112
|
-
!*** ./client/dom/files.
|
|
113
|
-
|
|
114
|
-
(
|
|
121
|
+
/***/ "./client/dom/files.mjs"
|
|
122
|
+
/*!******************************!*\
|
|
123
|
+
!*** ./client/dom/files.mjs ***!
|
|
124
|
+
\******************************/
|
|
125
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
115
126
|
|
|
116
127
|
"use strict";
|
|
117
|
-
eval("{\n\n/*
|
|
128
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ get: () => (/* binding */ get)\n/* harmony export */ });\n/* harmony import */ var itype__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\n/* harmony import */ var es6_promisify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.mjs\");\n/* harmony import */ var _dom_load__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! #dom/load */ \"./client/dom/load.mjs\");\n/* harmony import */ var _rest_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./rest.js */ \"./client/dom/rest.js\");\n/* global CloudCmd */\n\n\n\n\nconst Promises = {};\nconst FILES_JSON = 'config|modules';\nconst FILES_HTML = 'file|path|link|pathLink|media';\nconst FILES_HTML_ROOT = 'view/media-tmpl|config-tmpl|upload';\nconst DIR_HTML = '/tmpl/';\nconst DIR_HTML_FS = `${DIR_HTML}fs/`;\nconst DIR_JSON = '/json/';\nconst timeout = getTimeoutOnce(2000);\nconst get = getFile;\nfunction getFile(name) {\n const type = itype__WEBPACK_IMPORTED_MODULE_0__(name);\n check(name);\n if (type === 'string') return getModule(name);\n if (type === 'array') return Promise.all(name.map(getFile));\n}\nfunction check(name) {\n if (!name) throw Error('name could not be empty!');\n}\nfunction getModule(name) {\n const regExpHTML = RegExp(FILES_HTML + '|' + FILES_HTML_ROOT);\n const regExpJSON = RegExp(FILES_JSON);\n const isHTML = regExpHTML.test(name);\n const isJSON = regExpJSON.test(name);\n if (!isHTML && !isJSON) return showError(name);\n if (name === 'config') return getConfig();\n const path = getPath(name, isHTML, isJSON);\n return getSystemFile(path);\n}\nfunction getPath(name, isHTML, isJSON) {\n let path;\n const regExp = RegExp(FILES_HTML_ROOT);\n const isRoot = regExp.test(name);\n if (isHTML) {\n if (isRoot) path = DIR_HTML + name.replace('-tmpl', '');else path = DIR_HTML_FS + name;\n path += '.hbs';\n } else if (isJSON) {\n path = DIR_JSON + name + '.json';\n }\n return path;\n}\nfunction showError(name) {\n const str = `Wrong file name: ${name}`;\n const error = Error(str);\n throw error;\n}\nconst getSystemFile = (0,es6_promisify__WEBPACK_IMPORTED_MODULE_1__.promisify)((file, callback) => {\n const {\n prefix\n } = CloudCmd;\n if (!Promises[file]) Promises[file] = new Promise((success, error) => {\n const url = prefix + file;\n _dom_load__WEBPACK_IMPORTED_MODULE_2__.ajax({\n url,\n success,\n error\n });\n });\n Promises[file].then(data => {\n callback(null, data);\n }, error => {\n Promises[file] = null;\n callback(error);\n });\n});\nconst getConfig = async () => {\n let is;\n if (!Promises.config) Promises.config = () => {\n is = true;\n return _rest_js__WEBPACK_IMPORTED_MODULE_3__.Config.read();\n };\n const [, data] = await Promises.config();\n if (data) is = false;\n timeout(() => {\n if (!is) Promises.config = null;\n });\n return data;\n};\nfunction getTimeoutOnce(time) {\n let is;\n return callback => {\n if (is) return;\n is = true;\n setTimeout(() => {\n is = false;\n callback();\n }, time);\n };\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/files.mjs\n}");
|
|
118
129
|
|
|
119
130
|
/***/ },
|
|
120
131
|
|
|
@@ -129,14 +140,14 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
129
140
|
|
|
130
141
|
/***/ },
|
|
131
142
|
|
|
132
|
-
/***/ "./client/dom/index.
|
|
133
|
-
|
|
134
|
-
!*** ./client/dom/index.
|
|
135
|
-
|
|
136
|
-
(
|
|
143
|
+
/***/ "./client/dom/index.mjs"
|
|
144
|
+
/*!******************************!*\
|
|
145
|
+
!*** ./client/dom/index.mjs ***!
|
|
146
|
+
\******************************/
|
|
147
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
137
148
|
|
|
138
149
|
"use strict";
|
|
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__(/*! #dom/load */ \"./client/dom/load.mjs\");\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}");
|
|
150
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ CurrentInfo: () => (/* binding */ CurrentInfo),\n/* harmony export */ changePanel: () => (/* binding */ changePanel),\n/* harmony export */ checkStorageHash: () => (/* binding */ checkStorageHash),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ deleteCurrent: () => (/* binding */ deleteCurrent),\n/* harmony export */ deleteSelected: () => (/* binding */ deleteSelected),\n/* harmony export */ duplicatePanel: () => (/* binding */ duplicatePanel),\n/* harmony export */ expandSelection: () => (/* binding */ expandSelection),\n/* harmony export */ getActiveFiles: () => (/* binding */ getActiveFiles),\n/* harmony export */ getAllFiles: () => (/* binding */ getAllFiles),\n/* harmony export */ getCSSVar: () => (/* binding */ getCSSVar),\n/* harmony export */ getCurrentData: () => (/* binding */ getCurrentData),\n/* harmony export */ getCurrentDate: () => (/* binding */ getCurrentDate),\n/* harmony export */ getCurrentDirName: () => (/* binding */ getCurrentDirName),\n/* harmony export */ getCurrentLink: () => (/* binding */ getCurrentLink),\n/* harmony export */ getCurrentMode: () => (/* binding */ getCurrentMode),\n/* harmony export */ getCurrentOwner: () => (/* binding */ getCurrentOwner),\n/* harmony export */ getCurrentSize: () => (/* binding */ getCurrentSize),\n/* harmony export */ getFM: () => (/* binding */ getFM),\n/* harmony export */ getFilenames: () => (/* binding */ getFilenames),\n/* harmony export */ getFiles: () => (/* binding */ getFiles),\n/* harmony export */ getNotCurrentDirPath: () => (/* binding */ getNotCurrentDirPath),\n/* harmony export */ getPackerExt: () => (/* binding */ getPackerExt),\n/* harmony export */ getPanel: () => (/* binding */ getPanel),\n/* harmony export */ getPanelPosition: () => (/* binding */ getPanelPosition),\n/* harmony export */ getParentDirPath: () => (/* binding */ getParentDirPath),\n/* harmony export */ getRefreshButton: () => (/* binding */ getRefreshButton),\n/* harmony export */ goToDirectory: () => (/* binding */ goToDirectory),\n/* harmony export */ hidePanel: () => (/* binding */ hidePanel),\n/* harmony export */ loadCurrentHash: () => (/* binding */ loadCurrentHash),\n/* harmony export */ loadCurrentSize: () => (/* binding */ loadCurrentSize),\n/* harmony export */ loadRemote: () => (/* binding */ loadRemote),\n/* harmony export */ loadSocket: () => (/* binding */ loadSocket),\n/* harmony export */ promptNewDir: () => (/* binding */ promptNewDir),\n/* harmony export */ promptNewFile: () => (/* binding */ promptNewFile),\n/* harmony export */ remove: () => (/* binding */ remove),\n/* harmony export */ saveDataToStorage: () => (/* binding */ saveDataToStorage),\n/* harmony export */ scrollByPages: () => (/* binding */ scrollByPages),\n/* harmony export */ scrollIntoViewIfNeeded: () => (/* binding */ scrollIntoViewIfNeeded),\n/* harmony export */ setCurrentSize: () => (/* binding */ setCurrentSize),\n/* harmony export */ setHistory: () => (/* binding */ setHistory),\n/* harmony export */ showPanel: () => (/* binding */ showPanel),\n/* harmony export */ shrinkSelection: () => (/* binding */ shrinkSelection),\n/* harmony export */ swapPanels: () => (/* binding */ swapPanels),\n/* harmony export */ unselectFiles: () => (/* binding */ unselectFiles),\n/* harmony export */ updateCurrentInfo: () => (/* binding */ updateCurrentInfo)\n/* harmony export */ });\n/* harmony import */ var _dom_load__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! #dom/load */ \"./client/dom/load.mjs\");\n/* harmony import */ var _dom_files__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #dom/files */ \"./client/dom/files.mjs\");\n/* harmony import */ var _dom_dialog__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! #dom/dialog */ \"./client/dom/dialog.mjs\");\n/* harmony import */ var _dom_events__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! #dom/events */ \"./client/dom/events/index.mjs\");\n/* harmony import */ var _common_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! #common/util */ \"./common/util.mjs\");\n/* harmony import */ var _images_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./images.mjs */ \"./client/dom/images.mjs\");\n/* harmony import */ var _rest_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rest.js */ \"./client/dom/rest.js\");\n/* harmony import */ var _storage_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./storage.js */ \"./client/dom/storage.js\");\n/* harmony import */ var _operations_rename_current_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./operations/rename-current.js */ \"./client/dom/operations/rename-current.js\");\n/* harmony import */ var _current_file_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./current-file.mjs */ \"./client/dom/current-file.mjs\");\n/* harmony import */ var _dom_tree_mjs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./dom-tree.mjs */ \"./client/dom/dom-tree.mjs\");\n/* harmony import */ var _cmd_mjs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./cmd.mjs */ \"./client/dom/cmd.mjs\");\n/* harmony import */ var _io_index_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./io/index.js */ \"./client/dom/io/index.js\");\n/* harmony import */ var _directory_mjs__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./directory.mjs */ \"./client/dom/directory.mjs\");\n/* harmony import */ var _buffer_mjs__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./buffer.mjs */ \"./client/dom/buffer.mjs\");\n/* harmony import */ var _load_remote_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./load-remote.js */ \"./client/dom/load-remote.js\");\n/* harmony import */ var _select_by_pattern_mjs__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./select-by-pattern.mjs */ \"./client/dom/select-by-pattern.mjs\");\n/* global CloudCmd */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst {\n assign\n} = Object;\nconst DOM = {\n getCurrentDirName,\n getNotCurrentDirPath,\n getParentDirPath,\n load: _dom_load__WEBPACK_IMPORTED_MODULE_0__,\n RESTful: _rest_js__WEBPACK_IMPORTED_MODULE_6__,\n Storage: _storage_js__WEBPACK_IMPORTED_MODULE_7__,\n loadRemote,\n loadSocket,\n promptNewDir,\n promptNewFile,\n unselectFiles,\n getActiveFiles,\n getCurrentDate,\n getCurrentSize,\n loadCurrentSize,\n loadCurrentHash,\n setCurrentSize,\n getCurrentMode,\n getCurrentOwner,\n getCurrentData,\n getRefreshButton,\n getAllFiles,\n expandSelection,\n shrinkSelection,\n setHistory,\n getCurrentLink,\n getFilenames,\n checkStorageHash,\n saveDataToStorage,\n getFM,\n getPanelPosition,\n getCSSVar,\n getPanel,\n getFiles,\n showPanel,\n hidePanel,\n remove,\n deleteCurrent,\n deleteSelected,\n renameCurrent: _operations_rename_current_js__WEBPACK_IMPORTED_MODULE_8__,\n scrollIntoViewIfNeeded,\n scrollByPages,\n changePanel,\n getPackerExt,\n goToDirectory,\n duplicatePanel,\n swapPanels,\n updateCurrentInfo\n};\nassign(DOM, {\n ..._dom_tree_mjs__WEBPACK_IMPORTED_MODULE_10__,\n ..._current_file_mjs__WEBPACK_IMPORTED_MODULE_9__,\n ..._cmd_mjs__WEBPACK_IMPORTED_MODULE_11__\n});\nconst CurrentInfo = {};\nDOM.Images = _images_mjs__WEBPACK_IMPORTED_MODULE_5__;\nDOM.load = _dom_load__WEBPACK_IMPORTED_MODULE_0__;\nDOM.Files = _dom_files__WEBPACK_IMPORTED_MODULE_1__;\nDOM.RESTful = _rest_js__WEBPACK_IMPORTED_MODULE_6__;\nDOM.IO = _io_index_js__WEBPACK_IMPORTED_MODULE_12__;\nDOM.Storage = _storage_js__WEBPACK_IMPORTED_MODULE_7__;\nDOM.Dialog = _dom_dialog__WEBPACK_IMPORTED_MODULE_2__;\nDOM.CurrentInfo = CurrentInfo;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DOM);\nDOM.uploadDirectory = _directory_mjs__WEBPACK_IMPORTED_MODULE_13__.uploadDirectory;\nDOM.Buffer = _buffer_mjs__WEBPACK_IMPORTED_MODULE_14__;\nDOM.Events = _dom_events__WEBPACK_IMPORTED_MODULE_3__;\nconst isString = a => typeof a === 'string';\nconst TabPanel = {\n 'js-left': null,\n 'js-right': null\n};\nfunction loadRemote(name, options, callback) {\n _load_remote_js__WEBPACK_IMPORTED_MODULE_15__(name, options, callback);\n return DOM;\n}\nfunction loadSocket(callback) {\n DOM.loadRemote('socket', {\n name: 'io'\n }, callback);\n return DOM;\n}\n\n/**\n * create new folder\n *\n */\nasync function promptNewDir() {\n await promptNew('directory');\n}\n\n/**\n * create new file\n *\n * @typeName\n * @type\n */\nasync function promptNewFile() {\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 _rest_js__WEBPACK_IMPORTED_MODULE_6__.createDirectory(path);else await _rest_js__WEBPACK_IMPORTED_MODULE_6__.write(path);\n await CloudCmd.refresh({\n currentName\n });\n}\n\n/**\n * get current directory name\n */\nfunction 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 directory path\n */\nfunction 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 directory path\n */\nfunction getNotCurrentDirPath() {\n const panel = DOM.getPanel({\n active: false\n });\n return DOM.getCurrentDirPath(panel);\n}\n\n/*\n * unselect all files\n */\nfunction 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 */\nfunction 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}\nfunction 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 */\nfunction 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 */\nasync function loadCurrentSize(currentFile) {\n const current = currentFile || DOM.getCurrentFile();\n const query = '?size';\n const link = DOM.getCurrentPath(current);\n _images_mjs__WEBPACK_IMPORTED_MODULE_5__.show.load();\n if (name === '..') return;\n const [, size] = await _rest_js__WEBPACK_IMPORTED_MODULE_6__.read(link + query);\n DOM.setCurrentSize(size, current);\n _images_mjs__WEBPACK_IMPORTED_MODULE_5__.hide();\n return current;\n}\n\n/**\n * load hash\n * @callback\n * @currentFile\n */\nasync function loadCurrentHash(currentFile) {\n const current = currentFile || DOM.getCurrentFile();\n const query = '?hash';\n const link = DOM.getCurrentPath(current);\n const [, data] = await _rest_js__WEBPACK_IMPORTED_MODULE_6__.read(link + query);\n return data;\n}\n\n/**\n * set size\n * @currentFile\n */\nfunction 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 */\nfunction 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 */\nfunction 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 */\nasync function getCurrentData(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 _rest_js__WEBPACK_IMPORTED_MODULE_6__.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_js__WEBPACK_IMPORTED_MODULE_7__.get(`${path}-data`)];\n const [e, data] = await _rest_js__WEBPACK_IMPORTED_MODULE_6__.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 */\nfunction getRefreshButton(panel = DOM.getPanel()) {\n return DOM.getByDataName('js-refresh', panel);\n}\nfunction 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 */\nasync function expandSelection() {\n const msg = 'expand';\n const {\n files\n } = CurrentInfo;\n await (0,_select_by_pattern_mjs__WEBPACK_IMPORTED_MODULE_16__.selectByPattern)(msg, files);\n}\n\n/**\n * open dialog with shrink selection\n */\nasync function shrinkSelection() {\n const msg = 'shrink';\n const {\n files\n } = CurrentInfo;\n await (0,_select_by_pattern_mjs__WEBPACK_IMPORTED_MODULE_16__.selectByPattern)(msg, files);\n}\n\n/**\n * setting history wrapper\n */\nfunction 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 * get link from current (or param) file\n *\n * @param currentFile - current file by default\n */\nfunction getCurrentLink(currentFile) {\n const current = currentFile || DOM.getCurrentFile();\n const link = DOM.getByTag('a', current);\n return link[0];\n}\nfunction 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 */\nasync function checkStorageHash(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_js__WEBPACK_IMPORTED_MODULE_7__.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 */\nasync function saveDataToStorage(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_js__WEBPACK_IMPORTED_MODULE_7__.set(nameHash, hash);\n await _storage_js__WEBPACK_IMPORTED_MODULE_7__.set(nameData, data);\n return hash;\n}\nfunction getFM() {\n const {\n parentElement\n } = DOM.getPanel();\n return parentElement;\n}\nfunction getPanelPosition(panel) {\n panel = panel || DOM.getPanel();\n return panel.dataset.name.replace('js-', '');\n}\nfunction 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 */\nfunction 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}\nfunction 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 */\nfunction 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 */\nfunction 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 child\n * @param element\n */\nfunction 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 */\nfunction 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 */\nfunction 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 */\nfunction scrollIntoViewIfNeeded(element, center = false) {\n if (!element || !element.scrollIntoViewIfNeeded) return;\n element.scrollIntoViewIfNeeded(center);\n}\n\n/* scroll on one page */\nfunction 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}\nfunction 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}\nfunction getPackerExt(type) {\n if (type === 'zip') return '.zip';\n return '.tar.gz';\n}\nasync function goToDirectory(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}\nasync function duplicatePanel() {\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}\nasync function swapPanels() {\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}\nfunction 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 = (0,_common_util__WEBPACK_IMPORTED_MODULE_4__.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.mjs\n}");
|
|
140
151
|
|
|
141
152
|
/***/ },
|
|
142
153
|
|
|
@@ -169,7 +180,7 @@ eval("{\n\n/* global CloudCmd */\nconst {\n promisify\n} = __webpack_require__(
|
|
|
169
180
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
170
181
|
|
|
171
182
|
"use strict";
|
|
172
|
-
eval("{\n\n/* global CloudCmd */\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n findObjByNameInArr\n} = __webpack_require__(/*!
|
|
183
|
+
eval("{\n\n/* global CloudCmd */\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst itype = __webpack_require__(/*! itype */ \"./node_modules/itype/lib/itype.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n findObjByNameInArr\n} = __webpack_require__(/*! #common/util */ \"./common/util.mjs\");\nconst Files = __webpack_require__(/*! #dom/files */ \"./client/dom/files.mjs\");\nmodule.exports = (name, options, callback = options) => {\n const {\n prefix,\n config\n } = CloudCmd;\n const o = options;\n if (o.name && window[o.name]) return callback();\n Files.get('modules').then(async modules => {\n const online = config('online') && navigator.onLine;\n const module = findObjByNameInArr(modules.remote, name);\n const isArray = itype.array(module.local);\n const {\n version\n } = module;\n let remoteTmpls;\n let local;\n if (isArray) {\n remoteTmpls = module.remote;\n ({\n local\n } = module);\n } else {\n remoteTmpls = [module.remote];\n local = [module.local];\n }\n const localURL = local.map(url => prefix + url);\n const remoteURL = remoteTmpls.map(tmpl => {\n return rendy(tmpl, {\n version\n });\n });\n if (online) {\n const [e] = await tryToCatch(load.parallel, remoteURL);\n if (!e) return callback();\n }\n const [e] = await tryToCatch(load.parallel, localURL);\n callback(e);\n });\n};\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/load-remote.js\n}");
|
|
173
184
|
|
|
174
185
|
/***/ },
|
|
175
186
|
|
|
@@ -191,7 +202,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
191
202
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
192
203
|
|
|
193
204
|
"use strict";
|
|
194
|
-
eval("{\n\n/* global CloudCmd */\nconst capitalize = __webpack_require__(/*! just-capitalize */ \"./node_modules/just-capitalize/index.cjs\");\nconst _Dialog = __webpack_require__(/*!
|
|
205
|
+
eval("{\n\n/* global CloudCmd */\nconst capitalize = __webpack_require__(/*! just-capitalize */ \"./node_modules/just-capitalize/index.cjs\");\nconst _Dialog = __webpack_require__(/*! #dom/dialog */ \"./client/dom/dialog.mjs\");\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
206
|
|
|
196
207
|
/***/ },
|
|
197
208
|
|
|
@@ -202,18 +213,18 @@ eval("{\n\n/* global CloudCmd */\nconst capitalize = __webpack_require__(/*! jus
|
|
|
202
213
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
203
214
|
|
|
204
215
|
"use strict";
|
|
205
|
-
eval("{\n\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n encode\n} = __webpack_require__(/*! ../../common/entity */ \"./common/entity.js\");\nconst Images = __webpack_require__(/*! ./images.mjs */ \"./client/dom/images.mjs\");\nconst IO = __webpack_require__(/*! ./io */ \"./client/dom/io/index.js\");\nconst Dialog = __webpack_require__(/*!
|
|
216
|
+
eval("{\n\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n encode\n} = __webpack_require__(/*! ../../common/entity */ \"./common/entity.js\");\nconst Images = __webpack_require__(/*! ./images.mjs */ \"./client/dom/images.mjs\");\nconst IO = __webpack_require__(/*! ./io */ \"./client/dom/io/index.js\");\nconst Dialog = __webpack_require__(/*! #dom/dialog */ \"./client/dom/dialog.mjs\");\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
217
|
|
|
207
218
|
/***/ },
|
|
208
219
|
|
|
209
|
-
/***/ "./client/dom/select-by-pattern.
|
|
210
|
-
|
|
211
|
-
!*** ./client/dom/select-by-pattern.
|
|
212
|
-
|
|
213
|
-
(
|
|
220
|
+
/***/ "./client/dom/select-by-pattern.mjs"
|
|
221
|
+
/*!******************************************!*\
|
|
222
|
+
!*** ./client/dom/select-by-pattern.mjs ***!
|
|
223
|
+
\******************************************/
|
|
224
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
214
225
|
|
|
215
226
|
"use strict";
|
|
216
|
-
eval("{
|
|
227
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ selectByPattern: () => (/* binding */ selectByPattern)\n/* harmony export */ });\n/* harmony import */ var _dom_dialog__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! #dom/dialog */ \"./client/dom/dialog.mjs\");\n/* harmony import */ var _common_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! #common/util */ \"./common/util.mjs\");\n/* harmony import */ var _current_file_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./current-file.mjs */ \"./client/dom/current-file.mjs\");\n/* harmony import */ var _cmd_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./cmd.mjs */ \"./client/dom/cmd.mjs\");\n\n\n\n\nlet SelectType = '*.*';\nconst selectByPattern = async (msg, files) => {\n if (!files) return;\n const allMsg = `Specify file type for ${msg} selection`;\n const [cancel, type] = await (0,_dom_dialog__WEBPACK_IMPORTED_MODULE_0__.prompt)(allMsg, SelectType);\n if (cancel) return;\n SelectType = type;\n const regExp = (0,_common_util__WEBPACK_IMPORTED_MODULE_1__.getRegExp)(type);\n let matches = 0;\n for (const current of files) {\n const name = (0,_current_file_mjs__WEBPACK_IMPORTED_MODULE_2__.getCurrentName)(current);\n if (name === '..' || !regExp.test(name)) continue;\n ++matches;\n let selected = (0,_cmd_mjs__WEBPACK_IMPORTED_MODULE_3__.isSelected)(current);\n const shouldSel = msg === 'expand';\n if (shouldSel) selected = !selected;\n if (selected) (0,_cmd_mjs__WEBPACK_IMPORTED_MODULE_3__.toggleSelectedFile)(current);\n }\n if (!matches) (0,_dom_dialog__WEBPACK_IMPORTED_MODULE_0__.alert)('No matches found!');\n};\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/dom/select-by-pattern.mjs\n}");
|
|
217
228
|
|
|
218
229
|
/***/ },
|
|
219
230
|
|
|
@@ -235,7 +246,7 @@ eval("{\n\nconst {\n parse,\n stringify\n} = JSON;\nmodule.exports.set = async
|
|
|
235
246
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
236
247
|
|
|
237
248
|
"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__(/*! #dom/load */ \"./client/dom/load.mjs\");\nconst Images = __webpack_require__(/*! ./images.mjs */ \"./client/dom/images.mjs\");\nconst {\n alert\n} = __webpack_require__(/*!
|
|
249
|
+
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__(/*! #dom/load */ \"./client/dom/load.mjs\");\nconst Images = __webpack_require__(/*! ./images.mjs */ \"./client/dom/images.mjs\");\nconst {\n alert\n} = __webpack_require__(/*! #dom/dialog */ \"./client/dom/dialog.mjs\");\nconst {\n FS\n} = __webpack_require__(/*! ../../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\nconst {\n getCurrentDirPath\n} = __webpack_require__(/*! ./current-file.mjs */ \"./client/dom/current-file.mjs\");\nconst loadFile = wraptile(_loadFile);\nconst onEnd = wraptile(_onEnd);\nmodule.exports = (dir, files) => {\n if (!files) {\n files = dir;\n dir = getCurrentDirPath();\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
250
|
|
|
240
251
|
/***/ },
|
|
241
252
|
|
|
@@ -290,7 +301,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
290
301
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
291
302
|
|
|
292
303
|
"use strict";
|
|
293
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ setCurrentByChar)\n/* harmony export */ });\n/* harmony import */ var
|
|
304
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ setCurrentByChar)\n/* harmony export */ });\n/* harmony import */ var _common_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! #common/util */ \"./common/util.mjs\");\n/* global DOM */\n\nfunction setCurrentByChar(char, charStore) {\n const Info = DOM.CurrentInfo;\n let firstByName;\n let skipCount = 0;\n let set = false;\n let i = 0;\n const escapeChar = (0,_common_util__WEBPACK_IMPORTED_MODULE_0__.escapeRegExp)(char);\n const regExp = new RegExp(`^${escapeChar}.*$`, 'i');\n const {\n files\n } = Info;\n const chars = charStore();\n const n = chars.length;\n while (i < n && char === chars[i]) i++;\n if (!i) charStore([]);\n const skipN = skipCount = i;\n charStore(charStore().concat(char));\n const names = DOM.getFilenames(files);\n const isTest = a => regExp.test(a);\n const isRoot = a => a === '..';\n const not = f => a => !f(a);\n const setCurrent = name => {\n const byName = DOM.getCurrentByName(name);\n if (!skipCount) {\n set = true;\n DOM.setCurrentFile(byName);\n return true;\n }\n if (skipN === skipCount) firstByName = byName;\n --skipCount;\n };\n names.filter(isTest).filter(not(isRoot)).some(setCurrent);\n if (!set) {\n DOM.setCurrentFile(firstByName);\n charStore([char]);\n }\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/key/set-current-by-char.mjs\n}");
|
|
294
305
|
|
|
295
306
|
/***/ },
|
|
296
307
|
|
|
@@ -389,7 +400,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
389
400
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
390
401
|
|
|
391
402
|
"use strict";
|
|
392
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ init: () => (/* binding */ init),\n/* harmony export */ saveFile: () => (/* binding */ saveFile),\n/* harmony export */ uploadFile: () => (/* binding */ uploadFile)\n/* harmony export */ });\n/* harmony import */ var execon__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n/* harmony import */ var load_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var _dom_load__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! #dom/load */ \"./client/dom/load.mjs\");\n/* harmony import */ var
|
|
403
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ init: () => (/* binding */ init),\n/* harmony export */ saveFile: () => (/* binding */ saveFile),\n/* harmony export */ uploadFile: () => (/* binding */ uploadFile)\n/* harmony export */ });\n/* harmony import */ var execon__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n/* harmony import */ var load_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var _dom_load__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! #dom/load */ \"./client/dom/load.mjs\");\n/* harmony import */ var _dom_files__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! #dom/files */ \"./client/dom/files.mjs\");\n/* harmony import */ var _dom_images_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../dom/images.mjs */ \"./client/dom/images.mjs\");\n/* global CloudCmd, filepicker */\n\n\n\n\n\n\nconst {\n log\n} = CloudCmd;\nconst upload = currify__WEBPACK_IMPORTED_MODULE_1__(_upload);\nconst Name = 'Cloud';\nCloudCmd[Name] = {\n init,\n uploadFile,\n saveFile\n};\nasync function init() {\n const [modules] = await loadFiles();\n const {\n key\n } = modules.data.FilePicker;\n filepicker.setKey(key);\n _dom_images_mjs__WEBPACK_IMPORTED_MODULE_5__.hide();\n}\nfunction uploadFile(filename, data) {\n const mimetype = '';\n filepicker.store(data, {\n mimetype,\n filename\n }, fpFile => {\n filepicker.exportFile(fpFile, log, log);\n });\n}\nfunction 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 = execon__WEBPACK_IMPORTED_MODULE_0__[\"with\"](callback, filename);\n (0,_dom_load__WEBPACK_IMPORTED_MODULE_3__.ajax)({\n url,\n responseType,\n success\n });\n}\nfunction loadFiles() {\n const js = '//api.filepicker.io/v2/filepicker.js';\n return Promise.all([_dom_files__WEBPACK_IMPORTED_MODULE_4__.get('modules'), load_js__WEBPACK_IMPORTED_MODULE_2__.js(js)]);\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/cloud.mjs\n}");
|
|
393
404
|
|
|
394
405
|
/***/ },
|
|
395
406
|
|
|
@@ -400,7 +411,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
400
411
|
(module, exports, __webpack_require__) {
|
|
401
412
|
|
|
402
413
|
"use strict";
|
|
403
|
-
eval("{\n\n/* global CloudCmd */\nCloudCmd.CommandLine = exports;\nconst Dialog = __webpack_require__(/*!
|
|
414
|
+
eval("{\n\n/* global CloudCmd */\nCloudCmd.CommandLine = exports;\nconst Dialog = __webpack_require__(/*! #dom/dialog */ \"./client/dom/dialog.mjs\");\nconst noop = () => {};\nmodule.exports.init = noop;\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nasync function show() {\n const [, cmd] = await Dialog.prompt('Command Line', '');\n const TERMINAL = '^(t|terminal)';\n if (RegExp(`${TERMINAL}$`).test(cmd)) return await CloudCmd.Terminal.show();\n if (RegExp(TERMINAL).test(cmd)) {\n const command = cmd.replace(RegExp(`${TERMINAL} `), '');\n const exitCode = await CloudCmd.TerminalRun.show({\n command: `bash -c '${command}'`\n });\n if (exitCode === -1) await Dialog.alert(`☝️ Looks like Terminal is disabled, start Cloud Coammnder with '--terminal' flag.`);\n return;\n }\n}\nfunction hide() {}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/command-line.js\n}");
|
|
404
415
|
|
|
405
416
|
/***/ },
|
|
406
417
|
|
|
@@ -411,7 +422,7 @@ eval("{\n\n/* global CloudCmd */\nCloudCmd.CommandLine = exports;\nconst Dialog
|
|
|
411
422
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
412
423
|
|
|
413
424
|
"use strict";
|
|
414
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hide: () => (/* binding */ hide),\n/* harmony export */ init: () => (/* binding */ init),\n/* harmony export */ show: () => (/* binding */ show)\n/* harmony export */ });\n/* harmony import */ var rendy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n/* harmony import */ var wraptile__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n/* harmony import */ var squad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! squad */ \"./node_modules/squad/lib/squad.js\");\n/* harmony import */ var es6_promisify__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.mjs\");\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 load_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var _cloudcmd_create_element__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n/* harmony import */ var _dom_events__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! #dom/events */ \"./client/dom/events/index.mjs\");\n/* harmony import */ var
|
|
425
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ hide: () => (/* binding */ hide),\n/* harmony export */ init: () => (/* binding */ init),\n/* harmony export */ show: () => (/* binding */ show)\n/* harmony export */ });\n/* harmony import */ var rendy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n/* harmony import */ var wraptile__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n/* harmony import */ var squad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! squad */ \"./node_modules/squad/lib/squad.js\");\n/* harmony import */ var es6_promisify__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.mjs\");\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 load_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var _cloudcmd_create_element__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n/* harmony import */ var _dom_events__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! #dom/events */ \"./client/dom/events/index.mjs\");\n/* harmony import */ var _dom_files__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! #dom/files */ \"./client/dom/files.mjs\");\n/* harmony import */ var _css_config_css__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../css/config.css */ \"./css/config.css\");\n/* harmony import */ var _input_mjs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./input.mjs */ \"./client/modules/config/input.mjs\");\n/* harmony import */ var _dom_images_mjs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../dom/images.mjs */ \"./client/dom/images.mjs\");\n/* harmony import */ var _common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\n/* global CloudCmd, DOM, io */\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst {\n Dialog,\n setTitle\n} = DOM;\nconst Name = 'Config';\nconst loadSocket = (0,es6_promisify__WEBPACK_IMPORTED_MODULE_4__.promisify)(DOM.loadSocket);\nconst showLoad = () => {\n _dom_images_mjs__WEBPACK_IMPORTED_MODULE_12__.show.load('top');\n};\nconst addKey = currify__WEBPACK_IMPORTED_MODULE_1__((fn, input) => {\n _dom_events__WEBPACK_IMPORTED_MODULE_8__.addKey(input, fn);\n return input;\n});\nconst addChange = currify__WEBPACK_IMPORTED_MODULE_1__((fn, input) => {\n _dom_events__WEBPACK_IMPORTED_MODULE_8__.add('change', input, fn);\n return input;\n});\nconst Config = {};\nlet Template;\nconst loadCSS = load_js__WEBPACK_IMPORTED_MODULE_6__.css;\nconst init = async () => {\n if (!CloudCmd.config('configDialog')) return;\n showLoad();\n const {\n DIR_DIST\n } = CloudCmd;\n [Template] = await Promise.all([_dom_files__WEBPACK_IMPORTED_MODULE_9__.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__WEBPACK_IMPORTED_MODULE_2__(Dialog.alert, 'Wrong credentials!'));\n}\nConfig.save = saveHttp;\nasync function show() {\n if (!CloudCmd.config('configDialog')) return;\n await fillTemplate();\n}\nasync function fillTemplate() {\n const [error, config] = await (0,try_to_catch__WEBPACK_IMPORTED_MODULE_5__.tryToCatch)(_dom_files__WEBPACK_IMPORTED_MODULE_9__.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_mjs__WEBPACK_IMPORTED_MODULE_11__.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__WEBPACK_IMPORTED_MODULE_0__(Template, obj);\n Element = _cloudcmd_create_element__WEBPACK_IMPORTED_MODULE_7__('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__WEBPACK_IMPORTED_MODULE_3__(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}\nfunction hide() {\n CloudCmd.View.hide();\n}\nasync function onChange(el) {\n const obj = {};\n const name = _input_mjs__WEBPACK_IMPORTED_MODULE_11__.getName(el);\n const data = _input_mjs__WEBPACK_IMPORTED_MODULE_11__.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_mjs__WEBPACK_IMPORTED_MODULE_11__.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_mjs__WEBPACK_IMPORTED_MODULE_11__.getElementByName('username', Element);\n const elPassword = _input_mjs__WEBPACK_IMPORTED_MODULE_11__.getElementByName('password', Element);\n elUsername.disabled = !checked;\n elPassword.disabled = !checked;\n}\nfunction onNameChange(name) {\n setTitle((0,_common_cloudfunc_mjs__WEBPACK_IMPORTED_MODULE_13__.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}\nCloudCmd[Name] = {\n init,\n show,\n hide\n};\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/config/index.mjs\n}");
|
|
415
426
|
|
|
416
427
|
/***/ },
|
|
417
428
|
|
|
@@ -488,7 +499,7 @@ eval("{\n\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"
|
|
|
488
499
|
(module, exports, __webpack_require__) {
|
|
489
500
|
|
|
490
501
|
"use strict";
|
|
491
|
-
eval("{/* global CloudCmd */\n\n\n\nconst montag = __webpack_require__(/*! montag */ \"./node_modules/montag/lib/montag.js\");\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n MAX_FILE_SIZE: maxSize\n} = __webpack_require__(/*! ../../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\nconst {\n time,\n timeEnd\n} = __webpack_require__(/*!
|
|
502
|
+
eval("{/* global CloudCmd */\n\n\n\nconst montag = __webpack_require__(/*! montag */ \"./node_modules/montag/lib/montag.js\");\nconst {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst {\n MAX_FILE_SIZE: maxSize\n} = __webpack_require__(/*! ../../common/cloudfunc.mjs */ \"./common/cloudfunc.mjs\");\nconst {\n time,\n timeEnd\n} = __webpack_require__(/*! #common/util */ \"./common/util.mjs\");\nconst getEditor = () => editor;\nconst isFn = a => typeof a === 'function';\nconst loadJS = load.js;\nconst Name = 'Edit';\nCloudCmd[Name] = exports;\nconst EditorName = CloudCmd.config('editor');\nlet Loading = true;\nlet Element;\nlet editor;\nconst ConfigView = {\n afterShow: () => {\n editor.moveCursorTo(0, 0).focus();\n }\n};\nmodule.exports.init = async () => {\n const element = create();\n await CloudCmd.View();\n await loadFiles(element);\n};\nfunction create() {\n const element = createElement('div', {\n style: montag`\n width: 100%;\n height: 100%;\n font-family: \"Droid Sans Mono\";\n `,\n notAppend: true\n });\n Element = element;\n return element;\n}\nfunction checkFn(name, fn) {\n if (!isFn(fn)) throw Error(`${name} should be a function!`);\n}\nfunction initConfig(options = {}) {\n const config = {\n ...options,\n ...ConfigView\n };\n if (!options.afterShow) return config;\n checkFn('options.afterShow', options.afterShow);\n config.afterShow = () => {\n ConfigView.afterShow();\n options.afterShow();\n };\n return config;\n}\nmodule.exports.show = options => {\n if (Loading) return;\n CloudCmd.View.show(Element, initConfig(options));\n getEditor().setOptions({\n fontSize: 16\n });\n};\nmodule.exports.getEditor = getEditor;\nmodule.exports.getElement = () => Element;\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\nconst loadFiles = async element => {\n const prefix = `${CloudCmd.prefix}/${EditorName}`;\n const socketPath = CloudCmd.prefix;\n const prefixSocket = `${CloudCmd.prefixSocket}/${EditorName}`;\n const url = `${prefix}/${EditorName}.js`;\n time(`${Name} load`);\n await loadJS(url);\n const word = promisify(window[EditorName]);\n const [ed] = await tryToCatch(word, element, {\n maxSize,\n prefix,\n prefixSocket,\n socketPath\n });\n timeEnd(`${Name} load`);\n editor = ed;\n Loading = false;\n};\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/edit.js\n}");
|
|
492
503
|
|
|
493
504
|
/***/ },
|
|
494
505
|
|
|
@@ -521,7 +532,7 @@ eval("{\n\n/* global CloudCmd */\n/* global Util */\n/* global DOM */\n/* global
|
|
|
521
532
|
(module, exports, __webpack_require__) {
|
|
522
533
|
|
|
523
534
|
"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.mjs */ \"./client/dom/images.mjs\");\nconst {\n Markdown\n} = __webpack_require__(/*! ../dom/rest */ \"./client/dom/rest.js\");\nconst {\n alert\n} = __webpack_require__(/*!
|
|
535
|
+
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.mjs\");\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
536
|
|
|
526
537
|
/***/ },
|
|
527
538
|
|
|
@@ -587,7 +598,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
587
598
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
588
599
|
|
|
589
600
|
"use strict";
|
|
590
|
-
eval("{\n\nconst {\n getExt\n} = __webpack_require__(/*!
|
|
601
|
+
eval("{\n\nconst {\n getExt\n} = __webpack_require__(/*! #common/util */ \"./common/util.mjs\");\nmodule.exports = name => {\n const ext = getExtension(name);\n return name.replace(ext, '');\n};\nfunction getExtension(name) {\n if (name.endsWith('.tar.gz')) return '.tar.gz';\n if (name.endsWith('.tar.bz2')) return '.tar.bz2';\n return getExt(name);\n}\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/modules/operation/remove-extension.js\n}");
|
|
591
602
|
|
|
592
603
|
/***/ },
|
|
593
604
|
|
|
@@ -620,7 +631,7 @@ eval("{\n\n__webpack_require__(/*! domtokenlist-shim */ \"./node_modules/domtoke
|
|
|
620
631
|
(module, exports, __webpack_require__) {
|
|
621
632
|
|
|
622
633
|
"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.js\");\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.
|
|
634
|
+
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.js\");\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/index.mjs */ \"./client/dom/index.mjs\");\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
635
|
|
|
625
636
|
/***/ },
|
|
626
637
|
|
|
@@ -631,7 +642,7 @@ eval("{\n\n/* global CloudCmd, gritty */\nconst {\n promisify\n} = __webpack_re
|
|
|
631
642
|
(module, exports, __webpack_require__) {
|
|
632
643
|
|
|
633
644
|
"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.js\");\n__webpack_require__(/*! ../../css/terminal.css */ \"./css/terminal.css\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst DOM = __webpack_require__(/*! ../dom */ \"./client/dom/index.
|
|
645
|
+
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.js\");\n__webpack_require__(/*! ../../css/terminal.css */ \"./css/terminal.css\");\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst DOM = __webpack_require__(/*! ../dom/index.mjs */ \"./client/dom/index.mjs\");\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
646
|
|
|
636
647
|
/***/ },
|
|
637
648
|
|
|
@@ -642,7 +653,7 @@ eval("{\n\n/* global CloudCmd */\n/* global gritty */\nconst {\n tryToCatch\n}
|
|
|
642
653
|
(module, exports, __webpack_require__) {
|
|
643
654
|
|
|
644
655
|
"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__(/*!
|
|
656
|
+
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.mjs\");\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
657
|
|
|
647
658
|
/***/ },
|
|
648
659
|
|
|
@@ -664,7 +675,7 @@ eval("{\n\nmodule.exports = menuFn => {\n const module = {};\n const fn = Func
|
|
|
664
675
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
665
676
|
|
|
666
677
|
"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.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n codeFrameColumns\n} = __webpack_require__(/*! @babel/code-frame */ \"./node_modules/@babel/code-frame/lib/index.js\");\nconst Images = __webpack_require__(/*! ../../dom/images.mjs */ \"./client/dom/images.mjs\");\nconst Dialog = __webpack_require__(/*!
|
|
678
|
+
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.js\");\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst {\n codeFrameColumns\n} = __webpack_require__(/*! @babel/code-frame */ \"./node_modules/@babel/code-frame/lib/index.js\");\nconst Images = __webpack_require__(/*! ../../dom/images.mjs */ \"./client/dom/images.mjs\");\nconst Dialog = __webpack_require__(/*! #dom/dialog */ \"./client/dom/dialog.mjs\");\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
679
|
|
|
669
680
|
/***/ },
|
|
670
681
|
|
|
@@ -719,7 +730,7 @@ eval("{\n\nmodule.exports.runSelected = async (selectedItems, items, runUserMenu
|
|
|
719
730
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
720
731
|
|
|
721
732
|
"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.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst _modal = __webpack_require__(/*! @cloudcmd/modal */ \"./node_modules/@cloudcmd/modal/lib/modal.js\");\nconst _createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n time\n} = __webpack_require__(/*!
|
|
733
|
+
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.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst _modal = __webpack_require__(/*! @cloudcmd/modal */ \"./node_modules/@cloudcmd/modal/lib/modal.js\");\nconst _createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n time\n} = __webpack_require__(/*! #common/util */ \"./common/util.mjs\");\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.mjs\");\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
734
|
|
|
724
735
|
/***/ },
|
|
725
736
|
|
|
@@ -741,7 +752,7 @@ eval("{\n\nconst {\n extname\n} = __webpack_require__(/*! node:path */ \"./node
|
|
|
741
752
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
742
753
|
|
|
743
754
|
"use strict";
|
|
744
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ initSortPanel: () => (/* binding */ initSortPanel),\n/* harmony export */ sortPanel: () => (/* binding */ sortPanel)\n/* harmony export */ });\n/* harmony import */ var fullstore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n/* harmony import */ var
|
|
755
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ initSortPanel: () => (/* binding */ initSortPanel),\n/* harmony export */ sortPanel: () => (/* binding */ sortPanel)\n/* harmony export */ });\n/* harmony import */ var fullstore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n/* harmony import */ var _dom_index_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dom/index.mjs */ \"./client/dom/index.mjs\");\n/* global CloudCmd */\n\n\nconst sortPrevious = (0,fullstore__WEBPACK_IMPORTED_MODULE_0__.fullstore)();\nconst {\n getPanel\n} = _dom_index_mjs__WEBPACK_IMPORTED_MODULE_1__[\"default\"];\nconst initSortPanel = () => {\n const {\n sort\n } = CloudCmd;\n const position = _dom_index_mjs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].getPanelPosition();\n sortPrevious(sort[position]);\n};\nconst sortPanel = (name, panel = getPanel()) => {\n const {\n sort,\n order\n } = CloudCmd;\n const Info = _dom_index_mjs__WEBPACK_IMPORTED_MODULE_1__[\"default\"].CurrentInfo;\n const position = panel.dataset.name.replace('js-', '');\n if (name !== sortPrevious()) order[position] = 'asc';else if (order[position] === 'asc') order[position] = 'desc';else order[position] = 'asc';\n sortPrevious(name);\n sort[position] = name;\n const noCurrent = position !== Info.panelPosition;\n CloudCmd.refresh({\n panel,\n noCurrent\n });\n};\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/client/sort.mjs\n}");
|
|
745
756
|
|
|
746
757
|
/***/ },
|
|
747
758
|
|
|
@@ -789,14 +800,14 @@ eval("{\n\nconst {\n tryToCatch\n} = __webpack_require__(/*! try-to-catch */ \"
|
|
|
789
800
|
|
|
790
801
|
/***/ },
|
|
791
802
|
|
|
792
|
-
/***/ "./common/util.
|
|
793
|
-
|
|
794
|
-
!*** ./common/util.
|
|
795
|
-
|
|
796
|
-
(
|
|
803
|
+
/***/ "./common/util.mjs"
|
|
804
|
+
/*!*************************!*\
|
|
805
|
+
!*** ./common/util.mjs ***!
|
|
806
|
+
\*************************/
|
|
807
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
797
808
|
|
|
798
809
|
"use strict";
|
|
799
|
-
eval("{\n\
|
|
810
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ escapeRegExp: () => (/* binding */ escapeRegExp),\n/* harmony export */ findObjByNameInArr: () => (/* binding */ findObjByNameInArr),\n/* harmony export */ getExt: () => (/* binding */ getExt),\n/* harmony export */ getRegExp: () => (/* binding */ getRegExp),\n/* harmony export */ time: () => (/* binding */ time),\n/* harmony export */ timeEnd: () => (/* binding */ timeEnd)\n/* harmony export */ });\n/* harmony import */ var execon__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n\nconst isString = a => typeof a === 'string';\nconst escapeRegExp = str => {\n const isStr = isString(str);\n if (isStr) str = str.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n return str;\n};\n\n/**\n * get regexp from wild card\n */\nconst getRegExp = wildcard => {\n const escaped = `^${wildcard // search from start of line\n .replace(/\\./g, '\\\\.').replace(/\\*/g, '.*').replace('?', '.?')}$`;\n\n // search to end of line\n return RegExp(escaped);\n};\n\n/**\n * function gets file extension\n *\n * @param name\n * @return ext\n */\nconst getExt = name => {\n const isStr = isString(name);\n if (!isStr) return '';\n const dot = name.lastIndexOf('.');\n if (~dot) return name.substr(dot);\n return '';\n};\n\n/**\n * find object by name in arrray\n *\n * @param array\n * @param name\n */\nconst findObjByNameInArr = (array, name) => {\n let ret;\n if (!Array.isArray(array)) throw Error('array should be array!');\n if (!isString(name)) throw Error('name should be string!');\n array.some(item => {\n const is = item.name === name;\n const isArray = Array.isArray(item);\n if (is) {\n ret = item;\n return is;\n }\n if (!isArray) return is;\n return item.some(item => {\n const is = item.name === name;\n if (is) ret = item.data;\n return is;\n });\n });\n return ret;\n};\n\n/**\n * start timer\n * @param name\n */\nconst time = name => {\n execon__WEBPACK_IMPORTED_MODULE_0__.ifExist(console, 'time', [name]);\n};\n\n/**\n * stop timer\n * @param name\n */\nconst timeEnd = name => {\n execon__WEBPACK_IMPORTED_MODULE_0__.ifExist(console, 'timeEnd', [name]);\n};\n\n//# sourceURL=file://cloudcmd//Users/coderaiser/cloudcmd/common/util.mjs\n}");
|
|
800
811
|
|
|
801
812
|
/***/ },
|
|
802
813
|
|