pyodide 0.25.0-alpha.2 → 0.26.0-alpha.1

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/pyodide.asm.wasm CHANGED
Binary file
package/pyodide.d.ts CHANGED
@@ -13,10 +13,6 @@ export declare const version: string;
13
13
  interface PyProxy {
14
14
  [x: string]: any;
15
15
  }
16
- /**
17
- * A :js:class:`~pyodide.ffi.PyProxy` is an object that allows idiomatic use of a Python object from
18
- * JavaScript. See :ref:`type-translations-pyproxy`.
19
- */
20
16
  declare class PyProxy {
21
17
  /** @private */
22
18
  $$flags: number;
@@ -116,58 +112,7 @@ declare class PyProxy {
116
112
  */
117
113
  default_converter?: (obj: PyProxy, convert: (obj: PyProxy) => any, cacheConversion: (obj: PyProxy, result: any) => void) => any;
118
114
  }): any;
119
- /**
120
- * Check whether the :js:class:`~pyodide.ffi.PyProxy` is a :js:class:`~pyodide.ffi.PyProxyWithLength`.
121
- * @deprecated Use ``obj instanceof pyodide.ffi.PyProxyWithLength`` instead.
122
- */
123
- supportsLength(): this is PyProxyWithLength;
124
- /**
125
- * Check whether the :js:class:`~pyodide.ffi.PyProxy` is a :js:class:`~pyodide.ffi.PyProxyWithGet`.
126
- * @deprecated Use ``obj instanceof pyodide.ffi.PyProxyWithGet`` instead.
127
- */
128
- supportsGet(): this is PyProxyWithGet;
129
- /**
130
- * Check whether the :js:class:`~pyodide.ffi.PyProxy` is a :js:class:`~pyodide.ffi.PyProxyWithSet`.
131
- * @deprecated Use ``obj instanceof pyodide.ffi.PyProxyWithSet`` instead.
132
- */
133
- supportsSet(): this is PyProxyWithSet;
134
- /**
135
- * Check whether the :js:class:`~pyodide.ffi.PyProxy` is a :js:class:`~pyodide.ffi.PyProxyWithHas`.
136
- * @deprecated Use ``obj instanceof pyodide.ffi.PyProxyWithHas`` instead.
137
- */
138
- supportsHas(): this is PyProxyWithHas;
139
- /**
140
- * Check whether the :js:class:`~pyodide.ffi.PyProxy` is a
141
- * :js:class:`~pyodide.ffi.PyIterable`.
142
- * @deprecated Use ``obj instanceof pyodide.ffi.PyIterable`` instead.
143
- */
144
- isIterable(): this is PyIterable;
145
- /**
146
- * Check whether the :js:class:`~pyodide.ffi.PyProxy` is a
147
- * :js:class:`~pyodide.ffi.PyIterator`
148
- * @deprecated Use ``obj instanceof pyodide.ffi.PyIterator`` instead.
149
- */
150
- isIterator(): this is PyIterator;
151
- /**
152
- * Check whether the :js:class:`~pyodide.ffi.PyProxy` is a :js:class:`~pyodide.ffi.PyAwaitable`
153
- * @deprecated Use :js:class:`obj instanceof pyodide.ffi.PyAwaitable <pyodide.ffi.PyAwaitable>` instead.
154
- */
155
- isAwaitable(): this is PyAwaitable;
156
- /**
157
- * Check whether the :js:class:`~pyodide.ffi.PyProxy` is a :js:class:`~pyodide.ffi.PyBuffer`.
158
- * @deprecated Use ``obj instanceof pyodide.ffi.PyBuffer`` instead.
159
- */
160
- isBuffer(): this is PyBuffer;
161
- /**
162
- * Check whether the :js:class:`~pyodide.ffi.PyProxy` is a :js:class:`~pyodide.ffi.PyCallable`.
163
- * @deprecated ``obj instanceof pyodide.ffi.PyCallable`` instead.
164
- */
165
- isCallable(): this is PyCallable;
166
115
  }
