11"""
2+ stub file for type hints & documentations for the native module
23@see https://typing.readthedocs.io/en/latest/source/stubs.html
34"""
45
@@ -25,6 +26,25 @@ def eval(code: str, evalOpts: EvalOptions = {}, /) -> _typing.Any:
2526 """
2627
2728
29+ def require (moduleIdentifier : str , / ) -> JSObjectProxy :
30+ """
31+ Return the exports of a CommonJS module identified by `moduleIdentifier`, using standard CommonJS semantics
32+ """
33+
34+
35+ def new (ctor : JSFunctionProxy ) -> _typing .Callable [..., _typing .Any ]:
36+ """
37+ Wrap the JS new operator, emitting a lambda which constructs a new
38+ JS object upon invocation
39+ """
40+
41+
42+ def typeof (jsval : _typing .Any , / ):
43+ """
44+ This is the JS `typeof` operator, wrapped in a function so that it can be used easily from Python.
45+ """
46+
47+
2848def wait () -> _typing .Awaitable [None ]:
2949 """
3050 Block until all asynchronous jobs (Promise/setTimeout/etc.) finish.
@@ -43,6 +63,12 @@ def stop() -> None:
4363 """
4464
4565
66+ def runProgramModule (filename : str , argv : _typing .List [str ], extraPaths : _typing .List [str ] = []) -> None :
67+ """
68+ Load and evaluate a program (main) module. Program modules must be written in JavaScript.
69+ """
70+
71+
4672def isCompilableUnit (code : str ) -> bool :
4773 """
4874 Hint if a string might be compilable Javascript without actual evaluation
@@ -55,6 +81,14 @@ def collect() -> None:
5581 """
5682
5783
84+ def internalBinding (namespace : str ) -> JSObjectProxy :
85+ """
86+ INTERNAL USE ONLY
87+
88+ See function declarations in ./builtin_modules/internal-binding.d.ts
89+ """
90+
91+
5892class JSFunctionProxy ():
5993 """
6094 JavaScript Function proxy
@@ -81,13 +115,60 @@ class JSMethodProxy(JSFunctionProxy, object):
81115 print(myObject.value) # 42.0
82116 """
83117
84- def __init__ (self ) -> None :
85- """
86- PythonMonkey init function
87- """
118+ def __init__ (self ) -> None : "deleted"
119+
120+
121+ class JSObjectProxy (dict ):
122+ """
123+ JavaScript Object proxy dict
124+ """
125+
126+ def __init__ (self ) -> None : "deleted"
127+
128+
129+ class JSArrayProxy (list ):
130+ """
131+ JavaScript Array proxy
132+ """
133+
134+ def __init__ (self ) -> None : "deleted"
135+
136+
137+ class JSArrayIterProxy (_typing .Iterator ):
138+ """
139+ JavaScript Array Iterator proxy
140+ """
141+
142+ def __init__ (self ) -> None : "deleted"
143+
144+
145+ class JSStringProxy (str ):
146+ """
147+ JavaScript String proxy
148+ """
149+
150+ def __init__ (self ) -> None : "deleted"
151+
152+
153+ class bigint (int ):
154+ """
155+ Representing JavaScript BigInt in Python
156+ """
157+
158+
159+ class SpiderMonkeyError (Exception ):
160+ """
161+ Representing a corresponding JS Error in Python
162+ """
88163
89164
90165null = _typing .Annotated [
91- _typing .NewType ("pythonmonkey.null" , object ),
92- "Representing the JS null type in Python using a singleton object" ,
166+ _typing .NewType ("pythonmonkey.null" , object ),
167+ "Representing the JS null type in Python using a singleton object" ,
168+ ]
169+
170+
171+ globalThis = _typing .Annotated [
172+ JSObjectProxy ,
173+ "A Python Dict which is equivalent to the globalThis object in JavaScript" ,
93174]
0 commit comments