This copies the rules from the Browsertrix repo, and uses [`suppress-eslint-errors`](https://www.npmjs.com/package/suppress-eslint-errors) to suppose the violations. I'll take a pass at cleaning this up at some point in the future, and let's do our best to address these in the future as we come across them :) This'll help ensure new code being added to this repo is held to the same standard as code in Browsertrix's frontend.
38 lines
996 B
TypeScript
38 lines
996 B
TypeScript
import INDEX_HTML from "../index.html";
|
|
|
|
import { SWReplay } from "@webrecorder/wabac/src/swmain";
|
|
|
|
import { WorkerLoader } from "@webrecorder/wabac/src/loaders";
|
|
|
|
type Self = Window &
|
|
typeof globalThis & {
|
|
registration: { scope: string };
|
|
sw: SWReplay;
|
|
};
|
|
|
|
// TODO: Fix this the next time the file is edited.
|
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
if ((self as Self).registration) {
|
|
const staticData = new Map();
|
|
|
|
const prefix = (self as Self).registration.scope;
|
|
|
|
staticData.set(prefix, { type: "text/html", content: INDEX_HTML });
|
|
staticData.set(prefix + "index.html", {
|
|
type: "text/html",
|
|
content: INDEX_HTML,
|
|
});
|
|
|
|
const sp = new URLSearchParams(self.location.search);
|
|
|
|
const defaultConfig: { injectScripts?: string[] } = {};
|
|
|
|
if (sp.get("ruffle") == "1") {
|
|
defaultConfig.injectScripts = ["ruffle/ruffle.js"];
|
|
}
|
|
|
|
(self as Self).sw = new SWReplay({ staticData, defaultConfig });
|
|
} else {
|
|
new WorkerLoader(self);
|
|
}
|