Skip to content

Commit 4c117aa

Browse files
committed
rip out service worker emulation code
1 parent 442dd0a commit 4c117aa

File tree

16 files changed

+5
-396
lines changed

16 files changed

+5
-396
lines changed

packages/chrome/src/IsolatedFrame.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const cfg = {
5757
sync: "/scram/scramjet.sync.js",
5858
},
5959
flags: {
60-
serviceworkers: false,
6160
syncxhr: false,
6261
strictRewrites: true,
6362
rewriterLogs: false,

packages/chrome/src/main.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ const scramjetcfg: Partial<ScramjetInitConfig> = {
2727
captureErrors: false,
2828
interceptDownloads: true,
2929
},
30-
siteFlags: {
31-
"https://worker-playground.glitch.me/.*": {
32-
serviceworkers: true,
33-
},
34-
},
30+
siteFlags: {},
3531
};
3632

3733
export const scramjet = new ScramjetController(scramjetcfg);

packages/scramjet/src/client/dom/serviceworker.ts

Lines changed: 0 additions & 107 deletions
This file was deleted.

packages/scramjet/src/client/entry.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@ import { loadCodecs, setConfig } from "@/shared/index";
44
import { SCRAMJETCLIENT } from "@/symbols";
55
import { ScramjetClient } from "@client/index";
66
import { ScramjetContextEvent, UrlChangeEvent } from "@client/events";
7-
import { ScramjetServiceWorkerRuntime } from "@client/swruntime";
87
import { ScramjetConfig } from "@/types";
98

109
export const iswindow = "window" in globalThis && window instanceof Window;
1110
export const isworker = "WorkerGlobalScope" in globalThis;
1211
export const issw = "ServiceWorkerGlobalScope" in globalThis;
1312
export const isdedicated = "DedicatedWorkerGlobalScope" in globalThis;
1413
export const isshared = "SharedWorkerGlobalScope" in globalThis;
15-
export const isemulatedsw =
16-
"location" in globalThis &&
17-
new URL(globalThis.location.href).searchParams.get("dest") ===
18-
"serviceworker";
1914

2015
function createFrameId() {
2116
return `${Array(8)
@@ -43,11 +38,6 @@ export function loadAndHook(config: ScramjetConfig) {
4338

4439
client.hook();
4540

46-
if (isemulatedsw) {
47-
const runtime = new ScramjetServiceWorkerRuntime(client);
48-
runtime.hook();
49-
}
50-
5141
const contextev = new ScramjetContextEvent(client.global.window, client);
5242
client.frame?.dispatchEvent(contextev);
5343
const urlchangeev = new UrlChangeEvent(client.url.href);

packages/scramjet/src/client/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ export * from "./entry";
33
export * from "./events";
44
export * from "./helpers";
55
export * from "./location";
6-
export * from "./swruntime";
76
export * from "./index";
87
export * from "./location";

packages/scramjet/src/client/shared/chrome.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// delete all chrome specific apis, or apis that are not supported by any browser other than chrome
22
// these are not worth emulating and typically cause issues
33

4-
import { isemulatedsw, iswindow } from "@client/entry";
4+
import { iswindow } from "@client/entry";
55
import { ScramjetClient } from "@client/index";
66

77
// type self as any here, most of these are not defined in the types
@@ -17,6 +17,8 @@ export default function (client: ScramjetClient, self: any) {
1717
}
1818
};
1919

20+
Reflect.deleteProperty(Navigator.prototype, "serviceWorker");
21+
2022
// obviously
2123
// del("chrome");
2224

@@ -29,10 +31,6 @@ export default function (client: ScramjetClient, self: any) {
2931
if (iswindow) {
3032
del("ServiceWorkerRegistration.prototype.sync");
3133
}
32-
if (isemulatedsw) {
33-
del("SyncManager");
34-
del("SyncEvent");
35-
}
3634

3735
// trustedtypes
3836
del("TrustedHTML");

packages/scramjet/src/client/shared/requests/fetch.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { isemulatedsw } from "@client/entry";
21
import { rewriteUrl, unrewriteUrl } from "@rewriters/url";
32
import { ScramjetClient } from "@client/index";
43

@@ -7,8 +6,6 @@ export default function (client: ScramjetClient) {
76
apply(ctx) {
87
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
98
ctx.args[0] = rewriteUrl(ctx.args[0], client.meta);
10-
11-
if (isemulatedsw) ctx.args[0] += "?from=swruntime";
129
}
1310
},
1411
});
@@ -17,8 +14,6 @@ export default function (client: ScramjetClient) {
1714
construct(ctx) {
1815
if (typeof ctx.args[0] === "string" || ctx.args[0] instanceof URL) {
1916
ctx.args[0] = rewriteUrl(ctx.args[0], client.meta);
20-
21-
if (isemulatedsw) ctx.args[0] += "?from=swruntime";
2217
}
2318
},
2419
});

packages/scramjet/src/client/swruntime.ts

Lines changed: 0 additions & 168 deletions
This file was deleted.

packages/scramjet/src/controller/controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export class ScramjetController extends EventTarget {
4545
sync: "/scramjet.sync.js",
4646
},
4747
flags: {
48-
serviceworkers: false,
4948
syncxhr: false,
5049
strictRewrites: true,
5150
rewriterLogs: false,

0 commit comments

Comments
 (0)