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