mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 22:40:01 -04:00
add license and client apis
This commit is contained in:
parent
ecff2aca52
commit
aac959936c
19 changed files with 1004 additions and 89 deletions
26
src/client/eval.ts
Normal file
26
src/client/eval.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
const FunctionProxy = new Proxy(Function, {
|
||||
construct(target, argArray) {
|
||||
if (argArray.length === 1) {
|
||||
return Reflect.construct(target, self.__scramjet$bundle.rewriters.rewriteJs(argArray[0]));
|
||||
} else {
|
||||
return Reflect.construct(target, self.__scramjet$bundle.rewriters.rewriteJs(argArray[argArray.length - 1]))
|
||||
}
|
||||
},
|
||||
apply(target, thisArg, argArray) {
|
||||
if (argArray.length === 1) {
|
||||
return Reflect.apply(target, undefined, self.__scramjet$bundle.rewriters.rewriteJs(argArray[0]));
|
||||
} else {
|
||||
return Reflect.apply(target, undefined, [...argArray.map((x, index) => index === argArray.length - 1), self.__scramjet$bundle.rewriters.rewriteJs(argArray[argArray.length - 1])])
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
delete window.Function;
|
||||
|
||||
window.Function = FunctionProxy;
|
||||
|
||||
delete window.eval;
|
||||
|
||||
// since the function proxy is already rewriting the js we can just reuse it for the eval proxy
|
||||
|
||||
window.eval = (str: string) => window.Function(str);
|
Loading…
Add table
Add a link
Reference in a new issue