167
- /**
168
- * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object has a :meth:`~object.__len__`
169
- * method.
170
- */
171
116
  declare class PyProxyWithLength extends PyProxy {
172
117
  /** @private */
173
118
  static [Symbol.hasInstance](obj: any): obj is PyProxy;
@@ -181,10 +126,6 @@ declare class PyLengthMethods {
181
126
  */
182
127
  get length(): number;
183
128
  }
184
- /**
185
- * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object has a
186
- * :meth:`~object.__getitem__` method.
187
- */
188
129
  declare class PyProxyWithGet extends PyProxy {
189
130
  /** @private */
190
131
  static [Symbol.hasInstance](obj: any): obj is PyProxy;
@@ -201,10 +142,6 @@ declare class PyGetItemMethods {
201
142
  */
202
143
  get(key: any): any;
203
144
  }
204
- /**
205
- * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object has a
206
- * :meth:`~object.__setitem__` or :meth:`~object.__delitem__` method.
207
- */
208
145
  declare class PyProxyWithSet extends PyProxy {
209
146
  /** @private */
210
147
  static [Symbol.hasInstance](obj: any): obj is PyProxy;
@@ -227,10 +164,6 @@ declare class PySetItemMethods {
227
164
  */
228
165
  delete(key: any): void;
229
166
  }
230
- /**
231
- * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object has a
232
- * :meth:`~object.__contains__` method.
233
- */
234
167
  declare class PyProxyWithHas extends PyProxy {
235
168
  /** @private */
236
169
  static [Symbol.hasInstance](obj: any): obj is PyProxy;
@@ -254,8 +187,6 @@ declare class PyIterable extends PyProxy {
254
187
  /** @deprecated Use `import type { PyIterable } from "pyodide/ffi"` instead */
255
188
  interface PyIterable extends PyIterableMethods {
256
189
  }
257
- /** @deprecated Use :js:class:`pyodide.ffi.PyIterable` instead. */
258
- export type PyProxyIterable = PyIterable;
259
190
  declare class PyIterableMethods {
260
191
  /**
261
192
  * This translates to the Python code ``iter(obj)``. Return an iterator
@@ -289,8 +220,6 @@ declare class PyIterator extends PyProxy {
289
220
  /** @deprecated Use `import type { PyIterator } from "pyodide/ffi"` instead */
290
221
  interface PyIterator extends PyIteratorMethods {
291
222
  }
292
- /** @deprecated Use :js:class:`pyodide.ffi.PyIterator` instead. */
293
- export type PyProxyIterator = PyIterator;
294
223
  declare class PyIteratorMethods {
295
224
  /** @private */
296
225
  [Symbol.iterator](): this;
@@ -689,16 +618,10 @@ declare class PyAwaitable extends PyProxy {
689
618
  /** @deprecated Use `import type { PyAwaitable } from "pyodide/ffi"` instead */
690
619
  interface PyAwaitable extends Promise<any> {
691
620
  }
692
- /** @deprecated Use :js:class:`pyodide.ffi.PyAwaitable` instead. */
693
- export type PyProxyAwaitable = PyAwaitable;
694
621
  declare class PyCallable extends PyProxy {
695
622
  /** @private */
696
623
  static [Symbol.hasInstance](obj: any): obj is PyCallable;
697
624
  }
698
- /**
699
- * @deprecated Use :js:class:`pyodide.ffi.PyCallable` instead.
700
- */
701
- export type PyProxyCallable = PyCallable;
702
625
  /** @deprecated Use `import type { PyCallable } from "pyodide/ffi"` instead */
703
626
  interface PyCallable extends PyCallableMethods {
704
627
  (...args: any[]): any;
@@ -730,11 +653,66 @@ declare class PyCallableMethods {
730
653
  */
731
654
  call(thisArg: any, ...jsargs: any): any;
732
655
  /**
733
- * Call the function with key word arguments. The last argument must be an
656
+ * Call the function with keyword arguments. The last argument must be an
734
657
  * object with the keyword arguments.
735
658
  */
736
659
  callKwargs(...jsargs: any): any;
660
+ /**
661
+ * Call the function in a "relaxed" manner. Any extra arguments will be
662
+ * ignored. This matches the behavior of JavaScript functions more accurately.
663
+ *
664
+ * Any extra arguments will be ignored. This matches the behavior of
665
+ * JavaScript functions more accurately. Missing arguments are **NOT** filled
666
+ * with `None`. If too few arguments are passed, this will still raise a
667
+ * TypeError.
668
+ *
669
+ * This uses :py:func:`pyodide.code.relaxed_call`.
670
+ */
671
+ callRelaxed(...jsargs: any): any;
672
+ /**
673
+ * Call the function with keyword arguments in a "relaxed" manner. The last
674
+ * argument must be an object with the keyword arguments. Any extra arguments
675
+ * will be ignored. This matches the behavior of JavaScript functions more
676
+ * accurately.
677
+ *
678
+ * Missing arguments are **NOT** filled with `None`. If too few arguments are
679
+ * passed, this will still raise a TypeError. Also, if the same argument is
680
+ * passed as both a keyword argument and a positional argument, it will raise
681
+ * an error.
682
+ *
683
+ * This uses :py:func:`pyodide.code.relaxed_call`.
684
+ */
685
+ callKwargsRelaxed(...jsargs: any): any;
686
+ /**
687
+ * Call the function with stack switching enabled. Functions called this way
688
+ * can use
689
+ * :py:meth:`PyodideFuture.syncify() <pyodide.webloop.PyodideFuture.syncify>`
690
+ * to block until a :py:class:`~asyncio.Future` or :js:class:`Promise` is
691
+ * resolved. Only works in runtimes with JS Promise integration.
692
+ *
693
+ * .. admonition:: Experimental
694
+ * :class: warning
695
+ *
696
+ * This feature is not yet stable.
697
+ *
698
+ * @experimental
699
+ */
737
700
  callSyncifying(...jsargs: any): Promise<any>;
701
+ /**
702
+ * Call the function with stack switching enabled. The last argument must be
703
+ * an object with the keyword arguments. Functions called this way can use
704
+ * :py:meth:`PyodideFuture.syncify() <pyodide.webloop.PyodideFuture.syncify>`
705
+ * to block until a :py:class:`~asyncio.Future` or :js:class:`Promise` is
706
+ * resolved. Only works in runtimes with JS Promise integration.
707
+ *
708
+ * .. admonition:: Experimental
709
+ * :class: warning
710
+ *
711
+ * This feature is not yet stable.
712
+ *
713
+ * @experimental
714
+ */
715
+ callSyncifyingKwargs(...jsargs: any): Promise<any>;
738
716
  /**
739
717
  * The ``bind()`` method creates a new function that, when called, has its
740
718
  * ``this`` keyword set to the provided value, with a given sequence of
@@ -826,8 +804,6 @@ declare class PyDict extends PyProxy {
826
804
  /** @deprecated Use `import type { PyDict } from "pyodide/ffi"` instead */
827
805
  interface PyDict extends PyProxyWithGet, PyProxyWithSet, PyProxyWithHas, PyProxyWithLength, PyIterable {
828
806
  }
829
- /** @deprecated Use :js:class:`pyodide.ffi.PyDict` instead. */
830
- export type PyProxyDict = PyDict;
831
807
  /** @deprecated Use `import type { PyBufferView } from "pyodide/ffi"` instead */
832
808
  declare class PyBufferView {
833
809
  /**
@@ -1100,16 +1076,16 @@ declare class PyodideAPI {
1100
1076
  * expression (and the code doesn't end with a semicolon), the value of the
1101
1077
  * expression is returned.
1102
1078
  *
1103
- * @param code Python code to evaluate
1079
+ * @param code The Python code to run
1104
1080
  * @param options
1105
1081
  * @param options.globals An optional Python dictionary to use as the globals.
1106
1082
  * Defaults to :js:attr:`pyodide.globals`.
1107
1083
  * @param options.locals An optional Python dictionary to use as the locals.
1108
1084
  * Defaults to the same as ``globals``.
1109
- * @param options.filename An optional string to use as the filename. Defaults
1110
- * to "<exec>". If the filename does not start with "<" and end with ">",
1111
- * the source code will be added to the Python linecache and tracebacks
1112
- * will show source lines.
1085
+ * @param options.filename An optional string to use as the file name.
1086
+ * Defaults to ``"<exec>"``. If a custom file name is given, the
1087
+ * traceback for any exception that is thrown will show source lines
1088
+ * (unless the given file name starts with ``<`` and ends with ``>``).
1113
1089
  * @returns The result of the Python code translated to JavaScript. See the
1114
1090
  * documentation for :py:func:`~pyodide.code.eval_code` for more info.
1115
1091
  * @example
@@ -1160,16 +1136,16 @@ declare class PyodideAPI {
1160
1136
  * import any python packages referenced via ``import`` statements in your
1161
1137
  * code. This function will no longer do it for you.
1162
1138
  *
1163
- * @param code Python code to evaluate
1139
+ * @param code The Python code to run
1164
1140
  * @param options
1165
1141
  * @param options.globals An optional Python dictionary to use as the globals.
1166
1142
  * Defaults to :js:attr:`pyodide.globals`.
1167
1143
  * @param options.locals An optional Python dictionary to use as the locals.
1168
1144
  * Defaults to the same as ``globals``.
1169
- * @param options.filename An optional string to use as the filename. Defaults
1170
- * to "<exec>". If the filename does not start with "<" and end with ">",
1171
- * the source code will be added to the Python linecache and tracebacks
1172
- * will show source lines.
1145
+ * @param options.filename An optional string to use as the file name.
1146
+ * Defaults to ``"<exec>"``. If a custom file name is given, the
1147
+ * traceback for any exception that is thrown will show source lines
1148
+ * (unless the given file name starts with ``<`` and ends with ``>``).
1173
1149
  * @returns The result of the Python code translated to JavaScript.
1174
1150
  * @async
1175
1151
  */
@@ -1178,9 +1154,35 @@ declare class PyodideAPI {
1178
1154
  locals?: PyProxy;
1179
1155
  filename?: string;
1180
1156
  }): Promise<any>;
1157
+ /**
1158
+ * Runs a Python code string like :js:func:`pyodide.runPython` but with stack
1159
+ * switching enabled. Code executed in this way can use
1160
+ * :py:meth:`PyodideFuture.syncify() <pyodide.webloop.PyodideFuture.syncify>`
1161
+ * to block until a :py:class:`~asyncio.Future` or :js:class:`Promise` is
1162
+ * resolved. Only works in runtimes with JS Promise Integration enabled.
1163
+ *
1164
+ * .. admonition:: Experimental
1165
+ * :class: warning
1166
+ *
1167
+ * This feature is not yet stable.
1168
+ *
1169
+ * @experimental
1170
+ * @param code The Python code to run
1171
+ * @param options
1172
+ * @param options.globals An optional Python dictionary to use as the globals.
1173
+ * Defaults to :js:attr:`pyodide.globals`.
1174
+ * @param options.locals An optional Python dictionary to use as the locals.
1175
+ * Defaults to the same as ``globals``.
1176
+ * @param options.filename An optional string to use as the file name.
1177
+ * Defaults to ``"<exec>"``. If a custom file name is given, the
1178
+ * traceback for any exception that is thrown will show source lines
1179
+ * (unless the given file name starts with ``<`` and ends with ``>``).
1180
+ * @returns The result of the Python code translated to JavaScript.
1181
+ */
1181
1182
  static runPythonSyncifying(code: string, options?: {
1182
1183
  globals?: PyProxy;
1183
1184
  locals?: PyProxy;
1185
+ filename?: string;
1184
1186
  }): Promise<any>;
1185
1187
  /**
1186
1188
  * Registers the JavaScript object ``module`` as a JavaScript module named
@@ -1190,6 +1192,28 @@ declare class PyodideAPI {
1190
1192
  * module from :py:data:`sys.modules`. This calls
1191
1193
  * :func:`~pyodide.ffi.register_js_module`.
1192
1194
  *
1195
+ * Any attributes of the JavaScript objects which are themselves objects will
1196
+ * be treated as submodules:
1197
+ * ```pyodide
1198
+ * pyodide.registerJsModule("mymodule", { submodule: { value: 7 } });
1199
+ * pyodide.runPython(`
1200
+ * from mymodule.submodule import value
1201
+ * assert value == 7
1202
+ * `);
1203
+ * ```
1204
+ * If you wish to prevent this, try the following instead:
1205
+ * ```pyodide
1206
+ * const sys = pyodide.pyimport("sys");
1207
+ * sys.modules.set("mymodule", { obj: { value: 7 } });
1208
+ * pyodide.runPython(`
1209
+ * from mymodule import obj
1210
+ * assert obj.value == 7
1211
+ * # attempting to treat obj as a submodule raises ModuleNotFoundError:
1212
+ * # "No module named 'mymodule.obj'; 'mymodule' is not a package"
1213
+ * from mymodule.obj import value
1214
+ * `);
1215
+ * ```
1216
+ *
1193
1217
  * @param name Name of the JavaScript module to add
1194
1218
  * @param module JavaScript object backing the module
1195
1219
  */
@@ -1234,30 +1258,25 @@ declare class PyodideAPI {
1234
1258
  /**
1235
1259
  * Imports a module and returns it.
1236
1260
  *
1237
- * .. admonition:: Warning
1238
- * :class: warning
1239
- *
1240
- * This function has a completely different behavior than the old removed pyimport function!
1241
- *
1242
- * ``pyimport`` is roughly equivalent to:
1243
- *
1244
- * .. code-block:: js
1245
- *
1246
- * pyodide.runPython(`import ${pkgname}; ${pkgname}`);
1247
- *
1248
- * except that the global namespace will not change.
1249
- *
1250
- * Example:
1251
- *
1252
- * .. code-block:: js
1253
- *
1254
- * let sysmodule = pyodide.pyimport("sys");
1255
- * let recursionLimit = sysmodule.getrecursionlimit();
1261
+ * If `name` has no dot in it, then `pyimport(name)` is approximately
1262
+ * equivalent to:
1263
+ * ```js
1264
+ * pyodide.runPython(`import ${name}; ${name}`)
1265
+ * ```
1266
+ * except that `name` is not introduced into the Python global namespace. If
1267
+ * the name has one or more dots in it, say it is of the form `path.name`
1268
+ * where `name` has no dots but path may have zero or more dots. Then it is
1269
+ * approximately the same as:
1270
+ * ```js
1271
+ * pyodide.runPython(`from ${path} import ${name}; ${name}`);
1272
+ * ```
1256
1273
  *
1257
1274
  * @param mod_name The name of the module to import
1258
- * @returns A PyProxy for the imported module
1275
+ *
1276
+ * @example
1277
+ * pyodide.pyimport("math.comb")(4, 2) // returns 4 choose 2 = 6
1259
1278
  */
1260
- static pyimport(mod_name: string): PyProxy;
1279
+ static pyimport(mod_name: string): any;
1261
1280
  /**
1262
1281
  * Unpack an archive into a target directory.
1263
1282
  *
@@ -1321,39 +1340,6 @@ declare class PyodideAPI {
1321
1340
  * during execution of C code.
1322
1341
  */
1323
1342
  static checkInterrupt(): void;
1324
- /**
1325
- * Is ``jsobj`` a :js:class:`~pyodide.ffi.PyProxy`?
1326
- * @deprecated Use :js:class:`obj instanceof pyodide.ffi.PyProxy <pyodide.ffi.PyProxy>` instead.
1327
- * @param jsobj Object to test.
1328
- */
1329
- static isPyProxy(jsobj: any): jsobj is PyProxy;
1330
- /**
1331
- * An alias for :js:class:`pyodide.ffi.PyBufferView`.
1332
- *
1333
- * @hidetype
1334
- * @alias
1335
- * @dockind class
1336
- * @deprecated
1337
- */
1338
- static get PyBuffer(): typeof PyBufferView;
1339
- /**
1340
- * An alias for :js:class:`pyodide.ffi.PyBuffer`.
1341
- *
1342
- * @hidetype
1343
- * @alias
1344
- * @dockind class
1345
- * @deprecated
1346
- */
1347
- static get PyProxyBuffer(): typeof PyBuffer;
1348
- /**
1349
- * An alias for :js:class:`pyodide.ffi.PythonError`.
1350
- *
1351
- * @hidetype
1352
- * @alias
1353
- * @dockind class
1354
- * @deprecated
1355
- */
1356
- static get PythonError(): typeof PythonError;
1357
1343
  /**
1358
1344
  * Turn on or off debug mode. In debug mode, some error messages are improved
1359
1345
  * at a performance cost.
@@ -1372,7 +1358,6 @@ type ConfigType = {
1372
1358
  indexURL: string;
1373
1359
  packageCacheDir: string;
1374
1360
  lockFileURL: string;
1375
- homedir: string;
1376
1361
  fullStdLib?: boolean;
1377
1362
  stdLibURL?: string;
1378
1363
  stdin?: () => string;
@@ -1396,7 +1381,6 @@ type ConfigType = {
1396
1381
  * async function main() {
1397
1382
  * const pyodide = await loadPyodide({
1398
1383
  * fullStdLib: true,
1399
- * homedir: "/pyodide",
1400
1384
  * stdout: (msg) => console.log(`Pyodide: ${msg}`),
1401
1385
  * });
1402
1386
  * console.log("Loaded Pyodide");
@@ -1428,11 +1412,6 @@ export declare function loadPyodide(options?: {
1428
1412
  * Default: ```${indexURL}/pyodide-lock.json```
1429
1413
  */
1430
1414
  lockFileURL?: string;
1431
- /**
1432
- * The home directory which Pyodide will use inside virtual file system.
1433
- * This is deprecated, use ``{env: {HOME : some_dir}}`` instead.
1434
- */
1435
- homedir?: string;
1436
1415
  /**
1437
1416
  * Load the full Python standard library. Setting this to false excludes
1438
1417
  * unvendored modules from the standard library.
@@ -1514,10 +1493,5 @@ export declare function loadPyodide(options?: {
1514
1493
  _node_mounts?: string[];
1515
1494
  }): Promise<PyodideInterface>;
1516
1495
 
1517
- export type {
1518
- PyBuffer as PyProxyBuffer,
1519
- PyBufferView as PyBuffer,
1520
- };
1521
-
1522
1496
  export type {};
1523
- export type {PyProxy, PyProxyWithGet, PyProxyWithHas, PyProxyWithLength, PyProxyWithSet};
1497
+ export type {};
package/pyodide.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var loadPyodide=(()=>{var ce=Object.create;var _=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var f=(t,e)=>_(t,"name",{value:e,configurable:!0}),g=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,c)=>(typeof require<"u"?require:e)[c]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var U=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),pe=(t,e)=>{for(var c in e)_(t,c,{get:e[c],enumerable:!0})},$=(t,e,c,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of de(e))!ue.call(t,a)&&a!==c&&_(t,a,{get:()=>e[a],enumerable:!(o=le(e,a))||o.enumerable});return t};var h=(t,e,c)=>(c=t!=null?ce(fe(t)):{},$(e||!t||!t.__esModule?_(c,"default",{value:t,enumerable:!0}):c,t)),me=t=>$(_({},"__esModule",{value:!0}),t);var B=U((N,C)=>{(function(t,e){"use strict";typeof define=="function"&&define.amd?define("stackframe",[],e):typeof N=="object"?C.exports=e():t.StackFrame=e()})(N,function(){"use strict";function t(d){return!isNaN(parseFloat(d))&&isFinite(d)}f(t,"_isNumber");function e(d){return d.charAt(0).toUpperCase()+d.substring(1)}f(e,"_capitalize");function c(d){return function(){return this[d]}}f(c,"_getter");var o=["isConstructor","isEval","isNative","isToplevel"],a=["columnNumber","lineNumber"],r=["fileName","functionName","source"],n=["args"],u=["evalOrigin"],i=o.concat(a,r,n,u);function s(d){if(d)for(var y=0;y<i.length;y++)d[i[y]]!==void 0&&this["set"+e(i[y])](d[i[y]])}f(s,"StackFrame"),s.prototype={getArgs:function(){return this.args},setArgs:function(d){if(Object.prototype.toString.call(d)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=d},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(d){if(d instanceof s)this.evalOrigin=d;else if(d instanceof Object)this.evalOrigin=new s(d);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var d=this.getFileName()||"",y=this.getLineNumber()||"",w=this.getColumnNumber()||"",E=this.getFunctionName()||"";return this.getIsEval()?d?"[eval] ("+d+":"+y+":"+w+")":"[eval]:"+y+":"+w:E?E+" ("+d+":"+y+":"+w+")":d+":"+y+":"+w}},s.fromString=f(function(y){var w=y.indexOf("("),E=y.lastIndexOf(")"),ne=y.substring(0,w),ie=y.substring(w+1,E).split(","),M=y.substring(E+1);if(M.indexOf("@")===0)var k=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(M,""),oe=k[1],ae=k[2],se=k[3];return new s({functionName:ne,args:ie||void 0,fileName:oe,lineNumber:ae||void 0,columnNumber:se||void 0})},"StackFrame$$fromString");for(var l=0;l<o.length;l++)s.prototype["get"+e(o[l])]=c(o[l]),s.prototype["set"+e(o[l])]=function(d){return function(y){this[d]=!!y}}(o[l]);for(var m=0;m<a.length;m++)s.prototype["get"+e(a[m])]=c(a[m]),s.prototype["set"+e(a[m])]=function(d){return function(y){if(!t(y))throw new TypeError(d+" must be a Number");this[d]=Number(y)}}(a[m]);for(var p=0;p<r.length;p++)s.prototype["get"+e(r[p])]=c(r[p]),s.prototype["set"+e(r[p])]=function(d){return function(y){this[d]=String(y)}}(r[p]);return s})});var j=U((R,W)=>{(function(t,e){"use strict";typeof define=="function"&&define.amd?define("error-stack-parser",["stackframe"],e):typeof R=="object"?W.exports=e(B()):t.ErrorStackParser=e(t.StackFrame)})(R,f(function(e){"use strict";var c=/(^|@)\S+:\d+/,o=/^\s*at .*(\S+:\d+|\(native\))/m,a=/^(eval@)?(\[native code])?$/;return{parse:f(function(n){if(typeof n.stacktrace<"u"||typeof n["opera#sourceloc"]<"u")return this.parseOpera(n);if(n.stack&&n.stack.match(o))return this.parseV8OrIE(n);if(n.stack)return this.parseFFOrSafari(n);throw new Error("Cannot parse given Error object")},"ErrorStackParser$$parse"),extractLocation:f(function(n){if(n.indexOf(":")===-1)return[n];var u=/(.+?)(?::(\d+))?(?::(\d+))?$/,i=u.exec(n.replace(/[()]/g,""));return[i[1],i[2]||void 0,i[3]||void 0]},"ErrorStackParser$$extractLocation"),parseV8OrIE:f(function(n){var u=n.stack.split(`
1
+ "use strict";var loadPyodide=(()=>{var se=Object.create;var _=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var de=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var f=(t,e)=>_(t,"name",{value:e,configurable:!0}),g=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,c)=>(typeof require<"u"?require:e)[c]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ue=(t,e)=>{for(var c in e)_(t,c,{get:e[c],enumerable:!0})},U=(t,e,c,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of le(e))!fe.call(t,a)&&a!==c&&_(t,a,{get:()=>e[a],enumerable:!(o=ce(e,a))||o.enumerable});return t};var v=(t,e,c)=>(c=t!=null?se(de(t)):{},U(e||!t||!t.__esModule?_(c,"default",{value:t,enumerable:!0}):c,t)),pe=t=>U(_({},"__esModule",{value:!0}),t);var C=$((N,M)=>{(function(t,e){"use strict";typeof define=="function"&&define.amd?define("stackframe",[],e):typeof N=="object"?M.exports=e():t.StackFrame=e()})(N,function(){"use strict";function t(d){return!isNaN(parseFloat(d))&&isFinite(d)}f(t,"_isNumber");function e(d){return d.charAt(0).toUpperCase()+d.substring(1)}f(e,"_capitalize");function c(d){return function(){return this[d]}}f(c,"_getter");var o=["isConstructor","isEval","isNative","isToplevel"],a=["columnNumber","lineNumber"],r=["fileName","functionName","source"],n=["args"],u=["evalOrigin"],i=o.concat(a,r,n,u);function s(d){if(d)for(var y=0;y<i.length;y++)d[i[y]]!==void 0&&this["set"+e(i[y])](d[i[y]])}f(s,"StackFrame"),s.prototype={getArgs:function(){return this.args},setArgs:function(d){if(Object.prototype.toString.call(d)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=d},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(d){if(d instanceof s)this.evalOrigin=d;else if(d instanceof Object)this.evalOrigin=new s(d);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var d=this.getFileName()||"",y=this.getLineNumber()||"",w=this.getColumnNumber()||"",E=this.getFunctionName()||"";return this.getIsEval()?d?"[eval] ("+d+":"+y+":"+w+")":"[eval]:"+y+":"+w:E?E+" ("+d+":"+y+":"+w+")":d+":"+y+":"+w}},s.fromString=f(function(y){var w=y.indexOf("("),E=y.lastIndexOf(")"),re=y.substring(0,w),ne=y.substring(w+1,E).split(","),T=y.substring(E+1);if(T.indexOf("@")===0)var R=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(T,""),ie=R[1],oe=R[2],ae=R[3];return new s({functionName:re,args:ne||void 0,fileName:ie,lineNumber:oe||void 0,columnNumber:ae||void 0})},"StackFrame$$fromString");for(var l=0;l<o.length;l++)s.prototype["get"+e(o[l])]=c(o[l]),s.prototype["set"+e(o[l])]=function(d){return function(y){this[d]=!!y}}(o[l]);for(var m=0;m<a.length;m++)s.prototype["get"+e(a[m])]=c(a[m]),s.prototype["set"+e(a[m])]=function(d){return function(y){if(!t(y))throw new TypeError(d+" must be a Number");this[d]=Number(y)}}(a[m]);for(var p=0;p<r.length;p++)s.prototype["get"+e(r[p])]=c(r[p]),s.prototype["set"+e(r[p])]=function(d){return function(y){this[d]=String(y)}}(r[p]);return s})});var j=$((P,B)=>{(function(t,e){"use strict";typeof define=="function"&&define.amd?define("error-stack-parser",["stackframe"],e):typeof P=="object"?B.exports=e(C()):t.ErrorStackParser=e(t.StackFrame)})(P,f(function(e){"use strict";var c=/(^|@)\S+:\d+/,o=/^\s*at .*(\S+:\d+|\(native\))/m,a=/^(eval@)?(\[native code])?$/;return{parse:f(function(n){if(typeof n.stacktrace<"u"||typeof n["opera#sourceloc"]<"u")return this.parseOpera(n);if(n.stack&&n.stack.match(o))return this.parseV8OrIE(n);if(n.stack)return this.parseFFOrSafari(n);throw new Error("Cannot parse given Error object")},"ErrorStackParser$$parse"),extractLocation:f(function(n){if(n.indexOf(":")===-1)return[n];var u=/(.+?)(?::(\d+))?(?::(\d+))?$/,i=u.exec(n.replace(/[()]/g,""));return[i[1],i[2]||void 0,i[3]||void 0]},"ErrorStackParser$$extractLocation"),parseV8OrIE:f(function(n){var u=n.stack.split(`
2
2
  `).filter(function(i){return!!i.match(o)},this);return u.map(function(i){i.indexOf("(eval ")>-1&&(i=i.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var s=i.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),l=s.match(/ (\(.+\)$)/);s=l?s.replace(l[0],""):s;var m=this.extractLocation(l?l[1]:s),p=l&&s||void 0,d=["eval","<anonymous>"].indexOf(m[0])>-1?void 0:m[0];return new e({functionName:p,fileName:d,lineNumber:m[1],columnNumber:m[2],source:i})},this)},"ErrorStackParser$$parseV8OrIE"),parseFFOrSafari:f(function(n){var u=n.stack.split(`
3
3
  `).filter(function(i){return!i.match(a)},this);return u.map(function(i){if(i.indexOf(" > eval")>-1&&(i=i.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),i.indexOf("@")===-1&&i.indexOf(":")===-1)return new e({functionName:i});var s=/((.*".+"[^@]*)?[^@]*)(?:@)/,l=i.match(s),m=l&&l[1]?l[1]:void 0,p=this.extractLocation(i.replace(s,""));return new e({functionName:m,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:i})},this)},"ErrorStackParser$$parseFFOrSafari"),parseOpera:f(function(n){return!n.stacktrace||n.message.indexOf(`
4
4
  `)>-1&&n.message.split(`
@@ -6,7 +6,9 @@
6
6
  `).length?this.parseOpera9(n):n.stack?this.parseOpera11(n):this.parseOpera10(n)},"ErrorStackParser$$parseOpera"),parseOpera9:f(function(n){for(var u=/Line (\d+).*script (?:in )?(\S+)/i,i=n.message.split(`
7
7
  `),s=[],l=2,m=i.length;l<m;l+=2){var p=u.exec(i[l]);p&&s.push(new e({fileName:p[2],lineNumber:p[1],source:i[l]}))}return s},"ErrorStackParser$$parseOpera9"),parseOpera10:f(function(n){for(var u=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,i=n.stacktrace.split(`
8
8
  `),s=[],l=0,m=i.length;l<m;l+=2){var p=u.exec(i[l]);p&&s.push(new e({functionName:p[3]||void 0,fileName:p[2],lineNumber:p[1],source:i[l]}))}return s},"ErrorStackParser$$parseOpera10"),parseOpera11:f(function(n){var u=n.stack.split(`
9
- `).filter(function(i){return!!i.match(c)&&!i.match(/^Error created at/)},this);return u.map(function(i){var s=i.split("@"),l=this.extractLocation(s.pop()),m=s.shift()||"",p=m.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,d;m.match(/\(([^)]*)\)/)&&(d=m.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var y=d===void 0||d==="[arguments not available]"?void 0:d.split(",");return new e({functionName:p,args:y,fileName:l[0],lineNumber:l[1],columnNumber:l[2],source:i})},this)},"ErrorStackParser$$parseOpera11")}},"ErrorStackParser"))});var ke={};pe(ke,{loadPyodide:()=>T,version:()=>b});var G=h(j());var v=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&typeof process.browser>"u",F=v&&typeof module<"u"&&typeof module.exports<"u"&&typeof g<"u"&&typeof __dirname<"u",H=v&&!F,ye=typeof Deno<"u",z=!v&&!ye,q=z&&typeof window<"u"&&typeof document<"u"&&typeof document.createElement<"u"&&typeof sessionStorage<"u",V=z&&typeof importScripts<"u"&&typeof self<"u";var K,O,L,X,D,ge=`"fetch" is not defined, maybe you're using node < 18? From Pyodide >= 0.25.0, node >= 18 is required. Older versions of Node.js may work, but it is not guaranteed or supported. Falling back to "node-fetch".`;async function I(){if(!v||(K=(await import(/* webpackIgnore */"url")).default,D=await import(/* webpackIgnore */"fs/promises"),globalThis.fetch?O=fetch:(console.warn(ge),O=(await import(/* webpackIgnore */"node-fetch")).default),X=(await import(/* webpackIgnore */"vm")).default,L=await import(/* webpackIgnore */"path"),A=L.sep,typeof g<"u"))return;let t=await import(/* webpackIgnore */"fs"),e=await import(/* webpackIgnore */"crypto"),c=await import(/* webpackIgnore */"ws"),o=await import(/* webpackIgnore */"child_process"),a={fs:t,crypto:e,ws:c,child_process:o};globalThis.require=function(r){return a[r]}}f(I,"initNodeModules");function he(t,e){return L.resolve(e||".",t)}f(he,"node_resolvePath");function ve(t,e){return e===void 0&&(e=location),new URL(t,e).toString()}f(ve,"browser_resolvePath");var x;v?x=he:x=ve;var A;v||(A="/");function we(t,e){return t.startsWith("file://")&&(t=t.slice(7)),t.includes("://")?{response:O(t)}:{binary:D.readFile(t).then(c=>new Uint8Array(c.buffer,c.byteOffset,c.byteLength))}}f(we,"node_getBinaryResponse");function be(t,e){let c=new URL(t,location);return{response:fetch(c,e?{integrity:e}:{})}}f(be,"browser_getBinaryResponse");var S;v?S=we:S=be;async function J(t,e){let{response:c,binary:o}=S(t,e);if(o)return o;let a=await c;if(!a.ok)throw new Error(`Failed to load '${t}': request failed.`);return new Uint8Array(await a.arrayBuffer())}f(J,"loadBinaryFile");var P;if(q)P=f(async t=>await import(/* webpackIgnore */t),"loadScript");else if(V)P=f(async t=>{try{globalThis.importScripts(t)}catch(e){if(e instanceof TypeError)await import(/* webpackIgnore */t);else throw e}},"loadScript");else if(v)P=Ee;else throw new Error("Cannot determine runtime environment");async function Ee(t){t.startsWith("file://")&&(t=t.slice(7)),t.includes("://")?X.runInThisContext(await(await O(t)).text()):await import(/* webpackIgnore */K.pathToFileURL(t).href)}f(Ee,"nodeLoadScript");async function Y(t){if(v){await I();let e=await D.readFile(t);return JSON.parse(e)}else return await(await fetch(t)).json()}f(Y,"loadLockFile");async function Q(){if(F)return __dirname;let t;try{throw new Error}catch(o){t=o}let e=G.default.parse(t)[0].fileName;if(H){let o=await import(/* webpackIgnore */"path");return(await import(/* webpackIgnore */"url")).fileURLToPath(o.dirname(e))}let c=e.lastIndexOf(A);if(c===-1)throw new Error("Could not extract indexURL path from pyodide module location");return e.slice(0,c)}f(Q,"calculateDirname");function Z(t){let e=t.FS,c=t.FS.filesystems.MEMFS,o=t.PATH,a={DIR_MODE:16895,FILE_MODE:33279,mount:function(r){if(!r.opts.fileSystemHandle)throw new Error("opts.fileSystemHandle is required");return c.mount.apply(null,arguments)},syncfs:async(r,n,u)=>{try{let i=a.getLocalSet(r),s=await a.getRemoteSet(r),l=n?s:i,m=n?i:s;await a.reconcile(r,l,m),u(null)}catch(i){u(i)}},getLocalSet:r=>{let n=Object.create(null);function u(l){return l!=="."&&l!==".."}f(u,"isRealDir");function i(l){return m=>o.join2(l,m)}f(i,"toAbsolute");let s=e.readdir(r.mountpoint).filter(u).map(i(r.mountpoint));for(;s.length;){let l=s.pop(),m=e.stat(l);e.isDir(m.mode)&&s.push.apply(s,e.readdir(l).filter(u).map(i(l))),n[l]={timestamp:m.mtime,mode:m.mode}}return{type:"local",entries:n}},getRemoteSet:async r=>{let n=Object.create(null),u=await _e(r.opts.fileSystemHandle);for(let[i,s]of u)i!=="."&&(n[o.join2(r.mountpoint,i)]={timestamp:s.kind==="file"?(await s.getFile()).lastModifiedDate:new Date,mode:s.kind==="file"?a.FILE_MODE:a.DIR_MODE});return{type:"remote",entries:n,handles:u}},loadLocalEntry:r=>{let u=e.lookupPath(r).node,i=e.stat(r);if(e.isDir(i.mode))return{timestamp:i.mtime,mode:i.mode};if(e.isFile(i.mode))return u.contents=c.getFileDataAsTypedArray(u),{timestamp:i.mtime,mode:i.mode,contents:u.contents};throw new Error("node type not supported")},storeLocalEntry:(r,n)=>{if(e.isDir(n.mode))e.mkdirTree(r,n.mode);else if(e.isFile(n.mode))e.writeFile(r,n.contents,{canOwn:!0});else throw new Error("node type not supported");e.chmod(r,n.mode),e.utime(r,n.timestamp,n.timestamp)},removeLocalEntry:r=>{var n=e.stat(r);e.isDir(n.mode)?e.rmdir(r):e.isFile(n.mode)&&e.unlink(r)},loadRemoteEntry:async r=>{if(r.kind==="file"){let n=await r.getFile();return{contents:new Uint8Array(await n.arrayBuffer()),mode:a.FILE_MODE,timestamp:n.lastModifiedDate}}else{if(r.kind==="directory")return{mode:a.DIR_MODE,timestamp:new Date};throw new Error("unknown kind: "+r.kind)}},storeRemoteEntry:async(r,n,u)=>{let i=r.get(o.dirname(n)),s=e.isFile(u.mode)?await i.getFileHandle(o.basename(n),{create:!0}):await i.getDirectoryHandle(o.basename(n),{create:!0});if(s.kind==="file"){let l=await s.createWritable();await l.write(u.contents),await l.close()}r.set(n,s)},removeRemoteEntry:async(r,n)=>{await r.get(o.dirname(n)).removeEntry(o.basename(n)),r.delete(n)},reconcile:async(r,n,u)=>{let i=0,s=[];Object.keys(n.entries).forEach(function(p){let d=n.entries[p],y=u.entries[p];(!y||e.isFile(d.mode)&&d.timestamp.getTime()>y.timestamp.getTime())&&(s.push(p),i++)}),s.sort();let l=[];if(Object.keys(u.entries).forEach(function(p){n.entries[p]||(l.push(p),i++)}),l.sort().reverse(),!i)return;let m=n.type==="remote"?n.handles:u.handles;for(let p of s){let d=o.normalize(p.replace(r.mountpoint,"/")).substring(1);if(u.type==="local"){let y=m.get(d),w=await a.loadRemoteEntry(y);a.storeLocalEntry(p,w)}else{let y=a.loadLocalEntry(p);await a.storeRemoteEntry(m,d,y)}}for(let p of l)if(u.type==="local")a.removeLocalEntry(p);else{let d=o.normalize(p.replace(r.mountpoint,"/")).substring(1);await a.removeRemoteEntry(m,d)}}};t.FS.filesystems.NATIVEFS_ASYNC=a}f(Z,"initializeNativeFS");var _e=f(async t=>{let e=[];async function c(a){for await(let r of a.values())e.push(r),r.kind==="directory"&&await c(r)}f(c,"collect"),await c(t);let o=new Map;o.set(".",t);for(let a of e){let r=(await t.resolve(a)).join("/");o.set(r,a)}return o},"getFsHandles");function ee(){let t={};return t.noImageDecoding=!0,t.noAudioDecoding=!0,t.noWasmDecoding=!1,t.preRun=[],t.quit=(e,c)=>{throw t.exited={status:e,toThrow:c},c},t}f(ee,"createModule");function Pe(t,e){t.preRun.push(function(){let c="/";try{t.FS.mkdirTree(e)}catch(o){console.error(`Error occurred while making a home directory '${e}':`),console.error(o),console.error(`Using '${c}' for a home directory instead`),e=c}t.FS.chdir(e)})}f(Pe,"createHomeDirectory");function Se(t,e){t.preRun.push(function(){Object.assign(t.ENV,e)})}f(Se,"setEnvironment");function Oe(t,e){t.preRun.push(()=>{for(let c of e)t.FS.mkdirTree(c),t.FS.mount(t.FS.filesystems.NODEFS,{root:c},c)})}f(Oe,"mountLocalDirectories");function xe(t,e){let c=J(e);t.preRun.push(()=>{let o=t._py_version_major(),a=t._py_version_minor();t.FS.mkdirTree("/lib"),t.FS.mkdirTree(`/lib/python${o}.${a}/site-packages`),t.addRunDependency("install-stdlib"),c.then(r=>{t.FS.writeFile(`/lib/python${o}${a}.zip`,r)}).catch(r=>{console.error("Error occurred while installing the standard library:"),console.error(r)}).finally(()=>{t.removeRunDependency("install-stdlib")})})}f(xe,"installStdlib");function te(t,e){let c;e.stdLibURL!=null?c=e.stdLibURL:c=e.indexURL+"python_stdlib.zip",xe(t,c),Pe(t,e.env.HOME),Se(t,e.env),Oe(t,e._node_mounts),t.preRun.push(()=>Z(t))}f(te,"initializeFileSystem");function re(t,e){let{binary:c,response:o}=S(e+"pyodide.asm.wasm");t.instantiateWasm=function(a,r){return async function(){try{let n;o?n=await WebAssembly.instantiateStreaming(o,a):n=await WebAssembly.instantiate(await c,a);let{instance:u,module:i}=n;typeof WasmOffsetConverter<"u"&&(wasmOffsetConverter=new WasmOffsetConverter(wasmBinary,i)),r(u,i)}catch(n){console.warn("wasm instantiation failed!"),console.warn(n)}}(),{}}}f(re,"preloadWasm");var b="0.25.0a2";async function T(t={}){await I();let e=t.indexURL||await Q();e=x(e),e.endsWith("/")||(e+="/"),t.indexURL=e;let c={fullStdLib:!1,jsglobals:globalThis,stdin:globalThis.prompt?globalThis.prompt:void 0,lockFileURL:e+"pyodide-lock.json",args:[],_node_mounts:[],env:{},packageCacheDir:e,packages:[]},o=Object.assign(c,t);if(t.homedir){if(console.warn("The homedir argument to loadPyodide is deprecated. Use 'env: { HOME: value }' instead of 'homedir: value'."),t.env&&t.env.HOME)throw new Error("Set both env.HOME and homedir arguments");o.env.HOME=o.homedir}o.env.HOME||(o.env.HOME="/home/pyodide");let a=ee();a.print=o.stdout,a.printErr=o.stderr,a.arguments=o.args;let r={config:o};a.API=r,r.lockFilePromise=Y(o.lockFileURL),re(a,e),te(a,o);let n=new Promise(s=>a.postRun=s);if(a.locateFile=s=>o.indexURL+s,typeof _createPyodideModule!="function"){let s=`${o.indexURL}pyodide.asm.js`;await P(s)}if(await _createPyodideModule(a),await n,a.exited)throw a.exited.toThrow;if(t.pyproxyToStringRepr&&r.setPyProxyToStringMethod(!0),r.version!==b)throw new Error(`Pyodide version does not match: '${b}' <==> '${r.version}'. If you updated the Pyodide version, make sure you also updated the 'indexURL' parameter passed to loadPyodide.`);a.locateFile=s=>{throw new Error("Didn't expect to load any more file_packager files!")};let u=r.finalizeBootstrap();if(u.version.includes("dev")||r.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${u.version}/full/`),await r.packageIndexReady,r._pyodide._importhook.register_module_not_found_hook(r._import_name_to_package_name,r.lockfile_unvendored_stdlibs_and_test),r.lockfile_info.version!==b)throw new Error("Lock file version doesn't match Pyodide version");return r.package_loader.init_loaded_packages(),o.fullStdLib&&await u.loadPackage(r.lockfile_unvendored_stdlibs),r.initializeStreams(o.stdin,o.stdout,o.stderr),u}f(T,"loadPyodide");globalThis.loadPyodide=T;return me(ke);})();
9
+ `).filter(function(i){return!!i.match(c)&&!i.match(/^Error created at/)},this);return u.map(function(i){var s=i.split("@"),l=this.extractLocation(s.pop()),m=s.shift()||"",p=m.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,d;m.match(/\(([^)]*)\)/)&&(d=m.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var y=d===void 0||d==="[arguments not available]"?void 0:d.split(",");return new e({functionName:p,args:y,fileName:l[0],lineNumber:l[1],columnNumber:l[2],source:i})},this)},"ErrorStackParser$$parseOpera11")}},"ErrorStackParser"))});var ke={};ue(ke,{loadPyodide:()=>I,version:()=>b});var V=v(j());var h=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&typeof process.browser>"u",x=h&&typeof module<"u"&&typeof module.exports<"u"&&typeof g<"u"&&typeof __dirname<"u",W=h&&!x,me=typeof Deno<"u",H=!h&&!me,z=H&&typeof window<"u"&&typeof document<"u"&&typeof document.createElement<"u"&&typeof sessionStorage<"u",q=H&&typeof importScripts<"u"&&typeof self<"u";var K,F,X,L;async function D(){if(!h||(K=(await import(/* webpackIgnore */"url")).default,L=await import(/* webpackIgnore */"fs/promises"),X=(await import(/* webpackIgnore */"vm")).default,F=await import(/* webpackIgnore */"path"),A=F.sep,typeof g<"u"))return;let t=await import(/* webpackIgnore */"fs"),e=await import(/* webpackIgnore */"crypto"),c=await import(/* webpackIgnore */"ws"),o=await import(/* webpackIgnore */"child_process"),a={fs:t,crypto:e,ws:c,child_process:o};globalThis.require=function(r){return a[r]}}f(D,"initNodeModules");function ye(t,e){return F.resolve(e||".",t)}f(ye,"node_resolvePath");function ge(t,e){return e===void 0&&(e=location),new URL(t,e).toString()}f(ge,"browser_resolvePath");var k;h?k=ye:k=ge;var A;h||(A="/");function ve(t,e){return t.startsWith("file://")&&(t=t.slice(7)),t.includes("://")?{response:fetch(t)}:{binary:L.readFile(t).then(c=>new Uint8Array(c.buffer,c.byteOffset,c.byteLength))}}f(ve,"node_getBinaryResponse");function he(t,e){let c=new URL(t,location);return{response:fetch(c,e?{integrity:e}:{})}}f(he,"browser_getBinaryResponse");var O;h?O=ve:O=he;async function G(t,e){let{response:c,binary:o}=O(t,e);if(o)return o;let a=await c;if(!a.ok)throw new Error(`Failed to load '${t}': request failed.`);return new Uint8Array(await a.arrayBuffer())}f(G,"loadBinaryFile");var S;if(z)S=f(async t=>await import(/* webpackIgnore */t),"loadScript");else if(q)S=f(async t=>{try{globalThis.importScripts(t)}catch(e){if(e instanceof TypeError)await import(/* webpackIgnore */t);else throw e}},"loadScript");else if(h)S=we;else throw new Error("Cannot determine runtime environment");async function we(t){t.startsWith("file://")&&(t=t.slice(7)),t.includes("://")?X.runInThisContext(await(await fetch(t)).text()):await import(/* webpackIgnore */K.pathToFileURL(t).href)}f(we,"nodeLoadScript");async function J(t){if(h){await D();let e=await L.readFile(t);return JSON.parse(e)}else return await(await fetch(t)).json()}f(J,"loadLockFile");async function Y(){if(x)return __dirname;let t;try{throw new Error}catch(o){t=o}let e=V.default.parse(t)[0].fileName;if(W){let o=await import(/* webpackIgnore */"path");return(await import(/* webpackIgnore */"url")).fileURLToPath(o.dirname(e))}let c=e.lastIndexOf(A);if(c===-1)throw new Error("Could not extract indexURL path from pyodide module location");return e.slice(0,c)}f(Y,"calculateDirname");function Q(t){let e=t.FS,c=t.FS.filesystems.MEMFS,o=t.PATH,a={DIR_MODE:16895,FILE_MODE:33279,mount:function(r){if(!r.opts.fileSystemHandle)throw new Error("opts.fileSystemHandle is required");return c.mount.apply(null,arguments)},syncfs:async(r,n,u)=>{try{let i=a.getLocalSet(r),s=await a.getRemoteSet(r),l=n?s:i,m=n?i:s;await a.reconcile(r,l,m),u(null)}catch(i){u(i)}},getLocalSet:r=>{let n=Object.create(null);function u(l){return l!=="."&&l!==".."}f(u,"isRealDir");function i(l){return m=>o.join2(l,m)}f(i,"toAbsolute");let s=e.readdir(r.mountpoint).filter(u).map(i(r.mountpoint));for(;s.length;){let l=s.pop(),m=e.stat(l);e.isDir(m.mode)&&s.push.apply(s,e.readdir(l).filter(u).map(i(l))),n[l]={timestamp:m.mtime,mode:m.mode}}return{type:"local",entries:n}},getRemoteSet:async r=>{let n=Object.create(null),u=await be(r.opts.fileSystemHandle);for(let[i,s]of u)i!=="."&&(n[o.join2(r.mountpoint,i)]={timestamp:s.kind==="file"?(await s.getFile()).lastModifiedDate:new Date,mode:s.kind==="file"?a.FILE_MODE:a.DIR_MODE});return{type:"remote",entries:n,handles:u}},loadLocalEntry:r=>{let u=e.lookupPath(r).node,i=e.stat(r);if(e.isDir(i.mode))return{timestamp:i.mtime,mode:i.mode};if(e.isFile(i.mode))return u.contents=c.getFileDataAsTypedArray(u),{timestamp:i.mtime,mode:i.mode,contents:u.contents};throw new Error("node type not supported")},storeLocalEntry:(r,n)=>{if(e.isDir(n.mode))e.mkdirTree(r,n.mode);else if(e.isFile(n.mode))e.writeFile(r,n.contents,{canOwn:!0});else throw new Error("node type not supported");e.chmod(r,n.mode),e.utime(r,n.timestamp,n.timestamp)},removeLocalEntry:r=>{var n=e.stat(r);e.isDir(n.mode)?e.rmdir(r):e.isFile(n.mode)&&e.unlink(r)},loadRemoteEntry:async r=>{if(r.kind==="file"){let n=await r.getFile();return{contents:new Uint8Array(await n.arrayBuffer()),mode:a.FILE_MODE,timestamp:n.lastModifiedDate}}else{if(r.kind==="directory")return{mode:a.DIR_MODE,timestamp:new Date};throw new Error("unknown kind: "+r.kind)}},storeRemoteEntry:async(r,n,u)=>{let i=r.get(o.dirname(n)),s=e.isFile(u.mode)?await i.getFileHandle(o.basename(n),{create:!0}):await i.getDirectoryHandle(o.basename(n),{create:!0});if(s.kind==="file"){let l=await s.createWritable();await l.write(u.contents),await l.close()}r.set(n,s)},removeRemoteEntry:async(r,n)=>{await r.get(o.dirname(n)).removeEntry(o.basename(n)),r.delete(n)},reconcile:async(r,n,u)=>{let i=0,s=[];Object.keys(n.entries).forEach(function(p){let d=n.entries[p],y=u.entries[p];(!y||e.isFile(d.mode)&&d.timestamp.getTime()>y.timestamp.getTime())&&(s.push(p),i++)}),s.sort();let l=[];if(Object.keys(u.entries).forEach(function(p){n.entries[p]||(l.push(p),i++)}),l.sort().reverse(),!i)return;let m=n.type==="remote"?n.handles:u.handles;for(let p of s){let d=o.normalize(p.replace(r.mountpoint,"/")).substring(1);if(u.type==="local"){let y=m.get(d),w=await a.loadRemoteEntry(y);a.storeLocalEntry(p,w)}else{let y=a.loadLocalEntry(p);await a.storeRemoteEntry(m,d,y)}}for(let p of l)if(u.type==="local")a.removeLocalEntry(p);else{let d=o.normalize(p.replace(r.mountpoint,"/")).substring(1);await a.removeRemoteEntry(m,d)}}};t.FS.filesystems.NATIVEFS_ASYNC=a}f(Q,"initializeNativeFS");var be=f(async t=>{let e=[];async function c(a){for await(let r of a.values())e.push(r),r.kind==="directory"&&await c(r)}f(c,"collect"),await c(t);let o=new Map;o.set(".",t);for(let a of e){let r=(await t.resolve(a)).join("/");o.set(r,a)}return o},"getFsHandles");function Z(){let t={};return t.noImageDecoding=!0,t.noAudioDecoding=!0,t.noWasmDecoding=!1,t.preRun=[],t.quit=(e,c)=>{throw t.exited={status:e,toThrow:c},c},t}f(Z,"createModule");function Ee(t,e){t.preRun.push(function(){let c="/";try{t.FS.mkdirTree(e)}catch(o){console.error(`Error occurred while making a home directory '${e}':`),console.error(o),console.error(`Using '${c}' for a home directory instead`),e=c}t.FS.chdir(e)})}f(Ee,"createHomeDirectory");function _e(t,e){t.preRun.push(function(){Object.assign(t.ENV,e)})}f(_e,"setEnvironment");function Se(t,e){t.preRun.push(()=>{for(let c of e)t.FS.mkdirTree(c),t.FS.mount(t.FS.filesystems.NODEFS,{root:c},c)})}f(Se,"mountLocalDirectories");function Oe(t,e){let c=G(e);t.preRun.push(()=>{let o=t._py_version_major(),a=t._py_version_minor();t.FS.mkdirTree("/lib"),t.FS.mkdirTree(`/lib/python${o}.${a}/site-packages`),t.addRunDependency("install-stdlib"),c.then(r=>{t.FS.writeFile(`/lib/python${o}${a}.zip`,r)}).catch(r=>{console.error("Error occurred while installing the standard library:"),console.error(r)}).finally(()=>{t.removeRunDependency("install-stdlib")})})}f(Oe,"installStdlib");function ee(t,e){let c;e.stdLibURL!=null?c=e.stdLibURL:c=e.indexURL+"python_stdlib.zip",Oe(t,c),Ee(t,e.env.HOME),_e(t,e.env),Se(t,e._node_mounts),t.preRun.push(()=>Q(t))}f(ee,"initializeFileSystem");function te(t,e){let{binary:c,response:o}=O(e+"pyodide.asm.wasm");t.instantiateWasm=function(a,r){return async function(){try{let n;o?n=await WebAssembly.instantiateStreaming(o,a):n=await WebAssembly.instantiate(await c,a);let{instance:u,module:i}=n;typeof WasmOffsetConverter<"u"&&(wasmOffsetConverter=new WasmOffsetConverter(wasmBinary,i)),r(u,i)}catch(n){console.warn("wasm instantiation failed!"),console.warn(n)}}(),{}}}f(te,"preloadWasm");var b="0.26.0a1";async function I(t={}){await D();let e=t.indexURL||await Y();e=k(e),e.endsWith("/")||(e+="/"),t.indexURL=e;let c={fullStdLib:!1,jsglobals:globalThis,stdin:globalThis.prompt?globalThis.prompt:void 0,lockFileURL:e+"pyodide-lock.json",args:[],_node_mounts:[],env:{},packageCacheDir:e,packages:[]},o=Object.assign(c,t);o.env.HOME||(o.env.HOME="/home/pyodide");let a=Z();a.print=o.stdout,a.printErr=o.stderr,a.arguments=o.args;let r={config:o};a.API=r,r.lockFilePromise=J(o.lockFileURL),te(a,e),ee(a,o);let n=new Promise(s=>a.postRun=s);if(a.locateFile=s=>o.indexURL+s,typeof _createPyodideModule!="function"){let s=`${o.indexURL}pyodide.asm.js`;await S(s)}if(await _createPyodideModule(a),await n,a.exited)throw a.exited.toThrow;if(t.pyproxyToStringRepr&&r.setPyProxyToStringMethod(!0),r.version!==b)throw new Error(`Pyodide version does not match: '${b}' <==> '${r.version}'. If you updated the Pyodide version, make sure you also updated the 'indexURL' parameter passed to loadPyodide.`);a.locateFile=s=>{throw new Error("Didn't expect to load any more file_packager files!")};let u=r.finalizeBootstrap();if(u.version.includes("dev")||r.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${u.version}/full/`),await r.packageIndexReady,r._pyodide._importhook.register_module_not_found_hook(r._import_name_to_package_name,r.lockfile_unvendored_stdlibs_and_test),r.lockfile_info.version!==b)throw new Error(`Lock file version doesn't match Pyodide version.
10
+ lockfile version: ${r.lockfile_info.version}
11
+ pyodide version: ${b}`);return r.package_loader.init_loaded_packages(),o.fullStdLib&&await u.loadPackage(r.lockfile_unvendored_stdlibs),r.initializeStreams(o.stdin,o.stdout,o.stderr),u}f(I,"loadPyodide");globalThis.loadPyodide=I;return pe(ke);})();
10
12
  try{Object.assign(exports,loadPyodide)}catch(_){}
11
13
  globalThis.loadPyodide=loadPyodide.loadPyodide;
12
14
  //# sourceMappingURL=pyodide.js.map