From 4fb5334ebce12ed9562a8a771e3dc0f9767e116d Mon Sep 17 00:00:00 2001 From: Sneed Group Holder Date: Thu, 24 Oct 2024 15:43:37 -0500 Subject: [PATCH] add more polyfill hax --- qjs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qjs.c b/qjs.c index 284cb2b..310747f 100644 --- a/qjs.c +++ b/qjs.c @@ -497,6 +497,8 @@ int main(int argc, char **argv) } //POLYFILLS BEGIN + + ////Require and Global const char *reqPF = "async function require(x) {\n" " const y = await import(x);" // use dynamic import. " return y;\n" @@ -505,6 +507,19 @@ int main(int argc, char **argv) "globalThis.global = globalThis;\n"; eval_buf(ctx, reqPF, strlen(reqPF), "", JS_EVAL_TYPE_MODULE); + + const char *timeoutPF = "global.setTimeout = os.setTimeout\n" + "global.sleep = os.sleep"; + eval_buf(ctx, timeoutPF, strlen(timeoutPF), "", JS_EVAL_TYPE_MODULE); + + const char *stdGlobals = "global.urlGet = std.urlGet\n" + "global.loadFile = std.loadFile\n" + "global.printf = std.printf\n" + "global.evalFile = std.loadScript\n" + "global.getURL = std.urlGet"; + eval_buf(ctx, stdGlobals, strlen(stdGlobals), "", JS_EVAL_TYPE_MODULE); + + for(i = 0; i < include_count; i++) { if (eval_file(ctx, include_list[i], module)) goto fail;