Skip to content

Commit cdf89e1

Browse files
authored
Merge pull request #617 from mwszekely/main
Replace `self` with `globalThis` for use in Worklets
2 parents fd7330f + cc56037 commit cdf89e1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/comlink.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function isAllowedOrigin(
292292

293293
export function expose(
294294
obj: any,
295-
ep: Endpoint = self as any,
295+
ep: Endpoint = globalThis as any,
296296
allowedOrigins: (string | RegExp)[] = ["*"]
297297
) {
298298
ep.addEventListener("message", function callback(ev: MessageEvent) {
@@ -422,7 +422,7 @@ declare var FinalizationRegistry: FinalizationRegistry<Endpoint>;
422422

423423
const proxyCounter = new WeakMap<Endpoint, number>();
424424
const proxyFinalizers =
425-
"FinalizationRegistry" in self &&
425+
"FinalizationRegistry" in globalThis &&
426426
new FinalizationRegistry((ep: Endpoint) => {
427427
const newCount = (proxyCounter.get(ep) || 0) - 1;
428428
proxyCounter.set(ep, newCount);
@@ -550,7 +550,7 @@ export function proxy<T extends {}>(obj: T): T & ProxyMarked {
550550

551551
export function windowEndpoint(
552552
w: PostMessageWithOrigin,
553-
context: EventSource = self,
553+
context: EventSource = globalThis,
554554
targetOrigin = "*"
555555
): Endpoint {
556556
return {

0 commit comments

Comments
 (0)