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.
- pyjs/__init__.py +6 -0
- pyjs/__main__.py +6 -0
- pyjs/cli.py +816 -0
- pyjs/decorators.py +170 -0
- pyjs/docs/__init__.py +6 -0
- pyjs/docs/builder.py +351 -0
- pyjs/docs/cli.py +55 -0
- pyjs/docs/config.py +45 -0
- pyjs/docs/favicon.svg +18 -0
- pyjs/docs/markdown.py +61 -0
- pyjs/docs/models.py +38 -0
- pyjs/docs/navigation.py +61 -0
- pyjs/docs/style.css +901 -0
- pyjs/docs/ui.py +349 -0
- pyjs/nativescript/__init__.py +77 -0
- pyjs/scaffolding/__init__.py +418 -0
- pyjs/scaffolding/templates/app/README.md.template +33 -0
- pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__PYJS_PACKAGE__.py.template +81 -0
- pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__init__.py.template +0 -0
- pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__main__.py.template +5 -0
- pyjs/scaffolding/templates/app/tests/test_app.py.template +22 -0
- pyjs/scaffolding/templates/app/tests/test_browser_app.py.template +19 -0
- pyjs/scaffolding/templates/app_test.py.template +8 -0
- pyjs/server.py +468 -0
- pyjs/skills/pyjs/SKILL.md +161 -0
- pyjs/state.py +101 -0
- pyjs/testing/__init__.py +3 -0
- pyjs/testing/android.py +248 -0
- pyjs/testing/artifacts.py +37 -0
- pyjs/testing/assertion_rewriter.py +125 -0
- pyjs/testing/builder.py +191 -0
- pyjs/testing/capture.py +133 -0
- pyjs/testing/client/__init__.py +1 -0
- pyjs/testing/client/app.py +718 -0
- pyjs/testing/client/assertions.py +49 -0
- pyjs/testing/client/runtime.py +123 -0
- pyjs/testing/client/sidebar.py +377 -0
- pyjs/testing/client/state.py +107 -0
- pyjs/testing/client/viewer.py +361 -0
- pyjs/testing/daemon.py +641 -0
- pyjs/testing/helpers.py +155 -0
- pyjs/testing/protocol.py +56 -0
- pyjs/testing/pytest_plugin.py +797 -0
- pyjs/testing/web.py +97 -0
- pyjs/testing/webgpu.py +27 -0
- pyjs/tooling/__init__.py +4 -0
- pyjs/tooling/android.py +138 -0
- pyjs/tooling/browser.py +676 -0
- pyjs/tooling/command.py +75 -0
- pyjs/tooling/nativescript.py +156 -0
- pyjs/tooling/node.py +170 -0
- pyjs/tooling/perf.py +163 -0
- pyjs/transpiler/__init__.py +23 -0
- pyjs/transpiler/_builtins.py +485 -0
- pyjs/transpiler/analyzer.py +1495 -0
- pyjs/transpiler/objects.py +1015 -0
- pyjs/transpiler/source.py +189 -0
- pyjs/transpiler/transpiler.py +748 -0
- pyjs/transpiler/utils.py +150 -0
- pyjs/web/__init__.py +5 -0
- pyjs/web/console.py +16 -0
- pyjs/web/dom.py +1529 -0
- pyjs/web/domx.py +474 -0
- pyjs/web/dragdrop.py +102 -0
- pyjs/web/events.py +1306 -0
- pyjs/web/files.py +203 -0
- pyjs/web/geometry.py +475 -0
- pyjs/web/html.py +927 -0
- pyjs/web/indexeddb.py +410 -0
- pyjs/web/javascript.py +112 -0
- pyjs/web/network.py +193 -0
- pyjs/web/ssr.py +70 -0
- pyjs/web/streams.py +17 -0
- pyjs/web/svg.py +684 -0
- pyjs/web/timers.py +29 -0
- pyjs/web/ui/__init__.py +18 -0
- pyjs/web/ui/accordion.py +166 -0
- pyjs/web/ui/alert.py +52 -0
- pyjs/web/ui/alert_dialog.py +102 -0
- pyjs/web/ui/aspect_ratio.py +12 -0
- pyjs/web/ui/attachment.py +80 -0
- pyjs/web/ui/avatar.py +105 -0
- pyjs/web/ui/badge.py +48 -0
- pyjs/web/ui/breadcrumb.py +85 -0
- pyjs/web/ui/bubble.py +38 -0
- pyjs/web/ui/button.py +86 -0
- pyjs/web/ui/calendar.py +124 -0
- pyjs/web/ui/card.py +58 -0
- pyjs/web/ui/carousel.py +99 -0
- pyjs/web/ui/chart.py +56 -0
- pyjs/web/ui/checkbox.py +31 -0
- pyjs/web/ui/collapsible.py +71 -0
- pyjs/web/ui/combobox.py +36 -0
- pyjs/web/ui/command.py +118 -0
- pyjs/web/ui/context_menu.py +65 -0
- pyjs/web/ui/date_picker.py +24 -0
- pyjs/web/ui/dialog.py +289 -0
- pyjs/web/ui/direction.py +9 -0
- pyjs/web/ui/drawer.py +72 -0
- pyjs/web/ui/dropdown_menu.py +239 -0
- pyjs/web/ui/empty.py +69 -0
- pyjs/web/ui/field.py +96 -0
- pyjs/web/ui/floating.py +90 -0
- pyjs/web/ui/hover_card.py +128 -0
- pyjs/web/ui/input.py +48 -0
- pyjs/web/ui/input_group.py +77 -0
- pyjs/web/ui/input_otp.py +76 -0
- pyjs/web/ui/item.py +78 -0
- pyjs/web/ui/kbd.py +26 -0
- pyjs/web/ui/label.py +14 -0
- pyjs/web/ui/marker.py +29 -0
- pyjs/web/ui/menubar.py +52 -0
- pyjs/web/ui/message.py +57 -0
- pyjs/web/ui/message_scroller.py +45 -0
- pyjs/web/ui/native_select.py +47 -0
- pyjs/web/ui/navigation_menu.py +110 -0
- pyjs/web/ui/pagination.py +63 -0
- pyjs/web/ui/popover.py +217 -0
- pyjs/web/ui/progress.py +44 -0
- pyjs/web/ui/radio_group.py +129 -0
- pyjs/web/ui/resizable.py +194 -0
- pyjs/web/ui/scroll_area.py +29 -0
- pyjs/web/ui/select.py +83 -0
- pyjs/web/ui/separator.py +24 -0
- pyjs/web/ui/sheet.py +77 -0
- pyjs/web/ui/sidebar.py +162 -0
- pyjs/web/ui/skeleton.py +15 -0
- pyjs/web/ui/slider.py +46 -0
- pyjs/web/ui/sonner.py +70 -0
- pyjs/web/ui/spinner.py +14 -0
- pyjs/web/ui/switch.py +35 -0
- pyjs/web/ui/table.py +84 -0
- pyjs/web/ui/tabs.py +167 -0
- pyjs/web/ui/text.py +15 -0
- pyjs/web/ui/textarea.py +28 -0
- pyjs/web/ui/toggle.py +109 -0
- pyjs/web/ui/tooltip.py +164 -0
- pyjs/web/ui/typography.py +79 -0
- pyjs/web/url.py +76 -0
- pyjs/web/webgpu.py +496 -0
- pyjs-0.0.1.dist-info/METADATA +441 -0
- pyjs-0.0.1.dist-info/RECORD +146 -0
- pyjs-0.0.1.dist-info/WHEEL +5 -0
- pyjs-0.0.1.dist-info/entry_points.txt +5 -0
- pyjs-0.0.1.dist-info/licenses/LICENSE +28 -0
- 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()
|
pyjs/docs/navigation.py
ADDED
|
@@ -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) + "/"
|