pyodide 0.29.4 → 314.0.0-alpha.2

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.
package/pyodide.d.ts CHANGED
@@ -1,11 +1,22 @@
1
1
  // Generated by dts-bundle-generator v8.1.2
2
2
 
3
+ import { ReadableStream, WritableStream } from 'node:stream/web';
4
+
3
5
  interface CanvasInterface {
4
6
  setCanvas2D(canvas: HTMLCanvasElement): void;
5
7
  getCanvas2D(): HTMLCanvasElement | undefined;
6
8
  setCanvas3D(canvas: HTMLCanvasElement): void;
7
9
  getCanvas3D(): HTMLCanvasElement | undefined;
8
10
  }
11
+ interface Writer {
12
+ isatty?: boolean;
13
+ fsync?: () => void;
14
+ write(buffer: Uint8Array): number;
15
+ getTerminalSize?: () => {
16
+ rows: number;
17
+ columns: number;
18
+ } | undefined;
19
+ }
9
20
  type InFuncType = () => null | undefined | string | ArrayBuffer | Uint8Array | number;
10
21
  declare function setStdin(options?: {
11
22
  stdin?: InFuncType;
@@ -14,24 +25,330 @@ declare function setStdin(options?: {
14
25
  isatty?: boolean;
15
26
  autoEOF?: boolean;
16
27
  }): void;
17
- declare function setStdout(options?: {
18
- batched?: (output: string) => void;
19
- raw?: (charCode: number) => void;
20
- write?: (buffer: Uint8Array) => number;
21
- isatty?: boolean;
22
- }): void;
23
- declare function setStderr(options?: {
24
- batched?: (output: string) => void;
25
- raw?: (charCode: number) => void;
26
- write?: (buffer: Uint8Array) => number;
28
+ interface BatchedWriteHandler {
29
+ batched: (output: string) => void;
30
+ }
31
+ interface RawWriteHandler {
32
+ raw: (charCode: number) => void;
27
33
  isatty?: boolean;
28
- }): void;
34
+ getTerminalSize?: () => {
35
+ rows: number;
36
+ columns: number;
37
+ } | undefined;
38
+ }
39
+ type StdWriteOpts = BatchedWriteHandler | RawWriteHandler | Writer;
40
+ declare function setStdout(options?: StdWriteOpts | {}): void;
41
+ declare function setStderr(options?: StdWriteOpts | {}): void;
42
+ interface RuntimeEnv extends BaseRuntimeEnv {
43
+ IN_NODE_COMMONJS: boolean;
44
+ IN_NODE_ESM: boolean;
45
+ IN_BROWSER: boolean;
46
+ IN_BROWSER_MAIN_THREAD: boolean;
47
+ IN_BROWSER_WEB_WORKER: boolean;
48
+ }
49
+ interface BaseRuntimeEnv {
50
+ IN_NODE: boolean;
51
+ IN_BUN: boolean;
52
+ IN_DENO: boolean;
53
+ IN_SAFARI: boolean;
54
+ IN_SHELL: boolean;
55
+ IN_WORKERD: boolean;
56
+ }
57
+ interface SocketOptions {
58
+ /**
59
+ * Specifies whether or not to use TLS when creating the TCP socket.
60
+ *
61
+ * `off`
62
+ * Do not use TLS.
63
+ * `on`
64
+ * Use TLS.
65
+ * `starttls`
66
+ * Do not use TLS initially, but allow the socket to be
67
+ * upgraded to use TLS by calling startTls().
68
+ */
69
+ secureTransport?: "off" | "on" | "starttls";
70
+ /**
71
+ * Defines whether the writable side of the TCP socket will automatically
72
+ * close on end-of-file (EOF).
73
+ */
74
+ allowHalfOpen?: boolean;
75
+ }
76
+ interface SocketAddress {
77
+ /** The hostname to connect to. Example: `cloudflare.com`. */
78
+ hostname: string;
79
+ /** The port number to connect to. Example: `5432`. */
80
+ port: number;
81
+ }
82
+ interface SocketInfo {
83
+ remoteAddress?: string;
84
+ localAddress?: string;
85
+ }
86
+ type ConnectFunc = (address: SocketAddress | string, options?: SocketOptions) => Socket;
87
+ declare class Socket {
88
+ readable: ReadableStream<unknown>;
89
+ writable: WritableStream<unknown>;
90
+ opened: Promise<SocketInfo>;
91
+ closed: Promise<void>;
92
+ private _socket;
93
+ private allowHalfOpen;
94
+ private secureTransport;
95
+ private openedIsResolved;
96
+ private openedResolve;
97
+ private openedReject;
98
+ private closedResolve;
99
+ private closedReject;
100
+ private startTlsCalled;
101
+ constructor(addressOrSocket: SocketAddress | import("node:net").Socket, options?: SocketOptions);
102
+ close(): Promise<void>;
103
+ startTls(): Socket;
104
+ }
105
+ declare function initializeNodeSockFS(connectFunc?: ConnectFunc): Promise<void>;
106
+ type SerializedHiwireValue = {
107
+ path: string[];
108
+ } | {
109
+ serialized: any;
110
+ } | {
111
+ API: true;
112
+ } | {
113
+ abortSignalAny: true;
114
+ } | null;
115
+ type SnapshotConfig = {
116
+ hiwireKeys: SerializedHiwireValue[];
117
+ immortalKeys: string[];
118
+ };
119
+ declare class PackageManager {
120
+ #private;
121
+ /**
122
+ * Only used in Node. If we can't find a package in node_modules, we'll use this
123
+ * to fetch the package from the cdn (and we'll store it into node_modules so
124
+ * subsequent loads don't require a web request).
125
+ *
126
+ * exported for testing purposes.
127
+ */
128
+ cdnURL: string;
129
+ /**
130
+ * The set of loaded packages.
131
+ * This is exposed as a global variable and can be modified by micropip
132
+ *
133
+ * TODO: Make this private and expose a setter
134
+ */
135
+ loadedPackages: LoadedPackages;
136
+ private _lock;
137
+ installBaseUrl?: string;
138
+ /**
139
+ * The function to use for stdout and stderr, defaults to console.log and console.error
140
+ */
141
+ private stdout;
142
+ private stderr;
143
+ /**
144
+ * Buffers for store stdout and stderr messages temporarily.
145
+ * These are used to store the messages that are printed before the
146
+ * stdout and stderr functions are set.
147
+ */
148
+ private streamReady;
149
+ private stdoutBuffer;
150
+ private stderrBuffer;
151
+ private defaultChannel;
152
+ constructor(api: PackageManagerAPI, pyodideModule: PackageManagerModule);
153
+ /**
154
+ * Load packages from the Pyodide distribution or Python wheels by URL.
155
+ *
156
+ * This installs packages in the virtual filesystem. Packages
157
+ * needs to be imported from Python before it can be used.
158
+ *
159
+ * This function can only install packages included in the Pyodide distribution,
160
+ * or Python wheels by URL, without dependency resolution. It is significantly
161
+ * more limited in terms of functionality as compared to :mod:`micropip`,
162
+ * however it has less overhead and can be faster.
163
+ *
164
+ * When installing binary wheels by URLs it is user's responsibility to check
165
+ * that the installed binary wheel is compatible in terms of Python and
166
+ * Emscripten versions. Compatibility is not checked during installation time
167
+ * (unlike with micropip). If a wheel for the wrong Python/Emscripten version
168
+ * is installed it would fail at import time.
169
+ *
170
+ *
171
+ * @param names Either a single package name or URL or a list of them. URLs can
172
+ * be absolute or relative. The URLs must correspond to Python wheels:
173
+ * either pure Python wheels, with a file name ending with ``none-any.whl``
174
+ * or Emscripten/WASM 32 wheels, with a file name ending with
175
+ * ``cp<pyversion>_emscripten_<em_version>_wasm32.whl``.
176
+ * The argument can be a :js:class:`~pyodide.ffi.PyProxy` of a list, in
177
+ * which case the list will be converted to JavaScript and the
178
+ * :js:class:`~pyodide.ffi.PyProxy` will be destroyed.
179
+ * @param options
180
+ * @param options.messageCallback A callback, called with progress messages
181
+ * (optional)
182
+ * @param options.errorCallback A callback, called with error/warning messages
183
+ * (optional)
184
+ * @param options.checkIntegrity If true, check the integrity of the downloaded
185
+ * packages (default: true)
186
+ * @returns The loaded package data.
187
+ */
188
+ loadPackage(names: string | PyProxy | Array<string>, options?: {
189
+ messageCallback?: (message: string) => void;
190
+ errorCallback?: (message: string) => void;
191
+ checkIntegrity?: boolean;
192
+ }): Promise<PackageData[]>;
193
+ loadPackageInner(names: string | PyProxy | string[], options?: {
194
+ messageCallback?: (message: string) => void;
195
+ errorCallback?: (message: string) => void;
196
+ checkIntegrity?: boolean;
197
+ }): Promise<Array<PackageData>>;
198
+ /**
199
+ * Recursively add a package and its dependencies to toLoad.
200
+ * A helper function for recursiveDependencies.
201
+ * @param name The package to add
202
+ * @param toLoad The set of names of packages to load
203
+ * @private
204
+ */
205
+ private addPackageToLoad;
206
+ /**
207
+ * Calculate the dependencies of a set of packages
208
+ * @param names The list of names whose dependencies we need to calculate.
209
+ * @returns The map of package names to PackageLoadMetadata
210
+ * @private
211
+ */
212
+ private recursiveDependencies;
213
+ /**
214
+ * Download a package. If `channel` is `DEFAULT_CHANNEL`, look up the wheel URL
215
+ * relative to packageCacheDir (when IN_NODE), or to lockfileURL, otherwise use the URL specified by
216
+ * `channel`.
217
+ * @param pkg The package to download
218
+ * @param channel Either `DEFAULT_CHANNEL` or the absolute URL to the
219
+ * wheel or the path to the wheel relative to packageCacheDir (when IN_NODE), or lockfileURL.
220
+ * @param checkIntegrity Whether to check the integrity of the downloaded
221
+ * package.
222
+ * @returns The binary data for the package
223
+ * @private
224
+ */
225
+ private downloadPackage;
226
+ /**
227
+ * Install the package into the file system.
228
+ * @param metadata The package metadata
229
+ * @param buffer The binary data returned by downloadPackage
230
+ * @private
231
+ */
232
+ private installPackage;
233
+ /**
234
+ * Download and install the package.
235
+ * Downloads can be done in parallel, but installs must be done for dependencies first.
236
+ * @param pkg The package to load
237
+ * @param toLoad The map of package names to PackageLoadMetadata
238
+ * @param loaded The set of loaded package metadata, this will be updated by this function.
239
+ * @param failed The map of <failed package name, error message>, this will be updated by this function.
240
+ * @param checkIntegrity Whether to check the integrity of the downloaded
241
+ * package.
242
+ * @private
243
+ */
244
+ private downloadAndInstall;
245
+ /**
246
+ * Flushes the stdout and stderr buffers, that were collected before the
247
+ * stdout and stderr functions were set.
248
+ */
249
+ flushBuffers(): void;
250
+ /**
251
+ * getLoadedPackageChannel returns the channel from which a package was loaded.
252
+ * if the package is not loaded, it returns null.
253
+ * @param pkg package name
254
+ */
255
+ getLoadedPackageChannel(pkg: string): string | null;
256
+ setCallbacks(stdout?: (message: string) => void, stderr?: (message: string) => void): <T extends (...args: any[]) => any>(fn: T) => (...args: Parameters<T>) => ReturnType<T>;
257
+ logStdout(message: string): void;
258
+ logStderr(message: string): void;
259
+ }
29
260
  /**
30
261
  * @docgroup pyodide.ffi
31
262
  */
32
263
  /** @deprecated Use `import type { TypedArray } from "pyodide/ffi"` instead */
33
264
  export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
34
265
  type FSType = typeof FS;
266
+ type PreRunFunc = (Module: PyodideModule) => void;
267
+ type DSO = any;
268
+ interface LDSO {
269
+ loadedLibsByName: {
270
+ [key: string]: DSO;
271
+ };
272
+ }
273
+ interface EmscriptenModule {
274
+ locateFile: (file: string) => string;
275
+ exited?: {
276
+ toThrow: any;
277
+ };
278
+ ENV: {
279
+ [key: string]: string;
280
+ };
281
+ PATH: {
282
+ join2(a: string, b: string): string;
283
+ dirname(path: string): string;
284
+ basename(path: string): string;
285
+ normalize(path: string): string;
286
+ };
287
+ TTY: any;
288
+ FS: FSType;
289
+ LDSO: LDSO;
290
+ canvas?: HTMLCanvasElement;
291
+ addRunDependency(id: string): void;
292
+ removeRunDependency(id: string): void;
293
+ getDylinkMetadata(binary: Uint8Array | WebAssembly.Module): {
294
+ neededDynlibs: string[];
295
+ };
296
+ ERRNO_CODES: {
297
+ [k: string]: number;
298
+ };
299
+ stringToNewUTF8(x: string): number;
300
+ stringToUTF8OnStack: (str: string) => number;
301
+ HEAP8: Uint8Array;
302
+ HEAPU8: Uint8Array;
303
+ HEAP32: Int32Array;
304
+ HEAPU32: Uint32Array;
305
+ SOCKFS: any;
306
+ getSocketAddress: (addr: number, addrlen: number) => any;
307
+ getExceptionMessage(e: number): [
308
+ string,
309
+ string
310
+ ];
311
+ exitCode: number | undefined;
312
+ ExitStatus: {
313
+ new (exitCode: number): Error;
314
+ };
315
+ _free: (ptr: number) => void;
316
+ stackSave: () => number;
317
+ stackRestore: (ptr: number) => void;
318
+ promiseMap: {
319
+ free(id: number): void;
320
+ };
321
+ _emscripten_dlopen_promise(lib: number, flags: number): number;
322
+ _dlerror(): number;
323
+ UTF8ToString: (ptr: number, maxBytesToRead: number, ignoreNul?: boolean) => string;
324
+ }
325
+ /** @deprecated Use `import type { PythonModule } from "pyodide/ffi"` instead */
326
+ interface PythonModule extends EmscriptenModule {
327
+ _Py_EMSCRIPTEN_SIGNAL_HANDLING: number;
328
+ Py_EmscriptenSignalBuffer: TypedArray;
329
+ _Py_Version: number;
330
+ }
331
+ /** @deprecated Use `import type { PyodideModule } from "pyodide/ffi"` instead */
332
+ interface PyodideModule extends PythonModule {
333
+ API: API;
334
+ _compat_to_string_repr: number;
335
+ _compat_null_to_none: number;
336
+ _compat_dict_to_literalmap: number;
337
+ js2python_convert: (obj: any, options: {
338
+ depth?: number;
339
+ defaultConverter?: (value: any, converter: (value: any) => any, cacheConversion: (input: any, output: any) => void) => any;
340
+ }) => any;
341
+ _PropagatePythonError: typeof Error;
342
+ __hiwire_get(a: number): any;
343
+ __hiwire_set(a: number, b: any): void;
344
+ __hiwire_immortal_add(a: any): void;
345
+ _jslib_init(): number;
346
+ _init_pyodide_proxy(): number;
347
+ handle_js_error(e: any): void;
348
+ _print_stdout: (ptr: number) => void;
349
+ _print_stderr: (ptr: number) => void;
350
+ getPromise(p: number): Promise<any>;
351
+ }
35
352
  /**
36
353
  * The lockfile platform info. The ``abi_version`` field is used to check if the
37
354
  * lockfile is compatible with the interpreter. The remaining fields are
@@ -122,11 +439,107 @@ interface PackageData {
122
439
  packageType: PackageType;
123
440
  }
124
441
  type LoadedPackages = Record<string, string>;
442
+ interface API {
443
+ runtimeEnv: RuntimeEnv;
444
+ fatal_error: (e: any) => never;
445
+ isPyProxy: (e: any) => e is PyProxy;
446
+ debug_ffi: boolean;
447
+ maybe_fatal_error: (e: any) => void;
448
+ public_api: PyodideAPI;
449
+ config: PyodideConfigWithDefaults;
450
+ packageIndexReady: Promise<void>;
451
+ bootstrapFinalizedPromise: Promise<void>;
452
+ typedArrayAsUint8Array: (buffer: TypedArray | ArrayBuffer) => Uint8Array;
453
+ initializeStreams: (stdin?: InFuncType | undefined, stdout?: ((a: string) => void) | undefined, stderr?: ((a: string) => void) | undefined) => void;
454
+ getTypeTag: (o: any) => string;
455
+ inTestHoist?: boolean;
456
+ on_fatal?: (e: any) => void;
457
+ _skip_unwind_fatal_error?: boolean;
458
+ capture_stderr: () => void;
459
+ restore_stderr: () => string;
460
+ fatal_loading_error: (...args: string[]) => never;
461
+ PythonError: any;
462
+ NoGilError: any;
463
+ errorConstructors: Map<string, ErrorConstructor>;
464
+ deserializeError: (name: string, message: string, stack: string) => Error;
465
+ setPyProxyToStringMethod: (useRepr: boolean) => void;
466
+ setCompatNullToNone: (compat: boolean) => void;
467
+ setCompatToJsLiteralMap: (compat: boolean) => void;
468
+ _pyodide: any;
469
+ pyodide_py: any;
470
+ pyodide_code: any;
471
+ pyodide_ffi: any;
472
+ pyodide_base: any;
473
+ globals: PyProxy;
474
+ rawRun: (code: string) => [
475
+ number,
476
+ string
477
+ ];
478
+ runPythonInternal: (code: string) => any;
479
+ runPythonInternal_dict: any;
480
+ saveState: () => any;
481
+ restoreState: (state: any) => void;
482
+ scheduleCallback: (callback: () => void, timeout: number) => void;
483
+ package_loader: any;
484
+ importlib: any;
485
+ _import_name_to_package_name: Map<string, string>;
486
+ lockFilePromise: Promise<Lockfile | string>;
487
+ lockfile_unvendored_stdlibs: string[];
488
+ lockfile_unvendored_stdlibs_and_test: string[];
489
+ lockfile: Lockfile;
490
+ lockfile_info: LockfileInfo;
491
+ lockfile_packages: Record<string, LockfilePackage>;
492
+ packageManager: PackageManager;
493
+ flushPackageManagerBuffers: () => void;
494
+ defaultLdLibraryPath: string[];
495
+ sitepackages: string;
496
+ loadBinaryFile: (path: string, file_sub_resource_hash?: string | undefined) => Promise<Uint8Array>;
497
+ loadDynlib: (lib: string, global: boolean, searchDirs?: string[] | undefined, readFileFunc?: (path: string) => Uint8Array) => Promise<void>;
498
+ install: (buffer: Uint8Array, filename: string, installDir: string, metadata?: ReadonlyMap<string, string>) => Promise<void>;
499
+ _Comlink: any;
500
+ dsodir: string;
501
+ sys: PyProxy;
502
+ os: PyProxy;
503
+ restoreSnapshot(snapshot: Uint8Array): SnapshotConfig;
504
+ serializeHiwireState(serializer?: (obj: any) => any): SnapshotConfig;
505
+ makeSnapshot(serializer?: (obj: any) => any): Uint8Array;
506
+ saveSnapshot(): Uint8Array;
507
+ getExpectedKeys(): any[];
508
+ finalizeBootstrap: (fromSnapshot?: SnapshotConfig, snapshotDeserializer?: (obj: any) => any) => PyodideAPI;
509
+ syncUpSnapshotLoad3(conf: SnapshotConfig): void;
510
+ abortSignalAny: (signals: AbortSignal[]) => AbortSignal;
511
+ version: string;
512
+ abiVersion: string;
513
+ pyVersionTuple: [
514
+ number,
515
+ number,
516
+ number
517
+ ];
518
+ LiteralMap: any;
519
+ sitePackages: string;
520
+ initializeNodeSockFS: typeof initializeNodeSockFS;
521
+ _nodeSock: {
522
+ connect: (fd: number, host: string, port: number) => Promise<void>;
523
+ recv: (fd: number, nbytes: number) => Promise<Uint8Array | number>;
524
+ send: (fd: number, data: any) => Promise<number>;
525
+ startTls: (fd: number) => number;
526
+ };
527
+ }
528
+ type PackageManagerAPI = Pick<API, "importlib" | "package_loader" | "lockfile_packages" | "bootstrapFinalizedPromise" | "sitepackages" | "defaultLdLibraryPath" | "version"> & {
529
+ config: Pick<PyodideConfigWithDefaults, "packageCacheDir" | "packageBaseUrl" | "cdnUrl">;
530
+ };
531
+ type PackageManagerModule = Pick<PyodideModule, "PATH" | "LDSO" | "stringToNewUTF8" | "stringToUTF8OnStack" | "_print_stderr" | "_print_stdout" | "stackSave" | "stackRestore" | "_emscripten_dlopen_promise" | "getPromise" | "promiseMap" | "_dlerror" | "UTF8ToString">;
125
532
  /** @deprecated Use `import type { PyProxy } from "pyodide/ffi"` instead */
126
533
  interface PyProxy {
127
534
  [x: string]: any;
128
535
  }
536
+ declare const dispose: symbol;
129
537
  declare class PyProxy {
538
+ /**
539
+ * JavaScript resource management
540
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Resource_management#the_using_and_await_using_declarations
541
+ */
542
+ [Symbol.dispose]: () => void;
130
543
  /** @private */
131
544
  $$flags: number;
132
545
  /** @private */
@@ -237,7 +650,7 @@ declare class PyProxy {
237
650
  }
238
651
  declare class PyProxyWithLength extends PyProxy {
239
652
  /** @private */
240
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
653
+ static [Symbol.hasInstance](obj: any): obj is PyProxyWithLength;
241
654
  }
242
655
  /** @deprecated Use `import type { PyProxyWithLength } from "pyodide/ffi"` instead */
243
656
  interface PyProxyWithLength extends PyLengthMethods {
@@ -250,7 +663,7 @@ declare class PyLengthMethods {
250
663
  }
251
664
  declare class PyProxyWithGet extends PyProxy {
252
665
  /** @private */
253
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
666
+ static [Symbol.hasInstance](obj: any): obj is PyProxyWithGet;
254
667
  }
255
668
  /** @deprecated Use `import type { PyProxyWithGet } from "pyodide/ffi"` instead */
256
669
  interface PyProxyWithGet extends PyGetItemMethods {
@@ -281,7 +694,7 @@ declare class PyGetItemMethods {
281
694
  }
282
695
  declare class PyProxyWithSet extends PyProxy {
283
696
  /** @private */
284
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
697
+ static [Symbol.hasInstance](obj: any): obj is PyProxyWithSet;
285
698
  }
286
699
  /** @deprecated Use `import type { PyProxyWithSet } from "pyodide/ffi"` instead */
287
700
  interface PyProxyWithSet extends PySetItemMethods {
@@ -303,7 +716,7 @@ declare class PySetItemMethods {
303
716
  }
304
717
  declare class PyProxyWithHas extends PyProxy {
305
718
  /** @private */
306
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
719
+ static [Symbol.hasInstance](obj: any): obj is PyProxyWithHas;
307
720
  }
308
721
  /** @deprecated Use `import type { PyProxyWithHas } from "pyodide/ffi"` instead */
309
722
  interface PyProxyWithHas extends PyContainsMethods {
@@ -319,7 +732,7 @@ declare class PyContainsMethods {
319
732
  }
320
733
  declare class PyIterable extends PyProxy {
321
734
  /** @private */
322
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
735
+ static [Symbol.hasInstance](obj: any): obj is PyIterable;
323
736
  }
324
737
  /** @deprecated Use `import type { PyIterable } from "pyodide/ffi"` instead */
325
738
  interface PyIterable extends PyIterableMethods {
@@ -336,7 +749,7 @@ declare class PyIterableMethods {
336
749
  }
337
750
  declare class PyAsyncIterable extends PyProxy {
338
751
  /** @private */
339
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
752
+ static [Symbol.hasInstance](obj: any): obj is PyAsyncIterable;
340
753
  }
341
754
  /** @deprecated Use `import type { PyAsyncIterable } from "pyodide/ffi"` instead */
342
755
  interface PyAsyncIterable extends PyAsyncIterableMethods {
@@ -352,7 +765,7 @@ declare class PyAsyncIterableMethods {
352
765
  }
353
766
  declare class PyIterator extends PyProxy {
354
767
  /** @private */
355
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
768
+ static [Symbol.hasInstance](obj: any): obj is PyIterator;
356
769
  }
357
770
  /** @deprecated Use `import type { PyIterator } from "pyodide/ffi"` instead */
358
771
  interface PyIterator extends PyIteratorMethods {
@@ -378,7 +791,7 @@ declare class PyIteratorMethods {
378
791
  }
379
792
  declare class PyGenerator extends PyProxy {
380
793
  /** @private */
381
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
794
+ static [Symbol.hasInstance](obj: any): obj is PyGenerator;
382
795
  }
383
796
  /** @deprecated Use `import type { PyGenerator } from "pyodide/ffi"` instead */
384
797
  interface PyGenerator extends PyGeneratorMethods {
@@ -418,7 +831,7 @@ declare class PyGeneratorMethods {
418
831
  }
419
832
  declare class PyAsyncIterator extends PyProxy {
420
833
  /** @private */
421
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
834
+ static [Symbol.hasInstance](obj: any): obj is PyAsyncIterator;
422
835
  }
423
836
  /** @deprecated Use `import type { PyAsyncIterator } from "pyodide/ffi"` instead */
424
837
  interface PyAsyncIterator extends PyAsyncIteratorMethods {
@@ -444,7 +857,7 @@ declare class PyAsyncIteratorMethods {
444
857
  }
445
858
  declare class PyAsyncGenerator extends PyProxy {
446
859
  /** @private */
447
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
860
+ static [Symbol.hasInstance](obj: any): obj is PyAsyncGenerator;
448
861
  }
449
862
  /** @deprecated Use `import type { PyAsyncGenerator } from "pyodide/ffi"` instead */
450
863
  interface PyAsyncGenerator extends PyAsyncGeneratorMethods {
@@ -483,7 +896,7 @@ declare class PyAsyncGeneratorMethods {
483
896
  }
484
897
  declare class PySequence extends PyProxy {
485
898
  /** @private */
486
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
899
+ static [Symbol.hasInstance](obj: any): obj is PySequence;
487
900
  }
488
901
  /** @deprecated Use `import type { PySequence } from "pyodide/ffi"` instead */
489
902
  interface PySequence extends PySequenceMethods {
@@ -680,7 +1093,7 @@ declare class PySequenceMethods {
680
1093
  }
681
1094
  declare class PyMutableSequence extends PyProxy {
682
1095
  /** @private */
683
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
1096
+ static [Symbol.hasInstance](obj: any): obj is PyMutableSequence;
684
1097
  }
685
1098
  /** @deprecated Use `import type { PyMutableSequence } from "pyodide/ffi"` instead */
686
1099
  interface PyMutableSequence extends PyMutableSequenceMethods {
@@ -764,7 +1177,7 @@ declare class PyMutableSequenceMethods {
764
1177
  }
765
1178
  declare class PyAwaitable extends PyProxy {
766
1179
  /** @private */
767
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
1180
+ static [Symbol.hasInstance](obj: any): obj is PyAwaitable;
768
1181
  }
769
1182
  /** @deprecated Use `import type { PyAwaitable } from "pyodide/ffi"` instead */
770
1183
  interface PyAwaitable extends Promise<any> {
@@ -958,6 +1371,11 @@ declare class PyBufferMethods {
958
1371
  * data, so you might want to pass ``'dataview'`` as the type argument in that
959
1372
  * case.
960
1373
  *
1374
+ * When you are done with the buffer view, you have to call
1375
+ * :js:func:`~PyBufferView.release`. Alternatively, if you declare the buffer
1376
+ * with `using pybuf = proxy.getBuffer()`, JavaScript will automatically
1377
+ * release the buffer at the end of the current scope.
1378
+ *
961
1379
  * @param type The type of the :js:attr:`~pyodide.ffi.PyBufferView.data` field
962
1380
  * in the output. Should be one of: ``"i8"``, ``"u8"``, ``"u8clamped"``,
963
1381
  * ``"i16"``, ``"u16"``, ``"i32"``, ``"u32"``, ``"i32"``, ``"u32"``,
@@ -970,13 +1388,14 @@ declare class PyBufferMethods {
970
1388
  }
971
1389
  declare class PyDict extends PyProxy {
972
1390
  /** @private */
973
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
1391
+ static [Symbol.hasInstance](obj: any): obj is PyDict;
974
1392
  }
975
1393
  /** @deprecated Use `import type { PyDict } from "pyodide/ffi"` instead */
976
1394
  interface PyDict extends PyProxyWithGet, PyProxyWithSet, PyProxyWithHas, PyProxyWithLength, PyIterable {
977
1395
  }
978
1396
  /** @deprecated Use `import type { PyBufferView } from "pyodide/ffi"` instead */
979
1397
  declare class PyBufferView {
1398
+ [Symbol.dispose]: () => void;
980
1399
  /**
981
1400
  * The offset of the first entry of the array. For instance if our array
982
1401
  * is 3d, then you will find ``array[0,0,0]`` at
@@ -1426,6 +1845,17 @@ declare class PyodideAPI_ {
1426
1845
  * @param hostPath The host path to mount. It must be a directory that exists.
1427
1846
  */
1428
1847
  static mountNodeFS(emscriptenPath: string, hostPath: string): void;
1848
+ /**
1849
+ * Use Node.js native socket filesystem instead of Emscripten's SOCKFS.
1850
+ * @experimental
1851
+ */
1852
+ static useNodeSockFS(
1853
+ /**
1854
+ * @hidden
1855
+ */
1856
+ options?: {
1857
+ connect?: ConnectFunc;
1858
+ }): Promise<void>;
1429
1859
  /**
1430
1860
  * Tell Pyodide about Comlink.
1431
1861
  * Necessary to enable importing Comlink proxies into Python.
@@ -1492,6 +1922,25 @@ declare class PyodideAPI_ {
1492
1922
  * @docgroup exports
1493
1923
  */
1494
1924
  export type PyodideAPI = typeof PyodideAPI_;
1925
+ interface EmscriptenSettings {
1926
+ readonly noImageDecoding?: boolean;
1927
+ readonly noAudioDecoding?: boolean;
1928
+ readonly noWasmDecoding?: boolean;
1929
+ readonly preRun: readonly PreRunFunc[];
1930
+ readonly print?: (a: string) => void;
1931
+ readonly printErr?: (a: string) => void;
1932
+ readonly onExit?: (code: number) => void;
1933
+ readonly thisProgram?: string;
1934
+ readonly arguments: readonly string[];
1935
+ readonly instantiateWasm?: (imports: {
1936
+ [key: string]: any;
1937
+ }, successCallback: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void) => void;
1938
+ readonly API: API;
1939
+ readonly locateFile: (file: string) => string;
1940
+ noInitialRun?: boolean;
1941
+ INITIAL_MEMORY?: number;
1942
+ exitCode?: number;
1943
+ }
1495
1944
  /**
1496
1945
  * The Pyodide version.
1497
1946
  *
@@ -1500,6 +1949,7 @@ export type PyodideAPI = typeof PyodideAPI_;
1500
1949
  * version convention.
1501
1950
  */
1502
1951
  export declare const version: string;
1952
+ type CreatePyodideModuleFn = (settings: EmscriptenSettings) => Promise<PyodideModule>;
1503
1953
  /**
1504
1954
  * The configuration options for loading Pyodide.
1505
1955
  */
@@ -1550,16 +2000,12 @@ interface PyodideConfig {
1550
2000
  */
1551
2001
  packageBaseUrl?: string;
1552
2002
  /**
1553
- * Load the full Python standard library. Setting this to false excludes
1554
- * unvendored modules from the standard library.
1555
- * Default: ``false``
2003
+ * Deprecated: This option has no effect.
1556
2004
  */
1557
2005
  fullStdLib?: boolean;
1558
2006
  /**
1559
2007
  * The URL from which to load the standard library ``python_stdlib.zip``
1560
- * file. This URL includes the most of the Python standard library. Some
1561
- * stdlib modules were unvendored, and can be loaded separately
1562
- * with ``fullStdLib: true`` option or by their package name.
2008
+ * file. This URL includes the most of the Python standard library.
1563
2009
  * Default: ```${indexURL}/python_stdlib.zip```
1564
2010
  */
1565
2011
  stdLibURL?: string;
@@ -1666,6 +2112,17 @@ interface PyodideConfig {
1666
2112
  _loadSnapshot?: Uint8Array | ArrayBuffer | PromiseLike<Uint8Array | ArrayBuffer>;
1667
2113
  /** @ignore */
1668
2114
  _snapshotDeserializer?: (obj: any) => any;
2115
+ /**
2116
+ * @experimental
2117
+ * The constructor function to use to create the Pyodide module.
2118
+ * This function can be imported from `pyodide.asm.mjs`
2119
+ * and passed to `loadPyodide` as `createPyodideModule` option.
2120
+ * This is used to work around service workers forbid dynamic import(),
2121
+ * and not intended to be used in other cases.
2122
+ *
2123
+ * Warning: This is an experimental feature and may change in the future.
2124
+ */
2125
+ createPyodideModule?: CreatePyodideModuleFn;
1669
2126
  /** @ignore */
1670
2127
  BUILD_ID?: string;
1671
2128
  /** @ignore */
@@ -1682,7 +2139,6 @@ export type PyodideConfigWithDefaults = Required<PyodideConfig>;
1682
2139
  * @example
1683
2140
  * async function main() {
1684
2141
  * const pyodide = await loadPyodide({
1685
- * fullStdLib: true,
1686
2142
  * stdout: (msg) => console.log(`Pyodide: ${msg}`),
1687
2143
  * });
1688
2144
  * console.log("Loaded Pyodide");