pyjs 0.0.1__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 (146) hide show
  1. pyjs/__init__.py +6 -0
  2. pyjs/__main__.py +6 -0
  3. pyjs/cli.py +816 -0
  4. pyjs/decorators.py +170 -0
  5. pyjs/docs/__init__.py +6 -0
  6. pyjs/docs/builder.py +351 -0
  7. pyjs/docs/cli.py +55 -0
  8. pyjs/docs/config.py +45 -0
  9. pyjs/docs/favicon.svg +18 -0
  10. pyjs/docs/markdown.py +61 -0
  11. pyjs/docs/models.py +38 -0
  12. pyjs/docs/navigation.py +61 -0
  13. pyjs/docs/style.css +901 -0
  14. pyjs/docs/ui.py +349 -0
  15. pyjs/nativescript/__init__.py +77 -0
  16. pyjs/scaffolding/__init__.py +418 -0
  17. pyjs/scaffolding/templates/app/README.md.template +33 -0
  18. pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__PYJS_PACKAGE__.py.template +81 -0
  19. pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__init__.py.template +0 -0
  20. pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__main__.py.template +5 -0
  21. pyjs/scaffolding/templates/app/tests/test_app.py.template +22 -0
  22. pyjs/scaffolding/templates/app/tests/test_browser_app.py.template +19 -0
  23. pyjs/scaffolding/templates/app_test.py.template +8 -0
  24. pyjs/server.py +468 -0
  25. pyjs/skills/pyjs/SKILL.md +161 -0
  26. pyjs/state.py +101 -0
  27. pyjs/testing/__init__.py +3 -0
  28. pyjs/testing/android.py +248 -0
  29. pyjs/testing/artifacts.py +37 -0
  30. pyjs/testing/assertion_rewriter.py +125 -0
  31. pyjs/testing/builder.py +191 -0
  32. pyjs/testing/capture.py +133 -0
  33. pyjs/testing/client/__init__.py +1 -0
  34. pyjs/testing/client/app.py +718 -0
  35. pyjs/testing/client/assertions.py +49 -0
  36. pyjs/testing/client/runtime.py +123 -0
  37. pyjs/testing/client/sidebar.py +377 -0
  38. pyjs/testing/client/state.py +107 -0
  39. pyjs/testing/client/viewer.py +361 -0
  40. pyjs/testing/daemon.py +641 -0
  41. pyjs/testing/helpers.py +155 -0
  42. pyjs/testing/protocol.py +56 -0
  43. pyjs/testing/pytest_plugin.py +797 -0
  44. pyjs/testing/web.py +97 -0
  45. pyjs/testing/webgpu.py +27 -0
  46. pyjs/tooling/__init__.py +4 -0
  47. pyjs/tooling/android.py +138 -0
  48. pyjs/tooling/browser.py +676 -0
  49. pyjs/tooling/command.py +75 -0
  50. pyjs/tooling/nativescript.py +156 -0
  51. pyjs/tooling/node.py +170 -0
  52. pyjs/tooling/perf.py +163 -0
  53. pyjs/transpiler/__init__.py +23 -0
  54. pyjs/transpiler/_builtins.py +485 -0
  55. pyjs/transpiler/analyzer.py +1495 -0
  56. pyjs/transpiler/objects.py +1015 -0
  57. pyjs/transpiler/source.py +189 -0
  58. pyjs/transpiler/transpiler.py +748 -0
  59. pyjs/transpiler/utils.py +150 -0
  60. pyjs/web/__init__.py +5 -0
  61. pyjs/web/console.py +16 -0
  62. pyjs/web/dom.py +1529 -0
  63. pyjs/web/domx.py +474 -0
  64. pyjs/web/dragdrop.py +102 -0
  65. pyjs/web/events.py +1306 -0
  66. pyjs/web/files.py +203 -0
  67. pyjs/web/geometry.py +475 -0
  68. pyjs/web/html.py +927 -0
  69. pyjs/web/indexeddb.py +410 -0
  70. pyjs/web/javascript.py +112 -0
  71. pyjs/web/network.py +193 -0
  72. pyjs/web/ssr.py +70 -0
  73. pyjs/web/streams.py +17 -0
  74. pyjs/web/svg.py +684 -0
  75. pyjs/web/timers.py +29 -0
  76. pyjs/web/ui/__init__.py +18 -0
  77. pyjs/web/ui/accordion.py +166 -0
  78. pyjs/web/ui/alert.py +52 -0
  79. pyjs/web/ui/alert_dialog.py +102 -0
  80. pyjs/web/ui/aspect_ratio.py +12 -0
  81. pyjs/web/ui/attachment.py +80 -0
  82. pyjs/web/ui/avatar.py +105 -0
  83. pyjs/web/ui/badge.py +48 -0
  84. pyjs/web/ui/breadcrumb.py +85 -0
  85. pyjs/web/ui/bubble.py +38 -0
  86. pyjs/web/ui/button.py +86 -0
  87. pyjs/web/ui/calendar.py +124 -0
  88. pyjs/web/ui/card.py +58 -0
  89. pyjs/web/ui/carousel.py +99 -0
  90. pyjs/web/ui/chart.py +56 -0
  91. pyjs/web/ui/checkbox.py +31 -0
  92. pyjs/web/ui/collapsible.py +71 -0
  93. pyjs/web/ui/combobox.py +36 -0
  94. pyjs/web/ui/command.py +118 -0
  95. pyjs/web/ui/context_menu.py +65 -0
  96. pyjs/web/ui/date_picker.py +24 -0
  97. pyjs/web/ui/dialog.py +289 -0
  98. pyjs/web/ui/direction.py +9 -0
  99. pyjs/web/ui/drawer.py +72 -0
  100. pyjs/web/ui/dropdown_menu.py +239 -0
  101. pyjs/web/ui/empty.py +69 -0
  102. pyjs/web/ui/field.py +96 -0
  103. pyjs/web/ui/floating.py +90 -0
  104. pyjs/web/ui/hover_card.py +128 -0
  105. pyjs/web/ui/input.py +48 -0
  106. pyjs/web/ui/input_group.py +77 -0
  107. pyjs/web/ui/input_otp.py +76 -0
  108. pyjs/web/ui/item.py +78 -0
  109. pyjs/web/ui/kbd.py +26 -0
  110. pyjs/web/ui/label.py +14 -0
  111. pyjs/web/ui/marker.py +29 -0
  112. pyjs/web/ui/menubar.py +52 -0
  113. pyjs/web/ui/message.py +57 -0
  114. pyjs/web/ui/message_scroller.py +45 -0
  115. pyjs/web/ui/native_select.py +47 -0
  116. pyjs/web/ui/navigation_menu.py +110 -0
  117. pyjs/web/ui/pagination.py +63 -0
  118. pyjs/web/ui/popover.py +217 -0
  119. pyjs/web/ui/progress.py +44 -0
  120. pyjs/web/ui/radio_group.py +129 -0
  121. pyjs/web/ui/resizable.py +194 -0
  122. pyjs/web/ui/scroll_area.py +29 -0
  123. pyjs/web/ui/select.py +83 -0
  124. pyjs/web/ui/separator.py +24 -0
  125. pyjs/web/ui/sheet.py +77 -0
  126. pyjs/web/ui/sidebar.py +162 -0
  127. pyjs/web/ui/skeleton.py +15 -0
  128. pyjs/web/ui/slider.py +46 -0
  129. pyjs/web/ui/sonner.py +70 -0
  130. pyjs/web/ui/spinner.py +14 -0
  131. pyjs/web/ui/switch.py +35 -0
  132. pyjs/web/ui/table.py +84 -0
  133. pyjs/web/ui/tabs.py +167 -0
  134. pyjs/web/ui/text.py +15 -0
  135. pyjs/web/ui/textarea.py +28 -0
  136. pyjs/web/ui/toggle.py +109 -0
  137. pyjs/web/ui/tooltip.py +164 -0
  138. pyjs/web/ui/typography.py +79 -0
  139. pyjs/web/url.py +76 -0
  140. pyjs/web/webgpu.py +496 -0
  141. pyjs-0.0.1.dist-info/METADATA +441 -0
  142. pyjs-0.0.1.dist-info/RECORD +146 -0
  143. pyjs-0.0.1.dist-info/WHEEL +5 -0
  144. pyjs-0.0.1.dist-info/entry_points.txt +5 -0
  145. pyjs-0.0.1.dist-info/licenses/LICENSE +28 -0
  146. pyjs-0.0.1.dist-info/top_level.txt +1 -0
