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