pulse-framework 0.1.50__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.
Files changed (85) hide show
  1. pulse/__init__.py +542 -562
  2. pulse/_examples.py +29 -0
  3. pulse/app.py +0 -14
  4. pulse/cli/cmd.py +96 -80
  5. pulse/cli/dependencies.py +10 -41
  6. pulse/cli/folder_lock.py +3 -3
  7. pulse/cli/helpers.py +40 -67
  8. pulse/cli/logging.py +102 -0
  9. pulse/cli/packages.py +16 -0
  10. pulse/cli/processes.py +40 -23
  11. pulse/codegen/codegen.py +70 -35
  12. pulse/codegen/js.py +2 -4
  13. pulse/codegen/templates/route.py +94 -146
  14. pulse/component.py +115 -0
  15. pulse/components/for_.py +1 -1
  16. pulse/components/if_.py +1 -1
  17. pulse/components/react_router.py +16 -22
  18. pulse/{html → dom}/events.py +1 -1
  19. pulse/{html → dom}/props.py +6 -6
  20. pulse/{html → dom}/tags.py +11 -11
  21. pulse/dom/tags.pyi +480 -0
  22. pulse/form.py +7 -6
  23. pulse/hooks/init.py +1 -13
  24. pulse/js/__init__.py +37 -41
  25. pulse/js/__init__.pyi +22 -2
  26. pulse/js/_types.py +5 -3
  27. pulse/js/array.py +121 -38
  28. pulse/js/console.py +9 -9
  29. pulse/js/date.py +22 -19
  30. pulse/js/document.py +8 -4
  31. pulse/js/error.py +12 -14
  32. pulse/js/json.py +4 -3
  33. pulse/js/map.py +17 -7
  34. pulse/js/math.py +2 -2
  35. pulse/js/navigator.py +4 -4
  36. pulse/js/number.py +8 -8
  37. pulse/js/object.py +9 -13
  38. pulse/js/promise.py +25 -9
  39. pulse/js/regexp.py +6 -6
  40. pulse/js/set.py +20 -8
  41. pulse/js/string.py +7 -7
  42. pulse/js/weakmap.py +6 -6
  43. pulse/js/weakset.py +6 -6
  44. pulse/js/window.py +17 -14
  45. pulse/messages.py +1 -4
  46. pulse/react_component.py +3 -999
  47. pulse/render_session.py +74 -66
  48. pulse/renderer.py +311 -238
  49. pulse/routing.py +1 -10
  50. pulse/serializer.py +11 -1
  51. pulse/transpiler/__init__.py +84 -114
  52. pulse/transpiler/builtins.py +661 -343
  53. pulse/transpiler/errors.py +78 -2
  54. pulse/transpiler/function.py +463 -133
  55. pulse/transpiler/id.py +18 -0
  56. pulse/transpiler/imports.py +230 -325
  57. pulse/transpiler/js_module.py +218 -209
  58. pulse/transpiler/modules/__init__.py +16 -13
  59. pulse/transpiler/modules/asyncio.py +45 -26
  60. pulse/transpiler/modules/json.py +12 -8
  61. pulse/transpiler/modules/math.py +161 -216
  62. pulse/transpiler/modules/pulse/__init__.py +5 -0
  63. pulse/transpiler/modules/pulse/tags.py +231 -0
  64. pulse/transpiler/modules/typing.py +33 -28
  65. pulse/transpiler/nodes.py +1607 -923
  66. pulse/transpiler/py_module.py +118 -95
  67. pulse/transpiler/react_component.py +51 -0
  68. pulse/transpiler/transpiler.py +593 -437
  69. pulse/transpiler/vdom.py +255 -0
  70. {pulse_framework-0.1.50.dist-info → pulse_framework-0.1.52.dist-info}/METADATA +1 -1
  71. pulse_framework-0.1.52.dist-info/RECORD +120 -0
  72. pulse/html/tags.pyi +0 -470
  73. pulse/transpiler/constants.py +0 -110
  74. pulse/transpiler/context.py +0 -26
  75. pulse/transpiler/ids.py +0 -16
  76. pulse/transpiler/modules/re.py +0 -466
  77. pulse/transpiler/modules/tags.py +0 -268
  78. pulse/transpiler/utils.py +0 -4
  79. pulse/vdom.py +0 -667
  80. pulse_framework-0.1.50.dist-info/RECORD +0 -119
  81. /pulse/{html → dom}/__init__.py +0 -0
  82. /pulse/{html → dom}/elements.py +0 -0
  83. /pulse/{html → dom}/svg.py +0 -0
  84. {pulse_framework-0.1.50.dist-info → pulse_framework-0.1.52.dist-info}/WHEEL +0 -0
  85. {pulse_framework-0.1.50.dist-info → pulse_framework-0.1.52.dist-info}/entry_points.txt +0 -0
@@ -1,2 +1,78 @@
1
- class JSCompilationError(Exception):
2
- pass
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
+ )