From 807be22562d066fb0d79fc2e4abef117038f3271 Mon Sep 17 00:00:00 2001 From: Sneed Group Holder Date: Thu, 24 Oct 2024 15:56:39 -0500 Subject: [PATCH] make polyfills aio --- qjs.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/qjs.c b/qjs.c index 53b96bb..105af0c 100644 --- a/qjs.c +++ b/qjs.c @@ -497,28 +497,21 @@ int main(int argc, char **argv) } //POLYFILLS BEGIN - - ////Require and Global - const char *reqPF = "async function require(x) {\n" + const char *pf = "async function require(x) {\n" " const y = await import(x);" // use dynamic import. " return y;\n" "}\n" "globalThis.require = require;\n" - "globalThis.global = globalThis;\n"; - eval_buf(ctx, reqPF, strlen(reqPF), "", JS_EVAL_TYPE_MODULE); - - - const char *timeoutPF = "globalThis.setTimeout = globalThis.os.setTimeout\n" - "globalThis.clearTimeout = globalThis.os.clearTimeout\n" - "globalThis.sleep = globalThis.os.sleep"; - eval_buf(ctx, timeoutPF, strlen(timeoutPF), "", JS_EVAL_TYPE_MODULE); - - const char *stdGlobals = "globalThis.urlGet = globalThis.std.urlGet\n" - "globalThis.loadFile = globalThis.std.loadFile\n" - "globalThis.printf = globalThis.std.printf\n" - "globalThis.evalFile = globalThis.std.loadScript\n" - "globalThis.getURL = globalThis.std.urlGet"; - eval_buf(ctx, stdGlobals, strlen(stdGlobals), "", JS_EVAL_TYPE_MODULE); + "globalThis.global = globalThis;\n" + "globalThis.setTimeout = os.setTimeout\n" + "globalThis.clearTimeout = os.clearTimeout\n" + "globalThis.sleep = os.sleep\n" + "globalThis.urlGet = std.urlGet\n" + "globalThis.loadFile = std.loadFile\n" + "globalThis.printf = std.printf\n" + "globalThis.evalFile = std.loadScript\n" + "globalThis.getURL = std.urlGet"; + eval_buf(ctx, pf, strlen(pf), "", JS_EVAL_TYPE_MODULE); for(i = 0; i < include_count; i++) {