cloudcmd 16.16.0 → 16.16.2

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 (77) hide show
  1. package/ChangeLog +12 -0
  2. package/HELP.md +3 -1
  3. package/README.md +3 -5
  4. package/bin/cloudcmd.mjs +2 -2
  5. package/bin/release.mjs +1 -1
  6. package/common/base64.js +2 -2
  7. package/common/cloudfunc.js +1 -1
  8. package/common/datetime.js +1 -1
  9. package/common/util.js +4 -3
  10. package/dist/cloudcmd.common.js +3 -3
  11. package/dist/cloudcmd.common.js.map +1 -1
  12. package/dist/cloudcmd.js +1 -1
  13. package/dist/cloudcmd.js.map +1 -1
  14. package/dist/modules/cloud.js +1 -1
  15. package/dist/modules/cloud.js.map +1 -1
  16. package/dist/modules/command-line.js +1 -1
  17. package/dist/modules/command-line.js.map +1 -1
  18. package/dist/modules/config.js +1 -1
  19. package/dist/modules/config.js.map +1 -1
  20. package/dist/modules/contact.js +1 -1
  21. package/dist/modules/contact.js.map +1 -1
  22. package/dist/modules/edit-file-vim.js +1 -1
  23. package/dist/modules/edit-file-vim.js.map +1 -1
  24. package/dist/modules/edit-file.js +1 -1
  25. package/dist/modules/edit-file.js.map +1 -1
  26. package/dist/modules/edit-names-vim.js +1 -1
  27. package/dist/modules/edit-names-vim.js.map +1 -1
  28. package/dist/modules/edit-names.js +1 -1
  29. package/dist/modules/edit-names.js.map +1 -1
  30. package/dist/modules/edit.js +2 -2
  31. package/dist/modules/edit.js.map +1 -1
  32. package/dist/modules/help.js +1 -1
  33. package/dist/modules/help.js.map +1 -1
  34. package/dist/modules/konsole.js +1 -1
  35. package/dist/modules/konsole.js.map +1 -1
  36. package/dist/modules/markdown.js +1 -1
  37. package/dist/modules/markdown.js.map +1 -1
  38. package/dist/modules/menu.js +1 -1
  39. package/dist/modules/menu.js.map +1 -1
  40. package/dist/modules/operation.js +1 -1
  41. package/dist/modules/operation.js.map +1 -1
  42. package/dist/modules/polyfill.js +1 -1
  43. package/dist/modules/polyfill.js.map +1 -1
  44. package/dist/modules/terminal-run.js +1 -1
  45. package/dist/modules/terminal-run.js.map +1 -1
  46. package/dist/modules/terminal.js +1 -1
  47. package/dist/modules/terminal.js.map +1 -1
  48. package/dist/modules/upload.js +1 -1
  49. package/dist/modules/upload.js.map +1 -1
  50. package/dist/modules/user-menu.js +1 -1
  51. package/dist/modules/user-menu.js.map +1 -1
  52. package/dist/modules/view.js +1 -1
  53. package/dist/modules/view.js.map +1 -1
  54. package/dist/sw.js +1 -1
  55. package/dist/sw.js.map +1 -1
  56. package/dist-dev/cloudcmd.common.js +63 -15
  57. package/dist-dev/cloudcmd.js +7 -7
  58. package/dist-dev/modules/config.js +1 -1
  59. package/dist-dev/modules/contact.js +1 -1
  60. package/dist-dev/modules/edit.js +1 -1
  61. package/dist-dev/modules/markdown.js +1 -1
  62. package/dist-dev/modules/menu.js +1 -1
  63. package/dist-dev/modules/operation.js +2 -2
  64. package/dist-dev/modules/terminal-run.js +1 -1
  65. package/dist-dev/modules/terminal.js +1 -1
  66. package/dist-dev/modules/upload.js +1 -1
  67. package/dist-dev/modules/user-menu.js +2 -2
  68. package/dist-dev/modules/view.js +1 -1
  69. package/dist-dev/sw.js +1 -1
  70. package/package.json +8 -7
  71. package/server/cloudcmd.js +2 -2
  72. package/server/config.js +1 -1
  73. package/server/markdown/index.js +2 -2
  74. package/server/prefixer.js +3 -1
  75. package/server/rest/index.js +9 -12
  76. package/server/validate.js +2 -1
  77. package/static/user-menu.js +1 -2
