cloudcmd 19.10.2 → 19.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sw.js CHANGED
@@ -311,7 +311,7 @@ const respondWith = currify((f, e) => {
311
311
  e.respondWith(f(e));
312
312
  });
313
313
  const getPathName = url => new URL(url).pathname;
314
- const date = "Sat Apr 04 2026 00:06:21 GMT+0300 (Eastern European Summer Time)";
314
+ const date = "Sat Apr 04 2026 17:05:16 GMT+0300 (Eastern European Summer Time)";
315
315
  const NAME = `cloudcmd: ${date}`;
316
316
  const createRequest = a => new Request(a, {
317
317
  credentials: 'same-origin'
@@ -1756,7 +1756,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
1756
1756
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1757
1757
 
1758
1758
  "use strict";
1759
- 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 _css_terminal_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../css/terminal.css */ \"./css/terminal.css\");\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 try_to_catch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n/* harmony import */ var fullstore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n/* harmony import */ var execon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n/* harmony import */ var load_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! #dom */ \"./client/dom/index.js\");\n/* harmony import */ var _dom_images__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! #dom/images */ \"./client/dom/images.js\");\n\n\n\n\n\n\n\n\nconst {\n Dialog\n} = _dom__WEBPACK_IMPORTED_MODULE_6__[\"default\"];\nconst {\n CloudCmd\n} = globalThis;\nconst {\n Key,\n config\n} = CloudCmd;\nCloudCmd.TerminalRun = {\n init,\n show,\n hide\n};\nlet Loaded;\nlet Terminal;\nlet Socket;\nconst exitCodeStore = (0,fullstore__WEBPACK_IMPORTED_MODULE_3__.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 (0,try_to_catch__WEBPACK_IMPORTED_MODULE_2__.tryToCatch)(load_js__WEBPACK_IMPORTED_MODULE_5__.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};\nasync function init() {\n if (!config('terminal')) return;\n _dom_images__WEBPACK_IMPORTED_MODULE_7__.show.load('top');\n await CloudCmd.View();\n await loadAll();\n}\nasync function show(options = {}) {\n await runTerminal(options);\n}\nconst runTerminal = (0,es6_promisify__WEBPACK_IMPORTED_MODULE_1__.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});\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__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getCurrentDirPath,\n PASSIVE_DIR: _dom__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getNotCurrentDirPath,\n CURRENT_NAME: _dom__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getCurrentName,\n CURRENT_PATH: _dom__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getCurrentPath\n});\nfunction create(createOptions) {\n const {\n cwd = _dom__WEBPACK_IMPORTED_MODULE_6__[\"default\"].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 } = globalThis.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', execon__WEBPACK_IMPORTED_MODULE_4__[\"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}");
1759
+ 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 _css_terminal_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../css/terminal.css */ \"./css/terminal.css\");\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 try_to_catch__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n/* harmony import */ var fullstore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n/* harmony import */ var execon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n/* harmony import */ var load_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n/* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! #dom */ \"./client/dom/index.js\");\n/* harmony import */ var _dom_images__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! #dom/images */ \"./client/dom/images.js\");\n\n\n\n\n\n\n\n\nconst {\n Dialog\n} = _dom__WEBPACK_IMPORTED_MODULE_6__[\"default\"];\nconst {\n CloudCmd\n} = globalThis;\nconst {\n Key,\n config\n} = CloudCmd;\nCloudCmd.TerminalRun = {\n init,\n show,\n hide\n};\nlet Loaded;\nlet Terminal;\nlet Socket;\nconst exitCodeStore = (0,fullstore__WEBPACK_IMPORTED_MODULE_3__.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 (0,try_to_catch__WEBPACK_IMPORTED_MODULE_2__.tryToCatch)(load_js__WEBPACK_IMPORTED_MODULE_5__.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};\nasync function init() {\n if (!config('terminal')) return;\n _dom_images__WEBPACK_IMPORTED_MODULE_7__.show.load('top');\n await CloudCmd.View();\n await loadAll();\n}\nasync function show(options = {}) {\n return await runTerminal(options);\n}\nconst runTerminal = (0,es6_promisify__WEBPACK_IMPORTED_MODULE_1__.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});\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__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getCurrentDirPath,\n PASSIVE_DIR: _dom__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getNotCurrentDirPath,\n CURRENT_NAME: _dom__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getCurrentName,\n CURRENT_PATH: _dom__WEBPACK_IMPORTED_MODULE_6__[\"default\"].getCurrentPath\n});\nfunction create(createOptions) {\n const {\n cwd = _dom__WEBPACK_IMPORTED_MODULE_6__[\"default\"].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 } = globalThis.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', execon__WEBPACK_IMPORTED_MODULE_4__[\"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}");
1760
1760
 
1761
1761
  /***/ },
1762
1762
 
