pulse-framework 0.1.46__py3-none-any.whl → 0.1.47__py3-none-any.whl

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.
Files changed (71) hide show
  1. pulse/__init__.py +9 -23
  2. pulse/app.py +2 -24
  3. pulse/codegen/codegen.py +43 -88
  4. pulse/codegen/js.py +35 -5
  5. pulse/codegen/templates/route.py +341 -254
  6. pulse/form.py +1 -1
  7. pulse/helpers.py +40 -8
  8. pulse/hooks/core.py +2 -2
  9. pulse/hooks/effects.py +1 -1
  10. pulse/hooks/init.py +2 -1
  11. pulse/hooks/setup.py +1 -1
  12. pulse/hooks/stable.py +2 -2
  13. pulse/hooks/states.py +2 -2
  14. pulse/html/props.py +3 -2
  15. pulse/html/tags.py +135 -0
  16. pulse/html/tags.pyi +4 -0
  17. pulse/js/__init__.py +110 -0
  18. pulse/js/__init__.pyi +95 -0
  19. pulse/js/_types.py +297 -0
  20. pulse/js/array.py +253 -0
  21. pulse/js/console.py +47 -0
  22. pulse/js/date.py +113 -0
  23. pulse/js/document.py +138 -0
  24. pulse/js/error.py +139 -0
  25. pulse/js/json.py +62 -0
  26. pulse/js/map.py +84 -0
  27. pulse/js/math.py +66 -0
  28. pulse/js/navigator.py +76 -0
  29. pulse/js/number.py +54 -0
  30. pulse/js/object.py +173 -0
  31. pulse/js/promise.py +150 -0
  32. pulse/js/regexp.py +54 -0
  33. pulse/js/set.py +109 -0
  34. pulse/js/string.py +35 -0
  35. pulse/js/weakmap.py +50 -0
  36. pulse/js/weakset.py +45 -0
  37. pulse/js/window.py +199 -0
  38. pulse/messages.py +22 -3
  39. pulse/react_component.py +167 -14
  40. pulse/reactive_extensions.py +5 -5
  41. pulse/render_session.py +144 -34
  42. pulse/renderer.py +80 -115
  43. pulse/routing.py +1 -18
  44. pulse/transpiler/__init__.py +131 -0
  45. pulse/transpiler/builtins.py +731 -0
  46. pulse/transpiler/constants.py +110 -0
  47. pulse/transpiler/context.py +26 -0
  48. pulse/transpiler/errors.py +2 -0
  49. pulse/transpiler/function.py +250 -0
  50. pulse/transpiler/ids.py +16 -0
  51. pulse/transpiler/imports.py +409 -0
  52. pulse/transpiler/js_module.py +274 -0
  53. pulse/transpiler/modules/__init__.py +30 -0
  54. pulse/transpiler/modules/asyncio.py +38 -0
  55. pulse/transpiler/modules/json.py +20 -0
  56. pulse/transpiler/modules/math.py +320 -0
  57. pulse/transpiler/modules/re.py +466 -0
  58. pulse/transpiler/modules/tags.py +268 -0
  59. pulse/transpiler/modules/typing.py +59 -0
  60. pulse/transpiler/nodes.py +1216 -0
  61. pulse/transpiler/py_module.py +119 -0
  62. pulse/transpiler/transpiler.py +938 -0
  63. pulse/transpiler/utils.py +4 -0
  64. pulse/vdom.py +112 -6
  65. {pulse_framework-0.1.46.dist-info → pulse_framework-0.1.47.dist-info}/METADATA +1 -1
  66. pulse_framework-0.1.47.dist-info/RECORD +119 -0
  67. pulse/codegen/imports.py +0 -204
  68. pulse/css.py +0 -155
  69. pulse_framework-0.1.46.dist-info/RECORD +0 -80
  70. {pulse_framework-0.1.46.dist-info → pulse_framework-0.1.47.dist-info}/WHEEL +0 -0
  71. {pulse_framework-0.1.46.dist-info → pulse_framework-0.1.47.dist-info}/entry_points.txt +0 -0
