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.
Files changed (54) hide show
  1. pyweb/__init__.py +71 -0
  2. pyweb/app.py +37 -0
  3. pyweb/app_loader.py +139 -0
  4. pyweb/asgi.py +71 -0
  5. pyweb/auth.py +701 -0
  6. pyweb/bench.py +101 -0
  7. pyweb/browser.py +232 -0
  8. pyweb/build.py +295 -0
  9. pyweb/cache.py +201 -0
  10. pyweb/cli/__init__.py +465 -0
  11. pyweb/cli/__main__.py +3 -0
  12. pyweb/compiler/__init__.py +5 -0
  13. pyweb/compiler/ast.py +45 -0
  14. pyweb/compiler/codegen/__init__.py +9 -0
  15. pyweb/compiler/codegen/ir.py +50 -0
  16. pyweb/compiler/errors.py +29 -0
  17. pyweb/compiler/lower.py +733 -0
  18. pyweb/compiler/parser.py +532 -0
  19. pyweb/compiler/pipeline.py +158 -0
  20. pyweb/compiler/pyjs.py +1087 -0
  21. pyweb/compiler/rpc.py +35 -0
  22. pyweb/context.py +193 -0
  23. pyweb/css.py +115 -0
  24. pyweb/db/__init__.py +652 -0
  25. pyweb/db/migrate.py +143 -0
  26. pyweb/decorators.py +49 -0
  27. pyweb/deploy.py +102 -0
  28. pyweb/forms.py +108 -0
  29. pyweb/hosting.py +139 -0
  30. pyweb/jobs.py +248 -0
  31. pyweb/live.py +88 -0
  32. pyweb/lsp.py +214 -0
  33. pyweb/models.py +269 -0
  34. pyweb/npm.py +270 -0
  35. pyweb/observability.py +313 -0
  36. pyweb/platform.py +69 -0
  37. pyweb/plugins.py +112 -0
  38. pyweb/py.typed +0 -0
  39. pyweb/realtime.py +189 -0
  40. pyweb/rpc.py +137 -0
  41. pyweb/runtime/browser/runtime.js +1151 -0
  42. pyweb/runtime/server/__init__.py +445 -0
  43. pyweb/security.py +162 -0
  44. pyweb/serve.py +335 -0
  45. pyweb/ssr.py +260 -0
  46. pyweb/sync.py +118 -0
  47. pyweb/testing.py +154 -0
  48. pyweb/uploads.py +94 -0
  49. pyweb_stack-0.1.0.dist-info/METADATA +198 -0
  50. pyweb_stack-0.1.0.dist-info/RECORD +54 -0
  51. pyweb_stack-0.1.0.dist-info/WHEEL +5 -0
  52. pyweb_stack-0.1.0.dist-info/entry_points.txt +2 -0
  53. pyweb_stack-0.1.0.dist-info/licenses/LICENSE +21 -0
  54. 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,9 @@
1
+ """Codegen support: the app graph (PIR) used by ``pyweb inspect``.
2
+
3
+ Browser JavaScript is emitted by :mod:`pyweb.compiler.lower`; HTML is
4
+ rendered by :mod:`pyweb.ssr`.
5
+ """
6
+
7
+ from .ir import AppGraph, build_graph
8
+
9
+ __all__ = ["AppGraph", "build_graph"]
@@ -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)
@@ -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