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