pyodide 0.26.4 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ffi.d.ts +4 -1
- package/package.json +7 -5
- package/pyodide-lock.json +1 -1
- package/pyodide.asm.js +1 -1
- package/pyodide.asm.wasm +0 -0
- package/pyodide.d.ts +92 -31
- package/pyodide.js +3 -3
- package/pyodide.js.map +2 -2
- package/pyodide.mjs +2 -2
- package/pyodide.mjs.map +2 -2
- package/python_stdlib.zip +0 -0
package/pyodide.asm.wasm
CHANGED
|
Binary file
|
package/pyodide.d.ts
CHANGED
|
@@ -37,6 +37,75 @@ declare function setStderr(options?: {
|
|
|
37
37
|
}): void;
|
|
38
38
|
/** @deprecated Use `import type { TypedArray } from "pyodide/ffi"` instead */
|
|
39
39
|
export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
|
|
40
|
+
type FSNode = {
|
|
41
|
+
timestamp: number;
|
|
42
|
+
rdev: number;
|
|
43
|
+
contents: Uint8Array;
|
|
44
|
+
mode: number;
|
|
45
|
+
};
|
|
46
|
+
type FSStream = {
|
|
47
|
+
tty?: boolean;
|
|
48
|
+
seekable?: boolean;
|
|
49
|
+
stream_ops: FSStreamOps;
|
|
50
|
+
node: FSNode;
|
|
51
|
+
};
|
|
52
|
+
type FSStreamOps = FSStreamOpsGen<FSStream>;
|
|
53
|
+
type FSStreamOpsGen<T> = {
|
|
54
|
+
open: (a: T) => void;
|
|
55
|
+
close: (a: T) => void;
|
|
56
|
+
fsync: (a: T) => void;
|
|
57
|
+
read: (a: T, b: Uint8Array, offset: number, length: number, pos: number) => number;
|
|
58
|
+
write: (a: T, b: Uint8Array, offset: number, length: number, pos: number) => number;
|
|
59
|
+
};
|
|
60
|
+
interface FS {
|
|
61
|
+
unlink: (path: string) => void;
|
|
62
|
+
mkdirTree: (path: string, mode?: number) => void;
|
|
63
|
+
chdir: (path: string) => void;
|
|
64
|
+
symlink: (target: string, src: string) => FSNode;
|
|
65
|
+
createDevice: ((parent: string, name: string, input?: (() => number | null) | null, output?: ((code: number) => void) | null) => FSNode) & {
|
|
66
|
+
major: number;
|
|
67
|
+
};
|
|
68
|
+
closeStream: (fd: number) => void;
|
|
69
|
+
open: (path: string, flags: string | number, mode?: number) => FSStream;
|
|
70
|
+
makedev: (major: number, minor: number) => number;
|
|
71
|
+
mkdev: (path: string, dev: number) => FSNode;
|
|
72
|
+
filesystems: any;
|
|
73
|
+
stat: (path: string, dontFollow?: boolean) => any;
|
|
74
|
+
readdir: (path: string) => string[];
|
|
75
|
+
isDir: (mode: number) => boolean;
|
|
76
|
+
isMountpoint: (mode: FSNode) => boolean;
|
|
77
|
+
lookupPath: (path: string, options?: {
|
|
78
|
+
follow_mount?: boolean;
|
|
79
|
+
}) => {
|
|
80
|
+
node: FSNode;
|
|
81
|
+
};
|
|
82
|
+
isFile: (mode: number) => boolean;
|
|
83
|
+
writeFile: (path: string, contents: any, o?: {
|
|
84
|
+
canOwn?: boolean;
|
|
85
|
+
}) => void;
|
|
86
|
+
chmod: (path: string, mode: number) => void;
|
|
87
|
+
utime: (path: string, atime: number, mtime: number) => void;
|
|
88
|
+
rmdir: (path: string) => void;
|
|
89
|
+
mount: (type: any, opts: any, mountpoint: string) => any;
|
|
90
|
+
write: (stream: FSStream, buffer: any, offset: number, length: number, position?: number) => number;
|
|
91
|
+
close: (stream: FSStream) => void;
|
|
92
|
+
ErrnoError: {
|
|
93
|
+
new (errno: number): Error;
|
|
94
|
+
};
|
|
95
|
+
registerDevice<T>(dev: number, ops: FSStreamOpsGen<T>): void;
|
|
96
|
+
syncfs(dir: boolean, oncomplete: (val: void) => void): void;
|
|
97
|
+
findObject(a: string, dontResolveLastLink?: boolean): any;
|
|
98
|
+
readFile(a: string): Uint8Array;
|
|
99
|
+
}
|
|
100
|
+
type PackageType = "package" | "cpython_module" | "shared_library" | "static_library";
|
|
101
|
+
interface PackageData {
|
|
102
|
+
name: string;
|
|
103
|
+
version: string;
|
|
104
|
+
fileName: string;
|
|
105
|
+
/** @experimental */
|
|
106
|
+
packageType: PackageType;
|
|
107
|
+
}
|
|
108
|
+
type LoadedPackages = Record<string, string>;
|
|
40
109
|
/** @deprecated Use `import type { PyProxy } from "pyodide/ffi"` instead */
|
|
41
110
|
interface PyProxy {
|
|
42
111
|
[x: string]: any;
|
|
@@ -977,19 +1046,6 @@ declare class PyBufferView {
|
|
|
977
1046
|
*/
|
|
978
1047
|
release(): void;
|
|
979
1048
|
}
|
|
980
|
-
type PackageType = "package" | "cpython_module" | "shared_library" | "static_library";
|
|
981
|
-
interface PackageData {
|
|
982
|
-
name: string;
|
|
983
|
-
version: string;
|
|
984
|
-
fileName: string;
|
|
985
|
-
/** @experimental */
|
|
986
|
-
packageType: PackageType;
|
|
987
|
-
}
|
|
988
|
-
declare function loadPackage(names: string | PyProxy | Array<string>, options?: {
|
|
989
|
-
messageCallback?: (message: string) => void;
|
|
990
|
-
errorCallback?: (message: string) => void;
|
|
991
|
-
checkIntegrity?: boolean;
|
|
992
|
-
}): Promise<Array<PackageData>>;
|
|
993
1049
|
declare class PythonError extends Error {
|
|
994
1050
|
/**
|
|
995
1051
|
* The address of the error we are wrapping. We may later compare this
|
|
@@ -1013,11 +1069,13 @@ declare class PyodideAPI {
|
|
|
1013
1069
|
/** @hidden */
|
|
1014
1070
|
static version: string;
|
|
1015
1071
|
/** @hidden */
|
|
1016
|
-
static loadPackage:
|
|
1072
|
+
static loadPackage: (names: string | PyProxy | Array<string>, options?: {
|
|
1073
|
+
messageCallback?: (message: string) => void;
|
|
1074
|
+
errorCallback?: (message: string) => void;
|
|
1075
|
+
checkIntegrity?: boolean;
|
|
1076
|
+
}) => Promise<Array<PackageData>>;
|
|
1017
1077
|
/** @hidden */
|
|
1018
|
-
static loadedPackages:
|
|
1019
|
-
[key: string]: string;
|
|
1020
|
-
};
|
|
1078
|
+
static loadedPackages: LoadedPackages;
|
|
1021
1079
|
/** @hidden */
|
|
1022
1080
|
static ffi: {
|
|
1023
1081
|
PyProxy: typeof PyProxy;
|
|
@@ -1069,7 +1127,7 @@ declare class PyodideAPI {
|
|
|
1069
1127
|
* are available as members of ``FS.filesystems``:
|
|
1070
1128
|
* ``IDBFS``, ``NODEFS``, ``PROXYFS``, ``WORKERFS``.
|
|
1071
1129
|
*/
|
|
1072
|
-
static FS:
|
|
1130
|
+
static FS: FS;
|
|
1073
1131
|
/**
|
|
1074
1132
|
* An alias to the `Emscripten Path API
|
|
1075
1133
|
* <https://github.com/emscripten-core/emscripten/blob/main/src/library_path.js>`_.
|
|
@@ -1079,8 +1137,9 @@ declare class PyodideAPI {
|
|
|
1079
1137
|
*/
|
|
1080
1138
|
static PATH: any;
|
|
1081
1139
|
/**
|
|
1082
|
-
*
|
|
1083
|
-
* @
|
|
1140
|
+
* APIs to set a canvas for rendering graphics.
|
|
1141
|
+
* @summaryLink :ref:`canvas <js-api-pyodide-canvas>`
|
|
1142
|
+
* @omitFromAutoModule
|
|
1084
1143
|
*/
|
|
1085
1144
|
static canvas: CanvasInterface;
|
|
1086
1145
|
/**
|
|
@@ -1119,7 +1178,6 @@ declare class PyodideAPI {
|
|
|
1119
1178
|
* (optional)
|
|
1120
1179
|
* @param options.checkIntegrity If true, check the integrity of the downloaded
|
|
1121
1180
|
* packages (default: true)
|
|
1122
|
-
* @async
|
|
1123
1181
|
*/
|
|
1124
1182
|
static loadPackagesFromImports(code: string, options?: {
|
|
1125
1183
|
messageCallback?: (message: string) => void;
|
|
@@ -1203,7 +1261,6 @@ declare class PyodideAPI {
|
|
|
1203
1261
|
* traceback for any exception that is thrown will show source lines
|
|
1204
1262
|
* (unless the given file name starts with ``<`` and ends with ``>``).
|
|
1205
1263
|
* @returns The result of the Python code translated to JavaScript.
|
|
1206
|
-
* @async
|
|
1207
1264
|
*/
|
|
1208
1265
|
static runPythonAsync(code: string, options?: {
|
|
1209
1266
|
globals?: PyProxy;
|
|
@@ -1385,7 +1442,14 @@ declare class PyodideAPI {
|
|
|
1385
1442
|
* @returns The old value of the debug flag.
|
|
1386
1443
|
*/
|
|
1387
1444
|
static setDebug(debug: boolean): boolean;
|
|
1388
|
-
|
|
1445
|
+
/**
|
|
1446
|
+
*
|
|
1447
|
+
* @param param0
|
|
1448
|
+
* @returns
|
|
1449
|
+
*/
|
|
1450
|
+
static makeMemorySnapshot({ serializer, }?: {
|
|
1451
|
+
serializer?: (obj: any) => any;
|
|
1452
|
+
}): Uint8Array;
|
|
1389
1453
|
}
|
|
1390
1454
|
/** @hidden */
|
|
1391
1455
|
export type PyodideInterface = typeof PyodideAPI;
|
|
@@ -1412,13 +1476,12 @@ type ConfigType = {
|
|
|
1412
1476
|
_makeSnapshot: boolean;
|
|
1413
1477
|
enableRunUntilComplete: boolean;
|
|
1414
1478
|
checkAPIVersion: boolean;
|
|
1479
|
+
BUILD_ID: string;
|
|
1415
1480
|
};
|
|
1416
1481
|
/**
|
|
1417
1482
|
* Load the main Pyodide wasm module and initialize it.
|
|
1418
1483
|
*
|
|
1419
1484
|
* @returns The :ref:`js-api-pyodide` module.
|
|
1420
|
-
* @memberof globalThis
|
|
1421
|
-
* @async
|
|
1422
1485
|
* @example
|
|
1423
1486
|
* async function main() {
|
|
1424
1487
|
* const pyodide = await loadPyodide({
|
|
@@ -1547,14 +1610,12 @@ export declare function loadPyodide(options?: {
|
|
|
1547
1610
|
* @ignore
|
|
1548
1611
|
*/
|
|
1549
1612
|
_node_mounts?: string[];
|
|
1550
|
-
/**
|
|
1551
|
-
* @ignore
|
|
1552
|
-
*/
|
|
1613
|
+
/** @ignore */
|
|
1553
1614
|
_makeSnapshot?: boolean;
|
|
1554
|
-
/**
|
|
1555
|
-
* @ignore
|
|
1556
|
-
*/
|
|
1615
|
+
/** @ignore */
|
|
1557
1616
|
_loadSnapshot?: Uint8Array | ArrayBuffer | PromiseLike<Uint8Array | ArrayBuffer>;
|
|
1617
|
+
/** @ignore */
|
|
1618
|
+
_snapshotDeserializer?: (obj: any) => any;
|
|
1558
1619
|
}): Promise<PyodideInterface>;
|
|
1559
1620
|
|
|
1560
1621
|
export type {};
|
package/pyodide.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var loadPyodide=(()=>{var ne=Object.create;var
|
|
2
|
-
`).filter(function(n){return!!n.match(e)},this);return a.map(function(n){n.indexOf("(eval ")>-1&&(n=n.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var
|
|
3
|
-
`).filter(function(n){return!n.match(t)},this);return a.map(function(n){if(n.indexOf(" > eval")>-1&&(n=n.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),n.indexOf("@")===-1&&n.indexOf(":")===-1)return new A({functionName:n});var i=/((.*".+"[^@]*)?[^@]*)(?:@)/,s=n.match(i),l=s&&s[1]?s[1]:void 0,d=this.extractLocation(n.replace(i,""));return new A({functionName:l,fileName:d[0],lineNumber:d[1],columnNumber:d[2],source:n})},this)},"ErrorStackParser$$parseFFOrSafari")}}c(fe,"ErrorStackParser");var me=new fe;var j=me;var y=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!process.browser,T=y&&typeof module<"u"&&typeof module.exports<"u"&&typeof p<"u"&&typeof __dirname<"u",H=y&&!T,Le=typeof globalThis.Bun<"u",pe=typeof Deno<"u",V=!y&&!pe,z=V&&typeof window=="object"&&typeof document=="object"&&typeof document.createElement=="function"&&"sessionStorage"in window&&typeof importScripts!="function",q=V&&typeof importScripts=="function"&&typeof self=="object",Te=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Chrome")==-1&&navigator.userAgent.indexOf("Safari")>-1;var K,U,Y,J,C;async function M(){if(!y||(K=(await import(/* webpackIgnore */"node:url")).default,J=await import(/* webpackIgnore */"node:fs"),C=await import(/* webpackIgnore */"node:fs/promises"),Y=(await import(/* webpackIgnore */"node:vm")).default,U=await import(/* webpackIgnore */"node:path"),W=U.sep,typeof p<"u"))return;let e=J,t=await import(/* webpackIgnore */"node:crypto"),o=await import(/* webpackIgnore */"ws"),r=await import(/* webpackIgnore */"node:child_process"),a={fs:e,crypto:t,ws:o,child_process:r};globalThis.require=function(n){return a[n]}}c(M,"initNodeModules");function ge(e,t){return U.resolve(t||".",e)}c(ge,"node_resolvePath");function ye(e,t){return t===void 0&&(t=location),new URL(e,t).toString()}c(ye,"browser_resolvePath");var D;y?D=ge:D=ye;var W;y||(W="/");function be(e,t){return e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?{response:fetch(e)}:{binary:C.readFile(e).then(o=>new Uint8Array(o.buffer,o.byteOffset,o.byteLength))}}c(be,"node_getBinaryResponse");function ve(e,t){let o=new URL(e,location);return{response:fetch(o,t?{integrity:t}:{})}}c(ve,"browser_getBinaryResponse");var P;y?P=be:P=ve;async function G(e,t){let{response:o,binary:r}=P(e,t);if(r)return r;let a=await o;if(!a.ok)throw new Error(`Failed to load '${e}': request failed.`);return new Uint8Array(await a.arrayBuffer())}c(G,"loadBinaryFile");var I;if(z)I=c(async e=>await import(/* webpackIgnore */e),"loadScript");else if(q)I=c(async e=>{try{globalThis.importScripts(e)}catch(t){if(t instanceof TypeError)await import(/* webpackIgnore */e);else throw t}},"loadScript");else if(y)I=he;else throw new Error("Cannot determine runtime environment");async function he(e){e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?Y.runInThisContext(await(await fetch(e)).text()):await import(/* webpackIgnore */K.pathToFileURL(e).href)}c(he,"nodeLoadScript");async function X(e){if(y){await M();let t=await C.readFile(e,{encoding:"utf8"});return JSON.parse(t)}else return await(await fetch(e)).json()}c(X,"loadLockFile");async function Q(){if(T)return __dirname;let e;try{throw new Error}catch(r){e=r}let t=j.parse(e)[0].fileName;if(y&&!t.startsWith("file://")&&(t=`file://${t}`),H){let r=await import(/* webpackIgnore */"node:path");return(await import(/* webpackIgnore */"node:url")).fileURLToPath(r.dirname(t))}let o=t.lastIndexOf(W);if(o===-1)throw new Error("Could not extract indexURL path from pyodide module location");return t.slice(0,o)}c(Q,"calculateDirname");function Z(e){let t=e.FS,o=e.FS.filesystems.MEMFS,r=e.PATH,a={DIR_MODE:16895,FILE_MODE:33279,mount:function(n){if(!n.opts.fileSystemHandle)throw new Error("opts.fileSystemHandle is required");return o.mount.apply(null,arguments)},syncfs:async(n,i,s)=>{try{let l=a.getLocalSet(n),d=await a.getRemoteSet(n),u=i?d:l,m=i?l:d;await a.reconcile(n,u,m),s(null)}catch(l){s(l)}},getLocalSet:n=>{let i=Object.create(null);function s(u){return u!=="."&&u!==".."}c(s,"isRealDir");function l(u){return m=>r.join2(u,m)}c(l,"toAbsolute");let d=t.readdir(n.mountpoint).filter(s).map(l(n.mountpoint));for(;d.length;){let u=d.pop(),m=t.stat(u);t.isDir(m.mode)&&d.push.apply(d,t.readdir(u).filter(s).map(l(u))),i[u]={timestamp:m.mtime,mode:m.mode}}return{type:"local",entries:i}},getRemoteSet:async n=>{let i=Object.create(null),s=await Ee(n.opts.fileSystemHandle);for(let[l,d]of s)l!=="."&&(i[r.join2(n.mountpoint,l)]={timestamp:d.kind==="file"?(await d.getFile()).lastModifiedDate:new Date,mode:d.kind==="file"?a.FILE_MODE:a.DIR_MODE});return{type:"remote",entries:i,handles:s}},loadLocalEntry:n=>{let s=t.lookupPath(n).node,l=t.stat(n);if(t.isDir(l.mode))return{timestamp:l.mtime,mode:l.mode};if(t.isFile(l.mode))return s.contents=o.getFileDataAsTypedArray(s),{timestamp:l.mtime,mode:l.mode,contents:s.contents};throw new Error("node type not supported")},storeLocalEntry:(n,i)=>{if(t.isDir(i.mode))t.mkdirTree(n,i.mode);else if(t.isFile(i.mode))t.writeFile(n,i.contents,{canOwn:!0});else throw new Error("node type not supported");t.chmod(n,i.mode),t.utime(n,i.timestamp,i.timestamp)},removeLocalEntry:n=>{var i=t.stat(n);t.isDir(i.mode)?t.rmdir(n):t.isFile(i.mode)&&t.unlink(n)},loadRemoteEntry:async n=>{if(n.kind==="file"){let i=await n.getFile();return{contents:new Uint8Array(await i.arrayBuffer()),mode:a.FILE_MODE,timestamp:i.lastModifiedDate}}else{if(n.kind==="directory")return{mode:a.DIR_MODE,timestamp:new Date};throw new Error("unknown kind: "+n.kind)}},storeRemoteEntry:async(n,i,s)=>{let l=n.get(r.dirname(i)),d=t.isFile(s.mode)?await l.getFileHandle(r.basename(i),{create:!0}):await l.getDirectoryHandle(r.basename(i),{create:!0});if(d.kind==="file"){let u=await d.createWritable();await u.write(s.contents),await u.close()}n.set(i,d)},removeRemoteEntry:async(n,i)=>{await n.get(r.dirname(i)).removeEntry(r.basename(i)),n.delete(i)},reconcile:async(n,i,s)=>{let l=0,d=[];Object.keys(i.entries).forEach(function(f){let v=i.entries[f],N=s.entries[f];(!N||t.isFile(v.mode)&&v.timestamp.getTime()>N.timestamp.getTime())&&(d.push(f),l++)}),d.sort();let u=[];if(Object.keys(s.entries).forEach(function(f){i.entries[f]||(u.push(f),l++)}),u.sort().reverse(),!l)return;let m=i.type==="remote"?i.handles:s.handles;for(let f of d){let v=r.normalize(f.replace(n.mountpoint,"/")).substring(1);if(s.type==="local"){let N=m.get(v),te=await a.loadRemoteEntry(N);a.storeLocalEntry(f,te)}else{let N=a.loadLocalEntry(f);await a.storeRemoteEntry(m,v,N)}}for(let f of u)if(s.type==="local")a.removeLocalEntry(f);else{let v=r.normalize(f.replace(n.mountpoint,"/")).substring(1);await a.removeRemoteEntry(m,v)}}};e.FS.filesystems.NATIVEFS_ASYNC=a}c(Z,"initializeNativeFS");var Ee=c(async e=>{let t=[];async function o(a){for await(let n of a.values())t.push(n),n.kind==="directory"&&await o(n)}c(o,"collect"),await o(e);let r=new Map;r.set(".",e);for(let a of t){let n=(await e.resolve(a)).join("/");r.set(n,a)}return r},"getFsHandles");function ee(e){let t={noImageDecoding:!0,noAudioDecoding:!0,noWasmDecoding:!1,preRun:Fe(e),quit(o,r){throw t.exited={status:o,toThrow:r},r},print:e.stdout,printErr:e.stderr,arguments:e.args,API:{config:e},locateFile:o=>e.indexURL+o,instantiateWasm:Re(e.indexURL)};return t}c(ee,"createSettings");function Se(e){return function(t){let o="/";try{t.FS.mkdirTree(e)}catch(r){console.error(`Error occurred while making a home directory '${e}':`),console.error(r),console.error(`Using '${o}' for a home directory instead`),e=o}t.FS.chdir(e)}}c(Se,"createHomeDirectory");function we(e){return function(t){Object.assign(t.ENV,e)}}c(we,"setEnvironment");function Ne(e){return t=>{for(let o of e)t.FS.mkdirTree(o),t.FS.mount(t.FS.filesystems.NODEFS,{root:o},o)}}c(Ne,"mountLocalDirectories");function _e(e){let t=G(e);return o=>{let r=o._py_version_major(),a=o._py_version_minor();o.FS.mkdirTree("/lib"),o.FS.mkdirTree(`/lib/python${r}.${a}/site-packages`),o.addRunDependency("install-stdlib"),t.then(n=>{o.FS.writeFile(`/lib/python${r}${a}.zip`,n)}).catch(n=>{console.error("Error occurred while installing the standard library:"),console.error(n)}).finally(()=>{o.removeRunDependency("install-stdlib")})}}c(_e,"installStdlib");function Fe(e){let t;return e.stdLibURL!=null?t=e.stdLibURL:t=e.indexURL+"python_stdlib.zip",[_e(t),Se(e.env.HOME),we(e.env),Ne(e._node_mounts),Z]}c(Fe,"getFileSystemInitializationFuncs");function Re(e){let{binary:t,response:o}=P(e+"pyodide.asm.wasm");return function(r,a){return async function(){try{let n;o?n=await WebAssembly.instantiateStreaming(o,r):n=await WebAssembly.instantiate(await t,r);let{instance:i,module:s}=n;typeof WasmOffsetConverter<"u"&&(wasmOffsetConverter=new WasmOffsetConverter(wasmBinary,s)),a(i,s)}catch(n){console.warn("wasm instantiation failed!"),console.warn(n)}}(),{}}}c(Re,"getInstantiateWasmFunc");var k="0.26.4";async function B(e={}){var u,m;await M();let t=e.indexURL||await Q();t=D(t),t.endsWith("/")||(t+="/"),e.indexURL=t;let o={fullStdLib:!1,jsglobals:globalThis,stdin:globalThis.prompt?globalThis.prompt:void 0,lockFileURL:t+"pyodide-lock.json",args:[],_node_mounts:[],env:{},packageCacheDir:t,packages:[],enableRunUntilComplete:!1,checkAPIVersion:!0},r=Object.assign(o,e);(u=r.env).HOME??(u.HOME="/home/pyodide"),(m=r.env).PYTHONINSPECT??(m.PYTHONINSPECT="1");let a=ee(r),n=a.API;if(n.lockFilePromise=X(r.lockFileURL),typeof _createPyodideModule!="function"){let f=`${r.indexURL}pyodide.asm.js`;await I(f)}let i;if(e._loadSnapshot){let f=await e._loadSnapshot;ArrayBuffer.isView(f)?i=f:i=new Uint8Array(f),a.noInitialRun=!0,a.INITIAL_MEMORY=i.length}let s=await _createPyodideModule(a);if(a.exited)throw a.exited.toThrow;if(e.pyproxyToStringRepr&&n.setPyProxyToStringMethod(!0),n.version!==k&&r.checkAPIVersion)throw new Error(`Pyodide version does not match: '${k}' <==> '${n.version}'. If you updated the Pyodide version, make sure you also updated the 'indexURL' parameter passed to loadPyodide.`);s.locateFile=f=>{throw new Error("Didn't expect to load any more file_packager files!")};let l;i&&(l=n.restoreSnapshot(i));let d=n.finalizeBootstrap(l);return n.sys.path.insert(0,n.config.env.HOME),d.version.includes("dev")||n.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${d.version}/full/`),n._pyodide.set_excepthook(),await n.packageIndexReady,n.initializeStreams(r.stdin,r.stdout,r.stderr),d}c(B,"loadPyodide");globalThis.loadPyodide=B;return ce(Oe);})();
|
|
1
|
+
"use strict";var loadPyodide=(()=>{var ne=Object.create;var I=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var c=(e,t)=>I(e,"name",{value:t,configurable:!0}),p=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var se=(e,t)=>{for(var i in t)I(e,i,{get:t[i],enumerable:!0})},$=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ie(t))!ae.call(e,a)&&a!==i&&I(e,a,{get:()=>t[a],enumerable:!(r=re(t,a))||r.enumerable});return e};var b=(e,t,i)=>(i=e!=null?ne(oe(e)):{},$(t||!e||!e.__esModule?I(i,"default",{value:e,enumerable:!0}):i,e)),ce=e=>$(I({},"__esModule",{value:!0}),e);var Ie={};se(Ie,{loadPyodide:()=>B,version:()=>x});function le(e){return!isNaN(parseFloat(e))&&isFinite(e)}c(le,"_isNumber");function w(e){return e.charAt(0).toUpperCase()+e.substring(1)}c(w,"_capitalize");function L(e){return function(){return this[e]}}c(L,"_getter");var _=["isConstructor","isEval","isNative","isToplevel"],F=["columnNumber","lineNumber"],R=["fileName","functionName","source"],de=["args"],ue=["evalOrigin"],k=_.concat(F,R,de,ue);function g(e){if(e)for(var t=0;t<k.length;t++)e[k[t]]!==void 0&&this["set"+w(k[t])](e[k[t]])}c(g,"StackFrame");g.prototype={getArgs:function(){return this.args},setArgs:function(e){if(Object.prototype.toString.call(e)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=e},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(e){if(e instanceof g)this.evalOrigin=e;else if(e instanceof Object)this.evalOrigin=new g(e);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var e=this.getFileName()||"",t=this.getLineNumber()||"",i=this.getColumnNumber()||"",r=this.getFunctionName()||"";return this.getIsEval()?e?"[eval] ("+e+":"+t+":"+i+")":"[eval]:"+t+":"+i:r?r+" ("+e+":"+t+":"+i+")":e+":"+t+":"+i}};g.fromString=c(function(t){var i=t.indexOf("("),r=t.lastIndexOf(")"),a=t.substring(0,i),n=t.substring(i+1,r).split(","),o=t.substring(r+1);if(o.indexOf("@")===0)var s=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(o,""),l=s[1],d=s[2],u=s[3];return new g({functionName:a,args:n||void 0,fileName:l,lineNumber:d||void 0,columnNumber:u||void 0})},"StackFrame$$fromString");for(h=0;h<_.length;h++)g.prototype["get"+w(_[h])]=L(_[h]),g.prototype["set"+w(_[h])]=function(e){return function(t){this[e]=!!t}}(_[h]);var h;for(E=0;E<F.length;E++)g.prototype["get"+w(F[E])]=L(F[E]),g.prototype["set"+w(F[E])]=function(e){return function(t){if(!le(t))throw new TypeError(e+" must be a Number");this[e]=Number(t)}}(F[E]);var E;for(S=0;S<R.length;S++)g.prototype["get"+w(R[S])]=L(R[S]),g.prototype["set"+w(R[S])]=function(e){return function(t){this[e]=String(t)}}(R[S]);var S,A=g;function fe(){var e=/^\s*at .*(\S+:\d+|\(native\))/m,t=/^(eval@)?(\[native code])?$/;return{parse:c(function(r){if(r.stack&&r.stack.match(e))return this.parseV8OrIE(r);if(r.stack)return this.parseFFOrSafari(r);throw new Error("Cannot parse given Error object")},"ErrorStackParser$$parse"),extractLocation:c(function(r){if(r.indexOf(":")===-1)return[r];var a=/(.+?)(?::(\d+))?(?::(\d+))?$/,n=a.exec(r.replace(/[()]/g,""));return[n[1],n[2]||void 0,n[3]||void 0]},"ErrorStackParser$$extractLocation"),parseV8OrIE:c(function(r){var a=r.stack.split(`
|
|
2
|
+
`).filter(function(n){return!!n.match(e)},this);return a.map(function(n){n.indexOf("(eval ")>-1&&(n=n.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var o=n.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),s=o.match(/ (\(.+\)$)/);o=s?o.replace(s[0],""):o;var l=this.extractLocation(s?s[1]:o),d=s&&o||void 0,u=["eval","<anonymous>"].indexOf(l[0])>-1?void 0:l[0];return new A({functionName:d,fileName:u,lineNumber:l[1],columnNumber:l[2],source:n})},this)},"ErrorStackParser$$parseV8OrIE"),parseFFOrSafari:c(function(r){var a=r.stack.split(`
|
|
3
|
+
`).filter(function(n){return!n.match(t)},this);return a.map(function(n){if(n.indexOf(" > eval")>-1&&(n=n.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),n.indexOf("@")===-1&&n.indexOf(":")===-1)return new A({functionName:n});var o=/((.*".+"[^@]*)?[^@]*)(?:@)/,s=n.match(o),l=s&&s[1]?s[1]:void 0,d=this.extractLocation(n.replace(o,""));return new A({functionName:l,fileName:d[0],lineNumber:d[1],columnNumber:d[2],source:n})},this)},"ErrorStackParser$$parseFFOrSafari")}}c(fe,"ErrorStackParser");var me=new fe;var j=me;var y=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&!process.browser,T=y&&typeof module<"u"&&typeof module.exports<"u"&&typeof p<"u"&&typeof __dirname<"u",H=y&&!T,Le=typeof globalThis.Bun<"u",pe=typeof Deno<"u",z=!y&&!pe,V=z&&typeof window=="object"&&typeof document=="object"&&typeof document.createElement=="function"&&"sessionStorage"in window&&typeof importScripts!="function",q=z&&typeof importScripts=="function"&&typeof self=="object",Te=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Chrome")==-1&&navigator.userAgent.indexOf("Safari")>-1;var K,U,Y,J,C;async function M(){if(!y||(K=(await import(/* webpackIgnore */"node:url")).default,J=await import(/* webpackIgnore */"node:fs"),C=await import(/* webpackIgnore */"node:fs/promises"),Y=(await import(/* webpackIgnore */"node:vm")).default,U=await import(/* webpackIgnore */"node:path"),W=U.sep,typeof p<"u"))return;let e=J,t=await import(/* webpackIgnore */"node:crypto"),i=await import(/* webpackIgnore */"ws"),r=await import(/* webpackIgnore */"node:child_process"),a={fs:e,crypto:t,ws:i,child_process:r};globalThis.require=function(n){return a[n]}}c(M,"initNodeModules");function ge(e,t){return U.resolve(t||".",e)}c(ge,"node_resolvePath");function ye(e,t){return t===void 0&&(t=location),new URL(e,t).toString()}c(ye,"browser_resolvePath");var D;y?D=ge:D=ye;var W;y||(W="/");function be(e,t){return e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?{response:fetch(e)}:{binary:C.readFile(e).then(i=>new Uint8Array(i.buffer,i.byteOffset,i.byteLength))}}c(be,"node_getBinaryResponse");function ve(e,t){let i=new URL(e,location);return{response:fetch(i,t?{integrity:t}:{})}}c(ve,"browser_getBinaryResponse");var P;y?P=be:P=ve;async function G(e,t){let{response:i,binary:r}=P(e,t);if(r)return r;let a=await i;if(!a.ok)throw new Error(`Failed to load '${e}': request failed.`);return new Uint8Array(await a.arrayBuffer())}c(G,"loadBinaryFile");var O;if(V)O=c(async e=>await import(/* webpackIgnore */e),"loadScript");else if(q)O=c(async e=>{try{globalThis.importScripts(e)}catch(t){if(t instanceof TypeError)await import(/* webpackIgnore */e);else throw t}},"loadScript");else if(y)O=he;else throw new Error("Cannot determine runtime environment");async function he(e){e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?Y.runInThisContext(await(await fetch(e)).text()):await import(/* webpackIgnore */K.pathToFileURL(e).href)}c(he,"nodeLoadScript");async function X(e){if(y){await M();let t=await C.readFile(e,{encoding:"utf8"});return JSON.parse(t)}else return await(await fetch(e)).json()}c(X,"loadLockFile");async function Q(){if(T)return __dirname;let e;try{throw new Error}catch(r){e=r}let t=j.parse(e)[0].fileName;if(y&&!t.startsWith("file://")&&(t=`file://${t}`),H){let r=await import(/* webpackIgnore */"node:path");return(await import(/* webpackIgnore */"node:url")).fileURLToPath(r.dirname(t))}let i=t.lastIndexOf(W);if(i===-1)throw new Error("Could not extract indexURL path from pyodide module location");return t.slice(0,i)}c(Q,"calculateDirname");function Z(e){let t=e.FS,i=e.FS.filesystems.MEMFS,r=e.PATH,a={DIR_MODE:16895,FILE_MODE:33279,mount:function(n){if(!n.opts.fileSystemHandle)throw new Error("opts.fileSystemHandle is required");return i.mount.apply(null,arguments)},syncfs:async(n,o,s)=>{try{let l=a.getLocalSet(n),d=await a.getRemoteSet(n),u=o?d:l,m=o?l:d;await a.reconcile(n,u,m),s(null)}catch(l){s(l)}},getLocalSet:n=>{let o=Object.create(null);function s(u){return u!=="."&&u!==".."}c(s,"isRealDir");function l(u){return m=>r.join2(u,m)}c(l,"toAbsolute");let d=t.readdir(n.mountpoint).filter(s).map(l(n.mountpoint));for(;d.length;){let u=d.pop(),m=t.stat(u);t.isDir(m.mode)&&d.push.apply(d,t.readdir(u).filter(s).map(l(u))),o[u]={timestamp:m.mtime,mode:m.mode}}return{type:"local",entries:o}},getRemoteSet:async n=>{let o=Object.create(null),s=await Ee(n.opts.fileSystemHandle);for(let[l,d]of s)l!=="."&&(o[r.join2(n.mountpoint,l)]={timestamp:d.kind==="file"?(await d.getFile()).lastModifiedDate:new Date,mode:d.kind==="file"?a.FILE_MODE:a.DIR_MODE});return{type:"remote",entries:o,handles:s}},loadLocalEntry:n=>{let s=t.lookupPath(n).node,l=t.stat(n);if(t.isDir(l.mode))return{timestamp:l.mtime,mode:l.mode};if(t.isFile(l.mode))return s.contents=i.getFileDataAsTypedArray(s),{timestamp:l.mtime,mode:l.mode,contents:s.contents};throw new Error("node type not supported")},storeLocalEntry:(n,o)=>{if(t.isDir(o.mode))t.mkdirTree(n,o.mode);else if(t.isFile(o.mode))t.writeFile(n,o.contents,{canOwn:!0});else throw new Error("node type not supported");t.chmod(n,o.mode),t.utime(n,o.timestamp,o.timestamp)},removeLocalEntry:n=>{var o=t.stat(n);t.isDir(o.mode)?t.rmdir(n):t.isFile(o.mode)&&t.unlink(n)},loadRemoteEntry:async n=>{if(n.kind==="file"){let o=await n.getFile();return{contents:new Uint8Array(await o.arrayBuffer()),mode:a.FILE_MODE,timestamp:o.lastModifiedDate}}else{if(n.kind==="directory")return{mode:a.DIR_MODE,timestamp:new Date};throw new Error("unknown kind: "+n.kind)}},storeRemoteEntry:async(n,o,s)=>{let l=n.get(r.dirname(o)),d=t.isFile(s.mode)?await l.getFileHandle(r.basename(o),{create:!0}):await l.getDirectoryHandle(r.basename(o),{create:!0});if(d.kind==="file"){let u=await d.createWritable();await u.write(s.contents),await u.close()}n.set(o,d)},removeRemoteEntry:async(n,o)=>{await n.get(r.dirname(o)).removeEntry(r.basename(o)),n.delete(o)},reconcile:async(n,o,s)=>{let l=0,d=[];Object.keys(o.entries).forEach(function(f){let v=o.entries[f],N=s.entries[f];(!N||t.isFile(v.mode)&&v.timestamp.getTime()>N.timestamp.getTime())&&(d.push(f),l++)}),d.sort();let u=[];if(Object.keys(s.entries).forEach(function(f){o.entries[f]||(u.push(f),l++)}),u.sort().reverse(),!l)return;let m=o.type==="remote"?o.handles:s.handles;for(let f of d){let v=r.normalize(f.replace(n.mountpoint,"/")).substring(1);if(s.type==="local"){let N=m.get(v),te=await a.loadRemoteEntry(N);a.storeLocalEntry(f,te)}else{let N=a.loadLocalEntry(f);await a.storeRemoteEntry(m,v,N)}}for(let f of u)if(s.type==="local")a.removeLocalEntry(f);else{let v=r.normalize(f.replace(n.mountpoint,"/")).substring(1);await a.removeRemoteEntry(m,v)}}};e.FS.filesystems.NATIVEFS_ASYNC=a}c(Z,"initializeNativeFS");var Ee=c(async e=>{let t=[];async function i(a){for await(let n of a.values())t.push(n),n.kind==="directory"&&await i(n)}c(i,"collect"),await i(e);let r=new Map;r.set(".",e);for(let a of t){let n=(await e.resolve(a)).join("/");r.set(n,a)}return r},"getFsHandles");function ee(e){let t={noImageDecoding:!0,noAudioDecoding:!0,noWasmDecoding:!1,preRun:Fe(e),quit(i,r){throw t.exited={status:i,toThrow:r},r},print:e.stdout,printErr:e.stderr,arguments:e.args,API:{config:e},locateFile:i=>e.indexURL+i,instantiateWasm:Re(e.indexURL)};return t}c(ee,"createSettings");function Se(e){return function(t){let i="/";try{t.FS.mkdirTree(e)}catch(r){console.error(`Error occurred while making a home directory '${e}':`),console.error(r),console.error(`Using '${i}' for a home directory instead`),e=i}t.FS.chdir(e)}}c(Se,"createHomeDirectory");function we(e){return function(t){Object.assign(t.ENV,e)}}c(we,"setEnvironment");function Ne(e){return t=>{for(let i of e)t.FS.mkdirTree(i),t.FS.mount(t.FS.filesystems.NODEFS,{root:i},i)}}c(Ne,"mountLocalDirectories");function _e(e){let t=G(e);return i=>{let r=i._py_version_major(),a=i._py_version_minor();i.FS.mkdirTree("/lib"),i.FS.mkdirTree(`/lib/python${r}.${a}/site-packages`),i.addRunDependency("install-stdlib"),t.then(n=>{i.FS.writeFile(`/lib/python${r}${a}.zip`,n)}).catch(n=>{console.error("Error occurred while installing the standard library:"),console.error(n)}).finally(()=>{i.removeRunDependency("install-stdlib")})}}c(_e,"installStdlib");function Fe(e){let t;return e.stdLibURL!=null?t=e.stdLibURL:t=e.indexURL+"python_stdlib.zip",[_e(t),Se(e.env.HOME),we(e.env),Ne(e._node_mounts),Z]}c(Fe,"getFileSystemInitializationFuncs");function Re(e){let{binary:t,response:i}=P(e+"pyodide.asm.wasm");return function(r,a){return async function(){try{let n;i?n=await WebAssembly.instantiateStreaming(i,r):n=await WebAssembly.instantiate(await t,r);let{instance:o,module:s}=n;typeof WasmOffsetConverter<"u"&&(wasmOffsetConverter=new WasmOffsetConverter(wasmBinary,s)),a(o,s)}catch(n){console.warn("wasm instantiation failed!"),console.warn(n)}}(),{}}}c(Re,"getInstantiateWasmFunc");var x="0.27.0";async function B(e={}){var u,m;await M();let t=e.indexURL||await Q();t=D(t),t.endsWith("/")||(t+="/"),e.indexURL=t;let i={fullStdLib:!1,jsglobals:globalThis,stdin:globalThis.prompt?globalThis.prompt:void 0,lockFileURL:t+"pyodide-lock.json",args:[],_node_mounts:[],env:{},packageCacheDir:t,packages:[],enableRunUntilComplete:!1,checkAPIVersion:!0,BUILD_ID:"8f254d3346bd62b9d3eb64ff47e12c292072a672346cdf144e38e4e3f6572e16"},r=Object.assign(i,e);(u=r.env).HOME??(u.HOME="/home/pyodide"),(m=r.env).PYTHONINSPECT??(m.PYTHONINSPECT="1");let a=ee(r),n=a.API;if(n.lockFilePromise=X(r.lockFileURL),typeof _createPyodideModule!="function"){let f=`${r.indexURL}pyodide.asm.js`;await O(f)}let o;if(e._loadSnapshot){let f=await e._loadSnapshot;ArrayBuffer.isView(f)?o=f:o=new Uint8Array(f),a.noInitialRun=!0,a.INITIAL_MEMORY=o.length}let s=await _createPyodideModule(a);if(a.exited)throw a.exited.toThrow;if(e.pyproxyToStringRepr&&n.setPyProxyToStringMethod(!0),n.version!==x&&r.checkAPIVersion)throw new Error(`Pyodide version does not match: '${x}' <==> '${n.version}'. If you updated the Pyodide version, make sure you also updated the 'indexURL' parameter passed to loadPyodide.`);s.locateFile=f=>{throw new Error("Didn't expect to load any more file_packager files!")};let l;o&&(l=n.restoreSnapshot(o));let d=n.finalizeBootstrap(l,e._snapshotDeserializer);return n.sys.path.insert(0,n.config.env.HOME),d.version.includes("dev")||n.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${d.version}/full/`),n._pyodide.set_excepthook(),await n.packageIndexReady,n.initializeStreams(r.stdin,r.stdout,r.stderr),d}c(B,"loadPyodide");globalThis.loadPyodide=B;return ce(Ie);})();
|
|
4
4
|
try{Object.assign(exports,loadPyodide)}catch(_){}
|
|
5
5
|
globalThis.loadPyodide=loadPyodide.loadPyodide;
|
|
6
6
|
//# sourceMappingURL=pyodide.js.map
|