chore: convert sw.js to typescript
This commit is contained in:
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
declare module "*.svg";
|
||||
declare module "*.html";
|
||||
declare const __SW_NAME__: string;
|
||||
declare const __HELPER_PROXY__: string;
|
||||
declare const __GDRIVE_CLIENT_ID__: string;
|
||||
|
||||
+10
-4
@@ -4,10 +4,16 @@ import { SWReplay } from "@webrecorder/wabac/src/swmain";
|
||||
|
||||
import { WorkerLoader } from "@webrecorder/wabac/src/loaders";
|
||||
|
||||
if (self.registration) {
|
||||
type Self = Window &
|
||||
typeof globalThis & {
|
||||
registration: { scope: string };
|
||||
sw: SWReplay;
|
||||
};
|
||||
|
||||
if ((self as Self).registration) {
|
||||
const staticData = new Map();
|
||||
|
||||
const prefix = self.registration.scope;
|
||||
const prefix = (self as Self).registration.scope;
|
||||
|
||||
staticData.set(prefix, { type: "text/html", content: INDEX_HTML });
|
||||
staticData.set(prefix + "index.html", {
|
||||
@@ -17,13 +23,13 @@ if (self.registration) {
|
||||
|
||||
const sp = new URLSearchParams(self.location.search);
|
||||
|
||||
const defaultConfig = {};
|
||||
const defaultConfig: { injectScripts?: string[] } = {};
|
||||
|
||||
if (sp.get("ruffle") == "1") {
|
||||
defaultConfig.injectScripts = ["ruffle/ruffle.js"];
|
||||
}
|
||||
|
||||
self.sw = new SWReplay({ staticData, defaultConfig });
|
||||
(self as Self).sw = new SWReplay({ staticData, defaultConfig });
|
||||
} else {
|
||||
new WorkerLoader(self);
|
||||
}
|
||||
Reference in New Issue
Block a user