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,1639 @@
1
+ // Generated by dts-bundle-generator v8.1.2
2
+
3
+ /**
4
+ *
5
+ * The Pyodide version.
6
+ *
7
+ * The version here is a Python version, following :pep:`440`. This is different
8
+ * from the version in ``package.json`` which follows the node package manager
9
+ * version convention.
10
+ */
11
+ export declare const version: string;
12
+ interface CanvasInterface {
13
+ setCanvas2D(canvas: HTMLCanvasElement): void;
14
+ getCanvas2D(): HTMLCanvasElement | undefined;
15
+ setCanvas3D(canvas: HTMLCanvasElement): void;
16
+ getCanvas3D(): HTMLCanvasElement | undefined;
17
+ }
18
+ type InFuncType = () => null | undefined | string | ArrayBuffer | Uint8Array | number;
19
+ declare function setStdin(options?: {
20
+ stdin?: InFuncType;
21
+ read?: (buffer: Uint8Array) => number;
22
+ error?: boolean;
23
+ isatty?: boolean;
24
+ autoEOF?: boolean;
25
+ }): void;
26
+ declare function setStdout(options?: {
27
+ batched?: (output: string) => void;
28
+ raw?: (charCode: number) => void;
29
+ write?: (buffer: Uint8Array) => number;
30
+ isatty?: boolean;
31
+ }): void;
32
+ declare function setStderr(options?: {
33
+ batched?: (output: string) => void;
34
+ raw?: (charCode: number) => void;
35
+ write?: (buffer: Uint8Array) => number;
36
+ isatty?: boolean;
37
+ }): void;
38
+ /** @deprecated Use `import type { TypedArray } from "pyodide/ffi"` instead */
39
+ export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
40
+ type FSNode = {
41
+ timestamp: number;
42
+ rdev: number;
43
+ contents: Uint8Array;
44
+ mode: number;
45
+ };
46
+ type FSStream = {
47
+ tty?: boolean;
48
+ seekable?: boolean;
49
+ stream_ops: FSStreamOps;
50
+ node: FSNode;
51
+ };
52
+ type FSStreamOps = FSStreamOpsGen<FSStream>;
53
+ type FSStreamOpsGen<T> = {
54
+ open: (a: T) => void;
55
+ close: (a: T) => void;
56
+ fsync: (a: T) => void;
57
+ read: (a: T, b: Uint8Array, offset: number, length: number, pos: number) => number;
58
+ write: (a: T, b: Uint8Array, offset: number, length: number, pos: number) => number;
59
+ };
60
+ interface FSType {
61
+ unlink: (path: string) => void;
62
+ mkdirTree: (path: string, mode?: number) => void;
63
+ chdir: (path: string) => void;
64
+ symlink: (target: string, src: string) => FSNode;
65
+ createDevice: ((parent: string, name: string, input?: (() => number | null) | null, output?: ((code: number) => void) | null) => FSNode) & {
66
+ major: number;
67
+ };
68
+ closeStream: (fd: number) => void;
69
+ open: (path: string, flags: string | number, mode?: number) => FSStream;
70
+ makedev: (major: number, minor: number) => number;
71
+ mkdev: (path: string, dev: number) => FSNode;
72
+ filesystems: any;
73
+ stat: (path: string, dontFollow?: boolean) => any;
74
+ readdir: (path: string) => string[];
75
+ isDir: (mode: number) => boolean;
76
+ isMountpoint: (mode: FSNode) => boolean;
77
+ lookupPath: (path: string, options?: {
78
+ follow_mount?: boolean;
79
+ }) => {
80
+ node: FSNode;
81
+ };
82
+ isFile: (mode: number) => boolean;
83
+ writeFile: (path: string, contents: any, o?: {
84
+ canOwn?: boolean;
85
+ }) => void;
86
+ chmod: (path: string, mode: number) => void;
87
+ utime: (path: string, atime: number, mtime: number) => void;
88
+ rmdir: (path: string) => void;
89
+ mount: (type: any, opts: any, mountpoint: string) => any;
90
+ write: (stream: FSStream, buffer: any, offset: number, length: number, position?: number) => number;
91
+ close: (stream: FSStream) => void;
92
+ ErrnoError: {
93
+ new (errno: number): Error;
94
+ };
95
+ registerDevice<T>(dev: number, ops: FSStreamOpsGen<T>): void;
96
+ syncfs(dir: boolean, oncomplete: (val: void) => void): void;
97
+ findObject(a: string, dontResolveLastLink?: boolean): any;
98
+ readFile(a: string): Uint8Array;
99
+ }
100
+ type PackageType = "package" | "cpython_module" | "shared_library" | "static_library";
101
+ interface PackageData {
102
+ name: string;
103
+ version: string;
104
+ fileName: string;
105
+ /** @experimental */
106
+ packageType: PackageType;
107
+ }
108
+ type LoadedPackages = Record<string, string>;
109
+ /** @deprecated Use `import type { PyProxy } from "pyodide/ffi"` instead */
110
+ interface PyProxy {
111
+ [x: string]: any;
112
+ }
113
+ declare class PyProxy {
114
+ /** @private */
115
+ $$flags: number;
116
+ /** @private */
117
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
118
+ /**
119
+ * @hideconstructor
120
+ */
121
+ constructor();
122
+ /** @hidden */
123
+ get [Symbol.toStringTag](): string;
124
+ /**
125
+ * The name of the type of the object.
126
+ *
127
+ * Usually the value is ``"module.name"`` but for builtins or
128
+ * interpreter-defined types it is just ``"name"``. As pseudocode this is:
129
+ *
130
+ * .. code-block:: python
131
+ *
132
+ * ty = type(x)
133
+ * if ty.__module__ == 'builtins' or ty.__module__ == "__main__":
134
+ * return ty.__name__
135
+ * else:
136
+ * ty.__module__ + "." + ty.__name__
137
+ *
138
+ */
139
+ get type(): string;
140
+ /**
141
+ * Returns `str(o)` (unless `pyproxyToStringRepr: true` was passed to
142
+ * :js:func:`~globalThis.loadPyodide` in which case it will return `repr(o)`)
143
+ */
144
+ toString(): string;
145
+ /**
146
+ * Destroy the :js:class:`~pyodide.ffi.PyProxy`. This will release the memory. Any further attempt
147
+ * to use the object will raise an error.
148
+ *
149
+ * In a browser supporting :js:data:`FinalizationRegistry`, Pyodide will
150
+ * automatically destroy the :js:class:`~pyodide.ffi.PyProxy` when it is garbage collected, however
151
+ * there is no guarantee that the finalizer will be run in a timely manner so
152
+ * it is better to destroy the proxy explicitly.
153
+ *
154
+ * @param options
155
+ * @param options.message The error message to print if use is attempted after
156
+ * destroying. Defaults to "Object has already been destroyed".
157
+ *
158
+ */
159
+ destroy(options?: {
160
+ message?: string;
161
+ destroyRoundtrip?: boolean;
162
+ }): void;
163
+ /**
164
+ * Make a new :js:class:`~pyodide.ffi.PyProxy` pointing to the same Python object.
165
+ * Useful if the :js:class:`~pyodide.ffi.PyProxy` is destroyed somewhere else.
166
+ */
167
+ copy(): PyProxy;
168
+ /**
169
+ * Converts the :js:class:`~pyodide.ffi.PyProxy` into a JavaScript object as best as possible. By
170
+ * default does a deep conversion, if a shallow conversion is desired, you can
171
+ * use ``proxy.toJs({depth : 1})``. See :ref:`Explicit Conversion of PyProxy
172
+ * <type-translations-pyproxy-to-js>` for more info.
173
+ * @param options
174
+ * @return The JavaScript object resulting from the conversion.
175
+ */
176
+ toJs({ depth, pyproxies, create_pyproxies, dict_converter, default_converter, eager_converter, }?: {
177
+ /** How many layers deep to perform the conversion. Defaults to infinite */
178
+ depth?: number;
179
+ /**
180
+ * If provided, :js:meth:`toJs` will store all PyProxies created in this
181
+ * list. This allows you to easily destroy all the PyProxies by iterating
182
+ * the list without having to recurse over the generated structure. The most
183
+ * common use case is to create a new empty list, pass the list as
184
+ * ``pyproxies``, and then later iterate over ``pyproxies`` to destroy all of
185
+ * created proxies.
186
+ */
187
+ pyproxies?: PyProxy[];
188
+ /**
189
+ * If false, :js:meth:`toJs` will throw a
190
+ * :py:exc:`~pyodide.ffi.ConversionError` rather than producing a
191
+ * :js:class:`~pyodide.ffi.PyProxy`.
192
+ */
193
+ create_pyproxies?: boolean;
194
+ /**
195
+ * A function to be called on an iterable of pairs ``[key, value]``. Convert
196
+ * this iterable of pairs to the desired output. For instance,
197
+ * :js:func:`Object.fromEntries` would convert the dict to an object,
198
+ * :js:func:`Array.from` converts it to an :js:class:`Array` of pairs, and
199
+ * ``(it) => new Map(it)`` converts it to a :js:class:`Map` (which is the
200
+ * default behavior).
201
+ */
202
+ dict_converter?: (array: Iterable<[
203
+ key: string,
204
+ value: any
205
+ ]>) => any;
206
+ /**
207
+ * Optional argument to convert objects with no default conversion. See the
208
+ * documentation of :meth:`~pyodide.ffi.to_js`.
209
+ */
210
+ default_converter?: (obj: PyProxy, convert: (obj: PyProxy) => any, cacheConversion: (obj: PyProxy, result: any) => void) => any;
211
+ /**
212
+ * Optional callback to convert objects which gets called after ``str``,
213
+ * ``int``, ``float``, ``bool``, ``None``, and ``JsProxy`` are converted but
214
+ * *before* any default conversions are applied to standard data structures.
215
+ *
216
+ * Its arguments are the same as `dict_converter`.
217
+ * See the documentation of :meth:`~pyodide.ffi.to_js`.
218
+ */
219
+ eager_converter?: (obj: PyProxy, convert: (obj: PyProxy) => any, cacheConversion: (obj: PyProxy, result: any) => void) => any;
220
+ }): any;
221
+ }
222
+ declare class PyProxyWithLength extends PyProxy {
223
+ /** @private */
224
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
225
+ }
226
+ /** @deprecated Use `import type { PyProxyWithLength } from "pyodide/ffi"` instead */
227
+ interface PyProxyWithLength extends PyLengthMethods {
228
+ }
229
+ declare class PyLengthMethods {
230
+ /**
231
+ * The length of the object.
232
+ */
233
+ get length(): number;
234
+ }
235
+ declare class PyProxyWithGet extends PyProxy {
236
+ /** @private */
237
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
238
+ }
239
+ /** @deprecated Use `import type { PyProxyWithGet } from "pyodide/ffi"` instead */
240
+ interface PyProxyWithGet extends PyGetItemMethods {
241
+ }
242
+ declare class PyGetItemMethods {
243
+ /**
244
+ * This translates to the Python code ``obj[key]``.
245
+ *
246
+ * @param key The key to look up.
247
+ * @returns The corresponding value.
248
+ */
249
+ get(key: any): any;
250
+ /**
251
+ * Returns the object treated as a json adaptor.
252
+ *
253
+ * With a JsonAdaptor:
254
+ * 1. property access / modification / deletion is implemented with
255
+ * :meth:`~object.__getitem__`, :meth:`~object.__setitem__`, and
256
+ * :meth:`~object.__delitem__` respectively.
257
+ * 2. If an attribute is accessed and the result implements
258
+ * :meth:`~object.__getitem__` then the result will also be a json
259
+ * adaptor.
260
+ *
261
+ * For instance, ``JSON.stringify(proxy.asJsJson())`` acts like an
262
+ * inverse to Python's :py:func:`json.loads`.
263
+ */
264
+ asJsJson(): PyProxy & {};
265
+ }
266
+ declare class PyProxyWithSet extends PyProxy {
267
+ /** @private */
268
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
269
+ }
270
+ /** @deprecated Use `import type { PyProxyWithSet } from "pyodide/ffi"` instead */
271
+ interface PyProxyWithSet extends PySetItemMethods {
272
+ }
273
+ declare class PySetItemMethods {
274
+ /**
275
+ * This translates to the Python code ``obj[key] = value``.
276
+ *
277
+ * @param key The key to set.
278
+ * @param value The value to set it to.
279
+ */
280
+ set(key: any, value: any): void;
281
+ /**
282
+ * This translates to the Python code ``del obj[key]``.
283
+ *
284
+ * @param key The key to delete.
285
+ */
286
+ delete(key: any): void;
287
+ }
288
+ declare class PyProxyWithHas extends PyProxy {
289
+ /** @private */
290
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
291
+ }
292
+ /** @deprecated Use `import type { PyProxyWithHas } from "pyodide/ffi"` instead */
293
+ interface PyProxyWithHas extends PyContainsMethods {
294
+ }
295
+ declare class PyContainsMethods {
296
+ /**
297
+ * This translates to the Python code ``key in obj``.
298
+ *
299
+ * @param key The key to check for.
300
+ * @returns Is ``key`` present?
301
+ */
302
+ has(key: any): boolean;
303
+ }
304
+ declare class PyIterable extends PyProxy {
305
+ /** @private */
306
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
307
+ }
308
+ /** @deprecated Use `import type { PyIterable } from "pyodide/ffi"` instead */
309
+ interface PyIterable extends PyIterableMethods {
310
+ }
311
+ declare class PyIterableMethods {
312
+ /**
313
+ * This translates to the Python code ``iter(obj)``. Return an iterator
314
+ * associated to the proxy. See the documentation for
315
+ * :js:data:`Symbol.iterator`.
316
+ *
317
+ * This will be used implicitly by ``for(let x of proxy){}``.
318
+ */
319
+ [Symbol.iterator](): Iterator<any, any, any>;
320
+ }
321
+ declare class PyAsyncIterable extends PyProxy {
322
+ /** @private */
323
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
324
+ }
325
+ /** @deprecated Use `import type { PyAsyncIterable } from "pyodide/ffi"` instead */
326
+ interface PyAsyncIterable extends PyAsyncIterableMethods {
327
+ }
328
+ declare class PyAsyncIterableMethods {
329
+ /**
330
+ * This translates to the Python code ``aiter(obj)``. Return an async iterator
331
+ * associated to the proxy. See the documentation for :js:data:`Symbol.asyncIterator`.
332
+ *
333
+ * This will be used implicitly by ``for(await let x of proxy){}``.
334
+ */
335
+ [Symbol.asyncIterator](): AsyncIterator<any, any, any>;
336
+ }
337
+ declare class PyIterator extends PyProxy {
338
+ /** @private */
339
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
340
+ }
341
+ /** @deprecated Use `import type { PyIterator } from "pyodide/ffi"` instead */
342
+ interface PyIterator extends PyIteratorMethods {
343
+ }
344
+ declare class PyIteratorMethods {
345
+ /** @private */
346
+ [Symbol.iterator](): this;
347
+ /**
348
+ * This translates to the Python code ``next(obj)``. Returns the next value of
349
+ * the generator. See the documentation for :js:meth:`Generator.next` The
350
+ * argument will be sent to the Python generator.
351
+ *
352
+ * This will be used implicitly by ``for(let x of proxy){}``.
353
+ *
354
+ * @param arg The value to send to the generator. The value will be assigned
355
+ * as a result of a yield expression.
356
+ * @returns An Object with two properties: ``done`` and ``value``. When the
357
+ * generator yields ``some_value``, ``next`` returns ``{done : false, value :
358
+ * some_value}``. When the generator raises a :py:exc:`StopIteration`
359
+ * exception, ``next`` returns ``{done : true, value : result_value}``.
360
+ */
361
+ next(arg?: any): IteratorResult<any, any>;
362
+ }
363
+ declare class PyGenerator extends PyProxy {
364
+ /** @private */
365
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
366
+ }
367
+ /** @deprecated Use `import type { PyGenerator } from "pyodide/ffi"` instead */
368
+ interface PyGenerator extends PyGeneratorMethods {
369
+ }
370
+ declare class PyGeneratorMethods {
371
+ /**
372
+ * Throws an exception into the Generator.
373
+ *
374
+ * See the documentation for :js:meth:`Generator.throw`.
375
+ *
376
+ * @param exc Error The error to throw into the generator. Must be an
377
+ * instanceof ``Error``.
378
+ * @returns An Object with two properties: ``done`` and ``value``. When the
379
+ * generator yields ``some_value``, ``return`` returns ``{done : false, value
380
+ * : some_value}``. When the generator raises a
381
+ * ``StopIteration(result_value)`` exception, ``return`` returns ``{done :
382
+ * true, value : result_value}``.
383
+ */
384
+ throw(exc: any): IteratorResult<any, any>;
385
+ /**
386
+ * Throws a :py:exc:`GeneratorExit` into the generator and if the
387
+ * :py:exc:`GeneratorExit` is not caught returns the argument value ``{done:
388
+ * true, value: v}``. If the generator catches the :py:exc:`GeneratorExit` and
389
+ * returns or yields another value the next value of the generator this is
390
+ * returned in the normal way. If it throws some error other than
391
+ * :py:exc:`GeneratorExit` or :py:exc:`StopIteration`, that error is propagated. See
392
+ * the documentation for :js:meth:`Generator.return`.
393
+ *
394
+ * @param v The value to return from the generator.
395
+ * @returns An Object with two properties: ``done`` and ``value``. When the
396
+ * generator yields ``some_value``, ``return`` returns ``{done : false, value
397
+ * : some_value}``. When the generator raises a
398
+ * ``StopIteration(result_value)`` exception, ``return`` returns ``{done :
399
+ * true, value : result_value}``.
400
+ */
401
+ return(v: any): IteratorResult<any, any>;
402
+ }
403
+ declare class PyAsyncIterator extends PyProxy {
404
+ /** @private */
405
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
406
+ }
407
+ /** @deprecated Use `import type { PyAsyncIterator } from "pyodide/ffi"` instead */
408
+ interface PyAsyncIterator extends PyAsyncIteratorMethods {
409
+ }
410
+ declare class PyAsyncIteratorMethods {
411
+ /** @private */
412
+ [Symbol.asyncIterator](): this;
413
+ /**
414
+ * This translates to the Python code ``anext(obj)``. Returns the next value
415
+ * of the asynchronous iterator. The argument will be sent to the Python
416
+ * iterator (if it's a generator for instance).
417
+ *
418
+ * This will be used implicitly by ``for(let x of proxy){}``.
419
+ *
420
+ * @param arg The value to send to a generator. The value will be assigned as
421
+ * a result of a yield expression.
422
+ * @returns An Object with two properties: ``done`` and ``value``. When the
423
+ * iterator yields ``some_value``, ``next`` returns ``{done : false, value :
424
+ * some_value}``. When the giterator is done, ``next`` returns
425
+ * ``{done : true }``.
426
+ */
427
+ next(arg?: any): Promise<IteratorResult<any, any>>;
428
+ }
429
+ declare class PyAsyncGenerator extends PyProxy {
430
+ /** @private */
431
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
432
+ }
433
+ /** @deprecated Use `import type { PyAsyncGenerator } from "pyodide/ffi"` instead */
434
+ interface PyAsyncGenerator extends PyAsyncGeneratorMethods {
435
+ }
436
+ declare class PyAsyncGeneratorMethods {
437
+ /**
438
+ * Throws an exception into the Generator.
439
+ *
440
+ * See the documentation for :js:meth:`AsyncGenerator.throw`.
441
+ *
442
+ * @param exc Error The error to throw into the generator. Must be an
443
+ * instanceof ``Error``.
444
+ * @returns An Object with two properties: ``done`` and ``value``. When the
445
+ * generator yields ``some_value``, ``return`` returns ``{done : false, value
446
+ * : some_value}``. When the generator raises a
447
+ * ``StopIteration(result_value)`` exception, ``return`` returns ``{done :
448
+ * true, value : result_value}``.
449
+ */
450
+ throw(exc: any): Promise<IteratorResult<any, any>>;
451
+ /**
452
+ * Throws a :py:exc:`GeneratorExit` into the generator and if the
453
+ * :py:exc:`GeneratorExit` is not caught returns the argument value ``{done:
454
+ * true, value: v}``. If the generator catches the :py:exc:`GeneratorExit` and
455
+ * returns or yields another value the next value of the generator this is
456
+ * returned in the normal way. If it throws some error other than
457
+ * :py:exc:`GeneratorExit` or :py:exc:`StopAsyncIteration`, that error is
458
+ * propagated. See the documentation for :js:meth:`AsyncGenerator.throw`
459
+ *
460
+ * @param v The value to return from the generator.
461
+ * @returns An Object with two properties: ``done`` and ``value``. When the
462
+ * generator yields ``some_value``, ``return`` returns ``{done : false, value
463
+ * : some_value}``. When the generator raises a :py:exc:`StopAsyncIteration`
464
+ * exception, ``return`` returns ``{done : true, value : result_value}``.
465
+ */
466
+ return(v: any): Promise<IteratorResult<any, any>>;
467
+ }
468
+ declare class PySequence extends PyProxy {
469
+ /** @private */
470
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
471
+ }
472
+ /** @deprecated Use `import type { PySequence } from "pyodide/ffi"` instead */
473
+ interface PySequence extends PySequenceMethods {
474
+ }
475
+ declare class PySequenceMethods {
476
+ /** @hidden */
477
+ get [Symbol.isConcatSpreadable](): boolean;
478
+ /**
479
+ * See :js:meth:`Array.join`. The :js:meth:`Array.join` method creates and
480
+ * returns a new string by concatenating all of the elements in the
481
+ * :py:class:`~collections.abc.Sequence`.
482
+ *
483
+ * @param separator A string to separate each pair of adjacent elements of the
484
+ * Sequence.
485
+ *
486
+ * @returns A string with all Sequence elements joined.
487
+ */
488
+ join(separator?: string): string;
489
+ /**
490
+ * See :js:meth:`Array.slice`. The :js:meth:`Array.slice` method returns a
491
+ * shallow copy of a portion of a :py:class:`~collections.abc.Sequence` into a
492
+ * new array object selected from ``start`` to ``stop`` (`stop` not included)
493
+ * @param start Zero-based index at which to start extraction. Negative index
494
+ * counts back from the end of the Sequence.
495
+ * @param stop Zero-based index at which to end extraction. Negative index
496
+ * counts back from the end of the Sequence.
497
+ * @returns A new array containing the extracted elements.
498
+ */
499
+ slice(start?: number, stop?: number): any;
500
+ /**
501
+ * See :js:meth:`Array.lastIndexOf`. Returns the last index at which a given
502
+ * element can be found in the Sequence, or -1 if it is not present.
503
+ * @param elt Element to locate in the Sequence.
504
+ * @param fromIndex Zero-based index at which to start searching backwards,
505
+ * converted to an integer. Negative index counts back from the end of the
506
+ * Sequence.
507
+ * @returns The last index of the element in the Sequence; -1 if not found.
508
+ */
509
+ lastIndexOf(elt: any, fromIndex?: number): number;
510
+ /**
511
+ * See :js:meth:`Array.indexOf`. Returns the first index at which a given
512
+ * element can be found in the Sequence, or -1 if it is not present.
513
+ * @param elt Element to locate in the Sequence.
514
+ * @param fromIndex Zero-based index at which to start searching, converted to
515
+ * an integer. Negative index counts back from the end of the Sequence.
516
+ * @returns The first index of the element in the Sequence; -1 if not found.
517
+ */
518
+ indexOf(elt: any, fromIndex?: number): number;
519
+ /**
520
+ * See :js:meth:`Array.forEach`. Executes a provided function once for each
521
+ * ``Sequence`` element.
522
+ * @param callbackfn A function to execute for each element in the ``Sequence``. Its
523
+ * return value is discarded.
524
+ * @param thisArg A value to use as ``this`` when executing ``callbackFn``.
525
+ */
526
+ forEach(callbackfn: (elt: any) => void, thisArg?: any): void;
527
+ /**
528
+ * See :js:meth:`Array.map`. Creates a new array populated with the results of
529
+ * calling a provided function on every element in the calling ``Sequence``.
530
+ * @param callbackfn A function to execute for each element in the ``Sequence``. Its
531
+ * return value is added as a single element in the new array.
532
+ * @param thisArg A value to use as ``this`` when executing ``callbackFn``.
533
+ */
534
+ map<U>(callbackfn: (elt: any, index: number, array: any) => U, thisArg?: any): U[];
535
+ /**
536
+ * See :js:meth:`Array.filter`. Creates a shallow copy of a portion of a given
537
+ * ``Sequence``, filtered down to just the elements from the given array that pass
538
+ * the test implemented by the provided function.
539
+ * @param predicate A function to execute for each element in the array. It
540
+ * should return a truthy value to keep the element in the resulting array,
541
+ * and a falsy value otherwise.
542
+ * @param thisArg A value to use as ``this`` when executing ``predicate``.
543
+ */
544
+ filter(predicate: (elt: any, index: number, array: any) => boolean, thisArg?: any): any[];
545
+ /**
546
+ * See :js:meth:`Array.some`. Tests whether at least one element in the
547
+ * ``Sequence`` passes the test implemented by the provided function.
548
+ * @param predicate A function to execute for each element in the
549
+ * ``Sequence``. It should return a truthy value to indicate the element
550
+ * passes the test, and a falsy value otherwise.
551
+ * @param thisArg A value to use as ``this`` when executing ``predicate``.
552
+ */
553
+ some(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
554
+ /**
555
+ * See :js:meth:`Array.every`. Tests whether every element in the ``Sequence``
556
+ * passes the test implemented by the provided function.
557
+ * @param predicate A function to execute for each element in the
558
+ * ``Sequence``. It should return a truthy value to indicate the element
559
+ * passes the test, and a falsy value otherwise.
560
+ * @param thisArg A value to use as ``this`` when executing ``predicate``.
561
+ */
562
+ every(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
563
+ /**
564
+ * See :js:meth:`Array.reduce`. Executes a user-supplied "reducer" callback
565
+ * function on each element of the Sequence, in order, passing in the return
566
+ * value from the calculation on the preceding element. The final result of
567
+ * running the reducer across all elements of the Sequence is a single value.
568
+ * @param callbackfn A function to execute for each element in the ``Sequence``. Its
569
+ * return value is discarded.
570
+ */
571
+ reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any) => any, initialValue?: any): any;
572
+ /**
573
+ * See :js:meth:`Array.reduceRight`. Applies a function against an accumulator
574
+ * and each value of the Sequence (from right to left) to reduce it to a
575
+ * single value.
576
+ * @param callbackfn A function to execute for each element in the Sequence.
577
+ * Its return value is discarded.
578
+ */
579
+ reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any) => any, initialValue: any): any;
580
+ /**
581
+ * See :js:meth:`Array.at`. Takes an integer value and returns the item at
582
+ * that index.
583
+ * @param index Zero-based index of the Sequence element to be returned,
584
+ * converted to an integer. Negative index counts back from the end of the
585
+ * Sequence.
586
+ * @returns The element in the Sequence matching the given index.
587
+ */
588
+ at(index: number): any;
589
+ /**
590
+ * The :js:meth:`Array.concat` method is used to merge two or more arrays.
591
+ * This method does not change the existing arrays, but instead returns a new
592
+ * array.
593
+ * @param rest Arrays and/or values to concatenate into a new array.
594
+ * @returns A new Array instance.
595
+ */
596
+ concat(...rest: ConcatArray<any>[]): any[];
597
+ /**
598
+ * The :js:meth:`Array.includes` method determines whether a Sequence
599
+ * includes a certain value among its entries, returning true or false as
600
+ * appropriate.
601
+ * @param elt
602
+ * @returns
603
+ */
604
+ includes(elt: any): any;
605
+ /**
606
+ * The :js:meth:`Array.entries` method returns a new iterator object that
607
+ * contains the key/value pairs for each index in the ``Sequence``.
608
+ * @returns A new iterator object.
609
+ */
610
+ entries(): IterableIterator<[
611
+ number,
612
+ any
613
+ ]>;
614
+ /**
615
+ * The :js:meth:`Array.keys` method returns a new iterator object that
616
+ * contains the keys for each index in the ``Sequence``.
617
+ * @returns A new iterator object.
618
+ */
619
+ keys(): IterableIterator<number>;
620
+ /**
621
+ * The :js:meth:`Array.values` method returns a new iterator object that
622
+ * contains the values for each index in the ``Sequence``.
623
+ * @returns A new iterator object.
624
+ */
625
+ values(): IterableIterator<any>;
626
+ /**
627
+ * The :js:meth:`Array.find` method returns the first element in the provided
628
+ * array that satisfies the provided testing function.
629
+ * @param predicate A function to execute for each element in the
630
+ * ``Sequence``. It should return a truthy value to indicate a matching
631
+ * element has been found, and a falsy value otherwise.
632
+ * @param thisArg A value to use as ``this`` when executing ``predicate``.
633
+ * @returns The first element in the ``Sequence`` that satisfies the provided
634
+ * testing function.
635
+ */
636
+ find(predicate: (value: any, index: number, obj: any[]) => any, thisArg?: any): any;
637
+ /**
638
+ * The :js:meth:`Array.findIndex` method returns the index of the first
639
+ * element in the provided array that satisfies the provided testing function.
640
+ * @param predicate A function to execute for each element in the
641
+ * ``Sequence``. It should return a truthy value to indicate a matching
642
+ * element has been found, and a falsy value otherwise.
643
+ * @param thisArg A value to use as ``this`` when executing ``predicate``.
644
+ * @returns The index of the first element in the ``Sequence`` that satisfies
645
+ * the provided testing function.
646
+ */
647
+ findIndex(predicate: (value: any, index: number, obj: any[]) => any, thisArg?: any): number;
648
+ toJSON(this: any): unknown[];
649
+ /**
650
+ * Returns the object treated as a json adaptor.
651
+ *
652
+ * With a JsonAdaptor:
653
+ * 1. property access / modification / deletion is implemented with
654
+ * :meth:`~object.__getitem__`, :meth:`~object.__setitem__`, and
655
+ * :meth:`~object.__delitem__` respectively.
656
+ * 2. If an attribute is accessed and the result implements
657
+ * :meth:`~object.__getitem__` then the result will also be a json
658
+ * adaptor.
659
+ *
660
+ * For instance, ``JSON.stringify(proxy.asJsJson())`` acts like an
661
+ * inverse to Python's :py:func:`json.loads`.
662
+ */
663
+ asJsJson(): PyProxy & {};
664
+ }
665
+ declare class PyMutableSequence extends PyProxy {
666
+ /** @private */
667
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
668
+ }
669
+ /** @deprecated Use `import type { PyMutableSequence } from "pyodide/ffi"` instead */
670
+ interface PyMutableSequence extends PyMutableSequenceMethods {
671
+ }
672
+ declare class PyMutableSequenceMethods {
673
+ /**
674
+ * The :js:meth:`Array.reverse` method reverses a :js:class:`PyMutableSequence` in
675
+ * place.
676
+ * @returns A reference to the same :js:class:`PyMutableSequence`
677
+ */
678
+ reverse(): PyMutableSequence;
679
+ /**
680
+ * The :js:meth:`Array.sort` method sorts the elements of a
681
+ * :js:class:`PyMutableSequence` in place.
682
+ * @param compareFn A function that defines the sort order.
683
+ * @returns A reference to the same :js:class:`PyMutableSequence`
684
+ */
685
+ sort(compareFn?: (a: any, b: any) => number): PyMutableSequence;
686
+ /**
687
+ * The :js:meth:`Array.splice` method changes the contents of a
688
+ * :js:class:`PyMutableSequence` by removing or replacing existing elements and/or
689
+ * adding new elements in place.
690
+ * @param start Zero-based index at which to start changing the
691
+ * :js:class:`PyMutableSequence`.
692
+ * @param deleteCount An integer indicating the number of elements in the
693
+ * :js:class:`PyMutableSequence` to remove from ``start``.
694
+ * @param items The elements to add to the :js:class:`PyMutableSequence`, beginning from
695
+ * ``start``.
696
+ * @returns An array containing the deleted elements.
697
+ */
698
+ splice(start: number, deleteCount?: number, ...items: any[]): any[];
699
+ /**
700
+ * The :js:meth:`Array.push` method adds the specified elements to the end of
701
+ * a :js:class:`PyMutableSequence`.
702
+ * @param elts The element(s) to add to the end of the :js:class:`PyMutableSequence`.
703
+ * @returns The new length property of the object upon which the method was
704
+ * called.
705
+ */
706
+ push(...elts: any[]): any;
707
+ /**
708
+ * The :js:meth:`Array.pop` method removes the last element from a
709
+ * :js:class:`PyMutableSequence`.
710
+ * @returns The removed element from the :js:class:`PyMutableSequence`; undefined if the
711
+ * :js:class:`PyMutableSequence` is empty.
712
+ */
713
+ pop(): any;
714
+ /**
715
+ * The :js:meth:`Array.shift` method removes the first element from a
716
+ * :js:class:`PyMutableSequence`.
717
+ * @returns The removed element from the :js:class:`PyMutableSequence`; undefined if the
718
+ * :js:class:`PyMutableSequence` is empty.
719
+ */
720
+ shift(): any;
721
+ /**
722
+ * The :js:meth:`Array.unshift` method adds the specified elements to the
723
+ * beginning of a :js:class:`PyMutableSequence`.
724
+ * @param elts The elements to add to the front of the :js:class:`PyMutableSequence`.
725
+ * @returns The new length of the :js:class:`PyMutableSequence`.
726
+ */
727
+ unshift(...elts: any[]): any;
728
+ /**
729
+ * The :js:meth:`Array.copyWithin` method shallow copies part of a
730
+ * :js:class:`PyMutableSequence` to another location in the same :js:class:`PyMutableSequence`
731
+ * without modifying its length.
732
+ * @param target Zero-based index at which to copy the sequence to.
733
+ * @param start Zero-based index at which to start copying elements from.
734
+ * @param end Zero-based index at which to end copying elements from.
735
+ * @returns The modified :js:class:`PyMutableSequence`.
736
+ */
737
+ copyWithin(target: number, start?: number, end?: number): any;
738
+ /**
739
+ * The :js:meth:`Array.fill` method changes all elements in an array to a
740
+ * static value, from a start index to an end index.
741
+ * @param value Value to fill the array with.
742
+ * @param start Zero-based index at which to start filling. Default 0.
743
+ * @param end Zero-based index at which to end filling. Default
744
+ * ``list.length``.
745
+ * @returns
746
+ */
747
+ fill(value: any, start?: number, end?: number): any;
748
+ }
749
+ declare class PyAwaitable extends PyProxy {
750
+ /** @private */
751
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
752
+ }
753
+ /** @deprecated Use `import type { PyAwaitable } from "pyodide/ffi"` instead */
754
+ interface PyAwaitable extends Promise<any> {
755
+ }
756
+ declare class PyCallable extends PyProxy {
757
+ /** @private */
758
+ static [Symbol.hasInstance](obj: any): obj is PyCallable;
759
+ }
760
+ /** @deprecated Use `import type { PyCallable } from "pyodide/ffi"` instead */
761
+ interface PyCallable extends PyCallableMethods {
762
+ (...args: any[]): any;
763
+ }
764
+ declare class PyCallableMethods {
765
+ /**
766
+ * The ``apply()`` method calls the specified function with a given this
767
+ * value, and arguments provided as an array (or an array-like object). Like
768
+ * :js:meth:`Function.apply`.
769
+ *
770
+ * @param thisArg The ``this`` argument. Has no effect unless the
771
+ * :js:class:`~pyodide.ffi.PyCallable` has :js:meth:`captureThis` set. If
772
+ * :js:meth:`captureThis` is set, it will be passed as the first argument to
773
+ * the Python function.
774
+ * @param jsargs The array of arguments
775
+ * @returns The result from the function call.
776
+ */
777
+ apply(thisArg: any, jsargs: any): any;
778
+ /**
779
+ * Calls the function with a given this value and arguments provided
780
+ * individually. See :js:meth:`Function.call`.
781
+ *
782
+ * @param thisArg The ``this`` argument. Has no effect unless the
783
+ * :js:class:`~pyodide.ffi.PyCallable` has :js:meth:`captureThis` set. If
784
+ * :js:meth:`captureThis` is set, it will be passed as the first argument to
785
+ * the Python function.
786
+ * @param jsargs The arguments
787
+ * @returns The result from the function call.
788
+ */
789
+ call(thisArg: any, ...jsargs: any): any;
790
+ /**
791
+ * Call the Python function. The first parameter controls various parameters
792
+ * that change the way the call is performed.
793
+ *
794
+ * @param options
795
+ * @param options.kwargs If true, the last argument is treated as a collection
796
+ * of keyword arguments.
797
+ * @param options.promising If true, the call is made with stack switching
798
+ * enabled. Not needed if the callee is an async
799
+ * Python function.
800
+ * @param options.relaxed If true, extra arguments are ignored instead of
801
+ * raising a :py:exc:`TypeError`.
802
+ * @param jsargs Arguments to the Python function.
803
+ * @returns
804
+ */
805
+ callWithOptions({ relaxed, kwargs, promising, }: {
806
+ relaxed?: boolean;
807
+ kwargs?: boolean;
808
+ promising?: boolean;
809
+ }, ...jsargs: any): any;
810
+ /**
811
+ * Call the function with keyword arguments. The last argument must be an
812
+ * object with the keyword arguments.
813
+ */
814
+ callKwargs(...jsargs: any): any;
815
+ /**
816
+ * Call the function in a "relaxed" manner. Any extra arguments will be
817
+ * ignored. This matches the behavior of JavaScript functions more accurately.
818
+ *
819
+ * Any extra arguments will be ignored. This matches the behavior of
820
+ * JavaScript functions more accurately. Missing arguments are **NOT** filled
821
+ * with `None`. If too few arguments are passed, this will still raise a
822
+ * TypeError.
823
+ *
824
+ * This uses :py:func:`pyodide.code.relaxed_call`.
825
+ */
826
+ callRelaxed(...jsargs: any): any;
827
+ /**
828
+ * Call the function with keyword arguments in a "relaxed" manner. The last
829
+ * argument must be an object with the keyword arguments. Any extra arguments
830
+ * will be ignored. This matches the behavior of JavaScript functions more
831
+ * accurately.
832
+ *
833
+ * Missing arguments are **NOT** filled with ``None``. If too few arguments are
834
+ * passed, this will still raise a :py:exc:`TypeError`. Also, if the same argument is
835
+ * passed as both a keyword argument and a positional argument, it will raise
836
+ * an error.
837
+ *
838
+ * This uses :py:func:`pyodide.code.relaxed_call`.
839
+ */
840
+ callKwargsRelaxed(...jsargs: any): any;
841
+ /**
842
+ * Call the function with stack switching enabled. The last argument must be
843
+ * an object with the keyword arguments. Functions called this way can use
844
+ * :py:meth:`~pyodide.ffi.run_sync` to block until an
845
+ * :py:class:`~collections.abc.Awaitable` is resolved. Only works in runtimes
846
+ * with JS Promise integration.
847
+ *
848
+ * .. admonition:: Experimental
849
+ * :class: warning
850
+ *
851
+ * This feature is not yet stable.
852
+ *
853
+ * @experimental
854
+ */
855
+ callPromising(...jsargs: any): Promise<any>;
856
+ /**
857
+ * Call the function with stack switching enabled. The last argument must be
858
+ * an object with the keyword arguments. Functions called this way can use
859
+ * :py:meth:`~pyodide.ffi.run_sync` to block until an
860
+ * :py:class:`~collections.abc.Awaitable` is resolved. Only works in runtimes
861
+ * with JS Promise integration.
862
+ *
863
+ * .. admonition:: Experimental
864
+ * :class: warning
865
+ *
866
+ * This feature is not yet stable.
867
+ *
868
+ * @experimental
869
+ */
870
+ callPromisingKwargs(...jsargs: any): Promise<any>;
871
+ /**
872
+ * The ``bind()`` method creates a new function that, when called, has its
873
+ * ``this`` keyword set to the provided value, with a given sequence of
874
+ * arguments preceding any provided when the new function is called. See
875
+ * :js:meth:`Function.bind`.
876
+ *
877
+ * If the :js:class:`~pyodide.ffi.PyCallable` does not have
878
+ * :js:meth:`captureThis` set, the ``this`` parameter will be discarded. If it
879
+ * does have :js:meth:`captureThis` set, ``thisArg`` will be set to the first
880
+ * argument of the Python function. The returned proxy and the original proxy
881
+ * have the same lifetime so destroying either destroys both.
882
+ *
883
+ * @param thisArg The value to be passed as the ``this`` parameter to the
884
+ * target function ``func`` when the bound function is called.
885
+ * @param jsargs Extra arguments to prepend to arguments provided to the bound
886
+ * function when invoking ``func``.
887
+ * @returns
888
+ */
889
+ bind(thisArg: any, ...jsargs: any): PyProxy;
890
+ /**
891
+ * Returns a :js:class:`~pyodide.ffi.PyProxy` that passes ``this`` as the first argument to the
892
+ * Python function. The returned :js:class:`~pyodide.ffi.PyProxy` has the internal ``captureThis``
893
+ * property set.
894
+ *
895
+ * It can then be used as a method on a JavaScript object. The returned proxy
896
+ * and the original proxy have the same lifetime so destroying either destroys
897
+ * both.
898
+ *
899
+ * For example:
900
+ *
901
+ * .. code-block:: pyodide
902
+ *
903
+ * let obj = { a : 7 };
904
+ * pyodide.runPython(`
905
+ * def f(self):
906
+ * return self.a
907
+ * `);
908
+ * // Without captureThis, it doesn't work to use f as a method for obj:
909
+ * obj.f = pyodide.globals.get("f");
910
+ * obj.f(); // raises "TypeError: f() missing 1 required positional argument: 'self'"
911
+ * // With captureThis, it works fine:
912
+ * obj.f = pyodide.globals.get("f").captureThis();
913
+ * obj.f(); // returns 7
914
+ *
915
+ * @returns The resulting :js:class:`~pyodide.ffi.PyProxy`. It has the same lifetime as the
916
+ * original :js:class:`~pyodide.ffi.PyProxy` but passes ``this`` to the wrapped function.
917
+ *
918
+ */
919
+ captureThis(): PyProxy;
920
+ }
921
+ declare class PyBuffer extends PyProxy {
922
+ /** @private */
923
+ static [Symbol.hasInstance](obj: any): obj is PyBuffer;
924
+ }
925
+ /** @deprecated Use `import type { PyBuffer } from "pyodide/ffi"` instead */
926
+ interface PyBuffer extends PyBufferMethods {
927
+ }
928
+ declare class PyBufferMethods {
929
+ /**
930
+ * Get a view of the buffer data which is usable from JavaScript. No copy is
931
+ * ever performed.
932
+ *
933
+ * We do not support suboffsets, if the buffer requires suboffsets we will
934
+ * throw an error. JavaScript nd array libraries can't handle suboffsets
935
+ * anyways. In this case, you should use the :js:meth:`~PyProxy.toJs` api or
936
+ * copy the buffer to one that doesn't use suboffsets (using e.g.,
937
+ * :py:func:`numpy.ascontiguousarray`).
938
+ *
939
+ * If the buffer stores big endian data or half floats, this function will
940
+ * fail without an explicit type argument. For big endian data you can use
941
+ * :js:meth:`~PyProxy.toJs`. :js:class:`DataView` has support for big endian
942
+ * data, so you might want to pass ``'dataview'`` as the type argument in that
943
+ * case.
944
+ *
945
+ * @param type The type of the :js:attr:`~pyodide.ffi.PyBufferView.data` field
946
+ * in the output. Should be one of: ``"i8"``, ``"u8"``, ``"u8clamped"``,
947
+ * ``"i16"``, ``"u16"``, ``"i32"``, ``"u32"``, ``"i32"``, ``"u32"``,
948
+ * ``"i64"``, ``"u64"``, ``"f32"``, ``"f64"``, or ``"dataview"``. This argument
949
+ * is optional, if absent :js:meth:`~pyodide.ffi.PyBuffer.getBuffer` will try
950
+ * to determine the appropriate output type based on the buffer format string
951
+ * (see :std:ref:`struct-format-strings`).
952
+ */
953
+ getBuffer(type?: string): PyBufferView;
954
+ }
955
+ declare class PyDict extends PyProxy {
956
+ /** @private */
957
+ static [Symbol.hasInstance](obj: any): obj is PyProxy;
958
+ }
959
+ /** @deprecated Use `import type { PyDict } from "pyodide/ffi"` instead */
960
+ interface PyDict extends PyProxyWithGet, PyProxyWithSet, PyProxyWithHas, PyProxyWithLength, PyIterable {
961
+ }
962
+ /** @deprecated Use `import type { PyBufferView } from "pyodide/ffi"` instead */
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
+ declare class PythonError extends Error {
1059
+ /**
1060
+ * The address of the error we are wrapping. We may later compare this
1061
+ * against sys.last_exc.
1062
+ * WARNING: we don't own a reference to this pointer, dereferencing it
1063
+ * may be a use-after-free error!
1064
+ * @private
1065
+ */
1066
+ __error_address: number;
1067
+ /**
1068
+ * The name of the Python error class, e.g, :py:exc:`RuntimeError` or
1069
+ * :py:exc:`KeyError`.
1070
+ */
1071
+ type: string;
1072
+ constructor(type: string, message: string, error_address: number);
1073
+ }
1074
+ type NativeFS = {
1075
+ syncfs: () => Promise<void>;
1076
+ };
1077
+ declare class PyodideAPI {
1078
+ /** @hidden */
1079
+ static version: string;
1080
+ /** @hidden */
1081
+ static loadPackage: (names: string | PyProxy | Array<string>, options?: {
1082
+ messageCallback?: (message: string) => void;
1083
+ errorCallback?: (message: string) => void;
1084
+ checkIntegrity?: boolean;
1085
+ }) => Promise<Array<PackageData>>;
1086
+ /** @hidden */
1087
+ static loadedPackages: LoadedPackages;
1088
+ /** @hidden */
1089
+ static ffi: {
1090
+ PyProxy: typeof PyProxy;
1091
+ PyProxyWithLength: typeof PyProxyWithLength;
1092
+ PyProxyWithGet: typeof PyProxyWithGet;
1093
+ PyProxyWithSet: typeof PyProxyWithSet;
1094
+ PyProxyWithHas: typeof PyProxyWithHas;
1095
+ PyDict: typeof PyDict;
1096
+ PyIterable: typeof PyIterable;
1097
+ PyAsyncIterable: typeof PyAsyncIterable;
1098
+ PyIterator: typeof PyIterator;
1099
+ PyAsyncIterator: typeof PyAsyncIterator;
1100
+ PyGenerator: typeof PyGenerator;
1101
+ PyAsyncGenerator: typeof PyAsyncGenerator;
1102
+ PyAwaitable: typeof PyAwaitable;
1103
+ PyCallable: typeof PyCallable;
1104
+ PyBuffer: typeof PyBuffer;
1105
+ PyBufferView: typeof PyBufferView;
1106
+ PythonError: typeof PythonError;
1107
+ PySequence: typeof PySequence;
1108
+ PyMutableSequence: typeof PyMutableSequence;
1109
+ };
1110
+ /** @hidden */
1111
+ static setStdin: typeof setStdin;
1112
+ /** @hidden */
1113
+ static setStdout: typeof setStdout;
1114
+ /** @hidden */
1115
+ static setStderr: typeof setStderr;
1116
+ /**
1117
+ *
1118
+ * An alias to the global Python namespace.
1119
+ *
1120
+ * For example, to access a variable called ``foo`` in the Python global
1121
+ * scope, use ``pyodide.globals.get("foo")``
1122
+ */
1123
+ static globals: PyProxy;
1124
+ /**
1125
+ * An alias to the `Emscripten File System API
1126
+ * <https://emscripten.org/docs/api_reference/Filesystem-API.html>`_.
1127
+ *
1128
+ * This provides a wide range of POSIX-`like` file/device operations, including
1129
+ * `mount
1130
+ * <https://emscripten.org/docs/api_reference/Filesystem-API.html#FS.mount>`_
1131
+ * which can be used to extend the in-memory filesystem with features like `persistence
1132
+ * <https://emscripten.org/docs/api_reference/Filesystem-API.html#persistent-data>`_.
1133
+ *
1134
+ * While all the file systems implementations are enabled, only the default
1135
+ * ``MEMFS`` is guaranteed to work in all runtime settings. The implementations
1136
+ * are available as members of ``FS.filesystems``:
1137
+ * ``IDBFS``, ``NODEFS``, ``PROXYFS``, ``WORKERFS``.
1138
+ */
1139
+ static FS: FSType;
1140
+ /**
1141
+ * An alias to the `Emscripten Path API
1142
+ * <https://github.com/emscripten-core/emscripten/blob/main/src/library_path.js>`_.
1143
+ *
1144
+ * This provides a variety of operations for working with file system paths, such as
1145
+ * ``dirname``, ``normalize``, and ``splitPath``.
1146
+ */
1147
+ static PATH: any;
1148
+ /**
1149
+ * APIs to set a canvas for rendering graphics.
1150
+ * @summaryLink :ref:`canvas <js-api-pyodide-canvas>`
1151
+ * @omitFromAutoModule
1152
+ */
1153
+ static canvas: CanvasInterface;
1154
+ /**
1155
+ * A map from posix error names to error codes.
1156
+ */
1157
+ static ERRNO_CODES: {
1158
+ [code: string]: number;
1159
+ };
1160
+ /**
1161
+ * An alias to the Python :ref:`pyodide <python-api>` package.
1162
+ *
1163
+ * You can use this to call functions defined in the Pyodide Python package
1164
+ * from JavaScript.
1165
+ */
1166
+ static pyodide_py: PyProxy;
1167
+ /**
1168
+ * Inspect a Python code chunk and use :js:func:`pyodide.loadPackage` to install
1169
+ * any known packages that the code chunk imports. Uses the Python API
1170
+ * :func:`pyodide.code.find\_imports` to inspect the code.
1171
+ *
1172
+ * For example, given the following code as input
1173
+ *
1174
+ * .. code-block:: python
1175
+ *
1176
+ * import numpy as np
1177
+ * x = np.array([1, 2, 3])
1178
+ *
1179
+ * :js:func:`loadPackagesFromImports` will call
1180
+ * ``pyodide.loadPackage(['numpy'])``.
1181
+ *
1182
+ * @param code The code to inspect.
1183
+ * @param options Options passed to :js:func:`pyodide.loadPackage`.
1184
+ * @param options.messageCallback A callback, called with progress messages
1185
+ * (optional)
1186
+ * @param options.errorCallback A callback, called with error/warning messages
1187
+ * (optional)
1188
+ * @param options.checkIntegrity If true, check the integrity of the downloaded
1189
+ * packages (default: true)
1190
+ */
1191
+ static loadPackagesFromImports(code: string, options?: {
1192
+ messageCallback?: (message: string) => void;
1193
+ errorCallback?: (message: string) => void;
1194
+ checkIntegrity?: boolean;
1195
+ }): Promise<Array<PackageData>>;
1196
+ /**
1197
+ * Runs a string of Python code from JavaScript, using :py:func:`~pyodide.code.eval_code`
1198
+ * to evaluate the code. If the last statement in the Python code is an
1199
+ * expression (and the code doesn't end with a semicolon), the value of the
1200
+ * expression is returned.
1201
+ *
1202
+ * @param code The Python code to run
1203
+ * @param options
1204
+ * @param options.globals An optional Python dictionary to use as the globals.
1205
+ * Defaults to :js:attr:`pyodide.globals`.
1206
+ * @param options.locals An optional Python dictionary to use as the locals.
1207
+ * Defaults to the same as ``globals``.
1208
+ * @param options.filename An optional string to use as the file name.
1209
+ * Defaults to ``"<exec>"``. If a custom file name is given, the
1210
+ * traceback for any exception that is thrown will show source lines
1211
+ * (unless the given file name starts with ``<`` and ends with ``>``).
1212
+ * @returns The result of the Python code translated to JavaScript. See the
1213
+ * documentation for :py:func:`~pyodide.code.eval_code` for more info.
1214
+ * @example
1215
+ * async function main(){
1216
+ * const pyodide = await loadPyodide();
1217
+ * console.log(pyodide.runPython("1 + 2"));
1218
+ * // 3
1219
+ *
1220
+ * const globals = pyodide.toPy({ x: 3 });
1221
+ * console.log(pyodide.runPython("x + 1", { globals }));
1222
+ * // 4
1223
+ *
1224
+ * const locals = pyodide.toPy({ arr: [1, 2, 3] });
1225
+ * console.log(pyodide.runPython("sum(arr)", { locals }));
1226
+ * // 6
1227
+ * }
1228
+ * main();
1229
+ */
1230
+ static runPython(code: string, options?: {
1231
+ globals?: PyProxy;
1232
+ locals?: PyProxy;
1233
+ filename?: string;
1234
+ }): any;
1235
+ /**
1236
+ * Run a Python code string with top level await using
1237
+ * :py:func:`~pyodide.code.eval_code_async` to evaluate the code. Returns a promise which
1238
+ * resolves when execution completes. If the last statement in the Python code
1239
+ * is an expression (and the code doesn't end with a semicolon), the returned
1240
+ * promise will resolve to the value of this expression.
1241
+ *
1242
+ * For example:
1243
+ *
1244
+ * .. code-block:: pyodide
1245
+ *
1246
+ * let result = await pyodide.runPythonAsync(`
1247
+ * from js import fetch
1248
+ * response = await fetch("./pyodide-lock.json")
1249
+ * packages = await response.json()
1250
+ * # If final statement is an expression, its value is returned to JavaScript
1251
+ * len(packages.packages.object_keys())
1252
+ * `);
1253
+ * console.log(result); // 79
1254
+ *
1255
+ * .. admonition:: Python imports
1256
+ * :class: warning
1257
+ *
1258
+ * Since pyodide 0.18.0, you must call :js:func:`loadPackagesFromImports` to
1259
+ * import any python packages referenced via ``import`` statements in your
1260
+ * code. This function will no longer do it for you.
1261
+ *
1262
+ * @param code The Python code to run
1263
+ * @param options
1264
+ * @param options.globals An optional Python dictionary to use as the globals.
1265
+ * Defaults to :js:attr:`pyodide.globals`.
1266
+ * @param options.locals An optional Python dictionary to use as the locals.
1267
+ * Defaults to the same as ``globals``.
1268
+ * @param options.filename An optional string to use as the file name.
1269
+ * Defaults to ``"<exec>"``. If a custom file name is given, the
1270
+ * traceback for any exception that is thrown will show source lines
1271
+ * (unless the given file name starts with ``<`` and ends with ``>``).
1272
+ * @returns The result of the Python code translated to JavaScript.
1273
+ */
1274
+ static runPythonAsync(code: string, options?: {
1275
+ globals?: PyProxy;
1276
+ locals?: PyProxy;
1277
+ filename?: string;
1278
+ }): Promise<any>;
1279
+ /**
1280
+ * Registers the JavaScript object ``module`` as a JavaScript module named
1281
+ * ``name``. This module can then be imported from Python using the standard
1282
+ * Python import system. If another module by the same name has already been
1283
+ * imported, this won't have much effect unless you also delete the imported
1284
+ * module from :py:data:`sys.modules`. This calls
1285
+ * :func:`~pyodide.ffi.register_js_module`.
1286
+ *
1287
+ * Any attributes of the JavaScript objects which are themselves objects will
1288
+ * be treated as submodules:
1289
+ * ```pyodide
1290
+ * pyodide.registerJsModule("mymodule", { submodule: { value: 7 } });
1291
+ * pyodide.runPython(`
1292
+ * from mymodule.submodule import value
1293
+ * assert value == 7
1294
+ * `);
1295
+ * ```
1296
+ * If you wish to prevent this, try the following instead:
1297
+ * ```pyodide
1298
+ * const sys = pyodide.pyimport("sys");
1299
+ * sys.modules.set("mymodule", { obj: { value: 7 } });
1300
+ * pyodide.runPython(`
1301
+ * from mymodule import obj
1302
+ * assert obj.value == 7
1303
+ * # attempting to treat obj as a submodule raises ModuleNotFoundError:
1304
+ * # "No module named 'mymodule.obj'; 'mymodule' is not a package"
1305
+ * from mymodule.obj import value
1306
+ * `);
1307
+ * ```
1308
+ *
1309
+ * @param name Name of the JavaScript module to add
1310
+ * @param module JavaScript object backing the module
1311
+ */
1312
+ static registerJsModule(name: string, module: object): void;
1313
+ /**
1314
+ * Unregisters a JavaScript module with given name that has been previously
1315
+ * registered with :js:func:`pyodide.registerJsModule` or
1316
+ * :func:`~pyodide.ffi.register_js_module`. If a JavaScript module with that
1317
+ * name does not already exist, will throw an error. Note that if the module has
1318
+ * already been imported, this won't have much effect unless you also delete the
1319
+ * imported module from :py:data:`sys.modules`. This calls
1320
+ * :func:`~pyodide.ffi.unregister_js_module`.
1321
+ *
1322
+ * @param name Name of the JavaScript module to remove
1323
+ */
1324
+ static unregisterJsModule(name: string): void;
1325
+ /**
1326
+ * Convert a JavaScript object to a Python object as best as possible.
1327
+ *
1328
+ * This is similar to :py:meth:`~pyodide.ffi.JsProxy.to_py` but for use from
1329
+ * JavaScript. If the object is immutable or a :js:class:`~pyodide.ffi.PyProxy`,
1330
+ * it will be returned unchanged. If the object cannot be converted into Python,
1331
+ * it will be returned unchanged.
1332
+ *
1333
+ * See :ref:`type-translations-jsproxy-to-py` for more information.
1334
+ *
1335
+ * @param obj The object to convert.
1336
+ * @param options
1337
+ * @returns The object converted to Python.
1338
+ */
1339
+ static toPy(obj: any, { depth, defaultConverter, }?: {
1340
+ /**
1341
+ * Optional argument to limit the depth of the conversion.
1342
+ */
1343
+ depth: number;
1344
+ /**
1345
+ * Optional argument to convert objects with no default conversion. See the
1346
+ * documentation of :py:meth:`~pyodide.ffi.JsProxy.to_py`.
1347
+ */
1348
+ defaultConverter?: (value: any, converter: (value: any) => any, cacheConversion: (input: any, output: any) => void) => any;
1349
+ }): any;
1350
+ /**
1351
+ * Imports a module and returns it.
1352
+ *
1353
+ * If `name` has no dot in it, then `pyimport(name)` is approximately
1354
+ * equivalent to:
1355
+ * ```js
1356
+ * pyodide.runPython(`import ${name}; ${name}`)
1357
+ * ```
1358
+ * except that `name` is not introduced into the Python global namespace. If
1359
+ * the name has one or more dots in it, say it is of the form `path.name`
1360
+ * where `name` has no dots but path may have zero or more dots. Then it is
1361
+ * approximately the same as:
1362
+ * ```js
1363
+ * pyodide.runPython(`from ${path} import ${name}; ${name}`);
1364
+ * ```
1365
+ *
1366
+ * @param mod_name The name of the module to import
1367
+ *
1368
+ * @example
1369
+ * pyodide.pyimport("math.comb")(4, 2) // returns 4 choose 2 = 6
1370
+ */
1371
+ static pyimport(mod_name: string): any;
1372
+ /**
1373
+ * Unpack an archive into a target directory.
1374
+ *
1375
+ * @param buffer The archive as an :js:class:`ArrayBuffer` or :js:class:`TypedArray`.
1376
+ * @param format The format of the archive. Should be one of the formats
1377
+ * recognized by :py:func:`shutil.unpack_archive`. By default the options are
1378
+ * ``'bztar'``, ``'gztar'``, ``'tar'``, ``'zip'``, and ``'wheel'``. Several
1379
+ * synonyms are accepted for each format, e.g., for ``'gztar'`` any of
1380
+ * ``'.gztar'``, ``'.tar.gz'``, ``'.tgz'``, ``'tar.gz'`` or ``'tgz'`` are
1381
+ * considered to be
1382
+ * synonyms.
1383
+ *
1384
+ * @param options
1385
+ * @param options.extractDir The directory to unpack the archive into. Defaults
1386
+ * to the working directory.
1387
+ */
1388
+ static unpackArchive(buffer: TypedArray | ArrayBuffer, format: string, options?: {
1389
+ extractDir?: string;
1390
+ }): void;
1391
+ /**
1392
+ * Mounts a :js:class:`FileSystemDirectoryHandle` into the target directory.
1393
+ * Currently it's only possible to acquire a
1394
+ * :js:class:`FileSystemDirectoryHandle` in Chrome.
1395
+ *
1396
+ * @param path The absolute path in the Emscripten file system to mount the
1397
+ * native directory. If the directory does not exist, it will be created. If
1398
+ * it does exist, it must be empty.
1399
+ * @param fileSystemHandle A handle returned by
1400
+ * :js:func:`navigator.storage.getDirectory() <getDirectory>` or
1401
+ * :js:func:`window.showDirectoryPicker() <showDirectoryPicker>`.
1402
+ */
1403
+ static mountNativeFS(path: string, fileSystemHandle: FileSystemDirectoryHandle): Promise<NativeFS>;
1404
+ /**
1405
+ * Mounts a host directory into Pyodide file system. Only works in node.
1406
+ *
1407
+ * @param emscriptenPath The absolute path in the Emscripten file system to
1408
+ * mount the native directory. If the directory does not exist, it will be
1409
+ * created. If it does exist, it must be empty.
1410
+ * @param hostPath The host path to mount. It must be a directory that exists.
1411
+ */
1412
+ static mountNodeFS(emscriptenPath: string, hostPath: string): void;
1413
+ /**
1414
+ * Tell Pyodide about Comlink.
1415
+ * Necessary to enable importing Comlink proxies into Python.
1416
+ */
1417
+ static registerComlink(Comlink: any): void;
1418
+ /**
1419
+ * Sets the interrupt buffer to be ``interrupt_buffer``. This is only useful
1420
+ * when Pyodide is used in a webworker. The buffer should be a
1421
+ * :js:class:`SharedArrayBuffer` shared with the main browser thread (or another
1422
+ * worker). In that case, signal ``signum`` may be sent by writing ``signum``
1423
+ * into the interrupt buffer. If ``signum`` does not satisfy 0 < ``signum`` < 65
1424
+ * it will be silently ignored.
1425
+ *
1426
+ * You can disable interrupts by calling ``setInterruptBuffer(undefined)``.
1427
+ *
1428
+ * If you wish to trigger a :py:exc:`KeyboardInterrupt`, write ``SIGINT`` (a 2)
1429
+ * into the interrupt buffer.
1430
+ *
1431
+ * By default ``SIGINT`` raises a :py:exc:`KeyboardInterrupt` and all other signals
1432
+ * are ignored. You can install custom signal handlers with the signal module.
1433
+ * Even signals that normally have special meaning and can't be overridden like
1434
+ * ``SIGKILL`` and ``SIGSEGV`` are ignored by default and can be used for any
1435
+ * purpose you like.
1436
+ */
1437
+ static setInterruptBuffer(interrupt_buffer: TypedArray): void;
1438
+ /**
1439
+ * Throws a :py:exc:`KeyboardInterrupt` error if a :py:exc:`KeyboardInterrupt` has
1440
+ * been requested via the interrupt buffer.
1441
+ *
1442
+ * This can be used to enable keyboard interrupts during execution of JavaScript
1443
+ * code, just as :c:func:`PyErr_CheckSignals` is used to enable keyboard interrupts
1444
+ * during execution of C code.
1445
+ */
1446
+ static checkInterrupt(): void;
1447
+ /**
1448
+ * Turn on or off debug mode. In debug mode, some error messages are improved
1449
+ * at a performance cost.
1450
+ * @param debug If true, turn debug mode on. If false, turn debug mode off.
1451
+ * @returns The old value of the debug flag.
1452
+ */
1453
+ static setDebug(debug: boolean): boolean;
1454
+ /**
1455
+ *
1456
+ * @param param0
1457
+ * @returns
1458
+ */
1459
+ static makeMemorySnapshot({ serializer, }?: {
1460
+ serializer?: (obj: any) => any;
1461
+ }): Uint8Array;
1462
+ }
1463
+ /** @hidden */
1464
+ export type PyodideInterface = typeof PyodideAPI;
1465
+ /**
1466
+ * See documentation for loadPyodide.
1467
+ * @hidden
1468
+ */
1469
+ type ConfigType = {
1470
+ indexURL: string;
1471
+ packageCacheDir: string;
1472
+ lockFileURL: string;
1473
+ fullStdLib?: boolean;
1474
+ stdLibURL?: string;
1475
+ stdin?: () => string;
1476
+ stdout?: (msg: string) => void;
1477
+ stderr?: (msg: string) => void;
1478
+ jsglobals?: object;
1479
+ _sysExecutable?: string;
1480
+ args: string[];
1481
+ fsInit?: (FS: FSType, info: {
1482
+ sitePackages: string;
1483
+ }) => Promise<void>;
1484
+ env: {
1485
+ [key: string]: string;
1486
+ };
1487
+ packages: string[];
1488
+ _makeSnapshot: boolean;
1489
+ enableRunUntilComplete: boolean;
1490
+ checkAPIVersion: boolean;
1491
+ BUILD_ID: string;
1492
+ };
1493
+ /**
1494
+ * Load the main Pyodide wasm module and initialize it.
1495
+ *
1496
+ * @returns The :ref:`js-api-pyodide` module.
1497
+ * @example
1498
+ * async function main() {
1499
+ * const pyodide = await loadPyodide({
1500
+ * fullStdLib: true,
1501
+ * stdout: (msg) => console.log(`Pyodide: ${msg}`),
1502
+ * });
1503
+ * console.log("Loaded Pyodide");
1504
+ * }
1505
+ * main();
1506
+ */
1507
+ export declare function loadPyodide(options?: {
1508
+ /**
1509
+ * The URL from which Pyodide will load the main Pyodide runtime and
1510
+ * packages. It is recommended that you leave this unchanged, providing an
1511
+ * incorrect value can cause broken behavior.
1512
+ *
1513
+ * Default: The url that Pyodide is loaded from with the file name
1514
+ * (``pyodide.js`` or ``pyodide.mjs``) removed.
1515
+ */
1516
+ indexURL?: string;
1517
+ /**
1518
+ * The file path where packages will be cached in node. If a package
1519
+ * exists in ``packageCacheDir`` it is loaded from there, otherwise it is
1520
+ * downloaded from the JsDelivr CDN and then cached into ``packageCacheDir``.
1521
+ * Only applies when running in node; ignored in browsers.
1522
+ *
1523
+ * Default: same as indexURL
1524
+ */
1525
+ packageCacheDir?: string;
1526
+ /**
1527
+ * The URL from which Pyodide will load the Pyodide ``pyodide-lock.json`` lock
1528
+ * file. You can produce custom lock files with :py:func:`micropip.freeze`.
1529
+ * Default: ```${indexURL}/pyodide-lock.json```
1530
+ */
1531
+ lockFileURL?: string;
1532
+ /**
1533
+ * Load the full Python standard library. Setting this to false excludes
1534
+ * unvendored modules from the standard library.
1535
+ * Default: ``false``
1536
+ */
1537
+ fullStdLib?: boolean;
1538
+ /**
1539
+ * The URL from which to load the standard library ``python_stdlib.zip``
1540
+ * file. This URL includes the most of the Python standard library. Some
1541
+ * stdlib modules were unvendored, and can be loaded separately
1542
+ * with ``fullStdLib: true`` option or by their package name.
1543
+ * Default: ```${indexURL}/python_stdlib.zip```
1544
+ */
1545
+ stdLibURL?: string;
1546
+ /**
1547
+ * Override the standard input callback. Should ask the user for one line of
1548
+ * input. The :js:func:`pyodide.setStdin` function is more flexible and
1549
+ * should be preferred.
1550
+ */
1551
+ stdin?: () => string;
1552
+ /**
1553
+ * Override the standard output callback. The :js:func:`pyodide.setStdout`
1554
+ * function is more flexible and should be preferred in most cases, but
1555
+ * depending on the ``args`` passed to ``loadPyodide``, Pyodide may write to
1556
+ * stdout on startup, which can only be controlled by passing a custom
1557
+ * ``stdout`` function.
1558
+ */
1559
+ stdout?: (msg: string) => void;
1560
+ /**
1561
+ * Override the standard error output callback. The
1562
+ * :js:func:`pyodide.setStderr` function is more flexible and should be
1563
+ * preferred in most cases, but depending on the ``args`` passed to
1564
+ * ``loadPyodide``, Pyodide may write to stdout on startup, which can only
1565
+ * be controlled by passing a custom ``stdout`` function.
1566
+ */
1567
+ stderr?: (msg: string) => void;
1568
+ /**
1569
+ * The object that Pyodide will use for the ``js`` module.
1570
+ * Default: ``globalThis``
1571
+ */
1572
+ jsglobals?: object;
1573
+ /**
1574
+ * Determine the value of ``sys.executable``.
1575
+ * @ignore
1576
+ */
1577
+ _sysExecutable?: string;
1578
+ /**
1579
+ * Command line arguments to pass to Python on startup. See `Python command
1580
+ * line interface options
1581
+ * <https://docs.python.org/3.10/using/cmdline.html#interface-options>`_ for
1582
+ * more details. Default: ``[]``
1583
+ */
1584
+ args?: string[];
1585
+ /**
1586
+ * Environment variables to pass to Python. This can be accessed inside of
1587
+ * Python at runtime via :py:data:`os.environ`. Certain environment variables change
1588
+ * the way that Python loads:
1589
+ * https://docs.python.org/3.10/using/cmdline.html#environment-variables
1590
+ * Default: ``{}``.
1591
+ * If ``env.HOME`` is undefined, it will be set to a default value of
1592
+ * ``"/home/pyodide"``
1593
+ */
1594
+ env?: {
1595
+ [key: string]: string;
1596
+ };
1597
+ /**
1598
+ * A list of packages to load as Pyodide is initializing.
1599
+ *
1600
+ * This is the same as loading the packages with
1601
+ * :js:func:`pyodide.loadPackage` after Pyodide is loaded except using the
1602
+ * ``packages`` option is more efficient because the packages are downloaded
1603
+ * while Pyodide bootstraps itself.
1604
+ */
1605
+ packages?: string[];
1606
+ /**
1607
+ * Opt into the old behavior where :js:func:`PyProxy.toString() <pyodide.ffi.PyProxy.toString>`
1608
+ * calls :py:func:`repr` and not :py:class:`str() <str>`.
1609
+ * @deprecated
1610
+ */
1611
+ pyproxyToStringRepr?: boolean;
1612
+ /**
1613
+ * Make loop.run_until_complete() function correctly using stack switching
1614
+ */
1615
+ enableRunUntilComplete?: boolean;
1616
+ /**
1617
+ * If true (default), throw an error if the version of Pyodide core does not
1618
+ * match the version of the Pyodide js package.
1619
+ */
1620
+ checkAPIVersion?: boolean;
1621
+ /**
1622
+ * This is a hook that allows modification of the file system before the
1623
+ * main() function is called and the intereter is started. When this is
1624
+ * called, it is guaranteed that there is an empty site-packages directory.
1625
+ * @experimental
1626
+ */
1627
+ fsInit?: (FS: FSType, info: {
1628
+ sitePackages: string;
1629
+ }) => Promise<void>;
1630
+ /** @ignore */
1631
+ _makeSnapshot?: boolean;
1632
+ /** @ignore */
1633
+ _loadSnapshot?: Uint8Array | ArrayBuffer | PromiseLike<Uint8Array | ArrayBuffer>;
1634
+ /** @ignore */
1635
+ _snapshotDeserializer?: (obj: any) => any;
1636
+ }): Promise<PyodideInterface>;
1637
+
1638
+ export type {};
1639
+ export type {PackageData};