@@ -163,7 +163,7 @@
163
163
  /***/ (function(module, exports, __webpack_require__) {
164
164
 
165
165
  "use strict";
166
- eval("/* global CloudCmd, DOM */\n\n\n\n__webpack_require__(/*! ../../../css/view.css */ \"./css/view.css\");\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst modal = __webpack_require__(/*! @cloudcmd/modal */ \"./node_modules/@cloudcmd/modal/lib/modal.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n time\n} = __webpack_require__(/*! ../../../common/util */ \"./common/util.js\");\nconst {\n FS\n} = __webpack_require__(/*! ../../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst {\n isImage,\n isAudio,\n getType\n} = __webpack_require__(/*! ./types */ \"./client/modules/view/types.js\");\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\nconst Events = __webpack_require__(/*! ../../dom/events */ \"./client/dom/events/index.js\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\nconst {\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 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) {\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 if (data) {\n if (isArray(data)) El.append(...data);else El.append(data);\n modal.open(El, initConfig(options));\n return;\n }\n Images.show.load();\n const path = prefixURL + Info.path;\n const type = options.raw ? '' : await getType(path);\n switch (type) {\n default:\n return await viewFile();\n case 'markdown':\n return await CloudCmd.Markdown.show(Info.path);\n case 'html':\n return viewHtml(path);\n case 'image':\n return viewImage(Info.path, prefixURL);\n case 'media':\n return await viewMedia(path);\n case 'pdf':\n return viewPDF(path);\n }\n}\nmodule.exports._createIframe = createIframe;\nfunction createIframe(src) {\n const element = createElement('iframe', {\n src,\n width: '100%',\n height: '100%'\n });\n element.addEventListener('load', () => {\n element.contentWindow.addEventListener('keydown', listener);\n });\n return element;\n}\nmodule.exports._viewHtml = viewHtml;\nfunction viewHtml(src) {\n modal.open(createIframe(src), Config);\n}\nfunction viewPDF(src) {\n const element = createIframe(src);\n const options = assign({}, Config);\n if (CloudCmd.config('showFileName')) options.title = Info.name;\n modal.open(element, options);\n}\nasync function viewMedia(path) {\n const [e, element] = await getMediaElement(path);\n if (e) return alert(e);\n const allConfig = {\n ...Config,\n ...{\n autoSize: true,\n afterShow: () => {\n element.querySelector('audio, video').focus();\n }\n }\n };\n modal.open(element, allConfig);\n}\nasync function viewFile() {\n const [error, data] = await Info.getData();\n if (error) return Images.hide();\n const element = document.createTextNode(data);\n const options = Config;\n if (CloudCmd.config('showFileName')) options.title = Info.name;\n El.append(element);\n modal.open(El, options);\n}\nconst copy = a => assign({}, a);\nmodule.exports._initConfig = initConfig;\nfunction initConfig(options) {\n const config = copy(Config);\n if (!options) return config;\n const names = Object.keys(options);\n for (const name of names) {\n const isConfig = Boolean(config[name]);\n const item = options[name];\n if (!isFn(item) || !isConfig) {\n config[name] = options[name];\n continue;\n }\n const fn = config[name];\n config[name] = series(fn, item);\n }\n return config;\n}\nfunction hide() {\n modal.close();\n}\nfunction viewImage(path, prefixURL) {\n const isSupportedImage = a => isImage(a) || a === path;\n const makeTitle = path => ({\n href: `${prefixURL}${path}`,\n title: encode(basename(path))\n });\n const names = Info.files.map(DOM.getCurrentPath).filter(isSupportedImage);\n const titles = names.map(makeTitle);\n const index = names.indexOf(Info.path);\n const imageConfig = {\n index,\n autoSize: true,\n arrows: true,\n keys: true,\n helpers: {\n title: {}\n }\n };\n const config = {\n ...Config,\n ...imageConfig\n };\n modal.open(titles, config);\n}\nasync function getMediaElement(src) {\n check(src);\n const [error, template] = await tryToCatch(Files.get, 'view/media-tmpl');\n if (error) return [error];\n const {\n name\n } = Info;\n if (!TemplateAudio) TemplateAudio = template;\n const is = isAudio(name);\n const type = is ? 'audio' : 'video';\n const innerHTML = rendy(TemplateAudio, {\n src,\n type,\n name\n });\n const element = createElement('div', {\n innerHTML\n });\n return [null, element];\n}\nfunction check(src) {\n if (typeof src !== 'string') throw Error('src should be a string!');\n}\n\n/**\n * function loads css and js of FancyBox\n * @callback - executes, when everything loaded\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(_ref) {\n let {\n keyCode\n } = _ref;\n if (keyCode === Key.ESC) hide();\n}\n\n//# sourceURL=file://cloudcmd/client/modules/view/index.js");
166
+ eval("/* global CloudCmd, DOM */\n\n\n\n__webpack_require__(/*! ../../../css/view.css */ \"./css/view.css\");\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/lib/rendy.js\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst wraptile = __webpack_require__(/*! wraptile */ \"./node_modules/wraptile/lib/wraptile.js\");\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\nconst modal = __webpack_require__(/*! @cloudcmd/modal */ \"./node_modules/@cloudcmd/modal/lib/modal.js\");\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\nconst {\n time\n} = __webpack_require__(/*! ../../../common/util */ \"./common/util.js\");\nconst {\n FS\n} = __webpack_require__(/*! ../../../common/cloudfunc */ \"./common/cloudfunc.js\");\nconst {\n isImage,\n isAudio,\n getType\n} = __webpack_require__(/*! ./types */ \"./client/modules/view/types.js\");\nconst Files = __webpack_require__(/*! ../../dom/files */ \"./client/dom/files.js\");\nconst Events = __webpack_require__(/*! ../../dom/events */ \"./client/dom/events/index.js\");\nconst Images = __webpack_require__(/*! ../../dom/images */ \"./client/dom/images.js\");\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\nconst isString = a => typeof a === 'string';\nconst {\n assign\n} = Object;\nconst {\n isArray\n} = Array;\nconst lifo = currify((fn, el, cb, name) => fn(name, el, cb));\nconst series = wraptile((...a) => {\n for (const f of a) f();\n});\nconst isFn = a => typeof a === 'function';\nconst noop = () => {};\nconst addEvent = lifo(Events.add);\nconst loadCSS = load.css;\nmodule.exports.show = show;\nmodule.exports.hide = hide;\nlet Loading = false;\nconst Name = 'View';\nCloudCmd[Name] = module.exports;\nconst Info = DOM.CurrentInfo;\nconst {\n Key\n} = CloudCmd;\nconst basename = a => a.split('/').pop();\nlet El;\nlet TemplateAudio;\nlet Overlay;\nconst Config = {\n beforeShow: () => {\n Images.hide();\n Key.unsetBind();\n },\n beforeClose: () => {\n Events.rmKey(listener);\n Key.setBind();\n },\n afterShow: () => {\n El.focus();\n },\n onOverlayClick,\n afterClose: noop,\n autoSize: false,\n helpers: {\n title: {}\n }\n};\nmodule.exports._Config = Config;\nmodule.exports.init = async () => {\n await loadAll();\n const events = ['click', 'contextmenu'];\n events.forEach(addEvent(Overlay, onOverlayClick));\n};\nasync function show(data, options = {}) {\n const prefixURL = CloudCmd.prefixURL + FS;\n if (Loading) return;\n if (!options || options.bindKeys !== false) Events.addKey(listener);\n El = createElement('div', {\n className: 'view',\n notAppend: true\n });\n El.tabIndex = 0;\n if (data) {\n if (isArray(data)) El.append(...data);else El.append(data);\n modal.open(El, initConfig(options));\n return;\n }\n Images.show.load();\n const path = prefixURL + Info.path;\n const type = options.raw ? '' : await getType(path);\n switch (type) {\n default:\n return await viewFile();\n case 'markdown':\n return await CloudCmd.Markdown.show(Info.path);\n case 'html':\n return viewHtml(path);\n case 'image':\n return viewImage(Info.path, prefixURL);\n case 'media':\n return await viewMedia(path);\n case 'pdf':\n return viewPDF(path);\n }\n}\nmodule.exports._createIframe = createIframe;\nfunction createIframe(src) {\n const element = createElement('iframe', {\n src,\n width: '100%',\n height: '100%'\n });\n element.addEventListener('load', () => {\n element.contentWindow.addEventListener('keydown', listener);\n });\n return element;\n}\nmodule.exports._viewHtml = viewHtml;\nfunction viewHtml(src) {\n modal.open(createIframe(src), Config);\n}\nfunction viewPDF(src) {\n const element = createIframe(src);\n const options = assign({}, Config);\n if (CloudCmd.config('showFileName')) options.title = Info.name;\n modal.open(element, options);\n}\nasync function viewMedia(path) {\n const [e, element] = await getMediaElement(path);\n if (e) return alert(e);\n const allConfig = {\n ...Config,\n ...{\n autoSize: true,\n afterShow: () => {\n element.querySelector('audio, video').focus();\n }\n }\n };\n modal.open(element, allConfig);\n}\nasync function viewFile() {\n const [error, data] = await Info.getData();\n if (error) return Images.hide();\n const element = document.createTextNode(data);\n const options = Config;\n if (CloudCmd.config('showFileName')) options.title = Info.name;\n El.append(element);\n modal.open(El, options);\n}\nconst copy = a => assign({}, a);\nmodule.exports._initConfig = initConfig;\nfunction initConfig(options) {\n const config = copy(Config);\n if (!options) return config;\n const names = Object.keys(options);\n for (const name of names) {\n const isConfig = Boolean(config[name]);\n const item = options[name];\n if (!isFn(item) || !isConfig) {\n config[name] = options[name];\n continue;\n }\n const fn = config[name];\n config[name] = series(fn, item);\n }\n return config;\n}\nfunction hide() {\n modal.close();\n}\nfunction viewImage(path, prefixURL) {\n const isSupportedImage = a => isImage(a) || a === path;\n const makeTitle = path => ({\n href: `${prefixURL}${path}`,\n title: encode(basename(path))\n });\n const names = Info.files.map(DOM.getCurrentPath).filter(isSupportedImage);\n const titles = names.map(makeTitle);\n const index = names.indexOf(Info.path);\n const imageConfig = {\n index,\n autoSize: true,\n arrows: true,\n keys: true,\n helpers: {\n title: {}\n }\n };\n const config = {\n ...Config,\n ...imageConfig\n };\n modal.open(titles, config);\n}\nasync function getMediaElement(src) {\n check(src);\n const [error, template] = await tryToCatch(Files.get, 'view/media-tmpl');\n if (error) return [error];\n const {\n name\n } = Info;\n if (!TemplateAudio) TemplateAudio = template;\n const is = isAudio(name);\n const type = is ? 'audio' : 'video';\n const innerHTML = rendy(TemplateAudio, {\n src,\n type,\n name\n });\n const element = createElement('div', {\n innerHTML\n });\n return [null, element];\n}\nfunction check(src) {\n if (!isString(src)) throw Error('src should be a string!');\n}\n\n/**\n * function loads css and js of FancyBox\n * @callback - executes, when everything loaded\n */\nasync function loadAll() {\n const {\n DIR_DIST\n } = CloudCmd;\n time(`${Name} load`);\n Loading = true;\n await loadCSS(`${DIR_DIST}/view.css`);\n Loading = false;\n}\nfunction onOverlayClick(event) {\n const position = {\n x: event.clientX,\n y: event.clientY\n };\n setCurrentByPosition(position);\n}\nfunction setCurrentByPosition(position) {\n const element = DOM.getCurrentByPosition(position);\n if (!element) return;\n const {\n files,\n filesPassive\n } = Info;\n const isFiles = files.includes(element);\n const isFilesPassive = filesPassive.includes(element);\n if (!isFiles && !isFilesPassive) return;\n const isCurrent = DOM.isCurrentFile(element);\n if (isCurrent) return;\n DOM.setCurrentFile(element);\n}\nfunction listener({\n keyCode\n}) {\n if (keyCode === Key.ESC) hide();\n}\n\n//# sourceURL=file://cloudcmd/client/modules/view/index.js");
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\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst isDev = \"development\" === 'development';\nconst isGet = a => a.method === 'GET';\nconst isBasic = a => a.type === 'basic';\nconst wait = currify((f, e) => e.waitUntil(f()));\nconst respondWith = currify((f, e) => {\n const {\n request\n } = e;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n if (url.endsWith('/') || /\\^\\/fs/.test(pathname)) return;\n if (!isGet(request)) return;\n if (!isBasic(request)) return;\n if (pathname.startsWith('/api')) return;\n if (/^socket.io/.test(pathname)) return;\n e.respondWith(f(e));\n});\nconst getPathName = url => new URL(url).pathname;\nconst date = \"Sun Jul 09 2023 12:53:27 GMT+0300 (Eastern European Summer Time)\";\nconst NAME = `cloudcmd: ${date}`;\nconst createRequest = a => new Request(a, {\n credentials: 'same-origin'\n});\nconst getRequest = (a, request) => {\n if (a !== '/') return request;\n return createRequest('/');\n};\nself.addEventListener('install', wait(onInstall));\nself.addEventListener('fetch', respondWith(onFetch));\nself.addEventListener('activate', wait(onActivate));\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}\nasync function onInstall() {\n console.info(`cloudcmd: sw: install: ${NAME}`);\n await self.skipWaiting();\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}\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\");\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\nconst isDev = \"development\" === 'development';\nconst isGet = a => a.method === 'GET';\nconst isBasic = a => a.type === 'basic';\nconst wait = currify((f, e) => e.waitUntil(f()));\nconst respondWith = currify((f, e) => {\n const {\n request\n } = e;\n const {\n url\n } = request;\n const pathname = getPathName(url);\n if (url.endsWith('/') || /\\^\\/fs/.test(pathname)) return;\n if (!isGet(request)) return;\n if (!isBasic(request)) return;\n if (pathname.startsWith('/api')) return;\n if (/^socket.io/.test(pathname)) return;\n e.respondWith(f(e));\n});\nconst getPathName = url => new URL(url).pathname;\nconst date = \"Wed Aug 09 2023 19:04:41 GMT+0300 (Eastern European Summer Time)\";\nconst NAME = `cloudcmd: ${date}`;\nconst createRequest = a => new Request(a, {\n credentials: 'same-origin'\n});\nconst getRequest = (a, request) => {\n if (a !== '/') return request;\n return createRequest('/');\n};\nself.addEventListener('install', wait(onInstall));\nself.addEventListener('fetch', respondWith(onFetch));\nself.addEventListener('activate', wait(onActivate));\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}\nasync function onInstall() {\n console.info(`cloudcmd: sw: install: ${NAME}`);\n await self.skipWaiting();\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}\nasync function addToCache(request, response) {\n const cache = await caches.open(NAME);\n return cache.put(request, response);\n}\n\n//# sourceURL=file://cloudcmd/client/sw/sw.js");
105
105
 
106
106
  /***/ }),
