pyodide 0.23.4 → 0.24.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/ffi.d.ts +268 -36
- package/package.json +5 -11
- package/pyodide-lock.json +3703 -0
- package/pyodide.asm.js +3 -3
- package/pyodide.asm.wasm +0 -0
- package/pyodide.d.ts +337 -43
- package/pyodide.js +12 -1
- package/pyodide.js.map +7 -1
- package/pyodide.mjs +10 -1
- package/pyodide.mjs.map +7 -1
- package/python_stdlib.zip +0 -0
- package/repodata.json +0 -1
package/pyodide.asm.wasm
CHANGED
|
Binary file
|
package/pyodide.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v6.
|
|
1
|
+
// Generated by dts-bundle-generator v6.13.0
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -15,33 +15,6 @@ interface CanvasInterface {
|
|
|
15
15
|
setCanvas3D(canvas: HTMLCanvasElement): void;
|
|
16
16
|
getCanvas3D(): HTMLCanvasElement | undefined;
|
|
17
17
|
}
|
|
18
|
-
declare type PyProxyCache = {
|
|
19
|
-
cacheId: number;
|
|
20
|
-
refcnt: number;
|
|
21
|
-
leaked?: boolean;
|
|
22
|
-
};
|
|
23
|
-
declare type PyProxyProps = {
|
|
24
|
-
/**
|
|
25
|
-
* captureThis tracks whether this should be passed as the first argument to
|
|
26
|
-
* the Python function or not. We keep it false by default. To make a PyProxy
|
|
27
|
-
* where the ``this`` argument is included, call the :js:meth:`captureThis` method.
|
|
28
|
-
*/
|
|
29
|
-
captureThis: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* isBound tracks whether bind has been called
|
|
32
|
-
*/
|
|
33
|
-
isBound: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* the ``this`` value that has been bound to the PyProxy
|
|
36
|
-
*/
|
|
37
|
-
boundThis?: any;
|
|
38
|
-
/**
|
|
39
|
-
* Any extra arguments passed to bind are used for partial function
|
|
40
|
-
* application. These are stored here.
|
|
41
|
-
*/
|
|
42
|
-
boundArgs: any[];
|
|
43
|
-
roundtrip: boolean;
|
|
44
|
-
};
|
|
45
18
|
/** @deprecated Use `import type { PyProxy } from "pyodide/ffi"` instead */
|
|
46
19
|
interface PyProxy {
|
|
47
20
|
[x: string]: any;
|
|
@@ -51,16 +24,9 @@ interface PyProxy {
|
|
|
51
24
|
* JavaScript. See :ref:`type-translations-pyproxy`.
|
|
52
25
|
*/
|
|
53
26
|
declare class PyProxy {
|
|
54
|
-
/** @private */
|
|
55
|
-
$$: {
|
|
56
|
-
ptr: number;
|
|
57
|
-
cache: PyProxyCache;
|
|
58
|
-
destroyed_msg?: string;
|
|
59
|
-
};
|
|
60
|
-
/** @private */
|
|
61
|
-
$$props: PyProxyProps;
|
|
62
27
|
/** @private */
|
|
63
28
|
$$flags: number;
|
|
29
|
+
/** @private */
|
|
64
30
|
static [Symbol.hasInstance](obj: any): obj is PyProxy;
|
|
65
31
|
/**
|
|
66
32
|
* @private
|
|
@@ -452,6 +418,272 @@ declare class PyAsyncGeneratorMethods {
|
|
|
452
418
|
*/
|
|
453
419
|
return(v: any): Promise<IteratorResult<any, any>>;
|
|
454
420
|
}
|
|
421
|
+
declare class PySequence extends PyProxy {
|
|
422
|
+
/** @private */
|
|
423
|
+
static [Symbol.hasInstance](obj: any): obj is PyProxy;
|
|
424
|
+
}
|
|
425
|
+
/** @deprecated Use `import type { PySequence } from "pyodide/ffi"` instead */
|
|
426
|
+
interface PySequence extends PySequenceMethods {
|
|
427
|
+
}
|
|
428
|
+
declare class PySequenceMethods {
|
|
429
|
+
get [Symbol.isConcatSpreadable](): boolean;
|
|
430
|
+
/**
|
|
431
|
+
* See :js:meth:`Array.join`. The :js:meth:`Array.join` method creates and
|
|
432
|
+
* returns a new string by concatenating all of the elements in the
|
|
433
|
+
* :py:class:`~collections.abc.Sequence`.
|
|
434
|
+
*
|
|
435
|
+
* @param separator A string to separate each pair of adjacent elements of the
|
|
436
|
+
* Sequence.
|
|
437
|
+
*
|
|
438
|
+
* @returns A string with all Sequence elements joined.
|
|
439
|
+
*/
|
|
440
|
+
join(separator?: string): string;
|
|
441
|
+
/**
|
|
442
|
+
* See :js:meth:`Array.slice`. The :js:meth:`Array.slice` method returns a
|
|
443
|
+
* shallow copy of a portion of a :py:class:`~collections.abc.Sequence` into a
|
|
444
|
+
* new array object selected from ``start`` to ``stop`` (`stop` not included)
|
|
445
|
+
* @param start Zero-based index at which to start extraction. Negative index
|
|
446
|
+
* counts back from the end of the Sequence.
|
|
447
|
+
* @param stop Zero-based index at which to end extraction. Negative index
|
|
448
|
+
* counts back from the end of the Sequence.
|
|
449
|
+
* @returns A new array containing the extracted elements.
|
|
450
|
+
*/
|
|
451
|
+
slice(start?: number, stop?: number): any;
|
|
452
|
+
/**
|
|
453
|
+
* See :js:meth:`Array.lastIndexOf`. Returns the last index at which a given
|
|
454
|
+
* element can be found in the Sequence, or -1 if it is not present.
|
|
455
|
+
* @param elt Element to locate in the Sequence.
|
|
456
|
+
* @param fromIndex Zero-based index at which to start searching backwards,
|
|
457
|
+
* converted to an integer. Negative index counts back from the end of the
|
|
458
|
+
* Sequence.
|
|
459
|
+
* @returns The last index of the element in the Sequence; -1 if not found.
|
|
460
|
+
*/
|
|
461
|
+
lastIndexOf(elt: any, fromIndex?: number): number;
|
|
462
|
+
/**
|
|
463
|
+
* See :js:meth:`Array.indexOf`. Returns the first index at which a given
|
|
464
|
+
* element can be found in the Sequence, or -1 if it is not present.
|
|
465
|
+
* @param elt Element to locate in the Sequence.
|
|
466
|
+
* @param fromIndex Zero-based index at which to start searching, converted to
|
|
467
|
+
* an integer. Negative index counts back from the end of the Sequence.
|
|
468
|
+
* @returns The first index of the element in the Sequence; -1 if not found.
|
|
469
|
+
*/
|
|
470
|
+
indexOf(elt: any, fromIndex?: number): number;
|
|
471
|
+
/**
|
|
472
|
+
* See :js:meth:`Array.forEach`. Executes a provided function once for each
|
|
473
|
+
* ``Sequence`` element.
|
|
474
|
+
* @param callbackfn A function to execute for each element in the ``Sequence``. Its
|
|
475
|
+
* return value is discarded.
|
|
476
|
+
* @param thisArg A value to use as ``this`` when executing ``callbackFn``.
|
|
477
|
+
*/
|
|
478
|
+
forEach(callbackfn: (elt: any) => void, thisArg?: any): void;
|
|
479
|
+
/**
|
|
480
|
+
* See :js:meth:`Array.map`. Creates a new array populated with the results of
|
|
481
|
+
* calling a provided function on every element in the calling ``Sequence``.
|
|
482
|
+
* @param callbackfn A function to execute for each element in the ``Sequence``. Its
|
|
483
|
+
* return value is added as a single element in the new array.
|
|
484
|
+
* @param thisArg A value to use as ``this`` when executing ``callbackFn``.
|
|
485
|
+
*/
|
|
486
|
+
map(callbackfn: (elt: any, index: number, array: any) => void, thisArg?: any): unknown[];
|
|
487
|
+
/**
|
|
488
|
+
* See :js:meth:`Array.filter`. Creates a shallow copy of a portion of a given
|
|
489
|
+
* ``Sequence``, filtered down to just the elements from the given array that pass
|
|
490
|
+
* the test implemented by the provided function.
|
|
491
|
+
* @param callbackfn A function to execute for each element in the array. It
|
|
492
|
+
* should return a truthy value to keep the element in the resulting array,
|
|
493
|
+
* and a falsy value otherwise.
|
|
494
|
+
* @param thisArg A value to use as ``this`` when executing ``predicate``.
|
|
495
|
+
*/
|
|
496
|
+
filter(predicate: (elt: any, index: number, array: any) => boolean, thisArg?: any): any[];
|
|
497
|
+
/**
|
|
498
|
+
* See :js:meth:`Array.some`. Tests whether at least one element in the
|
|
499
|
+
* ``Sequence`` passes the test implemented by the provided function.
|
|
500
|
+
* @param callbackfn A function to execute for each element in the
|
|
501
|
+
* ``Sequence``. It should return a truthy value to indicate the element
|
|
502
|
+
* passes the test, and a falsy value otherwise.
|
|
503
|
+
* @param thisArg A value to use as ``this`` when executing ``predicate``.
|
|
504
|
+
*/
|
|
505
|
+
some(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
|
|
506
|
+
/**
|
|
507
|
+
* See :js:meth:`Array.every`. Tests whether every element in the ``Sequence``
|
|
508
|
+
* passes the test implemented by the provided function.
|
|
509
|
+
* @param callbackfn A function to execute for each element in the
|
|
510
|
+
* ``Sequence``. It should return a truthy value to indicate the element
|
|
511
|
+
* passes the test, and a falsy value otherwise.
|
|
512
|
+
* @param thisArg A value to use as ``this`` when executing ``predicate``.
|
|
513
|
+
*/
|
|
514
|
+
every(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
|
|
515
|
+
/**
|
|
516
|
+
* See :js:meth:`Array.reduce`. Executes a user-supplied "reducer" callback
|
|
517
|
+
* function on each element of the Sequence, in order, passing in the return
|
|
518
|
+
* value from the calculation on the preceding element. The final result of
|
|
519
|
+
* running the reducer across all elements of the Sequence is a single value.
|
|
520
|
+
* @param callbackfn A function to execute for each element in the ``Sequence``. Its
|
|
521
|
+
* return value is discarded.
|
|
522
|
+
* @param thisArg A value to use as ``this`` when executing ``callbackfn``.
|
|
523
|
+
*/
|
|
524
|
+
reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any) => any, initialValue?: any): any;
|
|
525
|
+
/**
|
|
526
|
+
* See :js:meth:`Array.reduceRight`. Applies a function against an accumulator
|
|
527
|
+
* and each value of the Sequence (from right to left) to reduce it to a
|
|
528
|
+
* single value.
|
|
529
|
+
* @param callbackfn A function to execute for each element in the Sequence.
|
|
530
|
+
* Its return value is discarded.
|
|
531
|
+
* @param thisArg A value to use as ``this`` when executing ``callbackFn``.
|
|
532
|
+
*/
|
|
533
|
+
reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any) => any, initialValue: any): any;
|
|
534
|
+
/**
|
|
535
|
+
* See :js:meth:`Array.at`. Takes an integer value and returns the item at
|
|
536
|
+
* that index.
|
|
537
|
+
* @param index Zero-based index of the Sequence element to be returned,
|
|
538
|
+
* converted to an integer. Negative index counts back from the end of the
|
|
539
|
+
* Sequence.
|
|
540
|
+
* @returns The element in the Sequence matching the given index.
|
|
541
|
+
*/
|
|
542
|
+
at(index: number): any;
|
|
543
|
+
/**
|
|
544
|
+
* The :js:meth:`Array.concat` method is used to merge two or more arrays.
|
|
545
|
+
* This method does not change the existing arrays, but instead returns a new
|
|
546
|
+
* array.
|
|
547
|
+
* @param rest Arrays and/or values to concatenate into a new array.
|
|
548
|
+
* @returns A new Array instance.
|
|
549
|
+
*/
|
|
550
|
+
concat(...rest: ConcatArray<any>[]): any[];
|
|
551
|
+
/**
|
|
552
|
+
* The :js:meth:`Array.includes` method determines whether a Sequence
|
|
553
|
+
* includes a certain value among its entries, returning true or false as
|
|
554
|
+
* appropriate.
|
|
555
|
+
* @param elt
|
|
556
|
+
* @returns
|
|
557
|
+
*/
|
|
558
|
+
includes(elt: any): any;
|
|
559
|
+
/**
|
|
560
|
+
* The :js:meth:`Array.entries` method returns a new iterator object that
|
|
561
|
+
* contains the key/value pairs for each index in the ``Sequence``.
|
|
562
|
+
* @returns A new iterator object.
|
|
563
|
+
*/
|
|
564
|
+
entries(): IterableIterator<[
|
|
565
|
+
number,
|
|
566
|
+
any
|
|
567
|
+
]>;
|
|
568
|
+
/**
|
|
569
|
+
* The :js:meth:`Array.keys` method returns a new iterator object that
|
|
570
|
+
* contains the keys for each index in the ``Sequence``.
|
|
571
|
+
* @returns A new iterator object.
|
|
572
|
+
*/
|
|
573
|
+
keys(): IterableIterator<number>;
|
|
574
|
+
/**
|
|
575
|
+
* The :js:meth:`Array.values` method returns a new iterator object that
|
|
576
|
+
* contains the values for each index in the ``Sequence``.
|
|
577
|
+
* @returns A new iterator object.
|
|
578
|
+
*/
|
|
579
|
+
values(): IterableIterator<any>;
|
|
580
|
+
/**
|
|
581
|
+
* The :js:meth:`Array.find` method returns the first element in the provided
|
|
582
|
+
* array that satisfies the provided testing function.
|
|
583
|
+
* @param predicate A function to execute for each element in the
|
|
584
|
+
* ``Sequence``. It should return a truthy value to indicate a matching
|
|
585
|
+
* element has been found, and a falsy value otherwise.
|
|
586
|
+
* @param thisArg A value to use as ``this`` when executing ``predicate``.
|
|
587
|
+
* @returns The first element in the ``Sequence`` that satisfies the provided
|
|
588
|
+
* testing function.
|
|
589
|
+
*/
|
|
590
|
+
find(predicate: (value: any, index: number, obj: any[]) => any, thisArg?: any): any;
|
|
591
|
+
/**
|
|
592
|
+
* The :js:meth:`Array.findIndex` method returns the index of the first
|
|
593
|
+
* element in the provided array that satisfies the provided testing function.
|
|
594
|
+
* @param predicate A function to execute for each element in the
|
|
595
|
+
* ``Sequence``. It should return a truthy value to indicate a matching
|
|
596
|
+
* element has been found, and a falsy value otherwise.
|
|
597
|
+
* @param thisArg A value to use as ``this`` when executing ``predicate``.
|
|
598
|
+
* @returns The index of the first element in the ``Sequence`` that satisfies
|
|
599
|
+
* the provided testing function.
|
|
600
|
+
*/
|
|
601
|
+
findIndex(predicate: (value: any, index: number, obj: any[]) => any, thisArg?: any): number;
|
|
602
|
+
}
|
|
603
|
+
declare class PyMutableSequence extends PyProxy {
|
|
604
|
+
/** @private */
|
|
605
|
+
static [Symbol.hasInstance](obj: any): obj is PyProxy;
|
|
606
|
+
}
|
|
607
|
+
/** @deprecated Use `import type { PyMutableSequence } from "pyodide/ffi"` instead */
|
|
608
|
+
interface PyMutableSequence extends PyMutableSequenceMethods {
|
|
609
|
+
}
|
|
610
|
+
declare class PyMutableSequenceMethods {
|
|
611
|
+
/**
|
|
612
|
+
* The :js:meth:`Array.reverse` method reverses a ``MutableSequence`` in
|
|
613
|
+
* place.
|
|
614
|
+
* @returns A reference to the same ``MutableSequence``
|
|
615
|
+
*/
|
|
616
|
+
reverse(): this;
|
|
617
|
+
/**
|
|
618
|
+
* The :js:meth:`Array.sort` method sorts the elements of a
|
|
619
|
+
* ``MutableSequence`` in place.
|
|
620
|
+
* @param compareFn A function that defines the sort order.
|
|
621
|
+
* @returns A reference to the same ``MutableSequence``
|
|
622
|
+
*/
|
|
623
|
+
sort(compareFn?: (a: any, b: any) => number): this;
|
|
624
|
+
/**
|
|
625
|
+
* The :js:meth:`Array.splice` method changes the contents of a
|
|
626
|
+
* ``MutableSequence`` by removing or replacing existing elements and/or
|
|
627
|
+
* adding new elements in place.
|
|
628
|
+
* @param start Zero-based index at which to start changing the
|
|
629
|
+
* ``MutableSequence``.
|
|
630
|
+
* @param deleteCount An integer indicating the number of elements in the
|
|
631
|
+
* ``MutableSequence`` to remove from ``start``.
|
|
632
|
+
* @param items The elements to add to the ``MutableSequence``, beginning from
|
|
633
|
+
* ``start``.
|
|
634
|
+
* @returns An array containing the deleted elements.
|
|
635
|
+
*/
|
|
636
|
+
splice(start: number, deleteCount?: number, ...items: any[]): void;
|
|
637
|
+
/**
|
|
638
|
+
* The :js:meth:`Array.push` method adds the specified elements to the end of
|
|
639
|
+
* a ``MutableSequence``.
|
|
640
|
+
* @param elts The element(s) to add to the end of the ``MutableSequence``.
|
|
641
|
+
* @returns The new length property of the object upon which the method was
|
|
642
|
+
* called.
|
|
643
|
+
*/
|
|
644
|
+
push(...elts: any[]): any;
|
|
645
|
+
/**
|
|
646
|
+
* The :js:meth:`Array.pop` method removes the last element from a
|
|
647
|
+
* ``MutableSequence``.
|
|
648
|
+
* @returns The removed element from the ``MutableSequence``; undefined if the
|
|
649
|
+
* ``MutableSequence`` is empty.
|
|
650
|
+
*/
|
|
651
|
+
pop(): void;
|
|
652
|
+
/**
|
|
653
|
+
* The :js:meth:`Array.shift` method removes the first element from a
|
|
654
|
+
* ``MutableSequence``.
|
|
655
|
+
* @returns The removed element from the ``MutableSequence``; undefined if the
|
|
656
|
+
* ``MutableSequence`` is empty.
|
|
657
|
+
*/
|
|
658
|
+
shift(): void;
|
|
659
|
+
/**
|
|
660
|
+
* The :js:meth:`Array.unshift` method adds the specified elements to the
|
|
661
|
+
* beginning of a ``MutableSequence``.
|
|
662
|
+
* @param elts The elements to add to the front of the ``MutableSequence``.
|
|
663
|
+
* @returns The new length of the ``MutableSequence``.
|
|
664
|
+
*/
|
|
665
|
+
unshift(...elts: any[]): any;
|
|
666
|
+
/**
|
|
667
|
+
* The :js:meth:`Array.copyWithin` method shallow copies part of a
|
|
668
|
+
* ``MutableSequence`` to another location in the same ``MutableSequence``
|
|
669
|
+
* without modifying its length.
|
|
670
|
+
* @param target Zero-based index at which to copy the sequence to.
|
|
671
|
+
* @param start Zero-based index at which to start copying elements from.
|
|
672
|
+
* @param end Zero-based index at which to end copying elements from.
|
|
673
|
+
* @returns The modified ``MutableSequence``.
|
|
674
|
+
*/
|
|
675
|
+
copyWithin(target: number, start?: number, end?: number): any;
|
|
676
|
+
/**
|
|
677
|
+
* The :js:meth:`Array.fill` method changes all elements in an array to a
|
|
678
|
+
* static value, from a start index to an end index.
|
|
679
|
+
* @param value Value to fill the array with.
|
|
680
|
+
* @param start Zero-based index at which to start filling. Default 0.
|
|
681
|
+
* @param end Zero-based index at which to end filling. Default
|
|
682
|
+
* ``list.length``.
|
|
683
|
+
* @returns
|
|
684
|
+
*/
|
|
685
|
+
fill(value: any, start?: number, end?: number): any;
|
|
686
|
+
}
|
|
455
687
|
declare class PyAwaitable extends PyProxy {
|
|
456
688
|
/** @private */
|
|
457
689
|
static [Symbol.hasInstance](obj: any): obj is PyProxy;
|
|
@@ -713,18 +945,21 @@ declare class PythonError extends Error {
|
|
|
713
945
|
declare type InFuncType = () => null | undefined | string | ArrayBuffer | Uint8Array | number;
|
|
714
946
|
declare function setStdin(options?: {
|
|
715
947
|
stdin?: InFuncType;
|
|
948
|
+
read?: (buffer: Uint8Array) => number;
|
|
716
949
|
error?: boolean;
|
|
717
950
|
isatty?: boolean;
|
|
718
951
|
autoEOF?: boolean;
|
|
719
952
|
}): void;
|
|
720
953
|
declare function setStdout(options?: {
|
|
721
|
-
batched?: (
|
|
722
|
-
raw?: (
|
|
954
|
+
batched?: (output: string) => void;
|
|
955
|
+
raw?: (charCode: number) => void;
|
|
956
|
+
write?: (buffer: Uint8Array) => number;
|
|
723
957
|
isatty?: boolean;
|
|
724
958
|
}): void;
|
|
725
959
|
declare function setStderr(options?: {
|
|
726
|
-
batched?: (
|
|
727
|
-
raw?: (
|
|
960
|
+
batched?: (output: string) => void;
|
|
961
|
+
raw?: (charCode: number) => void;
|
|
962
|
+
write?: (buffer: Uint8Array) => number;
|
|
728
963
|
isatty?: boolean;
|
|
729
964
|
}): void;
|
|
730
965
|
declare type NativeFS = {
|
|
@@ -758,6 +993,8 @@ declare class PyodideAPI {
|
|
|
758
993
|
PyBuffer: typeof PyBuffer;
|
|
759
994
|
PyBufferView: typeof PyBufferView;
|
|
760
995
|
PythonError: typeof PythonError;
|
|
996
|
+
PySequence: typeof PySequence;
|
|
997
|
+
PyMutableSequence: typeof PyMutableSequence;
|
|
761
998
|
};
|
|
762
999
|
/** @hidden */
|
|
763
1000
|
static setStdin: typeof setStdin;
|
|
@@ -862,6 +1099,21 @@ declare class PyodideAPI {
|
|
|
862
1099
|
* Defaults to the same as ``globals``.
|
|
863
1100
|
* @returns The result of the Python code translated to JavaScript. See the
|
|
864
1101
|
* documentation for :py:func:`~pyodide.code.eval_code` for more info.
|
|
1102
|
+
* @example
|
|
1103
|
+
* async function main(){
|
|
1104
|
+
* const pyodide = await loadPyodide();
|
|
1105
|
+
* console.log(pyodide.runPython("1 + 2"));
|
|
1106
|
+
* // 3
|
|
1107
|
+
*
|
|
1108
|
+
* const globals = pyodide.toPy({ x: 3 });
|
|
1109
|
+
* console.log(pyodide.runPython("x + 1", { globals }));
|
|
1110
|
+
* // 4
|
|
1111
|
+
*
|
|
1112
|
+
* const locals = pyodide.toPy({ arr: [1, 2, 3] });
|
|
1113
|
+
* console.log(pyodide.runPython("sum(arr)", { locals }));
|
|
1114
|
+
* // 6
|
|
1115
|
+
* }
|
|
1116
|
+
* main();
|
|
865
1117
|
*/
|
|
866
1118
|
static runPython(code: string, options?: {
|
|
867
1119
|
globals?: PyProxy;
|
|
@@ -880,7 +1132,7 @@ declare class PyodideAPI {
|
|
|
880
1132
|
*
|
|
881
1133
|
* let result = await pyodide.runPythonAsync(`
|
|
882
1134
|
* from js import fetch
|
|
883
|
-
* response = await fetch("./
|
|
1135
|
+
* response = await fetch("./pyodide-lock.json")
|
|
884
1136
|
* packages = await response.json()
|
|
885
1137
|
* # If final statement is an expression, its value is returned to JavaScript
|
|
886
1138
|
* len(packages.packages.object_keys())
|
|
@@ -1079,6 +1331,13 @@ declare class PyodideAPI {
|
|
|
1079
1331
|
* @deprecated
|
|
1080
1332
|
*/
|
|
1081
1333
|
static get PythonError(): typeof PythonError;
|
|
1334
|
+
/**
|
|
1335
|
+
* Turn on or off debug mode. In debug mode, some error messages are improved
|
|
1336
|
+
* at a performance cost.
|
|
1337
|
+
* @param debug If true, turn debug mode on. If false, turn debug mode off.
|
|
1338
|
+
* @returns The old value of the debug flag.
|
|
1339
|
+
*/
|
|
1340
|
+
static setDebug(debug: boolean): boolean;
|
|
1082
1341
|
}
|
|
1083
1342
|
/** @hidetype */
|
|
1084
1343
|
export declare type PyodideInterface = typeof PyodideAPI;
|
|
@@ -1100,6 +1359,9 @@ export declare type ConfigType = {
|
|
|
1100
1359
|
jsglobals?: object;
|
|
1101
1360
|
args: string[];
|
|
1102
1361
|
_node_mounts: string[];
|
|
1362
|
+
env: {
|
|
1363
|
+
[key: string]: string;
|
|
1364
|
+
};
|
|
1103
1365
|
};
|
|
1104
1366
|
/**
|
|
1105
1367
|
* Load the main Pyodide wasm module and initialize it.
|
|
@@ -1107,6 +1369,16 @@ export declare type ConfigType = {
|
|
|
1107
1369
|
* @returns The :ref:`js-api-pyodide` module.
|
|
1108
1370
|
* @memberof globalThis
|
|
1109
1371
|
* @async
|
|
1372
|
+
* @example
|
|
1373
|
+
* async function main() {
|
|
1374
|
+
* const pyodide = await loadPyodide({
|
|
1375
|
+
* fullStdLib: true,
|
|
1376
|
+
* homedir: "/pyodide",
|
|
1377
|
+
* stdout: (msg) => console.log(`Pyodide: ${msg}`),
|
|
1378
|
+
* });
|
|
1379
|
+
* console.log("Loaded Pyodide");
|
|
1380
|
+
* }
|
|
1381
|
+
* main();
|
|
1110
1382
|
*/
|
|
1111
1383
|
export declare function loadPyodide(options?: {
|
|
1112
1384
|
/**
|
|
@@ -1119,13 +1391,23 @@ export declare function loadPyodide(options?: {
|
|
|
1119
1391
|
*/
|
|
1120
1392
|
indexURL?: string;
|
|
1121
1393
|
/**
|
|
1394
|
+
* The file path where packages will be cached in `node.js`. If a package
|
|
1395
|
+
* exists in `packageCacheDir` it is loaded from there, otherwise it is
|
|
1396
|
+
* downloaded from the JsDelivr CDN and then cached into `packageCacheDir`.
|
|
1397
|
+
* Only applies when running in node.js. Ignored in browsers.
|
|
1398
|
+
*
|
|
1399
|
+
* Default: same as indexURL
|
|
1400
|
+
*/
|
|
1401
|
+
packageCacheDir?: string;
|
|
1402
|
+
/**
|
|
1403
|
+
* The URL from which Pyodide will load the Pyodide ``pyodide-lock.json`` lock
|
|
1122
1404
|
* file. You can produce custom lock files with :py:func:`micropip.freeze`.
|
|
1123
|
-
* Default: ```${indexURL}/
|
|
1405
|
+
* Default: ```${indexURL}/pyodide-lock.json```
|
|
1124
1406
|
*/
|
|
1125
1407
|
lockFileURL?: string;
|
|
1126
1408
|
/**
|
|
1127
1409
|
* The home directory which Pyodide will use inside virtual file system.
|
|
1128
|
-
*
|
|
1410
|
+
* This is deprecated, use ``{env: {HOME : some_dir}}`` instead.
|
|
1129
1411
|
*/
|
|
1130
1412
|
homedir?: string;
|
|
1131
1413
|
/**
|
|
@@ -1167,6 +1449,18 @@ export declare function loadPyodide(options?: {
|
|
|
1167
1449
|
* more details. Default: ``[]``
|
|
1168
1450
|
*/
|
|
1169
1451
|
args?: string[];
|
|
1452
|
+
/**
|
|
1453
|
+
* Environment variables to pass to Python. This can be accessed inside of
|
|
1454
|
+
* Python at runtime via `os.environ`. Certain environment variables change
|
|
1455
|
+
* the way that Python loads:
|
|
1456
|
+
* https://docs.python.org/3.10/using/cmdline.html#environment-variables
|
|
1457
|
+
* Default: {}
|
|
1458
|
+
* If `env.HOME` is undefined, it will be set to a default value of
|
|
1459
|
+
* `"/home/pyodide"`
|
|
1460
|
+
*/
|
|
1461
|
+
env?: {
|
|
1462
|
+
[key: string]: string;
|
|
1463
|
+
};
|
|
1170
1464
|
/**
|
|
1171
1465
|
* @ignore
|
|
1172
1466
|
*/
|
package/pyodide.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).loadPyodide={})}(this,(function(exports){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var errorStackParser={exports:{}},stackframe={exports:{}};!function(module,exports){module.exports=function(){function _isNumber(n){return!isNaN(parseFloat(n))&&isFinite(n)}function _capitalize(str){return str.charAt(0).toUpperCase()+str.substring(1)}function _getter(p){return function(){return this[p]}}var booleanProps=["isConstructor","isEval","isNative","isToplevel"],numericProps=["columnNumber","lineNumber"],stringProps=["fileName","functionName","source"],arrayProps=["args"],objectProps=["evalOrigin"],props=booleanProps.concat(numericProps,stringProps,arrayProps,objectProps);function StackFrame(obj){if(obj)for(var i=0;i<props.length;i++)void 0!==obj[props[i]]&&this["set"+_capitalize(props[i])](obj[props[i]])}StackFrame.prototype={getArgs:function(){return this.args},setArgs:function(v){if("[object Array]"!==Object.prototype.toString.call(v))throw new TypeError("Args must be an Array");this.args=v},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(v){if(v instanceof StackFrame)this.evalOrigin=v;else{if(!(v instanceof Object))throw new TypeError("Eval Origin must be an Object or StackFrame");this.evalOrigin=new StackFrame(v)}},toString:function(){var fileName=this.getFileName()||"",lineNumber=this.getLineNumber()||"",columnNumber=this.getColumnNumber()||"",functionName=this.getFunctionName()||"";return this.getIsEval()?fileName?"[eval] ("+fileName+":"+lineNumber+":"+columnNumber+")":"[eval]:"+lineNumber+":"+columnNumber:functionName?functionName+" ("+fileName+":"+lineNumber+":"+columnNumber+")":fileName+":"+lineNumber+":"+columnNumber}},StackFrame.fromString=function(str){var argsStartIndex=str.indexOf("("),argsEndIndex=str.lastIndexOf(")"),functionName=str.substring(0,argsStartIndex),args=str.substring(argsStartIndex+1,argsEndIndex).split(","),locationString=str.substring(argsEndIndex+1);if(0===locationString.indexOf("@"))var parts=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(locationString,""),fileName=parts[1],lineNumber=parts[2],columnNumber=parts[3];return new StackFrame({functionName:functionName,args:args||void 0,fileName:fileName,lineNumber:lineNumber||void 0,columnNumber:columnNumber||void 0})};for(var i=0;i<booleanProps.length;i++)StackFrame.prototype["get"+_capitalize(booleanProps[i])]=_getter(booleanProps[i]),StackFrame.prototype["set"+_capitalize(booleanProps[i])]=function(p){return function(v){this[p]=Boolean(v)}}(booleanProps[i]);for(var j=0;j<numericProps.length;j++)StackFrame.prototype["get"+_capitalize(numericProps[j])]=_getter(numericProps[j]),StackFrame.prototype["set"+_capitalize(numericProps[j])]=function(p){return function(v){if(!_isNumber(v))throw new TypeError(p+" must be a Number");this[p]=Number(v)}}(numericProps[j]);for(var k=0;k<stringProps.length;k++)StackFrame.prototype["get"+_capitalize(stringProps[k])]=_getter(stringProps[k]),StackFrame.prototype["set"+_capitalize(stringProps[k])]=function(p){return function(v){this[p]=String(v)}}(stringProps[k]);return StackFrame}()}(stackframe),function(module,exports){var StackFrame,FIREFOX_SAFARI_STACK_REGEXP,CHROME_IE_STACK_REGEXP,SAFARI_NATIVE_CODE_REGEXP;module.exports=(StackFrame=stackframe.exports,FIREFOX_SAFARI_STACK_REGEXP=/(^|@)\S+:\d+/,CHROME_IE_STACK_REGEXP=/^\s*at .*(\S+:\d+|\(native\))/m,SAFARI_NATIVE_CODE_REGEXP=/^(eval@)?(\[native code])?$/,{parse:function(error){if(void 0!==error.stacktrace||void 0!==error["opera#sourceloc"])return this.parseOpera(error);if(error.stack&&error.stack.match(CHROME_IE_STACK_REGEXP))return this.parseV8OrIE(error);if(error.stack)return this.parseFFOrSafari(error);throw new Error("Cannot parse given Error object")},extractLocation:function(urlLike){if(-1===urlLike.indexOf(":"))return[urlLike];var parts=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(urlLike.replace(/[()]/g,""));return[parts[1],parts[2]||void 0,parts[3]||void 0]},parseV8OrIE:function(error){return error.stack.split("\n").filter((function(line){return!!line.match(CHROME_IE_STACK_REGEXP)}),this).map((function(line){line.indexOf("(eval ")>-1&&(line=line.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var sanitizedLine=line.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),location=sanitizedLine.match(/ (\(.+\)$)/);sanitizedLine=location?sanitizedLine.replace(location[0],""):sanitizedLine;var locationParts=this.extractLocation(location?location[1]:sanitizedLine),functionName=location&&sanitizedLine||void 0,fileName=["eval","<anonymous>"].indexOf(locationParts[0])>-1?void 0:locationParts[0];return new StackFrame({functionName:functionName,fileName:fileName,lineNumber:locationParts[1],columnNumber:locationParts[2],source:line})}),this)},parseFFOrSafari:function(error){return error.stack.split("\n").filter((function(line){return!line.match(SAFARI_NATIVE_CODE_REGEXP)}),this).map((function(line){if(line.indexOf(" > eval")>-1&&(line=line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===line.indexOf("@")&&-1===line.indexOf(":"))return new StackFrame({functionName:line});var functionNameRegex=/((.*".+"[^@]*)?[^@]*)(?:@)/,matches=line.match(functionNameRegex),functionName=matches&&matches[1]?matches[1]:void 0,locationParts=this.extractLocation(line.replace(functionNameRegex,""));return new StackFrame({functionName:functionName,fileName:locationParts[0],lineNumber:locationParts[1],columnNumber:locationParts[2],source:line})}),this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){for(var lineRE=/Line (\d+).*script (?:in )?(\S+)/i,lines=e.message.split("\n"),result=[],i=2,len=lines.length;i<len;i+=2){var match=lineRE.exec(lines[i]);match&&result.push(new StackFrame({fileName:match[2],lineNumber:match[1],source:lines[i]}))}return result},parseOpera10:function(e){for(var lineRE=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,lines=e.stacktrace.split("\n"),result=[],i=0,len=lines.length;i<len;i+=2){var match=lineRE.exec(lines[i]);match&&result.push(new StackFrame({functionName:match[3]||void 0,fileName:match[2],lineNumber:match[1],source:lines[i]}))}return result},parseOpera11:function(error){return error.stack.split("\n").filter((function(line){return!!line.match(FIREFOX_SAFARI_STACK_REGEXP)&&!line.match(/^Error created at/)}),this).map((function(line){var argsRaw,tokens=line.split("@"),locationParts=this.extractLocation(tokens.pop()),functionCall=tokens.shift()||"",functionName=functionCall.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;functionCall.match(/\(([^)]*)\)/)&&(argsRaw=functionCall.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var args=void 0===argsRaw||"[arguments not available]"===argsRaw?void 0:argsRaw.split(",");return new StackFrame({functionName:functionName,args:args,fileName:locationParts[0],lineNumber:locationParts[1],columnNumber:locationParts[2],source:line})}),this)}})}(errorStackParser);var ErrorStackParser=errorStackParser.exports;const IN_NODE="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node&&void 0===process.browser;let nodeUrlMod,nodeFetch,nodePath,nodeVmMod,nodeFsPromisesMod,resolvePath,pathSep,loadBinaryFile,loadScript;if(resolvePath=IN_NODE?function(path,base){return nodePath.resolve(base||".",path)}:function(path,base){return void 0===base&&(base=location),new URL(path,base).toString()},IN_NODE||(pathSep="/"),loadBinaryFile=IN_NODE?async function(path,_file_sub_resource_hash){if(path.startsWith("file://")&&(path=path.slice("file://".length)),path.includes("://")){let response=await nodeFetch(path);if(!response.ok)throw new Error(`Failed to load '${path}': request failed.`);return new Uint8Array(await response.arrayBuffer())}{const data=await nodeFsPromisesMod.readFile(path);return new Uint8Array(data.buffer,data.byteOffset,data.byteLength)}}:async function(path,subResourceHash){const url=new URL(path,location);let options=subResourceHash?{integrity:subResourceHash}:{},response=await fetch(url,options);if(!response.ok)throw new Error(`Failed to load '${url}': request failed.`);return new Uint8Array(await response.arrayBuffer())},globalThis.document)loadScript=async url=>await import(/* webpackIgnore: true */url);else if(globalThis.importScripts)loadScript=async url=>{try{globalThis.importScripts(url)}catch(e){if(!(e instanceof TypeError))throw e;await import(/* webpackIgnore: true */url)}};else{if(!IN_NODE)throw new Error("Cannot determine runtime environment");loadScript=async function(url){url.startsWith("file://")&&(url=url.slice("file://".length));url.includes("://")?nodeVmMod.runInThisContext(await(await nodeFetch(url)).text()):await import(/* webpackIgnore: true */nodeUrlMod.pathToFileURL(url).href)}}function __values(o){var s="function"==typeof Symbol&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&"number"==typeof o.length)return{next:function(){return o&&i>=o.length&&(o=void 0),{value:o&&o[i++],done:!o}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function __asyncValues(o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,m=o[Symbol.asyncIterator];return m?m.call(o):(o=__values(o),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i);function verb(n){i[n]=o[n]&&function(v){return new Promise((function(resolve,reject){(function(resolve,reject,d,v){Promise.resolve(v).then((function(v){resolve({value:v,done:d})}),reject)})(resolve,reject,(v=o[n](v)).done,v.value)}))}}}const getFsHandles=async dirHandle=>{const handles=[];await async function collect(curDirHandle){var e_1,_a;try{for(var _c,_b=__asyncValues(curDirHandle.values());!(_c=await _b.next()).done;){const entry=_c.value;handles.push(entry),"directory"===entry.kind&&await collect(entry)}}catch(e_1_1){e_1={error:e_1_1}}finally{try{_c&&!_c.done&&(_a=_b.return)&&await _a.call(_b)}finally{if(e_1)throw e_1.error}}}(dirHandle);const result=new Map;result.set(".",dirHandle);for(const handle of handles){const relativePath=(await dirHandle.resolve(handle)).join("/");result.set(relativePath,handle)}return result};function initializeFileSystem(Module,config){let stdLibURL;stdLibURL=null!=config.stdLibURL?config.stdLibURL:config.indexURL+"python_stdlib.zip",function(Module,stdlibURL){const stdlibPromise=loadBinaryFile(stdlibURL);Module.preRun.push((()=>{const pymajor=Module._py_version_major(),pyminor=Module._py_version_minor();Module.FS.mkdirTree("/lib"),Module.FS.mkdirTree(`/lib/python${pymajor}.${pyminor}/site-packages`),Module.addRunDependency("install-stdlib"),stdlibPromise.then((stdlib=>{Module.FS.writeFile(`/lib/python${pymajor}${pyminor}.zip`,stdlib)})).catch((e=>{console.error("Error occurred while installing the standard library:"),console.error(e)})).finally((()=>{Module.removeRunDependency("install-stdlib")}))}))}(Module,stdLibURL),function(Module,path){Module.preRun.push((function(){try{Module.FS.mkdirTree(path)}catch(e){console.error(`Error occurred while making a home directory '${path}':`),console.error(e),console.error("Using '/' for a home directory instead"),path="/"}Module.ENV.HOME=path,Module.FS.chdir(path)}))}(Module,config.homedir),function(Module,mounts){Module.preRun.push((()=>{for(const mount of mounts)Module.FS.mkdirTree(mount),Module.FS.mount(Module.FS.filesystems.NODEFS,{root:mount},mount)}))}(Module,config._node_mounts),Module.preRun.push((()=>function(module){const FS=module.FS,MEMFS=module.FS.filesystems.MEMFS,PATH=module.PATH,nativeFSAsync={DIR_MODE:16895,FILE_MODE:33279,mount:function(mount){if(!mount.opts.fileSystemHandle)throw new Error("opts.fileSystemHandle is required");return MEMFS.mount.apply(null,arguments)},syncfs:async(mount,populate,callback)=>{try{const local=nativeFSAsync.getLocalSet(mount),remote=await nativeFSAsync.getRemoteSet(mount),src=populate?remote:local,dst=populate?local:remote;await nativeFSAsync.reconcile(mount,src,dst),callback(null)}catch(e){callback(e)}},getLocalSet:mount=>{let entries=Object.create(null);function isRealDir(p){return"."!==p&&".."!==p}function toAbsolute(root){return p=>PATH.join2(root,p)}let check=FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));for(;check.length;){let path=check.pop(),stat=FS.stat(path);FS.isDir(stat.mode)&&check.push.apply(check,FS.readdir(path).filter(isRealDir).map(toAbsolute(path))),entries[path]={timestamp:stat.mtime,mode:stat.mode}}return{type:"local",entries:entries}},getRemoteSet:async mount=>{const entries=Object.create(null),handles=await getFsHandles(mount.opts.fileSystemHandle);for(const[path,handle]of handles)"."!==path&&(entries[PATH.join2(mount.mountpoint,path)]={timestamp:"file"===handle.kind?(await handle.getFile()).lastModifiedDate:new Date,mode:"file"===handle.kind?nativeFSAsync.FILE_MODE:nativeFSAsync.DIR_MODE});return{type:"remote",entries:entries,handles:handles}},loadLocalEntry:path=>{const node=FS.lookupPath(path).node,stat=FS.stat(path);if(FS.isDir(stat.mode))return{timestamp:stat.mtime,mode:stat.mode};if(FS.isFile(stat.mode))return node.contents=MEMFS.getFileDataAsTypedArray(node),{timestamp:stat.mtime,mode:stat.mode,contents:node.contents};throw new Error("node type not supported")},storeLocalEntry:(path,entry)=>{if(FS.isDir(entry.mode))FS.mkdirTree(path,entry.mode);else{if(!FS.isFile(entry.mode))throw new Error("node type not supported");FS.writeFile(path,entry.contents,{canOwn:!0})}FS.chmod(path,entry.mode),FS.utime(path,entry.timestamp,entry.timestamp)},removeLocalEntry:path=>{var stat=FS.stat(path);FS.isDir(stat.mode)?FS.rmdir(path):FS.isFile(stat.mode)&&FS.unlink(path)},loadRemoteEntry:async handle=>{if("file"===handle.kind){const file=await handle.getFile();return{contents:new Uint8Array(await file.arrayBuffer()),mode:nativeFSAsync.FILE_MODE,timestamp:file.lastModifiedDate}}if("directory"===handle.kind)return{mode:nativeFSAsync.DIR_MODE,timestamp:new Date};throw new Error("unknown kind: "+handle.kind)},storeRemoteEntry:async(handles,path,entry)=>{const parentDirHandle=handles.get(PATH.dirname(path)),handle=FS.isFile(entry.mode)?await parentDirHandle.getFileHandle(PATH.basename(path),{create:!0}):await parentDirHandle.getDirectoryHandle(PATH.basename(path),{create:!0});if("file"===handle.kind){const writable=await handle.createWritable();await writable.write(entry.contents),await writable.close()}handles.set(path,handle)},removeRemoteEntry:async(handles,path)=>{const parentDirHandle=handles.get(PATH.dirname(path));await parentDirHandle.removeEntry(PATH.basename(path)),handles.delete(path)},reconcile:async(mount,src,dst)=>{let total=0;const create=[];Object.keys(src.entries).forEach((function(key){const e=src.entries[key],e2=dst.entries[key];(!e2||FS.isFile(e.mode)&&e.timestamp.getTime()>e2.timestamp.getTime())&&(create.push(key),total++)})),create.sort();const remove=[];if(Object.keys(dst.entries).forEach((function(key){src.entries[key]||(remove.push(key),total++)})),remove.sort().reverse(),!total)return;const handles="remote"===src.type?src.handles:dst.handles;for(const path of create){const relPath=PATH.normalize(path.replace(mount.mountpoint,"/")).substring(1);if("local"===dst.type){const handle=handles.get(relPath),entry=await nativeFSAsync.loadRemoteEntry(handle);nativeFSAsync.storeLocalEntry(path,entry)}else{const entry=nativeFSAsync.loadLocalEntry(path);await nativeFSAsync.storeRemoteEntry(handles,relPath,entry)}}for(const path of remove)if("local"===dst.type)nativeFSAsync.removeLocalEntry(path);else{const relPath=PATH.normalize(path.replace(mount.mountpoint,"/")).substring(1);await nativeFSAsync.removeRemoteEntry(handles,relPath)}}};module.FS.filesystems.NATIVEFS_ASYNC=nativeFSAsync}(Module)))}function finalizeBootstrap(API,config){API.runPythonInternal_dict=API._pyodide._base.eval_code("{}"),API.importlib=API.runPythonInternal("import importlib; importlib");let import_module=API.importlib.import_module;API.sys=import_module("sys"),API.sys.path.insert(0,config.homedir),API.os=import_module("os");let globals=API.runPythonInternal("import __main__; __main__.__dict__"),builtins=API.runPythonInternal("import builtins; builtins.__dict__");var builtins_dict;API.globals=(builtins_dict=builtins,new Proxy(globals,{get:(target,symbol)=>"get"===symbol?key=>{let result=target.get(key);return void 0===result&&(result=builtins_dict.get(key)),result}:"has"===symbol?key=>target.has(key)||builtins_dict.has(key):Reflect.get(target,symbol)}));let importhook=API._pyodide._importhook;importhook.register_js_finder.callKwargs({hook:function(o){"__all__"in o||Object.defineProperty(o,"__all__",{get:()=>pyodide.toPy(Object.getOwnPropertyNames(o).filter((name=>"__all__"!==name))),enumerable:!1,configurable:!0})}}),importhook.register_js_module("js",config.jsglobals);let pyodide=API.makePublicAPI();return importhook.register_js_module("pyodide_js",pyodide),API.pyodide_py=import_module("pyodide"),API.pyodide_code=import_module("pyodide.code"),API.pyodide_ffi=import_module("pyodide.ffi"),API.package_loader=import_module("pyodide._package_loader"),API.sitepackages=API.package_loader.SITE_PACKAGES.__str__(),API.dsodir=API.package_loader.DSO_DIR.__str__(),API.defaultLdLibraryPath=[API.dsodir,API.sitepackages],API.os.environ.__setitem__("LD_LIBRARY_PATH",API.defaultLdLibraryPath.join(":")),pyodide.pyodide_py=API.pyodide_py,pyodide.globals=API.globals,pyodide}async function loadPyodide(options={}){await async function(){if(!IN_NODE)return;if(nodeUrlMod=(await import("url")).default,nodeFsPromisesMod=await import("fs/promises"),nodeFetch=globalThis.fetch?fetch:(await import("node-fetch")).default,nodeVmMod=(await import("vm")).default,nodePath=await import("path"),pathSep=nodePath.sep,"undefined"!=typeof require)return;const node_modules={fs:await import("fs"),crypto:await import("crypto"),ws:await import("ws"),child_process:await import("child_process")};globalThis.require=function(mod){return node_modules[mod]}}();let indexURL=options.indexURL||function(){if("string"==typeof __dirname)return __dirname;let err;try{throw new Error}catch(e){err=e}let fileName=ErrorStackParser.parse(err)[0].fileName;const indexOfLastSlash=fileName.lastIndexOf(pathSep);if(-1===indexOfLastSlash)throw new Error("Could not extract indexURL path from pyodide module location");return fileName.slice(0,indexOfLastSlash)}();indexURL=resolvePath(indexURL),indexURL.endsWith("/")||(indexURL+="/"),options.indexURL=indexURL;const default_config={fullStdLib:!1,jsglobals:globalThis,stdin:globalThis.prompt?globalThis.prompt:void 0,homedir:"/home/pyodide",lockFileURL:indexURL+"repodata.json",args:[],_node_mounts:[],packageCacheDir:indexURL},config=Object.assign(default_config,options),Module=function(){let Module={noImageDecoding:!0,noAudioDecoding:!0,noWasmDecoding:!1,preRun:[],quit:(status,toThrow)=>{throw Module.exited={status:status,toThrow:toThrow},toThrow}};return Module}();Module.print=config.stdout,Module.printErr=config.stderr,Module.arguments=config.args;const API={config:config};Module.API=API,initializeFileSystem(Module,config);const moduleLoaded=new Promise((r=>Module.postRun=r));if(Module.locateFile=path=>config.indexURL+path,"function"!=typeof _createPyodideModule){const scriptSrc=`${config.indexURL}pyodide.asm.js`;await loadScript(scriptSrc)}if(await _createPyodideModule(Module),await moduleLoaded,Module.exited)throw Module.exited.toThrow;if("0.23.4"!==API.version)throw new Error(`Pyodide version does not match: '0.23.4' <==> '${API.version}'. If you updated the Pyodide version, make sure you also updated the 'indexURL' parameter passed to loadPyodide.`);Module.locateFile=path=>{throw new Error("Didn't expect to load any more file_packager files!")};let[err,captured_stderr]=API.rawRun("import _pyodide_core");err&&Module.API.fatal_loading_error("Failed to import _pyodide_core\n",captured_stderr);const pyodide=finalizeBootstrap(API,config);if(pyodide.version.includes("dev")||API.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${pyodide.version}/full/`),await API.packageIndexReady,API._pyodide._importhook.register_module_not_found_hook(API._import_name_to_package_name,API.repodata_unvendored_stdlibs_and_test),"0.23.4"!==API.repodata_info.version)throw new Error("Lock file version doesn't match Pyodide version");return API.package_loader.init_loaded_packages(),config.fullStdLib&&await pyodide.loadPackage(API.repodata_unvendored_stdlibs),API.initializeStreams(config.stdin,config.stdout,config.stderr),pyodide}globalThis.loadPyodide=loadPyodide,exports.loadPyodide=loadPyodide,exports.version="0.23.4",Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
1
|
+
"use strict";var loadPyodide=(()=>{var Z=Object.create;var w=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var f=(e,t)=>w(e,"name",{value:t,configurable:!0}),g=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof require<"u"?require:t)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var U=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ie=(e,t)=>{for(var o in t)w(e,o,{get:t[o],enumerable:!0})},$=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of te(t))!ne.call(e,a)&&a!==o&&w(e,a,{get:()=>t[a],enumerable:!(s=ee(t,a))||s.enumerable});return e};var h=(e,t,o)=>(o=e!=null?Z(re(e)):{},$(t||!e||!e.__esModule?w(o,"default",{value:e,enumerable:!0}):o,e)),oe=e=>$(w({},"__esModule",{value:!0}),e);var C=U((N,j)=>{(function(e,t){"use strict";typeof define=="function"&&define.amd?define("stackframe",[],t):typeof N=="object"?j.exports=t():e.StackFrame=t()})(N,function(){"use strict";function e(c){return!isNaN(parseFloat(c))&&isFinite(c)}f(e,"_isNumber");function t(c){return c.charAt(0).toUpperCase()+c.substring(1)}f(t,"_capitalize");function o(c){return function(){return this[c]}}f(o,"_getter");var s=["isConstructor","isEval","isNative","isToplevel"],a=["columnNumber","lineNumber"],r=["fileName","functionName","source"],n=["args"],u=["evalOrigin"],i=s.concat(a,r,n,u);function l(c){if(c)for(var y=0;y<i.length;y++)c[i[y]]!==void 0&&this["set"+t(i[y])](c[i[y]])}f(l,"StackFrame"),l.prototype={getArgs:function(){return this.args},setArgs:function(c){if(Object.prototype.toString.call(c)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=c},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(c){if(c instanceof l)this.evalOrigin=c;else if(c instanceof Object)this.evalOrigin=new l(c);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var c=this.getFileName()||"",y=this.getLineNumber()||"",v=this.getColumnNumber()||"",_=this.getFunctionName()||"";return this.getIsEval()?c?"[eval] ("+c+":"+y+":"+v+")":"[eval]:"+y+":"+v:_?_+" ("+c+":"+y+":"+v+")":c+":"+y+":"+v}},l.fromString=f(function(y){var v=y.indexOf("("),_=y.lastIndexOf(")"),K=y.substring(0,v),X=y.substring(v+1,_).split(","),T=y.substring(_+1);if(T.indexOf("@")===0)var O=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(T,""),Y=O[1],J=O[2],Q=O[3];return new l({functionName:K,args:X||void 0,fileName:Y,lineNumber:J||void 0,columnNumber:Q||void 0})},"StackFrame$$fromString");for(var d=0;d<s.length;d++)l.prototype["get"+t(s[d])]=o(s[d]),l.prototype["set"+t(s[d])]=function(c){return function(y){this[c]=!!y}}(s[d]);for(var p=0;p<a.length;p++)l.prototype["get"+t(a[p])]=o(a[p]),l.prototype["set"+t(a[p])]=function(c){return function(y){if(!e(y))throw new TypeError(c+" must be a Number");this[c]=Number(y)}}(a[p]);for(var m=0;m<r.length;m++)l.prototype["get"+t(r[m])]=o(r[m]),l.prototype["set"+t(r[m])]=function(c){return function(y){this[c]=String(y)}}(r[m]);return l})});var H=U((L,M)=>{(function(e,t){"use strict";typeof define=="function"&&define.amd?define("error-stack-parser",["stackframe"],t):typeof L=="object"?M.exports=t(C()):e.ErrorStackParser=t(e.StackFrame)})(L,f(function(t){"use strict";var o=/(^|@)\S+:\d+/,s=/^\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(s))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
|
+
`).filter(function(i){return!!i.match(s)},this);return u.map(function(i){i.indexOf("(eval ")>-1&&(i=i.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var l=i.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),d=l.match(/ (\(.+\)$)/);l=d?l.replace(d[0],""):l;var p=this.extractLocation(d?d[1]:l),m=d&&l||void 0,c=["eval","<anonymous>"].indexOf(p[0])>-1?void 0:p[0];return new t({functionName:m,fileName:c,lineNumber:p[1],columnNumber:p[2],source:i})},this)},"ErrorStackParser$$parseV8OrIE"),parseFFOrSafari:f(function(n){var u=n.stack.split(`
|
|
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 t({functionName:i});var l=/((.*".+"[^@]*)?[^@]*)(?:@)/,d=i.match(l),p=d&&d[1]?d[1]:void 0,m=this.extractLocation(i.replace(l,""));return new t({functionName:p,fileName:m[0],lineNumber:m[1],columnNumber:m[2],source:i})},this)},"ErrorStackParser$$parseFFOrSafari"),parseOpera:f(function(n){return!n.stacktrace||n.message.indexOf(`
|
|
4
|
+
`)>-1&&n.message.split(`
|
|
5
|
+
`).length>n.stacktrace.split(`
|
|
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
|
+
`),l=[],d=2,p=i.length;d<p;d+=2){var m=u.exec(i[d]);m&&l.push(new t({fileName:m[2],lineNumber:m[1],source:i[d]}))}return l},"ErrorStackParser$$parseOpera9"),parseOpera10:f(function(n){for(var u=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,i=n.stacktrace.split(`
|
|
8
|
+
`),l=[],d=0,p=i.length;d<p;d+=2){var m=u.exec(i[d]);m&&l.push(new t({functionName:m[3]||void 0,fileName:m[2],lineNumber:m[1],source:i[d]}))}return l},"ErrorStackParser$$parseOpera10"),parseOpera11:f(function(n){var u=n.stack.split(`
|
|
9
|
+
`).filter(function(i){return!!i.match(o)&&!i.match(/^Error created at/)},this);return u.map(function(i){var l=i.split("@"),d=this.extractLocation(l.pop()),p=l.shift()||"",m=p.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,c;p.match(/\(([^)]*)\)/)&&(c=p.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var y=c===void 0||c==="[arguments not available]"?void 0:c.split(",");return new t({functionName:m,args:y,fileName:d[0],lineNumber:d[1],columnNumber:d[2],source:i})},this)},"ErrorStackParser$$parseOpera11")}},"ErrorStackParser"))});var be={};ie(be,{loadPyodide:()=>D,version:()=>b});var q=h(H());var E=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&typeof process.browser=="undefined",A,F,R,I,B;async function z(){if(!E||(A=(await import("url")).default,B=await import("fs/promises"),globalThis.fetch?F=fetch:F=(await import("node-fetch")).default,I=(await import("vm")).default,R=await import("path"),x=R.sep,typeof g!="undefined"))return;let e=await import("fs"),t=await import("crypto"),o=await import("ws"),s=await import("child_process"),a={fs:e,crypto:t,ws:o,child_process:s};globalThis.require=function(r){return a[r]}}f(z,"initNodeModules");function ae(e,t){return R.resolve(t||".",e)}f(ae,"node_resolvePath");function se(e,t){return t===void 0&&(t=location),new URL(e,t).toString()}f(se,"browser_resolvePath");var k;E?k=ae:k=se;var x;E||(x="/");async function le(e,t){if(e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")){let o=await F(e);if(!o.ok)throw new Error(`Failed to load '${e}': request failed.`);return new Uint8Array(await o.arrayBuffer())}else{let o=await B.readFile(e);return new Uint8Array(o.buffer,o.byteOffset,o.byteLength)}}f(le,"node_loadBinaryFile");async function de(e,t){let o=new URL(e,location),a=await fetch(o,t?{integrity:t}:{});if(!a.ok)throw new Error(`Failed to load '${o}': request failed.`);return new Uint8Array(await a.arrayBuffer())}f(de,"browser_loadBinaryFile");var P;E?P=le:P=de;var S;if(globalThis.document)S=f(async e=>await import(e),"loadScript");else if(globalThis.importScripts)S=f(async e=>{try{globalThis.importScripts(e)}catch(t){if(t instanceof TypeError)await import(e);else throw t}},"loadScript");else if(E)S=ce;else throw new Error("Cannot determine runtime environment");async function ce(e){e.startsWith("file://")&&(e=e.slice(7)),e.includes("://")?I.runInThisContext(await(await F(e)).text()):await import(A.pathToFileURL(e).href)}f(ce,"nodeLoadScript");function W(e){let t=e.FS,o=e.FS.filesystems.MEMFS,s=e.PATH,a={DIR_MODE:16895,FILE_MODE:33279,mount:function(r){if(!r.opts.fileSystemHandle)throw new Error("opts.fileSystemHandle is required");return o.mount.apply(null,arguments)},syncfs:async(r,n,u)=>{try{let i=a.getLocalSet(r),l=await a.getRemoteSet(r),d=n?l:i,p=n?i:l;await a.reconcile(r,d,p),u(null)}catch(i){u(i)}},getLocalSet:r=>{let n=Object.create(null);function u(d){return d!=="."&&d!==".."}f(u,"isRealDir");function i(d){return p=>s.join2(d,p)}f(i,"toAbsolute");let l=t.readdir(r.mountpoint).filter(u).map(i(r.mountpoint));for(;l.length;){let d=l.pop(),p=t.stat(d);t.isDir(p.mode)&&l.push.apply(l,t.readdir(d).filter(u).map(i(d))),n[d]={timestamp:p.mtime,mode:p.mode}}return{type:"local",entries:n}},getRemoteSet:async r=>{let n=Object.create(null),u=await ue(r.opts.fileSystemHandle);for(let[i,l]of u)i!=="."&&(n[s.join2(r.mountpoint,i)]={timestamp:l.kind==="file"?(await l.getFile()).lastModifiedDate:new Date,mode:l.kind==="file"?a.FILE_MODE:a.DIR_MODE});return{type:"remote",entries:n,handles:u}},loadLocalEntry:r=>{let u=t.lookupPath(r).node,i=t.stat(r);if(t.isDir(i.mode))return{timestamp:i.mtime,mode:i.mode};if(t.isFile(i.mode))return u.contents=o.getFileDataAsTypedArray(u),{timestamp:i.mtime,mode:i.mode,contents:u.contents};throw new Error("node type not supported")},storeLocalEntry:(r,n)=>{if(t.isDir(n.mode))t.mkdirTree(r,n.mode);else if(t.isFile(n.mode))t.writeFile(r,n.contents,{canOwn:!0});else throw new Error("node type not supported");t.chmod(r,n.mode),t.utime(r,n.timestamp,n.timestamp)},removeLocalEntry:r=>{var n=t.stat(r);t.isDir(n.mode)?t.rmdir(r):t.isFile(n.mode)&&t.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(s.dirname(n)),l=t.isFile(u.mode)?await i.getFileHandle(s.basename(n),{create:!0}):await i.getDirectoryHandle(s.basename(n),{create:!0});if(l.kind==="file"){let d=await l.createWritable();await d.write(u.contents),await d.close()}r.set(n,l)},removeRemoteEntry:async(r,n)=>{await r.get(s.dirname(n)).removeEntry(s.basename(n)),r.delete(n)},reconcile:async(r,n,u)=>{let i=0,l=[];Object.keys(n.entries).forEach(function(m){let c=n.entries[m],y=u.entries[m];(!y||t.isFile(c.mode)&&c.timestamp.getTime()>y.timestamp.getTime())&&(l.push(m),i++)}),l.sort();let d=[];if(Object.keys(u.entries).forEach(function(m){n.entries[m]||(d.push(m),i++)}),d.sort().reverse(),!i)return;let p=n.type==="remote"?n.handles:u.handles;for(let m of l){let c=s.normalize(m.replace(r.mountpoint,"/")).substring(1);if(u.type==="local"){let y=p.get(c),v=await a.loadRemoteEntry(y);a.storeLocalEntry(m,v)}else{let y=a.loadLocalEntry(m);await a.storeRemoteEntry(p,c,y)}}for(let m of d)if(u.type==="local")a.removeLocalEntry(m);else{let c=s.normalize(m.replace(r.mountpoint,"/")).substring(1);await a.removeRemoteEntry(p,c)}}};e.FS.filesystems.NATIVEFS_ASYNC=a}f(W,"initializeNativeFS");var ue=f(async e=>{let t=[];async function o(a){for await(let r of a.values())t.push(r),r.kind==="directory"&&await o(r)}f(o,"collect"),await o(e);let s=new Map;s.set(".",e);for(let a of t){let r=(await e.resolve(a)).join("/");s.set(r,a)}return s},"getFsHandles");function G(){let e={};return e.noImageDecoding=!0,e.noAudioDecoding=!0,e.noWasmDecoding=!1,e.preRun=[],e.quit=(t,o)=>{throw e.exited={status:t,toThrow:o},o},e}f(G,"createModule");function fe(e,t){e.preRun.push(function(){let o="/";try{e.FS.mkdirTree(t)}catch(s){console.error(`Error occurred while making a home directory '${t}':`),console.error(s),console.error(`Using '${o}' for a home directory instead`),t=o}e.FS.chdir(t)})}f(fe,"createHomeDirectory");function pe(e,t){e.preRun.push(function(){Object.assign(e.ENV,t)})}f(pe,"setEnvironment");function me(e,t){e.preRun.push(()=>{for(let o of t)e.FS.mkdirTree(o),e.FS.mount(e.FS.filesystems.NODEFS,{root:o},o)})}f(me,"mountLocalDirectories");function ye(e,t){let o=P(t);e.preRun.push(()=>{let s=e._py_version_major(),a=e._py_version_minor();e.FS.mkdirTree("/lib"),e.FS.mkdirTree(`/lib/python${s}.${a}/site-packages`),e.addRunDependency("install-stdlib"),o.then(r=>{e.FS.writeFile(`/lib/python${s}${a}.zip`,r)}).catch(r=>{console.error("Error occurred while installing the standard library:"),console.error(r)}).finally(()=>{e.removeRunDependency("install-stdlib")})})}f(ye,"installStdlib");function V(e,t){let o;t.stdLibURL!=null?o=t.stdLibURL:o=t.indexURL+"python_stdlib.zip",ye(e,o),fe(e,t.env.HOME),pe(e,t.env),me(e,t._node_mounts),e.preRun.push(()=>W(e))}f(V,"initializeFileSystem");var b="0.24.0a1";function ge(e,t){return new Proxy(e,{get(o,s){return s==="get"?a=>{let r=o.get(a);return r===void 0&&(r=t.get(a)),r}:s==="has"?a=>o.has(a)||t.has(a):Reflect.get(o,s)}})}f(ge,"wrapPythonGlobals");function he(e,t){e.runPythonInternal_dict=e._pyodide._base.eval_code("{}"),e.importlib=e.runPythonInternal("import importlib; importlib");let o=e.importlib.import_module;e.sys=o("sys"),e.sys.path.insert(0,t.env.HOME),e.os=o("os");let s=e.runPythonInternal("import __main__; __main__.__dict__"),a=e.runPythonInternal("import builtins; builtins.__dict__");e.globals=ge(s,a);let r=e._pyodide._importhook;function n(i){"__all__"in i||Object.defineProperty(i,"__all__",{get:()=>u.toPy(Object.getOwnPropertyNames(i).filter(l=>l!=="__all__")),enumerable:!1,configurable:!0})}f(n,"jsFinderHook"),r.register_js_finder.callKwargs({hook:n}),r.register_js_module("js",t.jsglobals);let u=e.makePublicAPI();return r.register_js_module("pyodide_js",u),e.pyodide_py=o("pyodide"),e.pyodide_code=o("pyodide.code"),e.pyodide_ffi=o("pyodide.ffi"),e.package_loader=o("pyodide._package_loader"),e.sitepackages=e.package_loader.SITE_PACKAGES.__str__(),e.dsodir=e.package_loader.DSO_DIR.__str__(),e.defaultLdLibraryPath=[e.dsodir,e.sitepackages],e.os.environ.__setitem__("LD_LIBRARY_PATH",e.defaultLdLibraryPath.join(":")),u.pyodide_py=e.pyodide_py,u.globals=e.globals,u}f(he,"finalizeBootstrap");function ve(){if(typeof __dirname=="string")return __dirname;let e;try{throw new Error}catch(s){e=s}let t=q.default.parse(e)[0].fileName,o=t.lastIndexOf(x);if(o===-1)throw new Error("Could not extract indexURL path from pyodide module location");return t.slice(0,o)}f(ve,"calculateIndexURL");async function D(e={}){await z();let t=e.indexURL||ve();t=k(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},s=Object.assign(o,e);if(e.homedir){if(console.warn("The homedir argument to loadPyodide is deprecated. Use 'env: { HOME: value }' instead of 'homedir: value'."),e.env&&e.env.HOME)throw new Error("Set both env.HOME and homedir arguments");s.env.HOME=s.homedir}s.env.HOME||(s.env.HOME="/home/pyodide");let a=G();a.print=s.stdout,a.printErr=s.stderr,a.arguments=s.args;let r={config:s};a.API=r,V(a,s);let n=new Promise(p=>a.postRun=p);if(a.locateFile=p=>s.indexURL+p,typeof _createPyodideModule!="function"){let p=`${s.indexURL}pyodide.asm.js`;await S(p)}if(await _createPyodideModule(a),await n,a.exited)throw a.exited.toThrow;if(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=p=>{throw new Error("Didn't expect to load any more file_packager files!")};let[u,i]=r.rawRun("import _pyodide_core");u&&a.API.fatal_loading_error(`Failed to import _pyodide_core
|
|
10
|
+
`,i);let l=he(r,s);if(l.version.includes("dev")||r.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${l.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(),s.fullStdLib&&await l.loadPackage(r.lockfile_unvendored_stdlibs),r.initializeStreams(s.stdin,s.stdout,s.stderr),l}f(D,"loadPyodide");globalThis.loadPyodide=D;return oe(be);})();
|
|
11
|
+
try{Object.assign(exports,loadPyodide)}catch(_){}
|
|
12
|
+
globalThis.loadPyodide=loadPyodide.loadPyodide;
|
|
2
13
|
//# sourceMappingURL=pyodide.js.map
|