fix postmessage proxy

This commit is contained in:
velzie 2024-08-02 13:47:15 -04:00
parent a29e8c42a3
commit b8334993ae
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
5 changed files with 34 additions and 8 deletions

View file

@ -63,17 +63,30 @@ export class ScramjetClient {
recursive: true,
});
let modules = [];
for (const key of context.keys()) {
const module = context(key);
if (!key.endsWith(".ts")) continue;
if (
(key.startsWith("./dom/") && "window" in self) ||
(key.startsWith("./worker/") && "WorkerGlobalScope" in self) ||
key.startsWith("./shared/")
) {
const module = context(key);
module.default(this, this.global);
modules.push(module);
}
}
modules.sort((a, b) => {
const aorder = a.order || 0;
const border = b.order || 0;
return aorder - border;
});
for (const module of modules) {
module.default(this, this.global);
}
}
Proxy(name: string | string[], handler: Proxy) {