import * as plugins from './plugins.js'; import { ServiceworkerClient } from './classes.serviceworkerclient.js'; export class GlobalSW { losslessSw: ServiceworkerClient; constructor(losslessServiceWorkerInstanceArg: ServiceworkerClient) { this.losslessSw = losslessServiceWorkerInstanceArg; globalThis.globalSw = this; }; /** * purges the cache of the app's serviceworker * @returns */ public async purgeCache() { await this.losslessSw.actionManager.waitForServiceWorkerConnection(); console.log(`purgeCache() was executed via globalThis.globalSw`); const result = await this.losslessSw.actionManager.purgeServiceWorkerCache(); return result; } /** * attempts to reload the app */ public async reloadApp() { await this.purgeCache(); window.location.reload(); } }