pyodide 0.26.0-alpha.4 → 0.26.0-alpha.5

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/console.html CHANGED
@@ -2,6 +2,14 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
+ <meta
6
+ http-equiv="origin-trial"
7
+ content="Aq6vv/4syIkcyMszFgCc9LlH0kX88jdE7SXfCFnh2RQN0nhhL8o6PCQ2oE3a7n3mC7+d9n89Repw5HYBtjarDw4AAAB3eyJvcmlnaW4iOiJodHRwczovL3B5b2RpZGUub3JnOjQ0MyIsImZlYXR1cmUiOiJXZWJBc3NlbWJseUpTUHJvbWlzZUludGVncmF0aW9uIiwiZXhwaXJ5IjoxNzMwMjQ2Mzk5LCJpc1N1YmRvbWFpbiI6dHJ1ZX0="
8
+ />
9
+ <meta
10
+ http-equiv="origin-trial"
11
+ content="Ai8IXb0XqedlM/Q2guWXFfBkKiYY9uaPZpdjHqc8y0ZvpAfK9SKzp/dIuFH+txG/HEKxt59uIkk39hhWrhNgbw4AAABieyJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0OjgwMDAiLCJmZWF0dXJlIjoiV2ViQXNzZW1ibHlKU1Byb21pc2VJbnRlZ3JhdGlvbiIsImV4cGlyeSI6MTczMDI0NjM5OX0="
12
+ />
5
13
  <script src="https://cdn.jsdelivr.net/npm/jquery"></script>
6
14
  <script src="https://cdn.jsdelivr.net/npm/jquery.terminal@2.35.2/js/jquery.terminal.min.js"></script>
7
15
  <script src="https://cdn.jsdelivr.net/npm/jquery.terminal@2.35.2/js/unix_formatting.min.js"></script>
package/ffi.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- // Generated by dts-bundle-generator v8.1.1
1
+ // Generated by dts-bundle-generator v8.1.2
2
2
 
3
+ export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
3
4
  interface PyProxy {
4
5
  [x: string]: any;
5
6
  }
@@ -36,7 +37,7 @@ declare class PyProxy {
36
37
  get type(): string;
37
38
  /**
38
39
  * Returns `str(o)` (unless `pyproxyToStringRepr: true` was passed to
39
- * :js:func:`loadPyodide` in which case it will return `repr(o)`)
40
+ * :js:func:`~globalThis.loadPyodide` in which case it will return `repr(o)`)
40
41
  */
41
42
  toString(): string;
42
43
  /**
@@ -141,6 +142,21 @@ declare class PyGetItemMethods {
141
142
  * @returns The corresponding value.
142
143
  */
143
144
  get(key: any): any;
145
+ /**
146
+ * Returns the object treated as a json adaptor.
147
+ *
148
+ * With a JsonAdaptor:
149
+ * 1. property access / modification / deletion is implemented with
150
+ * :meth:`~object.__getitem__`, :meth:`~object.__setitem__`, and
151
+ * :meth:`~object.__delitem__` respectively.
152
+ * 2. If an attribute is accessed and the result implements
153
+ * :meth:`~object.__getitem__` then the result will also be a json
154
+ * adaptor.
155
+ *
156
+ * For instance, ``JSON.stringify(proxy.asJsJson())`` acts like an
157
+ * inverse to Python's :py:func:`json.loads`.
158
+ */
159
+ asJsJson(): PyProxy & {};
144
160
  }