package/dist-dev/sw.js CHANGED
@@ -37,7 +37,7 @@ eval("{// shim for using process in browser\nvar process = module.exports = {};\
37
37
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
38
38
 
39
39
  "use strict";
40
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var node_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node:process */ \"./node_modules/process/browser.js\");\n/* harmony import */ var try_to_catch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\n\n\nconst isDev = \"development\" === 'development';\nconst isGet = a => a.method === 'GET';\nconst isBasic = a => a.type === 'basic';\nconst wait = currify__WEBPACK_IMPORTED_MODULE_2__((f, e) => e.waitUntil(f()));\nconst respondWith = currify__WEBPACK_IMPORTED_MODULE_2__((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 = \"Sat Apr 04 2026 00:06:23 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};\nglobalThis.addEventListener('install', wait(onInstall));\nglobalThis.addEventListener('fetch', respondWith(onFetch));\nglobalThis.addEventListener('activate', wait(onActivate));\nasync function onActivate() {\n console.info(`cloudcmd: sw: activate: ${NAME}`);\n await globalThis.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 globalThis.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 (0,try_to_catch__WEBPACK_IMPORTED_MODULE_1__.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//Users/coderaiser/cloudcmd/client/sw/sw.js\n}");
40
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var node_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! node:process */ \"./node_modules/process/browser.js\");\n/* harmony import */ var try_to_catch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n/* harmony import */ var currify__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! currify */ \"./node_modules/currify/lib/currify.js\");\n\n\n\nconst isDev = \"development\" === 'development';\nconst isGet = a => a.method === 'GET';\nconst isBasic = a => a.type === 'basic';\nconst wait = currify__WEBPACK_IMPORTED_MODULE_2__((f, e) => e.waitUntil(f()));\nconst respondWith = currify__WEBPACK_IMPORTED_MODULE_2__((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 = \"Sat Apr 04 2026 17:05:18 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};\nglobalThis.addEventListener('install', wait(onInstall));\nglobalThis.addEventListener('fetch', respondWith(onFetch));\nglobalThis.addEventListener('activate', wait(onActivate));\nasync function onActivate() {\n console.info(`cloudcmd: sw: activate: ${NAME}`);\n await globalThis.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 globalThis.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 (0,try_to_catch__WEBPACK_IMPORTED_MODULE_1__.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//Users/coderaiser/cloudcmd/client/sw/sw.js\n}");
41
41
 
42
42
  /***/ },
43
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcmd",
3
- "version": "19.10.2",
3
+ "version": "19.11.1",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "File manager for the web with console and editor",
@@ -242,6 +242,7 @@ function cloudcmdMiddle({modules, config}) {
242
242
  }),
243
243
  userMenu({
244
244
  menuName: '.cloudcmd.menu.js',
245
+ config,
245
246
  }),
246
247
  rest({
247
248
  config,
@@ -12,7 +12,7 @@ transpile('');
12
12
 
13
13
  const PREFIX = '/api/v1/user-menu';
14
14
 
15
- export const userMenu = currify(async ({menuName, readFile = _readFile}, req, res, next) => {
15
+ export const userMenu = currify(async ({menuName, readFile = _readFile, config}, req, res, next) => {
16
16
  if (!req.url.startsWith(PREFIX))
17
17
  return next();
18
18
 
@@ -24,12 +24,13 @@ export const userMenu = currify(async ({menuName, readFile = _readFile}, req, re
24
24
  res,
25
25
  menuName,
26
26
  readFile,
27
+ config,
27
28
  });
28
29
 
29
30
  next();
30
31
  });
31
32
 
32
- async function onGET({req, res, menuName, readFile}) {
33
+ async function onGET({req, res, menuName, readFile, config}) {
33
34
  const {dir} = req.query;
34
35
  const url = req.url.replace(PREFIX, '');
35
36
 
@@ -40,8 +41,9 @@ async function onGET({req, res, menuName, readFile}) {
40
41
 
41
42
  const {findUp} = await import('find-up');
42
43
 
44
+ const cwd = join(config('root'), dir);
43
45
  const [errorFind, currentMenuPath] = await tryToCatch(findUp, [menuName], {
44
- cwd: dir,
46
+ cwd,
45
47
  });
46
48
 
47
49
  if (errorFind && errorFind.code !== 'ENOENT')
@@ -1,5 +1,6 @@
1
1
  const RENAME_FILE = 'Rename file';
2
- const CDN = 'https://cdn.jsdelivr.net/gh/cloudcmd/user-menu@1.2.4';
2
+ const CDN = 'https://cdn.jsdelivr.net';
3
+ const CDN_GH = `${CDN}/gh/cloudcmd/user-menu@1.2.4`;
3
4
 
4
5
  export default {
5
6
  '__settings': {
@@ -10,13 +11,7 @@ export default {
10
11
  await DOM.renameCurrent();
11
12
  },
12
13
 
13
- 'F6 - Copy URL to current file': async ({DOM}) => {
14
- const {copyURLToCurrentFile} = await import(`${CDN}/menu/copy-url-to-current-file.js`);
15
-
16
- await copyURLToCurrentFile({
17
- DOM,
18
- });
19
- },
14
+ 'F6 - Copy URL to current file': runFromCDN('copy-url-to-current-file'),
20
15
 
21
16
  'R - cd /': async ({CloudCmd}) => {
22
17
  await CloudCmd.changeDir('/');
@@ -156,3 +151,18 @@ function compare(a, b) {
156
151
 
157
152
  return result;
158
153
  }
154
+
155
+ const MAP = {
156
+ 'copy-url-to-current-file': 'copyURLToCurrentFile',
157
+ };
158
+
159
+ function runFromCDN(name) {
160
+ return async (...a) => {
161
+ const fnName = MAP[name];
162
+ const {
163
+ [fnName]: fn,
164
+ } = await import(`${CDN_GH}/menu/${name}.js`);
165
+
166
+ await fn(...a);
167
+ };
168
+ }