toolshu_pyodide 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1127 @@
1
+ // Generated by dts-bundle-generator v8.1.2
2
+
3
+ export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
4
+ interface PyProxy {
5
+ [x: string]: any;
6
+ }
7
+ /**
8
+ * A :js:class:`~pyodide.ffi.PyProxy` is an object that allows idiomatic use of a Python object from
9
+ * JavaScript. See :ref:`type-translations-pyproxy`.
10
+ */
11
+ declare class PyProxy {
12
+ /** @private */
13
+ $$flags: number;
14
+ /** @private */
15
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
16
+ /**
17
+ * @hideconstructor
18
+ */
19
+ constructor();
20
+ /** @hidden */
21
+ get [Symbol.toStringTag](): string;
22
+ /**
23
+ * The name of the type of the object.
24
+ *
25
+ * Usually the value is ``"module.name"`` but for builtins or
26
+ * interpreter-defined types it is just ``"name"``. As pseudocode this is:
27
+ *
28
+ * .. code-block:: python
29
+ *
30
+ * ty = type(x)
31
+ * if ty.__module__ == 'builtins' or ty.__module__ == "__main__":
32
+ * return ty.__name__
33
+ * else:
34
+ * ty.__module__ + "." + ty.__name__
35
+ *
36
+ */
37
+ get type(): string;
38
+ /**
39
+ * Returns `str(o)` (unless `pyproxyToStringRepr: true` was passed to
40
+ * :js:func:`~globalThis.loadPyodide` in which case it will return `repr(o)`)
41
+ */
42
+ toString(): string;
43
+ /**
44
+ * Destroy the :js:class:`~pyodide.ffi.PyProxy`. This will release the memory. Any further attempt
45
+ * to use the object will raise an error.
46
+ *
47
+ * In a browser supporting :js:data:`FinalizationRegistry`, Pyodide will
48
+ * automatically destroy the :js:class:`~pyodide.ffi.PyProxy` when it is garbage collected, however
49
+ * there is no guarantee that the finalizer will be run in a timely manner so
50
+ * it is better to destroy the proxy explicitly.
51
+ *
52
+ * @param options
53
+ * @param options.message The error message to print if use is attempted after
54
+ * destroying. Defaults to "Object has already been destroyed".
55
+ *
56
+ */
57
+ destroy(options?: {
58
+ message?: string;
59
+ destroyRoundtrip?: boolean;
60
+ }): void;
61
+ /**
62
+ * Make a new :js:class:`~pyodide.ffi.PyProxy` pointing to the same Python object.
63
+ * Useful if the :js:class:`~pyodide.ffi.PyProxy` is destroyed somewhere else.
64
+ */
65
+ copy(): PyProxy;
66
+ /**
67
+ * Converts the :js:class:`~pyodide.ffi.PyProxy` into a JavaScript object as best as possible. By
68
+ * default does a deep conversion, if a shallow conversion is desired, you can
69
+ * use ``proxy.toJs({depth : 1})``. See :ref:`Explicit Conversion of PyProxy
70
+ * <type-translations-pyproxy-to-js>` for more info.
71
+ * @param options
72
+ * @return The JavaScript object resulting from the conversion.
73
+ */
74
+ toJs({ depth, pyproxies, create_pyproxies, dict_converter, default_converter, eager_converter, }?: {
75
+ /** How many layers deep to perform the conversion. Defaults to infinite */
76
+ depth?: number;
77
+ /**
78
+ * If provided, :js:meth:`toJs` will store all PyProxies created in this
79
+ * list. This allows you to easily destroy all the PyProxies by iterating
80
+ * the list without having to recurse over the generated structure. The most
81
+ * common use case is to create a new empty list, pass the list as
82
+ * ``pyproxies``, and then later iterate over ``pyproxies`` to destroy all of
83
+ * created proxies.
84
+ */
85
+ pyproxies?: PyProxy[];
86
+ /**
87
+ * If false, :js:meth:`toJs` will throw a
88
+ * :py:exc:`~pyodide.ffi.ConversionError` rather than producing a
89
+ * :js:class:`~pyodide.ffi.PyProxy`.
90
+ */
91
+ create_pyproxies?: boolean;
92
+ /**
93
+ * A function to be called on an iterable of pairs ``[key, value]``. Convert
94
+ * this iterable of pairs to the desired output. For instance,
95
+ * :js:func:`Object.fromEntries` would convert the dict to an object,
96
+ * :js:func:`Array.from` converts it to an :js:class:`Array` of pairs, and
97
+ * ``(it) => new Map(it)`` converts it to a :js:class:`Map` (which is the
98
+ * default behavior).
99
+ */
100
+ dict_converter?: (array: Iterable<[
101
+ key: string,
102
+ value: any
103
+ ]>) => any;
104
+ /**
105
+ * Optional argument to convert objects with no default conversion. See the
106
+ * documentation of :meth:`~pyodide.ffi.to_js`.
107
+ */
108
+ default_converter?: (obj: PyProxy, convert: (obj: PyProxy) => any, cacheConversion: (obj: PyProxy, result: any) => void) => any;
109
+ /**
110
+ * Optional callback to convert objects which gets called after ``str``,
111
+ * ``int``, ``float``, ``bool``, ``None``, and ``JsProxy`` are converted but
112
+ * *before* any default conversions are applied to standard data structures.
113
+ *
114
+ * Its arguments are the same as `dict_converter`.
115
+ * See the documentation of :meth:`~pyodide.ffi.to_js`.
116
+ */
117
+ eager_converter?: (obj: PyProxy, convert: (obj: PyProxy) => any, cacheConversion: (obj: PyProxy, result: any) => void) => any;
118
+ }): any;
119
+ }
120
+ /**
121
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object has a :meth:`~object.__len__`
122
+ * method.
123
+ */
124
+ declare class PyProxyWithLength extends PyProxy {
125
+ /** @private */
126
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
127
+ }
128
+ interface PyProxyWithLength extends PyLengthMethods {
129
+ }
130
+ declare class PyLengthMethods {
131
+ /**
132
+ * The length of the object.
133
+ */
134
+ get length(): number;
135
+ }
136
+ /**
137
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object has a
138
+ * :meth:`~object.__getitem__` method.
139
+ */
140
+ declare class PyProxyWithGet extends PyProxy {
141
+ /** @private */
142
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
143
+ }
144
+ interface PyProxyWithGet extends PyGetItemMethods {
145
+ }
146
+ declare class PyGetItemMethods {
147
+ /**
148
+ * This translates to the Python code ``obj[key]``.
149
+ *
150
+ * @param key The key to look up.
151
+ * @returns The corresponding value.
152
+ */
153
+ get(key: any): any;
154
+ /**
155
+ * Returns the object treated as a json adaptor.
156
+ *
157
+ * With a JsonAdaptor:
158
+ * 1. property access / modification / deletion is implemented with
159
+ * :meth:`~object.__getitem__`, :meth:`~object.__setitem__`, and
160
+ * :meth:`~object.__delitem__` respectively.
161
+ * 2. If an attribute is accessed and the result implements
162
+ * :meth:`~object.__getitem__` then the result will also be a json
163
+ * adaptor.
164
+ *
165
+ * For instance, ``JSON.stringify(proxy.asJsJson())`` acts like an
166
+ * inverse to Python's :py:func:`json.loads`.
167
+ */
168
+ asJsJson(): PyProxy & {};
169
+ }
170
+ /**
171
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object has a
172
+ * :meth:`~object.__setitem__` or :meth:`~object.__delitem__` method.
173
+ */
174
+ declare class PyProxyWithSet extends PyProxy {
175
+ /** @private */
176
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
177
+ }
178
+ interface PyProxyWithSet extends PySetItemMethods {
179
+ }
180
+ declare class PySetItemMethods {
181
+ /**
182
+ * This translates to the Python code ``obj[key] = value``.
183
+ *
184
+ * @param key The key to set.
185
+ * @param value The value to set it to.
186
+ */
187
+ set(key: any, value: any): void;
188
+ /**
189
+ * This translates to the Python code ``del obj[key]``.
190
+ *
191
+ * @param key The key to delete.
192
+ */
193
+ delete(key: any): void;
194
+ }
195
+ /**
196
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object has a
197
+ * :meth:`~object.__contains__` method.
198
+ */
199
+ declare class PyProxyWithHas extends PyProxy {
200
+ /** @private */
201
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
202
+ }
203
+ interface PyProxyWithHas extends PyContainsMethods {
204
+ }
205
+ declare class PyContainsMethods {
206
+ /**
207
+ * This translates to the Python code ``key in obj``.
208
+ *
209
+ * @param key The key to check for.
210
+ * @returns Is ``key`` present?
211
+ */
212
+ has(key: any): boolean;
213
+ }
214
+ /**
215
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is :std:term:`iterable`
216
+ * (i.e., it has an :meth:`~object.__iter__` method).
217
+ */
218
+ declare class PyIterable extends PyProxy {
219
+ /** @private */
220
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
221
+ }
222
+ interface PyIterable extends PyIterableMethods {
223
+ }
224
+ declare class PyIterableMethods {
225
+ /**
226
+ * This translates to the Python code ``iter(obj)``. Return an iterator
227
+ * associated to the proxy. See the documentation for
228
+ * :js:data:`Symbol.iterator`.
229
+ *
230
+ * This will be used implicitly by ``for(let x of proxy){}``.
231
+ */
232
+ [Symbol.iterator](): Iterator<any, any, any>;
233
+ }
234
+ /**
235
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is :std:term:`asynchronous
236
+ * iterable` (i.e., has an :meth:`~object.__aiter__` method).
237
+ */
238
+ declare class PyAsyncIterable extends PyProxy {
239
+ /** @private */
240
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
241
+ }
242
+ interface PyAsyncIterable extends PyAsyncIterableMethods {
243
+ }
244
+ declare class PyAsyncIterableMethods {
245
+ /**
246
+ * This translates to the Python code ``aiter(obj)``. Return an async iterator
247
+ * associated to the proxy. See the documentation for :js:data:`Symbol.asyncIterator`.
248
+ *
249
+ * This will be used implicitly by ``for(await let x of proxy){}``.
250
+ */
251
+ [Symbol.asyncIterator](): AsyncIterator<any, any, any>;
252
+ }
253
+ /**
254
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is an :term:`iterator`
255
+ * (i.e., has a :meth:`~generator.send` or :meth:`~iterator.__next__` method).
256
+ */
257
+ declare class PyIterator extends PyProxy {
258
+ /** @private */
259
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
260
+ }
261
+ interface PyIterator extends PyIteratorMethods {
262
+ }
263
+ declare class PyIteratorMethods {
264
+ /** @private */
265
+ [Symbol.iterator](): this;
266
+ /**
267
+ * This translates to the Python code ``next(obj)``. Returns the next value of
268
+ * the generator. See the documentation for :js:meth:`Generator.next` The
269
+ * argument will be sent to the Python generator.
270
+ *
271
+ * This will be used implicitly by ``for(let x of proxy){}``.
272
+ *
273
+ * @param arg The value to send to the generator. The value will be assigned
274
+ * as a result of a yield expression.
275
+ * @returns An Object with two properties: ``done`` and ``value``. When the
276
+ * generator yields ``some_value``, ``next`` returns ``{done : false, value :
277
+ * some_value}``. When the generator raises a :py:exc:`StopIteration`
278
+ * exception, ``next`` returns ``{done : true, value : result_value}``.
279
+ */
280
+ next(arg?: any): IteratorResult<any, any>;
281
+ }
282
+ /**
283
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is a :std:term:`generator`
284
+ * (i.e., it is an instance of :py:class:`~collections.abc.Generator`).
285
+ */
286
+ declare class PyGenerator extends PyProxy {
287
+ /** @private */
288
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
289
+ }
290
+ interface PyGenerator extends PyGeneratorMethods {
291
+ }
292
+ declare class PyGeneratorMethods {
293
+ /**
294
+ * Throws an exception into the Generator.
295
+ *
296
+ * See the documentation for :js:meth:`Generator.throw`.
297
+ *
298
+ * @param exc Error The error to throw into the generator. Must be an
299
+ * instanceof ``Error``.
300
+ * @returns An Object with two properties: ``done`` and ``value``. When the
301
+ * generator yields ``some_value``, ``return`` returns ``{done : false, value
302
+ * : some_value}``. When the generator raises a
303
+ * ``StopIteration(result_value)`` exception, ``return`` returns ``{done :
304
+ * true, value : result_value}``.
305
+ */
306
+ throw(exc: any): IteratorResult<any, any>;
307
+ /**
308
+ * Throws a :py:exc:`GeneratorExit` into the generator and if the
309
+ * :py:exc:`GeneratorExit` is not caught returns the argument value ``{done:
310
+ * true, value: v}``. If the generator catches the :py:exc:`GeneratorExit` and
311
+ * returns or yields another value the next value of the generator this is
312
+ * returned in the normal way. If it throws some error other than
313
+ * :py:exc:`GeneratorExit` or :py:exc:`StopIteration`, that error is propagated. See
314
+ * the documentation for :js:meth:`Generator.return`.
315
+ *
316
+ * @param v The value to return from the generator.
317
+ * @returns An Object with two properties: ``done`` and ``value``. When the
318
+ * generator yields ``some_value``, ``return`` returns ``{done : false, value
319
+ * : some_value}``. When the generator raises a
320
+ * ``StopIteration(result_value)`` exception, ``return`` returns ``{done :
321
+ * true, value : result_value}``.
322
+ */
323
+ return(v: any): IteratorResult<any, any>;
324
+ }
325
+ /**
326
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is an
327
+ * :std:term:`asynchronous iterator`
328
+ */
329
+ declare class PyAsyncIterator extends PyProxy {
330
+ /** @private */
331
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
332
+ }
333
+ interface PyAsyncIterator extends PyAsyncIteratorMethods {
334
+ }
335
+ declare class PyAsyncIteratorMethods {
336
+ /** @private */
337
+ [Symbol.asyncIterator](): this;
338
+ /**
339
+ * This translates to the Python code ``anext(obj)``. Returns the next value
340
+ * of the asynchronous iterator. The argument will be sent to the Python
341
+ * iterator (if it's a generator for instance).
342
+ *
343
+ * This will be used implicitly by ``for(let x of proxy){}``.
344
+ *
345
+ * @param arg The value to send to a generator. The value will be assigned as
346
+ * a result of a yield expression.
347
+ * @returns An Object with two properties: ``done`` and ``value``. When the
348
+ * iterator yields ``some_value``, ``next`` returns ``{done : false, value :
349
+ * some_value}``. When the giterator is done, ``next`` returns
350
+ * ``{done : true }``.
351
+ */
352
+ next(arg?: any): Promise<IteratorResult<any, any>>;
353
+ }
354
+ /**
355
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is an
356
+ * :std:term:`asynchronous generator` (i.e., it is an instance of
357
+ * :py:class:`~collections.abc.AsyncGenerator`)
358
+ */
359
+ declare class PyAsyncGenerator extends PyProxy {
360
+ /** @private */
361
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
362
+ }
363
+ interface PyAsyncGenerator extends PyAsyncGeneratorMethods {
364
+ }
365
+ declare class PyAsyncGeneratorMethods {
366
+ /**
367
+ * Throws an exception into the Generator.
368
+ *
369
+ * See the documentation for :js:meth:`AsyncGenerator.throw`.
370
+ *
371
+ * @param exc Error The error to throw into the generator. Must be an
372
+ * instanceof ``Error``.
373
+ * @returns An Object with two properties: ``done`` and ``value``. When the
374
+ * generator yields ``some_value``, ``return`` returns ``{done : false, value
375
+ * : some_value}``. When the generator raises a
376
+ * ``StopIteration(result_value)`` exception, ``return`` returns ``{done :
377
+ * true, value : result_value}``.
378
+ */
379
+ throw(exc: any): Promise<IteratorResult<any, any>>;
380
+ /**
381
+ * Throws a :py:exc:`GeneratorExit` into the generator and if the
382
+ * :py:exc:`GeneratorExit` is not caught returns the argument value ``{done:
383
+ * true, value: v}``. If the generator catches the :py:exc:`GeneratorExit` and
384
+ * returns or yields another value the next value of the generator this is
385
+ * returned in the normal way. If it throws some error other than
386
+ * :py:exc:`GeneratorExit` or :py:exc:`StopAsyncIteration`, that error is
387
+ * propagated. See the documentation for :js:meth:`AsyncGenerator.throw`
388
+ *
389
+ * @param v The value to return from the generator.
390
+ * @returns An Object with two properties: ``done`` and ``value``. When the
391
+ * generator yields ``some_value``, ``return`` returns ``{done : false, value
392
+ * : some_value}``. When the generator raises a :py:exc:`StopAsyncIteration`
393
+ * exception, ``return`` returns ``{done : true, value : result_value}``.
394
+ */
395
+ return(v: any): Promise<IteratorResult<any, any>>;
396
+ }
397
+ /**
398
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is an
399
+ * :py:class:`~collections.abc.Sequence` (i.e., a :py:class:`list`)
400
+ */
401
+ declare class PySequence extends PyProxy {
402
+ /** @private */
403
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
404
+ }
405
+ interface PySequence extends PySequenceMethods {
406
+ }
407
+ declare class PySequenceMethods {
408
+ /** @hidden */
409
+ get [Symbol.isConcatSpreadable](): boolean;
410
+ /**
411
+ * See :js:meth:`Array.join`. The :js:meth:`Array.join` method creates and
412
+ * returns a new string by concatenating all of the elements in the
413
+ * :py:class:`~collections.abc.Sequence`.
414
+ *
415
+ * @param separator A string to separate each pair of adjacent elements of the
416
+ * Sequence.
417
+ *
418
+ * @returns A string with all Sequence elements joined.
419
+ */
420
+ join(separator?: string): string;
421
+ /**
422
+ * See :js:meth:`Array.slice`. The :js:meth:`Array.slice` method returns a
423
+ * shallow copy of a portion of a :py:class:`~collections.abc.Sequence` into a
424
+ * new array object selected from ``start`` to ``stop`` (`stop` not included)
425
+ * @param start Zero-based index at which to start extraction. Negative index
426
+ * counts back from the end of the Sequence.
427
+ * @param stop Zero-based index at which to end extraction. Negative index
428
+ * counts back from the end of the Sequence.
429
+ * @returns A new array containing the extracted elements.
430
+ */
431
+ slice(start?: number, stop?: number): any;
432
+ /**
433
+ * See :js:meth:`Array.lastIndexOf`. Returns the last index at which a given
434
+ * element can be found in the Sequence, or -1 if it is not present.
435
+ * @param elt Element to locate in the Sequence.
436
+ * @param fromIndex Zero-based index at which to start searching backwards,
437
+ * converted to an integer. Negative index counts back from the end of the
438
+ * Sequence.
439
+ * @returns The last index of the element in the Sequence; -1 if not found.
440
+ */
441
+ lastIndexOf(elt: any, fromIndex?: number): number;
442
+ /**
443
+ * See :js:meth:`Array.indexOf`. Returns the first index at which a given
444
+ * element can be found in the Sequence, or -1 if it is not present.
445
+ * @param elt Element to locate in the Sequence.
446
+ * @param fromIndex Zero-based index at which to start searching, converted to
447
+ * an integer. Negative index counts back from the end of the Sequence.
448
+ * @returns The first index of the element in the Sequence; -1 if not found.
449
+ */
450
+ indexOf(elt: any, fromIndex?: number): number;
451
+ /**
452
+ * See :js:meth:`Array.forEach`. Executes a provided function once for each
453
+ * ``Sequence`` element.
454
+ * @param callbackfn A function to execute for each element in the ``Sequence``. Its
455
+ * return value is discarded.
456
+ * @param thisArg A value to use as ``this`` when executing ``callbackFn``.
457
+ */
458
+ forEach(callbackfn: (elt: any) => void, thisArg?: any): void;
459
+ /**
460
+ * See :js:meth:`Array.map`. Creates a new array populated with the results of
461
+ * calling a provided function on every element in the calling ``Sequence``.
462
+ * @param callbackfn A function to execute for each element in the ``Sequence``. Its
463
+ * return value is added as a single element in the new array.
464
+ * @param thisArg A value to use as ``this`` when executing ``callbackFn``.
465
+ */
466
+ map<U>(callbackfn: (elt: any, index: number, array: any) => U, thisArg?: any): U[];
467
+ /**
468
+ * See :js:meth:`Array.filter`. Creates a shallow copy of a portion of a given
469
+ * ``Sequence``, filtered down to just the elements from the given array that pass
470
+ * the test implemented by the provided function.
471
+ * @param predicate A function to execute for each element in the array. It
472
+ * should return a truthy value to keep the element in the resulting array,
473
+ * and a falsy value otherwise.
474
+ * @param thisArg A value to use as ``this`` when executing ``predicate``.
475
+ */
476
+ filter(predicate: (elt: any, index: number, array: any) => boolean, thisArg?: any): any[];
477
+ /**
478
+ * See :js:meth:`Array.some`. Tests whether at least one element in the
479
+ * ``Sequence`` passes the test implemented by the provided function.
480
+ * @param predicate A function to execute for each element in the
481
+ * ``Sequence``. It should return a truthy value to indicate the element
482
+ * passes the test, and a falsy value otherwise.
483
+ * @param thisArg A value to use as ``this`` when executing ``predicate``.
484
+ */
485
+ some(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
486
+ /**
487
+ * See :js:meth:`Array.every`. Tests whether every element in the ``Sequence``
488
+ * passes the test implemented by the provided function.
489
+ * @param predicate A function to execute for each element in the
490
+ * ``Sequence``. It should return a truthy value to indicate the element
491
+ * passes the test, and a falsy value otherwise.
492
+ * @param thisArg A value to use as ``this`` when executing ``predicate``.
493
+ */
494
+ every(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
495
+ /**
496
+ * See :js:meth:`Array.reduce`. Executes a user-supplied "reducer" callback
497
+ * function on each element of the Sequence, in order, passing in the return
498
+ * value from the calculation on the preceding element. The final result of
499
+ * running the reducer across all elements of the Sequence is a single value.
500
+ * @param callbackfn A function to execute for each element in the ``Sequence``. Its
501
+ * return value is discarded.
502
+ */
503
+ reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any) => any, initialValue?: any): any;
504
+ /**
505
+ * See :js:meth:`Array.reduceRight`. Applies a function against an accumulator
506
+ * and each value of the Sequence (from right to left) to reduce it to a
507
+ * single value.
508
+ * @param callbackfn A function to execute for each element in the Sequence.
509
+ * Its return value is discarded.
510
+ */
511
+ reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any) => any, initialValue: any): any;
512
+ /**
513
+ * See :js:meth:`Array.at`. Takes an integer value and returns the item at
514
+ * that index.
515
+ * @param index Zero-based index of the Sequence element to be returned,
516
+ * converted to an integer. Negative index counts back from the end of the
517
+ * Sequence.
518
+ * @returns The element in the Sequence matching the given index.
519
+ */
520
+ at(index: number): any;
521
+ /**
522
+ * The :js:meth:`Array.concat` method is used to merge two or more arrays.
523
+ * This method does not change the existing arrays, but instead returns a new
524
+ * array.
525
+ * @param rest Arrays and/or values to concatenate into a new array.
526
+ * @returns A new Array instance.
527
+ */
528
+ concat(...rest: ConcatArray<any>[]): any[];
529
+ /**
530
+ * The :js:meth:`Array.includes` method determines whether a Sequence
531
+ * includes a certain value among its entries, returning true or false as
532
+ * appropriate.
533
+ * @param elt
534
+ * @returns
535
+ */
536
+ includes(elt: any): any;
537
+ /**
538
+ * The :js:meth:`Array.entries` method returns a new iterator object that
539
+ * contains the key/value pairs for each index in the ``Sequence``.
540
+ * @returns A new iterator object.
541
+ */
542
+ entries(): IterableIterator<[
543
+ number,
544
+ any
545
+ ]>;
546
+ /**
547
+ * The :js:meth:`Array.keys` method returns a new iterator object that
548
+ * contains the keys for each index in the ``Sequence``.
549
+ * @returns A new iterator object.
550
+ */
551
+ keys(): IterableIterator<number>;
552
+ /**
553
+ * The :js:meth:`Array.values` method returns a new iterator object that
554
+ * contains the values for each index in the ``Sequence``.
555
+ * @returns A new iterator object.
556
+ */
557
+ values(): IterableIterator<any>;
558
+ /**
559
+ * The :js:meth:`Array.find` method returns the first element in the provided
560
+ * array that satisfies the provided testing function.
561
+ * @param predicate A function to execute for each element in the
562
+ * ``Sequence``. It should return a truthy value to indicate a matching
563
+ * element has been found, and a falsy value otherwise.
564
+ * @param thisArg A value to use as ``this`` when executing ``predicate``.
565
+ * @returns The first element in the ``Sequence`` that satisfies the provided
566
+ * testing function.
567
+ */
568
+ find(predicate: (value: any, index: number, obj: any[]) => any, thisArg?: any): any;
569
+ /**
570
+ * The :js:meth:`Array.findIndex` method returns the index of the first
571
+ * element in the provided array that satisfies the provided testing function.
572
+ * @param predicate A function to execute for each element in the
573
+ * ``Sequence``. It should return a truthy value to indicate a matching
574
+ * element has been found, and a falsy value otherwise.
575
+ * @param thisArg A value to use as ``this`` when executing ``predicate``.
576
+ * @returns The index of the first element in the ``Sequence`` that satisfies
577
+ * the provided testing function.
578
+ */
579
+ findIndex(predicate: (value: any, index: number, obj: any[]) => any, thisArg?: any): number;
580
+ toJSON(this: any): unknown[];
581
+ /**
582
+ * Returns the object treated as a json adaptor.
583
+ *
584
+ * With a JsonAdaptor:
585
+ * 1. property access / modification / deletion is implemented with
586
+ * :meth:`~object.__getitem__`, :meth:`~object.__setitem__`, and
587
+ * :meth:`~object.__delitem__` respectively.
588
+ * 2. If an attribute is accessed and the result implements
589
+ * :meth:`~object.__getitem__` then the result will also be a json
590
+ * adaptor.
591
+ *
592
+ * For instance, ``JSON.stringify(proxy.asJsJson())`` acts like an
593
+ * inverse to Python's :py:func:`json.loads`.
594
+ */
595
+ asJsJson(): PyProxy & {};
596
+ }
597
+ /**
598
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is an
599
+ * :py:class:`~collections.abc.MutableSequence` (i.e., a :py:class:`list`)
600
+ */
601
+ declare class PyMutableSequence extends PyProxy {
602
+ /** @private */
603
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
604
+ }
605
+ interface PyMutableSequence extends PyMutableSequenceMethods {
606
+ }
607
+ declare class PyMutableSequenceMethods {
608
+ /**
609
+ * The :js:meth:`Array.reverse` method reverses a :js:class:`PyMutableSequence` in
610
+ * place.
611
+ * @returns A reference to the same :js:class:`PyMutableSequence`
612
+ */
613
+ reverse(): PyMutableSequence;
614
+ /**
615
+ * The :js:meth:`Array.sort` method sorts the elements of a
616
+ * :js:class:`PyMutableSequence` in place.
617
+ * @param compareFn A function that defines the sort order.
618
+ * @returns A reference to the same :js:class:`PyMutableSequence`
619
+ */
620
+ sort(compareFn?: (a: any, b: any) => number): PyMutableSequence;
621
+ /**
622
+ * The :js:meth:`Array.splice` method changes the contents of a
623
+ * :js:class:`PyMutableSequence` by removing or replacing existing elements and/or
624
+ * adding new elements in place.
625
+ * @param start Zero-based index at which to start changing the
626
+ * :js:class:`PyMutableSequence`.
627
+ * @param deleteCount An integer indicating the number of elements in the
628
+ * :js:class:`PyMutableSequence` to remove from ``start``.
629
+ * @param items The elements to add to the :js:class:`PyMutableSequence`, beginning from
630
+ * ``start``.
631
+ * @returns An array containing the deleted elements.
632
+ */
633
+ splice(start: number, deleteCount?: number, ...items: any[]): any[];
634
+ /**
635
+ * The :js:meth:`Array.push` method adds the specified elements to the end of
636
+ * a :js:class:`PyMutableSequence`.
637
+ * @param elts The element(s) to add to the end of the :js:class:`PyMutableSequence`.
638
+ * @returns The new length property of the object upon which the method was
639
+ * called.
640
+ */
641
+ push(...elts: any[]): any;
642
+ /**
643
+ * The :js:meth:`Array.pop` method removes the last element from a
644
+ * :js:class:`PyMutableSequence`.
645
+ * @returns The removed element from the :js:class:`PyMutableSequence`; undefined if the
646
+ * :js:class:`PyMutableSequence` is empty.
647
+ */
648
+ pop(): any;
649
+ /**
650
+ * The :js:meth:`Array.shift` method removes the first element from a
651
+ * :js:class:`PyMutableSequence`.
652
+ * @returns The removed element from the :js:class:`PyMutableSequence`; undefined if the
653
+ * :js:class:`PyMutableSequence` is empty.
654
+ */
655
+ shift(): any;
656
+ /**
657
+ * The :js:meth:`Array.unshift` method adds the specified elements to the
658
+ * beginning of a :js:class:`PyMutableSequence`.
659
+ * @param elts The elements to add to the front of the :js:class:`PyMutableSequence`.
660
+ * @returns The new length of the :js:class:`PyMutableSequence`.
661
+ */
662
+ unshift(...elts: any[]): any;
663
+ /**
664
+ * The :js:meth:`Array.copyWithin` method shallow copies part of a
665
+ * :js:class:`PyMutableSequence` to another location in the same :js:class:`PyMutableSequence`
666
+ * without modifying its length.
667
+ * @param target Zero-based index at which to copy the sequence to.
668
+ * @param start Zero-based index at which to start copying elements from.
669
+ * @param end Zero-based index at which to end copying elements from.
670
+ * @returns The modified :js:class:`PyMutableSequence`.
671
+ */
672
+ copyWithin(target: number, start?: number, end?: number): any;
673
+ /**
674
+ * The :js:meth:`Array.fill` method changes all elements in an array to a
675
+ * static value, from a start index to an end index.
676
+ * @param value Value to fill the array with.
677
+ * @param start Zero-based index at which to start filling. Default 0.
678
+ * @param end Zero-based index at which to end filling. Default
679
+ * ``list.length``.
680
+ * @returns
681
+ */
682
+ fill(value: any, start?: number, end?: number): any;
683
+ }
684
+ /**
685
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is :ref:`awaitable
686
+ * <asyncio-awaitables>` (i.e., has an :meth:`~object.__await__` method).
687
+ */
688
+ declare class PyAwaitable extends PyProxy {
689
+ /** @private */
690
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
691
+ }
692
+ interface PyAwaitable extends Promise<any> {
693
+ }
694
+ /**
695
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is
696
+ * :std:term:`callable` (i.e., has an :py:meth:`~object.__call__` method).
697
+ */
698
+ declare class PyCallable extends PyProxy {
699
+ /** @private */
700
+ static [Symbol.hasInstance](obj: any): obj is PyCallable;
701
+ }
702
+ interface PyCallable extends PyCallableMethods {
703
+ (...args: any[]): any;
704
+ }
705
+ declare class PyCallableMethods {
706
+ /**
707
+ * The ``apply()`` method calls the specified function with a given this
708
+ * value, and arguments provided as an array (or an array-like object). Like
709
+ * :js:meth:`Function.apply`.
710
+ *
711
+ * @param thisArg The ``this`` argument. Has no effect unless the
712
+ * :js:class:`~pyodide.ffi.PyCallable` has :js:meth:`captureThis` set. If
713
+ * :js:meth:`captureThis` is set, it will be passed as the first argument to
714
+ * the Python function.
715
+ * @param jsargs The array of arguments
716
+ * @returns The result from the function call.
717
+ */
718
+ apply(thisArg: any, jsargs: any): any;
719
+ /**
720
+ * Calls the function with a given this value and arguments provided
721
+ * individually. See :js:meth:`Function.call`.
722
+ *
723
+ * @param thisArg The ``this`` argument. Has no effect unless the
724
+ * :js:class:`~pyodide.ffi.PyCallable` has :js:meth:`captureThis` set. If
725
+ * :js:meth:`captureThis` is set, it will be passed as the first argument to
726
+ * the Python function.
727
+ * @param jsargs The arguments
728
+ * @returns The result from the function call.
729
+ */
730
+ call(thisArg: any, ...jsargs: any): any;
731
+ /**
732
+ * Call the Python function. The first parameter controls various parameters
733
+ * that change the way the call is performed.
734
+ *
735
+ * @param options
736
+ * @param options.kwargs If true, the last argument is treated as a collection
737
+ * of keyword arguments.
738
+ * @param options.promising If true, the call is made with stack switching
739
+ * enabled. Not needed if the callee is an async
740
+ * Python function.
741
+ * @param options.relaxed If true, extra arguments are ignored instead of
742
+ * raising a :py:exc:`TypeError`.
743
+ * @param jsargs Arguments to the Python function.
744
+ * @returns
745
+ */
746
+ callWithOptions({ relaxed, kwargs, promising, }: {
747
+ relaxed?: boolean;
748
+ kwargs?: boolean;
749
+ promising?: boolean;
750
+ }, ...jsargs: any): any;
751
+ /**
752
+ * Call the function with keyword arguments. The last argument must be an
753
+ * object with the keyword arguments.
754
+ */
755
+ callKwargs(...jsargs: any): any;
756
+ /**
757
+ * Call the function in a "relaxed" manner. Any extra arguments will be
758
+ * ignored. This matches the behavior of JavaScript functions more accurately.
759
+ *
760
+ * Any extra arguments will be ignored. This matches the behavior of
761
+ * JavaScript functions more accurately. Missing arguments are **NOT** filled
762
+ * with `None`. If too few arguments are passed, this will still raise a
763
+ * TypeError.
764
+ *
765
+ * This uses :py:func:`pyodide.code.relaxed_call`.
766
+ */
767
+ callRelaxed(...jsargs: any): any;
768
+ /**
769
+ * Call the function with keyword arguments in a "relaxed" manner. The last
770
+ * argument must be an object with the keyword arguments. Any extra arguments
771
+ * will be ignored. This matches the behavior of JavaScript functions more
772
+ * accurately.
773
+ *
774
+ * Missing arguments are **NOT** filled with ``None``. If too few arguments are
775
+ * passed, this will still raise a :py:exc:`TypeError`. Also, if the same argument is
776
+ * passed as both a keyword argument and a positional argument, it will raise
777
+ * an error.
778
+ *
779
+ * This uses :py:func:`pyodide.code.relaxed_call`.
780
+ */
781
+ callKwargsRelaxed(...jsargs: any): any;
782
+ /**
783
+ * Call the function with stack switching enabled. The last argument must be
784
+ * an object with the keyword arguments. Functions called this way can use
785
+ * :py:meth:`~pyodide.ffi.run_sync` to block until an
786
+ * :py:class:`~collections.abc.Awaitable` is resolved. Only works in runtimes
787
+ * with JS Promise integration.
788
+ *
789
+ * .. admonition:: Experimental
790
+ * :class: warning
791
+ *
792
+ * This feature is not yet stable.
793
+ *
794
+ * @experimental
795
+ */
796
+ callPromising(...jsargs: any): Promise<any>;
797
+ /**
798
+ * Call the function with stack switching enabled. The last argument must be
799
+ * an object with the keyword arguments. Functions called this way can use
800
+ * :py:meth:`~pyodide.ffi.run_sync` to block until an
801
+ * :py:class:`~collections.abc.Awaitable` is resolved. Only works in runtimes
802
+ * with JS Promise integration.
803
+ *
804
+ * .. admonition:: Experimental
805
+ * :class: warning
806
+ *
807
+ * This feature is not yet stable.
808
+ *
809
+ * @experimental
810
+ */
811
+ callPromisingKwargs(...jsargs: any): Promise<any>;
812
+ /**
813
+ * The ``bind()`` method creates a new function that, when called, has its
814
+ * ``this`` keyword set to the provided value, with a given sequence of
815
+ * arguments preceding any provided when the new function is called. See
816
+ * :js:meth:`Function.bind`.
817
+ *
818
+ * If the :js:class:`~pyodide.ffi.PyCallable` does not have
819
+ * :js:meth:`captureThis` set, the ``this`` parameter will be discarded. If it
820
+ * does have :js:meth:`captureThis` set, ``thisArg`` will be set to the first
821
+ * argument of the Python function. The returned proxy and the original proxy
822
+ * have the same lifetime so destroying either destroys both.
823
+ *
824
+ * @param thisArg The value to be passed as the ``this`` parameter to the
825
+ * target function ``func`` when the bound function is called.
826
+ * @param jsargs Extra arguments to prepend to arguments provided to the bound
827
+ * function when invoking ``func``.
828
+ * @returns
829
+ */
830
+ bind(thisArg: any, ...jsargs: any): PyProxy;
831
+ /**
832
+ * Returns a :js:class:`~pyodide.ffi.PyProxy` that passes ``this`` as the first argument to the
833
+ * Python function. The returned :js:class:`~pyodide.ffi.PyProxy` has the internal ``captureThis``
834
+ * property set.
835
+ *
836
+ * It can then be used as a method on a JavaScript object. The returned proxy
837
+ * and the original proxy have the same lifetime so destroying either destroys
838
+ * both.
839
+ *
840
+ * For example:
841
+ *
842
+ * .. code-block:: pyodide
843
+ *
844
+ * let obj = { a : 7 };
845
+ * pyodide.runPython(`
846
+ * def f(self):
847
+ * return self.a
848
+ * `);
849
+ * // Without captureThis, it doesn't work to use f as a method for obj:
850
+ * obj.f = pyodide.globals.get("f");
851
+ * obj.f(); // raises "TypeError: f() missing 1 required positional argument: 'self'"
852
+ * // With captureThis, it works fine:
853
+ * obj.f = pyodide.globals.get("f").captureThis();
854
+ * obj.f(); // returns 7
855
+ *
856
+ * @returns The resulting :js:class:`~pyodide.ffi.PyProxy`. It has the same lifetime as the
857
+ * original :js:class:`~pyodide.ffi.PyProxy` but passes ``this`` to the wrapped function.
858
+ *
859
+ */
860
+ captureThis(): PyProxy;
861
+ }
862
+ /**
863
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object supports the
864
+ * Python :external:doc:`c-api/buffer`.
865
+ *
866
+ * Examples of buffers include {py:class}`bytes` objects and numpy
867
+ * {external+numpy:ref}`arrays`.
868
+ */
869
+ declare class PyBuffer extends PyProxy {
870
+ /** @private */
871
+ static [Symbol.hasInstance](obj: any): obj is PyBuffer;
872
+ }
873
+ interface PyBuffer extends PyBufferMethods {
874
+ }
875
+ declare class PyBufferMethods {
876
+ /**
877
+ * Get a view of the buffer data which is usable from JavaScript. No copy is
878
+ * ever performed.
879
+ *
880
+ * We do not support suboffsets, if the buffer requires suboffsets we will
881
+ * throw an error. JavaScript nd array libraries can't handle suboffsets
882
+ * anyways. In this case, you should use the :js:meth:`~PyProxy.toJs` api or
883
+ * copy the buffer to one that doesn't use suboffsets (using e.g.,
884
+ * :py:func:`numpy.ascontiguousarray`).
885
+ *
886
+ * If the buffer stores big endian data or half floats, this function will
887
+ * fail without an explicit type argument. For big endian data you can use
888
+ * :js:meth:`~PyProxy.toJs`. :js:class:`DataView` has support for big endian
889
+ * data, so you might want to pass ``'dataview'`` as the type argument in that
890
+ * case.
891
+ *
892
+ * @param type The type of the :js:attr:`~pyodide.ffi.PyBufferView.data` field
893
+ * in the output. Should be one of: ``"i8"``, ``"u8"``, ``"u8clamped"``,
894
+ * ``"i16"``, ``"u16"``, ``"i32"``, ``"u32"``, ``"i32"``, ``"u32"``,
895
+ * ``"i64"``, ``"u64"``, ``"f32"``, ``"f64"``, or ``"dataview"``. This argument
896
+ * is optional, if absent :js:meth:`~pyodide.ffi.PyBuffer.getBuffer` will try
897
+ * to determine the appropriate output type based on the buffer format string
898
+ * (see :std:ref:`struct-format-strings`).
899
+ */
900
+ getBuffer(type?: string): PyBufferView;
901
+ }
902
+ /**
903
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is a :py:class:`dict`.
904
+ */
905
+ declare class PyDict extends PyProxy {
906
+ /** @private */
907
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
908
+ }
909
+ interface PyDict extends PyProxyWithGet, PyProxyWithSet, PyProxyWithHas, PyProxyWithLength, PyIterable {
910
+ }
911
+ /**
912
+ * A class to allow access to Python data buffers from JavaScript. These are
913
+ * produced by :js:meth:`~pyodide.ffi.PyBuffer.getBuffer` and cannot be constructed directly.
914
+ * When you are done, release it with the :js:func:`~PyBufferView.release` method.
915
+ * See the Python :external:doc:`c-api/buffer` documentation for more
916
+ * information.
917
+ *
918
+ * To find the element ``x[a_1, ..., a_n]``, you could use the following code:
919
+ *
920
+ * .. code-block:: js
921
+ *
922
+ * function multiIndexToIndex(pybuff, multiIndex) {
923
+ * if (multindex.length !== pybuff.ndim) {
924
+ * throw new Error("Wrong length index");
925
+ * }
926
+ * let idx = pybuff.offset;
927
+ * for (let i = 0; i < pybuff.ndim; i++) {
928
+ * if (multiIndex[i] < 0) {
929
+ * multiIndex[i] = pybuff.shape[i] - multiIndex[i];
930
+ * }
931
+ * if (multiIndex[i] < 0 || multiIndex[i] >= pybuff.shape[i]) {
932
+ * throw new Error("Index out of range");
933
+ * }
934
+ * idx += multiIndex[i] * pybuff.stride[i];
935
+ * }
936
+ * return idx;
937
+ * }
938
+ * console.log("entry is", pybuff.data[multiIndexToIndex(pybuff, [2, 0, -1])]);
939
+ *
940
+ * .. admonition:: Converting between TypedArray types
941
+ * :class: warning
942
+ *
943
+ * The following naive code to change the type of a typed array does not
944
+ * work:
945
+ *
946
+ * .. code-block:: js
947
+ *
948
+ * // Incorrectly convert a TypedArray.
949
+ * // Produces a Uint16Array that points to the entire WASM memory!
950
+ * let myarray = new Uint16Array(buffer.data.buffer);
951
+ *
952
+ * Instead, if you want to convert the output TypedArray, you need to say:
953
+ *
954
+ * .. code-block:: js
955
+ *
956
+ * // Correctly convert a TypedArray.
957
+ * let myarray = new Uint16Array(
958
+ * buffer.data.buffer,
959
+ * buffer.data.byteOffset,
960
+ * buffer.data.byteLength
961
+ * );
962
+ */
963
+ declare class PyBufferView {
964
+ /**
965
+ * The offset of the first entry of the array. For instance if our array
966
+ * is 3d, then you will find ``array[0,0,0]`` at
967
+ * ``pybuf.data[pybuf.offset]``
968
+ */
969
+ offset: number;
970
+ /**
971
+ * If the data is read only, you should not modify it. There is no way for us
972
+ * to enforce this, but it may cause very weird behavior. See
973
+ * :py:attr:`memoryview.readonly`.
974
+ */
975
+ readonly: boolean;
976
+ /**
977
+ * The format string for the buffer. See :ref:`struct-format-strings`
978
+ * and :py:attr:`memoryview.format`.
979
+ */
980
+ format: string;
981
+ /**
982
+ * How large is each entry in bytes? See :py:attr:`memoryview.itemsize`.
983
+ */
984
+ itemsize: number;
985
+ /**
986
+ * The number of dimensions of the buffer. If ``ndim`` is 0, the buffer
987
+ * represents a single scalar or struct. Otherwise, it represents an
988
+ * array. See :py:attr:`memoryview.ndim`.
989
+ */
990
+ ndim: number;
991
+ /**
992
+ * The total number of bytes the buffer takes up. This is equal to
993
+ * :js:attr:`buff.data.byteLength <TypedArray.byteLength>`. See
994
+ * :py:attr:`memoryview.nbytes`.
995
+ */
996
+ nbytes: number;
997
+ /**
998
+ * The shape of the buffer, that is how long it is in each dimension.
999
+ * The length will be equal to ``ndim``. For instance, a 2x3x4 array
1000
+ * would have shape ``[2, 3, 4]``. See :py:attr:`memoryview.shape`.
1001
+ */
1002
+ shape: number[];
1003
+ /**
1004
+ * An array of of length ``ndim`` giving the number of elements to skip
1005
+ * to get to a new element in each dimension. See the example definition
1006
+ * of a ``multiIndexToIndex`` function above. See :py:attr:`memoryview.strides`.
1007
+ */
1008
+ strides: number[];
1009
+ /**
1010
+ * The actual data. A typed array of an appropriate size backed by a segment
1011
+ * of the WASM memory.
1012
+ *
1013
+ * The ``type`` argument of :js:meth:`~pyodide.ffi.PyBuffer.getBuffer` determines
1014
+ * which sort of :js:class:`TypedArray` or :js:class:`DataView` to return. By
1015
+ * default :js:meth:`~pyodide.ffi.PyBuffer.getBuffer` will look at the format string
1016
+ * to determine the most appropriate option. Most often the result is a
1017
+ * :js:class:`Uint8Array`.
1018
+ *
1019
+ * .. admonition:: Contiguity
1020
+ * :class: warning
1021
+ *
1022
+ * If the buffer is not contiguous, the :js:attr:`~PyBufferView.readonly`
1023
+ * TypedArray will contain data that is not part of the buffer. Modifying
1024
+ * this data leads to undefined behavior.
1025
+ *
1026
+ * .. admonition:: Read only buffers
1027
+ * :class: warning
1028
+ *
1029
+ * If :js:attr:`buffer.readonly <PyBufferView.readonly>` is ``true``, you
1030
+ * should not modify the buffer. Modifying a read only buffer leads to
1031
+ * undefined behavior.
1032
+ *
1033
+ */
1034
+ data: TypedArray;
1035
+ /**
1036
+ * Is it C contiguous? See :py:attr:`memoryview.c_contiguous`.
1037
+ */
1038
+ c_contiguous: boolean;
1039
+ /**
1040
+ * Is it Fortran contiguous? See :py:attr:`memoryview.f_contiguous`.
1041
+ */
1042
+ f_contiguous: boolean;
1043
+ /**
1044
+ * @private
1045
+ */
1046
+ _released: boolean;
1047
+ /**
1048
+ * @private
1049
+ */
1050
+ _view_ptr: number;
1051
+ /** @private */
1052
+ constructor();
1053
+ /**
1054
+ * Release the buffer. This allows the memory to be reclaimed.
1055
+ */
1056
+ release(): void;
1057
+ }
1058
+ /**
1059
+ * A JavaScript error caused by a Python exception.
1060
+ *
1061
+ * In order to reduce the risk of large memory leaks, the :js:class:`PythonError`
1062
+ * contains no reference to the Python exception that caused it. You can find
1063
+ * the actual Python exception that caused this error as
1064
+ * :py:data:`sys.last_exc`.
1065
+ *
1066
+ * See :ref:`type translations of errors <type-translations-errors>` for more
1067
+ * information.
1068
+ *
1069
+ * .. admonition:: Avoid leaking stack Frames
1070
+ * :class: warning
1071
+ *
1072
+ * If you make a :js:class:`~pyodide.ffi.PyProxy` of
1073
+ * :py:data:`sys.last_exc`, you should be especially careful to
1074
+ * :js:meth:`~pyodide.ffi.PyProxy.destroy` it when you are done. You may leak a large
1075
+ * amount of memory including the local variables of all the stack frames in
1076
+ * the traceback if you don't. The easiest way is to only handle the
1077
+ * exception in Python.
1078
+ *
1079
+ * @hideconstructor
1080
+ */
1081
+ declare class PythonError extends Error {
1082
+ /**
1083
+ * The address of the error we are wrapping. We may later compare this
1084
+ * against sys.last_exc.
1085
+ * WARNING: we don't own a reference to this pointer, dereferencing it
1086
+ * may be a use-after-free error!
1087
+ * @private
1088
+ */
1089
+ __error_address: number;
1090
+ /**
1091
+ * The name of the Python error class, e.g, :py:exc:`RuntimeError` or
1092
+ * :py:exc:`KeyError`.
1093
+ */
1094
+ type: string;
1095
+ constructor(type: string, message: string, error_address: number);
1096
+ }
1097
+ /**
1098
+ * Foreign function interface classes. Can be used for typescript type
1099
+ * annotations or at runtime for `instanceof` checks.
1100
+ * @summaryLink :ref:`ffi <js-api-pyodide-ffi>`
1101
+ * @hidetype
1102
+ * @omitFromAutoModule
1103
+ */
1104
+ declare const ffi: {
1105
+ PyProxy: typeof PyProxy;
1106
+ PyProxyWithLength: typeof PyProxyWithLength;
1107
+ PyProxyWithGet: typeof PyProxyWithGet;
1108
+ PyProxyWithSet: typeof PyProxyWithSet;
1109
+ PyProxyWithHas: typeof PyProxyWithHas;
1110
+ PyDict: typeof PyDict;
1111
+ PyIterable: typeof PyIterable;
1112
+ PyAsyncIterable: typeof PyAsyncIterable;
1113
+ PyIterator: typeof PyIterator;
1114
+ PyAsyncIterator: typeof PyAsyncIterator;
1115
+ PyGenerator: typeof PyGenerator;
1116
+ PyAsyncGenerator: typeof PyAsyncGenerator;
1117
+ PyAwaitable: typeof PyAwaitable;
1118
+ PyCallable: typeof PyCallable;
1119
+ PyBuffer: typeof PyBuffer;
1120
+ PyBufferView: typeof PyBufferView;
1121
+ PythonError: typeof PythonError;
1122
+ PySequence: typeof PySequence;
1123
+ PyMutableSequence: typeof PyMutableSequence;
1124
+ };
1125
+
1126
+ export type {};
1127
+ export type {PyAsyncGenerator, PyAsyncIterable, PyAsyncIterator, PyAwaitable, PyBuffer, PyBufferView, PyCallable, PyDict, PyGenerator, PyIterable, PyIterator, PyMutableSequence, PyProxy, PyProxyWithGet, PyProxyWithHas, PyProxyWithLength, PyProxyWithSet, PySequence, PythonError};