145
161
  /**
146
162
  * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object has a
@@ -245,7 +261,7 @@ declare class PyIteratorMethods {
245
261
  *
246
262
  * This will be used implicitly by ``for(let x of proxy){}``.
247
263
  *
248
- * @param any The value to send to the generator. The value will be assigned
264
+ * @param arg The value to send to the generator. The value will be assigned
249
265
  * as a result of a yield expression.
250
266
  * @returns An Object with two properties: ``done`` and ``value``. When the
251
267
  * generator yields ``some_value``, ``next`` returns ``{done : false, value :
@@ -270,7 +286,7 @@ declare class PyGeneratorMethods {
270
286
  *
271
287
  * See the documentation for :js:meth:`Generator.throw`.
272
288
  *
273
- * @param exception Error The error to throw into the generator. Must be an
289
+ * @param exc Error The error to throw into the generator. Must be an
274
290
  * instanceof ``Error``.
275
291
  * @returns An Object with two properties: ``done`` and ``value``. When the
276
292
  * generator yields ``some_value``, ``return`` returns ``{done : false, value
@@ -288,7 +304,7 @@ declare class PyGeneratorMethods {
288
304
  * :py:exc:`GeneratorExit` or :py:exc:`StopIteration`, that error is propagated. See
289
305
  * the documentation for :js:meth:`Generator.return`.
290
306
  *
291
- * @param any The value to return from the generator.
307
+ * @param v The value to return from the generator.
292
308
  * @returns An Object with two properties: ``done`` and ``value``. When the
293
309
  * generator yields ``some_value``, ``return`` returns ``{done : false, value
294
310
  * : some_value}``. When the generator raises a
@@ -317,7 +333,7 @@ declare class PyAsyncIteratorMethods {
317
333
  *
318
334
  * This will be used implicitly by ``for(let x of proxy){}``.
319
335
  *
320
- * @param any The value to send to a generator. The value will be assigned as
336
+ * @param arg The value to send to a generator. The value will be assigned as
321
337
  * a result of a yield expression.
322
338
  * @returns An Object with two properties: ``done`` and ``value``. When the
323
339
  * iterator yields ``some_value``, ``next`` returns ``{done : false, value :
@@ -343,7 +359,7 @@ declare class PyAsyncGeneratorMethods {
343
359
  *
344
360
  * See the documentation for :js:meth:`AsyncGenerator.throw`.
345
361
  *
346
- * @param exception Error The error to throw into the generator. Must be an
362
+ * @param exc Error The error to throw into the generator. Must be an
347
363
  * instanceof ``Error``.
348
364
  * @returns An Object with two properties: ``done`` and ``value``. When the
349
365
  * generator yields ``some_value``, ``return`` returns ``{done : false, value
@@ -361,7 +377,7 @@ declare class PyAsyncGeneratorMethods {
361
377
  * :py:exc:`GeneratorExit` or :py:exc:`StopAsyncIteration`, that error is
362
378
  * propagated. See the documentation for :js:meth:`AsyncGenerator.throw`
363
379
  *
364
- * @param any The value to return from the generator.
380
+ * @param v The value to return from the generator.
365
381
  * @returns An Object with two properties: ``done`` and ``value``. When the
366
382
  * generator yields ``some_value``, ``return`` returns ``{done : false, value
367
383
  * : some_value}``. When the generator raises a :py:exc:`StopAsyncIteration`
@@ -443,7 +459,7 @@ declare class PySequenceMethods {
443
459
  * See :js:meth:`Array.filter`. Creates a shallow copy of a portion of a given
444
460
  * ``Sequence``, filtered down to just the elements from the given array that pass
445
461
  * the test implemented by the provided function.
446
- * @param callbackfn A function to execute for each element in the array. It
462
+ * @param predicate A function to execute for each element in the array. It
447
463
  * should return a truthy value to keep the element in the resulting array,
448
464
  * and a falsy value otherwise.
449
465
  * @param thisArg A value to use as ``this`` when executing ``predicate``.
@@ -452,7 +468,7 @@ declare class PySequenceMethods {
452
468
  /**
453
469
  * See :js:meth:`Array.some`. Tests whether at least one element in the
454
470
  * ``Sequence`` passes the test implemented by the provided function.
455
- * @param callbackfn A function to execute for each element in the
471
+ * @param predicate A function to execute for each element in the
456
472
  * ``Sequence``. It should return a truthy value to indicate the element
457
473
  * passes the test, and a falsy value otherwise.
458
474
  * @param thisArg A value to use as ``this`` when executing ``predicate``.
@@ -461,7 +477,7 @@ declare class PySequenceMethods {
461
477
  /**
462
478
  * See :js:meth:`Array.every`. Tests whether every element in the ``Sequence``
463
479
  * passes the test implemented by the provided function.
464
- * @param callbackfn A function to execute for each element in the
480
+ * @param predicate A function to execute for each element in the
465
481
  * ``Sequence``. It should return a truthy value to indicate the element
466
482
  * passes the test, and a falsy value otherwise.
467
483
  * @param thisArg A value to use as ``this`` when executing ``predicate``.
@@ -474,7 +490,6 @@ declare class PySequenceMethods {
474
490
  * running the reducer across all elements of the Sequence is a single value.
475
491
  * @param callbackfn A function to execute for each element in the ``Sequence``. Its
476
492
  * return value is discarded.
477
- * @param thisArg A value to use as ``this`` when executing ``callbackfn``.
478
493
  */
