UNPKG

pyodide

Version:

The Pyodide JavaScript package

4 lines 83.7 kB
{ "version": 3, "sources": ["../src/js/vendor/stackframe/stackframe.ts", "../src/js/vendor/stackframe/error-stack-parser.ts", "../src/js/environments.ts", "../src/js/compat.ts", "../src/js/nativefs.ts", "../src/core/sentinel.ts", "../src/js/emscripten-settings.ts", "../src/js/version.ts", "../src/js/common/path.ts", "../src/js/pyodide.ts"], "sourcesContent": ["// @ts-nocheck\n// Port of https://github.com/stacktracejs/stackframe/blob/master/stackframe.js.\n// Rewritten to ES6 and removed UMD and CommonJS support.\n\nfunction _isNumber(n) {\n return !isNaN(parseFloat(n)) && isFinite(n);\n}\n\nfunction _capitalize(str) {\n return str.charAt(0).toUpperCase() + str.substring(1);\n}\n\nfunction _getter(p) {\n return function () {\n return this[p];\n };\n}\n\nvar booleanProps = [\"isConstructor\", \"isEval\", \"isNative\", \"isToplevel\"];\nvar numericProps = [\"columnNumber\", \"lineNumber\"];\nvar stringProps = [\"fileName\", \"functionName\", \"source\"];\nvar arrayProps = [\"args\"];\nvar objectProps = [\"evalOrigin\"];\n\nvar props = booleanProps.concat(\n numericProps,\n stringProps,\n arrayProps,\n objectProps,\n);\n\ndeclare namespace StackFrame {\n export interface StackFrameOptions {\n isConstructor?: boolean;\n isEval?: boolean;\n isNative?: boolean;\n isToplevel?: boolean;\n columnNumber?: number;\n lineNumber?: number;\n fileName?: string;\n functionName?: string;\n source?: string;\n args?: any[];\n evalOrigin?: StackFrame;\n }\n}\n\ndeclare class StackFrame {\n constructor(obj: StackFrame.StackFrameOptions);\n\n args?: any[];\n getArgs(): any[] | undefined;\n setArgs(args: any[]): void;\n\n evalOrigin?: StackFrame;\n getEvalOrigin(): StackFrame | undefined;\n setEvalOrigin(stackframe: StackFrame): void;\n\n isConstructor?: boolean;\n getIsConstructor(): boolean | undefined;\n setIsConstructor(isConstructor: boolean): void;\n\n isEval?: boolean;\n getIsEval(): boolean | undefined;\n setIsEval(isEval: boolean): void;\n\n isNative?: boolean;\n getIsNative(): boolean | undefined;\n setIsNative(isNative: boolean): void;\n\n isToplevel?: boolean;\n getIsToplevel(): boolean | undefined;\n setIsToplevel(isToplevel: boolean): void;\n\n columnNumber?: number;\n getColumnNumber(): number | undefined;\n setColumnNumber(columnNumber: number): void;\n\n lineNumber?: number;\n getLineNumber(): number | undefined;\n setLineNumber(lineNumber: number): void;\n\n fileName?: string;\n getFileName(): string | undefined;\n setFileName(fileName: string): void;\n\n functionName?: string;\n getFunctionName(): string | undefined;\n setFunctionName(functionName: string): void;\n\n source?: string;\n getSource(): string | undefined;\n setSource(source: string): void;\n\n toString(): string;\n}\n\nfunction StackFrame(obj) {\n if (!obj) return;\n for (var i = 0; i < props.length; i++) {\n if (obj[props[i]] !== undefined) {\n this[\"set\" + _capitalize(props[i])](obj[props[i]]);\n }\n }\n}\n\nStackFrame.prototype = {\n getArgs: function () {\n return this.args;\n },\n setArgs: function (v) {\n if (Object.prototype.toString.call(v) !== \"[object Array]\") {\n throw new TypeError(\"Args must be an Array\");\n }\n this.args = v;\n },\n\n getEvalOrigin: function () {\n return this.evalOrigin;\n },\n setEvalOrigin: function (v) {\n if (v instanceof StackFrame) {\n this.evalOrigin = v;\n } else if (v instanceof Object) {\n this.evalOrigin = new StackFrame(v);\n } else {\n throw new TypeError(\"Eval Origin must be an Object or StackFrame\");\n }\n },\n\n toString: function () {\n var fileName = this.getFileName() || \"\";\n var lineNumber = this.getLineNumber() || \"\";\n var columnNumber = this.getColumnNumber() || \"\";\n var functionName = this.getFunctionName() || \"\";\n if (this.getIsEval()) {\n if (fileName) {\n return (\n \"[eval] (\" + fileName + \":\" + lineNumber + \":\" + columnNumber + \")\"\n );\n }\n return \"[eval]:\" + lineNumber + \":\" + columnNumber;\n }\n if (functionName) {\n return (\n functionName +\n \" (\" +\n fileName +\n \":\" +\n lineNumber +\n \":\" +\n columnNumber +\n \")\"\n );\n }\n return fileName + \":\" + lineNumber + \":\" + columnNumber;\n },\n};\n\nStackFrame.fromString = function StackFrame$$fromString(str) {\n var argsStartIndex = str.indexOf(\"(\");\n var argsEndIndex = str.lastIndexOf(\")\");\n\n var functionName = str.substring(0, argsStartIndex);\n var args = str.substring(argsStartIndex + 1, argsEndIndex).split(\",\");\n var locationString = str.substring(argsEndIndex + 1);\n\n if (locationString.indexOf(\"@\") === 0) {\n var parts = /@(.+?)(?::(\\d+))?(?::(\\d+))?$/.exec(locationString, \"\");\n var fileName = parts[1];\n var lineNumber = parts[2];\n var columnNumber = parts[3];\n }\n\n return new StackFrame({\n functionName: functionName,\n args: args || undefined,\n fileName: fileName,\n lineNumber: lineNumber || undefined,\n columnNumber: columnNumber || undefined,\n });\n};\n\nfor (var i = 0; i < booleanProps.length; i++) {\n StackFrame.prototype[\"get\" + _capitalize(booleanProps[i])] = _getter(\n booleanProps[i],\n );\n StackFrame.prototype[\"set\" + _capitalize(booleanProps[i])] = (function (p) {\n return function (v) {\n this[p] = Boolean(v);\n };\n })(booleanProps[i]);\n}\n\nfor (var j = 0; j < numericProps.length; j++) {\n StackFrame.prototype[\"get\" + _capitalize(numericProps[j])] = _getter(\n numericProps[j],\n );\n StackFrame.prototype[\"set\" + _capitalize(numericProps[j])] = (function (p) {\n return function (v) {\n if (!_isNumber(v)) {\n throw new TypeError(p + \" must be a Number\");\n }\n this[p] = Number(v);\n };\n })(numericProps[j]);\n}\n\nfor (var k = 0; k < stringProps.length; k++) {\n StackFrame.prototype[\"get\" + _capitalize(stringProps[k])] = _getter(\n stringProps[k],\n );\n StackFrame.prototype[\"set\" + _capitalize(stringProps[k])] = (function (p) {\n return function (v) {\n this[p] = String(v);\n };\n })(stringProps[k]);\n}\n\nexport default StackFrame;\n", "// @ts-nocheck\n// Port of https://github.com/stacktracejs/error-stack-parser\n// Rewritten to ES6 and removed UMD and CommonJS support.\n// Removed old opera support.\n\nimport StackFrame from \"./stackframe\";\n\ndeclare namespace ErrorStackParser {\n export type { StackFrame };\n /**\n * Given an Error object, extract the most information from it.\n *\n * @param {Error} error object\n * @return {Array} of StackFrames\n */\n export function parse(error: Error): StackFrame[];\n}\n\nfunction ErrorStackParser() {\n var CHROME_IE_STACK_REGEXP = /^\\s*at .*(\\S+:\\d+|\\(native\\))/m;\n var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code])?$/;\n\n return {\n /**\n * Given an Error object, extract the most information from it.\n *\n * @param {Error} error object\n * @return {Array} of StackFrames\n */\n parse: function ErrorStackParser$$parse(error: Error): StackFrame[] {\n if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {\n return this.parseV8OrIE(error);\n } else if (error.stack) {\n return this.parseFFOrSafari(error);\n } else {\n throw new Error(\"Cannot parse given Error object\");\n }\n },\n\n // Separate line and column numbers from a string of the form: (URI:Line:Column)\n extractLocation: function ErrorStackParser$$extractLocation(urlLike) {\n // Fail-fast but return locations like \"(native)\"\n if (urlLike.indexOf(\":\") === -1) {\n return [urlLike];\n }\n\n var regExp = /(.+?)(?::(\\d+))?(?::(\\d+))?$/;\n var parts = regExp.exec(urlLike.replace(/[()]/g, \"\"));\n return [parts[1], parts[2] || undefined, parts[3] || undefined];\n },\n\n parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {\n var filtered = error.stack.split(\"\\n\").filter(function (line) {\n return !!line.match(CHROME_IE_STACK_REGEXP);\n }, this);\n\n return filtered.map(function (line) {\n if (line.indexOf(\"(eval \") > -1) {\n // Throw away eval information until we implement stacktrace.js/stackframe#8\n line = line\n .replace(/eval code/g, \"eval\")\n .replace(/(\\(eval at [^()]*)|(,.*$)/g, \"\");\n }\n var sanitizedLine = line\n .replace(/^\\s+/, \"\")\n .replace(/\\(eval code/g, \"(\")\n .replace(/^.*?\\s+/, \"\");\n\n // capture and preserve the parenthesized location \"(/foo/my bar.js:12:87)\" in\n // case it has spaces in it, as the string is split on \\s+ later on\n var location = sanitizedLine.match(/ (\\(.+\\)$)/);\n\n // remove the parenthesized location from the line, if it was matched\n sanitizedLine = location\n ? sanitizedLine.replace(location[0], \"\")\n : sanitizedLine;\n\n // if a location was matched, pass it to extractLocation() otherwise pass all sanitizedLine\n // because this line doesn't have function name\n var locationParts = this.extractLocation(\n location ? location[1] : sanitizedLine,\n );\n var functionName = (location && sanitizedLine) || undefined;\n var fileName =\n [\"eval\", \"<anonymous>\"].indexOf(locationParts[0]) > -1\n ? undefined\n : locationParts[0];\n\n return new StackFrame({\n functionName: functionName,\n fileName: fileName,\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n source: line,\n });\n }, this);\n },\n\n parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {\n var filtered = error.stack.split(\"\\n\").filter(function (line) {\n return !line.match(SAFARI_NATIVE_CODE_REGEXP);\n }, this);\n\n return filtered.map(function (line) {\n // Throw away eval information until we implement stacktrace.js/stackframe#8\n if (line.indexOf(\" > eval\") > -1) {\n line = line.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n \":$1\",\n );\n }\n\n if (line.indexOf(\"@\") === -1 && line.indexOf(\":\") === -1) {\n // Safari eval frames only have function names and nothing else\n return new StackFrame({\n functionName: line,\n });\n } else {\n var functionNameRegex = /((.*\".+\"[^@]*)?[^@]*)(?:@)/;\n var matches = line.match(functionNameRegex);\n var functionName = matches && matches[1] ? matches[1] : undefined;\n var locationParts = this.extractLocation(\n line.replace(functionNameRegex, \"\"),\n );\n\n return new StackFrame({\n functionName: functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2],\n source: line,\n });\n }\n }, this);\n },\n };\n}\n\nconst errorStackParser = new ErrorStackParser();\n\nexport { StackFrame };\nexport default errorStackParser;\n", "/**\n * @hidden\n */\nexport interface RuntimeEnv extends BaseRuntimeEnv {\n IN_NODE_COMMONJS: boolean;\n IN_NODE_ESM: boolean;\n IN_BROWSER: boolean;\n IN_BROWSER_MAIN_THREAD: boolean;\n IN_BROWSER_WEB_WORKER: boolean;\n}\n\ninterface BaseRuntimeEnv {\n IN_NODE: boolean;\n IN_BUN: boolean;\n IN_DENO: boolean;\n IN_SAFARI: boolean;\n IN_SHELL: boolean;\n}\n\ndeclare var read: any;\ndeclare var load: any;\ndeclare var Deno: any;\ndeclare var Bun: any;\n\nfunction getGlobalRuntimeEnv(): RuntimeEnv {\n if (typeof API !== \"undefined\" && API !== globalThis.API) {\n // We're in pyodide.asm.js, get runtimeEnv off of API.\n // Hopefully this API !== globalThis.API prevents us from accidentally\n // picking up a global.\n return API.runtimeEnv;\n }\n // We're in pyodide.mjs, do the feature detection.\n const IN_BUN = typeof Bun !== \"undefined\";\n const IN_DENO = typeof Deno !== \"undefined\";\n const IN_NODE =\n typeof process === \"object\" &&\n typeof process.versions === \"object\" &&\n typeof process.versions.node === \"string\" &&\n !(process as any).browser;\n const IN_SAFARI =\n typeof navigator === \"object\" &&\n typeof navigator.userAgent === \"string\" &&\n navigator.userAgent.indexOf(\"Chrome\") === -1 &&\n navigator.userAgent.indexOf(\"Safari\") > -1;\n const IN_SHELL = typeof read === \"function\" && typeof load === \"function\";\n return calculateDerivedFlags({\n IN_BUN,\n IN_DENO,\n IN_NODE,\n IN_SAFARI,\n IN_SHELL,\n });\n}\n\n/** @private Internal runtime environment state */\nexport const RUNTIME_ENV: RuntimeEnv = getGlobalRuntimeEnv();\n\nfunction calculateDerivedFlags(base: BaseRuntimeEnv): RuntimeEnv {\n const IN_NODE_COMMONJS =\n base.IN_NODE &&\n typeof module !== \"undefined\" &&\n module.exports &&\n typeof require === \"function\" &&\n typeof __dirname === \"string\";\n\n const IN_NODE_ESM = base.IN_NODE && !IN_NODE_COMMONJS;\n const IN_BROWSER = !base.IN_NODE && !base.IN_DENO && !base.IN_BUN;\n const IN_BROWSER_MAIN_THREAD =\n IN_BROWSER &&\n typeof window !== \"undefined\" &&\n typeof (window as any).document !== \"undefined\" &&\n typeof (document as any).createElement === \"function\" &&\n \"sessionStorage\" in (window as any) &&\n typeof (globalThis as any).importScripts !== \"function\";\n const IN_BROWSER_WEB_WORKER =\n IN_BROWSER &&\n typeof (globalThis as any).WorkerGlobalScope !== \"undefined\" &&\n typeof (globalThis as any).self !== \"undefined\" &&\n (globalThis as any).self instanceof (globalThis as any).WorkerGlobalScope;\n return {\n ...base,\n IN_BROWSER,\n IN_BROWSER_MAIN_THREAD,\n IN_BROWSER_WEB_WORKER,\n IN_NODE_COMMONJS,\n IN_NODE_ESM,\n };\n}\n", "import ErrorStackParser from \"./vendor/stackframe/error-stack-parser\";\nimport { RUNTIME_ENV } from \"./environments\";\nimport { Lockfile } from \"./types\";\nlet nodeUrlMod: typeof import(\"node:url\");\nlet nodePath: typeof import(\"node:path\");\nlet nodeVmMod: typeof import(\"node:vm\");\n/** @private */\nexport let nodeFSMod: typeof import(\"node:fs\");\n/** @private */\nexport let nodeFsPromisesMod: typeof import(\"node:fs/promises\");\n\ndeclare function load(a: string): Promise<void>;\ndeclare function read(a: string): string;\ndeclare function readbuffer(a: string): ArrayBuffer;\n\ndeclare var globalThis: {\n importScripts: (url: string) => void;\n document?: typeof document;\n fetch?: typeof fetch;\n location?: URL;\n};\n\n/**\n * If we're in node, it's most convenient to import various node modules on\n * initialization. Otherwise, this does nothing.\n * @private\n */\nexport async function initNodeModules() {\n if (!RUNTIME_ENV.IN_NODE) {\n return;\n }\n // @ts-ignore\n nodeUrlMod = (await import(\"node:url\")).default;\n nodeFSMod = await import(\"node:fs\");\n nodeFsPromisesMod = await import(\"node:fs/promises\");\n\n // @ts-ignore\n nodeVmMod = (await import(\"node:vm\")).default;\n nodePath = await import(\"node:path\");\n pathSep = nodePath.sep;\n\n // Emscripten uses `require`, so if it's missing (because we were imported as\n // an ES6 module) we need to polyfill `require` with `import`. `import` is\n // async and `require` is synchronous, so we import all packages that might be\n // required up front and define require to look them up in this table.\n\n if (typeof require !== \"undefined\") {\n return;\n }\n // These are all the packages required in pyodide.asm.js. You can get this\n // list with:\n // $ grep -o 'require(\"[a-z]*\")' pyodide.asm.js | sort -u\n const fs = nodeFSMod;\n const crypto = await import(\"node:crypto\");\n const ws = await import(\"ws\");\n const child_process = await import(\"node:child_process\");\n const node_modules: { [mode: string]: any } = {\n fs,\n crypto,\n ws,\n child_process,\n };\n // Since we're in an ES6 module, this is only modifying the module namespace,\n // it's still private to Pyodide.\n (globalThis as any).require = function (mod: string): any {\n return node_modules[mod];\n };\n}\n\nexport function isAbsolute(path: string): boolean {\n return path.includes(\"://\") || path.startsWith(\"/\");\n}\n\nfunction node_resolvePath(path: string, base?: string): string {\n return nodePath.resolve(base || \".\", path);\n}\n\nfunction browser_resolvePath(path: string, base?: string): string {\n if (base === undefined) {\n // @ts-ignore\n base = location;\n }\n return new URL(path, base).toString();\n}\n\nexport let resolvePath: (rest: string, base?: string) => string;\nif (RUNTIME_ENV.IN_NODE) {\n resolvePath = node_resolvePath;\n} else if (RUNTIME_ENV.IN_SHELL) {\n resolvePath = (x) => x;\n} else {\n resolvePath = browser_resolvePath;\n}\n\n/**\n * Get the path separator. If we are on Linux or in the browser, it's /.\n * In Windows, it's \\.\n * @private\n */\nexport let pathSep: string;\n\nif (!RUNTIME_ENV.IN_NODE) {\n pathSep = \"/\";\n}\n\n/**\n * Load a binary file, only for use in Node. If the path explicitly is a URL,\n * then fetch from a URL, else load from the file system.\n * @param indexURL base path to resolve relative paths\n * @param path the path to load\n * @param checksum sha-256 checksum of the package\n * @returns An ArrayBuffer containing the binary data\n * @private\n */\nfunction node_getBinaryResponse(\n path: string,\n _file_sub_resource_hash?: string | undefined, // Ignoring sub resource hash. See issue-2431.\n):\n | { response: Promise<Response>; binary?: undefined }\n | { binary: Promise<Uint8Array> } {\n if (path.startsWith(\"file://\")) {\n // handle file:// with filesystem operations rather than with fetch.\n path = path.slice(\"file://\".length);\n }\n if (path.includes(\"://\")) {\n // If it has a protocol, make a fetch request\n return { response: fetch(path) };\n } else {\n // Otherwise get it from the file system\n return {\n binary: nodeFsPromisesMod\n .readFile(path)\n .then(\n (data: Buffer) =>\n new Uint8Array(data.buffer, data.byteOffset, data.byteLength),\n ),\n };\n }\n}\n\nfunction shell_getBinaryResponse(\n path: string,\n _file_sub_resource_hash?: string | undefined, // Ignoring sub resource hash. See issue-2431.\n):\n | { response: Promise<Response>; binary?: undefined }\n | { binary: Promise<Uint8Array> } {\n if (path.startsWith(\"file://\")) {\n // handle file:// with filesystem operations rather than with fetch.\n path = path.slice(\"file://\".length);\n }\n if (path.includes(\"://\")) {\n // If it has a protocol, make a fetch request\n throw new Error(\"Shell cannot fetch urls\");\n } else {\n // Otherwise get it from the file system\n return {\n binary: Promise.resolve(new Uint8Array(readbuffer(path))),\n };\n }\n}\n\n/**\n * Load a binary file, only for use in browser. Resolves relative paths against\n * indexURL.\n *\n * @param path the path to load\n * @param subResourceHash the sub resource hash for fetch() integrity check\n * @returns A Uint8Array containing the binary data\n * @private\n */\nfunction browser_getBinaryResponse(\n path: string,\n subResourceHash: string | undefined,\n): { response: Promise<Response>; binary?: undefined } {\n const url = new URL(path, location as unknown as URL);\n let options = subResourceHash ? { integrity: subResourceHash } : {};\n return { response: fetch(url, options) };\n}\n\n/** @private */\nexport let getBinaryResponse: (\n path: string,\n file_sub_resource_hash?: string | undefined,\n) =>\n | { response: Promise<Response>; binary?: undefined }\n | { response?: undefined; binary: Promise<Uint8Array> };\nif (RUNTIME_ENV.IN_NODE) {\n getBinaryResponse = node_getBinaryResponse;\n} else if (RUNTIME_ENV.IN_SHELL) {\n getBinaryResponse = shell_getBinaryResponse;\n} else {\n getBinaryResponse = browser_getBinaryResponse;\n}\n\nexport async function loadBinaryFile(\n path: string,\n file_sub_resource_hash?: string | undefined,\n): Promise<Uint8Array> {\n const { response, binary } = getBinaryResponse(path, file_sub_resource_hash);\n if (binary) {\n return binary;\n }\n const r = await response;\n if (!r.ok) {\n throw new Error(`Failed to load '${path}': request failed.`);\n }\n return new Uint8Array(await r.arrayBuffer());\n}\n\n/**\n * Currently loadScript is only used once to load `pyodide.asm.js`.\n * @param url\n * @private\n */\nexport let loadScript: (url: string) => Promise<void>;\n\nif (RUNTIME_ENV.IN_BROWSER_MAIN_THREAD) {\n // browser\n loadScript = async (url) => await import(/* webpackIgnore: true */ url);\n} else if (RUNTIME_ENV.IN_BROWSER_WEB_WORKER) {\n // webworker\n loadScript = async (url) => {\n try {\n // use importScripts in classic web worker\n globalThis.importScripts(url);\n } catch (e) {\n // importScripts throws TypeError in a module type web worker, use import instead\n if (e instanceof TypeError) {\n await import(/* webpackIgnore: true */ url);\n } else {\n throw e;\n }\n }\n };\n} else if (RUNTIME_ENV.IN_NODE) {\n loadScript = nodeLoadScript;\n} else if (RUNTIME_ENV.IN_SHELL) {\n loadScript = load;\n} else {\n throw new Error(\"Cannot determine runtime environment\");\n}\n\n/**\n * Load a text file and executes it as Javascript\n * @param url The path to load. May be a url or a relative file system path.\n * @private\n */\nasync function nodeLoadScript(url: string) {\n if (url.startsWith(\"file://\")) {\n // handle file:// with filesystem operations rather than with fetch.\n url = url.slice(\"file://\".length);\n }\n if (url.includes(\"://\")) {\n // If it's a url, load it with fetch then eval it.\n nodeVmMod.runInThisContext(await (await fetch(url)).text());\n } else {\n // Otherwise, hopefully it is a relative path we can load from the file\n // system.\n await import(/* webpackIgnore: true */ nodeUrlMod.pathToFileURL(url).href);\n }\n}\n\nexport async function loadLockFile(lockFileURL: string): Promise<Lockfile> {\n if (RUNTIME_ENV.IN_NODE) {\n await initNodeModules();\n const package_string = await nodeFsPromisesMod.readFile(lockFileURL, {\n encoding: \"utf8\",\n });\n return JSON.parse(package_string);\n } else if (RUNTIME_ENV.IN_SHELL) {\n const package_string = read(lockFileURL);\n return JSON.parse(package_string);\n } else {\n let response = await fetch(lockFileURL);\n return await response.json();\n }\n}\n\n/**\n * Calculate the directory name of the current module.\n * This is used to guess the indexURL when it is not provided.\n */\nexport async function calculateDirname(): Promise<string> {\n if (RUNTIME_ENV.IN_NODE_COMMONJS) {\n return __dirname;\n }\n\n let err: Error;\n try {\n throw new Error();\n } catch (e) {\n err = e as Error;\n }\n let fileName = ErrorStackParser.parse(err)[0].fileName!;\n\n if (RUNTIME_ENV.IN_NODE && !fileName.startsWith(\"file://\")) {\n fileName = `file://${fileName}`; // Error stack filenames are not starting with `file://` in `Bun`\n }\n\n if (RUNTIME_ENV.IN_NODE_ESM) {\n const nodePath = await import(\"node:path\");\n const nodeUrl = await import(\"node:url\");\n\n // FIXME: We would like to use import.meta.url here,\n // but mocha seems to mess with compiling typescript files to ES6.\n return nodeUrl.fileURLToPath(nodePath.dirname(fileName));\n }\n\n const indexOfLastSlash = fileName.lastIndexOf(pathSep);\n if (indexOfLastSlash === -1) {\n throw new Error(\n \"Could not extract indexURL path from pyodide module location. Please pass the indexURL explicitly to loadPyodide.\",\n );\n }\n return fileName.slice(0, indexOfLastSlash);\n}\n\n/**\n * Ensure that the directory exists before trying to download files into it (Node.js only).\n * @param dir The directory to ensure exists\n */\nexport async function ensureDirNode(dir?: string) {\n if (!RUNTIME_ENV.IN_NODE) {\n return;\n }\n if (!dir) {\n return;\n }\n\n try {\n // Check if the `installBaseUrl` directory exists\n await nodeFsPromisesMod.stat(dir); // Use `.stat()` which works even on ASAR archives of Electron apps, while `.access` doesn't.\n } catch {\n // If it doesn't exist, make it. Call mkdir() here only when necessary after checking the existence to avoid an error on read-only file systems. See https://github.com/pyodide/pyodide/issues/4736\n await nodeFsPromisesMod.mkdir(dir, {\n recursive: true,\n });\n }\n}\n\n/**\n * Calculates the install base url for the package manager.\n * exported for testing\n * @param lockFileURL\n * @returns the install base url\n * @private\n */\nexport function calculateInstallBaseUrl(lockFileURL: string) {\n // 1. If the lockfile URL includes a path with slash (file url in Node.js or http url in browser), use the directory of the lockfile URL\n // 2. Otherwise, fallback to the current location\n // 2.1. In the browser, use `location` to get the current location\n // 2.2. In Node.js just use the pwd\n return (\n lockFileURL.substring(0, lockFileURL.lastIndexOf(\"/\") + 1) ||\n globalThis.location?.toString() ||\n \".\"\n );\n}\n", "import { PyodideModule } from \"./types\";\n\n/**\n * @private\n */\nasync function syncfs(m: PyodideModule, direction: boolean): Promise<void> {\n return new Promise((resolve, reject) => {\n m.FS.syncfs(direction, (err: any) => {\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n });\n });\n}\n\n/**\n * @private\n */\nexport async function syncLocalToRemote(m: PyodideModule): Promise<void> {\n return await syncfs(m, false);\n}\n\n/**\n * @private\n */\nexport async function syncRemoteToLocal(m: PyodideModule): Promise<void> {\n return await syncfs(m, true);\n}\n\n/**\n * @private\n */\nexport function initializeNativeFS(module: PyodideModule) {\n const FS = module.FS;\n const MEMFS = module.FS.filesystems.MEMFS;\n const PATH = module.PATH;\n\n const nativeFSAsync = {\n // DIR_MODE: {{{ cDefine('S_IFDIR') }}} | 511 /* 0777 */,\n // FILE_MODE: {{{ cDefine('S_IFREG') }}} | 511 /* 0777 */,\n DIR_MODE: 16384 | 511,\n FILE_MODE: 32768 | 511,\n mount: function (mount: any) {\n if (!mount.opts.fileSystemHandle) {\n throw new Error(\"opts.fileSystemHandle is required\");\n }\n\n // reuse all of the core MEMFS functionality\n return MEMFS.mount.apply(null, arguments);\n },\n syncfs: async (mount: any, populate: Boolean, callback: Function) => {\n try {\n const local = nativeFSAsync.getLocalSet(mount);\n const remote = await nativeFSAsync.getRemoteSet(mount);\n const src = populate ? remote : local;\n const dst = populate ? local : remote;\n await nativeFSAsync.reconcile(mount, src, dst);\n callback(null);\n } catch (e) {\n callback(e);\n }\n },\n // Returns file set of emscripten's filesystem at the mountpoint.\n getLocalSet: (mount: any) => {\n let entries = Object.create(null);\n\n function isRealDir(p: string) {\n return p !== \".\" && p !== \"..\";\n }\n\n function toAbsolute(root: string) {\n return (p: string) => {\n return PATH.join2(root, p);\n };\n }\n\n let check = FS.readdir(mount.mountpoint)\n .filter(isRealDir)\n .map(toAbsolute(mount.mountpoint));\n\n while (check.length) {\n let path = check.pop();\n let stat = FS.stat(path);\n\n if (FS.isDir(stat.mode)) {\n check.push.apply(\n check,\n FS.readdir(path).filter(isRealDir).map(toAbsolute(path)),\n );\n }\n\n entries[path] = { timestamp: stat.mtime, mode: stat.mode };\n }\n\n return { type: \"local\", entries: entries };\n },\n // Returns file set of the real, on-disk filesystem at the mountpoint.\n getRemoteSet: async (mount: any) => {\n // TODO: this should be a map.\n const entries = Object.create(null);\n\n const handles = await getFsHandles(mount.opts.fileSystemHandle);\n for (const [path, handle] of handles) {\n if (path === \".\") continue;\n\n entries[PATH.join2(mount.mountpoint, path)] = {\n timestamp:\n handle.kind === \"file\"\n ? new Date((await handle.getFile()).lastModified)\n : new Date(),\n mode:\n handle.kind === \"file\"\n ? nativeFSAsync.FILE_MODE\n : nativeFSAsync.DIR_MODE,\n };\n }\n\n return { type: \"remote\", entries, handles };\n },\n loadLocalEntry: (path: string) => {\n const lookup = FS.lookupPath(path, {});\n const node = lookup.node;\n const stat = FS.stat(path);\n\n if (FS.isDir(stat.mode)) {\n return { timestamp: stat.mtime, mode: stat.mode };\n } else if (FS.isFile(stat.mode)) {\n node.contents = MEMFS.getFileDataAsTypedArray(node);\n return {\n timestamp: stat.mtime,\n mode: stat.mode,\n contents: node.contents,\n };\n } else {\n throw new Error(\"node type not supported\");\n }\n },\n storeLocalEntry: (path: string, entry: any) => {\n if (FS.isDir(entry[\"mode\"])) {\n FS.mkdirTree(path, entry[\"mode\"]);\n } else if (FS.isFile(entry[\"mode\"])) {\n FS.writeFile(path, entry[\"contents\"], { canOwn: true });\n } else {\n throw new Error(\"node type not supported\");\n }\n\n FS.chmod(path, entry[\"mode\"]);\n FS.utime(path, entry[\"timestamp\"], entry[\"timestamp\"]);\n },\n removeLocalEntry: (path: string) => {\n var stat = FS.stat(path);\n\n if (FS.isDir(stat.mode)) {\n FS.rmdir(path);\n } else if (FS.isFile(stat.mode)) {\n FS.unlink(path);\n }\n },\n loadRemoteEntry: async (handle: any) => {\n if (handle.kind === \"file\") {\n const file = await handle.getFile();\n return {\n contents: new Uint8Array(await file.arrayBuffer()),\n mode: nativeFSAsync.FILE_MODE,\n timestamp: new Date(file.lastModified),\n };\n } else if (handle.kind === \"directory\") {\n return {\n mode: nativeFSAsync.DIR_MODE,\n timestamp: new Date(),\n };\n } else {\n throw new Error(\"unknown kind: \" + handle.kind);\n }\n },\n storeRemoteEntry: async (handles: any, path: string, entry: any) => {\n const parentDirHandle = handles.get(PATH.dirname(path));\n const handle = FS.isFile(entry.mode)\n ? await parentDirHandle.getFileHandle(PATH.basename(path), {\n create: true,\n })\n : await parentDirHandle.getDirectoryHandle(PATH.basename(path), {\n create: true,\n });\n if (handle.kind === \"file\") {\n const writable = await handle.createWritable();\n await writable.write(entry.contents);\n await writable.close();\n }\n handles.set(path, handle);\n },\n removeRemoteEntry: async (handles: any, path: string) => {\n const parentDirHandle = handles.get(PATH.dirname(path));\n await parentDirHandle.removeEntry(PATH.basename(path));\n handles.delete(path);\n },\n reconcile: async (mount: any, src: any, dst: any) => {\n let total = 0;\n\n const create: Array<string> = [];\n Object.keys(src.entries).forEach(function (key) {\n const e = src.entries[key];\n const e2 = dst.entries[key];\n if (\n !e2 ||\n (FS.isFile(e.mode) &&\n e[\"timestamp\"].getTime() > e2[\"timestamp\"].getTime())\n ) {\n create.push(key);\n total++;\n }\n });\n // sort paths in ascending order so directory entries are created\n // before the files inside them\n create.sort();\n\n const remove: Array<string> = [];\n Object.keys(dst.entries).forEach(function (key) {\n if (!src.entries[key]) {\n remove.push(key);\n total++;\n }\n });\n // sort paths in descending order so files are deleted before their\n // parent directories\n remove.sort().reverse();\n\n if (!total) {\n return;\n }\n\n const handles = src.type === \"remote\" ? src.handles : dst.handles;\n\n for (const path of create) {\n const relPath = PATH.normalize(\n path.replace(mount.mountpoint, \"/\"),\n ).substring(1);\n if (dst.type === \"local\") {\n const handle = handles.get(relPath);\n const entry = await nativeFSAsync.loadRemoteEntry(handle);\n nativeFSAsync.storeLocalEntry(path, entry);\n } else {\n const entry = nativeFSAsync.loadLocalEntry(path);\n await nativeFSAsync.storeRemoteEntry(handles, relPath, entry);\n }\n }\n\n for (const path of remove) {\n if (dst.type === \"local\") {\n nativeFSAsync.removeLocalEntry(path);\n } else {\n const relPath = PATH.normalize(\n path.replace(mount.mountpoint, \"/\"),\n ).substring(1);\n await nativeFSAsync.removeRemoteEntry(handles, relPath);\n }\n }\n },\n };\n\n module.FS.filesystems.NATIVEFS_ASYNC = nativeFSAsync;\n}\n\nconst getFsHandles = async (dirHandle: any) => {\n const handles: any = [];\n\n async function collect(curDirHandle: any) {\n for await (const entry of curDirHandle.values()) {\n handles.push(entry);\n if (entry.kind === \"directory\") {\n await collect(entry);\n }\n }\n }\n\n await collect(dirHandle);\n\n const result = new Map();\n result.set(\".\", dirHandle);\n for (const handle of handles) {\n const relativePath = (await dirHandle.resolve(handle)).join(\"/\");\n result.set(relativePath, handle);\n }\n return result;\n};\n", "// @ts-ignore Can't find sentinel.wasm or it's corresponding type declarations\nimport sentinelWasm from \"./sentinel.wasm\";\n\ndeclare const sentinelWasm: Uint8Array;\n\nconst sentinelInstancePromise: Promise<WebAssembly.Instance | undefined> =\n (async function () {\n // Starting with iOS 18.3.1, WebKit on iOS has an issue with the garbage\n // collector that breaks the call trampoline. See #130418 and\n // https://bugs.webkit.org/show_bug.cgi?id=293113 for details.\n let isIOS =\n globalThis.navigator &&\n (/iPad|iPhone|iPod/.test(navigator.userAgent) ||\n // Starting with iPadOS 13, iPads might send a platform string that looks like a desktop Mac.\n // To differentiate, we check if the platform is 'MacIntel' (common for Macs and newer iPads)\n // AND if the device has multi-touch capabilities (navigator.maxTouchPoints > 1)\n (navigator.platform === \"MacIntel\" &&\n typeof navigator.maxTouchPoints !== \"undefined\" &&\n navigator.maxTouchPoints > 1));\n if (isIOS) {\n return undefined;\n }\n try {\n const module = await WebAssembly.compile(sentinelWasm);\n return await WebAssembly.instantiate(module);\n } catch (e) {\n if (e instanceof WebAssembly.CompileError) {\n return undefined;\n }\n throw e;\n }\n })();\n\ntype SentinelInstance<T> = {\n create_sentinel: () => T;\n is_sentinel: (val: any) => val is T;\n};\n\n/**\n * @private\n */\nexport async function getSentinelImport(): Promise<SentinelInstance<Symbol>> {\n const sentinelInstance = await sentinelInstancePromise;\n if (sentinelInstance) {\n return sentinelInstance.exports as SentinelInstance<Symbol>;\n }\n const error_marker = Symbol(\"error marker\");\n return {\n create_sentinel: () => error_marker,\n is_sentinel: (val: any): val is typeof error_marker => val === error_marker,\n };\n}\n", "/** @private */\n\nimport { PyodideConfigWithDefaults } from \"./pyodide\";\nimport { initializeNativeFS } from \"./nativefs\";\nimport { loadBinaryFile, getBinaryResponse } from \"./compat\";\nimport { API, PreRunFunc, type PyodideModule, type FSType } from \"./types\";\nimport { getSentinelImport } from \"generated/sentinel\";\nimport { RUNTIME_ENV } from \"./environments\";\n\n/**\n * @private\n * @hidden\n */\nexport interface EmscriptenSettings {\n readonly noImageDecoding?: boolean;\n readonly noAudioDecoding?: boolean;\n readonly noWasmDecoding?: boolean;\n readonly preRun: readonly PreRunFunc[];\n readonly print?: (a: string) => void;\n readonly printErr?: (a: string) => void;\n readonly onExit?: (code: number) => void;\n readonly thisProgram?: string;\n readonly arguments: readonly string[];\n readonly instantiateWasm?: (\n imports: { [key: string]: any },\n successCallback: (\n instance: WebAssembly.Instance,\n module: WebAssembly.Module,\n ) => void,\n ) => void;\n readonly API: API;\n readonly locateFile: (file: string) => string;\n\n noInitialRun?: boolean;\n INITIAL_MEMORY?: number;\n exitCode?: number;\n}\n\n/**\n * Get the base settings to use to load Pyodide.\n *\n * @private\n */\nexport function createSettings(\n config: PyodideConfigWithDefaults,\n): EmscriptenSettings {\n const API = { config, runtimeEnv: RUNTIME_ENV } as API;\n const settings: EmscriptenSettings = {\n noImageDecoding: true,\n noAudioDecoding: true,\n noWasmDecoding: false,\n preRun: getFileSystemInitializationFuncs(config),\n print: config.stdout,\n printErr: config.stderr,\n onExit(code) {\n settings.exitCode = code;\n },\n thisProgram: config._sysExecutable,\n arguments: config.args,\n API,\n // Emscripten calls locateFile exactly one time with argument\n // pyodide.asm.wasm to get the URL it should download it from.\n //\n // If we set instantiateWasm the return value of locateFile actually is\n // unused, but Emscripten calls it anyways. We set instantiateWasm except\n // when compiling with source maps, see comment in getInstantiateWasmFunc().\n //\n // It also is called when Emscripten tries to find a dependency of a shared\n // library but it failed to find it in the file system. But for us that\n // means dependency resolution has already failed and we want to throw an\n // error anyways.\n locateFile: (path: string) => config.indexURL + path,\n instantiateWasm: getInstantiateWasmFunc(config.indexURL),\n };\n return settings;\n}\n\n/**\n * Make the home directory inside the virtual file system,\n * then change the working directory to it.\n *\n * @param Module The Emscripten Module.\n * @param path The path to the home directory.\n * @private\n */\nfunction createHomeDirectory(path: string): PreRunFunc {\n return function (Module) {\n const fallbackPath = \"/\";\n try {\n Module.FS.mkdirTree(path);\n } catch (e) {\n console.error(`Error occurred while making a home directory '${path}':`);\n console.error(e);\n console.error(`Using '${fallbackPath}' for a home directory instead`);\n path = fallbackPath;\n }\n Module.FS.chdir(path);\n };\n}\n\nfunction setEnvironment(env: { [key: string]: string }): PreRunFunc {\n return function (Module) {\n Object.assign(Module.ENV, env);\n };\n}\n\n/**\n * Mount local directories to the virtual file system. Only for Node.js.\n * @param mounts The list of paths to mount.\n */\nfunction callFsInitHook(\n fsInit: undefined | ((fs: FSType, info: { sitePackages: string }) => void),\n): PreRunFunc[] {\n if (!fsInit) {\n return [];\n }\n return [\n async (Module) => {\n Module.addRunDependency(\"fsInitHook\");\n try {\n await fsInit(Module.FS, { sitePackages: Module.API.sitePackages });\n } finally {\n Module.removeRunDependency(\"fsInitHook\");\n }\n },\n ];\n}\n\nfunction computeVersionTuple(Module: PyodideModule): [number, number, number] {\n const versionInt = Module.HEAPU32[Module._Py_Version >>> 2];\n const major = (versionInt >>> 24) & 0xff;\n const minor = (versionInt >>> 16) & 0xff;\n const micro = (versionInt >>> 8) & 0xff;\n return [major, minor, micro];\n}\n/**\n * Install the Python standard library to the virtual file system.\n *\n * Previously, this was handled by Emscripten's file packager (pyodide.asm.data).\n * However, using the file packager means that we have only one version\n * of the standard library available. We want to be able to use different\n * versions of the standard library, for example:\n *\n * - Use compiled(.pyc) or uncompiled(.py) standard library.\n * - Remove unused modules or add additional modules using bundlers like pyodide-pack.\n *\n * @param stdlibURL The URL for the Python standard library\n */\nfunction installStdlib(stdlibURL: string): PreRunFunc {\n const stdlibPromise: Promise<Uint8Array> = loadBinaryFile(stdlibURL);\n return async (Module: PyodideModule) => {\n Module.API.pyVersionTuple = computeVersionTuple(Module);\n const [pymajor, pyminor] = Module.API.pyVersionTuple;\n Module.FS.mkdirTree(\"/lib\");\n Module.API.sitePackages = `/lib/python${pymajor}.${pyminor}/site-packages`;\n Module.FS.mkdirTree(Module.API.sitePackages);\n Module.addRunDependency(\"install-stdlib\");\n\n try {\n const stdlib = await stdlibPromise;\n Module.FS.writeFile(`/lib/python${pymajor}${pyminor}.zip`, stdlib);\n } catch (e) {\n console.error(\"Error occurred while installing the standard library:\");\n console.error(e);\n } finally {\n Module.removeRunDependency(\"install-stdlib\");\n }\n };\n}\n\n/**\n * Initialize the virtual file system, before loading Python interpreter.\n * @private\n */\nfunction getFileSystemInitializationFuncs(\n config: PyodideConfigWithDefaults,\n): PreRunFunc[] {\n let stdLibURL;\n if (config.stdLibURL != undefined) {\n stdLibURL = config.stdLibURL;\n } else {\n stdLibURL = config.indexURL + \"python_stdlib.zip\";\n }\n\n return [\n installStdlib(stdLibURL),\n createHomeDirectory(config.env.HOME),\n setEnvironment(config.env),\n initializeNativeFS,\n ...callFsInitHook(config.fsInit),\n ];\n}\n\nfunction getInstantiateWasmFunc(\n indexURL: string,\n): EmscriptenSettings[\"instantiateWasm\"] {\n // @ts-ignore\n if (SOURCEMAP || typeof WasmOffsetConverter !== \"undefined\") {\n // According to the docs:\n //\n // \"Sanitizers or source map is currently not supported if overriding\n // WebAssembly instantiation with Module.instantiateWasm.\"\n // https://emscripten.org/docs/api_reference/module.html?highlight=instantiatewasm#Module.instantiateWasm\n //\n // typeof WasmOffsetConverter !== \"undefined\" checks for asan.\n return;\n }\n const { binary, response } = getBinaryResponse(indexURL + \"pyodide.asm.wasm\");\n const sentinelImportPromise = getSentinelImport();\n return function (\n imports: { [key: string]: { [key: string]: any } },\n successCallback: (\n instance: WebAssembly.Instance,\n module: WebAssembly.Module,\n ) => void,\n ) {\n (async function () {\n imports.sentinel = await sentinelImportPromise;\n try {\n let res: WebAssembly.WebAssemblyInstantiatedSource;\n if (response) {\n res = await WebAssembly.instantiateStreaming(response, imports);\n } else {\n res = await WebAssembly.instantiate(await binary, imports);\n }\n const { instance, module } = res;\n successCallback(instance, module);\n } catch (e) {\n console.warn(\"wasm instantiation failed!\");\n console.warn(e);\n }\n })();\n\n return {}; // Compiling asynchronously, no exports.\n };\n}\n", "/**\n *\n * The Pyodide version.\n *\n * The version here is a Python version, following :pep:`440`. This is different\n * from the version in ``package.json`` which follows the node package manager\n * version convention.\n */\nexport const version: string = \"0.29.0\";\n", "/**\n * @hidden\n */\nexport function withTrailingSlash<T extends string | undefined>(path: T): T {\n if (path === undefined) {\n return path;\n }\n\n if (path.endsWith(\"/\")) {\n return path;\n }\n return (path + \"/\") as T;\n}\n", "/**\n * The main bootstrap code for loading pyodide.\n */\nimport {\n calculateDirname,\n loadScript,\n initNodeModules,\n resolvePath,\n loadLockFile,\n calculateInstallBaseUrl,\n} from \"./compat\";\n\nimport { createSettings } from \"./emscripten-settings\";\nimport { version as version_ } from \"./version\";\n\nimport type { PyodideAPI } from \"./api.js\";\nimport type {\n TypedArray,\n PyodideModule,\n PackageData,\n FSType,\n Lockfile,\n} from \"./types\";\nimport type { EmscriptenSettings } from \"./emscripten-settings\";\nimport type { SnapshotConfig } from \"./snapshot\";\nimport { withTrailingSlash } from \"./common/path\";\nexport type { PyodideAPI, TypedArray, PyodideAPI as PyodideInterface };\nexport type { LockfileInfo, LockfilePackage, Lockfile } from \"./types\";\n\nexport { type PackageData };\n\n/**\n * The Pyodide version.\n *\n * The version here is a Python version, following :pep:`440`. This is different\n * from the version in ``package.json`` which follows the node package manager\n * version convention.\n */\nexport const version: string = version_;\n\ndeclare function _createPyodideModule(\n settings: EmscriptenSettings,\n): Promise<PyodideModule>;\n\n// BUILD_ID is generated from hashing together pyodide.asm.js and\n// pyodide.asm.wasm in esbuild.config.outer.mjs\n//\n// It is used to check that memory snapshots were generated by the same build of\n// the runtime that is trying to use them. Attempting to use a snapshot from a\n// different build will fail badly. See logic in snapshot.ts.\ndeclare const BUILD_ID: string;\n\n/**\n * The configuration options for loading Pyodide.\n */\nexport interface PyodideConfig {\n /**\n * The URL from which Pyodide will load the main Pyodide runtime and\n * packages. It is recommended that you leave this unchanged, providing an\n * incorrect value can cause broken behavior.\n *\n * Default: The url that Pyodide is loaded from with the file name\n * (``pyodide.js`` or ``pyodide.mjs``) removed.\n */\n indexURL?: string;\n /**\n * The file path where packages will be cached in node. If a package\n * exists in ``packageCacheDir`` it is loaded from there, otherwise it is\n * downloaded from the JsDelivr CDN and then cached into ``packageCacheDir``.\n * Only applies when running in node; ignored in browsers.\n *\n * Default: same as indexURL\n */\n packageCacheDir?: string;\n\n /**\n * The URL from which Pyodide will load the Pyodide ``pyodide-lock.json`` lock\n * file. You can produce custom lock files with :py:func:`micropip.freeze`.\n * Default: ```${indexURL}/pyodide-lock.json```\n */\n lockFileURL?: string;\n /**\n * The contents of a lockfile. If a string, it should be valid json and\n * ``JSON.parse()`` should return a ``Lockfile`` instance. See\n * :js:interface:`~pyodide.Lockfile` for the schema.\n */\n lockFileContents?: Lockfile | string | Promise<Lockfile | string>;\n /**\n * The base url relative to which a relative value of\n * :js:attr:`~pyodide.LockfilePackage.file_name` is interpreted. If\n * ``lockfileContents`` is provided, then ``lockFileContents`` must be\n * provided explicitly in order to install packages with relative paths.\n *\n * Otherwise, the default is calculated as follows:\n *\n * 1. If `lockFileURL` contains a ``/``, the default is everything before the last\n * ``/`` in ``lockFileURL``.\n * 2. If in the browser, the default is ``location.toString()``.\n * 3. Otherwise, the default is `'.'`.\n */\n packageBaseUrl?: string;\n /**\n * Load the full Python standard library. Setting this to false excludes\n * unvendored modules from the standard library.\n * Default: ``false``\n */\n fullStdLib?: boolean;\n /**\n * The URL from which to load the standard library ``python_stdlib.zip``\n * file. This URL includes the most of the Python standard library. Some\n * stdlib modules were unvendored, and can be loaded separately\n * with ``fullStdLib: true`` option or by their package name.\n * Default: ```${indexURL}/python_stdlib.zip```\n */\n stdLibURL?: string;\n /**\n * Override the standard input callback. Should ask the user for one line of\n * input. The :js:func:`pyodide.setStdin` function is more flexible and\n * should be preferred.\n */\n stdin?: () => string | null;\n /**\n * Override the standard output callback. The :js:func:`pyodide.setStdout`\n * function is more flexible and should be preferred in most cases, but\n * depending on the ``args`` passed to ``loadPyodide``, Pyodide may write to\n * stdout on startup, which can only be controlled by passing a custom\n * ``stdout`` function.\n */\n stdout?: (msg: string) => void;\n /**\n * Override the standard error output callback. The\n * :js:func:`pyodide.setStderr` function is more flexible and should be\n * preferred in most cases, but depending on the ``args`` passed to\n * ``loadPyodide``, Pyodide may write to stdout on startup, which can only\n * be controlled by passing a custom ``stdout`` function.\n */\n stderr?: (msg: string) => void;\n /**\n * The object that Pyodide will use for the ``js`` module.\n * Default: ``globalThis``\n */\n jsglobals?: objec