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/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]: ...
|