Skip to content
File

Blob: src/pyodide/types/Pyodide.d.ts

typescript41 lines
1// Copyright (c) 2026 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5declare type AnyClass<T = any> = new (...args: any[]) => T;
6 
7declare type Handler = (...args: any[]) => any;
8 
9declare type PyCallable = ((...args: any[]) => any) & {
10 call: (...args: any[]) => any;
11 callRelaxed: (...args: any[]) => any;
12 callPromising: (...args: any[]) => any;
13 callKwargs: (...args: any[]) => any;
14 callWithOptions?: (
15 options: { relaxed?: boolean; promising?: boolean; kwargs?: boolean },
16 ...args: any[]
17 ) => any;
18 destroy(): void;
19};
20 
21declare type PyDict = object;
22 
23interface PyModule {
24 [handlerName: string]: PyCallable;
25}
26 
27interface Pyodide {
28 _module: Module;
29 runPython: (
30 code: string,
31 opts?: { globals?: PyDict; filename?: string }
32 ) => any;
33 registerJsModule: (handle: string, mod: object) => void;
34 pyimport: (moduleName: string) => PyModule;
35 FS: FS;
36 loadPackage: (names: string | string[], options: object) => Promise<any[]>;
37 setStdout: (options?: any) => void;
38 setStderr: (options?: any) => void;
39 version: API['version'];
40}