add more polyfills

This commit is contained in:
The Ghost of FOSS' Future 2025-01-06 19:28:30 -06:00 committed by GitHub
parent 5d1cb14683
commit 710866995b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

6
qjs.c
View file

@ -172,9 +172,12 @@ static int eval_file(JSContext *ctx, const char *filename, int module)
"if (typeof std !== 'undefined') {\n" "if (typeof std !== 'undefined') {\n"
" globalThis.urlGet = std.urlGet;\n" " globalThis.urlGet = std.urlGet;\n"
" globalThis.loadFile = std.loadFile;\n" " globalThis.loadFile = std.loadFile;\n"
" globalThis.doneRequire = std.loadFile;\n"
" globalThis.printf = console.log;\n" " globalThis.printf = console.log;\n"
" globalThis.evalFile = std.loadScript;\n" " globalThis.evalFile = std.loadScript;\n"
" globalThis.require = (moduleSpecifier) => import(moduleSpecifier).then(mod => mod.default || mod);\n" " globalThis.require = (moduleSpecifier) => import(moduleSpecifier).then(mod => mod.default || mod);\n"
" globalThis.stdRequire = globalThis.require;\n"
" globalThis.safeGlobals = {} \n"
" globalThis.getURL = std.urlGet;\n" " globalThis.getURL = std.urlGet;\n"
"} else {\n" "} else {\n"
" console.error('std is not defined.');\n" " console.error('std is not defined.');\n"
@ -735,9 +738,12 @@ start:
"if (typeof std !== 'undefined') {\n" "if (typeof std !== 'undefined') {\n"
" globalThis.urlGet = std.urlGet;\n" " globalThis.urlGet = std.urlGet;\n"
" globalThis.loadFile = std.loadFile;\n" " globalThis.loadFile = std.loadFile;\n"
" globalThis.doneRequire = std.loadFile;\n"
" globalThis.printf = console.log;\n" " globalThis.printf = console.log;\n"
" globalThis.evalFile = std.loadScript;\n" " globalThis.evalFile = std.loadScript;\n"
" globalThis.require = (moduleSpecifier) => import(moduleSpecifier).then(mod => mod.default || mod);\n" " globalThis.require = (moduleSpecifier) => import(moduleSpecifier).then(mod => mod.default || mod);\n"
" globalThis.stdRequire = globalThis.require;\n"
" globalThis.safeGlobals = {} \n"
" globalThis.getURL = std.urlGet;\n" " globalThis.getURL = std.urlGet;\n"
"} else {\n" "} else {\n"
" console.error('std is not defined.');\n" " console.error('std is not defined.');\n"