Skip to content

Commit 5e66ad6

Browse files
committed
[chrome] properly initialize scramjet
1 parent 94da769 commit 5e66ad6

File tree

4 files changed

+63
-60
lines changed

4 files changed

+63
-60
lines changed

packages/chrome/public/controller.sw.js

Lines changed: 47 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/chrome/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function App(props: {}, cx: ComponentContext) {
7878
}
7979
App.style = css`
8080
:scope {
81-
background-color: var(--toolbar);
81+
background-color: var(--frame);
8282
--separator-color: color-mix(in srgb, currentColor 10%, transparent);
8383
}
8484
.separator {

packages/chrome/src/proxy/scramjet.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export function createFetchHandler(controller: Controller) {
315315
let promises: Promise<any>[] = [];
316316
for (const context of contexts) {
317317
if (context.alive()) {
318-
console.log("sending to " + context.id, context.windowproxy);
318+
// console.log("sending to " + context.id, context.windowproxy);
319319
promises.push(
320320
context.rpc.call("setCookie", {
321321
url: url.href,
@@ -325,18 +325,18 @@ export function createFetchHandler(controller: Controller) {
325325
}
326326
}
327327
if (promises.length === 0) return;
328-
console.log("actually sent");
328+
// console.log("actually sent");
329329

330330
// a context could be deadlocked, so add a safety
331-
await Promise.race([
332-
new Promise((res) =>
333-
setTimeout(() => {
334-
console.error("a context deadlocked! hit timeout");
335-
res(null);
336-
}, 1000)
337-
),
338-
Promise.all(promises),
339-
]);
331+
// await Promise.race([
332+
// new Promise((res) =>
333+
// setTimeout(() => {
334+
// console.error("a context deadlocked! hit timeout");
335+
// res(null);
336+
// }, 1000)
337+
// ),
338+
// Promise.all(promises),
339+
// ]);
340340
},
341341
});
342342

packages/inject/src/scramjet.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import {
22
CookieJar,
33
iswindow,
4-
loadAndHook,
54
SCRAMJETCLIENT,
65
ScramjetClient,
7-
ScramjetClientInit,
8-
ScramjetInitConfig,
9-
ScramjetInterface,
106
setWasm,
117
} from "@mercuryworkshop/scramjet";
128
import { FrameSequence, InjectScramjetInit } from "./types";
@@ -31,7 +27,9 @@ export function loadScramjet({
3127

3228
const transport = new LibcurlClient({ wisp });
3329

34-
loadAndHook({
30+
if (SCRAMJETCLIENT in self) return;
31+
32+
client = new ScramjetClient(globalThis, {
3533
context: {
3634
interface: {
3735
getInjectScripts,
@@ -45,6 +43,5 @@ export function loadScramjet({
4543
transport,
4644
sendSetCookie: async (url: URL, cookie: string) => {},
4745
});
48-
49-
client = self[SCRAMJETCLIENT];
46+
client.hook();
5047
}

0 commit comments

Comments
 (0)