pulse/js/_types.py ADDED
@@ -0,0 +1,297 @@
1
+ """Common type definitions for JavaScript builtin bindings.
2
+
3
+ This module provides type aliases and protocols for proper typing of JS APIs.
4
+ These are purely for static type checking - they have no runtime effect.
5
+ """
6
+
7
+ from collections.abc import Awaitable as _Awaitable
8
+ from collections.abc import Callable as _Callable
9
+ from collections.abc import Iterator as _Iterator
10
+ from typing import Protocol as _Protocol
11
+ from typing import TypeVar as _TypeVar
12
+ from typing import overload as _overload
13
+
14
+ # Type variables
15
+ T = _TypeVar("T")
16
+ T_co = _TypeVar("T_co", covariant=True)
17
+ T_contra = _TypeVar("T_contra", contravariant=True)
18
+ K = _TypeVar("K")
19
+ V = _TypeVar("V")
20
+ R = _TypeVar("R")
21
+
22
+ # Promise result types
23
+ PromiseSettledResult = dict[
24
+ str, T | str
25
+ ] # { status: "fulfilled" | "rejected", value?: T, reason?: any }
26
+
27
+
28
+ # Callback type aliases for collection methods
29
+ # These mirror JavaScript's callback signatures
30
+
31
+ # Array callbacks
32
+ ArrayCallback = _Callable[[T, int, "JSArray[T]"], R]
33
+ ArrayCallbackNoIndex = _Callable[[T], R]
34
+ ArrayPredicate = _Callable[[T, int, "JSArray[T]"], bool]
35
+ ArrayReducer = _Callable[[R, T, int, "JSArray[T]"], R]
36
+ ArrayComparator = _Callable[[T, T], int]
37
+
38
+ # Map callbacks
39
+ MapForEachCallback = _Callable[[V, K, "JSMap[K, V]"], None]
40
+
41
+ # Set callbacks
42
+ SetForEachCallback = _Callable[[T, T, "JSSet[T]"], None]
43
+
44
+
45
+ # JavaScript Iterator protocol
46
+ class JSIterator(_Protocol[T_co]):
47
+ """Protocol for JavaScript Iterator objects."""
48
+
49
+ def next(self) -> "JSIteratorResult[T_co]": ...
50
+
51
+ def __iter__(self) -> "JSIterator[T_co]": ...
52
+
53
+
54
+ class JSIteratorResult(_Protocol[T_co]):
55
+ """Result from JavaScript Iterator.next()."""
56
+
57
+ @property
58
+ def value(self) -> T_co: ...
59
+
60
+ @property
61
+ def done(self) -> bool: ...
62
+
63
+
64
+ # JavaScript Iterable protocol
65
+ class JSIterable(_Protocol[T_co]):
66
+ """Protocol for JavaScript Iterable objects (has Symbol.iterator)."""
67
+
68
+ def __iter__(self) -> _Iterator[T_co]: ...
69
+
70
+
71
+ # Placeholder for forward references within this module
72
+ class JSArray(_Protocol[T_co]):
73
+ """Forward reference for Array type - actual implementation in array.py."""
74
+
75
+ ...
76
+
77
+
78
+ V_co = _TypeVar("V_co", covariant=True)
79
+
80
+
81
+ class JSMap(_Protocol[T_co, V_co]):
82
+ """Forward reference for Map type - actual implementation in map.py."""
83
+
84
+ ...
85
+
86
+
87
+ class JSSet(_Protocol[T_co]):
88
+ """Forward reference for Set type - actual implementation in set.py."""
89
+
90
+ ...
91
+
92
+
93
+ # DOM Element types (for document/window methods)
94
+ class Element(_Protocol):
95
+ """Protocol for DOM Element objects."""
96
+
97
+ @property
98
+ def tagName(self) -> str: ...
99
+
100
+ @property
101
+ def id(self) -> str: ...
102
+
103
+ @property
104
+ def className(self) -> str: ...
105
+
106
+ @property
107
+ def innerHTML(self) -> str: ...
108
+
109
+ @property
110
+ def textContent(self) -> str | None: ...
111
+
112
+ @property
113
+ def parentElement(self) -> "Element | None": ...
114
+
115
+ @property
116
+ def children(self) -> "NodeList[Element]": ...
117
+
118
+ def querySelector(self, selectors: str) -> "Element | None": ...
119
+ def querySelectorAll(self, selectors: str) -> "NodeList[Element]": ...
120
+ def getAttribute(self, name: str) -> str | None: ...
121
+ def setAttribute(self, name: str, value: str) -> None: ...
122
+ def removeAttribute(self, name: str) -> None: ...
123
+ def hasAttribute(self, name: str) -> bool: ...
124
+ def addEventListener(
125
+ self,
126
+ type: str,
127
+ listener: _Callable[..., None],
128
+ options: bool | dict[str, bool] | None = None,
129
+ ) -> None: ...
130
+ def removeEventListener(
131
+ self,
132
+ type: str,
133
+ listener: _Callable[..., None],
134
+ options: bool | dict[str, bool] | None = None,
135
+ ) -> None: ...
136
+ def remove(self) -> None: ...
137
+ def append(self, *nodes: "Element | str") -> None: ...
138
+ def prepend(self, *nodes: "Element | str") -> None: ...
139
+ def replaceWith(self, *nodes: "Element | str") -> None: ...
140
+
141
+
142
+ class HTMLElement(Element, _Protocol):
143
+ """Protocol for HTMLElement objects."""
144
+
145
+ @property
146
+ def style(self) -> "CSSStyleDeclaration": ...
147
+
148
+ @property
149
+ def dataset(self) -> dict[str, str]: ...
150
+
151
+ @property
152
+ def offsetWidth(self) -> int: ...
153
+
154
+ @property
155
+ def offsetHeight(self) -> int: ...
156
+
157
+ def focus(self) -> None: ...
158
+ def blur(self) -> None: ...
159
+ def click(self) -> None: ...
160
+
161
+
162
+ class CSSStyleDeclaration(_Protocol):
163
+ """Protocol for CSSStyleDeclaration."""
164
+
165
+ def getPropertyValue(self, property: str) -> str: ...
166
+ def setProperty(self, property: str, value: str, priority: str = "") -> None: ...
167
+ def removeProperty(self, property: str) -> str: ...
168
+
169
+
170
+ class NodeList(_Protocol[T]):
171
+ """Protocol for NodeList objects."""
172
+
173
+ @property
174
+ def length(self) -> int: ...
175
+
176
+ def item(self, index: int) -> T | None: ...
177
+ def __iter__(self) -> _Iterator[T]: ...
178
+ def __len__(self) -> int: ...
179
+
180
+ @_overload
181
+ def __getitem__(self, index: int) -> T: ...
182
+ @_overload
183
+ def __getitem__(self, index: slice) -> list[T]: ...
184
+
185
+
186
+ class HTMLCollection(_Protocol[T_co]):
187
+ """Protocol for HTMLCollection objects."""
188
+
189
+ @property
190
+ def length(self) -> int: ...
191
+
192
+ def item(self, index: int) -> T_co | None: ...
193
+ def namedItem(self, name: str) -> T_co | None: ...
194
+ def __iter__(self) -> _Iterator[T_co]: ...
195
+ def __len__(self) -> int: ...
196
+
197
+
198
+ # Selection API
199
+ class Selection(_Protocol):
200
+ """Protocol for window.getSelection() result."""
201
+
202
+ @property
203
+ def anchorNode(self) -> Element | None: ...
204
+
205
+ @property
206
+ def focusNode(self) -> Element | None: ...
207
+
208
+ @property
209
+ def isCollapsed(self) -> bool: ...
210
+
211
+ @property
212
+ def rangeCount(self) -> int: ...
213
+
214
+ def getRangeAt(self, index: int) -> "Range": ...
215
+ def collapse(self, node: Element | None, offset: int = 0) -> None: ...
216
+ def selectAllChildren(self, node: Element) -> None: ...
217
+ def removeAllRanges(self) -> None: ...
218
+ def toString(self) -> str: ...
219
+
220
+
221
+ class Range(_Protocol):
222
+ """Protocol for Range objects."""
223
+
224
+ @property
225
+ def startContainer(self) -> Element: ...
226
+
227
+ @property
228
+ def endContainer(self) -> Element: ...
229
+
230
+ @property
231
+ def startOffset(self) -> int: ...
232
+
233
+ @property
234
+ def endOffset(self) -> int: ...
235
+
236
+ @property
237
+ def collapsed(self) -> bool: ...
238
+
239
+ def setStart(self, node: Element, offset: int) -> None: ...
240
+ def setEnd(self, node: Element, offset: int) -> None: ...
241
+ def selectNode(self, node: Element) -> None: ...
242
+ def selectNodeContents(self, node: Element) -> None: ...
243
+ def collapse(self, toStart: bool = False) -> None: ...
244
+ def cloneContents(self) -> Element: ...
245
+ def deleteContents(self) -> None: ...
246
+
247
+
248
+ # Clipboard API
249
+ class Clipboard(_Protocol):
250
+ """Protocol for Navigator.clipboard."""
251
+
252
+ def read(self) -> _Awaitable[list["ClipboardItem"]]: ...
253
+ def readText(self) -> _Awaitable[str]: ...
254
+ def write(self, data: list["ClipboardItem"]) -> _Awaitable[None]: ...
255
+ def writeText(self, text: str) -> _Awaitable[None]: ...
256
+
257
+
258
+ class ClipboardItem(_Protocol):
259
+ """Protocol for ClipboardItem."""
260
+
261
+ @property
262
+ def types(self) -> list[str]: ...
263
+
264
+ def getType(self, type: str) -> _Awaitable[bytes]: ...
265
+
266
+
267
+ # Event types
268
+ class Event(_Protocol):
269
+ """Protocol for Event objects."""
270
+
271
+ @property
272
+ def type(self) -> str: ...
273
+
274
+ @property
275
+ def target(self) -> Element | None: ...
276
+
277
+ @property
278
+ def currentTarget(self) -> Element | None: ...
279
+
280
+ @property
281
+ def bubbles(self) -> bool: ...
282
+
283
+ @property
284
+ def cancelable(self) -> bool: ...
285
+
286
+ @property
287
+ def defaultPrevented(self) -> bool: ...
288
+
289
+ def preventDefault(self) -> None: ...
290
+ def stopPropagation(self) -> None: ...
291
+ def stopImmediatePropagation(self) -> None: ...
292
+
293
+
294
+ # JSON types
295
+ JSONValue = None | bool | int | float | str | list["JSONValue"] | dict[str, "JSONValue"]
296
+ JSONReplacer = list[str | int] | _Callable[[str, JSONValue], JSONValue]
297
+ JSONReviver = _Callable[[str, JSONValue], JSONValue]
pulse/js/array.py ADDED
@@ -0,0 +1,253 @@
1
+ """
2
+ JavaScript Array builtin module.
3
+
4
+ Usage:
5
+ import pulse.js.array as Array
6
+ Array.isArray([1, 2, 3]) # -> Array.isArray([1, 2, 3])
7
+ Array.from([1, 2, 3]) # -> Array.from([1, 2, 3])
8
+
9
+ # Note: For 'from' (Python keyword), use namespace import:
10
+ # import pulse.js.array as Array; Array.from(...)
11
+ # Or use the underscore version for direct import:
12
+ from pulse.js.array import isArray, from_
13
+ isArray([1, 2, 3]) # -> Array.isArray([1, 2, 3])
14
+ from_([1, 2, 3]) # -> Array.from([1, 2, 3])
15
+ """
16
+
17
+ from collections.abc import Callable as _Callable
18
+ from collections.abc import Iterable as _Iterable
19
+ from typing import Any as _Any
20
+ from typing import Generic as _Generic
21
+ from typing import TypeVar as _TypeVar
22
+
23
+ from pulse.transpiler.js_module import register_js_module as _register_js_module
24
+
25
+ T = _TypeVar("T")
26
+ U = _TypeVar("U")
27
+ S = _TypeVar("S")
28
+
29
+
30
+ class Array(_Generic[T]):
31
+ """JavaScript Array - a generic indexed collection.
32
+
33
+ Array[T] represents a JavaScript array containing elements of type T.
34
+ All instance methods preserve the expected generic types.
35
+ """
36
+
37
+ def __init__(self, *args: T | int) -> None:
38
+ """Create an Array.
39
+
40
+ - No arguments: empty array
41
+ - Single int: array with that length
42
+ - Multiple args: array with those elements
43
+ """
44
+ ...
45
+
46
+ # Static methods
47
+ @staticmethod
48
+ def isArray(value: _Any) -> bool:
49
+ """Determine whether the passed value is an Array."""
50
+ ...
51
+
52
+ @staticmethod
53
+ def from_(
54
+ arrayLike: _Iterable[T],
55
+ mapFn: _Callable[[T, int], U] | None = None,
56
+ thisArg: _Any | None = None,
57
+ ) -> "list[U] | list[T]":
58
+ """Create a new Array from an array-like or iterable object."""
59
+ ...
60
+
61
+ @staticmethod
62
+ def of(*elements: T) -> "list[T]":
63
+ """Create a new Array from a variable number of arguments."""
64
+ ...
65
+
66
+ # Accessor properties
67
+ @property
68
+ def length(self) -> int:
69
+ """The number of elements in the array."""
70
+ ...
71
+
72
+ # Mutator methods (modify the array in place)
73
+ def push(self, *items: T) -> int:
74
+ """Add elements to the end; returns new length."""
75
+ ...
76
+
77
+ def pop(self) -> T | None:
78
+ """Remove and return the last element."""
79
+ ...
80
+
81
+ def shift(self) -> T | None:
82
+ """Remove and return the first element."""
83
+ ...
84
+
85
+ def unshift(self, *items: T) -> int:
86
+ """Add elements to the beginning; returns new length."""
87
+ ...
88
+
89
+ def splice(
90
+ self, start: int, deleteCount: int | None = None, *items: T
91
+ ) -> "list[T]":
92
+ """Remove/replace elements and optionally insert new ones."""
93
+ ...
94
+
95
+ def reverse(self) -> "Array[T]":
96
+ """Reverse the array in place."""
97
+ ...
98
+
99
+ def sort(self, compareFn: _Callable[[T, T], int] | None = None) -> "Array[T]":
100
+ """Sort the array in place."""
101
+ ...
102
+
103
+ def fill(self, value: T, start: int = 0, end: int | None = None) -> "Array[T]":
104
+ """Fill all elements with a static value."""
105
+ ...
106
+
107
+ def copyWithin(
108
+ self, target: int, start: int = 0, end: int | None = None
109
+ ) -> "Array[T]":
110
+ """Copy part of the array to another location within it."""
111
+ ...
112
+
113
+ # Accessor methods (return new arrays or values)
114
+ def concat(self, *items: T | "_Iterable[T]") -> "list[T]":
115
+ """Merge arrays and/or values into a new array."""
116
+ ...
117
+
118
+ def slice(self, start: int = 0, end: int | None = None) -> "list[T]":
119
+ """Return a shallow copy of a portion of the array."""
120
+ ...
121
+
122
+ def join(self, separator: str = ",") -> str:
123
+ """Join all elements into a string."""
124
+ ...
125
+
126
+ def indexOf(self, searchElement: T, fromIndex: int = 0) -> int:
127
+ """Return first index of element, or -1 if not found."""
128
+ ...
129
+
130
+ def lastIndexOf(self, searchElement: T, fromIndex: int | None = None) -> int:
131
+ """Return last index of element, or -1 if not found."""
132
+ ...
133
+
134
+ def includes(self, searchElement: T, fromIndex: int = 0) -> bool:
135
+ """Determine whether the array contains the element."""
136
+ ...
137
+
138
+ def at(self, index: int) -> T | None:
139
+ """Return element at index (supports negative indexing)."""
140
+ ...
141
+
142
+ def flat(self, depth: int = 1) -> "list[_Any]":
143
+ """Flatten nested arrays to the specified depth."""
144
+ ...
145
+
146
+ def flatMap(
147
+ self, callback: _Callable[[T, int, "Array[T]"], _Iterable[U]]
148
+ ) -> "list[U]":
149
+ """Map then flatten the result by one level."""
150
+ ...
151
+
152
+ def toReversed(self) -> "list[T]":
153
+ """Return a new reversed array (ES2023)."""
154
+ ...
155
+
156
+ def toSorted(self, compareFn: _Callable[[T, T], int] | None = None) -> "list[T]":
157
+ """Return a new sorted array (ES2023)."""
158
+ ...
159
+
160
+ def toSpliced(
161
+ self, start: int, deleteCount: int | None = None, *items: T
162
+ ) -> "list[T]":
163
+ """Return a new array with elements spliced (ES2023)."""
164
+ ...
165
+
166
+ def with_(self, index: int, value: T) -> "list[T]":
167
+ """Return a new array with element at index replaced (ES2023)."""
168
+ ...
169
+
170
+ # Iteration methods
171
+ def forEach(self, callback: _Callable[[T, int, "Array[T]"], None]) -> None:
172
+ """Execute a function for each element."""
173
+ ...
174
+
175
+ def map(self, callback: _Callable[[T, int, "Array[T]"], U]) -> "list[U]":
176
+ """Create a new array with results of calling callback on each element."""
177
+ ...
178
+
179
+ def filter(self, callback: _Callable[[T, int, "Array[T]"], bool]) -> "list[T]":
180
+ """Create a new array with elements that pass the test."""
181
+ ...
182
+
183
+ def reduce(
184
+ self,
185
+ callback: _Callable[[U, T, int, "Array[T]"], U],
186
+ initialValue: U | None = None,
187
+ ) -> U:
188
+ """Reduce array to a single value (left to right).
189
+
190
+ If no initialValue is provided, the first element is used.
191
+ """
192
+ ...
193
+
194
+ def reduceRight(
195
+ self,
196
+ callback: _Callable[[U, T, int, "Array[T]"], U],
197
+ initialValue: U | None = None,
198
+ ) -> U:
199
+ """Reduce array to a single value (right to left).
200
+
201
+ If no initialValue is provided, the last element is used.
202
+ """
203
+ ...
204
+
205
+ def find(self, callback: _Callable[[T, int, "Array[T]"], bool]) -> T | None:
206
+ """Return first element satisfying the callback."""
207
+ ...
208
+
209
+ def findIndex(self, callback: _Callable[[T, int, "Array[T]"], bool]) -> int:
210
+ """Return index of first element satisfying the callback, or -1."""
211
+ ...
212
+
213
+ def findLast(self, callback: _Callable[[T, int, "Array[T]"], bool]) -> T | None:
214
+ """Return last element satisfying the callback (ES2023)."""
215
+ ...
216
+
217
+ def findLastIndex(self, callback: _Callable[[T, int, "Array[T]"], bool]) -> int:
218
+ """Return index of last element satisfying the callback, or -1 (ES2023)."""
219
+ ...
220
+
221
+ def every(self, callback: _Callable[[T, int, "Array[T]"], bool]) -> bool:
222
+ """Test whether all elements pass the callback."""
223
+ ...
224
+
225
+ def some(self, callback: _Callable[[T, int, "Array[T]"], bool]) -> bool:
226
+ """Test whether at least one element passes the callback."""
227
+ ...
228
+
229
+ # Iterator methods
230
+ def keys(self) -> _Iterable[int]:
231
+ """Return an iterator of array indices."""
232
+ ...
233
+
234
+ def values(self) -> _Iterable[T]:
235
+ """Return an iterator of array values."""
236
+ ...
237
+
238
+ def entries(self) -> _Iterable[tuple[int, T]]:
239
+ """Return an iterator of [index, value] pairs."""
240
+ ...
241
+
242
+ # String conversion
243
+ def toString(self) -> str:
244
+ """Return a string representing the array."""
245
+ ...
246
+
247
+ def toLocaleString(self) -> str:
248
+ """Return a localized string representing the array."""
249
+ ...
250
+
251
+
252
+ # Self-register this module as a JS builtin
253
+ _register_js_module(name="Array", global_scope=True)
pulse/js/console.py ADDED
@@ -0,0 +1,47 @@
1
+ """
2
+ JavaScript Console builtin module.
3
+
4
+ Usage:
5
+ import pulse.js.console as console
6
+ console.log("Hello") # -> console.log("Hello")
7
+ console.error("Error") # -> console.error("Error")
8
+ console.assert(True, "msg") # -> console.assert(True, "msg")
9
+
10
+ # Note: For 'assert' (Python keyword), use namespace import:
11
+ # import pulse.js.console as console; console.assert(...)
12
+ # Or use the underscore version for direct import:
13
+ from pulse.js.console import log, error, warn, info, debug, assert_
14
+ log("Hello") # -> console.log("Hello")
15
+ error("Error") # -> console.error("Error")
16
+ assert_(True, "msg") # -> console.assert(True, "msg")
17
+ """
18
+
19
+ from typing import Any as _Any
20
+
21
+ from pulse.transpiler.js_module import register_js_module as _register_js_module
22
+
23
+
24
+ # Methods (type stubs for IDE support)
25
+ def assert_(condition: bool, *data: _Any) -> None: ...
26
+ def clear() -> None: ...
27
+ def count(label: str | None = None) -> None: ...
28
+ def countReset(label: str | None = None) -> None: ...
29
+ def debug(*data: _Any) -> None: ...
30
+ def dir(item: _Any, options: dict[str, _Any] | None = None) -> None: ...
31
+ def dirxml(*data: _Any) -> None: ...
32
+ def error(*data: _Any) -> None: ...
33
+ def group(*label: _Any) -> None: ...
34
+ def groupCollapsed(*label: _Any) -> None: ...
35
+ def groupEnd() -> None: ...
36
+ def info(*data: _Any) -> None: ...
37
+ def log(*data: _Any) -> None: ...
38
+ def table(tabularData: _Any, properties: list[str] | None = None) -> None: ...
39
+ def time(label: str | None = None) -> None: ...
40
+ def timeEnd(label: str | None = None) -> None: ...
41
+ def timeLog(label: str | None = None, *data: _Any) -> None: ...
42
+ def trace(*data: _Any) -> None: ...
43
+ def warn(*data: _Any) -> None: ...
44
+
45
+
46
+ # Self-register this module as a JS builtin
47
+ _register_js_module(name="console")
pulse/js/date.py ADDED
@@ -0,0 +1,113 @@
1
+ """
2
+ JavaScript Date builtin module.
3
+
4
+ Usage:
5
+ import pulse.js.date as Date
6
+ Date.now() # -> Date.now()
7
+ Date.parse("2023-01-01") # -> Date.parse("2023-01-01")
8
+
9
+ from pulse.js.date import now, parse
10
+ now() # -> Date.now()
11
+ parse("2023-01-01") # -> Date.parse("2023-01-01")
12
+ """
13
+
14
+ from typing import Any as _Any
15
+
16
+ from pulse.transpiler.js_module import register_js_module as _register_js_module
17
+
18
+
19
+ class Date:
20
+ """Class for JavaScript Date instances."""
21
+
22
+ def __init__(self, value: int | str | None = None): ...
23
+
24
+ @staticmethod
25
+ def now() -> float: ...
26
+
27
+ @staticmethod
28
+ def parse(dateString: str) -> float: ...
29
+
30
+ @staticmethod
31
+ def UTC(
32
+ year: int,
33
+ month: int,
34
+ date: int | None = None,
35
+ hours: int | None = None,
36
+ minutes: int | None = None,
37
+ seconds: int | None = None,
38
+ ms: int | None = None,
39
+ ) -> float: ...
40
+
41
+ def getDate(self) -> int: ...
42
+ def getDay(self) -> int: ...
43
+ def getFullYear(self) -> int: ...
44
+ def getHours(self) -> int: ...
45
+ def getMilliseconds(self) -> int: ...
46
+ def getMinutes(self) -> int: ...
47
+ def getMonth(self) -> int: ...
48
+ def getSeconds(self) -> int: ...
49
+ def getTime(self) -> float: ...
50
+ def getTimezoneOffset(self) -> int: ...
51
+ def getUTCDate(self) -> int: ...
52
+ def getUTCDay(self) -> int: ...
53
+ def getUTCFullYear(self) -> int: ...
54
+ def getUTCHours(self) -> int: ...
55
+ def getUTCMilliseconds(self) -> int: ...
56
+ def getUTCMinutes(self) -> int: ...
57
+ def getUTCMonth(self) -> int: ...
58
+ def getUTCSeconds(self) -> int: ...
59
+ def setDate(self, date: int) -> float: ...
60
+ def setFullYear(
61
+ self, year: int, month: int | None = None, date: int | None = None
62
+ ) -> float: ...
63
+ def setHours(
64
+ self,
65
+ hours: int,
66
+ min: int | None = None,
67
+ sec: int | None = None,
68
+ ms: int | None = None,
69
+ ) -> float: ...
70
+ def setMilliseconds(self, ms: int) -> float: ...
71
+ def setMinutes(
72
+ self, min: int, sec: int | None = None, ms: int | None = None
73
+ ) -> float: ...
74
+ def setMonth(self, month: int, date: int | None = None) -> float: ...
75
+ def setSeconds(self, sec: int, ms: int | None = None) -> float: ...
76
+ def setTime(self, time: float) -> float: ...
77
+ def setUTCDate(self, date: int) -> float: ...
78
+ def setUTCFullYear(
79
+ self, year: int, month: int | None = None, date: int | None = None
80
+ ) -> float: ...
81
+ def setUTCHours(
82
+ self,
83
+ hours: int,
84
+ min: int | None = None,
85
+ sec: int | None = None,
86
+ ms: int | None = None,
87
+ ) -> float: ...
88
+ def setUTCMilliseconds(self, ms: int) -> float: ...
89
+ def setUTCMinutes(
90
+ self, min: int, sec: int | None = None, ms: int | None = None
91
+ ) -> float: ...
92
+ def setUTCMonth(self, month: int, date: int | None = None) -> float: ...
93
+ def setUTCSeconds(self, sec: int, ms: int | None = None) -> float: ...
94
+ def toDateString(self) -> str: ...
95
+ def toISOString(self) -> str: ...
96
+ def toJSON(self, key: _Any | None = None) -> str: ...
97
+ def toLocaleDateString(
98
+ self, locales: str | None = None, options: _Any | None = None
99
+ ) -> str: ...
100
+ def toLocaleString(
101
+ self, locales: str | None = None, options: _Any | None = None
102
+ ) -> str: ...
103
+ def toLocaleTimeString(
104
+ self, locales: str | None = None, options: _Any | None = None
105
+ ) -> str: ...
106
+ def toString(self) -> str: ...
107
+ def toTimeString(self) -> str: ...
108
+ def toUTCString(self) -> str: ...
109
+ def valueOf(self) -> float: ...
110
+
111
+
112
+ # Self-register this module as a JS builtin
113
+ _register_js_module(name="Date", global_scope=True)