diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 5ecfc1b..61a27d8 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -20,7 +20,7 @@ jobs: - name: Yarn Install run: yarn install --frozen-lockfile - + - name: Yarn Build run: yarn build diff --git a/src/sw.js b/src/sw.js new file mode 100644 index 0000000..117f1e6 --- /dev/null +++ b/src/sw.js @@ -0,0 +1,29 @@ +import INDEX_HTML from "../index.html"; + +import { SWReplay } from "@webrecorder/wabac/src/swmain"; + +import { WorkerLoader } from "@webrecorder/wabac/src/loaders"; + +if (self.registration) { + const staticData = new Map(); + + const prefix = 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 = {}; + + if (sp.get("ruffle") == "1") { + defaultConfig.injectScripts = ["ruffle/ruffle.js"]; + } + + self.sw = new SWReplay({ staticData, defaultConfig }); +} else { + new WorkerLoader(self); +}