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