mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-12 14:00:01 -04:00
pass in full scramjet config
This commit is contained in:
parent
c60645d478
commit
f0e8aed666
2 changed files with 10 additions and 12 deletions
|
@ -24,21 +24,15 @@ export function rewriteJs(js: string | ArrayBuffer, origin?: URL) {
|
|||
if ("window" in globalThis) origin ??= new URL(decodeUrl(location.href));
|
||||
|
||||
const before = performance.now();
|
||||
const cfg = {
|
||||
prefix: self.$scramjet.config.prefix,
|
||||
codec: self.$scramjet.config.codec.encode,
|
||||
wrapfn: self.$scramjet.config.wrapfn,
|
||||
trysetfn: self.$scramjet.config.trysetfn,
|
||||
importfn: self.$scramjet.config.importfn,
|
||||
rewritefn: self.$scramjet.config.rewritefn,
|
||||
};
|
||||
if (typeof js === "string") {
|
||||
js = new TextDecoder().decode(rewrite_js(js, origin.toString(), cfg));
|
||||
js = new TextDecoder().decode(
|
||||
rewrite_js(js, origin.toString(), self.$scramjet.config)
|
||||
);
|
||||
} else {
|
||||
js = rewrite_js_from_arraybuffer(
|
||||
new Uint8Array(js),
|
||||
origin.toString(),
|
||||
cfg
|
||||
self.$scramjet.config
|
||||
);
|
||||
}
|
||||
const after = performance.now();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue