pyodide 0.29.2 → 314.0.0-alpha.1

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.asm.wasm CHANGED
Binary file
package/pyodide.d.ts CHANGED
@@ -1,5 +1,7 @@
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;
@@ -26,24 +28,315 @@ declare function setStderr(options?: {
26
28
  write?: (buffer: Uint8Array) => number;
27
29
  isatty?: boolean;
28
30
  }): void;
31
+ interface RuntimeEnv extends BaseRuntimeEnv {
32
+ IN_NODE_COMMONJS: boolean;
33
+ IN_NODE_ESM: boolean;
34
+ IN_BROWSER: boolean;
35
+ IN_BROWSER_MAIN_THREAD: boolean;
36
+ IN_BROWSER_WEB_WORKER: boolean;
37
+ }
38
+ interface BaseRuntimeEnv {
39
+ IN_NODE: boolean;
40
+ IN_BUN: boolean;
41
+ IN_DENO: boolean;
42
+ IN_SAFARI: boolean;
43
+ IN_SHELL: boolean;
44
+ IN_WORKERD: boolean;
45
+ }
46
+ interface SocketOptions {
47
+ /**
48
+ * Specifies whether or not to use TLS when creating the TCP socket.
49
+ *
50
+ * `off`
51
+ * Do not use TLS.
52
+ * `on`
53
+ * Use TLS.
54
+ * `starttls`
55
+ * Do not use TLS initially, but allow the socket to be
56
+ * upgraded to use TLS by calling startTls().
57
+ */
58
+ secureTransport?: "off" | "on" | "starttls";
59
+ /**
60
+ * Defines whether the writable side of the TCP socket will automatically
61
+ * close on end-of-file (EOF).
62
+ */
63
+ allowHalfOpen?: boolean;
64
+ }
65
+ interface SocketAddress {
66
+ /** The hostname to connect to. Example: `cloudflare.com`. */
67
+ hostname: string;
68
+ /** The port number to connect to. Example: `5432`. */
69
+ port: number;
70
+ }
71
+ interface SocketInfo {
72
+ remoteAddress?: string;
73
+ localAddress?: string;
74
+ }
75
+ type ConnectFunc = (address: SocketAddress | string, options?: SocketOptions) => Socket;
76
+ declare class Socket {
77
+ readable: ReadableStream<unknown>;
78
+ writable: WritableStream<unknown>;
79
+ opened: Promise<SocketInfo>;
80
+ closed: Promise<void>;
81
+ private _socket;
82
+ private allowHalfOpen;
83
+ private secureTransport;
84
+ private openedIsResolved;
85
+ private openedResolve;
86
+ private openedReject;
87
+ private closedResolve;
88
+ private closedReject;
89
+ private startTlsCalled;
90
+ constructor(addressOrSocket: SocketAddress | import("node:net").Socket, options?: SocketOptions);
91
+ close(): Promise<void>;
92
+ startTls(): Socket;
93
+ }
94
+ declare function initializeNodeSockFS(connectFunc?: ConnectFunc): Promise<void>;
95
+ type SerializedHiwireValue = {
96
+ path: string[];
97
+ } | {
98
+ serialized: any;
99
+ } | {
100
+ API: true;
101
+ } | {
102
+ abortSignalAny: true;
103
+ } | null;
104
+ type SnapshotConfig = {
105
+ hiwireKeys: SerializedHiwireValue[];
106
+ immortalKeys: string[];
107
+ };
108
+ declare class PackageManager {
109
+ #private;
110
+ /**
111
+ * Only used in Node. If we can't find a package in node_modules, we'll use this
112
+ * to fetch the package from the cdn (and we'll store it into node_modules so
113
+ * subsequent loads don't require a web request).
114
+ *
115
+ * exported for testing purposes.
116
+ */
117
+ cdnURL: string;
118
+ /**
119
+ * The set of loaded packages.
120
+ * This is exposed as a global variable and can be modified by micropip
121
+ *
122
+ * TODO: Make this private and expose a setter
123
+ */
124
+ loadedPackages: LoadedPackages;
125
+ private _lock;
126
+ installBaseUrl?: string;
127
+ /**
128
+ * The function to use for stdout and stderr, defaults to console.log and console.error
129
+ */
130
+ private stdout;
131
+ private stderr;
132
+ /**
133
+ * Buffers for store stdout and stderr messages temporarily.
134
+ * These are used to store the messages that are printed before the
135
+ * stdout and stderr functions are set.
136
+ */
137
+ private streamReady;
138
+ private stdoutBuffer;
139
+ private stderrBuffer;
140
+ private defaultChannel;
141
+ constructor(api: PackageManagerAPI, pyodideModule: PackageManagerModule);
142
+ /**
143
+ * Load packages from the Pyodide distribution or Python wheels by URL.
144
+ *
145
+ * This installs packages in the virtual filesystem. Packages
146
+ * needs to be imported from Python before it can be used.
147
+ *
148
+ * This function can only install packages included in the Pyodide distribution,
149
+ * or Python wheels by URL, without dependency resolution. It is significantly
150
+ * more limited in terms of functionality as compared to :mod:`micropip`,
151
+ * however it has less overhead and can be faster.
152
+ *
153
+ * When installing binary wheels by URLs it is user's responsibility to check
154
+ * that the installed binary wheel is compatible in terms of Python and
155
+ * Emscripten versions. Compatibility is not checked during installation time
156
+ * (unlike with micropip). If a wheel for the wrong Python/Emscripten version
157
+ * is installed it would fail at import time.
158
+ *
159
+ *
160
+ * @param names Either a single package name or URL or a list of them. URLs can
161
+ * be absolute or relative. The URLs must correspond to Python wheels:
162
+ * either pure Python wheels, with a file name ending with ``none-any.whl``
163
+ * or Emscripten/WASM 32 wheels, with a file name ending with
164
+ * ``cp<pyversion>_emscripten_<em_version>_wasm32.whl``.
165
+ * The argument can be a :js:class:`~pyodide.ffi.PyProxy` of a list, in
166
+ * which case the list will be converted to JavaScript and the
167
+ * :js:class:`~pyodide.ffi.PyProxy` will be destroyed.
168
+ * @param options
169
+ * @param options.messageCallback A callback, called with progress messages
170
+ * (optional)
171
+ * @param options.errorCallback A callback, called with error/warning messages
172
+ * (optional)
173
+ * @param options.checkIntegrity If true, check the integrity of the downloaded
174
+ * packages (default: true)
175
+ * @returns The loaded package data.
176
+ */
177
+ loadPackage(names: string | PyProxy | Array<string>, options?: {
178
+ messageCallback?: (message: string) => void;
179
+ errorCallback?: (message: string) => void;
180
+ checkIntegrity?: boolean;
181
+ }): Promise<PackageData[]>;
182
+ loadPackageInner(names: string | PyProxy | string[], options?: {
183
+ messageCallback?: (message: string) => void;
184
+ errorCallback?: (message: string) => void;
185
+ checkIntegrity?: boolean;
186
+ }): Promise<Array<PackageData>>;
187
+ /**
188
+ * Recursively add a package and its dependencies to toLoad.
189
+ * A helper function for recursiveDependencies.
190
+ * @param name The package to add
191
+ * @param toLoad The set of names of packages to load
192
+ * @private
193
+ */
194
+ private addPackageToLoad;
195
+ /**
196
+ * Calculate the dependencies of a set of packages
197
+ * @param names The list of names whose dependencies we need to calculate.
198
+ * @returns The map of package names to PackageLoadMetadata
199
+ * @private
200
+ */
201
+ private recursiveDependencies;
202
+ /**
203
+ * Download a package. If `channel` is `DEFAULT_CHANNEL`, look up the wheel URL
204
+ * relative to packageCacheDir (when IN_NODE), or to lockfileURL, otherwise use the URL specified by
205
+ * `channel`.
206
+ * @param pkg The package to download
207
+ * @param channel Either `DEFAULT_CHANNEL` or the absolute URL to the
208
+ * wheel or the path to the wheel relative to packageCacheDir (when IN_NODE), or lockfileURL.
209
+ * @param checkIntegrity Whether to check the integrity of the downloaded
210
+ * package.
211
+ * @returns The binary data for the package
212
+ * @private
213
+ */
214
+ private downloadPackage;
215
+ /**
216
+ * Install the package into the file system.
217
+ * @param metadata The package metadata
218
+ * @param buffer The binary data returned by downloadPackage
219
+ * @private
220
+ */
221
+ private installPackage;
222
+ /**
223
+ * Download and install the package.
224
+ * Downloads can be done in parallel, but installs must be done for dependencies first.
225
+ * @param pkg The package to load
226
+ * @param toLoad The map of package names to PackageLoadMetadata
227
+ * @param loaded The set of loaded package metadata, this will be updated by this function.
228
+ * @param failed The map of <failed package name, error message>, this will be updated by this function.
229
+ * @param checkIntegrity Whether to check the integrity of the downloaded
230
+ * package.
231
+ * @private
232
+ */
233
+ private downloadAndInstall;
234
+ /**
235
+ * Flushes the stdout and stderr buffers, that were collected before the
236
+ * stdout and stderr functions were set.
237
+ */
238
+ flushBuffers(): void;
239
+ /**
240
+ * getLoadedPackageChannel returns the channel from which a package was loaded.
241
+ * if the package is not loaded, it returns null.
242
+ * @param pkg package name
243
+ */
244
+ getLoadedPackageChannel(pkg: string): string | null;
245
+ setCallbacks(stdout?: (message: string) => void, stderr?: (message: string) => void): <T extends (...args: any[]) => any>(fn: T) => (...args: Parameters<T>) => ReturnType<T>;
246
+ logStdout(message: string): void;
247
+ logStderr(message: string): void;
248
+ }
29
249
  /**
30
250
  * @docgroup pyodide.ffi
31
251
  */
