cloudcmd 15.9.15 → 16.1.0
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 +25 -0
- package/HELP.md +4 -1
- package/README.md +1 -1
- package/common/cloudfunc.js +3 -7
- package/common/entity.js +1 -1
- package/dist/cloudcmd.common.js +3 -3
- package/dist/cloudcmd.common.js.map +1 -1
- package/dist/cloudcmd.js.map +1 -1
- package/dist/modules/operation.js +1 -1
- package/dist/modules/operation.js.map +1 -1
- package/dist/sw.js +1 -1
- package/dist/sw.js.map +1 -1
- package/dist-dev/cloudcmd.common.js +6 -6
- package/dist-dev/modules/operation.js +1 -1
- package/dist-dev/sw.js +1 -1
- package/package.json +11 -11
- package/server/server.js +5 -5
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=u(r);/\/$/.test(r)||/\^\/fs/.test(o)||"GET"===n.method&&(t=>"basic"===t.type)(n)&&(/^\/api/.test(o)||/^socket.io/.test(o)||e.respondWith(t(e)))}),u=t=>new URL(t).pathname,a="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=u(r);/\/$/.test(r)||/\^\/fs/.test(o)||"GET"===n.method&&(t=>"basic"===t.type)(n)&&(/^\/api/.test(o)||/^socket.io/.test(o)||e.respondWith(t(e)))}),u=t=>new URL(t).pathname,a="cloudcmd: Sat Apr 23 2022 01:35:16 GMT+0300 (Eastern European Summer Time)",s=(t,e)=>"/"!==t?e:(t=>new Request(t,{credentials:"same-origin"}))("/");self.addEventListener("install",i((async function(){console.info("cloudcmd: sw: install: "+a),await self.skipWaiting()}))),self.addEventListener("fetch",c((async function(t){const{request:e}=t,{url:n}=e,o=u(n),i=s(o,t.request),c=await caches.open(a),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(a)).put(t,e)}(e,d.clone()),d)}))),self.addEventListener("activate",i((async function(){console.info("cloudcmd: sw: activate: "+a),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
|
package/dist/sw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["file://cloudcmd/webpack/bootstrap","file://cloudcmd/client/sw/sw.js","file://cloudcmd/node_modules/try-to-catch/lib/try-to-catch.js","file://cloudcmd/node_modules/currify/lib/currify.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","tryToCatch","require","currify","wait","f","e","waitUntil","respondWith","request","url","pathname","getPathName","test","method","a","type","isBasic","URL","NAME","getRequest","Request","credentials","createRequest","self","addEventListener","async","console","info","skipWaiting","event","newRequest","cache","caches","open","response","match","resp","fetch","Response","message","put","addToCache","clone","clients","claim","keys","deleteCache","delete","Promise","all","map","fn","args","Error","check","length","again","args2","count","arguments","b"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE,GAA4B,iBAATF,EAAmB,IAAI,IAAIM,KAAON,EAAOrB,EAAoBU,EAAEe,EAAIE,EAAK,SAASA,GAAO,OAAON,EAAMM,IAAQC,KAAK,KAAMD,IAC9I,OAAOF,GAIRzB,EAAoB6B,EAAI,SAAS1B,GAChC,IAAIS,EAAST,GAAUA,EAAOqB,WAC7B,WAAwB,OAAOrB,EAAgB,SAC/C,WAA8B,OAAOA,GAEtC,OADAH,EAAoBU,EAAEE,EAAQ,IAAKA,GAC5BA,GAIRZ,EAAoBa,EAAI,SAASiB,EAAQC,GAAY,OAAOjB,OAAOkB,UAAUC,eAAe1B,KAAKuB,EAAQC,IAGzG/B,EAAoBkC,EAAI,SAIjBlC,EAAoBA,EAAoBmC,EAAI,G,+BC/ErD,MAAMC,EAAaC,EAAQ,GACrBC,EAAUD,EAAQ,GAOlBE,EAAOD,EAAQ,CAACE,EAAGC,IAAMA,EAAEC,UAAUF,MACrCG,EAAcL,EAAQ,CAACE,EAAGC,KAC5B,MAAM,QAACG,GAAWH,GACZ,IAACI,GAAOD,EACRE,EAAWC,EAAYF,GAEzB,MAAMG,KAAKH,IAAQ,SAASG,KAAKF,IATP,QAYnBF,EAZQK,QACNC,IAAiB,UAAXA,EAAEC,KAchBC,CAAQR,KAGT,SAASI,KAAKF,IAGd,aAAaE,KAAKF,IAGtBL,EAAEE,YAAYH,EAAEC,OAGdM,EAAeF,GAAQ,IAAIQ,IAAIR,GAAKC,SAGpCQ,EAAQ,+EAMRC,EAAa,CAACL,EAAGN,IACT,MAANM,EACON,EANQM,IAAM,IAAIM,QAAQN,EAAG,CACxCO,YAAa,gBAONC,CAAc,KAGzBC,KAAKC,iBAAiB,UAAWrB,GAcjCsB,iBACIC,QAAQC,KAAM,0BAAyBT,SAEjCK,KAAKK,kBAhBfL,KAAKC,iBAAiB,QAASjB,GAmB/BkB,eAAuBI,GACnB,MAAM,QAACrB,GAAWqB,GACZ,IAACpB,GAAOD,EACRE,EAAWC,EAAYF,GACvBqB,EAAaX,EAAWT,EAAUmB,EAAMrB,SAExCuB,QAAcC,OAAOC,KAAKf,GAC1BgB,QAAiBH,EAAMI,MAAM3B,GAEnC,GAAc0B,EACV,OAAOA,EAEX,MAAO7B,EAAG+B,SAAcpC,EAAWqC,MAAOP,EAAY,CAClDT,YAAa,gBAGjB,OAAIhB,EACO,IAAIiC,SAASjC,EAAEkC,gBAO9Bd,eAA0BjB,EAAS0B,GAE/B,aADoBF,OAAOC,KAAKf,IACnBsB,IAAIhC,EAAS0B,GAPpBO,CAAWjC,EAAS4B,EAAKM,SAExBN,OAvCXb,KAAKC,iBAAiB,WAAYrB,GAElCsB,iBACIC,QAAQC,KAAM,2BAA0BT,SAElCK,KAAKoB,QAAQC,QACnB,MAAMC,QAAab,OAAOa,OACpBC,EAAcd,OAAOe,OAAOvD,KAAKwC,cAEjCgB,QAAQC,IAAIJ,EAAKK,IAAIJ,S,6BC5D/B/E,EAAOD,QAAU2D,MAAO0B,KAAOC,MAU/B,SAAeD,GACX,GAAkB,mBAAPA,EACP,MAAME,MAAM,4BAXhBC,CAAMH,GAEN,IACI,MAAO,CAAC,WAAYA,KAAMC,IAC5B,MAAM/C,GACJ,MAAO,CAACA,M,6BCNhB,MASMH,EAAU,CAACiD,KAAOC,KAGpB,GAeJ,SAAeD,GACX,GAAkB,mBAAPA,EACP,MAAME,MAAM,0BAnBhBC,CAAMH,GAEFC,EAAKG,QAAUJ,EAAGI,OAClB,OAAOJ,KAAMC,GAEjB,MAAMI,EAAQ,IAAIC,IACPvD,EAAQiD,KAAWC,KAASK,GAGjCC,EAAQP,EAAGI,OAASH,EAAKG,OAAS,EAGxC,MAtBM,CAACJ,GAAO,CAEd,SAAUrC,GAAI,OAAOqC,KAAMQ,YAC3B,SAAU7C,EAAG8C,GAAI,OAAOT,KAAMQ,YAC9B,SAAU7C,EAAG8C,EAAGvF,GAAI,OAAO8E,KAAMQ,YACjC,SAAU7C,EAAG8C,EAAGvF,EAAGC,GAAI,OAAO6E,KAAMQ,YACpC,SAAU7C,EAAG8C,EAAGvF,EAAGC,EAAG+B,GAAI,OAAO8C,KAAMQ,aAc1BvD,CAAEoD,GAAOE,IAEPF,GAGnBzF,EAAOD,QAAUoC","file":"sw.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/dist/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","'use strict';\n\nconst codegen = require('codegen.macro');\nconst tryToCatch = require('try-to-catch');\nconst currify = require('currify');\n\nconst isDev = process.env.NODE_ENV === 'development';\n\nconst isGet = (a) => a.method === 'GET';\nconst isBasic = (a) => a.type === 'basic';\n\nconst wait = currify((f, e) => e.waitUntil(f()));\nconst respondWith = currify((f, e) => {\n const {request} = e;\n const {url} = request;\n const pathname = getPathName(url);\n \n if (/\\/$/.test(url) || /\\^\\/fs/.test(pathname))\n return;\n \n if (!isGet(request))\n return;\n \n if (!isBasic(request))\n return;\n \n if (/^\\/api/.test(pathname))\n return;\n \n if (/^socket.io/.test(pathname))\n return;\n \n e.respondWith(f(e));\n});\n\nconst getPathName = (url) => new URL(url).pathname;\n\nconst date = codegen`module.exports = '\"' + Date() + '\"'`;\nconst NAME = `cloudcmd: ${date}`;\n\nconst createRequest = (a) => new Request(a, {\n credentials: 'same-origin',\n});\n\nconst getRequest = (a, request) => {\n if (a !== '/')\n return request;\n \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 \n await self.clients.claim();\n const keys = await caches.keys();\n const deleteCache = caches.delete.bind(caches);\n \n await Promise.all(keys.map(deleteCache));\n}\n\nasync function onInstall() {\n console.info(`cloudcmd: sw: install: ${NAME}`);\n \n await self.skipWaiting();\n}\n\nasync function onFetch(event) {\n const {request} = event;\n const {url} = request;\n const pathname = getPathName(url);\n const newRequest = getRequest(pathname, event.request);\n \n const cache = await caches.open(NAME);\n const response = await cache.match(request);\n \n if (!isDev && response)\n return response;\n \n const [e, resp] = await tryToCatch(fetch, newRequest, {\n credentials: 'same-origin',\n });\n \n if (e)\n return new Response(e.message);\n \n await addToCache(request, resp.clone());\n \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","'use strict';\n\nmodule.exports = async (fn, ...args) => {\n check(fn);\n \n try {\n return [null, await fn(...args)];\n } catch(e) {\n return [e];\n }\n};\n\nfunction check(fn) {\n if (typeof fn !== 'function')\n throw Error('fn should be a function!');\n}\n\n","'use strict';\n\nconst f = (fn) => [\n /*eslint no-unused-vars: 0*/\n function (a) {return fn(...arguments);},\n function (a, b) {return fn(...arguments);},\n function (a, b, c) {return fn(...arguments);},\n function (a, b, c, d) {return fn(...arguments);},\n function (a, b, c, d, e) {return fn(...arguments);},\n];\n\nconst currify = (fn, ...args) => {\n check(fn);\n \n if (args.length >= fn.length)\n return fn(...args);\n \n const again = (...args2) => {\n return currify(fn, ...[...args, ...args2]);\n };\n \n const count = fn.length - args.length - 1;\n const func = f(again)[count];\n \n return func || again;\n};\n\nmodule.exports = currify;\n\nfunction check(fn) {\n if (typeof fn !== 'function')\n throw Error('fn should be function!');\n}\n\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["file://cloudcmd/webpack/bootstrap","file://cloudcmd/client/sw/sw.js","file://cloudcmd/node_modules/try-to-catch/lib/try-to-catch.js","file://cloudcmd/node_modules/currify/lib/currify.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","tryToCatch","require","currify","wait","f","e","waitUntil","respondWith","request","url","pathname","getPathName","test","method","a","type","isBasic","URL","NAME","getRequest","Request","credentials","createRequest","self","addEventListener","async","console","info","skipWaiting","event","newRequest","cache","caches","open","response","match","resp","fetch","Response","message","put","addToCache","clone","clients","claim","keys","deleteCache","delete","Promise","all","map","fn","args","Error","check","length","again","args2","count","arguments","b"],"mappings":"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","file":"sw.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/dist/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","'use strict';\n\nconst codegen = require('codegen.macro');\nconst tryToCatch = require('try-to-catch');\nconst currify = require('currify');\n\nconst isDev = process.env.NODE_ENV === 'development';\n\nconst isGet = (a) => a.method === 'GET';\nconst isBasic = (a) => a.type === 'basic';\n\nconst wait = currify((f, e) => e.waitUntil(f()));\nconst respondWith = currify((f, e) => {\n const {request} = e;\n const {url} = request;\n const pathname = getPathName(url);\n \n if (/\\/$/.test(url) || /\\^\\/fs/.test(pathname))\n return;\n \n if (!isGet(request))\n return;\n \n if (!isBasic(request))\n return;\n \n if (/^\\/api/.test(pathname))\n return;\n \n if (/^socket.io/.test(pathname))\n return;\n \n e.respondWith(f(e));\n});\n\nconst getPathName = (url) => new URL(url).pathname;\n\nconst date = codegen`module.exports = '\"' + Date() + '\"'`;\nconst NAME = `cloudcmd: ${date}`;\n\nconst createRequest = (a) => new Request(a, {\n credentials: 'same-origin',\n});\n\nconst getRequest = (a, request) => {\n if (a !== '/')\n return request;\n \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 \n await self.clients.claim();\n const keys = await caches.keys();\n const deleteCache = caches.delete.bind(caches);\n \n await Promise.all(keys.map(deleteCache));\n}\n\nasync function onInstall() {\n console.info(`cloudcmd: sw: install: ${NAME}`);\n \n await self.skipWaiting();\n}\n\nasync function onFetch(event) {\n const {request} = event;\n const {url} = request;\n const pathname = getPathName(url);\n const newRequest = getRequest(pathname, event.request);\n \n const cache = await caches.open(NAME);\n const response = await cache.match(request);\n \n if (!isDev && response)\n return response;\n \n const [e, resp] = await tryToCatch(fetch, newRequest, {\n credentials: 'same-origin',\n });\n \n if (e)\n return new Response(e.message);\n \n await addToCache(request, resp.clone());\n \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","'use strict';\n\nmodule.exports = async (fn, ...args) => {\n check(fn);\n \n try {\n return [null, await fn(...args)];\n } catch(e) {\n return [e];\n }\n};\n\nfunction check(fn) {\n if (typeof fn !== 'function')\n throw Error('fn should be a function!');\n}\n\n","'use strict';\n\nconst f = (fn) => [\n /*eslint no-unused-vars: 0*/\n function (a) {return fn(...arguments);},\n function (a, b) {return fn(...arguments);},\n function (a, b, c) {return fn(...arguments);},\n function (a, b, c, d) {return fn(...arguments);},\n function (a, b, c, d, e) {return fn(...arguments);},\n];\n\nconst currify = (fn, ...args) => {\n check(fn);\n \n if (args.length >= fn.length)\n return fn(...args);\n \n const again = (...args2) => {\n return currify(fn, ...[...args, ...args2]);\n };\n \n const count = fn.length - args.length - 1;\n const func = f(again)[count];\n \n return func || again;\n};\n\nmodule.exports = currify;\n\nfunction check(fn) {\n if (typeof fn !== 'function')\n throw Error('fn should be function!');\n}\n\n"],"sourceRoot":""}
|
|
@@ -20,7 +20,7 @@ eval("\n/* global CloudCmd */\n\nconst tryToPromiseAll = __webpack_require__(/*!
|
|
|
20
20
|
/***/ (function(module, exports, __webpack_require__) {
|
|
21
21
|
|
|
22
22
|
"use strict";
|
|
23
|
-
eval("
|
|
23
|
+
eval("\n/* global DOM */\n\n/* global CloudCmd */\n\nconst {\n atob,\n btoa\n} = __webpack_require__(/*! ../../common/base64 */ \"./common/base64.js\");\n\nconst createElement = __webpack_require__(/*! @cloudcmd/create-element */ \"./node_modules/@cloudcmd/create-element/lib/create-element.js\");\n\nconst {\n encode,\n decode\n} = __webpack_require__(/*! ../../common/entity */ \"./common/entity.js\");\n\nconst {\n getTitle,\n FS\n} = __webpack_require__(/*! ../../common/cloudfunc */ \"./common/cloudfunc.js\");\n\nlet Title;\nconst CURRENT_FILE = 'current-file';\n\nconst encodeNBSP = a => a === null || a === void 0 ? void 0 : a.replace('\\xa0', ' ');\n\nconst decodeNBSP = a => a === null || a === void 0 ? void 0 : a.replace(' ', '\\xa0');\n\nmodule.exports._CURRENT_FILE = CURRENT_FILE;\n/**\n * set name from current (or param) file\n *\n * @param name\n * @param current\n */\n\nmodule.exports.setCurrentName = (name, current) => {\n const Info = DOM.CurrentInfo;\n const {\n link\n } = Info;\n const {\n prefix\n } = CloudCmd;\n const dir = prefix + FS + Info.dirPath;\n const encoded = encode(name);\n link.title = encoded;\n link.href = dir + encoded;\n link.innerHTML = encoded;\n current.setAttribute('data-name', createNameAttribute(name));\n CloudCmd.emit('current-file', current);\n return link;\n};\n/**\n * get name from current (or param) file\n *\n * @param currentFile\n */\n\n\nmodule.exports.getCurrentName = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n if (!current) return '';\n return parseNameAttribute(current.getAttribute('data-name'));\n};\n/**\n * Generate a `data-name` attribute for the given filename\n * @param name The string name to encode\n */\n\n\nconst createNameAttribute = name => {\n const encoded = btoa(encodeURI(name));\n return `js-file-${encoded}`;\n};\n/**\n * Parse a `data-name` attribute string back into the original filename\n * @param attribute The string we wish to decode\n */\n\n\nconst parseNameAttribute = attribute => {\n attribute = attribute.replace('js-file-', '');\n return decodeNBSP(decodeURI(atob(attribute)));\n};\n\nmodule.exports._parseNameAttribute = parseNameAttribute;\n\nconst parseHrefAttribute = (prefix, attribute) => {\n attribute = attribute.replace(RegExp('^' + prefix + FS), '');\n return decode(decodeNBSP(attribute));\n};\n\nmodule.exports._parseHrefAttribute = parseHrefAttribute;\n/**\n * get current direcotory path\n */\n\nmodule.exports.getCurrentDirPath = function () {\n let panel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DOM.getPanel();\n const path = DOM.getByDataName('js-path', panel);\n return path.textContent;\n};\n/**\n * get link from current (or param) file\n *\n * @param currentFile - current file by default\n */\n\n\nmodule.exports.getCurrentPath = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const [element] = DOM.getByTag('a', current);\n const {\n prefix\n } = CloudCmd;\n return parseHrefAttribute(prefix, element.getAttribute('href'));\n};\n/**\n * get current direcotory name\n */\n\n\nmodule.exports.getCurrentDirName = () => {\n const href = DOM.getCurrentDirPath().replace(/\\/$/, '');\n const substr = href.substr(href, href.lastIndexOf('/'));\n const ret = href.replace(substr + '/', '') || '/';\n return ret;\n};\n/**\n * get current direcotory path\n */\n\n\nmodule.exports.getParentDirPath = panel => {\n const path = DOM.getCurrentDirPath(panel);\n const dirName = DOM.getCurrentDirName() + '/';\n const index = path.lastIndexOf(dirName);\n if (path === '/') return path;\n return path.slice(0, index);\n};\n/**\n * get not current direcotory path\n */\n\n\nmodule.exports.getNotCurrentDirPath = () => {\n const panel = DOM.getPanel({\n active: false\n });\n return DOM.getCurrentDirPath(panel);\n};\n/**\n * unified way to get current file\n *\n * @currentFile\n */\n\n\nmodule.exports.getCurrentFile = () => {\n return DOM.getByClass(CURRENT_FILE);\n};\n/**\n * get current file by name\n */\n\n\nmodule.exports.getCurrentByName = function (name) {\n let panel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DOM.CurrentInfo.panel;\n const dataName = 'js-file-' + btoa(encodeURI(encodeNBSP(name)));\n return DOM.getByDataName(dataName, panel);\n};\n/**\n * private function thet unset currentfile\n *\n * @currentFile\n */\n\n\nfunction unsetCurrentFile(currentFile) {\n const is = DOM.isCurrentFile(currentFile);\n if (!is) return;\n currentFile.classList.remove(CURRENT_FILE);\n}\n/**\n * unified way to set current file\n */\n\n\nmodule.exports.setCurrentFile = (currentFile, options) => {\n const o = options;\n const currentFileWas = DOM.getCurrentFile();\n if (!currentFile) return DOM;\n let pathWas = '';\n\n if (currentFileWas) {\n pathWas = DOM.getCurrentDirPath();\n unsetCurrentFile(currentFileWas);\n }\n\n currentFile.classList.add(CURRENT_FILE);\n const path = DOM.getCurrentDirPath();\n const name = CloudCmd.config('name');\n\n if (path !== pathWas) {\n DOM.setTitle(getTitle({\n name,\n path\n }));\n /* history could be present\n * but it should be false\n * to prevent default behavior\n */\n\n if (!o || o.history) {\n const historyPath = path === '/' ? path : FS + path;\n DOM.setHistory(historyPath, null, historyPath);\n }\n }\n /* scrolling to current file */\n\n\n const CENTER = true;\n DOM.scrollIntoViewIfNeeded(currentFile, CENTER);\n CloudCmd.emit('current-file', currentFile);\n CloudCmd.emit('current-path', path);\n CloudCmd.emit('current-name', DOM.getCurrentName(currentFile));\n return DOM;\n};\n\nthis.setCurrentByName = name => {\n const current = DOM.getCurrentByName(name);\n return DOM.setCurrentFile(current);\n};\n/*\n * set current file by position\n *\n * @param layer - element\n * @param - position {x, y}\n */\n\n\nmodule.exports.getCurrentByPosition = _ref => {\n let {\n x,\n y\n } = _ref;\n const element = document.elementFromPoint(x, y);\n\n const getEl = el => {\n const {\n tagName\n } = el;\n const isChild = /A|SPAN|LI/.test(tagName);\n if (!isChild) return null;\n if (tagName === 'A') return el.parentElement.parentElement;\n if (tagName === 'SPAN') return el.parentElement;\n return el;\n };\n\n const el = getEl(element);\n if (el && el.tagName !== 'LI') return null;\n return el;\n};\n/**\n * current file check\n *\n * @param currentFile\n */\n\n\nmodule.exports.isCurrentFile = currentFile => {\n if (!currentFile) return false;\n return DOM.isContainClass(currentFile, CURRENT_FILE);\n};\n/**\n * set title or create title element\n *\n * @param name\n */\n\n\nmodule.exports.setTitle = name => {\n if (!Title) Title = DOM.getByTag('title')[0] || createElement('title', {\n innerHTML: name,\n parent: document.head\n });\n Title.textContent = name;\n return DOM;\n};\n/**\n * check is current file is a directory\n *\n * @param currentFile\n */\n\n\nmodule.exports.isCurrentIsDir = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const path = DOM.getCurrentPath(current);\n const fileType = DOM.getCurrentType(current);\n const isZip = /\\.zip$/.test(path);\n const isDir = /^directory(-link)?/.test(fileType);\n return isDir || isZip;\n};\n\nmodule.exports.getCurrentType = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const el = DOM.getByDataName('js-type', current);\n const type = el.className.split(' ').pop();\n return type;\n};\n\n//# sourceURL=file://cloudcmd/client/dom/current-file.js");
|
|
24
24
|
|
|
25
25
|
/***/ }),
|
|
26
26
|
|
|
@@ -116,7 +116,7 @@ eval("/* global DOM */\n\n\nconst createElement = __webpack_require__(/*! @cloud
|
|
|
116
116
|
/***/ (function(module, exports, __webpack_require__) {
|
|
117
117
|
|
|
118
118
|
"use strict";
|
|
119
|
-
eval("\n/* global CloudCmd */\n\nconst Util = __webpack_require__(/*! ../../common/util */ \"./common/util.js\");\n\nconst Images = __webpack_require__(/*! ./images */ \"./client/dom/images.js\");\n\nconst load = __webpack_require__(/*! ./load */ \"./client/dom/load.js\");\n\nconst Files = __webpack_require__(/*! ./files */ \"./client/dom/files.js\");\n\nconst RESTful = __webpack_require__(/*! ./rest */ \"./client/dom/rest.js\");\n\nconst IO = __webpack_require__(/*! ./io */ \"./client/dom/io/index.js\");\n\nconst Storage = __webpack_require__(/*! ./storage */ \"./client/dom/storage.js\");\n\nconst Dialog = __webpack_require__(/*! ./dialog */ \"./client/dom/dialog.js\");\n\nconst renameCurrent = __webpack_require__(/*! ./operations/rename-current */ \"./client/dom/operations/rename-current.js\");\n\nconst CurrentFile = __webpack_require__(/*! ./current-file */ \"./client/dom/current-file.js\");\n\nconst DOMTree = __webpack_require__(/*! ./dom-tree */ \"./client/dom/dom-tree.js\");\n\nconst Cmd = module.exports;\nconst DOM = { ...DOMTree,\n ...CurrentFile,\n ...Cmd\n};\nconst CurrentInfo = {};\nDOM.Images = Images;\nDOM.load = load;\nDOM.Files = Files;\nDOM.RESTful = RESTful;\nDOM.IO = IO;\nDOM.Storage = Storage;\nDOM.Dialog = Dialog;\nDOM.CurrentInfo = CurrentInfo;\nmodule.exports = DOM;\nDOM.uploadDirectory = __webpack_require__(/*! ./directory */ \"./client/dom/directory.js\");\nDOM.Buffer = __webpack_require__(/*! ./buffer */ \"./client/dom/buffer.js\");\nDOM.Events = __webpack_require__(/*! ./events */ \"./client/dom/events/index.js\");\n\nconst loadRemote = __webpack_require__(/*! ./load-remote */ \"./client/dom/load-remote.js\");\n\nconst selectByPattern = __webpack_require__(/*! ./select-by-pattern */ \"./client/dom/select-by-pattern.js\");\n\nconst SELECTED_FILE = 'selected-file';\nconst TabPanel = {\n 'js-left': null,\n 'js-right': null\n};\n\nmodule.exports.loadRemote = (name, options, callback) => {\n loadRemote(name, options, callback);\n return DOM;\n};\n\nmodule.exports.loadSocket = callback => {\n DOM.loadRemote('socket', {\n name: 'io'\n }, callback);\n return DOM;\n};\n/**\n * create new folder\n *\n */\n\n\nmodule.exports.promptNewDir = async function () {\n await promptNew('directory');\n};\n/**\n * create new file\n *\n * @typeName\n * @type\n */\n\n\nmodule.exports.promptNewFile = async () => {\n await promptNew('file');\n};\n\nasync function promptNew(typeName) {\n const {\n Dialog\n } = DOM;\n const dir = DOM.getCurrentDirPath();\n const msg = 'New ' + typeName || false;\n\n const getName = () => {\n const name = DOM.getCurrentName();\n if (name === '..') return '';\n return name;\n };\n\n const name = getName();\n const [cancel, currentName] = await Dialog.prompt(msg, name);\n if (cancel) return;\n const path = `${dir}${currentName}`;\n if (typeName === 'directory') await RESTful.createDirectory(path);else await RESTful.write(path);\n await CloudCmd.refresh({\n currentName\n });\n}\n/**\n * get current direcotory name\n */\n\n\nmodule.exports.getCurrentDirName = () => {\n const href = DOM.getCurrentDirPath().replace(/\\/$/, '');\n const substr = href.substr(href, href.lastIndexOf('/'));\n const ret = href.replace(substr + '/', '') || '/';\n return ret;\n};\n/**\n * get current direcotory path\n */\n\n\nmodule.exports.getParentDirPath = panel => {\n const path = DOM.getCurrentDirPath(panel);\n const dirName = DOM.getCurrentDirName() + '/';\n const index = path.lastIndexOf(dirName);\n if (path !== '/') return path.slice(0, index);\n return path;\n};\n/**\n * get not current direcotory path\n */\n\n\nmodule.exports.getNotCurrentDirPath = () => {\n const panel = DOM.getPanel({\n active: false\n });\n const path = DOM.getCurrentDirPath(panel);\n return path;\n};\n/**\n * get current file by name\n */\n\n\nmodule.exports.getCurrentByName = function (name) {\n let panel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CurrentInfo.panel;\n const dataName = 'js-file-' + btoa(encodeURI(name));\n const element = DOM.getByDataName(dataName, panel);\n return element;\n};\n/**\n * unified way to get selected files\n *\n * @currentFile\n */\n\n\nmodule.exports.getSelectedFiles = () => {\n const panel = DOM.getPanel();\n const selected = DOM.getByClassAll(SELECTED_FILE, panel);\n return Array.from(selected);\n};\n/*\n * unselect all files\n */\n\n\nmodule.exports.unselectFiles = files => {\n files = files || DOM.getSelectedFiles();\n Array.from(files).forEach(DOM.toggleSelectedFile);\n};\n/**\n * get all selected files or current when none selected\n *\n * @currentFile\n */\n\n\nmodule.exports.getActiveFiles = () => {\n const current = DOM.getCurrentFile();\n const files = DOM.getSelectedFiles();\n const name = DOM.getCurrentName(current);\n if (!files.length && name !== '..') return [current];\n return files;\n};\n\nmodule.exports.getCurrentDate = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const date = DOM.getByDataName('js-date', current).textContent;\n return date;\n};\n/**\n * get size\n * @currentFile\n */\n\n\nmodule.exports.getCurrentSize = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n /* если это папка - возвращаем слово dir вместо размера*/\n\n const size = DOM.getByDataName('js-size', current).textContent.replace(/^<|>$/g, '');\n return size;\n};\n/**\n * get size\n * @currentFile\n */\n\n\nmodule.exports.loadCurrentSize = async currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const query = '?size';\n const link = DOM.getCurrentPath(current);\n Images.show.load();\n if (name === '..') return;\n const [, size] = await RESTful.read(link + query);\n DOM.setCurrentSize(size, current);\n Images.hide();\n return current;\n};\n/**\n * load hash\n * @callback\n * @currentFile\n */\n\n\nmodule.exports.loadCurrentHash = async currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const query = '?hash';\n const link = DOM.getCurrentPath(current);\n const [, data] = await RESTful.read(link + query);\n return data;\n};\n/**\n * set size\n * @currentFile\n */\n\n\nmodule.exports.setCurrentSize = (size, currentFile) => {\n const current = currentFile || DOM.getCurrentFile();\n const sizeElement = DOM.getByDataName('js-size', current);\n sizeElement.textContent = size;\n};\n/**\n * @currentFile\n */\n\n\nmodule.exports.getCurrentMode = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const mode = DOM.getByDataName('js-mode', current);\n return mode.textContent;\n};\n/**\n * @currentFile\n */\n\n\nmodule.exports.getCurrentOwner = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const owner = DOM.getByDataName('js-owner', current);\n return owner.textContent;\n};\n/**\n * unified way to get current file content\n *\n * @param currentFile\n */\n\n\nmodule.exports.getCurrentData = async currentFile => {\n const {\n Dialog\n } = DOM;\n const Info = DOM.CurrentInfo;\n const current = currentFile || DOM.getCurrentFile();\n const path = DOM.getCurrentPath(current);\n const isDir = DOM.isCurrentIsDir(current);\n\n if (Info.name === '..') {\n Dialog.alert.noFiles();\n return [Error('No Files')];\n }\n\n if (isDir) return await RESTful.read(path);\n const [hashNew, hash] = await DOM.checkStorageHash(path);\n if (!hashNew) return [Error(`Can't get hash of a file`)];\n if (hash === hashNew) return [null, await Storage.get(`${path}-data`)];\n const [e, data] = await RESTful.read(path);\n if (e) return [e, null];\n const ONE_MEGABYTE = 1024 * 1024 * 1024;\n const {\n length\n } = data;\n if (hash && length < ONE_MEGABYTE) await DOM.saveDataToStorage(path, data, hashNew);\n return [null, data];\n};\n/**\n * unified way to get RefreshButton\n */\n\n\nmodule.exports.getRefreshButton = function () {\n let panel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DOM.getPanel();\n return DOM.getByDataName('js-refresh', panel);\n};\n/**\n * select current file\n * @param currentFile\n */\n\n\nmodule.exports.selectFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n current.classList.add(SELECTED_FILE);\n return Cmd;\n};\n\nmodule.exports.unselectFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n current.classList.remove(SELECTED_FILE);\n return Cmd;\n};\n\nmodule.exports.toggleSelectedFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const name = DOM.getCurrentName(current);\n if (name === '..') return Cmd;\n current.classList.toggle(SELECTED_FILE);\n return Cmd;\n};\n\nmodule.exports.toggleAllSelectedFiles = () => {\n DOM.getAllFiles().map(DOM.toggleSelectedFile);\n return Cmd;\n};\n\nmodule.exports.selectAllFiles = () => {\n DOM.getAllFiles().map(DOM.selectFile);\n return Cmd;\n};\n\nmodule.exports.getAllFiles = () => {\n const panel = DOM.getPanel();\n const files = DOM.getFiles(panel);\n const name = DOM.getCurrentName(files[0]);\n\n const from = a => a === '..' ? 1 : 0;\n\n const i = from(name);\n return Array.from(files).slice(i);\n};\n/**\n * open dialog with expand selection\n */\n\n\nmodule.exports.expandSelection = () => {\n const msg = 'expand';\n const {\n files\n } = CurrentInfo;\n selectByPattern(msg, files);\n};\n/**\n * open dialog with shrink selection\n */\n\n\nmodule.exports.shrinkSelection = () => {\n const msg = 'shrink';\n const {\n files\n } = CurrentInfo;\n selectByPattern(msg, files);\n};\n/**\n * setting history wrapper\n */\n\n\nmodule.exports.setHistory = (data, title, url) => {\n const ret = window.history;\n const {\n prefix\n } = CloudCmd;\n url = prefix + url;\n if (ret) history.pushState(data, title, url);\n return ret;\n};\n/**\n * selected file check\n *\n * @param currentFile\n */\n\n\nmodule.exports.isSelected = selected => {\n if (!selected) return false;\n return DOM.isContainClass(selected, SELECTED_FILE);\n};\n/**\n * get link from current (or param) file\n *\n * @param currentFile - current file by default\n */\n\n\nmodule.exports.getCurrentLink = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const link = DOM.getByTag('a', current);\n return link[0];\n};\n\nmodule.exports.getFilenames = files => {\n if (!files) throw Error('AllFiles could not be empty');\n const first = files[0] || DOM.getCurrentFile();\n const name = DOM.getCurrentName(first);\n const allFiles = Array.from(files);\n if (name === '..') allFiles.shift();\n const names = allFiles.map(current => {\n return DOM.getCurrentName(current);\n });\n return names;\n};\n/**\n * check storage hash\n */\n\n\nmodule.exports.checkStorageHash = async name => {\n const nameHash = name + '-hash';\n if (typeof name !== 'string') throw Error('name should be a string!');\n const [loadHash, storeHash] = await Promise.all([DOM.loadCurrentHash(), Storage.get(nameHash)]);\n return [loadHash, storeHash];\n};\n/**\n * save data to storage\n *\n * @param name\n * @param data\n * @param hash\n * @param callback\n */\n\n\nmodule.exports.saveDataToStorage = async (name, data, hash) => {\n const isDir = DOM.isCurrentIsDir();\n if (isDir) return;\n hash = hash || (await DOM.loadCurrentHash());\n const nameHash = name + '-hash';\n const nameData = name + '-data';\n await Storage.set(nameHash, hash);\n await Storage.set(nameData, data);\n return hash;\n};\n\nmodule.exports.getFM = () => DOM.getPanel().parentElement;\n\nmodule.exports.getPanelPosition = panel => {\n panel = panel || DOM.getPanel();\n return panel.dataset.name.replace('js-', '');\n};\n/** function getting panel active, or passive\n * @param options = {active: true}\n */\n\n\nmodule.exports.getPanel = options => {\n let files;\n let panel;\n let isLeft;\n let dataName = 'js-';\n const current = DOM.getCurrentFile();\n\n if (!current) {\n panel = DOM.getByDataName('js-left');\n } else {\n files = current.parentElement;\n panel = files.parentElement;\n isLeft = panel.getAttribute('data-name') === 'js-left';\n }\n /* if {active : false} getting passive panel */\n\n\n if (options && !options.active) {\n dataName += isLeft ? 'right' : 'left';\n panel = DOM.getByDataName(dataName);\n }\n /* if two panels showed\n * then always work with passive\n * panel\n */\n\n\n if (window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH) panel = DOM.getByDataName('js-left');\n if (!panel) throw Error('can not find Active Panel!');\n return panel;\n};\n\nmodule.exports.getFiles = element => {\n const files = DOM.getByDataName('js-files', element);\n return files.children || [];\n};\n/**\n * shows panel right or left (or active)\n */\n\n\nmodule.exports.showPanel = active => {\n const panel = DOM.getPanel({\n active\n });\n if (!panel) return false;\n DOM.show(panel);\n return true;\n};\n/**\n * hides panel right or left (or active)\n */\n\n\nmodule.exports.hidePanel = active => {\n const panel = DOM.getPanel({\n active\n });\n if (!panel) return false;\n return DOM.hide(panel);\n};\n/**\n * remove child of element\n * @param pChild\n * @param element\n */\n\n\nmodule.exports.remove = (child, element) => {\n const parent = element || document.body;\n parent.removeChild(child);\n return DOM;\n};\n/**\n * remove current file from file table\n * @param current\n *\n */\n\n\nmodule.exports.deleteCurrent = current => {\n if (!current) DOM.getCurrentFile();\n const parent = current === null || current === void 0 ? void 0 : current.parentElement;\n const name = DOM.getCurrentName(current);\n\n if (current && name !== '..') {\n const next = current.nextSibling;\n const prev = current.previousSibling;\n DOM.setCurrentFile(next || prev);\n parent.removeChild(current);\n }\n};\n/**\n * remove selected files from file table\n * @Selected\n */\n\n\nmodule.exports.deleteSelected = selected => {\n selected = selected || DOM.getSelectedFiles();\n if (!selected) return;\n selected.map(DOM.deleteCurrent);\n};\n/**\n * rename current file\n *\n * @currentFile\n */\n\n\nmodule.exports.renameCurrent = renameCurrent;\n/**\n * unified way to scrollIntoViewIfNeeded\n * (native suporte by webkit only)\n * @param element\n * @param center - to scroll as small as possible param should be false\n */\n\nmodule.exports.scrollIntoViewIfNeeded = function (element) {\n let center = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n if (!element || !element.scrollIntoViewIfNeeded) return;\n element.scrollIntoViewIfNeeded(center);\n};\n/* scroll on one page */\n\n\nmodule.exports.scrollByPages = (element, pPages) => {\n const ret = (element === null || element === void 0 ? void 0 : element.scrollByPages) && pPages;\n if (ret) element.scrollByPages(pPages);\n return ret;\n};\n\nmodule.exports.changePanel = () => {\n const Info = CurrentInfo;\n let panel = DOM.getPanel();\n CloudCmd.emit('passive-dir', Info.dirPath);\n const panelPassive = DOM.getPanel({\n active: false\n });\n let name = DOM.getCurrentName();\n const filesPassive = DOM.getFiles(panelPassive);\n let dataName = panel.getAttribute('data-name');\n TabPanel[dataName] = name;\n panel = panelPassive;\n dataName = panel.getAttribute('data-name');\n name = TabPanel[dataName];\n let files;\n let current;\n\n if (name) {\n current = DOM.getCurrentByName(name, panel);\n if (current) files = current.parentElement;\n }\n\n if (!files || !files.parentElement) {\n current = DOM.getCurrentByName(name, panel);\n if (!current) [current] = filesPassive;\n }\n\n DOM.setCurrentFile(current, {\n history: true\n });\n CloudCmd.emit('active-dir', Info.dirPath);\n return DOM;\n};\n\nmodule.exports.getPackerExt = type => {\n if (type === 'zip') return '.zip';\n return '.tar.gz';\n};\n\nmodule.exports.goToDirectory = async () => {\n const msg = 'Go to directory:';\n const {\n Dialog\n } = DOM;\n const {\n dirPath\n } = CurrentInfo;\n const [cancel, path = dirPath] = await Dialog.prompt(msg, dirPath);\n if (cancel) return;\n await CloudCmd.loadDir({\n path\n });\n};\n\nmodule.exports.duplicatePanel = async () => {\n const Info = CurrentInfo;\n const {\n isDir\n } = Info;\n const panel = Info.panelPassive;\n const noCurrent = !Info.isOnePanel;\n\n const getPath = isDir => {\n if (isDir) return Info.path;\n return Info.dirPath;\n };\n\n const path = getPath(isDir);\n await CloudCmd.loadDir({\n path,\n panel,\n noCurrent\n });\n};\n\nmodule.exports.swapPanels = async () => {\n const Info = CurrentInfo;\n const {\n panel,\n files,\n element,\n panelPassive\n } = Info;\n const path = DOM.getCurrentDirPath();\n const dirPathPassive = DOM.getNotCurrentDirPath();\n let currentIndex = files.indexOf(element);\n await CloudCmd.loadDir({\n path,\n panel: panelPassive,\n noCurrent: true\n });\n await CloudCmd.loadDir({\n path: dirPathPassive,\n panel\n });\n const length = Info.files.length - 1;\n if (currentIndex > length) currentIndex = length;\n const el = Info.files[currentIndex];\n DOM.setCurrentFile(el);\n};\n\nmodule.exports.CurrentInfo = CurrentInfo;\n\nmodule.exports.updateCurrentInfo = currentFile => {\n const info = DOM.CurrentInfo;\n const current = currentFile || DOM.getCurrentFile();\n const files = current.parentElement;\n const panel = files.parentElement || DOM.getPanel();\n const panelPassive = DOM.getPanel({\n active: false\n });\n const filesPassive = DOM.getFiles(panelPassive);\n const name = DOM.getCurrentName(current);\n info.dir = DOM.getCurrentDirName();\n info.dirPath = DOM.getCurrentDirPath();\n info.parentDirPath = DOM.getParentDirPath();\n info.element = current;\n info.ext = Util.getExt(name);\n info.files = Array.from(files.children);\n info.filesPassive = Array.from(filesPassive);\n info.first = files.firstChild;\n info.getData = DOM.getCurrentData;\n info.last = files.lastChild;\n info.link = DOM.getCurrentLink(current);\n info.mode = DOM.getCurrentMode(current);\n info.name = name;\n info.path = DOM.getCurrentPath(current);\n info.panel = panel;\n info.panelPassive = panelPassive;\n info.size = DOM.getCurrentSize(current);\n info.isDir = DOM.isCurrentIsDir();\n info.isSelected = DOM.isSelected(current);\n info.panelPosition = DOM.getPanel().dataset.name.replace('js-', '');\n info.isOnePanel = info.panel.getAttribute('data-name') === info.panelPassive.getAttribute('data-name');\n};\n\n//# sourceURL=file://cloudcmd/client/dom/index.js");
|
|
119
|
+
eval("\n/* global CloudCmd */\n\nconst Util = __webpack_require__(/*! ../../common/util */ \"./common/util.js\");\n\nconst Images = __webpack_require__(/*! ./images */ \"./client/dom/images.js\");\n\nconst load = __webpack_require__(/*! ./load */ \"./client/dom/load.js\");\n\nconst Files = __webpack_require__(/*! ./files */ \"./client/dom/files.js\");\n\nconst RESTful = __webpack_require__(/*! ./rest */ \"./client/dom/rest.js\");\n\nconst IO = __webpack_require__(/*! ./io */ \"./client/dom/io/index.js\");\n\nconst Storage = __webpack_require__(/*! ./storage */ \"./client/dom/storage.js\");\n\nconst Dialog = __webpack_require__(/*! ./dialog */ \"./client/dom/dialog.js\");\n\nconst renameCurrent = __webpack_require__(/*! ./operations/rename-current */ \"./client/dom/operations/rename-current.js\");\n\nconst CurrentFile = __webpack_require__(/*! ./current-file */ \"./client/dom/current-file.js\");\n\nconst DOMTree = __webpack_require__(/*! ./dom-tree */ \"./client/dom/dom-tree.js\");\n\nconst Cmd = module.exports;\nconst DOM = { ...DOMTree,\n ...CurrentFile,\n ...Cmd\n};\nconst CurrentInfo = {};\nDOM.Images = Images;\nDOM.load = load;\nDOM.Files = Files;\nDOM.RESTful = RESTful;\nDOM.IO = IO;\nDOM.Storage = Storage;\nDOM.Dialog = Dialog;\nDOM.CurrentInfo = CurrentInfo;\nmodule.exports = DOM;\nDOM.uploadDirectory = __webpack_require__(/*! ./directory */ \"./client/dom/directory.js\");\nDOM.Buffer = __webpack_require__(/*! ./buffer */ \"./client/dom/buffer.js\");\nDOM.Events = __webpack_require__(/*! ./events */ \"./client/dom/events/index.js\");\n\nconst loadRemote = __webpack_require__(/*! ./load-remote */ \"./client/dom/load-remote.js\");\n\nconst selectByPattern = __webpack_require__(/*! ./select-by-pattern */ \"./client/dom/select-by-pattern.js\");\n\nconst SELECTED_FILE = 'selected-file';\nconst TabPanel = {\n 'js-left': null,\n 'js-right': null\n};\n\nmodule.exports.loadRemote = (name, options, callback) => {\n loadRemote(name, options, callback);\n return DOM;\n};\n\nmodule.exports.loadSocket = callback => {\n DOM.loadRemote('socket', {\n name: 'io'\n }, callback);\n return DOM;\n};\n/**\n * create new folder\n *\n */\n\n\nmodule.exports.promptNewDir = async function () {\n await promptNew('directory');\n};\n/**\n * create new file\n *\n * @typeName\n * @type\n */\n\n\nmodule.exports.promptNewFile = async () => {\n await promptNew('file');\n};\n\nasync function promptNew(typeName) {\n const {\n Dialog\n } = DOM;\n const dir = DOM.getCurrentDirPath();\n const msg = 'New ' + typeName || false;\n\n const getName = () => {\n const name = DOM.getCurrentName();\n if (name === '..') return '';\n return name;\n };\n\n const name = getName();\n const [cancel, currentName] = await Dialog.prompt(msg, name);\n if (cancel) return;\n const path = `${dir}${currentName}`;\n if (typeName === 'directory') await RESTful.createDirectory(path);else await RESTful.write(path);\n await CloudCmd.refresh({\n currentName\n });\n}\n/**\n * get current direcotory name\n */\n\n\nmodule.exports.getCurrentDirName = () => {\n const href = DOM.getCurrentDirPath().replace(/\\/$/, '');\n const substr = href.substr(href, href.lastIndexOf('/'));\n const ret = href.replace(substr + '/', '') || '/';\n return ret;\n};\n/**\n * get current direcotory path\n */\n\n\nmodule.exports.getParentDirPath = panel => {\n const path = DOM.getCurrentDirPath(panel);\n const dirName = DOM.getCurrentDirName() + '/';\n const index = path.lastIndexOf(dirName);\n if (path !== '/') return path.slice(0, index);\n return path;\n};\n/**\n * get not current direcotory path\n */\n\n\nmodule.exports.getNotCurrentDirPath = () => {\n const panel = DOM.getPanel({\n active: false\n });\n const path = DOM.getCurrentDirPath(panel);\n return path;\n};\n/**\n * unified way to get selected files\n *\n * @currentFile\n */\n\n\nmodule.exports.getSelectedFiles = () => {\n const panel = DOM.getPanel();\n const selected = DOM.getByClassAll(SELECTED_FILE, panel);\n return Array.from(selected);\n};\n/*\n * unselect all files\n */\n\n\nmodule.exports.unselectFiles = files => {\n files = files || DOM.getSelectedFiles();\n Array.from(files).forEach(DOM.toggleSelectedFile);\n};\n/**\n * get all selected files or current when none selected\n *\n * @currentFile\n */\n\n\nmodule.exports.getActiveFiles = () => {\n const current = DOM.getCurrentFile();\n const files = DOM.getSelectedFiles();\n const name = DOM.getCurrentName(current);\n if (!files.length && name !== '..') return [current];\n return files;\n};\n\nmodule.exports.getCurrentDate = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const date = DOM.getByDataName('js-date', current).textContent;\n return date;\n};\n/**\n * get size\n * @currentFile\n */\n\n\nmodule.exports.getCurrentSize = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n /* если это папка - возвращаем слово dir вместо размера*/\n\n const size = DOM.getByDataName('js-size', current).textContent.replace(/^<|>$/g, '');\n return size;\n};\n/**\n * get size\n * @currentFile\n */\n\n\nmodule.exports.loadCurrentSize = async currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const query = '?size';\n const link = DOM.getCurrentPath(current);\n Images.show.load();\n if (name === '..') return;\n const [, size] = await RESTful.read(link + query);\n DOM.setCurrentSize(size, current);\n Images.hide();\n return current;\n};\n/**\n * load hash\n * @callback\n * @currentFile\n */\n\n\nmodule.exports.loadCurrentHash = async currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const query = '?hash';\n const link = DOM.getCurrentPath(current);\n const [, data] = await RESTful.read(link + query);\n return data;\n};\n/**\n * set size\n * @currentFile\n */\n\n\nmodule.exports.setCurrentSize = (size, currentFile) => {\n const current = currentFile || DOM.getCurrentFile();\n const sizeElement = DOM.getByDataName('js-size', current);\n sizeElement.textContent = size;\n};\n/**\n * @currentFile\n */\n\n\nmodule.exports.getCurrentMode = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const mode = DOM.getByDataName('js-mode', current);\n return mode.textContent;\n};\n/**\n * @currentFile\n */\n\n\nmodule.exports.getCurrentOwner = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const owner = DOM.getByDataName('js-owner', current);\n return owner.textContent;\n};\n/**\n * unified way to get current file content\n *\n * @param currentFile\n */\n\n\nmodule.exports.getCurrentData = async currentFile => {\n const {\n Dialog\n } = DOM;\n const Info = DOM.CurrentInfo;\n const current = currentFile || DOM.getCurrentFile();\n const path = DOM.getCurrentPath(current);\n const isDir = DOM.isCurrentIsDir(current);\n\n if (Info.name === '..') {\n Dialog.alert.noFiles();\n return [Error('No Files')];\n }\n\n if (isDir) return await RESTful.read(path);\n const [hashNew, hash] = await DOM.checkStorageHash(path);\n if (!hashNew) return [Error(`Can't get hash of a file`)];\n if (hash === hashNew) return [null, await Storage.get(`${path}-data`)];\n const [e, data] = await RESTful.read(path);\n if (e) return [e, null];\n const ONE_MEGABYTE = 1024 * 1024 * 1024;\n const {\n length\n } = data;\n if (hash && length < ONE_MEGABYTE) await DOM.saveDataToStorage(path, data, hashNew);\n return [null, data];\n};\n/**\n * unified way to get RefreshButton\n */\n\n\nmodule.exports.getRefreshButton = function () {\n let panel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DOM.getPanel();\n return DOM.getByDataName('js-refresh', panel);\n};\n/**\n * select current file\n * @param currentFile\n */\n\n\nmodule.exports.selectFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n current.classList.add(SELECTED_FILE);\n return Cmd;\n};\n\nmodule.exports.unselectFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n current.classList.remove(SELECTED_FILE);\n return Cmd;\n};\n\nmodule.exports.toggleSelectedFile = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const name = DOM.getCurrentName(current);\n if (name === '..') return Cmd;\n current.classList.toggle(SELECTED_FILE);\n return Cmd;\n};\n\nmodule.exports.toggleAllSelectedFiles = () => {\n DOM.getAllFiles().map(DOM.toggleSelectedFile);\n return Cmd;\n};\n\nmodule.exports.selectAllFiles = () => {\n DOM.getAllFiles().map(DOM.selectFile);\n return Cmd;\n};\n\nmodule.exports.getAllFiles = () => {\n const panel = DOM.getPanel();\n const files = DOM.getFiles(panel);\n const name = DOM.getCurrentName(files[0]);\n\n const from = a => a === '..' ? 1 : 0;\n\n const i = from(name);\n return Array.from(files).slice(i);\n};\n/**\n * open dialog with expand selection\n */\n\n\nmodule.exports.expandSelection = () => {\n const msg = 'expand';\n const {\n files\n } = CurrentInfo;\n selectByPattern(msg, files);\n};\n/**\n * open dialog with shrink selection\n */\n\n\nmodule.exports.shrinkSelection = () => {\n const msg = 'shrink';\n const {\n files\n } = CurrentInfo;\n selectByPattern(msg, files);\n};\n/**\n * setting history wrapper\n */\n\n\nmodule.exports.setHistory = (data, title, url) => {\n const ret = window.history;\n const {\n prefix\n } = CloudCmd;\n url = prefix + url;\n if (ret) history.pushState(data, title, url);\n return ret;\n};\n/**\n * selected file check\n *\n * @param currentFile\n */\n\n\nmodule.exports.isSelected = selected => {\n if (!selected) return false;\n return DOM.isContainClass(selected, SELECTED_FILE);\n};\n/**\n * get link from current (or param) file\n *\n * @param currentFile - current file by default\n */\n\n\nmodule.exports.getCurrentLink = currentFile => {\n const current = currentFile || DOM.getCurrentFile();\n const link = DOM.getByTag('a', current);\n return link[0];\n};\n\nmodule.exports.getFilenames = files => {\n if (!files) throw Error('AllFiles could not be empty');\n const first = files[0] || DOM.getCurrentFile();\n const name = DOM.getCurrentName(first);\n const allFiles = Array.from(files);\n if (name === '..') allFiles.shift();\n const names = allFiles.map(current => {\n return DOM.getCurrentName(current);\n });\n return names;\n};\n/**\n * check storage hash\n */\n\n\nmodule.exports.checkStorageHash = async name => {\n const nameHash = name + '-hash';\n if (typeof name !== 'string') throw Error('name should be a string!');\n const [loadHash, storeHash] = await Promise.all([DOM.loadCurrentHash(), Storage.get(nameHash)]);\n return [loadHash, storeHash];\n};\n/**\n * save data to storage\n *\n * @param name\n * @param data\n * @param hash\n * @param callback\n */\n\n\nmodule.exports.saveDataToStorage = async (name, data, hash) => {\n const isDir = DOM.isCurrentIsDir();\n if (isDir) return;\n hash = hash || (await DOM.loadCurrentHash());\n const nameHash = name + '-hash';\n const nameData = name + '-data';\n await Storage.set(nameHash, hash);\n await Storage.set(nameData, data);\n return hash;\n};\n\nmodule.exports.getFM = () => DOM.getPanel().parentElement;\n\nmodule.exports.getPanelPosition = panel => {\n panel = panel || DOM.getPanel();\n return panel.dataset.name.replace('js-', '');\n};\n/** function getting panel active, or passive\n * @param options = {active: true}\n */\n\n\nmodule.exports.getPanel = options => {\n let files;\n let panel;\n let isLeft;\n let dataName = 'js-';\n const current = DOM.getCurrentFile();\n\n if (!current) {\n panel = DOM.getByDataName('js-left');\n } else {\n files = current.parentElement;\n panel = files.parentElement;\n isLeft = panel.getAttribute('data-name') === 'js-left';\n }\n /* if {active : false} getting passive panel */\n\n\n if (options && !options.active) {\n dataName += isLeft ? 'right' : 'left';\n panel = DOM.getByDataName(dataName);\n }\n /* if two panels showed\n * then always work with passive\n * panel\n */\n\n\n if (window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH) panel = DOM.getByDataName('js-left');\n if (!panel) throw Error('can not find Active Panel!');\n return panel;\n};\n\nmodule.exports.getFiles = element => {\n const files = DOM.getByDataName('js-files', element);\n return files.children || [];\n};\n/**\n * shows panel right or left (or active)\n */\n\n\nmodule.exports.showPanel = active => {\n const panel = DOM.getPanel({\n active\n });\n if (!panel) return false;\n DOM.show(panel);\n return true;\n};\n/**\n * hides panel right or left (or active)\n */\n\n\nmodule.exports.hidePanel = active => {\n const panel = DOM.getPanel({\n active\n });\n if (!panel) return false;\n return DOM.hide(panel);\n};\n/**\n * remove child of element\n * @param pChild\n * @param element\n */\n\n\nmodule.exports.remove = (child, element) => {\n const parent = element || document.body;\n parent.removeChild(child);\n return DOM;\n};\n/**\n * remove current file from file table\n * @param current\n *\n */\n\n\nmodule.exports.deleteCurrent = current => {\n if (!current) DOM.getCurrentFile();\n const parent = current === null || current === void 0 ? void 0 : current.parentElement;\n const name = DOM.getCurrentName(current);\n\n if (current && name !== '..') {\n const next = current.nextSibling;\n const prev = current.previousSibling;\n DOM.setCurrentFile(next || prev);\n parent.removeChild(current);\n }\n};\n/**\n * remove selected files from file table\n * @Selected\n */\n\n\nmodule.exports.deleteSelected = selected => {\n selected = selected || DOM.getSelectedFiles();\n if (!selected) return;\n selected.map(DOM.deleteCurrent);\n};\n/**\n * rename current file\n *\n * @currentFile\n */\n\n\nmodule.exports.renameCurrent = renameCurrent;\n/**\n * unified way to scrollIntoViewIfNeeded\n * (native suporte by webkit only)\n * @param element\n * @param center - to scroll as small as possible param should be false\n */\n\nmodule.exports.scrollIntoViewIfNeeded = function (element) {\n let center = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n if (!element || !element.scrollIntoViewIfNeeded) return;\n element.scrollIntoViewIfNeeded(center);\n};\n/* scroll on one page */\n\n\nmodule.exports.scrollByPages = (element, pPages) => {\n const ret = (element === null || element === void 0 ? void 0 : element.scrollByPages) && pPages;\n if (ret) element.scrollByPages(pPages);\n return ret;\n};\n\nmodule.exports.changePanel = () => {\n const Info = CurrentInfo;\n let panel = DOM.getPanel();\n CloudCmd.emit('passive-dir', Info.dirPath);\n const panelPassive = DOM.getPanel({\n active: false\n });\n let name = DOM.getCurrentName();\n const filesPassive = DOM.getFiles(panelPassive);\n let dataName = panel.getAttribute('data-name');\n TabPanel[dataName] = name;\n panel = panelPassive;\n dataName = panel.getAttribute('data-name');\n name = TabPanel[dataName];\n let files;\n let current;\n\n if (name) {\n current = DOM.getCurrentByName(name, panel);\n if (current) files = current.parentElement;\n }\n\n if (!files || !files.parentElement) {\n current = DOM.getCurrentByName(name, panel);\n if (!current) [current] = filesPassive;\n }\n\n DOM.setCurrentFile(current, {\n history: true\n });\n CloudCmd.emit('active-dir', Info.dirPath);\n return DOM;\n};\n\nmodule.exports.getPackerExt = type => {\n if (type === 'zip') return '.zip';\n return '.tar.gz';\n};\n\nmodule.exports.goToDirectory = async () => {\n const msg = 'Go to directory:';\n const {\n Dialog\n } = DOM;\n const {\n dirPath\n } = CurrentInfo;\n const [cancel, path = dirPath] = await Dialog.prompt(msg, dirPath);\n if (cancel) return;\n await CloudCmd.loadDir({\n path\n });\n};\n\nmodule.exports.duplicatePanel = async () => {\n const Info = CurrentInfo;\n const {\n isDir\n } = Info;\n const panel = Info.panelPassive;\n const noCurrent = !Info.isOnePanel;\n\n const getPath = isDir => {\n if (isDir) return Info.path;\n return Info.dirPath;\n };\n\n const path = getPath(isDir);\n await CloudCmd.loadDir({\n path,\n panel,\n noCurrent\n });\n};\n\nmodule.exports.swapPanels = async () => {\n const Info = CurrentInfo;\n const {\n panel,\n files,\n element,\n panelPassive\n } = Info;\n const path = DOM.getCurrentDirPath();\n const dirPathPassive = DOM.getNotCurrentDirPath();\n let currentIndex = files.indexOf(element);\n await CloudCmd.loadDir({\n path,\n panel: panelPassive,\n noCurrent: true\n });\n await CloudCmd.loadDir({\n path: dirPathPassive,\n panel\n });\n const length = Info.files.length - 1;\n if (currentIndex > length) currentIndex = length;\n const el = Info.files[currentIndex];\n DOM.setCurrentFile(el);\n};\n\nmodule.exports.CurrentInfo = CurrentInfo;\n\nmodule.exports.updateCurrentInfo = currentFile => {\n const info = DOM.CurrentInfo;\n const current = currentFile || DOM.getCurrentFile();\n const files = current.parentElement;\n const panel = files.parentElement || DOM.getPanel();\n const panelPassive = DOM.getPanel({\n active: false\n });\n const filesPassive = DOM.getFiles(panelPassive);\n const name = DOM.getCurrentName(current);\n info.dir = DOM.getCurrentDirName();\n info.dirPath = DOM.getCurrentDirPath();\n info.parentDirPath = DOM.getParentDirPath();\n info.element = current;\n info.ext = Util.getExt(name);\n info.files = Array.from(files.children);\n info.filesPassive = Array.from(filesPassive);\n info.first = files.firstChild;\n info.getData = DOM.getCurrentData;\n info.last = files.lastChild;\n info.link = DOM.getCurrentLink(current);\n info.mode = DOM.getCurrentMode(current);\n info.name = name;\n info.path = DOM.getCurrentPath(current);\n info.panel = panel;\n info.panelPassive = panelPassive;\n info.size = DOM.getCurrentSize(current);\n info.isDir = DOM.isCurrentIsDir();\n info.isSelected = DOM.isSelected(current);\n info.panelPosition = DOM.getPanel().dataset.name.replace('js-', '');\n info.isOnePanel = info.panel.getAttribute('data-name') === info.panelPassive.getAttribute('data-name');\n};\n\n//# sourceURL=file://cloudcmd/client/dom/index.js");
|
|
120
120
|
|
|
121
121
|
/***/ }),
|
|
122
122
|
|
|
@@ -260,7 +260,7 @@ eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\n\nmodule.exports.btoa = st
|
|
|
260
260
|
/***/ (function(module, exports, __webpack_require__) {
|
|
261
261
|
|
|
262
262
|
"use strict";
|
|
263
|
-
eval("\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 store = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n\nconst {\n encode\n} = __webpack_require__(/*! ./entity */ \"./common/entity.js\");\n\nconst {\n btoa\n} = __webpack_require__(/*! ./base64 */ \"./common/base64.js\");\n\nconst getHeaderField = currify(_getHeaderField);\n/* КОНСТАНТЫ (общие для клиента и сервера)*/\n\n/* название программы */\n\nconst NAME = 'Cloud Commander';\nconst FS = '/fs';\nconst Path = store();\nPath('/');\nmodule.exports.FS = FS;\nmodule.exports.apiURL = '/api/v1';\nmodule.exports.MAX_FILE_SIZE = 500 * 1024;\nmodule.exports.getHeaderField = getHeaderField;\nmodule.exports.getPathLink = getPathLink;\nmodule.exports.getDotDot = getDotDot;\n\nmodule.exports.formatMsg = (msg, name, status) => {\n status = status || 'ok';\n name = name || '';\n if (name) name = '(\"' + name + '\")';\n return msg + ': ' + status + name;\n};\n/**\n * Функция возвращает заголовок веб страницы\n * @path\n */\n\n\nmodule.exports.getTitle = options => {\n options = options || {};\n const {\n path = Path(),\n name\n } = options;\n const array = [name || NAME, path];\n return array.filter(Boolean).join(' - ');\n};\n/** Функция получает адреса каждого каталога в пути\n * возвращаеться массив каталогов\n * @param url - адрес каталога\n */\n\n\nfunction getPathLink(url, prefix, template) {\n if (!url) throw Error('url could not be empty!');\n if (!template) throw Error('template could not be empty!');\n const names = url.split('/').slice(1, -1);\n const allNames = ['/', ...names];\n const lines = [];\n const n = allNames.length;\n let path = '/';\n\n for (let i = 0; i < n; i++) {\n const name = allNames[i];\n const isLast = i === n - 1;\n if (i) path += name + '/';\n\n if (i && isLast) {\n lines.push(name + '/');\n continue;\n }\n\n const slash = i ? '/' : '';\n lines.push(rendy(template, {\n path,\n name,\n slash,\n prefix\n }));\n }\n\n return lines.join('');\n}\n\nconst getDataName = name => {\n const encoded = btoa(encodeURI(name));\n return `data-name=\"js-file-${encoded}\" `;\n};\n/**\n * Функция строит таблицу файлв из JSON-информации о файлах\n * @param params - информация о файлах\n *\n */\n\n\nmodule.exports.buildFromJSON = params => {\n const {\n prefix,\n template,\n sort = 'name',\n order = 'asc'\n } = params;\n const templateFile = template.file;\n const templateLink = template.link;\n const json = params.data;\n const path = encode(json.path);\n const {\n files\n } = json;\n /*\n * Строим путь каталога в котором мы находимся\n * со всеми подкаталогами\n */\n\n const htmlPath = getPathLink(path, prefix, template.pathLink);\n let fileTable = rendy(template.path, {\n link: prefix + FS + path,\n fullPath: path,\n path: htmlPath\n });\n const owner = 'owner';\n const mode = 'mode';\n const getFieldName = getHeaderField(sort, order);\n const name = getFieldName('name');\n const size = getFieldName('size');\n const date = getFieldName('date');\n const header = rendy(templateFile, {\n tag: 'div',\n attribute: 'data-name=\"js-fm-header\" ',\n className: 'fm-header',\n type: '',\n name,\n size,\n date,\n owner,\n mode\n });\n /* сохраняем путь */\n\n Path(path);\n fileTable += header + '<ul data-name=\"js-files\" class=\"files\">';\n /* Если мы не в корне */\n\n if (path !== '/') {\n const dotDot = getDotDot(path);\n const link = prefix + FS + dotDot;\n const linkResult = rendy(template.link, {\n link,\n title: '..',\n name: '..'\n });\n const dataName = getDataName('..');\n const attribute = 'draggable=\"true\" ' + dataName;\n /* Сохраняем путь к каталогу верхнего уровня*/\n\n fileTable += rendy(template.file, {\n tag: 'li',\n attribute,\n className: '',\n type: 'directory',\n name: linkResult,\n size: '<dir>',\n date: '--.--.----',\n owner: '.',\n mode: '--- --- ---'\n });\n }\n\n fileTable += files.map(updateField).map(file => {\n const name = encode(file.name);\n const link = prefix + FS + path + name;\n const {\n type,\n mode,\n date,\n owner,\n size\n } = file;\n const linkResult = rendy(templateLink, {\n link,\n title: name,\n name,\n attribute: getAttribute(file.type)\n });\n const dataName = getDataName(file.name);\n const attribute = `draggable=\"true\" ${dataName}`;\n return rendy(templateFile, {\n tag: 'li',\n attribute,\n className: '',\n type,\n name: linkResult,\n size,\n date,\n owner,\n mode\n });\n }).join('');\n fileTable += '</ul>';\n return fileTable;\n};\n\nfunction updateField(file) {\n return { ...file,\n date: file.date || '--.--.----',\n owner: file.owner || 'root',\n size: getSize(file)\n };\n}\n\nfunction getAttribute(type) {\n if (type === 'directory') return '';\n return 'target=\"_blank\" ';\n}\n\nmodule.exports._getSize = getSize;\n\nfunction getSize(
|
|
263
|
+
eval("\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 store = __webpack_require__(/*! fullstore */ \"./node_modules/fullstore/lib/fullstore.js\");\n\nconst {\n encode\n} = __webpack_require__(/*! ./entity */ \"./common/entity.js\");\n\nconst {\n btoa\n} = __webpack_require__(/*! ./base64 */ \"./common/base64.js\");\n\nconst getHeaderField = currify(_getHeaderField);\n/* КОНСТАНТЫ (общие для клиента и сервера)*/\n\n/* название программы */\n\nconst NAME = 'Cloud Commander';\nconst FS = '/fs';\nconst Path = store();\nPath('/');\nmodule.exports.FS = FS;\nmodule.exports.apiURL = '/api/v1';\nmodule.exports.MAX_FILE_SIZE = 500 * 1024;\nmodule.exports.getHeaderField = getHeaderField;\nmodule.exports.getPathLink = getPathLink;\nmodule.exports.getDotDot = getDotDot;\n\nmodule.exports.formatMsg = (msg, name, status) => {\n status = status || 'ok';\n name = name || '';\n if (name) name = '(\"' + name + '\")';\n return msg + ': ' + status + name;\n};\n/**\n * Функция возвращает заголовок веб страницы\n * @path\n */\n\n\nmodule.exports.getTitle = options => {\n options = options || {};\n const {\n path = Path(),\n name\n } = options;\n const array = [name || NAME, path];\n return array.filter(Boolean).join(' - ');\n};\n/** Функция получает адреса каждого каталога в пути\n * возвращаеться массив каталогов\n * @param url - адрес каталога\n */\n\n\nfunction getPathLink(url, prefix, template) {\n if (!url) throw Error('url could not be empty!');\n if (!template) throw Error('template could not be empty!');\n const names = url.split('/').slice(1, -1);\n const allNames = ['/', ...names];\n const lines = [];\n const n = allNames.length;\n let path = '/';\n\n for (let i = 0; i < n; i++) {\n const name = allNames[i];\n const isLast = i === n - 1;\n if (i) path += name + '/';\n\n if (i && isLast) {\n lines.push(name + '/');\n continue;\n }\n\n const slash = i ? '/' : '';\n lines.push(rendy(template, {\n path,\n name,\n slash,\n prefix\n }));\n }\n\n return lines.join('');\n}\n\nconst getDataName = name => {\n const encoded = btoa(encodeURI(name));\n return `data-name=\"js-file-${encoded}\" `;\n};\n/**\n * Функция строит таблицу файлв из JSON-информации о файлах\n * @param params - информация о файлах\n *\n */\n\n\nmodule.exports.buildFromJSON = params => {\n const {\n prefix,\n template,\n sort = 'name',\n order = 'asc'\n } = params;\n const templateFile = template.file;\n const templateLink = template.link;\n const json = params.data;\n const path = encode(json.path);\n const {\n files\n } = json;\n /*\n * Строим путь каталога в котором мы находимся\n * со всеми подкаталогами\n */\n\n const htmlPath = getPathLink(path, prefix, template.pathLink);\n let fileTable = rendy(template.path, {\n link: prefix + FS + path,\n fullPath: path,\n path: htmlPath\n });\n const owner = 'owner';\n const mode = 'mode';\n const getFieldName = getHeaderField(sort, order);\n const name = getFieldName('name');\n const size = getFieldName('size');\n const date = getFieldName('date');\n const header = rendy(templateFile, {\n tag: 'div',\n attribute: 'data-name=\"js-fm-header\" ',\n className: 'fm-header',\n type: '',\n name,\n size,\n date,\n owner,\n mode\n });\n /* сохраняем путь */\n\n Path(path);\n fileTable += header + '<ul data-name=\"js-files\" class=\"files\">';\n /* Если мы не в корне */\n\n if (path !== '/') {\n const dotDot = getDotDot(path);\n const link = prefix + FS + dotDot;\n const linkResult = rendy(template.link, {\n link,\n title: '..',\n name: '..'\n });\n const dataName = getDataName('..');\n const attribute = 'draggable=\"true\" ' + dataName;\n /* Сохраняем путь к каталогу верхнего уровня*/\n\n fileTable += rendy(template.file, {\n tag: 'li',\n attribute,\n className: '',\n type: 'directory',\n name: linkResult,\n size: '<dir>',\n date: '--.--.----',\n owner: '.',\n mode: '--- --- ---'\n });\n }\n\n fileTable += files.map(updateField).map(file => {\n const name = encode(file.name);\n const link = prefix + FS + path + name;\n const {\n type,\n mode,\n date,\n owner,\n size\n } = file;\n const linkResult = rendy(templateLink, {\n link,\n title: name,\n name,\n attribute: getAttribute(file.type)\n });\n const dataName = getDataName(file.name);\n const attribute = `draggable=\"true\" ${dataName}`;\n return rendy(templateFile, {\n tag: 'li',\n attribute,\n className: '',\n type,\n name: linkResult,\n size,\n date,\n owner,\n mode\n });\n }).join('');\n fileTable += '</ul>';\n return fileTable;\n};\n\nfunction updateField(file) {\n return { ...file,\n date: file.date || '--.--.----',\n owner: file.owner || 'root',\n size: getSize(file)\n };\n}\n\nfunction getAttribute(type) {\n if (type === 'directory') return '';\n return 'target=\"_blank\" ';\n}\n\nmodule.exports._getSize = getSize;\n\nfunction getSize(_ref) {\n let {\n size,\n type\n } = _ref;\n if (type === 'directory') return '<dir>';\n if (/link/.test(type)) return '<link>';\n return size;\n}\n\nfunction _getHeaderField(sort, order, name) {\n const arrow = order === 'asc' ? '↑' : '↓';\n if (sort !== name) return name;\n if (sort === 'name' && order === 'asc') return name;\n return `${name}${arrow}`;\n}\n\nfunction getDotDot(path) {\n // убираем последний слеш и каталог в котором мы сейчас находимся\n const lastSlash = path.substr(path, path.lastIndexOf('/'));\n const dotDot = lastSlash.substr(lastSlash, lastSlash.lastIndexOf('/'));\n if (!dotDot) return '/';\n return dotDot;\n}\n\n//# sourceURL=file://cloudcmd/common/cloudfunc.js");
|
|
264
264
|
|
|
265
265
|
/***/ }),
|
|
266
266
|
|
|
@@ -272,7 +272,7 @@ eval("\n\nconst rendy = __webpack_require__(/*! rendy */ \"./node_modules/rendy/
|
|
|
272
272
|
/***/ (function(module, exports, __webpack_require__) {
|
|
273
273
|
|
|
274
274
|
"use strict";
|
|
275
|
-
eval("\n\nconst Entities = {\n ' ': ' ',\n '<': '<',\n '>': '>',\n '"': '\"'\n};\nconst keys = Object.keys(Entities);\n\nmodule.exports.encode = str => {\n for (const code of keys) {\n const char = Entities[code];\n const reg = RegExp(char, 'g');\n str = str.replace(reg, code);\n }\n\n return str;\n};\n\nmodule.exports.decode = str => {\n for (const code of keys) {\n const char = Entities[code];\n const reg = RegExp(code, 'g');\n str = str.replace(reg, char);\n }\n\n return str;\n};\n\n//# sourceURL=file://cloudcmd/common/entity.js");
|
|
275
|
+
eval("\n\nconst Entities = {\n // ' ': ' ',\n '<': '<',\n '>': '>',\n '"': '\"'\n};\nconst keys = Object.keys(Entities);\n\nmodule.exports.encode = str => {\n for (const code of keys) {\n const char = Entities[code];\n const reg = RegExp(char, 'g');\n str = str.replace(reg, code);\n }\n\n return str;\n};\n\nmodule.exports.decode = str => {\n for (const code of keys) {\n const char = Entities[code];\n const reg = RegExp(code, 'g');\n str = str.replace(reg, char);\n }\n\n return str;\n};\n\n//# sourceURL=file://cloudcmd/common/entity.js");
|
|
276
276
|
|
|
277
277
|
/***/ }),
|
|
278
278
|
|
|
@@ -367,7 +367,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n
|
|
|
367
367
|
/***/ (function(module, exports, __webpack_require__) {
|
|
368
368
|
|
|
369
369
|
"use strict";
|
|
370
|
-
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = highlight;\nexports.getChalk = getChalk;\nexports.shouldHighlight = shouldHighlight;\n\nvar _jsTokens = __webpack_require__(/*! js-tokens */ \"./node_modules/js-tokens/index.js\");\n\nvar _helperValidatorIdentifier = __webpack_require__(/*! @babel/helper-validator-identifier */ \"./node_modules/@babel/helper-validator-identifier/lib/index.js\");\n\nvar _chalk = __webpack_require__(/*! chalk */ \"./node_modules/@babel/highlight/node_modules/chalk/index.js\");\n\nconst sometimesKeywords = new Set([\"as\", \"async\", \"from\", \"get\", \"of\", \"set\"]);\n\nfunction getDefs(chalk) {\n return {\n keyword: chalk.cyan,\n capitalized: chalk.yellow,\n jsxIdentifier: chalk.yellow,\n punctuator: chalk.yellow,\n number: chalk.magenta,\n string: chalk.green,\n regex: chalk.magenta,\n comment: chalk.grey,\n invalid: chalk.white.bgRed.bold\n };\n}\n\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/;\nconst BRACKET = /^[()[\\]{}]$/;\nlet tokenize;\n{\n const JSX_TAG = /^[a-z][\\w-]*$/i;\n\n const getTokenType = function (token, offset, text) {\n if (token.type === \"name\") {\n if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) {\n return \"keyword\";\n }\n\n if (JSX_TAG.test(token.value) && (text[offset - 1] === \"<\" || text.
|
|
370
|
+
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = highlight;\nexports.getChalk = getChalk;\nexports.shouldHighlight = shouldHighlight;\n\nvar _jsTokens = __webpack_require__(/*! js-tokens */ \"./node_modules/js-tokens/index.js\");\n\nvar _helperValidatorIdentifier = __webpack_require__(/*! @babel/helper-validator-identifier */ \"./node_modules/@babel/helper-validator-identifier/lib/index.js\");\n\nvar _chalk = __webpack_require__(/*! chalk */ \"./node_modules/@babel/highlight/node_modules/chalk/index.js\");\n\nconst sometimesKeywords = new Set([\"as\", \"async\", \"from\", \"get\", \"of\", \"set\"]);\n\nfunction getDefs(chalk) {\n return {\n keyword: chalk.cyan,\n capitalized: chalk.yellow,\n jsxIdentifier: chalk.yellow,\n punctuator: chalk.yellow,\n number: chalk.magenta,\n string: chalk.green,\n regex: chalk.magenta,\n comment: chalk.grey,\n invalid: chalk.white.bgRed.bold\n };\n}\n\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/;\nconst BRACKET = /^[()[\\]{}]$/;\nlet tokenize;\n{\n const JSX_TAG = /^[a-z][\\w-]*$/i;\n\n const getTokenType = function (token, offset, text) {\n if (token.type === \"name\") {\n if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) {\n return \"keyword\";\n }\n\n if (JSX_TAG.test(token.value) && (text[offset - 1] === \"<\" || text.slice(offset - 2, offset) == \"</\")) {\n return \"jsxIdentifier\";\n }\n\n if (token.value[0] !== token.value[0].toLowerCase()) {\n return \"capitalized\";\n }\n }\n\n if (token.type === \"punctuator\" && BRACKET.test(token.value)) {\n return \"bracket\";\n }\n\n if (token.type === \"invalid\" && (token.value === \"@\" || token.value === \"#\")) {\n return \"punctuator\";\n }\n\n return token.type;\n };\n\n tokenize = function* (text) {\n let match;\n\n while (match = _jsTokens.default.exec(text)) {\n const token = _jsTokens.matchToToken(match);\n\n yield {\n type: getTokenType(token, match.index, text),\n value: token.value\n };\n }\n };\n}\n\nfunction highlightTokens(defs, text) {\n let highlighted = \"\";\n\n for (const {\n type,\n value\n } of tokenize(text)) {\n const colorize = defs[type];\n\n if (colorize) {\n highlighted += value.split(NEWLINE).map(str => colorize(str)).join(\"\\n\");\n } else {\n highlighted += value;\n }\n }\n\n return highlighted;\n}\n\nfunction shouldHighlight(options) {\n return !!_chalk.supportsColor || options.forceColor;\n}\n\nfunction getChalk(options) {\n return options.forceColor ? new _chalk.constructor({\n enabled: true,\n level: 1\n }) : _chalk;\n}\n\nfunction highlight(code, options = {}) {\n if (code !== \"\" && shouldHighlight(options)) {\n const chalk = getChalk(options);\n const defs = getDefs(chalk);\n return highlightTokens(defs, code);\n } else {\n return code;\n }\n}\n\n//# sourceURL=file://cloudcmd/node_modules/@babel/highlight/lib/index.js");
|
|
371
371
|
|
|
372
372
|
/***/ }),
|
|
373
373
|
|
|
@@ -998,7 +998,7 @@ eval("\n\nconst constant = (a) => () => a;\n\n/**\n * render template with data\
|
|
|
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.module.js\");\n\n\nfunction isOptionsObject(options) {\n return options === Object(options) && Object.keys(options).length !== 0;\n}\n\nfunction defaultBehavior(actions, behavior) {\n if (behavior === void 0) {\n behavior = 'auto';\n }\n\n var canSmoothScroll = ('scrollBehavior' in document.body.style);\n actions.forEach(function (_ref) {\n var el = _ref.el,\n top = _ref.top,\n left = _ref.left;\n\n if (el.scroll && canSmoothScroll) {\n el.scroll({\n top: top,\n left: left,\n behavior: behavior\n });\n } else {\n el.scrollTop = top;\n el.scrollLeft = left;\n }\n });\n}\n\nfunction getOptions(options) {\n if (options === false) {\n return {\n block: 'end',\n inline: 'nearest'\n };\n }\n\n if (isOptionsObject(options)) {\n return options;\n }\n\n return {\n block: 'start',\n inline: 'nearest'\n };\n}\n\nfunction scrollIntoView(target, options) {\n var
|
|
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.module.js\");\n\n\nfunction isOptionsObject(options) {\n return options === Object(options) && Object.keys(options).length !== 0;\n}\n\nfunction defaultBehavior(actions, behavior) {\n if (behavior === void 0) {\n behavior = 'auto';\n }\n\n var canSmoothScroll = ('scrollBehavior' in document.body.style);\n actions.forEach(function (_ref) {\n var el = _ref.el,\n top = _ref.top,\n left = _ref.left;\n\n if (el.scroll && canSmoothScroll) {\n el.scroll({\n top: top,\n left: left,\n behavior: behavior\n });\n } else {\n el.scrollTop = top;\n el.scrollLeft = left;\n }\n });\n}\n\nfunction getOptions(options) {\n if (options === false) {\n return {\n block: 'end',\n inline: 'nearest'\n };\n }\n\n if (isOptionsObject(options)) {\n return options;\n }\n\n return {\n block: 'start',\n inline: 'nearest'\n };\n}\n\nfunction scrollIntoView(target, options) {\n var isTargetAttached = target.isConnected || target.ownerDocument.documentElement.contains(target);\n\n if (isOptionsObject(options) && typeof options.behavior === 'function') {\n return options.behavior(isTargetAttached ? Object(compute_scroll_into_view__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(target, options) : []);\n }\n\n if (!isTargetAttached) {\n return;\n }\n\n var computeOptions = getOptions(options);\n return defaultBehavior(Object(compute_scroll_into_view__WEBPACK_IMPORTED_MODULE_0__[\"default\"])(target, computeOptions), computeOptions.behavior);\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (scrollIntoView);\n\n//# sourceURL=file://cloudcmd/node_modules/scroll-into-view-if-needed/es/index.js");
|
|
1002
1002
|
|
|
1003
1003
|
/***/ }),
|
|
1004
1004
|
|
|
@@ -187,7 +187,7 @@ eval("\n\nconst currify = __webpack_require__(/*! currify */ \"./node_modules/cu
|
|
|
187
187
|
/***/ (function(module, exports, __webpack_require__) {
|
|
188
188
|
|
|
189
189
|
"use strict";
|
|
190
|
-
eval("/* global CloudCmd */\n\n/* global Util */\n\n/* global DOM */\n\n/* global fileop */\n\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 {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.mjs\");\n\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\n\nconst removeExtension = __webpack_require__(/*! ./remove-extension */ \"./client/modules/operation/remove-extension.js\");\n\nconst setListeners = __webpack_require__(/*! ./set-listeners */ \"./client/modules/operation/set-listeners.js\");\n\nconst getNextCurrentName = __webpack_require__(/*! ./get-next-current-name */ \"./client/modules/operation/get-next-current-name.js\");\n\nconst removeQuery = a => a.replace(/\\?.*/, '');\n\nconst Name = 'Operation';\nCloudCmd[Name] = exports;\nconst {\n config\n} = CloudCmd;\nconst {\n Dialog,\n Images\n} = DOM;\nconst authCheck = wraptile(_authCheck);\nconst Operation = {};\nlet Loaded;\nlet copyFn;\nlet moveFn;\nlet deleteFn;\nlet extractFn;\nlet packZipFn;\nlet packTarFn;\nconst Info = DOM.CurrentInfo;\nconst showLoad = Images.show.load.bind(null, 'top');\nconst processFiles = currify(_processFiles);\n\nconst noFilesCheck = () => {\n const {\n length\n } = DOM.getActiveFiles();\n const is = Boolean(!length);\n if (is) return Dialog.alert.noFiles();\n return is;\n};\n\nmodule.exports.init = promisify(callback => {\n showLoad();\n exec.series([DOM.loadSocket, async callback => {\n if (config('dropbox')) return callback();\n const {\n prefix,\n prefixSocket\n } = CloudCmd;\n await loadAll();\n await initOperations(prefix, prefixSocket, callback);\n }, callback => {\n Loaded = true;\n Images.hide();\n callback();\n }], callback);\n});\n\nfunction _authCheck(spawn, ok) {\n const accept = wraptile(ok);\n const alertDialog = wraptile(Dialog.alert);\n spawn.on('accept', accept(spawn));\n spawn.on('reject', alertDialog('Wrong credentials!'));\n spawn.emit('auth', config('username'), config('password'));\n}\n\nconst onConnect = currify((fn, operator) => {\n setOperations(operator);\n fn();\n});\n\nasync function initOperations(prefix, socketPrefix, fn) {\n socketPrefix = `${socketPrefix}/fileop`;\n const operator = await fileop({\n prefix,\n socketPrefix\n });\n operator.on('connect', authCheck(operator, onConnect(fn)));\n}\n\nfunction setOperations(operator) {\n packTarFn = (_ref, callback) => {\n let {\n from,\n to,\n names\n } = _ref;\n const operation = 'Tar';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.tar(from, to, names).then(listen);\n };\n\n packZipFn = (_ref2, callback) => {\n let {\n from,\n to,\n names\n } = _ref2;\n const operation = 'Zip';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.zip(from, to, names).then(listen);\n };\n\n deleteFn = (from, files, callback) => {\n from = removeQuery(from);\n const operation = 'Delete';\n const listen = setListeners({\n operation,\n callback,\n from\n });\n operator.remove(from, files).then(listen);\n };\n\n copyFn = (_ref3, callback) => {\n let {\n from,\n to,\n names\n } = _ref3;\n const operation = 'Copy';\n const listen = setListeners({\n operation,\n callback,\n from,\n to,\n names\n });\n operator.copy(from, to, names).then(listen);\n };\n\n moveFn = (_ref4, callback) => {\n let {\n from,\n to,\n names\n } = _ref4;\n const operation = 'Move';\n const listen = setListeners({\n operation,\n callback,\n from,\n to\n });\n operator.move(from, to, names).then(listen);\n };\n\n extractFn = (_ref5, callback) => {\n let {\n from,\n to\n } = _ref5;\n const operation = 'Extract';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.extract(from, to).then(listen);\n };\n}\n\nfunction getPacker(type) {\n if (type === 'zip') return packZipFn;\n return packTarFn;\n}\n\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\n\nmodule.exports.show = (operation, data) => {\n if (!Loaded) return;\n if (operation === 'copy') return Operation.copy(data);\n if (operation === 'move') return Operation.move(data);\n if (operation === 'delete') return Operation.delete();\n if (operation === 'delete:silent') return Operation.deleteSilent();\n if (operation === 'pack') return Operation.pack();\n if (operation === 'extract') return Operation.extract();\n};\n\nOperation.copy = processFiles({\n type: 'copy'\n});\nOperation.move = processFiles({\n type: 'move'\n});\nOperation.delete = promptDelete;\nOperation.deleteSilent = deleteSilent;\n\nOperation.pack = () => {\n const isZip = config('packer') === 'zip';\n twopack('pack', isZip ? 'zip' : 'tar');\n};\n\nOperation.extract = () => {\n twopack('extract');\n};\n/**\n * prompt and delete current file or selected files\n *\n * @currentFile\n */\n\n\nasync function promptDelete() {\n if (noFilesCheck()) return;\n const msgAsk = 'Do you really want to delete the ';\n const msgSel = 'selected ';\n const files = DOM.getActiveFiles();\n const names = DOM.getFilenames(files);\n const n = names.length;\n let msg;\n\n if (n) {\n let name = '';\n\n for (let i = 0; i < 5 && i < n; i++) name += '\\n' + names[i];\n\n if (n >= 5) name += '\\n...';\n msg = msgAsk + msgSel + n + ' files/directories?\\n' + encode(name);\n } else {\n const current = DOM.getCurrentFile();\n const isDir = DOM.isCurrentIsDir(current);\n\n const getType = isDir => isDir ? 'directory' : 'file';\n\n const type = getType(isDir) + ' ';\n const name = DOM.getCurrentName(current);\n msg = msgAsk + msgSel + type + name + '?';\n }\n\n const [cancel] = await Dialog.confirm(msg);\n if (cancel) return;\n deleteSilent(files);\n}\n/**\n * delete current or selected files\n *\n * @files\n */\n\n\nfunction deleteSilent() {\n let files = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DOM.getActiveFiles();\n const query = '?files';\n const path = Info.dirPath;\n if (noFilesCheck()) return;\n showLoad();\n const removedNames = DOM.getFilenames(files);\n const names = DOM.CurrentInfo.files.map(DOM.getCurrentName);\n const currentName = DOM.getCurrentName();\n const nextCurrentName = getNextCurrentName(currentName, names, removedNames);\n deleteFn(path + query, removedNames, async () => {\n await CloudCmd.refresh();\n const names = Info.files.map(DOM.getCurrentName);\n const isCurrent = names.includes(currentName);\n const name = isCurrent ? currentName : nextCurrentName;\n DOM.setCurrentByName(name);\n });\n}\n/*\n * process files (copy or move)\n * @param data\n * @param operation\n */\n\n\nasync function _processFiles(options, data) {\n let selFiles;\n let files;\n let panel;\n let shouldAsk;\n let ok;\n let from = '';\n let to = '';\n let names = [];\n /* eslint no-multi-spaces: 0 */\n\n if (data) {\n from = data.from;\n to = data.to;\n names = data.names;\n panel = Info.panel;\n } else {\n from = Info.dirPath;\n to = DOM.getNotCurrentDirPath();\n selFiles = DOM.getSelectedFiles();\n names = DOM.getFilenames(selFiles);\n data = {};\n shouldAsk = true;\n panel = Info.panelPassive;\n }\n\n if (!names.length) names.push(DOM.getCurrentName());\n const [name] = names;\n const sameName = DOM.getCurrentByName(name, panel);\n if (!data && noFilesCheck()) return;\n const {\n type\n } = options;\n const isCopy = type === 'copy';\n const option = isCopy ? 'confirmCopy' : 'confirmMove';\n const title = isCopy ? 'Copy' : 'Rename/Move';\n const operation = isCopy ? copyFn : moveFn;\n\n if (shouldAsk && config(option)) {\n const [cancel, newTo] = await prompt(title, to, names.map(encode));\n if (!cancel) ask(newTo);\n return;\n }\n\n ask(to);\n\n function ask(to) {\n ok = from !== to && to;\n if (ok && !shouldAsk || !sameName) return go();\n const str = `\"${name}\" already exist. Overwrite?`;\n const cancel = false;\n Dialog.confirm(str, {\n cancel\n }).then(go);\n\n function go() {\n showLoad();\n files = {\n from,\n to,\n names\n };\n operation(files, async () => {\n await DOM.Storage.remove(from);\n const {\n panel,\n panelPassive\n } = Info;\n\n const setCurrent = () => {\n const currentName = name || data.names[0];\n DOM.setCurrentByName(currentName);\n };\n\n if (!Info.isOnePanel) CloudCmd.refresh({\n panel: panelPassive,\n noCurrent: true\n });\n CloudCmd.refresh({\n panel\n }, setCurrent);\n });\n }\n }\n}\n\nfunction checkEmpty(name, operation) {\n if (!operation) throw Error(name + ' could not be empty!');\n}\n\nfunction twopack(operation, type) {\n let op;\n let fileFrom;\n let currentName = Info.name;\n const {\n path,\n dirPath\n } = Info;\n const activeFiles = DOM.getActiveFiles();\n const names = DOM.getFilenames(activeFiles);\n checkEmpty('operation', operation);\n if (!names.length) return Dialog.alert.noFiles();\n\n switch (operation) {\n case 'extract':\n op = extractFn;\n fileFrom = {\n from: path,\n to: dirPath\n };\n currentName = removeExtension(currentName);\n break;\n\n case 'pack':\n op = getPacker(type);\n if (names.length > 1) currentName = Info.dir;\n currentName += DOM.getPackerExt(type);\n fileFrom = {\n from: dirPath,\n to: dirPath + currentName,\n names\n };\n break;\n }\n\n showLoad();\n op(fileFrom, error => {\n !error && CloudCmd.refresh({\n currentName\n });\n });\n}\n\nasync function prompt(msg, to, names) {\n const n = names.length;\n const [name] = names;\n msg += ' ';\n if (names.length > 1) msg += n + ' file(s)';else msg += '\"' + name + '\"';\n msg += ' to';\n return await Dialog.prompt(msg, to);\n}\n\nasync function loadAll() {\n const {\n prefix\n } = CloudCmd;\n const file = `${prefix}/fileop/fileop.js`;\n const [error] = await tryToCatch(load.js, file);\n if (error) Dialog.alert(error.message);\n Loaded = true;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/operation/index.js");
|
|
190
|
+
eval("/* global CloudCmd */\n\n/* global Util */\n\n/* global DOM */\n\n/* global fileop */\n\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 {\n promisify\n} = __webpack_require__(/*! es6-promisify */ \"./node_modules/es6-promisify/dist/promisify.mjs\");\n\nconst exec = __webpack_require__(/*! execon */ \"./node_modules/execon/lib/exec.js\");\n\nconst load = __webpack_require__(/*! load.js */ \"./node_modules/load.js/lib/load.js\");\n\nconst tryToCatch = __webpack_require__(/*! try-to-catch */ \"./node_modules/try-to-catch/lib/try-to-catch.js\");\n\nconst {\n encode\n} = __webpack_require__(/*! ../../../common/entity */ \"./common/entity.js\");\n\nconst removeExtension = __webpack_require__(/*! ./remove-extension */ \"./client/modules/operation/remove-extension.js\");\n\nconst setListeners = __webpack_require__(/*! ./set-listeners */ \"./client/modules/operation/set-listeners.js\");\n\nconst getNextCurrentName = __webpack_require__(/*! ./get-next-current-name */ \"./client/modules/operation/get-next-current-name.js\");\n\nconst removeQuery = a => a.replace(/\\?.*/, '');\n\nconst Name = 'Operation';\nCloudCmd[Name] = exports;\nconst {\n config\n} = CloudCmd;\nconst {\n Dialog,\n Images\n} = DOM;\nconst authCheck = wraptile(_authCheck);\nconst Operation = {};\nlet Loaded;\nlet copyFn;\nlet moveFn;\nlet deleteFn;\nlet extractFn;\nlet packZipFn;\nlet packTarFn;\nconst Info = DOM.CurrentInfo;\nconst showLoad = Images.show.load.bind(null, 'top');\nconst processFiles = currify(_processFiles);\n\nconst noFilesCheck = () => {\n const {\n length\n } = DOM.getActiveFiles();\n const is = Boolean(!length);\n if (is) return Dialog.alert.noFiles();\n return is;\n};\n\nmodule.exports.init = promisify(callback => {\n showLoad();\n exec.series([DOM.loadSocket, async callback => {\n if (config('dropbox')) return callback();\n const {\n prefix,\n prefixSocket\n } = CloudCmd;\n await loadAll();\n await initOperations(prefix, prefixSocket, callback);\n }, callback => {\n Loaded = true;\n Images.hide();\n callback();\n }], callback);\n});\n\nfunction _authCheck(spawn, ok) {\n const accept = wraptile(ok);\n const alertDialog = wraptile(Dialog.alert);\n spawn.on('accept', accept(spawn));\n spawn.on('reject', alertDialog('Wrong credentials!'));\n spawn.emit('auth', config('username'), config('password'));\n}\n\nconst onConnect = currify((fn, operator) => {\n setOperations(operator);\n fn();\n});\n\nasync function initOperations(prefix, socketPrefix, fn) {\n socketPrefix = `${socketPrefix}/fileop`;\n const operator = await fileop({\n prefix,\n socketPrefix\n });\n operator.on('connect', authCheck(operator, onConnect(fn)));\n}\n\nfunction setOperations(operator) {\n packTarFn = (_ref, callback) => {\n let {\n from,\n to,\n names\n } = _ref;\n const operation = 'Tar';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.tar(from, to, names).then(listen);\n };\n\n packZipFn = (_ref2, callback) => {\n let {\n from,\n to,\n names\n } = _ref2;\n const operation = 'Zip';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.zip(from, to, names).then(listen);\n };\n\n deleteFn = (from, files, callback) => {\n from = removeQuery(from);\n const operation = 'Delete';\n const listen = setListeners({\n operation,\n callback,\n from\n });\n operator.remove(from, files).then(listen);\n };\n\n copyFn = (_ref3, callback) => {\n let {\n from,\n to,\n names\n } = _ref3;\n const operation = 'Copy';\n const listen = setListeners({\n operation,\n callback,\n from,\n to,\n names\n });\n operator.copy(from, to, names).then(listen);\n };\n\n moveFn = (_ref4, callback) => {\n let {\n from,\n to,\n names\n } = _ref4;\n const operation = 'Move';\n const listen = setListeners({\n operation,\n callback,\n from,\n to\n });\n operator.move(from, to, names).then(listen);\n };\n\n extractFn = (_ref5, callback) => {\n let {\n from,\n to\n } = _ref5;\n const operation = 'Extract';\n const listen = setListeners({\n operation,\n callback,\n noContinue: true,\n from,\n to\n });\n operator.extract(from, to).then(listen);\n };\n}\n\nfunction getPacker(type) {\n if (type === 'zip') return packZipFn;\n return packTarFn;\n}\n\nmodule.exports.hide = () => {\n CloudCmd.View.hide();\n};\n\nmodule.exports.show = (operation, data) => {\n if (!Loaded) return;\n if (operation === 'copy') return Operation.copy(data);\n if (operation === 'move') return Operation.move(data);\n if (operation === 'delete') return Operation.delete();\n if (operation === 'delete:silent') return Operation.deleteSilent();\n if (operation === 'pack') return Operation.pack();\n if (operation === 'extract') return Operation.extract();\n};\n\nOperation.copy = processFiles({\n type: 'copy'\n});\nOperation.move = processFiles({\n type: 'move'\n});\nOperation.delete = promptDelete;\nOperation.deleteSilent = deleteSilent;\n\nOperation.pack = () => {\n const isZip = config('packer') === 'zip';\n twopack('pack', isZip ? 'zip' : 'tar');\n};\n\nOperation.extract = () => {\n twopack('extract');\n};\n/**\n * prompt and delete current file or selected files\n *\n * @currentFile\n */\n\n\nasync function promptDelete() {\n if (noFilesCheck()) return;\n const msgAsk = 'Do you really want to delete the ';\n const msgSel = 'selected ';\n const files = DOM.getActiveFiles();\n const names = DOM.getFilenames(files);\n const n = names.length;\n let msg;\n\n if (n) {\n let name = '';\n\n for (let i = 0; i < 5 && i < n; i++) name += '\\n' + names[i];\n\n if (n >= 5) name += '\\n...';\n msg = msgAsk + msgSel + n + ' files/directories?\\n' + encode(name);\n } else {\n const current = DOM.getCurrentFile();\n const isDir = DOM.isCurrentIsDir(current);\n\n const getType = isDir => isDir ? 'directory' : 'file';\n\n const type = getType(isDir) + ' ';\n const name = DOM.getCurrentName(current);\n msg = msgAsk + msgSel + type + name + '?';\n }\n\n const [cancel] = await Dialog.confirm(msg);\n if (cancel) return;\n deleteSilent(files);\n}\n/**\n * delete current or selected files\n *\n * @files\n */\n\n\nfunction deleteSilent() {\n let files = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DOM.getActiveFiles();\n const query = '?files';\n const path = Info.dirPath;\n if (noFilesCheck()) return;\n showLoad();\n const removedNames = DOM.getFilenames(files);\n const names = DOM.CurrentInfo.files.map(DOM.getCurrentName);\n const currentName = DOM.getCurrentName();\n const nextCurrentName = getNextCurrentName(currentName, names, removedNames);\n deleteFn(path + query, removedNames, async () => {\n await CloudCmd.refresh();\n const names = Info.files.map(DOM.getCurrentName);\n const isCurrent = names.includes(currentName);\n const name = isCurrent ? currentName : nextCurrentName;\n DOM.setCurrentByName(name);\n });\n}\n/*\n * process files (copy or move)\n * @param data\n * @param operation\n */\n\n\nasync function _processFiles(options, data) {\n let selFiles;\n let files;\n let panel;\n let shouldAsk;\n let ok;\n let from = '';\n let to = '';\n let names = [];\n /* eslint no-multi-spaces: 0 */\n\n if (data) {\n from = data.from;\n to = data.to;\n names = data.names;\n panel = Info.panel;\n } else {\n from = Info.dirPath;\n to = DOM.getNotCurrentDirPath();\n selFiles = DOM.getSelectedFiles();\n names = DOM.getFilenames(selFiles);\n data = {};\n shouldAsk = true;\n panel = Info.panelPassive;\n }\n\n if (!names.length) names.push(DOM.getCurrentName());\n const [name] = names;\n const sameName = DOM.getCurrentByName(name, panel);\n if (!data && noFilesCheck()) return;\n const {\n type\n } = options;\n const isCopy = type === 'copy';\n const option = isCopy ? 'confirmCopy' : 'confirmMove';\n const title = isCopy ? 'Copy' : 'Rename/Move';\n const operation = isCopy ? copyFn : moveFn;\n\n if (shouldAsk && config(option)) {\n const [cancel, newTo] = await prompt(title, to, names.map(encode));\n if (!cancel) ask(newTo);\n return;\n }\n\n ask(to);\n\n function ask(to) {\n ok = from !== to && to;\n if (ok && !shouldAsk || !sameName) return go();\n const str = `\"${name}\" already exist. Overwrite?`;\n const cancel = false;\n Dialog.confirm(str, {\n cancel\n }).then(go);\n\n function go() {\n showLoad();\n files = {\n from,\n to,\n names\n };\n operation(files, async () => {\n await DOM.Storage.remove(from);\n const {\n panel,\n panelPassive\n } = Info;\n if (!Info.isOnePanel) CloudCmd.refresh({\n panel: panelPassive,\n noCurrent: true\n });\n CloudCmd.refresh({\n panel\n });\n });\n }\n }\n}\n\nfunction checkEmpty(name, operation) {\n if (!operation) throw Error(name + ' could not be empty!');\n}\n\nfunction twopack(operation, type) {\n let op;\n let fileFrom;\n let currentName = Info.name;\n const {\n path,\n dirPath\n } = Info;\n const activeFiles = DOM.getActiveFiles();\n const names = DOM.getFilenames(activeFiles);\n checkEmpty('operation', operation);\n if (!names.length) return Dialog.alert.noFiles();\n\n switch (operation) {\n case 'extract':\n op = extractFn;\n fileFrom = {\n from: path,\n to: dirPath\n };\n currentName = removeExtension(currentName);\n break;\n\n case 'pack':\n op = getPacker(type);\n if (names.length > 1) currentName = Info.dir;\n currentName += DOM.getPackerExt(type);\n fileFrom = {\n from: dirPath,\n to: dirPath + currentName,\n names\n };\n break;\n }\n\n showLoad();\n op(fileFrom, error => {\n !error && CloudCmd.refresh({\n currentName\n });\n });\n}\n\nasync function prompt(msg, to, names) {\n const n = names.length;\n const [name] = names;\n msg += ' ';\n if (names.length > 1) msg += n + ' file(s)';else msg += '\"' + name + '\"';\n msg += ' to';\n return await Dialog.prompt(msg, to);\n}\n\nasync function loadAll() {\n const {\n prefix\n } = CloudCmd;\n const file = `${prefix}/fileop/fileop.js`;\n const [error] = await tryToCatch(load.js, file);\n if (error) Dialog.alert(error.message);\n Loaded = true;\n}\n\n//# sourceURL=file://cloudcmd/client/modules/operation/index.js");
|
|
191
191
|
|
|
192
192
|
/***/ }),
|
|
193
193
|
|
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 = \"
|
|
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 = \"Sat Apr 23 2022 01:35:24 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");
|
|
105
105
|
|
|
106
106
|
/***/ }),
|
|
107
107
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcmd",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.1.0",
|
|
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",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"currify": "^4.0.0",
|
|
96
96
|
"deepmerge": "^4.0.0",
|
|
97
97
|
"deepword": "^8.0.0",
|
|
98
|
-
"dword": "^
|
|
98
|
+
"dword": "^14.0.0",
|
|
99
99
|
"edward": "^13.0.0",
|
|
100
100
|
"es6-promisify": "^7.0.0",
|
|
101
101
|
"execon": "^1.2.0",
|
|
@@ -119,12 +119,12 @@
|
|
|
119
119
|
"onezip": "^5.0.0",
|
|
120
120
|
"open": "^8.0.5",
|
|
121
121
|
"package-json": "^7.0.0",
|
|
122
|
-
"ponse": "^
|
|
122
|
+
"ponse": "^7.0.0",
|
|
123
123
|
"pullout": "^4.0.0",
|
|
124
|
-
"putout": "^
|
|
124
|
+
"putout": "^25.0.1",
|
|
125
125
|
"redzip": "^2.0.0",
|
|
126
126
|
"rendy": "^3.0.0",
|
|
127
|
-
"restafary": "^
|
|
127
|
+
"restafary": "^11.0.0",
|
|
128
128
|
"restbox": "^3.0.0",
|
|
129
129
|
"shortdate": "^2.0.0",
|
|
130
130
|
"simport": "^1.0.1",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"try-catch": "^3.0.0",
|
|
137
137
|
"try-to-catch": "^3.0.0",
|
|
138
138
|
"tryrequire": "^3.0.0",
|
|
139
|
-
"win32": "^
|
|
139
|
+
"win32": "^7.0.0",
|
|
140
140
|
"wraptile": "^3.0.0",
|
|
141
141
|
"writejson": "^3.0.0",
|
|
142
142
|
"yargs-parser": "^21.0.0"
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"@cloudcmd/create-element": "^2.0.0",
|
|
151
151
|
"@cloudcmd/modal": "^2.0.0",
|
|
152
152
|
"@cloudcmd/olark": "^3.0.2",
|
|
153
|
-
"@cloudcmd/stub": "^
|
|
153
|
+
"@cloudcmd/stub": "^4.0.1",
|
|
154
154
|
"auto-globals": "^2.0.0",
|
|
155
155
|
"babel-loader": "^8.0.0",
|
|
156
156
|
"babel-plugin-macros": "^3.0.0",
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
"emitify": "^4.0.1",
|
|
166
166
|
"eslint": "^8.0.1",
|
|
167
167
|
"eslint-plugin-node": "^11.0.0",
|
|
168
|
-
"eslint-plugin-putout": "^
|
|
168
|
+
"eslint-plugin-putout": "^14.4.0",
|
|
169
169
|
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
|
|
170
170
|
"gritty": "^6.0.0",
|
|
171
171
|
"gunzip-maybe": "^1.3.1",
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"just-pascal-case": "^1.1.0",
|
|
177
177
|
"limier": "^3.0.0",
|
|
178
178
|
"load.js": "^3.0.0",
|
|
179
|
-
"madrun": "^
|
|
179
|
+
"madrun": "^9.0.0",
|
|
180
180
|
"memfs": "^3.0.1",
|
|
181
181
|
"minor": "^1.2.2",
|
|
182
182
|
"mock-require": "^3.0.1",
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
"smalltalk": "^4.0.0",
|
|
196
196
|
"style-loader": "^2.0.0",
|
|
197
197
|
"supermenu": "^4.0.1",
|
|
198
|
-
"supertape": "^
|
|
198
|
+
"supertape": "^7.1.0",
|
|
199
199
|
"tar-stream": "^2.0.0",
|
|
200
200
|
"unionfs": "^4.0.0",
|
|
201
201
|
"url-loader": "^4.0.0",
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
"yaspeller": "^8.0.0"
|
|
207
207
|
},
|
|
208
208
|
"engines": {
|
|
209
|
-
"node": ">=
|
|
209
|
+
"node": ">=16"
|
|
210
210
|
},
|
|
211
211
|
"license": "MIT",
|
|
212
212
|
"main": "server/cloudcmd.js",
|
package/server/server.js
CHANGED
|
@@ -35,12 +35,12 @@ const logger = tryRequire('morgan');
|
|
|
35
35
|
|
|
36
36
|
module.exports = async (options, config) => {
|
|
37
37
|
const prefix = config('prefix');
|
|
38
|
-
const port = process.env.PORT
|
|
39
|
-
config('port');
|
|
38
|
+
const port = process.env.PORT /* c9 */
|
|
39
|
+
|| config('port');
|
|
40
40
|
|
|
41
|
-
const ip = process.env.IP
|
|
42
|
-
config('ip')
|
|
43
|
-
'0.0.0.0';
|
|
41
|
+
const ip = process.env.IP /* c9 */
|
|
42
|
+
|| config('ip')
|
|
43
|
+
|| '0.0.0.0';
|
|
44
44
|
|
|
45
45
|
const app = express();
|
|
46
46
|
const server = http.createServer(app);
|