@@ -11,12 +11,28 @@ declare const python: {
1111 } ;
1212 /** Python `print` */
1313 print ( ...values : any ) : void ;
14- /** Python `sys.stdout.write`. Write the given string to stdout. */
15- stdout_write ( s : string ) : void ;
16- /** Python `sys.stderr.write`. Write the given string to stderr. */
17- stderr_write ( s : string ) : void ;
14+ /** Python `eval` */
15+ eval ( code : string , globals ?: Record < string , any > , locals ?: Record < string , any > ) : any ;
16+ /** Python `exec` */
17+ exec ( code : string , globals ?: Record < string , any > , locals ?: Record < string , any > ) : void ;
18+ /** Python `sys.stdout`. */
19+ stdout : {
20+ /** Write the given string to stdout. */
21+ write ( s : string ) : number ;
22+ read ( n : number ) : string ;
23+ } ;
24+ /** Python `sys.stderr`. */
25+ stderr : {
26+ /** Write the given string to stderr. */
27+ write ( s : string ) : number ;
28+ read ( n : number ) : string ;
29+ } ;
1830 /** Python `os.getenv`. Get an environment variable, return undefined if it doesn't exist. */
1931 getenv ( key : string ) : string | undefined ;
32+ /** Python `exit`. Exit the program. */
33+ exit ( exitCode : number ) : never ;
34+ /** Loads a python module using importlib, prefills it with an exports object and returns the module. */
35+ load ( filename : string ) : object ;
2036 /** Python `sys.path` */
2137 paths : string [ ] ;
2238} ;
@@ -25,7 +41,12 @@ declare const python: {
2541declare function pmEval ( code : string ) : any ;
2642
2743// Expose our own `console` as a property of the global object
28- declare const console : import ( "console" ) . Console ;
44+ // XXX: ↓↓↓ we must use "var" here
45+ declare var console : import ( "console" ) . Console ;
46+
47+ // Expose `atob`/`btoa` as properties of the global object
48+ declare var atob : typeof import ( "base64" ) . atob ;
49+ declare var btoa : typeof import ( "base64" ) . btoa ;
2950
3051// Keep this in sync with both https://hg.mozilla.org/releases/mozilla-esr102/file/a03fde6/js/public/Promise.h#l331
3152// and https://github.com/nodejs/node/blob/v20.2.0/deps/v8/include/v8-promise.h#L30
0 commit comments