cloudcmd 15.9.7 → 15.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/ChangeLog +33 -0
  2. package/HELP.md +10 -4
  3. package/README.md +2 -4
  4. package/bin/cloudcmd.mjs +20 -20
  5. package/common/callbackify.js +6 -8
  6. package/dist/cloudcmd.common.js +3 -3
  7. package/dist/cloudcmd.common.js.map +1 -1
  8. package/dist/cloudcmd.js +1 -1
  9. package/dist/cloudcmd.js.map +1 -1
  10. package/dist/modules/cloud.js +1 -1
  11. package/dist/modules/cloud.js.map +1 -1
  12. package/dist/modules/config.js +1 -1
  13. package/dist/modules/config.js.map +1 -1
  14. package/dist/modules/contact.js +1 -1
  15. package/dist/modules/contact.js.map +1 -1
  16. package/dist/modules/edit.js +1 -1
  17. package/dist/modules/edit.js.map +1 -1
  18. package/dist/modules/konsole.js.map +1 -1
  19. package/dist/modules/markdown.js +1 -1
  20. package/dist/modules/markdown.js.map +1 -1
  21. package/dist/modules/menu.js +1 -1
  22. package/dist/modules/menu.js.map +1 -1
  23. package/dist/modules/operation.js +1 -1
  24. package/dist/modules/operation.js.map +1 -1
  25. package/dist/modules/terminal-run.js +1 -1
  26. package/dist/modules/terminal-run.js.map +1 -1
  27. package/dist/modules/terminal.js +1 -1
  28. package/dist/modules/terminal.js.map +1 -1
  29. package/dist/modules/upload.js +1 -1
  30. package/dist/modules/upload.js.map +1 -1
  31. package/dist/modules/user-menu.js +1 -1
  32. package/dist/modules/user-menu.js.map +1 -1
  33. package/dist/modules/view.js +1 -1
  34. package/dist/modules/view.js.map +1 -1
  35. package/dist/sw.js +1 -1
  36. package/dist/sw.js.map +1 -1
  37. package/dist-dev/cloudcmd.common.js +29 -29
  38. package/dist-dev/cloudcmd.js +6 -6
  39. package/dist-dev/modules/cloud.js +1 -1
  40. package/dist-dev/modules/config.js +2 -2
  41. package/dist-dev/modules/contact.js +1 -1
  42. package/dist-dev/modules/edit.js +1 -1
  43. package/dist-dev/modules/konsole.js +1 -1
  44. package/dist-dev/modules/markdown.js +1 -1
  45. package/dist-dev/modules/menu.js +1 -1
  46. package/dist-dev/modules/operation.js +2 -2
  47. package/dist-dev/modules/terminal-run.js +1 -1
  48. package/dist-dev/modules/terminal.js +1 -1
  49. package/dist-dev/modules/upload.js +1 -1
  50. package/dist-dev/modules/user-menu.js +2 -2
  51. package/dist-dev/modules/view.js +1 -1
  52. package/dist-dev/sw.js +1 -1
  53. package/package.json +8 -8
  54. package/server/config.js +1 -1
  55. package/server/distribute/log.js +1 -3
  56. package/server/show-config.js +1 -3
  57. package/server/user-menu.js +1 -1