107
107
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcmd",
3
- "version": "16.16.0",
3
+ "version": "16.16.2",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "File manager for the web with console and editor",
@@ -85,6 +85,8 @@
85
85
  },
86
86
  "subdomain": "cloudcmd",
87
87
  "dependencies": {
88
+ "@babel/core": "^7.22.9",
89
+ "@babel/plugin-proposal-optional-chaining": "^7.21.0",
88
90
  "@cloudcmd/dropbox": "^4.0.1",
89
91
  "@cloudcmd/fileop": "^7.0.0",
90
92
  "@cloudcmd/move-files": "^7.0.0",
@@ -126,8 +128,8 @@
126
128
  "package-json": "^8.1.0",
127
129
  "ponse": "^7.0.0",
128
130
  "pullout": "^4.0.0",
129
- "putout": "^30.1.1",
130
- "redzip": "^2.0.0",
131
+ "putout": "^31.0.3",
132
+ "redzip": "^3.0.0",
131
133
  "rendy": "^3.0.0",
132
134
  "restafary": "^11.0.0",
133
135
  "restbox": "^3.0.0",
@@ -147,15 +149,14 @@
147
149
  "yargs-parser": "^21.0.0"
148
150
  },
149
151
  "devDependencies": {
150
- "@babel/code-frame": "^7.5.5",
151
- "@babel/core": "^7.0.0",
152
- "@babel/plugin-proposal-optional-chaining": "^7.12.7",
152
+ "@babel/code-frame": "^7.22.5",
153
153
  "@babel/preset-env": "^7.0.0",
154
154
  "@cloudcmd/clipboard": "^2.0.0",
155
155
  "@cloudcmd/create-element": "^2.0.0",
156
156
  "@cloudcmd/modal": "^3.0.0",
157
157
  "@cloudcmd/olark": "^3.0.2",
158
158
  "@cloudcmd/stub": "^4.0.1",
159
+ "@putout/babel": "^1.0.5",
159
160
  "auto-globals": "^3.0.0",
160
161
  "babel-loader": "^8.0.0",
161
162
  "babel-plugin-macros": "^3.0.0",
@@ -169,7 +170,7 @@
169
170
  "emitify": "^4.0.1",
170
171
  "eslint": "^8.0.1",
171
172
  "eslint-plugin-n": "^16.0.1",
172
- "eslint-plugin-putout": "^18.0.0",
173
+ "eslint-plugin-putout": "^19.0.3",
173
174
  "extract-text-webpack-plugin": "^4.0.0-alpha.0",
174
175
  "gritty": "^7.0.0",
175
176
  "gunzip-maybe": "^1.3.1",
@@ -109,7 +109,7 @@ module.exports._getPrefix = getPrefix;
109
109
  function getPrefix(prefix) {
110
110
  if (isFn(prefix))
111
111
  return prefix() || '';
112
-
112
+
113
113
  return prefix || '';
114
114
  }
115
115
 
@@ -258,7 +258,7 @@ module.exports._replaceDist = replaceDist;
258
258
  function replaceDist(url) {
259
259
  if (!isDev)
260
260
  return url;
261
-
261
+
262
262
  return url.replace(/^\/dist\//, '/dist-dev/');
263
263
  }
264
264
 
package/server/config.js CHANGED
@@ -76,7 +76,7 @@ const manageListen = currify((manage, socket, auth) => {
76
76
  function initWrite(filename, configManager) {
77
77
  if (filename)
78
78
  return write.bind(null, filename, configManager);
79
-
79
+
80
80
  return resolve;
81
81
  }
82
82
 
@@ -9,7 +9,7 @@ const threadIt = require('thread-it');
9
9
  const {read} = require('redzip');
10
10
 
11
11
  const root = require('../root');
12
-
12
+ const isString = (a) => typeof a === 'string';
13
13
  const parse = threadIt(join(__dirname, 'worker'));
14
14
 
15
15
  threadIt.init();
@@ -56,7 +56,7 @@ async function onPUT(request) {
56
56
  }
57
57
 
58
58
  function check(name, request) {
59
- if (typeof name !== 'string')
59
+ if (!isString(name))
60
60
  throw Error('name should be string!');
61
61
 
62
62
  if (!request)
@@ -1,7 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ const isString = (a) => typeof a === 'string';
4
+
3
5
  module.exports = (value) => {
4
- if (typeof value !== 'string')
6
+ if (!isString(value))
5
7
  return '';
6
8
 
7
9
  if (value.length === 1)
@@ -22,7 +22,8 @@ const ponse = require('ponse');
22
22
 
23
23
  const copymitter = require('copymitter');
24
24
  const moveFiles = require('@cloudcmd/move-files');
25
-
25
+ const isString = (a) => typeof a === 'string';
26
+ const isFn = (a) => typeof a === 'function';
26
27
  const swap = wraptile((fn, a, b) => fn(b, a));
27
28
  const isWin32 = process.platform === 'win32';
28
29
  const {apiURL} = CloudFunc;
@@ -148,7 +149,7 @@ function onGET(params, config, callback) {
148
149
  function getPackReg(packer) {
149
150
  if (packer === 'zip')
150
151
  return /\.zip$/;
151
-
152
+
152
153
  return /\.tar\.gz$/;
153
154
  }
154
155
 
@@ -167,14 +168,11 @@ function streamPack(cmd, response, packer) {
167
168
  function getCMD(cmd) {
168
169
  if (cmd[0] === '/')
169
170
  return cmd.slice(1);
170
-
171
+
171
172
  return cmd;
172
173
  }
173
174
 
174
- const getMoveMsg = (names) => {
175
- const msg = formatMsg('move', names);
176
- return msg;
177
- };
175
+ const getMoveMsg = (names) => formatMsg('move', names);
178
176
 
179
177
  const getRenameMsg = (from, to) => {
180
178
  const msg = formatMsg('rename', {
@@ -376,9 +374,8 @@ module.exports._getWin32RootMsg = getWin32RootMsg;
376
374
 
377
375
  function getWin32RootMsg() {
378
376
  const message = 'Could not copy from/to root on windows!';
379
- const error = Error(message);
380
377
 
381
- return error;
378
+ return Error(message);
382
379
  }
383
380
 
384
381
  function parseData(data) {
@@ -398,12 +395,12 @@ function formatMsg(msg, data, status) {
398
395
  }
399
396
 
400
397
  function checkPut(name, body, callback) {
401
- if (typeof name !== 'string')
398
+ if (!isString(name))
402
399
  throw Error('name should be a string!');
403
400
 
404
- if (typeof body !== 'string')
401
+ if (!isString(body))
405
402
  throw Error('body should be a string!');
406
403
 
407
- if (typeof callback !== 'function')
404
+ if (!isFn(callback))
408
405
  throw Error('callback should be a function!');
409
406
  }
@@ -4,9 +4,10 @@ const tryCatch = require('try-catch');
4
4
 
5
5
  const exit = require('./exit');
6
6
  const columns = require('./columns');
7
+ const isString = (a) => typeof a === 'string';
7
8
 
8
9
  module.exports.root = (dir, config) => {
9
- if (typeof dir !== 'string')
10
+ if (!isString(dir))
10
11
  throw Error('dir should be a string');
11
12
 
12
13
  if (dir === '/')
@@ -131,9 +131,8 @@ async function createDefaultMenu({path, data, DOM, CloudCmd}) {
131
131
 
132
132
  async function readDefaultMenu({prefix}) {
133
133
  const res = await fetch(`${prefix}/api/v1/user-menu/default`);
134
- const data = await res.text();
135
134
 
136
- return data;
135
+ return await res.text();
137
136
  }
138
137
 
139
138
  module.exports._selectNames = selectNames;