pulse-framework 0.1.51__py3-none-any.whl → 0.1.52__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.
- pulse/__init__.py +542 -562
- pulse/_examples.py +29 -0
- pulse/app.py +0 -14
- pulse/cli/cmd.py +96 -80
- pulse/cli/dependencies.py +10 -41
- pulse/cli/folder_lock.py +3 -3
- pulse/cli/helpers.py +40 -67
- pulse/cli/logging.py +102 -0
- pulse/cli/packages.py +16 -0
- pulse/cli/processes.py +40 -23
- pulse/codegen/codegen.py +70 -35
- pulse/codegen/js.py +2 -4
- pulse/codegen/templates/route.py +94 -146
- pulse/component.py +115 -0
- pulse/components/for_.py +1 -1
- pulse/components/if_.py +1 -1
- pulse/components/react_router.py +16 -22
- pulse/{html → dom}/events.py +1 -1
- pulse/{html → dom}/props.py +6 -6
- pulse/{html → dom}/tags.py +11 -11
- pulse/dom/tags.pyi +480 -0
- pulse/form.py +7 -6
- pulse/hooks/init.py +1 -13
- pulse/js/__init__.py +37 -41
- pulse/js/__init__.pyi +22 -2
- pulse/js/_types.py +5 -3
- pulse/js/array.py +121 -38
- pulse/js/console.py +9 -9
- pulse/js/date.py +22 -19
- pulse/js/document.py +8 -4
- pulse/js/error.py +12 -14
- pulse/js/json.py +4 -3
- pulse/js/map.py +17 -7
- pulse/js/math.py +2 -2
- pulse/js/navigator.py +4 -4
- pulse/js/number.py +8 -8
- pulse/js/object.py +9 -13
- pulse/js/promise.py +25 -9
- pulse/js/regexp.py +6 -6
- pulse/js/set.py +20 -8
- pulse/js/string.py +7 -7
- pulse/js/weakmap.py +6 -6
- pulse/js/weakset.py +6 -6
- pulse/js/window.py +17 -14
- pulse/messages.py +1 -4
- pulse/react_component.py +3 -1001
- pulse/render_session.py +74 -66
- pulse/renderer.py +311 -238
- pulse/routing.py +1 -10
- pulse/transpiler/__init__.py +84 -114
- pulse/transpiler/builtins.py +661 -343
- pulse/transpiler/errors.py +78 -2
- pulse/transpiler/function.py +463 -133
- pulse/transpiler/id.py +18 -0
- pulse/transpiler/imports.py +230 -325
- pulse/transpiler/js_module.py +218 -209
- pulse/transpiler/modules/__init__.py +16 -13
- pulse/transpiler/modules/asyncio.py +45 -26
- pulse/transpiler/modules/json.py +12 -8
- pulse/transpiler/modules/math.py +161 -216
- pulse/transpiler/modules/pulse/__init__.py +5 -0
- pulse/transpiler/modules/pulse/tags.py +231 -0
- pulse/transpiler/modules/typing.py +33 -28
- pulse/transpiler/nodes.py +1607 -923
- pulse/transpiler/py_module.py +118 -95
- pulse/transpiler/react_component.py +51 -0
- pulse/transpiler/transpiler.py +593 -437
- pulse/transpiler/vdom.py +255 -0
- {pulse_framework-0.1.51.dist-info → pulse_framework-0.1.52.dist-info}/METADATA +1 -1
- pulse_framework-0.1.52.dist-info/RECORD +120 -0
- pulse/html/tags.pyi +0 -470
- pulse/transpiler/constants.py +0 -110
- pulse/transpiler/context.py +0 -26
- pulse/transpiler/ids.py +0 -16
- pulse/transpiler/modules/re.py +0 -466
- pulse/transpiler/modules/tags.py +0 -268
- pulse/transpiler/utils.py +0 -4
- pulse/vdom.py +0 -599
- pulse_framework-0.1.51.dist-info/RECORD +0 -119
- /pulse/{html → dom}/__init__.py +0 -0
- /pulse/{html → dom}/elements.py +0 -0
- /pulse/{html → dom}/svg.py +0 -0
- {pulse_framework-0.1.51.dist-info → pulse_framework-0.1.52.dist-info}/WHEEL +0 -0
- {pulse_framework-0.1.51.dist-info → pulse_framework-0.1.52.dist-info}/entry_points.txt +0 -0
pulse/routing.py
CHANGED
|
@@ -3,10 +3,9 @@ from collections.abc import Sequence
|
|
|
3
3
|
from dataclasses import dataclass, field
|
|
4
4
|
from typing import TypedDict, cast, override
|
|
5
5
|
|
|
6
|
+
from pulse.component import Component
|
|
6
7
|
from pulse.env import env
|
|
7
|
-
from pulse.react_component import ReactComponent
|
|
8
8
|
from pulse.reactive_extensions import ReactiveDict
|
|
9
|
-
from pulse.vdom import Component
|
|
10
9
|
|
|
11
10
|
# angle brackets cannot appear in a regular URL path, this ensures no name conflicts
|
|
12
11
|
LAYOUT_INDICATOR = "<layout>"
|
|
@@ -158,7 +157,6 @@ class Route:
|
|
|
158
157
|
segments: list[PathSegment]
|
|
159
158
|
render: Component[[]]
|
|
160
159
|
children: Sequence["Route | Layout"]
|
|
161
|
-
components: Sequence[ReactComponent[...]] | None
|
|
162
160
|
is_index: bool
|
|
163
161
|
is_dynamic: bool
|
|
164
162
|
dev: bool
|
|
@@ -168,7 +166,6 @@ class Route:
|
|
|
168
166
|
path: str,
|
|
169
167
|
render: Component[[]],
|
|
170
168
|
children: "Sequence[Route | Layout] | None" = None,
|
|
171
|
-
components: "Sequence[ReactComponent[...]] | None" = None,
|
|
172
169
|
dev: bool = False,
|
|
173
170
|
):
|
|
174
171
|
self.path = ensure_relative_path(path)
|
|
@@ -176,7 +173,6 @@ class Route:
|
|
|
176
173
|
|
|
177
174
|
self.render = render
|
|
178
175
|
self.children = children or []
|
|
179
|
-
self.components = components
|
|
180
176
|
self.dev = dev
|
|
181
177
|
self.parent: Route | Layout | None = None
|
|
182
178
|
|
|
@@ -249,19 +245,16 @@ def replace_layout_indicator(path_list: list[str], value: str):
|
|
|
249
245
|
class Layout:
|
|
250
246
|
render: Component[...]
|
|
251
247
|
children: Sequence["Route | Layout"]
|
|
252
|
-
components: Sequence[ReactComponent[...]] | None
|
|
253
248
|
dev: bool
|
|
254
249
|
|
|
255
250
|
def __init__(
|
|
256
251
|
self,
|
|
257
252
|
render: "Component[...]",
|
|
258
253
|
children: "Sequence[Route | Layout] | None" = None,
|
|
259
|
-
components: "Sequence[ReactComponent[...]] | None" = None,
|
|
260
254
|
dev: bool = False,
|
|
261
255
|
):
|
|
262
256
|
self.render = render
|
|
263
257
|
self.children = children or []
|
|
264
|
-
self.components = components
|
|
265
258
|
self.dev = dev
|
|
266
259
|
self.parent: Route | Layout | None = None
|
|
267
260
|
# 1-based sibling index assigned by RouteTree at each level
|
|
@@ -352,14 +345,12 @@ def filter_dev_routes(routes: Sequence[Route | Layout]) -> list[Route | Layout]:
|
|
|
352
345
|
path=route.path,
|
|
353
346
|
render=route.render,
|
|
354
347
|
children=filtered_children,
|
|
355
|
-
components=route.components,
|
|
356
348
|
dev=route.dev,
|
|
357
349
|
)
|
|
358
350
|
else: # Layout
|
|
359
351
|
filtered_route = Layout(
|
|
360
352
|
render=route.render,
|
|
361
353
|
children=filtered_children,
|
|
362
|
-
components=route.components,
|
|
363
354
|
dev=route.dev,
|
|
364
355
|
)
|
|
365
356
|
filtered.append(filtered_route)
|
pulse/transpiler/__init__.py
CHANGED
|
@@ -1,131 +1,101 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""v2 transpiler with pure data node AST."""
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
# Ensure built-in Python modules (e.g., math) are registered on import.
|
|
4
|
+
from pulse.transpiler import modules as _modules # noqa: F401
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
For advanced use cases (custom transpilers, AST manipulation, module registration),
|
|
9
|
-
import from this module:
|
|
10
|
-
|
|
11
|
-
from pulse.transpiler import JSExpr, JsTranspiler, register_module, ...
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
# Core types
|
|
15
|
-
# Builtins system
|
|
16
|
-
from pulse.transpiler.builtins import ALL_METHODS as ALL_METHODS
|
|
6
|
+
# Builtins
|
|
17
7
|
from pulse.transpiler.builtins import BUILTINS as BUILTINS
|
|
18
|
-
from pulse.transpiler.builtins import DICT_METHODS as DICT_METHODS
|
|
19
|
-
from pulse.transpiler.builtins import LIST_METHODS as LIST_METHODS
|
|
20
|
-
from pulse.transpiler.builtins import METHOD_CLASSES as METHOD_CLASSES
|
|
21
|
-
from pulse.transpiler.builtins import SET_METHODS as SET_METHODS
|
|
22
|
-
from pulse.transpiler.builtins import STR_METHODS as STR_METHODS
|
|
23
|
-
from pulse.transpiler.builtins import BuiltinMethods as BuiltinMethods
|
|
24
|
-
from pulse.transpiler.builtins import DictMethods as DictMethods
|
|
25
|
-
from pulse.transpiler.builtins import ListMethods as ListMethods
|
|
26
|
-
from pulse.transpiler.builtins import SetMethods as SetMethods
|
|
27
|
-
from pulse.transpiler.builtins import StringMethods as StringMethods
|
|
28
8
|
from pulse.transpiler.builtins import emit_method as emit_method
|
|
29
9
|
|
|
30
|
-
#
|
|
31
|
-
from pulse.transpiler.
|
|
32
|
-
from pulse.transpiler.constants import JsConstant as JsConstant
|
|
33
|
-
from pulse.transpiler.constants import JsPrimitive as JsPrimitive
|
|
34
|
-
from pulse.transpiler.constants import JsValue as JsValue
|
|
35
|
-
from pulse.transpiler.constants import JsVar as JsVar
|
|
36
|
-
from pulse.transpiler.constants import const_to_js as const_to_js
|
|
37
|
-
from pulse.transpiler.constants import jsify as jsify
|
|
38
|
-
|
|
39
|
-
# Context
|
|
40
|
-
from pulse.transpiler.context import interpreted_mode as interpreted_mode
|
|
41
|
-
from pulse.transpiler.context import is_interpreted_mode as is_interpreted_mode
|
|
42
|
-
from pulse.transpiler.errors import JSCompilationError as JSCompilationError
|
|
10
|
+
# Errors
|
|
11
|
+
from pulse.transpiler.errors import TranspileError as TranspileError
|
|
43
12
|
|
|
44
13
|
# Function system
|
|
45
14
|
from pulse.transpiler.function import FUNCTION_CACHE as FUNCTION_CACHE
|
|
15
|
+
|
|
16
|
+
# Constant hoisting
|
|
17
|
+
from pulse.transpiler.function import Constant as Constant
|
|
46
18
|
from pulse.transpiler.function import JsFunction as JsFunction
|
|
19
|
+
from pulse.transpiler.function import analyze_deps as analyze_deps
|
|
20
|
+
from pulse.transpiler.function import clear_function_cache as clear_function_cache
|
|
21
|
+
from pulse.transpiler.function import (
|
|
22
|
+
collect_function_graph as collect_function_graph,
|
|
23
|
+
)
|
|
47
24
|
from pulse.transpiler.function import javascript as javascript
|
|
25
|
+
from pulse.transpiler.function import registered_constants as registered_constants
|
|
26
|
+
from pulse.transpiler.function import registered_functions as registered_functions
|
|
48
27
|
|
|
49
|
-
#
|
|
50
|
-
from pulse.transpiler.
|
|
51
|
-
from pulse.transpiler.
|
|
52
|
-
from pulse.transpiler.imports import CssImport as CssImport
|
|
53
|
-
from pulse.transpiler.imports import Import as Import
|
|
28
|
+
# ID generator
|
|
29
|
+
from pulse.transpiler.id import next_id as next_id
|
|
30
|
+
from pulse.transpiler.id import reset_id_counter as reset_id_counter
|
|
54
31
|
|
|
55
|
-
# Import
|
|
32
|
+
# Import utilities
|
|
33
|
+
from pulse.transpiler.imports import Import as Import
|
|
34
|
+
from pulse.transpiler.imports import ImportKind as ImportKind
|
|
35
|
+
from pulse.transpiler.imports import caller_file as caller_file
|
|
56
36
|
from pulse.transpiler.imports import clear_import_registry as clear_import_registry
|
|
57
|
-
from pulse.transpiler.imports import
|
|
58
|
-
from pulse.transpiler.imports import
|
|
37
|
+
from pulse.transpiler.imports import get_registered_imports as get_registered_imports
|
|
38
|
+
from pulse.transpiler.imports import is_absolute_path as is_absolute_path
|
|
39
|
+
from pulse.transpiler.imports import is_local_path as is_local_path
|
|
40
|
+
from pulse.transpiler.imports import is_relative_path as is_relative_path
|
|
59
41
|
|
|
60
|
-
#
|
|
61
|
-
from pulse.transpiler.js_module import JS_MODULES as JS_MODULES
|
|
42
|
+
# JS module system
|
|
62
43
|
from pulse.transpiler.js_module import JsModule as JsModule
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
from pulse.transpiler.nodes import
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
from pulse.transpiler.nodes import
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
from pulse.transpiler.nodes import
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
from pulse.transpiler.nodes import
|
|
77
|
-
from pulse.transpiler.nodes import
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
from pulse.transpiler.nodes import
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
from pulse.transpiler.nodes import
|
|
84
|
-
from pulse.transpiler.nodes import
|
|
85
|
-
from pulse.transpiler.nodes import
|
|
86
|
-
from pulse.transpiler.nodes import
|
|
87
|
-
from pulse.transpiler.nodes import
|
|
88
|
-
from pulse.transpiler.nodes import
|
|
89
|
-
from pulse.transpiler.nodes import
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
from pulse.transpiler.nodes import
|
|
95
|
-
from pulse.transpiler.nodes import
|
|
96
|
-
from pulse.transpiler.nodes import
|
|
97
|
-
from pulse.transpiler.nodes import
|
|
98
|
-
from pulse.transpiler.nodes import
|
|
99
|
-
from pulse.transpiler.nodes import
|
|
100
|
-
from pulse.transpiler.nodes import
|
|
101
|
-
from pulse.transpiler.nodes import
|
|
102
|
-
from pulse.transpiler.nodes import
|
|
103
|
-
from pulse.transpiler.nodes import
|
|
104
|
-
from pulse.transpiler.nodes import
|
|
105
|
-
from pulse.transpiler.nodes import
|
|
106
|
-
from pulse.transpiler.nodes import
|
|
107
|
-
from pulse.transpiler.nodes import
|
|
108
|
-
from pulse.transpiler.nodes import
|
|
109
|
-
from pulse.transpiler.nodes import
|
|
110
|
-
from pulse.transpiler.nodes import
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
from pulse.transpiler.nodes import
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
from pulse.transpiler.
|
|
117
|
-
from pulse.transpiler.nodes import JSWhile as JSWhile
|
|
118
|
-
from pulse.transpiler.nodes import JSXElement as JSXElement
|
|
119
|
-
from pulse.transpiler.nodes import JSXFragment as JSXFragment
|
|
120
|
-
from pulse.transpiler.nodes import JSXProp as JSXProp
|
|
121
|
-
from pulse.transpiler.nodes import JSXSpreadProp as JSXSpreadProp
|
|
122
|
-
from pulse.transpiler.nodes import is_primary as is_primary
|
|
123
|
-
|
|
124
|
-
# Module registration - Python modules
|
|
125
|
-
from pulse.transpiler.py_module import PY_MODULES as PY_MODULES
|
|
126
|
-
from pulse.transpiler.py_module import PyModule as PyModule
|
|
127
|
-
from pulse.transpiler.py_module import PyModuleExpr as PyModuleExpr
|
|
128
|
-
from pulse.transpiler.py_module import register_module as register_module
|
|
44
|
+
|
|
45
|
+
# Global registry
|
|
46
|
+
from pulse.transpiler.nodes import EXPR_REGISTRY as EXPR_REGISTRY
|
|
47
|
+
from pulse.transpiler.nodes import UNDEFINED as UNDEFINED
|
|
48
|
+
|
|
49
|
+
# Expression nodes
|
|
50
|
+
from pulse.transpiler.nodes import Array as Array
|
|
51
|
+
from pulse.transpiler.nodes import Arrow as Arrow
|
|
52
|
+
|
|
53
|
+
# Statement nodes
|
|
54
|
+
from pulse.transpiler.nodes import Assign as Assign
|
|
55
|
+
from pulse.transpiler.nodes import Binary as Binary
|
|
56
|
+
from pulse.transpiler.nodes import Block as Block
|
|
57
|
+
from pulse.transpiler.nodes import Break as Break
|
|
58
|
+
from pulse.transpiler.nodes import Call as Call
|
|
59
|
+
|
|
60
|
+
# Type aliases
|
|
61
|
+
from pulse.transpiler.nodes import Continue as Continue
|
|
62
|
+
|
|
63
|
+
# Data nodes
|
|
64
|
+
from pulse.transpiler.nodes import Element as Element
|
|
65
|
+
from pulse.transpiler.nodes import Expr as Expr
|
|
66
|
+
from pulse.transpiler.nodes import ExprStmt as ExprStmt
|
|
67
|
+
from pulse.transpiler.nodes import ForOf as ForOf
|
|
68
|
+
from pulse.transpiler.nodes import Function as Function
|
|
69
|
+
from pulse.transpiler.nodes import Identifier as Identifier
|
|
70
|
+
from pulse.transpiler.nodes import If as If
|
|
71
|
+
|
|
72
|
+
# JSX wrapper
|
|
73
|
+
from pulse.transpiler.nodes import Jsx as Jsx
|
|
74
|
+
from pulse.transpiler.nodes import Literal as Literal
|
|
75
|
+
from pulse.transpiler.nodes import Member as Member
|
|
76
|
+
from pulse.transpiler.nodes import New as New
|
|
77
|
+
from pulse.transpiler.nodes import Node as Node
|
|
78
|
+
from pulse.transpiler.nodes import Object as Object
|
|
79
|
+
from pulse.transpiler.nodes import Prop as Prop
|
|
80
|
+
from pulse.transpiler.nodes import PulseNode as PulseNode
|
|
81
|
+
from pulse.transpiler.nodes import Return as Return
|
|
82
|
+
from pulse.transpiler.nodes import Spread as Spread
|
|
83
|
+
from pulse.transpiler.nodes import Stmt as Stmt
|
|
84
|
+
from pulse.transpiler.nodes import Subscript as Subscript
|
|
85
|
+
from pulse.transpiler.nodes import Template as Template
|
|
86
|
+
from pulse.transpiler.nodes import Ternary as Ternary
|
|
87
|
+
from pulse.transpiler.nodes import Throw as Throw
|
|
88
|
+
from pulse.transpiler.nodes import Unary as Unary
|
|
89
|
+
from pulse.transpiler.nodes import Undefined as Undefined
|
|
90
|
+
from pulse.transpiler.nodes import Value as Value
|
|
91
|
+
from pulse.transpiler.nodes import While as While
|
|
92
|
+
|
|
93
|
+
# Emit
|
|
94
|
+
from pulse.transpiler.nodes import emit as emit
|
|
95
|
+
|
|
96
|
+
# React components (JSX imports with typed call signature)
|
|
97
|
+
from pulse.transpiler.react_component import react_component as react_component
|
|
129
98
|
|
|
130
99
|
# Transpiler
|
|
131
|
-
from pulse.transpiler.transpiler import
|
|
100
|
+
from pulse.transpiler.transpiler import Transpiler as Transpiler
|
|
101
|
+
from pulse.transpiler.transpiler import transpile as transpile
|