fix: syncxhr and dynamic import function

This commit is contained in:
Percs 2024-11-02 21:10:58 -05:00
parent 7de29b7cf3
commit 3981e40deb
2 changed files with 4 additions and 2 deletions

View file

@ -3,7 +3,7 @@ import { config } from "../../shared";
import { rewriteUrl } from "../../shared/rewriters/url"; import { rewriteUrl } from "../../shared/rewriters/url";
export default function (client: ScramjetClient, self: Self) { export default function (client: ScramjetClient, self: Self) {
const Function = client.natives.Function; const Function = client.natives["Function"];
self[config.globals.importfn] = function (base: string) { self[config.globals.importfn] = function (base: string) {
return function (url: string) { return function (url: string) {

View file

@ -5,7 +5,9 @@ import { ScramjetClient } from "../../client";
export default function (client: ScramjetClient, self: Self) { export default function (client: ScramjetClient, self: Self) {
let worker; let worker;
if (self.Worker && flagEnabled("syncxhr", client.url)) { if (self.Worker && flagEnabled("syncxhr", client.url)) {
worker = new client.natives["Worker"](config.files.sync); worker = new (client.natives["Worker"] ? client.natives["Worker"] : Worker)(
config.files.sync
);
} }
const ARGS = Symbol("xhr original args"); const ARGS = Symbol("xhr original args");
const HEADERS = Symbol("xhr headers"); const HEADERS = Symbol("xhr headers");