cloudcmd
Version:
File manager for the web with console and editor
364 lines (318 loc) • 10.2 kB
JavaScript
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 4299
(module) {
;
const f = (fn) => [
/*eslint no-unused-vars: 0*/
function (a) {return fn(...arguments);},
function (a, b) {return fn(...arguments);},
function (a, b, c) {return fn(...arguments);},
function (a, b, c, d) {return fn(...arguments);},
function (a, b, c, d, e) {return fn(...arguments);},
];
const currify = (fn, ...args) => {
check(fn);
if (args.length >= fn.length)
return fn(...args);
const again = (...args2) => {
return currify(fn, ...[...args, ...args2]);
};
const count = fn.length - args.length - 1;
const func = f(again)[count];
return func || again;
};
module.exports = currify;
function check(fn) {
if (typeof fn !== 'function')
throw Error('fn should be function!');
}
/***/ },
/***/ 5606
(module) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
// This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
(() => {
;
// EXTERNAL MODULE: ./node_modules/process/browser.js
var browser = __webpack_require__(5606);
;// ./node_modules/try-to-catch/lib/try-to-catch.js
const isFn = (a) => typeof a === 'function';
const tryToCatch = async (fn, ...args) => {
check(fn);
try {
return [null, await fn(...args)];
} catch(e) {
return [e];
}
};
function check(fn) {
if (!isFn(fn))
throw Error('fn should be a function!');
}
// EXTERNAL MODULE: ./node_modules/currify/lib/currify.js
var currify = __webpack_require__(4299);
;// ./client/sw/sw.js
const isDev = "production" === 'development';
const isGet = a => a.method === 'GET';
const isBasic = a => a.type === 'basic';
const wait = currify((f, e) => e.waitUntil(f()));
const respondWith = currify((f, e) => {
const {
request
} = e;
const {
url
} = request;
const pathname = getPathName(url);
if (url.endsWith('/') || /\^\/fs/.test(pathname)) return;
if (!isGet(request)) return;
if (!isBasic(request)) return;
if (pathname.startsWith('/api')) return;
if (/^socket.io/.test(pathname)) return;
e.respondWith(f(e));
});
const getPathName = url => new URL(url).pathname;
const date = "Tue May 26 2026 23:16:55 GMT+0300 (Eastern European Summer Time)";
const NAME = `cloudcmd: ${date}`;
const createRequest = a => new Request(a, {
credentials: 'same-origin'
});
const getRequest = (a, request) => {
if (a !== '/') return request;
return createRequest('/');
};
globalThis.addEventListener('install', wait(onInstall));
globalThis.addEventListener('fetch', respondWith(onFetch));
globalThis.addEventListener('activate', wait(onActivate));
async function onActivate() {
console.info(`cloudcmd: sw: activate: ${NAME}`);
await globalThis.clients.claim();
const keys = await caches.keys();
const deleteCache = caches.delete.bind(caches);
await Promise.all(keys.map(deleteCache));
}
async function onInstall() {
console.info(`cloudcmd: sw: install: ${NAME}`);
await globalThis.skipWaiting();
}
async function onFetch(event) {
const {
request
} = event;
const {
url
} = request;
const pathname = getPathName(url);
const newRequest = getRequest(pathname, event.request);
const cache = await caches.open(NAME);
const response = await cache.match(request);
if (!isDev && response) return response;
const [e, resp] = await tryToCatch(fetch, newRequest, {
credentials: 'same-origin'
});
if (e) return new Response(e.message);
await addToCache(request, resp.clone());
return resp;
}
async function addToCache(request, response) {
const cache = await caches.open(NAME);
return cache.put(request, response);
}
})();
/******/ })()
;
//# sourceMappingURL=sw.js.map