479
494
  reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any) => any, initialValue?: any): any;
480
495
  /**
@@ -483,7 +498,6 @@ declare class PySequenceMethods {
483
498
  * single value.
484
499
  * @param callbackfn A function to execute for each element in the Sequence.
485
500
  * Its return value is discarded.
486
- * @param thisArg A value to use as ``this`` when executing ``callbackFn``.
487
501
  */
488
502
  reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any) => any, initialValue: any): any;
489
503
  /**
@@ -554,6 +568,22 @@ declare class PySequenceMethods {
554
568
  * the provided testing function.
555
569
  */
556
570
  findIndex(predicate: (value: any, index: number, obj: any[]) => any, thisArg?: any): number;
571
+ toJSON(this: any): unknown[];
572
+ /**
573
+ * Returns the object treated as a json adaptor.
574
+ *
575
+ * With a JsonAdaptor:
576
+ * 1. property access / modification / deletion is implemented with
577
+ * :meth:`~object.__getitem__`, :meth:`~object.__setitem__`, and
578
+ * :meth:`~object.__delitem__` respectively.
579
+ * 2. If an attribute is accessed and the result implements
580
+ * :meth:`~object.__getitem__` then the result will also be a json
581
+ * adaptor.
582
+ *
583
+ * For instance, ``JSON.stringify(proxy.asJsJson())`` acts like an
584
+ * inverse to Python's :py:func:`json.loads`.
585
+ */
586
+ asJsJson(): PyProxy & {};
557
587
  }
558
588
  /**
559
589
  * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is an
@@ -689,6 +719,26 @@ declare class PyCallableMethods {
689
719
  * @returns The result from the function call.
690
720
  */
691
721
  call(thisArg: any, ...jsargs: any): any;
722
+ /**
723
+ * Call the Python function. The first parameter controls various parameters
724
+ * that change the way the call is performed.
725
+ *
726
+ * @param options
727
+ * @param options.kwargs If true, the last argument is treated as a collection
728
+ * of keyword arguments.
729
+ * @param options.promising If true, the call is made with stack switching
730
+ * enabled. Not needed if the callee is an async
731
+ * Python function.
732
+ * @param options.relaxed If true, extra arguments are ignored instead of
733
+ * raising a :py:exc:`TypeError`.
734
+ * @param jsargs Arguments to the Python function.
735
+ * @returns
736
+ */
737
+ callWithOptions({ relaxed, kwargs, promising, }: {
738
+ relaxed?: boolean;
739
+ kwargs?: boolean;
740
+ promising?: boolean;
741
+ }, ...jsargs: any): any;
692
742
  /**
693
743
  * Call the function with keyword arguments. The last argument must be an
694
744
  * object with the keyword arguments.
@@ -712,8 +762,8 @@ declare class PyCallableMethods {
712
762
  * will be ignored. This matches the behavior of JavaScript functions more
713
763
  * accurately.
714
764
  *
715
- * Missing arguments are **NOT** filled with `None`. If too few arguments are
716
- * passed, this will still raise a TypeError. Also, if the same argument is
765
+ * Missing arguments are **NOT** filled with ``None``. If too few arguments are
766
+ * passed, this will still raise a :py:exc:`TypeError`. Also, if the same argument is
717
767
  * passed as both a keyword argument and a positional argument, it will raise
718
768
  * an error.
719
769
  *
@@ -721,11 +771,11 @@ declare class PyCallableMethods {
721
771
  */
