From 4b84d20bb0f53caae1e5aa2d618d6be1d2e71cdf Mon Sep 17 00:00:00 2001 From: coderiaser Date: Thu, 15 Jan 2026 22:14:01 +0200 Subject: [PATCH] chore: cloudcmd --- client/cloudcmd.js | 16 ++-- client/dom/current-file.spec.js | 120 ++++++++++++++-------------- client/dom/index.js | 4 +- client/dom/index.spec.js | 10 +-- client/dom/storage.spec.js | 36 ++++----- client/get-json-from-file-table.mjs | 1 - client/key/index.spec.js | 4 +- client/key/vim/find.spec.js | 2 +- client/key/vim/index.spec.js | 18 ++--- client/listeners/index.js | 6 +- client/load-module.mjs | 6 +- client/modules/menu/cloudmenu.mjs | 2 +- client/modules/terminal-run.js | 2 +- client/modules/terminal.js | 2 +- client/modules/view/types.spec.js | 11 +-- client/sort.mjs | 3 +- client/sw/sw.js | 10 +-- 17 files changed, 121 insertions(+), 132 deletions(-) diff --git a/client/cloudcmd.js b/client/cloudcmd.js index 152cf865..99246920 100644 --- a/client/cloudcmd.js +++ b/client/cloudcmd.js @@ -12,11 +12,11 @@ const {initSortPanel, sortPanel} = require('./sort.mjs'); const isDev = process.env.NODE_ENV === 'development'; module.exports = async (config) => { - window.Util = require('../common/util'); - window.CloudFunc = require('../common/cloudfunc'); + globalThis.Util = require('../common/util'); + globalThis.CloudFunc = require('../common/cloudfunc'); - window.DOM = require('./dom'); - window.CloudCmd = require('./client'); + globalThis.DOM = require('./dom'); + globalThis.CloudCmd = require('./client'); await register(config); @@ -29,13 +29,13 @@ module.exports = async (config) => { globalThis.CloudCmd.init(prefix, config); - if (window.CloudCmd.config('menu') === 'aleman') + if (globalThis.CloudCmd.config('menu') === 'aleman') setTimeout(() => { import('https://esm.sh/@putout/processor-html'); import('https://esm.sh/@putout/bundle'); }, 100); }; -window.CloudCmd = module.exports; +globalThis.CloudCmd = module.exports; function getPrefix(prefix) { if (!prefix) @@ -51,7 +51,7 @@ const onUpdateFound = wraptile(async (config) => { if (isDev) return; - const {DOM} = window; + const {DOM} = globalThis; const prefix = getPrefix(config.prefix); await load.js(`${prefix}/dist/cloudcmd.common.js`); @@ -60,7 +60,7 @@ const onUpdateFound = wraptile(async (config) => { console.log('cloudcmd: sw: updated'); DOM.Events.removeAll(); - window.CloudCmd(config); + globalThis.CloudCmd(config); }); async function register(config) { diff --git a/client/dom/current-file.spec.js b/client/dom/current-file.spec.js index ec643d3d..88d966e7 100644 --- a/client/dom/current-file.spec.js +++ b/client/dom/current-file.spec.js @@ -11,10 +11,10 @@ const returns = wraptile(id); const {_CURRENT_FILE} = currentFile; test('current-file: setCurrentName: setAttribute', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; - global.DOM = getDOM(); - global.CloudCmd = getCloudCmd(); + globalThis.DOM = getDOM(); + globalThis.CloudCmd = getCloudCmd(); const current = create(); const {setAttribute} = current; @@ -23,17 +23,17 @@ test('current-file: setCurrentName: setAttribute', (t) => { t.calledWith(setAttribute, ['data-name', 'js-file-aGVsbG8='], 'should call setAttribute'); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.end(); }); test('current-file: setCurrentName: setAttribute: cyrillic', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; - global.DOM = getDOM(); - global.CloudCmd = getCloudCmd(); + globalThis.DOM = getDOM(); + globalThis.CloudCmd = getCloudCmd(); const current = create(); const {setAttribute} = current; @@ -42,8 +42,8 @@ test('current-file: setCurrentName: setAttribute: cyrillic', (t) => { t.calledWith(setAttribute, ['data-name', 'js-file-JUQwJUIwJUQwJUI5'], 'should call setAttribute'); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.end(); }); @@ -59,12 +59,12 @@ test('current-file: getCurrentName', (t) => { }); test('current-file: emit', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; const emit = stub(); - global.DOM = getDOM(); - global.CloudCmd = getCloudCmd({ + globalThis.DOM = getDOM(); + globalThis.CloudCmd = getCloudCmd({ emit, }); @@ -74,22 +74,22 @@ test('current-file: emit', (t) => { t.calledWith(emit, ['current-file', current], 'should call emit'); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.end(); }); test('current-file: setCurrentName: return', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; const link = {}; - global.DOM = getDOM({ + globalThis.DOM = getDOM({ link, }); - global.CloudCmd = getCloudCmd(); + globalThis.CloudCmd = getCloudCmd(); const current = create(); @@ -97,19 +97,19 @@ test('current-file: setCurrentName: return', (t) => { t.equal(result, link, 'should return link'); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.end(); }); test('current-file: getParentDirPath: result', (t) => { - const {DOM} = global; + const {DOM} = globalThis; const getCurrentDirPath = returns('/D/Films/+++favorite films/'); const getCurrentDirName = returns('+++favorite films'); - global.DOM = getDOM({ + globalThis.DOM = getDOM({ getCurrentDirPath, getCurrentDirName, }); @@ -117,55 +117,55 @@ test('current-file: getParentDirPath: result', (t) => { const result = currentFile.getParentDirPath(); const expected = '/D/Films/'; - global.DOM = DOM; + globalThis.DOM = DOM; t.equal(result, expected, 'should return parent dir path'); t.end(); }); test('current-file: isCurrentFile: no', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; - global.DOM = getDOM(); - global.CloudCmd = getCloudCmd(); + globalThis.DOM = getDOM(); + globalThis.CloudCmd = getCloudCmd(); const result = currentFile.isCurrentFile(); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.notOk(result); t.end(); }); test('current-file: isCurrentFile', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; const isContainClass = stub(); - global.DOM = getDOM({ + globalThis.DOM = getDOM({ isContainClass, }); - global.CloudCmd = getCloudCmd(); + globalThis.CloudCmd = getCloudCmd(); const current = {}; currentFile.isCurrentFile(current); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.calledWith(isContainClass, [current, _CURRENT_FILE], 'should call isContainClass'); t.end(); }); test('current-file: getCurrentType', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; - global.DOM = getDOM(); - global.CloudCmd = getCloudCmd(); + globalThis.DOM = getDOM(); + globalThis.CloudCmd = getCloudCmd(); - const {getByDataName} = global.DOM; + const {getByDataName} = globalThis.DOM; getByDataName.returns({ className: 'mini-icon directory', @@ -175,87 +175,87 @@ test('current-file: getCurrentType', (t) => { currentFile.getCurrentType(current); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.calledWith(getByDataName, ['js-type', current]); t.end(); }); test('current-file: isCurrentIsDir: getCurrentType', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; - global.DOM = getDOM(); - global.CloudCmd = getCloudCmd(); + globalThis.DOM = getDOM(); + globalThis.CloudCmd = getCloudCmd(); - const {getCurrentType} = global.DOM; + const {getCurrentType} = globalThis.DOM; const current = create(); currentFile.isCurrentIsDir(current); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.calledWith(getCurrentType, [current]); t.end(); }); test('current-file: isCurrentIsDir: directory', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; - global.DOM = getDOM({ + globalThis.DOM = getDOM({ getCurrentType: stub().returns('directory'), }); - global.CloudCmd = getCloudCmd(); + globalThis.CloudCmd = getCloudCmd(); const current = create(); const result = currentFile.isCurrentIsDir(current); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.ok(result); t.end(); }); test('current-file: isCurrentIsDir: directory-link', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; - global.DOM = getDOM({ + globalThis.DOM = getDOM({ getCurrentType: stub().returns('directory-link'), }); - global.CloudCmd = getCloudCmd(); + globalThis.CloudCmd = getCloudCmd(); const current = create(); const result = currentFile.isCurrentIsDir(current); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.ok(result); t.end(); }); test('current-file: isCurrentIsDir: file', (t) => { - const {DOM, CloudCmd} = global; + const {DOM, CloudCmd} = globalThis; - global.DOM = getDOM({ + globalThis.DOM = getDOM({ getCurrentType: stub().returns('file'), }); - global.CloudCmd = getCloudCmd(); + globalThis.CloudCmd = getCloudCmd(); const current = create(); const result = currentFile.isCurrentIsDir(current); - global.DOM = DOM; - global.CloudCmd = CloudCmd; + globalThis.DOM = DOM; + globalThis.CloudCmd = CloudCmd; t.notOk(result); t.end(); diff --git a/client/dom/index.js b/client/dom/index.js index 9bb7b4fe..965f1972 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -416,7 +416,7 @@ module.exports.shrinkSelection = () => { * setting history wrapper */ module.exports.setHistory = (data, title, url) => { - const ret = window.history; + const ret = globalThis.history; const {prefix} = CloudCmd; url = prefix + url; @@ -554,7 +554,7 @@ module.exports.getPanel = (options) => { * then always work with passive * panel */ - if (window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH) + if (globalThis.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH) panel = DOM.getByDataName('js-left'); if (!panel) diff --git a/client/dom/index.spec.js b/client/dom/index.spec.js index 18dc7ea1..e3a4b4bc 100644 --- a/client/dom/index.spec.js +++ b/client/dom/index.spec.js @@ -5,7 +5,7 @@ require('css-modules-require-hook/preset'); const {test, stub} = require('supertape'); const {getCSSVar, goToDirectory} = require('./index'); -global.CloudCmd = {}; +globalThis.CloudCmd = {}; test('cloudcmd: client: dom: goToDirectory', async (t) => { const path = ''; @@ -25,14 +25,14 @@ test('cloudcmd: client: dom: getCSSVar', (t) => { const body = {}; const getPropertyValue = stub().returns(0); - global.getComputedStyle = stub().returns({ + globalThis.getComputedStyle = stub().returns({ getPropertyValue, }); const result = getCSSVar('hello', { body, }); - delete global.getComputedStyle; + delete globalThis.getComputedStyle; t.notOk(result); t.end(); @@ -42,14 +42,14 @@ test('cloudcmd: client: dom: getCSSVar: 1', (t) => { const body = {}; const getPropertyValue = stub().returns(1); - global.getComputedStyle = stub().returns({ + globalThis.getComputedStyle = stub().returns({ getPropertyValue, }); const result = getCSSVar('hello', { body, }); - delete global.getComputedStyle; + delete globalThis.getComputedStyle; t.ok(result); t.end(); diff --git a/client/dom/storage.spec.js b/client/dom/storage.spec.js index abd7258a..0b281ffc 100644 --- a/client/dom/storage.spec.js +++ b/client/dom/storage.spec.js @@ -7,58 +7,58 @@ const storage = require('./storage'); const {stringify} = JSON; test('cloudcmd: client: storage: set', async (t) => { - const {localStorage} = global; + const {localStorage} = globalThis; const setItem = stub(); - global.localStorage = { + globalThis.localStorage = { setItem, }; await storage.set('hello', 'world'); - global.localStorage = localStorage; + globalThis.localStorage = localStorage; t.calledWith(setItem, ['hello', 'world'], 'should call setItem'); t.end(); }); test('cloudcmd: client: storage: get', async (t) => { - const {localStorage} = global; + const {localStorage} = globalThis; const getItem = stub().returns('world'); - global.localStorage = { + globalThis.localStorage = { getItem, }; const result = await storage.get('hello'); - global.localStorage = localStorage; + globalThis.localStorage = localStorage; t.equal(result, 'world'); t.end(); }); test('cloudcmd: client: storage: getJson', async (t) => { - const {localStorage} = global; + const {localStorage} = globalThis; const expected = { hello: 'world', }; const getItem = stub().returns(stringify(expected)); - global.localStorage = { + globalThis.localStorage = { getItem, }; const result = await storage.getJson('hello'); - global.localStorage = localStorage; + globalThis.localStorage = localStorage; t.deepEqual(result, expected); t.end(); }); test('cloudcmd: client: storage: setJson', async (t) => { - const {localStorage} = global; + const {localStorage} = globalThis; const data = { hello: 'world', }; @@ -66,42 +66,42 @@ test('cloudcmd: client: storage: setJson', async (t) => { const expected = stringify(data); const setItem = stub(); - global.localStorage = { + globalThis.localStorage = { setItem, }; await storage.setJson('hello', data); - global.localStorage = localStorage; + globalThis.localStorage = localStorage; t.calledWith(setItem, ['hello', expected]); t.end(); }); test('cloudcmd: client: storage: remove', async (t) => { - const {localStorage} = global; + const {localStorage} = globalThis; const removeItem = stub(); - global.localStorage = { + globalThis.localStorage = { removeItem, }; await storage.remove('hello'); - global.localStorage = localStorage; + globalThis.localStorage = localStorage; t.calledWith(removeItem, ['hello'], 'should call removeItem'); t.end(); }); test('cloudcmd: client: storage: clear', async (t) => { - const {localStorage} = global; + const {localStorage} = globalThis; const clear = stub(); - global.localStorage = { + globalThis.localStorage = { clear, }; await storage.clear(); - global.localStorage = localStorage; + globalThis.localStorage = localStorage; t.calledWithNoArgs(clear, 'should call clear'); t.end(); diff --git a/client/get-json-from-file-table.mjs b/client/get-json-from-file-table.mjs index 6be9e1c4..86edebf9 100644 --- a/client/get-json-from-file-table.mjs +++ b/client/get-json-from-file-table.mjs @@ -42,4 +42,3 @@ export const getJsonFromFileTable = () => { return fileTable; }; - diff --git a/client/key/index.spec.js b/client/key/index.spec.js index 2df5279f..3e52e5ac 100644 --- a/client/key/index.spec.js +++ b/client/key/index.spec.js @@ -12,8 +12,8 @@ const {getDOM, getCloudCmd} = require('./vim/globals.fixture'); const test = autoGlobals(supertape); const {stub} = supertape; -global.DOM = getDOM(); -global.CloudCmd = getCloudCmd(); +globalThis.DOM = getDOM(); +globalThis.CloudCmd = getCloudCmd(); test('cloudcmd: client: key: enable vim', async (t) => { const vim = stub(); diff --git a/client/key/vim/find.spec.js b/client/key/vim/find.spec.js index 1b36216b..74cc7fb1 100644 --- a/client/key/vim/find.spec.js +++ b/client/key/vim/find.spec.js @@ -5,7 +5,7 @@ const dir = './'; const {getDOM} = require('./globals.fixture'); -global.DOM = getDOM(); +globalThis.DOM = getDOM(); const {_next, _previous} = require(`${dir}find`); diff --git a/client/key/vim/index.spec.js b/client/key/vim/index.spec.js index cbef0e3b..b131de4f 100644 --- a/client/key/vim/index.spec.js +++ b/client/key/vim/index.spec.js @@ -10,13 +10,13 @@ const pathVim = join(dir, 'vim'); const {getDOM, getCloudCmd} = require('./globals.fixture'); -global.DOM = getDOM(); -global.CloudCmd = getCloudCmd(); +globalThis.DOM = getDOM(); +globalThis.CloudCmd = getCloudCmd(); const vim = require(pathVim); const {assign} = Object; -const {DOM} = global; +const {DOM} = globalThis; const {Buffer} = DOM; const pathFind = join(dir, 'vim', 'find'); const {reRequire, stopAll} = mockRequire; @@ -595,7 +595,7 @@ test('cloudcmd: client: key: N', (t) => { test('cloudcmd: client: key: make directory', async (t) => { const vim = reRequire(pathVim); - const {DOM} = global; + const {DOM} = globalThis; assign(DOM, { promptNewDir: stub(), @@ -615,7 +615,7 @@ test('cloudcmd: client: key: make directory', async (t) => { test('cloudcmd: client: key: make file', (t) => { const vim = reRequire(pathVim); - const {DOM} = global; + const {DOM} = globalThis; assign(DOM, { promptNewFile: stub(), @@ -634,7 +634,7 @@ test('cloudcmd: client: key: make file', (t) => { }); test.skip('cloudcmd: client: vim: terminal', (t) => { - const {CloudCmd} = global; + const {CloudCmd} = globalThis; assign(CloudCmd, { Terminal: { @@ -652,10 +652,10 @@ test.skip('cloudcmd: client: vim: terminal', (t) => { }); test.skip('cloudcmd: client: vim: edit', async (t) => { - global.DOM = getDOM(); - global.CloudCmd = getCloudCmd(); + globalThis.DOM = getDOM(); + globalThis.CloudCmd = getCloudCmd(); - const {CloudCmd} = global; + const {CloudCmd} = globalThis; assign(CloudCmd, { EditFileVim: { diff --git a/client/listeners/index.js b/client/listeners/index.js index 99206a9e..814b57bd 100644 --- a/client/listeners/index.js +++ b/client/listeners/index.js @@ -32,7 +32,7 @@ module.exports.init = async () => { CloudCmd.Listeners = module.exports; const unselect = (event) => { - const isMac = /Mac/.test(window.navigator.platform); + const isMac = /Mac/.test(globalThis.navigator.platform); const { shiftKey, metaKey, @@ -246,7 +246,7 @@ function onClick(event) { } function toggleSelect(key, files) { - const isMac = /Mac/.test(window.navigator.platform); + const isMac = /Mac/.test(globalThis.navigator.platform); if (!key) throw Error('key should not be undefined!'); @@ -480,7 +480,7 @@ function pop() { function resize() { Events.add('resize', () => { - const is = window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH; + const is = globalThis.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH; if (!is) return; diff --git a/client/load-module.mjs b/client/load-module.mjs index c518ad56..7fc2c328 100644 --- a/client/load-module.mjs +++ b/client/load-module.mjs @@ -1,10 +1,9 @@ /* global CloudCmd */ import exec from 'execon'; import {tryToCatch} from 'try-to-catch'; -import {js} from 'load.js'; +import {js as loadJS} from 'load.js'; import pascalCase from 'just-pascal-case'; -const loadJS = js; const noJS = (a) => a.replace(/.js$/, ''); /** @@ -50,9 +49,8 @@ export const loadModule = (params) => { const [e, a] = await tryToCatch(m); if (e) - return console.error(e); + return; return await a.show(...args); }; }; - diff --git a/client/modules/menu/cloudmenu.mjs b/client/modules/menu/cloudmenu.mjs index b36ca828..1fbe5165 100644 --- a/client/modules/menu/cloudmenu.mjs +++ b/client/modules/menu/cloudmenu.mjs @@ -14,7 +14,7 @@ export const createCloudMenu = async (fm, options, menuData) => { async function loadMenu() { if (CloudCmd.config('menu') === 'aleman') { - const {host, protocol} = window.location; + const {host, protocol} = globalThis.location; const url = `${protocol}//${host}/node_modules/aleman/menu/menu.js`; const {createMenu} = await import(/* webpackIgnore: true */url); diff --git a/client/modules/terminal-run.js b/client/modules/terminal-run.js index 57ed4971..33b5dbae 100644 --- a/client/modules/terminal-run.js +++ b/client/modules/terminal-run.js @@ -33,7 +33,7 @@ const loadAll = async () => { const [e] = await tryToCatch(load.parallel, [js, css]); if (e) { - const src = e.target.src.replace(window.location.href, ''); + const src = e.target.src.replace(globalThis.location.href, ''); return Dialog.alert(`file ${src} could not be loaded`); } diff --git a/client/modules/terminal.js b/client/modules/terminal.js index d7099d87..7b9197ca 100644 --- a/client/modules/terminal.js +++ b/client/modules/terminal.js @@ -32,7 +32,7 @@ const loadAll = async () => { const [e] = await tryToCatch(loadParallel, [js, css]); if (e) { - const src = e.target.src.replace(window.location.href, ''); + const src = e.target.src.replace(globalThis.location.href, ''); return Dialog.alert(`file ${src} could not be loaded`); } diff --git a/client/modules/view/types.spec.js b/client/modules/view/types.spec.js index 52ed5bad..d8004f9e 100644 --- a/client/modules/view/types.spec.js +++ b/client/modules/view/types.spec.js @@ -22,12 +22,9 @@ test('cloudcmd: client: view: types: detectType', async (t) => { headers: [], }); - const originalFetch = global.fetch; - - global.fetch = fetch; + globalThis.fetch = fetch; await _detectType('/hello'); - global.fetch = originalFetch; const expected = ['/hello', { method: 'HEAD', }]; @@ -37,17 +34,13 @@ test('cloudcmd: client: view: types: detectType', async (t) => { }); test('cloudcmd: client: view: types: detectType: found', async (t) => { - const originalFetch = global.fetch; - - global.fetch = stub().returns({ + globalThis.fetch = stub().returns({ headers: [ ['content-type', 'image/png'], ], }); const result = await _detectType('/hello'); - global.fetch = originalFetch; - t.equal(result, '.png'); t.end(); }); diff --git a/client/sort.mjs b/client/sort.mjs index 5625b433..73539c81 100644 --- a/client/sort.mjs +++ b/client/sort.mjs @@ -7,7 +7,7 @@ const sortPrevious = fullstore(); const {getPanel} = DOM; export const initSortPanel = () => { - const {sort, order} = CloudCmd; + const {sort} = CloudCmd; const position = DOM.getPanelPosition(); sortPrevious(sort[position]); @@ -34,4 +34,3 @@ export const sortPanel = (name, panel = getPanel()) => { noCurrent, }); }; - diff --git a/client/sw/sw.js b/client/sw/sw.js index b2f66429..e4cad253 100644 --- a/client/sw/sw.js +++ b/client/sw/sw.js @@ -50,14 +50,14 @@ const getRequest = (a, request) => { return createRequest('/'); }; -self.addEventListener('install', wait(onInstall)); -self.addEventListener('fetch', respondWith(onFetch)); -self.addEventListener('activate', wait(onActivate)); +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 self.clients.claim(); + await globalThis.clients.claim(); const keys = await caches.keys(); const deleteCache = caches.delete.bind(caches); @@ -67,7 +67,7 @@ async function onActivate() { async function onInstall() { console.info(`cloudcmd: sw: install: ${NAME}`); - await self.skipWaiting(); + await globalThis.skipWaiting(); } async function onFetch(event) {