pulse-framework 0.1.51__py3-none-any.whl → 0.1.53__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.53.dist-info}/METADATA +1 -1
- pulse_framework-0.1.53.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.53.dist-info}/WHEEL +0 -0
- {pulse_framework-0.1.51.dist-info → pulse_framework-0.1.53.dist-info}/entry_points.txt +0 -0
pulse/transpiler/errors.py
CHANGED
|
@@ -1,2 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"""Transpiler-specific error classes."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import ast
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TranspileError(Exception):
|
|
9
|
+
"""Error during transpilation with optional source location."""
|
|
10
|
+
|
|
11
|
+
message: str
|
|
12
|
+
node: ast.expr | ast.stmt | ast.excepthandler | None
|
|
13
|
+
source: str | None
|
|
14
|
+
filename: str | None
|
|
15
|
+
func_name: str | None
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
message: str,
|
|
20
|
+
*,
|
|
21
|
+
node: ast.expr | ast.stmt | ast.excepthandler | None = None,
|
|
22
|
+
source: str | None = None,
|
|
23
|
+
filename: str | None = None,
|
|
24
|
+
func_name: str | None = None,
|
|
25
|
+
) -> None:
|
|
26
|
+
self.message = message
|
|
27
|
+
self.node = node
|
|
28
|
+
self.source = source
|
|
29
|
+
self.filename = filename
|
|
30
|
+
self.func_name = func_name
|
|
31
|
+
super().__init__(self._format_message())
|
|
32
|
+
|
|
33
|
+
def _format_message(self) -> str:
|
|
34
|
+
"""Format the error message with source location if available."""
|
|
35
|
+
parts = [self.message]
|
|
36
|
+
|
|
37
|
+
if self.node is not None and hasattr(self.node, "lineno"):
|
|
38
|
+
loc_parts: list[str] = []
|
|
39
|
+
if self.func_name:
|
|
40
|
+
loc_parts.append(f"in {self.func_name}")
|
|
41
|
+
if self.filename:
|
|
42
|
+
loc_parts.append(f"at {self.filename}:{self.node.lineno}")
|
|
43
|
+
else:
|
|
44
|
+
loc_parts.append(f"at line {self.node.lineno}")
|
|
45
|
+
if hasattr(self.node, "col_offset"):
|
|
46
|
+
loc_parts[-1] += f":{self.node.col_offset}"
|
|
47
|
+
|
|
48
|
+
if loc_parts:
|
|
49
|
+
parts.append(" ".join(loc_parts))
|
|
50
|
+
|
|
51
|
+
# Show the source line if available
|
|
52
|
+
if self.source:
|
|
53
|
+
lines = self.source.splitlines()
|
|
54
|
+
if 0 < self.node.lineno <= len(lines):
|
|
55
|
+
source_line = lines[self.node.lineno - 1]
|
|
56
|
+
parts.append(f"\n {source_line}")
|
|
57
|
+
# Add caret pointing to column
|
|
58
|
+
if hasattr(self.node, "col_offset"):
|
|
59
|
+
parts.append(" " + " " * self.node.col_offset + "^")
|
|
60
|
+
|
|
61
|
+
return "\n".join(parts) if len(parts) > 1 else parts[0]
|
|
62
|
+
|
|
63
|
+
def with_context(
|
|
64
|
+
self,
|
|
65
|
+
*,
|
|
66
|
+
node: ast.expr | ast.stmt | ast.excepthandler | None = None,
|
|
67
|
+
source: str | None = None,
|
|
68
|
+
filename: str | None = None,
|
|
69
|
+
func_name: str | None = None,
|
|
70
|
+
) -> TranspileError:
|
|
71
|
+
"""Return a new TranspileError with additional context."""
|
|
72
|
+
return TranspileError(
|
|
73
|
+
self.message,
|
|
74
|
+
node=node or self.node,
|
|
75
|
+
source=source or self.source,
|
|
76
|
+
filename=filename or self.filename,
|
|
77
|
+
func_name=func_name or self.func_name,
|
|
78
|
+
)
|