pyjs/web/ssr.py ADDED
@@ -0,0 +1,70 @@
1
+ import html
2
+ from io import StringIO
3
+
4
+ from pyjs.web.domx import HTMLElement
5
+
6
+ VOID_ELEMENTS = {
7
+ "area",
8
+ "base",
9
+ "br",
10
+ "col",
11
+ "embed",
12
+ "hr",
13
+ "img",
14
+ "input",
15
+ "link",
16
+ "meta",
17
+ "param",
18
+ "source",
19
+ "track",
20
+ "wbr",
21
+ }
22
+
23
+
24
+ class RawHTML(str):
25
+ """HTML that has been explicitly marked as trusted by server code."""
26
+
27
+
28
+ def raw_html(value: str) -> RawHTML:
29
+ return RawHTML(value)
30
+
31
+
32
+ def write_html(parent: HTMLElement, output):
33
+ tag_name = parent.tagName.lower()
34
+ start = [f"<{tag_name}"]
35
+ for attribute in parent.attributes:
36
+ name = attribute.name
37
+ value = attribute.value
38
+ if value is not None:
39
+ start.append(f' {name}="{html.escape(str(value), quote=True)}"')
40
+ for name, value in parent.dataset.map.items():
41
+ if value is not None:
42
+ start.append(f' data-{name}="{html.escape(str(value), quote=True)}"')
43
+
44
+ if parent.childNodes:
45
+ start.append(">")
46
+ output.write("".join(start))
47
+ for child in parent.childNodes:
48
+ if isinstance(child, HTMLElement):
49
+ write_html(child, output)
50
+ else:
51
+ value = child.data
52
+ if isinstance(value, RawHTML):
53
+ output.write(value)
54
+ else:
55
+ output.write(html.escape(value, quote=False))
56
+ output.write(f"</{tag_name}>")
57
+ elif tag_name not in VOID_ELEMENTS:
58
+ output.write("".join(start) + f"></{tag_name}>")
59
+ else:
60
+ output.write("".join(start) + "/>")
61
+
62
+
63
+ def render_html(element: HTMLElement) -> str:
64
+ output = StringIO()
65
+ write_html(element, output)
66
+ return output.getvalue()
67
+
68
+
69
+ def render_document(element: HTMLElement) -> str:
70
+ return "<!doctype html>\n" + render_html(element)
pyjs/web/streams.py ADDED
@@ -0,0 +1,17 @@
1
+ from pyjs import js
2
+
3
+
4
+ @js(builtin=True)
5
+ class ReadableStream:
6
+ def __init__(self, source: object | None = None, strategy: object | None = None):
7
+ self.locked: bool = False
8
+
9
+ async def cancel(self, reason: object | None = None) -> None: ...
10
+
11
+ def getReader(self, options: object | None = None) -> object: ...
12
+
13
+ def pipeThrough(self, transform: object, options: object | None = None) -> ReadableStream: ...
14
+
15
+ async def pipeTo(self, destination: object, options: object | None = None) -> None: ...
16
+
17
+ def tee(self) -> list[ReadableStream]: ...