722
772
  callKwargsRelaxed(...jsargs: any): any;
723
773
  /**
724
- * Call the function with stack switching enabled. Functions called this way
725
- * can use
726
- * :py:meth:`PyodideFuture.syncify() <pyodide.webloop.PyodideFuture.syncify>`
727
- * to block until a :py:class:`~asyncio.Future` or :js:class:`Promise` is
728
- * resolved. Only works in runtimes with JS Promise integration.
774
+ * Call the function with stack switching enabled. The last argument must be
775
+ * an object with the keyword arguments. Functions called this way can use
776
+ * :py:meth:`~pyodide.ffi.run_sync` to block until an
777
+ * :py:class:`~collections.abc.Awaitable` is resolved. Only works in runtimes
778
+ * with JS Promise integration.
729
779
  *
730
780
  * .. admonition:: Experimental
731
781
  * :class: warning
@@ -734,13 +784,13 @@ declare class PyCallableMethods {
734
784
  *
735
785
  * @experimental
736
786
  */
737
- callSyncifying(...jsargs: any): Promise<any>;
787
+ callPromising(...jsargs: any): Promise<any>;
738
788
  /**
739
789
  * Call the function with stack switching enabled. The last argument must be
740
790
  * an object with the keyword arguments. Functions called this way can use
741
- * :py:meth:`PyodideFuture.syncify() <pyodide.webloop.PyodideFuture.syncify>`
742
- * to block until a :py:class:`~asyncio.Future` or :js:class:`Promise` is
743
- * resolved. Only works in runtimes with JS Promise integration.
791
+ * :py:meth:`~pyodide.ffi.run_sync` to block until an
792
+ * :py:class:`~collections.abc.Awaitable` is resolved. Only works in runtimes
793
+ * with JS Promise integration.
744
794
  *
745
795
  * .. admonition:: Experimental
746
796
  * :class: warning
@@ -749,7 +799,7 @@ declare class PyCallableMethods {
749
799
  *
750
800
  * @experimental
751
801
  */
