1
1
"""
2
+ stub file for type hints & documentations for the native module
2
3
@see https://typing.readthedocs.io/en/latest/source/stubs.html
3
4
"""
4
5
@@ -25,6 +26,25 @@ def eval(code: str, evalOpts: EvalOptions = {}, /) -> _typing.Any:
25
26
"""
26
27
27
28
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
+
28
48
def wait () -> _typing .Awaitable [None ]:
29
49
"""
30
50
Block until all asynchronous jobs (Promise/setTimeout/etc.) finish.
@@ -43,6 +63,12 @@ def stop() -> None:
43
63
"""
44
64
45
65
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
+
46
72
def isCompilableUnit (code : str ) -> bool :
47
73
"""
48
74
Hint if a string might be compilable Javascript without actual evaluation
@@ -55,6 +81,14 @@ def collect() -> None:
55
81
"""
56
82
57
83
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
+
58
92
class JSFunctionProxy ():
59
93
"""
60
94
JavaScript Function proxy
@@ -81,13 +115,60 @@ class JSMethodProxy(JSFunctionProxy, object):
81
115
print(myObject.value) # 42.0
82
116
"""
83
117
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
+ """
88
163
89
164
90
165
null = _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" ,
93
174
]
0 commit comments