pyweb-stack 0.1.0__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.
- pyweb/__init__.py +71 -0
- pyweb/app.py +37 -0
- pyweb/app_loader.py +139 -0
- pyweb/asgi.py +71 -0
- pyweb/auth.py +701 -0
- pyweb/bench.py +101 -0
- pyweb/browser.py +232 -0
- pyweb/build.py +295 -0
- pyweb/cache.py +201 -0
- pyweb/cli/__init__.py +465 -0
- pyweb/cli/__main__.py +3 -0
- pyweb/compiler/__init__.py +5 -0
- pyweb/compiler/ast.py +45 -0
- pyweb/compiler/codegen/__init__.py +9 -0
- pyweb/compiler/codegen/ir.py +50 -0
- pyweb/compiler/errors.py +29 -0
- pyweb/compiler/lower.py +733 -0
- pyweb/compiler/parser.py +532 -0
- pyweb/compiler/pipeline.py +158 -0
- pyweb/compiler/pyjs.py +1087 -0
- pyweb/compiler/rpc.py +35 -0
- pyweb/context.py +193 -0
- pyweb/css.py +115 -0
- pyweb/db/__init__.py +652 -0
- pyweb/db/migrate.py +143 -0
- pyweb/decorators.py +49 -0
- pyweb/deploy.py +102 -0
- pyweb/forms.py +108 -0
- pyweb/hosting.py +139 -0
- pyweb/jobs.py +248 -0
- pyweb/live.py +88 -0
- pyweb/lsp.py +214 -0
- pyweb/models.py +269 -0
- pyweb/npm.py +270 -0
- pyweb/observability.py +313 -0
- pyweb/platform.py +69 -0
- pyweb/plugins.py +112 -0
- pyweb/py.typed +0 -0
- pyweb/realtime.py +189 -0
- pyweb/rpc.py +137 -0
- pyweb/runtime/browser/runtime.js +1151 -0
- pyweb/runtime/server/__init__.py +445 -0
- pyweb/security.py +162 -0
- pyweb/serve.py +335 -0
- pyweb/ssr.py +260 -0
- pyweb/sync.py +118 -0
- pyweb/testing.py +154 -0
- pyweb/uploads.py +94 -0
- pyweb_stack-0.1.0.dist-info/METADATA +198 -0
- pyweb_stack-0.1.0.dist-info/RECORD +54 -0
- pyweb_stack-0.1.0.dist-info/WHEEL +5 -0
- pyweb_stack-0.1.0.dist-info/entry_points.txt +2 -0
- pyweb_stack-0.1.0.dist-info/licenses/LICENSE +21 -0
- pyweb_stack-0.1.0.dist-info/top_level.txt +1 -0
pyweb/compiler/ast.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Unified AST: Python logic (real `ast` nodes) + UI AST (markup nodes)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class TextNode:
|
|
10
|
+
text: str
|
|
11
|
+
line: int = 0
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class ExprNode:
|
|
16
|
+
code: str
|
|
17
|
+
line: int = 0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass
|
|
21
|
+
class Element:
|
|
22
|
+
tag: str
|
|
23
|
+
attrs: dict
|
|
24
|
+
children: list
|
|
25
|
+
line: int = 0
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def is_component(self):
|
|
29
|
+
return bool(self.tag[:1].isupper())
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass
|
|
33
|
+
class ControlFor:
|
|
34
|
+
target: str
|
|
35
|
+
iterable: str
|
|
36
|
+
body: list
|
|
37
|
+
line: int = 0
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass
|
|
41
|
+
class ControlIf:
|
|
42
|
+
test: str
|
|
43
|
+
body: list
|
|
44
|
+
orelse: list = field(default_factory=list)
|
|
45
|
+
line: int = 0
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""PyWeb IR (PIR): typed app graph. Textual form is debug-only.
|
|
2
|
+
|
|
3
|
+
Textual example:
|
|
4
|
+
page Home("/") signals [count@3] rpc [get_count()->Int@12]
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class IRNode:
|
|
14
|
+
kind: str
|
|
15
|
+
name: str
|
|
16
|
+
type: str = "Any"
|
|
17
|
+
line: int = 0
|
|
18
|
+
meta: dict = field(default_factory=dict)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class AppGraph:
|
|
23
|
+
pages: list = field(default_factory=list)
|
|
24
|
+
rpc: list = field(default_factory=list)
|
|
25
|
+
signals: dict = field(default_factory=dict)
|
|
26
|
+
computeds: dict = field(default_factory=dict)
|
|
27
|
+
placement: dict = field(default_factory=dict)
|
|
28
|
+
edges: list = field(default_factory=list)
|
|
29
|
+
sourcemap: list = field(default_factory=list) # (generated_desc, source_line)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def build_graph(pages, rpc_specs, signals, computeds, placement, edges):
|
|
33
|
+
g = AppGraph(pages=pages, rpc=rpc_specs, signals=signals,
|
|
34
|
+
computeds=computeds, placement=placement, edges=edges)
|
|
35
|
+
for s in signals:
|
|
36
|
+
g.sourcemap.append((f"sig:{s}", 0))
|
|
37
|
+
for r in rpc_specs:
|
|
38
|
+
g.sourcemap.append((f"rpc:{r['name']}", r["line"]))
|
|
39
|
+
return g
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def to_text(g: AppGraph):
|
|
43
|
+
lines = []
|
|
44
|
+
for p in g.pages:
|
|
45
|
+
lines.append(f"page {p['name']}(\"{p['route']}\") signals {p.get('signals', [])} rpc {[r['name'] for r in g.rpc]}")
|
|
46
|
+
for s, c in g.computeds.items():
|
|
47
|
+
lines.append(f" computed {s} = {c['code']} deps {c['deps']}")
|
|
48
|
+
for sym, (loc, why) in g.placement.items():
|
|
49
|
+
lines.append(f" place {sym}: {loc} # {why}")
|
|
50
|
+
return "\n".join(lines)
|
pyweb/compiler/errors.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Compiler errors that point at a `.pyweb` file and line."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CompileError(ValueError):
|
|
7
|
+
"""A user-facing compile error.
|
|
8
|
+
|
|
9
|
+
``str(err)`` is ``"<file>:<line>: <message>"`` so editors and CI logs
|
|
10
|
+
can jump to the source; ``err.lineno`` and ``err.msg`` are available
|
|
11
|
+
separately.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, msg, lineno=None, filename=None):
|
|
15
|
+
self.msg = msg
|
|
16
|
+
self.lineno = lineno
|
|
17
|
+
self.filename = filename
|
|
18
|
+
super().__init__(self._render())
|
|
19
|
+
|
|
20
|
+
def _render(self):
|
|
21
|
+
where = self.filename or "<pyweb>"
|
|
22
|
+
if self.lineno:
|
|
23
|
+
where += f":{self.lineno}"
|
|
24
|
+
return f"{where}: {self.msg}"
|
|
25
|
+
|
|
26
|
+
def with_file(self, filename):
|
|
27
|
+
self.filename = filename
|
|
28
|
+
self.args = (self._render(),)
|
|
29
|
+
return self
|