752
- callSyncifyingKwargs(...jsargs: any): Promise<any>;
802
+ callPromisingKwargs(...jsargs: any): Promise<any>;
753
803
  /**
754
804
  * The ``bind()`` method creates a new function that, when called, has its
755
805
  * ``this`` keyword set to the provided value, with a given sequence of
@@ -833,7 +883,7 @@ declare class PyBufferMethods {
833
883
  * @param type The type of the :js:attr:`~pyodide.ffi.PyBufferView.data` field
834
884
  * in the output. Should be one of: ``"i8"``, ``"u8"``, ``"u8clamped"``,
835
885
  * ``"i16"``, ``"u16"``, ``"i32"``, ``"u32"``, ``"i32"``, ``"u32"``,
836
- * ``"i64"``, ``"u64"``, ``"f32"``, ``"f64``, or ``"dataview"``. This argument
886
+ * ``"i64"``, ``"u64"``, ``"f32"``, ``"f64"``, or ``"dataview"``. This argument
837
887
  * is optional, if absent :js:meth:`~pyodide.ffi.PyBuffer.getBuffer` will try
838
888
  * to determine the appropriate output type based on the buffer format string
839
889
  * (see :std:ref:`struct-format-strings`).
@@ -860,23 +910,23 @@ interface PyDict extends PyProxyWithGet, PyProxyWithSet, PyProxyWithHas, PyProxy
860
910
  *
861
911
  * .. code-block:: js
862
912
  *
863
- * function multiIndexToIndex(pybuff, multiIndex){
864
- * if(multindex.length !==pybuff.ndim){
865
- * throw new Error("Wrong length index");
913
+ * function multiIndexToIndex(pybuff, multiIndex) {
914
+ * if (multindex.length !== pybuff.ndim) {
915
+ * throw new Error("Wrong length index");
866
916
  * }
867
917
  * let idx = pybuff.offset;
868
- * for(let i = 0; i < pybuff.ndim; i++){
869
- * if(multiIndex[i] < 0){
870
- * multiIndex[i] = pybuff.shape[i] - multiIndex[i];
871
- * }
872
- * if(multiIndex[i] < 0 || multiIndex[i] >= pybuff.shape[i]){
873
- * throw new Error("Index out of range");
874
- * }
875
- * idx += multiIndex[i] * pybuff.stride[i];
918
+ * for (let i = 0; i < pybuff.ndim; i++) {
919
+ * if (multiIndex[i] < 0) {
920
+ * multiIndex[i] = pybuff.shape[i] - multiIndex[i];
921
+ * }
922
+ * if (multiIndex[i] < 0 || multiIndex[i] >= pybuff.shape[i]) {
923
+ * throw new Error("Index out of range");
924
+ * }
925
+ * idx += multiIndex[i] * pybuff.stride[i];
876
926
  * }
877
927
  * return idx;
878
- * }
879
- * console.log("entry is", pybuff.data[multiIndexToIndex(pybuff, [2, 0, -1])]);
928
+ * }
929
+ * console.log("entry is", pybuff.data[multiIndexToIndex(pybuff, [2, 0, -1])]);
880
930
  *
881
931
  * .. admonition:: Converting between TypedArray types
882
932
  * :class: warning
@@ -931,7 +981,8 @@ declare class PyBufferView {
931
981
  ndim: number;
932
982
  /**
933
983
  * The total number of bytes the buffer takes up. This is equal to
934
- * :js:attr:`buff.data.byteLength <TypedArray.byteLength>`. See :py:attr:`memoryview.nbytes`.
984
+ * :js:attr:`buff.data.byteLength <TypedArray.byteLength>`. See
985
+ * :py:attr:`memoryview.nbytes`.
935
986
  */
936
987
  nbytes: number;
937
988
  /**
@@ -980,7 +1031,13 @@ declare class PyBufferView {
980
1031
  * Is it Fortran contiguous? See :py:attr:`memoryview.f_contiguous`.
981
1032
  */
982
1033
  f_contiguous: boolean;
1034
+ /**
1035
+ * @private
1036
+ */
983
1037
  _released: boolean;
1038
+ /**
1039
+ * @private
1040
+ */
984
1041
  _view_ptr: number;
985
1042
  /** @private */
986
1043
  constructor();
@@ -989,7 +1046,6 @@ declare class PyBufferView {
989
1046
  */
990
1047
  release(): void;
991
1048
  }
992
- export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
993
1049
  /**
994
1050
  * A JavaScript error caused by a Python exception.
995
1051
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyodide",
3
- "version": "0.26.0-alpha.4",
3
+ "version": "0.26.0-alpha.5",
4
4
  "description": "The Pyodide JavaScript package",
5
5
  "keywords": [
6
6
  "python",
@@ -127,7 +127,6 @@
127
127
  }
128
128
  },
129
129
  "dependencies": {
130
- "base-64": "^1.0.0",
131
130
  "ws": "^8.5.0"
132
131
  },
133
132
  "types": "./pyodide.d.ts",