32
252
  /** @deprecated Use `import type { TypedArray } from "pyodide/ffi"` instead */
33
253
  export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
34
- type FSStreamOpsGen<T> = {
35
- open: (a: T) => void;
36
- close: (a: T) => void;
37
- fsync: (a: T) => void;
38
- read: (a: T, b: Uint8Array, offset: number, length: number, pos: number) => number;
39
- write: (a: T, b: Uint8Array, offset: number, length: number, pos: number) => number;
40
- };
41
- /** @deprecated Use `import type { PyodideFSType } from "pyodide/ffi"` instead */
42
- interface PyodideFSType {
43
- filesystems: any;
44
- registerDevice<T>(dev: number, ops: FSStreamOpsGen<T>): void;
254
+ type FSType = typeof FS;
255
+ type PreRunFunc = (Module: PyodideModule) => void;
256
+ type DSO = any;
257
+ interface LDSO {
258
+ loadedLibsByName: {
259
+ [key: string]: DSO;
260
+ };
261
+ }
262
+ interface EmscriptenModule {
263
+ locateFile: (file: string) => string;
264
+ exited?: {
265
+ toThrow: any;
266
+ };
267
+ ENV: {
268
+ [key: string]: string;
269
+ };
270
+ PATH: {
271
+ join2(a: string, b: string): string;
272
+ dirname(path: string): string;
273
+ basename(path: string): string;
274
+ normalize(path: string): string;
275
+ };
276
+ TTY: any;
277
+ FS: FSType;
278
+ LDSO: LDSO;
279
+ canvas?: HTMLCanvasElement;
280
+ addRunDependency(id: string): void;
281
+ removeRunDependency(id: string): void;
282
+ getDylinkMetadata(binary: Uint8Array | WebAssembly.Module): {
283
+ neededDynlibs: string[];
284
+ };
285
+ ERRNO_CODES: {
286
+ [k: string]: number;
287
+ };
288
+ stringToNewUTF8(x: string): number;
289
+ stringToUTF8OnStack: (str: string) => number;
290
+ HEAP8: Uint8Array;
291
+ HEAPU8: Uint8Array;
292
+ HEAPU32: Uint32Array;
293
+ SOCKFS: any;
294
+ getSocketAddress: (addr: number, addrlen: number) => any;
295
+ getExceptionMessage(e: number): [
296
+ string,
297
+ string
298
+ ];
299
+ exitCode: number | undefined;
300
+ ExitStatus: {
301
+ new (exitCode: number): Error;
302
+ };
303
+ _free: (ptr: number) => void;
304
+ stackSave: () => number;
305
+ stackRestore: (ptr: number) => void;
306
+ promiseMap: {
307
+ free(id: number): void;
308
+ };
309
+ _emscripten_dlopen_promise(lib: number, flags: number): number;
310
+ _dlerror(): number;
311
+ UTF8ToString: (ptr: number, maxBytesToRead: number, ignoreNul?: boolean) => string;
312
+ }
313
+ /** @deprecated Use `import type { PythonModule } from "pyodide/ffi"` instead */
314
+ interface PythonModule extends EmscriptenModule {
315
+ _Py_EMSCRIPTEN_SIGNAL_HANDLING: number;
316
+ Py_EmscriptenSignalBuffer: TypedArray;
317
+ _Py_Version: number;
318
+ }
319
+ /** @deprecated Use `import type { PyodideModule } from "pyodide/ffi"` instead */
320
+ interface PyodideModule extends PythonModule {
321
+ API: API;
322
+ _compat_to_string_repr: number;
323
+ _compat_null_to_none: number;
324
+ _compat_dict_to_literalmap: number;
325
+ js2python_convert: (obj: any, options: {
326
+ depth?: number;
327
+ defaultConverter?: (value: any, converter: (value: any) => any, cacheConversion: (input: any, output: any) => void) => any;
328
+ }) => any;
329
+ _PropagatePythonError: typeof Error;
330
+ __hiwire_get(a: number): any;
331
+ __hiwire_set(a: number, b: any): void;
332
+ __hiwire_immortal_add(a: any): void;
333
+ _jslib_init(): number;
334
+ _init_pyodide_proxy(): number;
335
+ handle_js_error(e: any): void;
336
+ _print_stdout: (ptr: number) => void;
337
+ _print_stderr: (ptr: number) => void;
338
+ getPromise(p: number): Promise<any>;
45
339
  }
46
- type FSType = typeof FS & PyodideFSType;
47
340
  /**
48
341
  * The lockfile platform info. The ``abi_version`` field is used to check if the
49
342
  * lockfile is compatible with the interpreter. The remaining fields are
@@ -134,11 +427,101 @@ interface PackageData {
134
427
  packageType: PackageType;
135
428
  }
136
429
  type LoadedPackages = Record<string, string>;
430
+ interface API {
431
+ runtimeEnv: RuntimeEnv;
432
+ fatal_error: (e: any) => never;
433
+ isPyProxy: (e: any) => e is PyProxy;
434
+ debug_ffi: boolean;
435
+ maybe_fatal_error: (e: any) => void;
436
+ public_api: PyodideAPI;
437
+ config: PyodideConfigWithDefaults;
438
+ packageIndexReady: Promise<void>;
439
+ bootstrapFinalizedPromise: Promise<void>;
440
+ typedArrayAsUint8Array: (buffer: TypedArray | ArrayBuffer) => Uint8Array;
441
+ initializeStreams: (stdin?: InFuncType | undefined, stdout?: ((a: string) => void) | undefined, stderr?: ((a: string) => void) | undefined) => void;
442
+ getTypeTag: (o: any) => string;
443
+ inTestHoist?: boolean;
444
+ on_fatal?: (e: any) => void;
445
+ _skip_unwind_fatal_error?: boolean;
446
+ capture_stderr: () => void;
447
+ restore_stderr: () => string;
448
+ fatal_loading_error: (...args: string[]) => never;
449
+ PythonError: any;
450
+ NoGilError: any;
451
+ errorConstructors: Map<string, ErrorConstructor>;
452
+ deserializeError: (name: string, message: string, stack: string) => Error;
453
+ setPyProxyToStringMethod: (useRepr: boolean) => void;
454
+ setCompatNullToNone: (compat: boolean) => void;
455
+ setCompatToJsLiteralMap: (compat: boolean) => void;
456
+ _pyodide: any;
457
+ pyodide_py: any;
458
+ pyodide_code: any;
459
+ pyodide_ffi: any;
460
+ pyodide_base: any;
461
+ globals: PyProxy;
462
+ rawRun: (code: string) => [
463
+ number,
464
+ string
465
+ ];
466
+ runPythonInternal: (code: string) => any;
467
+ runPythonInternal_dict: any;
468
+ saveState: () => any;
469
+ restoreState: (state: any) => void;
470
+ scheduleCallback: (callback: () => void, timeout: number) => void;
471
+ package_loader: any;
472
+ importlib: any;
473
+ _import_name_to_package_name: Map<string, string>;
474
+ lockFilePromise: Promise<Lockfile | string>;
475
+ lockfile_unvendored_stdlibs: string[];
476
+ lockfile_unvendored_stdlibs_and_test: string[];
477
+ lockfile: Lockfile;
478
+ lockfile_info: LockfileInfo;
479
+ lockfile_packages: Record<string, LockfilePackage>;
480
+ packageManager: PackageManager;
481
+ flushPackageManagerBuffers: () => void;
482
+ defaultLdLibraryPath: string[];
483
+ sitepackages: string;
484
+ loadBinaryFile: (path: string, file_sub_resource_hash?: string | undefined) => Promise<Uint8Array>;
485
+ loadDynlib: (lib: string, global: boolean, searchDirs?: string[] | undefined, readFileFunc?: (path: string) => Uint8Array) => Promise<void>;
486
+ install: (buffer: Uint8Array, filename: string, installDir: string, metadata?: ReadonlyMap<string, string>) => Promise<void>;
487
+ _Comlink: any;
488
+ dsodir: string;
489
+ sys: PyProxy;
490
+ os: PyProxy;
491
+ restoreSnapshot(snapshot: Uint8Array): SnapshotConfig;
492
+ serializeHiwireState(serializer?: (obj: any) => any): SnapshotConfig;
493
+ makeSnapshot(serializer?: (obj: any) => any): Uint8Array;
494
+ saveSnapshot(): Uint8Array;
495
+ getExpectedKeys(): any[];
496
+ finalizeBootstrap: (fromSnapshot?: SnapshotConfig, snapshotDeserializer?: (obj: any) => any) => PyodideAPI;
497
+ syncUpSnapshotLoad3(conf: SnapshotConfig): void;
498
+ abortSignalAny: (signals: AbortSignal[]) => AbortSignal;
499
+ version: string;
500
+ abiVersion: string;
501
+ pyVersionTuple: [
502
+ number,
503
+ number,
504
+ number
505
+ ];
506
+ LiteralMap: any;
507
+ sitePackages: string;
508
+ initializeNodeSockFS: typeof initializeNodeSockFS;
509
+ }
510
+ type PackageManagerAPI = Pick<API, "importlib" | "package_loader" | "lockfile_packages" | "bootstrapFinalizedPromise" | "sitepackages" | "defaultLdLibraryPath" | "version"> & {
511
+ config: Pick<PyodideConfigWithDefaults, "packageCacheDir" | "packageBaseUrl" | "cdnUrl">;
512
+ };
513
+ type PackageManagerModule = Pick<PyodideModule, "PATH" | "LDSO" | "stringToNewUTF8" | "stringToUTF8OnStack" | "_print_stderr" | "_print_stdout" | "stackSave" | "stackRestore" | "_emscripten_dlopen_promise" | "getPromise" | "promiseMap" | "_dlerror" | "UTF8ToString">;
137
514
  /** @deprecated Use `import type { PyProxy } from "pyodide/ffi"` instead */
138
515
  interface PyProxy {
139
516
  [x: string]: any;
140
517
  }
518
+ declare const dispose: symbol;
141
519
  declare class PyProxy {
520
+ /**
521
+ * JavaScript resource management
522
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Resource_management#the_using_and_await_using_declarations
523
+ */
524
+ [Symbol.dispose]: () => void;
142
525
  /** @private */
143
526
  $$flags: number;
144
527
  /** @private */
@@ -249,7 +632,7 @@ declare class PyProxy {
249
632
  }
250
633
  declare class PyProxyWithLength extends PyProxy {
251
634
  /** @private */
252
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
635
+ static [Symbol.hasInstance](obj: any): obj is PyProxyWithLength;
253
636
  }
254
637
  /** @deprecated Use `import type { PyProxyWithLength } from "pyodide/ffi"` instead */
255
638
  interface PyProxyWithLength extends PyLengthMethods {
@@ -262,7 +645,7 @@ declare class PyLengthMethods {
262
645
  }
263
646
  declare class PyProxyWithGet extends PyProxy {
264
647
  /** @private */
265
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
648
+ static [Symbol.hasInstance](obj: any): obj is PyProxyWithGet;
266
649
  }
267
650
  /** @deprecated Use `import type { PyProxyWithGet } from "pyodide/ffi"` instead */
268
651
  interface PyProxyWithGet extends PyGetItemMethods {
@@ -293,7 +676,7 @@ declare class PyGetItemMethods {
293
676
  }
294
677
  declare class PyProxyWithSet extends PyProxy {
295
678
  /** @private */
296
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
679
+ static [Symbol.hasInstance](obj: any): obj is PyProxyWithSet;
297
680
  }
298
681
  /** @deprecated Use `import type { PyProxyWithSet } from "pyodide/ffi"` instead */
299
682
  interface PyProxyWithSet extends PySetItemMethods {
@@ -315,7 +698,7 @@ declare class PySetItemMethods {
315
698
  }
316
699
  declare class PyProxyWithHas extends PyProxy {
317
700
  /** @private */
318
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
701
+ static [Symbol.hasInstance](obj: any): obj is PyProxyWithHas;
319
702
  }
320
703
  /** @deprecated Use `import type { PyProxyWithHas } from "pyodide/ffi"` instead */
321
704
  interface PyProxyWithHas extends PyContainsMethods {
@@ -331,7 +714,7 @@ declare class PyContainsMethods {
331
714
  }
332
715
  declare class PyIterable extends PyProxy {
333
716
  /** @private */
334
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
717
+ static [Symbol.hasInstance](obj: any): obj is PyIterable;
335
718
  }
336
719
  /** @deprecated Use `import type { PyIterable } from "pyodide/ffi"` instead */
337
720
  interface PyIterable extends PyIterableMethods {
@@ -348,7 +731,7 @@ declare class PyIterableMethods {
348
731
  }
349
732
  declare class PyAsyncIterable extends PyProxy {
350
733
  /** @private */
351
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
734
+ static [Symbol.hasInstance](obj: any): obj is PyAsyncIterable;
352
735
  }
353
736
  /** @deprecated Use `import type { PyAsyncIterable } from "pyodide/ffi"` instead */
354
737
  interface PyAsyncIterable extends PyAsyncIterableMethods {
@@ -364,7 +747,7 @@ declare class PyAsyncIterableMethods {
364
747
  }
365
748
  declare class PyIterator extends PyProxy {
366
749
  /** @private */
367
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
750
+ static [Symbol.hasInstance](obj: any): obj is PyIterator;
368
751
  }
369
752
  /** @deprecated Use `import type { PyIterator } from "pyodide/ffi"` instead */
370
753
  interface PyIterator extends PyIteratorMethods {
@@ -390,7 +773,7 @@ declare class PyIteratorMethods {
390
773
  }
391
774
  declare class PyGenerator extends PyProxy {
392
775
  /** @private */
393
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
776
+ static [Symbol.hasInstance](obj: any): obj is PyGenerator;
394
777
  }
395
778
  /** @deprecated Use `import type { PyGenerator } from "pyodide/ffi"` instead */
396
779
  interface PyGenerator extends PyGeneratorMethods {
@@ -430,7 +813,7 @@ declare class PyGeneratorMethods {
430
813
  }
431
814
  declare class PyAsyncIterator extends PyProxy {
432
815
  /** @private */
433
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
816
+ static [Symbol.hasInstance](obj: any): obj is PyAsyncIterator;
434
817
  }
435
818
  /** @deprecated Use `import type { PyAsyncIterator } from "pyodide/ffi"` instead */
436
819
  interface PyAsyncIterator extends PyAsyncIteratorMethods {
@@ -456,7 +839,7 @@ declare class PyAsyncIteratorMethods {
456
839
  }
457
840
  declare class PyAsyncGenerator extends PyProxy {
458
841
  /** @private */
459
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
842
+ static [Symbol.hasInstance](obj: any): obj is PyAsyncGenerator;
460
843
  }
461
844
  /** @deprecated Use `import type { PyAsyncGenerator } from "pyodide/ffi"` instead */
462
845
  interface PyAsyncGenerator extends PyAsyncGeneratorMethods {
@@ -495,7 +878,7 @@ declare class PyAsyncGeneratorMethods {
495
878
  }
496
879
  declare class PySequence extends PyProxy {
497
880
  /** @private */
498
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
881
+ static [Symbol.hasInstance](obj: any): obj is PySequence;
499
882
  }
500
883
  /** @deprecated Use `import type { PySequence } from "pyodide/ffi"` instead */
501
884
  interface PySequence extends PySequenceMethods {
@@ -692,7 +1075,7 @@ declare class PySequenceMethods {
692
1075
  }
693
1076
  declare class PyMutableSequence extends PyProxy {
694
1077
  /** @private */
695
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
1078
+ static [Symbol.hasInstance](obj: any): obj is PyMutableSequence;
696
1079
  }
697
1080
  /** @deprecated Use `import type { PyMutableSequence } from "pyodide/ffi"` instead */
698
1081
  interface PyMutableSequence extends PyMutableSequenceMethods {
@@ -776,7 +1159,7 @@ declare class PyMutableSequenceMethods {
776
1159
  }
777
1160
  declare class PyAwaitable extends PyProxy {
778
1161
  /** @private */
779
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
1162
+ static [Symbol.hasInstance](obj: any): obj is PyAwaitable;
780
1163
  }
781
1164
  /** @deprecated Use `import type { PyAwaitable } from "pyodide/ffi"` instead */
782
1165
  interface PyAwaitable extends Promise<any> {
@@ -970,6 +1353,11 @@ declare class PyBufferMethods {
970
1353
  * data, so you might want to pass ``'dataview'`` as the type argument in that
971
1354
  * case.
972
1355
  *
1356
+ * When you are done with the buffer view, you have to call
1357
+ * :js:func:`~PyBufferView.release`. Alternatively, if you declare the buffer
1358
+ * with `using pybuf = proxy.getBuffer()`, JavaScript will automatically
1359
+ * release the buffer at the end of the current scope.
1360
+ *
973
1361
  * @param type The type of the :js:attr:`~pyodide.ffi.PyBufferView.data` field
974
1362
  * in the output. Should be one of: ``"i8"``, ``"u8"``, ``"u8clamped"``,
975
1363
  * ``"i16"``, ``"u16"``, ``"i32"``, ``"u32"``, ``"i32"``, ``"u32"``,
@@ -982,13 +1370,14 @@ declare class PyBufferMethods {
982
1370
  }
983
1371
  declare class PyDict extends PyProxy {
984
1372
  /** @private */
985
- static [Symbol.hasInstance](obj: any): obj is PyProxy;
1373
+ static [Symbol.hasInstance](obj: any): obj is PyDict;
986
1374
  }
987
1375
  /** @deprecated Use `import type { PyDict } from "pyodide/ffi"` instead */
988
1376
  interface PyDict extends PyProxyWithGet, PyProxyWithSet, PyProxyWithHas, PyProxyWithLength, PyIterable {
989
1377
  }
990
1378
  /** @deprecated Use `import type { PyBufferView } from "pyodide/ffi"` instead */
991
1379
  declare class PyBufferView {
1380
+ [Symbol.dispose]: () => void;
992
1381
  /**
993
1382
  * The offset of the first entry of the array. For instance if our array
994
1383
  * is 3d, then you will find ``array[0,0,0]`` at
@@ -1438,6 +1827,17 @@ declare class PyodideAPI_ {
1438
1827
  * @param hostPath The host path to mount. It must be a directory that exists.
1439
1828
  */
1440
1829
  static mountNodeFS(emscriptenPath: string, hostPath: string): void;
1830
+ /**
1831
+ * Use Node.js native socket filesystem instead of Emscripten's SOCKFS.
1832
+ * @experimental
1833
+ */
1834
+ static useNodeSockFS(
1835
+ /**
1836
+ * @hidden
1837
+ */
1838
+ options?: {
1839
+ connect?: ConnectFunc;
1840
+ }): Promise<void>;
1441
1841
  /**
1442
1842
  * Tell Pyodide about Comlink.
1443
1843
  * Necessary to enable importing Comlink proxies into Python.
@@ -1504,6 +1904,25 @@ declare class PyodideAPI_ {
1504
1904
  * @docgroup exports
1505
1905
  */
1506
1906
  export type PyodideAPI = typeof PyodideAPI_;
1907
+ interface EmscriptenSettings {
1908
+ readonly noImageDecoding?: boolean;
1909
+ readonly noAudioDecoding?: boolean;
1910
+ readonly noWasmDecoding?: boolean;
1911
+ readonly preRun: readonly PreRunFunc[];
1912
+ readonly print?: (a: string) => void;
1913
+ readonly printErr?: (a: string) => void;
1914
+ readonly onExit?: (code: number) => void;
1915
+ readonly thisProgram?: string;
1916
+ readonly arguments: readonly string[];
1917
+ readonly instantiateWasm?: (imports: {
1918
+ [key: string]: any;
1919
+ }, successCallback: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void) => void;
1920
+ readonly API: API;
1921
+ readonly locateFile: (file: string) => string;
1922
+ noInitialRun?: boolean;
1923
+ INITIAL_MEMORY?: number;
1924
+ exitCode?: number;
1925
+ }
1507
1926
  /**
1508
1927
  * The Pyodide version.
1509
1928
  *
@@ -1512,6 +1931,7 @@ export type PyodideAPI = typeof PyodideAPI_;
1512
1931
  * version convention.
1513
1932
  */
1514
1933
  export declare const version: string;
1934
+ type CreatePyodideModuleFn = (settings: EmscriptenSettings) => Promise<PyodideModule>;
1515
1935
  /**
1516
1936
  * The configuration options for loading Pyodide.
1517
1937
  */
@@ -1562,16 +1982,12 @@ interface PyodideConfig {
1562
1982
  */
1563
1983
  packageBaseUrl?: string;
1564
1984
  /**
1565
- * Load the full Python standard library. Setting this to false excludes
1566
- * unvendored modules from the standard library.
1567
- * Default: ``false``
1985
+ * Deprecated: This option has no effect.
1568
1986
  */
1569
1987
  fullStdLib?: boolean;
1570
1988
  /**
1571
1989
  * The URL from which to load the standard library ``python_stdlib.zip``
1572
- * file. This URL includes the most of the Python standard library. Some
1573
- * stdlib modules were unvendored, and can be loaded separately
1574
- * with ``fullStdLib: true`` option or by their package name.
1990
+ * file. This URL includes the most of the Python standard library.
1575
1991
  * Default: ```${indexURL}/python_stdlib.zip```
1576
1992
  */
1577
1993
  stdLibURL?: string;
@@ -1678,6 +2094,17 @@ interface PyodideConfig {
1678
2094
  _loadSnapshot?: Uint8Array | ArrayBuffer | PromiseLike<Uint8Array | ArrayBuffer>;
1679
2095
  /** @ignore */
1680
2096
  _snapshotDeserializer?: (obj: any) => any;
2097
+ /**
2098
+ * @experimental
2099
+ * The constructor function to use to create the Pyodide module.
2100
+ * This function can be imported from `pyodide.asm.mjs`
2101
+ * and passed to `loadPyodide` as `createPyodideModule` option.
2102
+ * This is used to work around service workers forbid dynamic import(),
2103
+ * and not intended to be used in other cases.
2104
+ *
2105
+ * Warning: This is an experimental feature and may change in the future.
2106
+ */
2107
+ createPyodideModule?: CreatePyodideModuleFn;
1681
2108
  /** @ignore */
1682
2109
  BUILD_ID?: string;
1683
2110
  /** @ignore */
@@ -1694,7 +2121,6 @@ export type PyodideConfigWithDefaults = Required<PyodideConfig>;
1694
2121
  * @example
1695
2122
  * async function main() {
1696
2123
  * const pyodide = await loadPyodide({
1697
- * fullStdLib: true,
1698
2124
  * stdout: (msg) => console.log(`Pyodide: ${msg}`),
1699
2125
  * });
1700
2126
  * console.log("Loaded Pyodide");