Skip to content

Commit

Permalink
feat: add annotations to all calls of rewritejs
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Dec 14, 2024
1 parent e873fa7 commit 4f7f633
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion rewriter/wasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ cd ../../
# 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

mkdir dist/ || true
mkdir -p dist/

cp rewriter/wasm/out/optimized.wasm dist/scramjet.wasm.wasm
{

cat <<EOF
Expand Down
6 changes: 4 additions & 2 deletions src/client/shared/eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function (client: ScramjetClient, self: Self) {
value: function (js: any) {
if (typeof js !== "string") return js;

const rewritten = rewriteJs(js, null, client.meta);
const rewritten = rewriteJs(js, "(direct eval proxy)", client.meta);

return rewritten;
},
Expand All @@ -23,5 +23,7 @@ export function indirectEval(this: ScramjetClient, js: any) {

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
);
}
6 changes: 5 additions & 1 deletion src/client/shared/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { rewriteJs } from "../../shared";
function rewriteFunction(ctx: ProxyCtx, client: ScramjetClient) {
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)());
}

Expand Down
3 changes: 2 additions & 1 deletion src/shared/rewriters/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export function rewriteUrl(url: string | URL, meta: URLMeta) {

if (url.startsWith("javascript:")) {
return (
"javascript:" + rewriteJs(url.slice("javascript:".length), null, meta)
"javascript:" +
rewriteJs(url.slice("javascript:".length), "(javascript: url)", meta)
);
} else if (url.startsWith("blob:")) {
return location.origin + $scramjet.config.prefix + url;
Expand Down

0 comments on commit 4f7f633

Please sign in to comment.