@@ -175,7 +175,7 @@ eval("\n\nmodule.exports = menuFn => {\n const module = {};\n const fn = Funct
175
175
  /***/ (function(module, exports, __webpack_require__) {
176
176
 
177
177
  "use strict";
178
- eval("\n/* global CloudCmd, DOM */\n\n__webpack_require__(/*! ../../../css/user-menu.css */ \"./css/user-menu.css\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst tryCatch = __webpack_require__(/*! try-catch */ \"./node_modules/try-catch/lib/try-catch.js\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst {\n codeFrameColumns\n} = __webpack_require__(/*! @babel/code-frame */ \"./node_modules/@babel/code-frame/lib/index.js\");\n\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\n\nconst Dialog = __webpack_require__(/*! ../../dom/dialog */ \"./client/dom/dialog.js\");\n\nconst getUserMenu = __webpack_require__(/*! ./get-user-menu */ \"./client/modules/user-menu/get-user-menu.js\");\n\nconst navigate = __webpack_require__(/*! ./navigate */ \"./client/modules/user-menu/navigate.js\");\n\nconst parseError = __webpack_require__(/*! ./parse-error */ \"./client/modules/user-menu/parse-error.js\");\n\nconst parseUserMenu = __webpack_require__(/*! ./parse-user-menu */ \"./client/modules/user-menu/parse-user-menu.js\");\n\nconst {\n runSelected\n} = __webpack_require__(/*! ./run */ \"./client/modules/user-menu/run.js\");\n\nconst loadCSS = load.css;\nconst sourceStore = fullstore();\nconst Name = 'UserMenu';\nCloudCmd[Name] = module.exports;\nconst {\n Key\n} = CloudCmd;\n\nmodule.exports.init = async () => {\n await Promise.all([loadCSS(`${CloudCmd.prefix}/dist/user-menu.css`), CloudCmd.View()]);\n};\n\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nconst {\n CurrentInfo\n} = DOM;\n\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\n const afterShow = () => select.focus();\n\n const autoSize = true;\n CloudCmd.View.show([button, select], {\n autoSize,\n afterShow\n });\n}\n\nfunction fillTemplate(options) {\n const result = [];\n\n for (const option of options) result.push(`<option>${option}</option>`);\n\n return result.join('');\n}\n\nfunction hide() {\n CloudCmd.View.hide();\n}\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();else 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});\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};\n\nfunction getCodeFrame({\n error,\n source\n}) {\n const {\n code\n } = error;\n if (!code || code === 'frame') return error.message;\n const [line, column] = parseError(error);\n const start = {\n line,\n column\n };\n const location = {\n start\n };\n const frame = codeFrameColumns(source, location, {\n message: error.message,\n highlightCode: false\n });\n return `<pre>${frame}</pre>`;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/user-menu/index.js");
178
+ eval("\n/* global CloudCmd, DOM */\n\n__webpack_require__(/*! ../../../css/user-menu.css */ \"./css/user-menu.css\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n\nconst fullstore = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst tryCatch = __webpack_require__(/*! try-catch */ \"./node_modules/try-catch/lib/try-catch.js\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst {\n codeFrameColumns\n} = __webpack_require__(/*! @babel/code-frame */ \"./node_modules/@babel/code-frame/lib/index.js\");\n\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\n\nconst Dialog = __webpack_require__(/*! ../../dom/dialog */ \"./client/dom/dialog.js\");\n\nconst getUserMenu = __webpack_require__(/*! ./get-user-menu */ \"./client/modules/user-menu/get-user-menu.js\");\n\nconst navigate = __webpack_require__(/*! ./navigate */ \"./client/modules/user-menu/navigate.js\");\n\nconst parseError = __webpack_require__(/*! ./parse-error */ \"./client/modules/user-menu/parse-error.js\");\n\nconst parseUserMenu = __webpack_require__(/*! ./parse-user-menu */ \"./client/modules/user-menu/parse-user-menu.js\");\n\nconst {\n runSelected\n} = __webpack_require__(/*! ./run */ \"./client/modules/user-menu/run.js\");\n\nconst loadCSS = load.css;\nconst sourceStore = fullstore();\nconst Name = 'UserMenu';\nCloudCmd[Name] = module.exports;\nconst {\n Key\n} = CloudCmd;\n\nmodule.exports.init = async () => {\n await Promise.all([loadCSS(`${CloudCmd.prefix}/dist/user-menu.css`), CloudCmd.View()]);\n};\n\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nconst {\n CurrentInfo\n} = DOM;\n\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\n const afterShow = () => select.focus();\n\n const autoSize = true;\n CloudCmd.View.show([button, select], {\n autoSize,\n afterShow\n });\n}\n\nfunction fillTemplate(options) {\n const result = [];\n\n for (const option of options) result.push(`<option>${option}</option>`);\n\n return result.join('');\n}\n\nfunction hide() {\n CloudCmd.View.hide();\n}\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, _ref) => {\n let {\n value\n } = _ref;\n await runUserMenu(items[value]);\n});\nconst onKeyDown = currify(async (_ref2, e) => {\n let {\n keys,\n userMenu\n } = _ref2;\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});\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};\n\nfunction getCodeFrame(_ref3) {\n let {\n error,\n source\n } = _ref3;\n const {\n code\n } = error;\n if (!code || code === 'frame') return error.message;\n const [line, column] = parseError(error);\n const start = {\n line,\n column\n };\n const location = {\n start\n };\n const frame = codeFrameColumns(source, location, {\n message: error.message,\n highlightCode: false\n });\n return `<pre>${frame}</pre>`;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/user-menu/index.js");
179
179
 
180
180
  /***/ }),
181
181
 
@@ -187,7 +187,7 @@ eval("\n/* global CloudCmd, DOM */\n\n__webpack_require__(/*! ../../../css/user-
187
187
  /***/ (function(module, exports, __webpack_require__) {
188
188
 
189
189
  "use strict";
190
- eval("\n\nconst {\n J,\n K,\n UP,\n DOWN\n} = __webpack_require__(/*! ../../key/key.js */ \"./client/key/key.js\");\n\nmodule.exports = (el, {\n keyCode\n}) => {\n if (keyCode === DOWN || keyCode === J) return down(el);\n if (keyCode === UP || keyCode === K) return up(el);\n};\n\nfunction down(el) {\n const {\n length\n } = el;\n if (el.selectedIndex === length - 1) el.selectedIndex = 0;else ++el.selectedIndex;\n}\n\nfunction up(el) {\n const {\n length\n } = el;\n if (!el.selectedIndex) el.selectedIndex = length - 1;else --el.selectedIndex;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/user-menu/navigate.js");
190
+ eval("\n\nconst {\n J,\n K,\n UP,\n DOWN\n} = __webpack_require__(/*! ../../key/key.js */ \"./client/key/key.js\");\n\nmodule.exports = (el, _ref) => {\n let {\n keyCode\n } = _ref;\n if (keyCode === DOWN || keyCode === J) return down(el);\n if (keyCode === UP || keyCode === K) return up(el);\n};\n\nfunction down(el) {\n const {\n length\n } = el;\n if (el.selectedIndex === length - 1) el.selectedIndex = 0;else ++el.selectedIndex;\n}\n\nfunction up(el) {\n const {\n length\n } = el;\n if (!el.selectedIndex) el.selectedIndex = length - 1;else --el.selectedIndex;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/user-menu/navigate.js");
191
191
 
192
192
  /***/ }),
193
193
 
@@ -163,7 +163,7 @@
163
163
  /***/ (function(module, exports, __webpack_require__) {
164
164
 
165
165
  "use strict";
166
- eval("\n/* global CloudCmd, DOM */\n\n__webpack_require__(/*! ../../../css/view.css */ \"./css/view.css\");\n\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst modal = __webpack_require__(/*! @cloudcmd/modal */ \"./node_modules/@cloudcmd/modal/lib/modal.js\");\n\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst {\n time\n} = __webpack_require__(/*! ../../../common/util */ \"./common/util.js\");\n\nconst {\n FS\n} = __webpack_require__(/*! ../../../common/cloudfunc */ \"./common/cloudfunc.js\");\n\nconst {\n isImage,\n isAudio,\n getType\n} = __webpack_require__(/*! ./types */ \"./client/modules/view/types.js\");\n\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\n\nconst Events = __webpack_require__(/*! ../../dom/events */ \"./client/dom/events/index.js\");\n\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\n\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\n\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});\n\nconst isFn = a => typeof a === 'function';\n\nconst noop = () => {};\n\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;\n\nconst basename = a => a.split('/').pop();\n\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;\n\nmodule.exports.init = async () => {\n await loadAll();\n const events = ['click', 'contextmenu'];\n events.forEach(addEvent(Overlay, onOverlayClick));\n};\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\n if (data) {\n if (isArray(data)) El.append(...data);else El.append(data);\n modal.open(El, initConfig(options));\n return;\n }\n\n Images.show.load();\n const path = prefixURL + Info.path;\n const type = options.raw ? '' : await getType(path);\n\n switch (type) {\n default:\n return await viewFile();\n\n case 'markdown':\n return await CloudCmd.Markdown.show(Info.path);\n\n case 'html':\n return viewHtml(path);\n\n case 'image':\n return viewImage(Info.path, prefixURL);\n\n case 'media':\n return await viewMedia(path);\n\n case 'pdf':\n return viewPDF(path);\n }\n}\n\nmodule.exports._createIframe = createIframe;\n\nfunction createIframe(src) {\n const element = createElement('iframe', {\n src,\n width: '100%',\n height: '100%'\n });\n element.addEventListener('load', () => {\n element.contentWindow.addEventListener('keydown', listener);\n });\n return element;\n}\n\nmodule.exports._viewHtml = viewHtml;\n\nfunction viewHtml(src) {\n modal.open(createIframe(src), Config);\n}\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}\n\nasync function viewMedia(path) {\n const [e, element] = await getMediaElement(path);\n if (e) return alert(e);\n const allConfig = { ...Config,\n ...{\n autoSize: true,\n afterShow: () => {\n element.querySelector('audio, video').focus();\n }\n }\n };\n modal.open(element, allConfig);\n}\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}\n\nconst copy = a => assign({}, a);\n\nmodule.exports._initConfig = initConfig;\n\nfunction initConfig(options) {\n const config = copy(Config);\n if (!options) return config;\n const names = Object.keys(options);\n\n for (const name of names) {\n const isConfig = Boolean(config[name]);\n const item = options[name];\n\n if (!isFn(item) || !isConfig) {\n config[name] = options[name];\n continue;\n }\n\n const fn = config[name];\n config[name] = series(fn, item);\n }\n\n return config;\n}\n\nfunction hide() {\n modal.close();\n}\n\nfunction viewImage(path, prefixURL) {\n const isSupportedImage = a => isImage(a) || a === path;\n\n const makeTitle = path => {\n return {\n href: `${prefixURL}${path}`,\n title: encode(basename(path))\n };\n };\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 = { ...Config,\n ...imageConfig\n };\n modal.open(titles, config);\n}\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}\n\nfunction check(src) {\n if (typeof src !== 'string') throw Error('src should be a string!');\n}\n/**\n * function loads css and js of FancyBox\n * @callback - executes, when everything loaded\n */\n\n\nasync function loadAll() {\n const {\n prefix\n } = CloudCmd;\n time(Name + ' load');\n Loading = true;\n await loadCSS(`${prefix}/dist/view.css`);\n Loading = false;\n}\n\nfunction onOverlayClick(event) {\n const position = {\n x: event.clientX,\n y: event.clientY\n };\n setCurrentByPosition(position);\n}\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}\n\nfunction listener({\n keyCode\n}) {\n if (keyCode === Key.ESC) hide();\n}\n\n//# sourceURL=file://cloudcmd/client/modules/view/index.js");
166
+ eval("\n/* global CloudCmd, DOM */\n\n__webpack_require__(/*! ../../../css/view.css */ \"./css/view.css\");\n\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst modal = __webpack_require__(/*! @cloudcmd/modal */ \"./node_modules/@cloudcmd/modal/lib/modal.js\");\n\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst {\n time\n} = __webpack_require__(/*! ../../../common/util */ \"./common/util.js\");\n\nconst {\n FS\n} = __webpack_require__(/*! ../../../common/cloudfunc */ \"./common/cloudfunc.js\");\n\nconst {\n isImage,\n isAudio,\n getType\n} = __webpack_require__(/*! ./types */ \"./client/modules/view/types.js\");\n\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\n\nconst Events = __webpack_require__(/*! ../../dom/events */ \"./client/dom/events/index.js\");\n\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\n\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\n\nconst {\n assign\n} = Object;\nconst {\n isArray\n} = Array;\nconst lifo = currify((fn, el, cb, name) => fn(name, el, cb));\nconst series = wraptile(function () {\n for (var _len = arguments.length, a = new Array(_len), _key = 0; _key < _len; _key++) {\n a[_key] = arguments[_key];\n }\n\n for (const f of a) f();\n});\n\nconst isFn = a => typeof a === 'function';\n\nconst noop = () => {};\n\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;\n\nconst basename = a => a.split('/').pop();\n\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;\n\nmodule.exports.init = async () => {\n await loadAll();\n const events = ['click', 'contextmenu'];\n events.forEach(addEvent(Overlay, onOverlayClick));\n};\n\nasync function show(data) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\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\n if (data) {\n if (isArray(data)) El.append(...data);else El.append(data);\n modal.open(El, initConfig(options));\n return;\n }\n\n Images.show.load();\n const path = prefixURL + Info.path;\n const type = options.raw ? '' : await getType(path);\n\n switch (type) {\n default:\n return await viewFile();\n\n case 'markdown':\n return await CloudCmd.Markdown.show(Info.path);\n\n case 'html':\n return viewHtml(path);\n\n case 'image':\n return viewImage(Info.path, prefixURL);\n\n case 'media':\n return await viewMedia(path);\n\n case 'pdf':\n return viewPDF(path);\n }\n}\n\nmodule.exports._createIframe = createIframe;\n\nfunction createIframe(src) {\n const element = createElement('iframe', {\n src,\n width: '100%',\n height: '100%'\n });\n element.addEventListener('load', () => {\n element.contentWindow.addEventListener('keydown', listener);\n });\n return element;\n}\n\nmodule.exports._viewHtml = viewHtml;\n\nfunction viewHtml(src) {\n modal.open(createIframe(src), Config);\n}\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}\n\nasync function viewMedia(path) {\n const [e, element] = await getMediaElement(path);\n if (e) return alert(e);\n const allConfig = { ...Config,\n ...{\n autoSize: true,\n afterShow: () => {\n element.querySelector('audio, video').focus();\n }\n }\n };\n modal.open(element, allConfig);\n}\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}\n\nconst copy = a => assign({}, a);\n\nmodule.exports._initConfig = initConfig;\n\nfunction initConfig(options) {\n const config = copy(Config);\n if (!options) return config;\n const names = Object.keys(options);\n\n for (const name of names) {\n const isConfig = Boolean(config[name]);\n const item = options[name];\n\n if (!isFn(item) || !isConfig) {\n config[name] = options[name];\n continue;\n }\n\n const fn = config[name];\n config[name] = series(fn, item);\n }\n\n return config;\n}\n\nfunction hide() {\n modal.close();\n}\n\nfunction viewImage(path, prefixURL) {\n const isSupportedImage = a => isImage(a) || a === path;\n\n const makeTitle = path => ({\n href: `${prefixURL}${path}`,\n title: encode(basename(path))\n });\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 = { ...Config,\n ...imageConfig\n };\n modal.open(titles, config);\n}\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}\n\nfunction check(src) {\n if (typeof src !== 'string') throw Error('src should be a string!');\n}\n/**\n * function loads css and js of FancyBox\n * @callback - executes, when everything loaded\n */\n\n\nasync function loadAll() {\n const {\n prefix\n } = CloudCmd;\n time(Name + ' load');\n Loading = true;\n await loadCSS(`${prefix}/dist/view.css`);\n Loading = false;\n}\n\nfunction onOverlayClick(event) {\n const position = {\n x: event.clientX,\n y: event.clientY\n };\n setCurrentByPosition(position);\n}\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}\n\nfunction listener(_ref) {\n let {\n keyCode\n } = _ref;\n if (keyCode === Key.ESC) hide();\n}\n\n//# sourceURL=file://cloudcmd/client/modules/view/index.js");
167
167
 
168
168
  /***/ }),
169
169
 
package/dist-dev/sw.js CHANGED
@@ -101,7 +101,7 @@ var serviceWorkerOption = {
101
101
  /***/ (function(module, exports, __webpack_require__) {
102
102
 
103
103
  "use strict";
104
- eval("\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst isDev = \"development\" === 'development';\n\nconst isGet = a => a.method === 'GET';\n\nconst isBasic = a => a.type === 'basic';\n\nconst wait = currify((f, e) => e.waitUntil(f()));\nconst respondWith = currify((f, e) => {\n const {\n request\n } = e;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n if (/\\/$/.test(url) || /\\^\\/fs/.test(pathname)) return;\n if (!isGet(request)) return;\n if (!isBasic(request)) return;\n if (/^\\/api/.test(pathname)) return;\n if (/^socket.io/.test(pathname)) return;\n e.respondWith(f(e));\n});\n\nconst getPathName = url => new URL(url).pathname;\n\nconst date = \"Sun Jun 27 2021 16:37:52 GMT+0300 (Eastern European Summer Time)\";\nconst NAME = `cloudcmd: ${date}`;\n\nconst createRequest = a => new Request(a, {\n credentials: 'same-origin'\n});\n\nconst getRequest = (a, request) => {\n if (a !== '/') return request;\n return createRequest('/');\n};\n\nself.addEventListener('install', wait(onInstall));\nself.addEventListener('fetch', respondWith(onFetch));\nself.addEventListener('activate', wait(onActivate));\n\nasync function onActivate() {\n console.info(`cloudcmd: sw: activate: ${NAME}`);\n await self.clients.claim();\n const keys = await caches.keys();\n const deleteCache = caches.delete.bind(caches);\n await Promise.all(keys.map(deleteCache));\n}\n\nasync function onInstall() {\n console.info(`cloudcmd: sw: install: ${NAME}`);\n await self.skipWaiting();\n}\n\nasync function onFetch(event) {\n const {\n request\n } = event;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n const newRequest = getRequest(pathname, event.request);\n const cache = await caches.open(NAME);\n const response = await cache.match(request);\n if (!isDev && response) return response;\n const [e, resp] = await tryToCatch(fetch, newRequest, {\n credentials: 'same-origin'\n });\n if (e) return new Response(e.message);\n await addToCache(request, resp.clone());\n return resp;\n}\n\nasync function addToCache(request, response) {\n const cache = await caches.open(NAME);\n return cache.put(request, response);\n}\n\n//# sourceURL=file://cloudcmd/client/sw/sw.js");
104
+ eval("\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\nconst isDev = \"development\" === 'development';\n\nconst isGet = a => a.method === 'GET';\n\nconst isBasic = a => a.type === 'basic';\n\nconst wait = currify((f, e) => e.waitUntil(f()));\nconst respondWith = currify((f, e) => {\n const {\n request\n } = e;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n if (/\\/$/.test(url) || /\\^\\/fs/.test(pathname)) return;\n if (!isGet(request)) return;\n if (!isBasic(request)) return;\n if (/^\\/api/.test(pathname)) return;\n if (/^socket.io/.test(pathname)) return;\n e.respondWith(f(e));\n});\n\nconst getPathName = url => new URL(url).pathname;\n\nconst date = \"Thu Dec 09 2021 14:18:56 GMT+0200 (Eastern European Standard Time)\";\nconst NAME = `cloudcmd: ${date}`;\n\nconst createRequest = a => new Request(a, {\n credentials: 'same-origin'\n});\n\nconst getRequest = (a, request) => {\n if (a !== '/') return request;\n return createRequest('/');\n};\n\nself.addEventListener('install', wait(onInstall));\nself.addEventListener('fetch', respondWith(onFetch));\nself.addEventListener('activate', wait(onActivate));\n\nasync function onActivate() {\n console.info(`cloudcmd: sw: activate: ${NAME}`);\n await self.clients.claim();\n const keys = await caches.keys();\n const deleteCache = caches.delete.bind(caches);\n await Promise.all(keys.map(deleteCache));\n}\n\nasync function onInstall() {\n console.info(`cloudcmd: sw: install: ${NAME}`);\n await self.skipWaiting();\n}\n\nasync function onFetch(event) {\n const {\n request\n } = event;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n const newRequest = getRequest(pathname, event.request);\n const cache = await caches.open(NAME);\n const response = await cache.match(request);\n if (!isDev && response) return response;\n const [e, resp] = await tryToCatch(fetch, newRequest, {\n credentials: 'same-origin'\n });\n if (e) return new Response(e.message);\n await addToCache(request, resp.clone());\n return resp;\n}\n\nasync function addToCache(request, response) {\n const cache = await caches.open(NAME);\n return cache.put(request, response);\n}\n\n//# sourceURL=file://cloudcmd/client/sw/sw.js");
105
105
 
106
106
  /***/ }),
107
107
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcmd",
3
- "version": "15.9.7",
3
+ "version": "15.9.11",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "File manager for the web with console and editor",
6
6
  "homepage": "http://cloudcmd.io",
@@ -100,7 +100,7 @@
100
100
  "execon": "^1.2.0",
101
101
  "express": "^4.13.0",
102
102
  "files-io": "^4.0.0",
103
- "find-up": "^5.0.0",
103
+ "find-up": "^6.1.0",
104
104
  "for-each-key": "^2.0.0",
105
105
  "format-io": "^2.0.0",
106
106
  "fullstore": "^3.0.0",
@@ -120,7 +120,7 @@
120
120
  "package-json": "^7.0.0",
121
121
  "ponse": "^6.0.0",
122
122
  "pullout": "^4.0.0",
123
- "putout": "^18.0.1",
123
+ "putout": "^22.0.2",
124
124
  "redzip": "^2.0.0",
125
125
  "rendy": "^3.0.0",
126
126
  "restafary": "^10.0.0",
@@ -138,7 +138,7 @@
138
138
  "win32": "^6.0.0",
139
139
  "wraptile": "^3.0.0",
140
140
  "writejson": "^3.0.0",
141
- "yargs-parser": "^20.2.5"
141
+ "yargs-parser": "^21.0.0"
142
142
  },
143
143
  "devDependencies": {
144
144
  "@babel/code-frame": "^7.5.5",
@@ -162,9 +162,9 @@
162
162
  "css-modules-require-hook": "^4.2.3",
163
163
  "domtokenlist-shim": "^1.2.0",
164
164
  "emitify": "^4.0.1",
165
- "eslint": "^7.0.0-rc.0",
165
+ "eslint": "^8.0.1",
166
166
  "eslint-plugin-node": "^11.0.0",
167
- "eslint-plugin-putout": "^8.0.1",
167
+ "eslint-plugin-putout": "^12.2.0",
168
168
  "extract-text-webpack-plugin": "^4.0.0-alpha.0",
169
169
  "gritty": "^6.0.0",
170
170
  "gunzip-maybe": "^1.3.1",
@@ -194,7 +194,7 @@
194
194
  "smalltalk": "^4.0.0",
195
195
  "style-loader": "^2.0.0",
196
196
  "supermenu": "^4.0.1",
197
- "supertape": "^5.0.0",
197
+ "supertape": "^6.9.1",
198
198
  "tar-stream": "^2.0.0",
199
199
  "unionfs": "^4.0.0",
200
200
  "url-loader": "^4.0.0",
@@ -202,7 +202,7 @@
202
202
  "webpack-cli": "^3.0.1",
203
203
  "webpack-merge": "^5.0.8",
204
204
  "webpackbar": "^5.0.0-3",
205
- "yaspeller": "^7.0.0"
205
+ "yaspeller": "^8.0.0"
206
206
  },
207
207
  "engines": {
208
208
  "node": ">=14"
package/server/config.js CHANGED
@@ -114,7 +114,7 @@ function createConfig({configPath} = {}) {
114
114
  return configManager;
115
115
  }
116
116
 
117
- const write = async (filename, config) => {
117
+ const write = (filename, config) => {
118
118
  return writejson(filename, config('*'), {mode: 0o600});
119
119
  };
120
120
 
@@ -32,9 +32,7 @@ function stringToRGB(a) {
32
32
  ];
33
33
  }
34
34
 
35
- const add = (a, b) => {
36
- return a + b.charCodeAt(0);
37
- };
35
+ const add = (a, b) => a + b.charCodeAt(0);
38
36
 
39
37
  function crc(a) {
40
38
  return a
@@ -8,9 +8,7 @@ const {
8
8
  module.exports = (config) => {
9
9
  check(config);
10
10
 
11
- const data = Object.keys(config).map((name) => {
12
- return [name, config[name]];
13
- });
11
+ const data = Object.keys(config).map((name) => [name, config[name]]);
14
12
 
15
13
  if (!data.length)
16
14
  return '';
@@ -8,7 +8,6 @@ const {join} = require('path');
8
8
  const montag = require('montag');
9
9
  const tryToCatch = require('try-to-catch');
10
10
  const currify = require('currify');
11
- const findUp = require('find-up');
12
11
  const threadIt = require('thread-it');
13
12
  const {codeframe} = require('putout');
14
13
  const putout = threadIt(require.resolve('putout'));
@@ -44,6 +43,7 @@ async function onGET({req, res, menuName}) {
44
43
  if (url === '/default')
45
44
  return sendDefaultMenu(res);
46
45
 
46
+ const {findUp} = await import('find-up');
47
47
  const [errorFind, currentMenuPath] = await tryToCatch(findUp, [
48
48
  menuName,
49
49
  ], {cwd: dir});