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/docs/markdown.py ADDED
@@ -0,0 +1,61 @@
1
+ import re
2
+ from pathlib import Path
3
+
4
+ import markdown
5
+ import yaml
6
+
7
+ from .models import Heading
8
+
9
+ FRONT_MATTER = re.compile(r"\A---\s*\n(.*?)\n---\s*(?:\n|\Z)", re.DOTALL)
10
+ DESCRIPTION = re.compile(r"<p>(.*?)</p>", re.DOTALL)
11
+ TAGS = re.compile(r"<[^>]+>")
12
+
13
+
14
+ def parse_document(path: Path) -> tuple[dict, str]:
15
+ source = path.read_text(encoding="utf-8")
16
+ match = FRONT_MATTER.match(source)
17
+ if match is None:
18
+ return {}, source
19
+ metadata = yaml.safe_load(match.group(1)) or {}
20
+ if not isinstance(metadata, dict):
21
+ raise ValueError(f"{path}: front matter must be a mapping")
22
+ return metadata, source[match.end() :]
23
+
24
+
25
+ def render_markdown(source: str) -> tuple[str, list[Heading], str]:
26
+ renderer = markdown.Markdown(
27
+ extensions=[
28
+ "admonition",
29
+ "attr_list",
30
+ "codehilite",
31
+ "fenced_code",
32
+ "footnotes",
33
+ "md_in_html",
34
+ "sane_lists",
35
+ "tables",
36
+ "toc",
37
+ ],
38
+ extension_configs={
39
+ "codehilite": {
40
+ "css_class": "highlight",
41
+ "guess_lang": False,
42
+ "linenums": False,
43
+ },
44
+ "toc": {"permalink": True, "toc_depth": "2-4"},
45
+ },
46
+ output_format="html",
47
+ )
48
+ html = renderer.convert(source)
49
+ headings = []
50
+
51
+ def collect(tokens):
52
+ for token in tokens:
53
+ headings.append(Heading(token["id"], TAGS.sub("", token["name"]), token["level"]))
54
+ collect(token.get("children", []))
55
+
56
+ collect(renderer.toc_tokens)
57
+ description_match = DESCRIPTION.search(html)
58
+ description = ""
59
+ if description_match is not None:
60
+ description = TAGS.sub("", description_match.group(1)).strip()
61
+ return html, headings, description
pyjs/docs/models.py ADDED
@@ -0,0 +1,38 @@
1
+ from dataclasses import dataclass, field
2
+ from pathlib import Path
3
+
4
+
5
+ @dataclass
6
+ class Heading:
7
+ id: str
8
+ title: str
9
+ level: int
10
+
11
+
12
+ @dataclass
13
+ class Page:
14
+ source_path: Path
15
+ relative_path: Path
16
+ output_path: Path
17
+ route: str
18
+ title: str
19
+ description: str
20
+ order: float
21
+ hidden: bool
22
+ html: str
23
+ headings: list[Heading]
24
+ previous: Page | None = None
25
+ next: Page | None = None
26
+
27
+
28
+ @dataclass
29
+ class NavNode:
30
+ title: str
31
+ order: float = 1000
32
+ page: Page | None = None
33
+ children: list[NavNode] = field(default_factory=list)
34
+
35
+ def sort(self):
36
+ self.children.sort(key=lambda node: (node.order, node.title.lower()))
37
+ for child in self.children:
38
+ child.sort()
@@ -0,0 +1,61 @@
1
+ from pathlib import Path
2
+
3
+ from .models import NavNode, Page
4
+
5
+
6
+ def humanize(value: str) -> str:
7
+ return value.replace("-", " ").replace("_", " ").strip().title()
8
+
9
+
10
+ def build_navigation(pages: list[Page]) -> NavNode:
11
+ root = NavNode("")
12
+ directories: dict[tuple[str, ...], NavNode] = {(): root}
13
+ for page in pages:
14
+ if page.hidden:
15
+ continue
16
+ parts = page.relative_path.with_suffix("").parts
17
+ directory_parts = parts[:-1]
18
+ parent = root
19
+ for depth in range(1, len(directory_parts) + 1):
20
+ key = directory_parts[:depth]
21
+ if key not in directories:
22
+ directories[key] = NavNode(humanize(key[-1]))
23
+ parent.children.append(directories[key])
24
+ parent = directories[key]
25
+ if parts[-1] == "index":
26
+ if parent is root:
27
+ root.children.append(NavNode(page.title, page.order, page))
28
+ continue
29
+ parent.title = page.title
30
+ parent.page = page
31
+ parent.order = page.order
32
+ else:
33
+ parent.children.append(NavNode(page.title, page.order, page))
34
+ if parent.page is None:
35
+ parent.order = min(parent.order, page.order)
36
+ root.sort()
37
+ return root
38
+
39
+
40
+ def navigation_pages(root: NavNode) -> list[Page]:
41
+ pages = []
42
+
43
+ def visit(node: NavNode):
44
+ if node.page is not None:
45
+ pages.append(node.page)
46
+ for child in node.children:
47
+ visit(child)
48
+
49
+ for child in root.children:
50
+ visit(child)
51
+ return pages
52
+
53
+
54
+ def route_for(relative_path: Path) -> str:
55
+ path = relative_path.with_suffix("")
56
+ parts = path.parts
57
+ if parts == ("index",):
58
+ return "/"
59
+ if parts[-1] == "index":
60
+ parts = parts[:-1]
61
+ return "/" + "/".join(parts) + "/"