cloudcmd 16.8.0 → 16.9.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/ChangeLog +12 -0
- package/HELP.md +3 -1
- package/README.md +1 -1
- package/dist/cloudcmd.common.js +3 -3
- package/dist/cloudcmd.common.js.map +1 -1
- package/dist/sw.js +1 -1
- package/dist-dev/cloudcmd.common.js +11 -11
- package/dist-dev/modules/polyfill.js +1 -1
- package/dist-dev/sw.js +1 -1
- package/package.json +3 -4
- package/static/user-menu.js +50 -15
package/dist/sw.js
CHANGED
|
@@ -5,5 +5,5 @@ var serviceWorkerOption = {
|
|
|
5
5
|
]
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/dist/",n(n.s=0)}([function(t,e,n){"use strict";const r=n(1),o=n(2),i=o((t,e)=>e.waitUntil(t())),c=o((t,e)=>{const{request:n}=e,{url:r}=n,o=a(r);r.endsWith("/")||/\^\/fs/.test(o)||"GET"===n.method&&(t=>"basic"===t.type)(n)&&(o.startsWith("/api")||/^socket.io/.test(o)||e.respondWith(t(e)))}),a=t=>new URL(t).pathname,u="cloudcmd:
|
|
8
|
+
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/dist/",n(n.s=0)}([function(t,e,n){"use strict";const r=n(1),o=n(2),i=o((t,e)=>e.waitUntil(t())),c=o((t,e)=>{const{request:n}=e,{url:r}=n,o=a(r);r.endsWith("/")||/\^\/fs/.test(o)||"GET"===n.method&&(t=>"basic"===t.type)(n)&&(o.startsWith("/api")||/^socket.io/.test(o)||e.respondWith(t(e)))}),a=t=>new URL(t).pathname,u="cloudcmd: Wed Jan 18 2023 11:11:47 GMT+0200 (Eastern European Standard Time)",s=(t,e)=>"/"!==t?e:(t=>new Request(t,{credentials:"same-origin"}))("/");self.addEventListener("install",i((async function(){console.info("cloudcmd: sw: install: "+u),await self.skipWaiting()}))),self.addEventListener("fetch",c((async function(t){const{request:e}=t,{url:n}=e,o=a(n),i=s(o,t.request),c=await caches.open(u),f=await c.match(e);if(f)return f;const[l,d]=await r(fetch,i,{credentials:"same-origin"});return l?new Response(l.message):(await async function(t,e){return(await caches.open(u)).put(t,e)}(e,d.clone()),d)}))),self.addEventListener("activate",i((async function(){console.info("cloudcmd: sw: activate: "+u),await self.clients.claim();const t=await caches.keys(),e=caches.delete.bind(caches);await Promise.all(t.map(e))})))},function(t,e,n){"use strict";t.exports=async(t,...e)=>{!function(t){if("function"!=typeof t)throw Error("fn should be a function!")}(t);try{return[null,await t(...e)]}catch(t){return[t]}}},function(t,e,n){"use strict";const r=(t,...e)=>{if(function(t){if("function"!=typeof t)throw Error("fn should be function!")}(t),e.length>=t.length)return t(...e);const n=(...n)=>r(t,...e,...n),o=t.length-e.length-1;return(t=>[function(e){return t(...arguments)},function(e,n){return t(...arguments)},function(e,n,r){return t(...arguments)},function(e,n,r,o){return t(...arguments)},function(e,n,r,o,i){return t(...arguments)}])(n)[o]||n};t.exports=r}]);
|
|
9
9
|
//# sourceMappingURL=sw.js.map
|
|
@@ -595,15 +595,15 @@ eval("var conversions = __webpack_require__(/*! ./conversions */ \"./node_module
|
|
|
595
595
|
|
|
596
596
|
/***/ }),
|
|
597
597
|
|
|
598
|
-
/***/ "./node_modules/compute-scroll-into-view/dist/index.
|
|
599
|
-
|
|
600
|
-
!*** ./node_modules/compute-scroll-into-view/dist/index.
|
|
601
|
-
|
|
598
|
+
/***/ "./node_modules/compute-scroll-into-view/dist/index.js":
|
|
599
|
+
/*!*************************************************************!*\
|
|
600
|
+
!*** ./node_modules/compute-scroll-into-view/dist/index.js ***!
|
|
601
|
+
\*************************************************************/
|
|
602
602
|
/*! exports provided: default */
|
|
603
|
-
/***/ (function(
|
|
603
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
604
604
|
|
|
605
605
|
"use strict";
|
|
606
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return
|
|
606
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return o; });\nlet e=e=>\"object\"==typeof e&&null!=e&&1===e.nodeType,t=(e,t)=>(!t||\"hidden\"!==e)&&(\"visible\"!==e&&\"clip\"!==e),n=(e,n)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){let l=getComputedStyle(e,null);return t(l.overflowY,n)||t(l.overflowX,n)||(e=>{let t=(e=>{if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}})(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)})(e)}return!1},l=(e,t,n,l,i,o,r,d)=>o<e&&r>t||o>e&&r<t?0:o<=e&&d<=n||r>=t&&d>=n?o-e-l:r>t&&d<n||o<e&&d>n?r-t+i:0,i=e=>{let t=e.parentElement;return null==t?e.getRootNode().host||null:t};var o=(t,o)=>{var r,d,h,f,u,s;if(\"undefined\"==typeof document)return[];let{scrollMode:a,block:c,inline:g,boundary:m,skipOverflowHiddenElements:p}=o,w=\"function\"==typeof m?m:e=>e!==m;if(!e(t))throw new TypeError(\"Invalid target\");let W=document.scrollingElement||document.documentElement,H=[],b=t;for(;e(b)&&w(b);){if(b=i(b),b===W){H.push(b);break}null!=b&&b===document.body&&n(b)&&!n(document.documentElement)||null!=b&&n(b,p)&&H.push(b)}let v=null!=(d=null==(r=window.visualViewport)?void 0:r.width)?d:innerWidth,y=null!=(f=null==(h=window.visualViewport)?void 0:h.height)?f:innerHeight,E=null!=(u=window.scrollX)?u:pageXOffset,M=null!=(s=window.scrollY)?s:pageYOffset,{height:x,width:I,top:C,right:R,bottom:T,left:V}=t.getBoundingClientRect(),k=\"start\"===c||\"nearest\"===c?C:\"end\"===c?T:C+x/2,B=\"center\"===g?V+I/2:\"end\"===g?R:V,D=[];for(let e=0;e<H.length;e++){let t=H[e],{height:n,width:i,top:o,right:r,bottom:d,left:h}=t.getBoundingClientRect();if(\"if-needed\"===a&&C>=0&&V>=0&&T<=y&&R<=v&&C>=o&&T<=d&&V>=h&&R<=r)return D;let f=getComputedStyle(t),u=parseInt(f.borderLeftWidth,10),s=parseInt(f.borderTopWidth,10),m=parseInt(f.borderRightWidth,10),p=parseInt(f.borderBottomWidth,10),w=0,b=0,O=\"offsetWidth\"in t?t.offsetWidth-t.clientWidth-u-m:0,X=\"offsetHeight\"in t?t.offsetHeight-t.clientHeight-s-p:0,Y=\"offsetWidth\"in t?0===t.offsetWidth?0:i/t.offsetWidth:0,L=\"offsetHeight\"in t?0===t.offsetHeight?0:n/t.offsetHeight:0;if(W===t)w=\"start\"===c?k:\"end\"===c?k-y:\"nearest\"===c?l(M,M+y,y,s,p,M+k,M+k+x,x):k-y/2,b=\"start\"===g?B:\"center\"===g?B-v/2:\"end\"===g?B-v:l(E,E+v,v,u,m,E+B,E+B+I,I),w=Math.max(0,w+M),b=Math.max(0,b+E);else{w=\"start\"===c?k-o-s:\"end\"===c?k-d+p+X:\"nearest\"===c?l(o,d,n,s,p+X,k,k+x,x):k-(o+n/2)+X/2,b=\"start\"===g?B-h-u:\"center\"===g?B-(h+i/2)+O/2:\"end\"===g?B-r+m+O:l(h,r,i,u,m+O,B,B+I,I);let{scrollLeft:e,scrollTop:f}=t;w=Math.max(0,Math.min(f+w/L,t.scrollHeight-n/L+X)),b=Math.max(0,Math.min(e+b/Y,t.scrollWidth-i/Y+O)),k+=f-w,B+=e-b}D.push({el:t,top:w,left:b})}return D};//# sourceMappingURL=index.js.map\n\n\n//# sourceURL=file://cloudcmd/node_modules/compute-scroll-into-view/dist/index.js");
|
|
607
607
|
|
|
608
608
|
/***/ }),
|
|
609
609
|
|
|
@@ -990,15 +990,15 @@ eval("\n\nconst constant = (a) => () => a;\n\n/**\n * render template with data\
|
|
|
990
990
|
|
|
991
991
|
/***/ }),
|
|
992
992
|
|
|
993
|
-
/***/ "./node_modules/scroll-into-view-if-needed/
|
|
994
|
-
|
|
995
|
-
!*** ./node_modules/scroll-into-view-if-needed/
|
|
996
|
-
|
|
993
|
+
/***/ "./node_modules/scroll-into-view-if-needed/dist/index.js":
|
|
994
|
+
/*!***************************************************************!*\
|
|
995
|
+
!*** ./node_modules/scroll-into-view-if-needed/dist/index.js ***!
|
|
996
|
+
\***************************************************************/
|
|
997
997
|
/*! exports provided: default */
|
|
998
998
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
999
999
|
|
|
1000
1000
|
"use strict";
|
|
1001
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var compute_scroll_into_view__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! compute-scroll-into-view */ \"./node_modules/compute-scroll-into-view/dist/index.
|
|
1001
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return o; });\n/* harmony import */ var compute_scroll_into_view__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! compute-scroll-into-view */ \"./node_modules/compute-scroll-into-view/dist/index.js\");\nlet t=e=>!1===e?{block:\"end\",inline:\"nearest\"}:(e=>e===Object(e)&&0!==Object.keys(e).length)(e)?e:{block:\"start\",inline:\"nearest\"};function o(o,l){let n=o.isConnected||o.ownerDocument.documentElement.contains(o);if((e=>\"object\"==typeof e&&\"function\"==typeof e.behavior)(l))return l.behavior(n?Object(compute_scroll_into_view__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(o,l):[]);if(!n)return;let r=t(l),c=Object(compute_scroll_into_view__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(o,r),i=\"scrollBehavior\"in document.body.style;c.forEach((e=>{let{el:t,top:o,left:l}=e;t.scroll&&i?t.scroll({top:o,left:l,behavior:r.behavior}):(t.scrollTop=o,t.scrollLeft=l)}))}//# sourceMappingURL=index.js.map\n\n\n//# sourceURL=file://cloudcmd/node_modules/scroll-into-view-if-needed/dist/index.js");
|
|
1002
1002
|
|
|
1003
1003
|
/***/ }),
|
|
1004
1004
|
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
/***/ (function(module, exports, __webpack_require__) {
|
|
164
164
|
|
|
165
165
|
"use strict";
|
|
166
|
-
eval("\n\n/* global DOM */\n__webpack_require__(/*! domtokenlist-shim */ \"./node_modules/domtokenlist-shim/dist/domtokenlist.js\");\nconst scrollIntoViewIfNeeded = __webpack_require__(/*! scroll-into-view-if-needed */ \"./node_modules/scroll-into-view-if-needed/
|
|
166
|
+
eval("\n\n/* global DOM */\n__webpack_require__(/*! domtokenlist-shim */ \"./node_modules/domtokenlist-shim/dist/domtokenlist.js\");\nconst scrollIntoViewIfNeeded = __webpack_require__(/*! scroll-into-view-if-needed */ \"./node_modules/scroll-into-view-if-needed/dist/index.js\").default;\nDOM.scrollIntoViewIfNeeded = el => scrollIntoViewIfNeeded(el, {\n block: 'nearest'\n});\n\n//# sourceURL=file://cloudcmd/client/modules/polyfill.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 = \"
|
|
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 Jan 18 2023 11:11:53 GMT+0200 (Eastern European Standard 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.
|
|
3
|
+
"version": "16.9.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"commitType": "colon",
|
|
6
6
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
@@ -166,7 +166,6 @@
|
|
|
166
166
|
"emitify": "^4.0.1",
|
|
167
167
|
"eslint": "^8.0.1",
|
|
168
168
|
"eslint-plugin-n": "^15.2.4",
|
|
169
|
-
"eslint-plugin-node": "^11.0.0",
|
|
170
169
|
"eslint-plugin-putout": "^16.0.0",
|
|
171
170
|
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
|
|
172
171
|
"gritty": "^7.0.0",
|
|
@@ -191,14 +190,14 @@
|
|
|
191
190
|
"readjson": "^2.0.1",
|
|
192
191
|
"request": "^2.76.0",
|
|
193
192
|
"rimraf": "^4.0.5",
|
|
194
|
-
"scroll-into-view-if-needed": "^
|
|
193
|
+
"scroll-into-view-if-needed": "^3.0.4",
|
|
195
194
|
"serve-once": "^2.0.0",
|
|
196
195
|
"serviceworker-webpack-plugin": "^1.0.1",
|
|
197
196
|
"smalltalk": "^4.0.0",
|
|
198
197
|
"style-loader": "^2.0.0",
|
|
199
198
|
"supermenu": "^4.0.1",
|
|
200
199
|
"supertape": "^8.1.0",
|
|
201
|
-
"tar-stream": "^
|
|
200
|
+
"tar-stream": "^3.0.0",
|
|
202
201
|
"unionfs": "^4.0.0",
|
|
203
202
|
"url-loader": "^4.0.0",
|
|
204
203
|
"webpack": "^4.0.0",
|
package/static/user-menu.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const RENAME_FILE = 'Rename file';
|
|
4
|
+
const CDN = 'https://cdn.jsdelivr.net/gh/cloudcmd/user-menu@1.1.1';
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
'__settings': {
|
|
@@ -12,13 +13,47 @@ module.exports = {
|
|
|
12
13
|
[`F2 - ${RENAME_FILE}`]: async ({DOM}) => {
|
|
13
14
|
await DOM.renameCurrent();
|
|
14
15
|
},
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
'F6 - Copy URL to current file': async ({DOM}) => {
|
|
18
|
+
const {copyURLToCurrentFile} = await import(`${CDN}/menu/copy-url-to-current-file.js`);
|
|
19
|
+
await copyURLToCurrentFile({DOM});
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
'R - cd /': async ({CloudCmd}) => {
|
|
23
|
+
await CloudCmd.changeDir('/');
|
|
24
|
+
},
|
|
25
|
+
'Y - Convert YouTube to MP3': async ({CloudCmd, DOM}) => {
|
|
26
|
+
const {convertYouTubeToMp3} = await import(`${CDN}/menu/convert-youtube-to-mp3.js`);
|
|
27
|
+
await convertYouTubeToMp3({CloudCmd, DOM});
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
'F - Convert flac to mp3 [ffmpeg]': async ({CloudCmd, DOM}) => {
|
|
31
|
+
const {convertFlacToMp3} = await import(`${CDN}/menu/ffmpeg.js`);
|
|
32
|
+
await convertFlacToMp3({CloudCmd, DOM});
|
|
33
|
+
},
|
|
34
|
+
'M - Convert mpeg to mp3 [ffmpeg]': async ({CloudCmd, DOM}) => {
|
|
35
|
+
const {convertMp4ToMp3} = await import(`${CDN}/menu/ffmpeg.js`);
|
|
36
|
+
await convertMp4ToMp3({CloudCmd, DOM});
|
|
37
|
+
},
|
|
38
|
+
|
|
16
39
|
'C - Create User Menu File': async ({DOM, CloudCmd}) => {
|
|
17
|
-
const {
|
|
40
|
+
const {
|
|
41
|
+
Dialog,
|
|
42
|
+
CurrentInfo,
|
|
43
|
+
} = DOM;
|
|
44
|
+
const currentFile = DOM.getCurrentByName('.cloudcmd.menu.js');
|
|
45
|
+
|
|
46
|
+
if (currentFile) {
|
|
47
|
+
const [cancel] = await Dialog.confirm(`Looks like file '.cloudcmd.menu.js' already exists. Overwrite?`);
|
|
48
|
+
|
|
49
|
+
if (cancel)
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
18
53
|
const {dirPath} = CurrentInfo;
|
|
19
54
|
const path = `${dirPath}.cloudcmd.menu.js`;
|
|
20
55
|
const {prefix} = CloudCmd;
|
|
21
|
-
|
|
56
|
+
|
|
22
57
|
const data = await readDefaultMenu({prefix});
|
|
23
58
|
await createDefaultMenu({
|
|
24
59
|
path,
|
|
@@ -34,25 +69,25 @@ module.exports = {
|
|
|
34
69
|
getCurrentByName,
|
|
35
70
|
selectFile,
|
|
36
71
|
} = DOM;
|
|
37
|
-
|
|
72
|
+
|
|
38
73
|
const {
|
|
39
74
|
files,
|
|
40
75
|
filesPassive,
|
|
41
76
|
panel,
|
|
42
77
|
panelPassive,
|
|
43
78
|
} = CurrentInfo;
|
|
44
|
-
|
|
79
|
+
|
|
45
80
|
const names = getFilenames(files);
|
|
46
81
|
const namesPassive = getFilenames(filesPassive);
|
|
47
|
-
|
|
82
|
+
|
|
48
83
|
const selectedNames = compare(names, namesPassive);
|
|
49
84
|
const selectedNamesPassive = compare(namesPassive, names);
|
|
50
|
-
|
|
85
|
+
|
|
51
86
|
selectNames(selectedNames, panel, {
|
|
52
87
|
selectFile,
|
|
53
88
|
getCurrentByName,
|
|
54
89
|
});
|
|
55
|
-
|
|
90
|
+
|
|
56
91
|
selectNames(selectedNamesPassive, panelPassive, {
|
|
57
92
|
selectFile,
|
|
58
93
|
getCurrentByName,
|
|
@@ -62,19 +97,19 @@ module.exports = {
|
|
|
62
97
|
|
|
63
98
|
async function createDefaultMenu({path, data, DOM, CloudCmd}) {
|
|
64
99
|
const {IO} = DOM;
|
|
65
|
-
|
|
100
|
+
|
|
66
101
|
await IO.write(path, data);
|
|
67
102
|
await CloudCmd.refresh();
|
|
68
|
-
|
|
103
|
+
|
|
69
104
|
DOM.setCurrentByName('.cloudcmd.menu.js');
|
|
70
|
-
|
|
105
|
+
|
|
71
106
|
await CloudCmd.EditFile.show();
|
|
72
107
|
}
|
|
73
108
|
|
|
74
109
|
async function readDefaultMenu({prefix}) {
|
|
75
110
|
const res = await fetch(`${prefix}/api/v1/user-menu/default`);
|
|
76
111
|
const data = await res.text();
|
|
77
|
-
|
|
112
|
+
|
|
78
113
|
return data;
|
|
79
114
|
}
|
|
80
115
|
|
|
@@ -89,14 +124,14 @@ function selectNames(names, panel, {selectFile, getCurrentByName}) {
|
|
|
89
124
|
module.exports._compare = compare;
|
|
90
125
|
function compare(a, b) {
|
|
91
126
|
const result = [];
|
|
92
|
-
|
|
127
|
+
|
|
93
128
|
for (const el of a) {
|
|
94
129
|
if (b.includes(el))
|
|
95
130
|
continue;
|
|
96
|
-
|
|
131
|
+
|
|
97
132
|
result.push(el);
|
|
98
133
|
}
|
|
99
|
-
|
|
134
|
+
|
|
100
135
|
return result;
|
|
101
136
|
}
|
|
102
137
|
|