mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
feat: add annotations to all calls of rewritejs
This commit is contained in:
parent
e873fa7688
commit
4f7f633345
4 changed files with 13 additions and 5 deletions
|
@ -32,8 +32,9 @@ cd ../../
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
time wasm-opt $WASMOPTFLAGS --converge -tnh -O4 --vacuum --dce --enable-threads --enable-bulk-memory --enable-simd rewriter/wasm/out/wasm_bg.wasm -o rewriter/wasm/out/optimized.wasm
|
time wasm-opt $WASMOPTFLAGS --converge -tnh -O4 --vacuum --dce --enable-threads --enable-bulk-memory --enable-simd rewriter/wasm/out/wasm_bg.wasm -o rewriter/wasm/out/optimized.wasm
|
||||||
|
|
||||||
mkdir dist/ || true
|
mkdir -p dist/
|
||||||
|
|
||||||
|
cp rewriter/wasm/out/optimized.wasm dist/scramjet.wasm.wasm
|
||||||
{
|
{
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default function (client: ScramjetClient, self: Self) {
|
||||||
value: function (js: any) {
|
value: function (js: any) {
|
||||||
if (typeof js !== "string") return js;
|
if (typeof js !== "string") return js;
|
||||||
|
|
||||||
const rewritten = rewriteJs(js, null, client.meta);
|
const rewritten = rewriteJs(js, "(direct eval proxy)", client.meta);
|
||||||
|
|
||||||
return rewritten;
|
return rewritten;
|
||||||
},
|
},
|
||||||
|
@ -23,5 +23,7 @@ export function indirectEval(this: ScramjetClient, js: any) {
|
||||||
|
|
||||||
const indirection = this.global.eval;
|
const indirection = this.global.eval;
|
||||||
|
|
||||||
return indirection(rewriteJs(js, null, this.meta) as string);
|
return indirection(
|
||||||
|
rewriteJs(js, "(indirect eval proxy)", this.meta) as string
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,11 @@ import { rewriteJs } from "../../shared";
|
||||||
function rewriteFunction(ctx: ProxyCtx, client: ScramjetClient) {
|
function rewriteFunction(ctx: ProxyCtx, client: ScramjetClient) {
|
||||||
const stringifiedFunction = ctx.call().toString();
|
const stringifiedFunction = ctx.call().toString();
|
||||||
|
|
||||||
const content = rewriteJs(`return ${stringifiedFunction}`, null, client.meta);
|
const content = rewriteJs(
|
||||||
|
`return ${stringifiedFunction}`,
|
||||||
|
"(function proxy)",
|
||||||
|
client.meta
|
||||||
|
);
|
||||||
ctx.return(ctx.fn(content)());
|
ctx.return(ctx.fn(content)());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ export function rewriteUrl(url: string | URL, meta: URLMeta) {
|
||||||
|
|
||||||
if (url.startsWith("javascript:")) {
|
if (url.startsWith("javascript:")) {
|
||||||
return (
|
return (
|
||||||
"javascript:" + rewriteJs(url.slice("javascript:".length), null, meta)
|
"javascript:" +
|
||||||
|
rewriteJs(url.slice("javascript:".length), "(javascript: url)", meta)
|
||||||
);
|
);
|
||||||
} else if (url.startsWith("blob:")) {
|
} else if (url.startsWith("blob:")) {
|
||||||
return location.origin + $scramjet.config.prefix + url;
|
return location.origin + $scramjet.config.prefix + url;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue