mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-12 14:00:01 -04:00
fix rewriter
This commit is contained in:
parent
0e37a7f267
commit
396170e4ea
7 changed files with 115 additions and 43 deletions
|
@ -8,6 +8,7 @@ import {
|
|||
rewrite_js_from_arraybuffer,
|
||||
} from "../../../rewriter/out/rewriter.js";
|
||||
import "../../../static/wasm.js";
|
||||
import { importfn, wrapfn } from "../../client/shared/wrap";
|
||||
|
||||
initSync(
|
||||
new WebAssembly.Module(
|
||||
|
@ -25,9 +26,25 @@ export function rewriteJs(js: string | ArrayBuffer, origin?: URL) {
|
|||
|
||||
const before = performance.now();
|
||||
if (typeof js === "string") {
|
||||
js = new TextDecoder().decode(rewrite_js(js, origin.toString()));
|
||||
js = new TextDecoder().decode(
|
||||
rewrite_js(
|
||||
js,
|
||||
origin.toString(),
|
||||
self.$scramjet.config.prefix,
|
||||
self.$scramjet.config.codec.encode as any,
|
||||
wrapfn,
|
||||
importfn
|
||||
)
|
||||
);
|
||||
} else {
|
||||
js = rewrite_js_from_arraybuffer(new Uint8Array(js), origin.toString());
|
||||
js = rewrite_js_from_arraybuffer(
|
||||
new Uint8Array(js),
|
||||
origin.toString(),
|
||||
self.$scramjet.config.prefix,
|
||||
self.$scramjet.config.codec.encode as any,
|
||||
wrapfn,
|
||||
importfn
|
||||
);
|
||||
}
|
||||
const after = performance.now();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue