pyjs 0.0.1__tar.gz → 0.0.2__tar.gz

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 (165) hide show
  1. {pyjs-0.0.1 → pyjs-0.0.2}/PKG-INFO +25 -40
  2. {pyjs-0.0.1 → pyjs-0.0.2}/README.md +22 -36
  3. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/__init__.py +1 -1
  4. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/cli.py +94 -2
  5. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/decorators.py +89 -14
  6. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/docs/ui.py +27 -5
  7. {pyjs-0.0.1/pyjs/web → pyjs-0.0.2/pyjs}/javascript.py +29 -2
  8. pyjs-0.0.2/pyjs/python.py +185 -0
  9. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/scaffolding/__init__.py +4 -0
  10. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/scaffolding/templates/app/README.md.template +7 -0
  11. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/server.py +116 -7
  12. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/skills/pyjs/SKILL.md +14 -2
  13. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/client/app.py +30 -17
  14. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/client/state.py +13 -7
  15. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/daemon.py +32 -3
  16. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/helpers.py +85 -12
  17. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/pytest_plugin.py +14 -5
  18. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/web.py +0 -8
  19. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/tooling/browser.py +24 -4
  20. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/transpiler/__init__.py +10 -0
  21. pyjs-0.0.2/pyjs/transpiler/_builtins.py +899 -0
  22. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/transpiler/analyzer.py +598 -59
  23. pyjs-0.0.2/pyjs/transpiler/diagnostics.py +394 -0
  24. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/transpiler/objects.py +288 -14
  25. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/transpiler/source.py +68 -12
  26. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/transpiler/transpiler.py +170 -10
  27. pyjs-0.0.2/pyjs/web/__init__.py +1 -0
  28. pyjs-0.0.2/pyjs/web/clipboard.py +139 -0
  29. pyjs-0.0.2/pyjs/web/crypto.py +1152 -0
  30. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/dom.py +1716 -342
  31. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/domx.py +40 -18
  32. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/dragdrop.py +3 -7
  33. pyjs-0.0.2/pyjs/web/encoding.py +128 -0
  34. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/events.py +1080 -552
  35. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/files.py +37 -18
  36. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/geometry.py +133 -56
  37. pyjs-0.0.2/pyjs/web/html.py +4571 -0
  38. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/indexeddb.py +16 -2
  39. pyjs-0.0.2/pyjs/web/navigation.py +175 -0
  40. pyjs-0.0.2/pyjs/web/network.py +601 -0
  41. pyjs-0.0.2/pyjs/web/serviceworker.py +1040 -0
  42. pyjs-0.0.2/pyjs/web/storage.py +43 -0
  43. pyjs-0.0.2/pyjs/web/streams.py +478 -0
  44. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/svg.py +538 -4
  45. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/__init__.py +1 -1
  46. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/dialog.py +4 -2
  47. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/navigation_menu.py +5 -1
  48. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/select.py +2 -4
  49. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/sheet.py +10 -1
  50. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/sidebar.py +39 -0
  51. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/url.py +2 -1
  52. pyjs-0.0.2/pyjs/web/webgpu.py +2231 -0
  53. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs.egg-info/PKG-INFO +25 -40
  54. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs.egg-info/SOURCES.txt +9 -1
  55. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs.egg-info/requires.txt +1 -1
  56. {pyjs-0.0.1 → pyjs-0.0.2}/pyproject.toml +17 -3
  57. pyjs-0.0.1/pyjs/transpiler/_builtins.py +0 -485
  58. pyjs-0.0.1/pyjs/web/__init__.py +0 -5
  59. pyjs-0.0.1/pyjs/web/html.py +0 -927
  60. pyjs-0.0.1/pyjs/web/network.py +0 -193
  61. pyjs-0.0.1/pyjs/web/streams.py +0 -17
  62. pyjs-0.0.1/pyjs/web/webgpu.py +0 -496
  63. {pyjs-0.0.1 → pyjs-0.0.2}/LICENSE +0 -0
  64. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/__main__.py +0 -0
  65. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/docs/__init__.py +0 -0
  66. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/docs/builder.py +0 -0
  67. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/docs/cli.py +0 -0
  68. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/docs/config.py +0 -0
  69. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/docs/favicon.svg +0 -0
  70. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/docs/markdown.py +0 -0
  71. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/docs/models.py +0 -0
  72. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/docs/navigation.py +0 -0
  73. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/docs/style.css +0 -0
  74. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/nativescript/__init__.py +0 -0
  75. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__PYJS_PACKAGE__.py.template +0 -0
  76. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__init__.py.template +0 -0
  77. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__main__.py.template +0 -0
  78. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/scaffolding/templates/app/tests/test_app.py.template +0 -0
  79. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/scaffolding/templates/app/tests/test_browser_app.py.template +0 -0
  80. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/scaffolding/templates/app_test.py.template +0 -0
  81. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/state.py +0 -0
  82. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/__init__.py +0 -0
  83. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/android.py +0 -0
  84. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/artifacts.py +0 -0
  85. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/assertion_rewriter.py +0 -0
  86. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/builder.py +0 -0
  87. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/capture.py +0 -0
  88. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/client/__init__.py +0 -0
  89. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/client/assertions.py +0 -0
  90. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/client/runtime.py +0 -0
  91. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/client/sidebar.py +0 -0
  92. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/client/viewer.py +0 -0
  93. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/protocol.py +0 -0
  94. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/testing/webgpu.py +0 -0
  95. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/tooling/__init__.py +0 -0
  96. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/tooling/android.py +0 -0
  97. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/tooling/command.py +0 -0
  98. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/tooling/nativescript.py +0 -0
  99. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/tooling/node.py +0 -0
  100. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/tooling/perf.py +0 -0
  101. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/transpiler/utils.py +0 -0
  102. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/console.py +0 -0
  103. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ssr.py +0 -0
  104. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/timers.py +0 -0
  105. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/accordion.py +0 -0
  106. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/alert.py +0 -0
  107. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/alert_dialog.py +0 -0
  108. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/aspect_ratio.py +0 -0
  109. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/attachment.py +0 -0
  110. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/avatar.py +0 -0
  111. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/badge.py +0 -0
  112. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/breadcrumb.py +0 -0
  113. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/bubble.py +0 -0
  114. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/button.py +0 -0
  115. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/calendar.py +0 -0
  116. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/card.py +0 -0
  117. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/carousel.py +0 -0
  118. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/chart.py +0 -0
  119. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/checkbox.py +0 -0
  120. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/collapsible.py +0 -0
  121. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/combobox.py +0 -0
  122. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/command.py +0 -0
  123. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/context_menu.py +0 -0
  124. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/date_picker.py +0 -0
  125. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/direction.py +0 -0
  126. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/drawer.py +0 -0
  127. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/dropdown_menu.py +0 -0
  128. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/empty.py +0 -0
  129. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/field.py +0 -0
  130. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/floating.py +0 -0
  131. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/hover_card.py +0 -0
  132. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/input.py +0 -0
  133. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/input_group.py +0 -0
  134. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/input_otp.py +0 -0
  135. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/item.py +0 -0
  136. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/kbd.py +0 -0
  137. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/label.py +0 -0
  138. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/marker.py +0 -0
  139. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/menubar.py +0 -0
  140. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/message.py +0 -0
  141. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/message_scroller.py +0 -0
  142. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/native_select.py +0 -0
  143. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/pagination.py +0 -0
  144. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/popover.py +0 -0
  145. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/progress.py +0 -0
  146. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/radio_group.py +0 -0
  147. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/resizable.py +0 -0
  148. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/scroll_area.py +0 -0
  149. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/separator.py +0 -0
  150. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/skeleton.py +0 -0
  151. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/slider.py +0 -0
  152. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/sonner.py +0 -0
  153. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/spinner.py +0 -0
  154. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/switch.py +0 -0
  155. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/table.py +0 -0
  156. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/tabs.py +0 -0
  157. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/text.py +0 -0
  158. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/textarea.py +0 -0
  159. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/toggle.py +0 -0
  160. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/tooltip.py +0 -0
  161. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs/web/ui/typography.py +0 -0
  162. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs.egg-info/dependency_links.txt +0 -0
  163. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs.egg-info/entry_points.txt +0 -0
  164. {pyjs-0.0.1 → pyjs-0.0.2}/pyjs.egg-info/top_level.txt +0 -0
  165. {pyjs-0.0.1 → pyjs-0.0.2}/setup.cfg +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyjs
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Python to JavaScript transpiler.
5
5
  Author-email: Lex Berezhny <lex@damoti.com>
6
- License: BSD-3-Clause
6
+ License-Expression: BSD-3-Clause
7
7
  Project-URL: Homepage, https://pyjs.org
8
8
  Project-URL: Documentation, https://pyjs.org/docs/
9
9
  Project-URL: Release notes, https://github.com/pyjs/pyjs/releases
@@ -12,7 +12,6 @@ Project-URL: Tracker, https://github.com/pyjs/pyjs/issues
12
12
  Classifier: Development Status :: 2 - Pre-Alpha
13
13
  Classifier: Environment :: Web Environment
14
14
  Classifier: Intended Audience :: Developers
15
- Classifier: License :: OSI Approved :: BSD License
16
15
  Classifier: Operating System :: OS Independent
17
16
  Classifier: Programming Language :: Python
18
17
  Classifier: Programming Language :: Python :: 3
@@ -31,13 +30,13 @@ Requires-Dist: pyyaml>=6.0
31
30
  Requires-Dist: pytest
32
31
  Requires-Dist: websockets
33
32
  Provides-Extra: examples
34
- Requires-Dist: pyjs-examples==0.0.1; extra == "examples"
33
+ Requires-Dist: pyjs-examples==0.0.2; extra == "examples"
35
34
  Dynamic: license-file
36
35
 
37
36
  # PyJS: Python to JavaScript
38
37
 
39
- > Pre-alpha: useful applications and tests work today, but APIs may change before the first
40
- > release.
38
+ > Pre-alpha: useful applications and tests work today, but APIs may change during the early
39
+ > releases.
41
40
 
42
41
  PyJS is a statically analyzed Python-to-JavaScript compiler. It turns reachable, typed Python code
43
42
  into readable, tree-shaken JavaScript without shipping a Python runtime. Its current libraries make
@@ -87,17 +86,8 @@ python -m pytest -q
87
86
  python -m pytest -q --pyjs-target=web
88
87
  ```
89
88
 
90
- To work on PyJS from a source checkout:
91
-
92
- ```bash
93
- python -m pip install -e .
94
- ```
95
-
96
- Install the separate examples distribution when working on the examples:
97
-
98
- ```bash
99
- python -m pip install -e examples
100
- ```
89
+ To develop PyJS itself from a source checkout, see
90
+ [CONTRIBUTING.md](CONTRIBUTING.md).
101
91
 
102
92
  ## Start from an example
103
93
 
@@ -119,7 +109,9 @@ pyjs create dialog_demo --template pyjs_examples.samples.ui_dialog
119
109
  `pyjs create NAME` creates a project in `NAME/`, with application code in
120
110
  `NAME/NAME/NAME.py` and tests in `NAME/tests/`. Pass a destination as the second positional argument
121
111
  to populate another directory, such as `pyjs create routine .`. Add `--src-layout` to put the
122
- package under `src/`. After installation, `python -m NAME` starts either package layout.
112
+ package under `src/`. After installation, `python -m NAME` starts either package layout through its
113
+ ordinary Python entry point. `pyjs serve` is also available as a convenience and uses the
114
+ application recorded in `pyproject.toml`.
123
115
  `--single-file` explicitly requests one standalone Python file and requires a file template when
124
116
  combined with `--template`. The `pyjs-examples` distribution registers both file and directory
125
117
  templates and contains the source copied by `pyjs create`; templates are not embedded in the
@@ -161,6 +153,10 @@ available to the browser compiler, and reachable methods are included in the gen
161
153
  `CustomElement` subclasses render on the server and hydrate as browser-native custom elements.
162
154
  `ref()` reconnects Python attributes to existing server-rendered nodes rather than recreating them.
163
155
 
156
+ Module values cross the same explicit compilation boundary through a `JS[T]` annotation. Combine
157
+ it with `Final` for constants, such as `heartbeat_interval: Final[JS[int]] = 5_000`; unmarked
158
+ module values remain server-only and cannot be included by an accidental browser-side reference.
159
+
164
160
  Values that must survive rendering and hydration can live on the custom element as DOM attributes.
165
161
  The `state()` descriptor and `@effect(...)` provide a small typed reactive layer for updating the
166
162
  DOM imperatively. Server-only handlers and browser methods can coexist in the same module.
@@ -363,8 +359,9 @@ python -m pytest -q
363
359
  python -m pytest -q --pyjs-target=web
364
360
  ```
365
361
 
366
- Use `pytest.mark.pyjs_web` for tests requiring native browser behavior and
367
- `pytest.mark.pyjs_python` for tests that cannot be compiled. A filename such as
362
+ Use `pytest.mark.pyjs_web` for tests that should be compiled and run in the browser.
363
+ Unmarked tests run only as ordinary Python tests; `pytest.mark.pyjs_python` can make that intent
364
+ explicit. A filename such as
368
365
  `test_browser_dialog.py` is only an organizational convention and has no implicit behavior.
369
366
 
370
367
  Browser tests retain console output and errors. Tests that render meaningful UI retain their iframe
@@ -380,12 +377,14 @@ preview, and render assertions can compare screenshots against checked-in PNG ba
380
377
  | `pyjs --src-all INPUT` | Include all tree-shaken dependency sources |
381
378
  | `pyjs --perf INPUT` | Compare Python and generated-JavaScript performance |
382
379
  | `pyjs create NAME [DESTINATION]` | Create a starter project |
380
+ | `pyjs serve [TARGET]` | Serve a configured project, module, or Python file |
383
381
  | `pyjs template` | List templates registered by installed packages |
384
382
  | `pyjs template NAME` | Print the complete materialized template source |
385
383
  | `pyjs template NAME --src` | Print the transpiled entry-module JavaScript |
386
384
  | `pyjs build MODULE[:ENTRY]` | Write generated JavaScript, CSS, and HTML |
387
385
  | `pyjs docs build` | Build a static documentation site |
388
386
  | `pyjs docs serve` | Build and serve documentation locally |
387
+ | `pyjs inspect URL` | Capture a screenshot and structured browser diagnostics |
389
388
  | `pyjs skill` | Print version-matched instructions for coding agents |
390
389
 
391
390
  The built-in application server is run from Python source with `serve(__file__)`; the generated
@@ -393,7 +392,7 @@ starter and examples already provide this entry point.
393
392
 
394
393
  ## Current limitations and missing features
395
394
 
396
- PyJS is intentionally a typed subset of Python, and the first release remains pre-alpha:
395
+ PyJS is intentionally a typed subset of Python, and the current releases remain pre-alpha:
397
396
 
398
397
  - Multiple inheritance is not supported.
399
398
  - Reflection, runtime monkey-patching, `eval()`, and arbitrary dynamic imports are outside the
@@ -415,27 +414,13 @@ PyJS is intentionally a typed subset of Python, and the first release remains pr
415
414
  - NativeScript output is experimental; the first proof of concept currently targets Android and
416
415
  covers a small set of core views.
417
416
 
418
- See [TESTING.md](TESTING.md) and [TREE_SHAKING.md](TREE_SHAKING.md) for focused implementation
417
+ See the [testing guide](docs/guide/testing.md) and
418
+ [TREE_SHAKING.md](TREE_SHAKING.md) for focused behavior and implementation
419
419
  status. The broader guides and references live in [docs/](docs/).
420
420
 
421
- ## Development from a checkout
422
-
423
- PyJS currently requires Python 3.14:
424
-
425
- ```bash
426
- python -m pip install -e .
427
- python -m pytest -q
428
- ```
429
-
430
- The examples are a separate distribution:
431
-
432
- ```bash
433
- python -m pip install -e examples
434
- cd examples
435
- python -m pytest -q
436
- ```
421
+ ## Contributing
437
422
 
438
- Run Ruff against changed Python files before submitting changes. Generated `.main.js`, `.main.css`,
439
- and `.main.html` files are build artifacts rather than hand-authored source.
423
+ The development environment, repository structure, compiler contracts, and
424
+ verification workflow are documented in [CONTRIBUTING.md](CONTRIBUTING.md).
440
425
 
441
426
  PyJS is distributed under the [BSD 3-Clause License](LICENSE).
@@ -1,7 +1,7 @@
1
1
  # PyJS: Python to JavaScript
2
2
 
3
- > Pre-alpha: useful applications and tests work today, but APIs may change before the first
4
- > release.
3
+ > Pre-alpha: useful applications and tests work today, but APIs may change during the early
4
+ > releases.
5
5
 
6
6
  PyJS is a statically analyzed Python-to-JavaScript compiler. It turns reachable, typed Python code
7
7
  into readable, tree-shaken JavaScript without shipping a Python runtime. Its current libraries make
@@ -51,17 +51,8 @@ python -m pytest -q
51
51
  python -m pytest -q --pyjs-target=web
52
52
  ```
53
53
 
54
- To work on PyJS from a source checkout:
55
-
56
- ```bash
57
- python -m pip install -e .
58
- ```
59
-
60
- Install the separate examples distribution when working on the examples:
61
-
62
- ```bash
63
- python -m pip install -e examples
64
- ```
54
+ To develop PyJS itself from a source checkout, see
55
+ [CONTRIBUTING.md](CONTRIBUTING.md).
65
56
 
66
57
  ## Start from an example
67
58
 
@@ -83,7 +74,9 @@ pyjs create dialog_demo --template pyjs_examples.samples.ui_dialog
83
74
  `pyjs create NAME` creates a project in `NAME/`, with application code in
84
75
  `NAME/NAME/NAME.py` and tests in `NAME/tests/`. Pass a destination as the second positional argument
85
76
  to populate another directory, such as `pyjs create routine .`. Add `--src-layout` to put the
86
- package under `src/`. After installation, `python -m NAME` starts either package layout.
77
+ package under `src/`. After installation, `python -m NAME` starts either package layout through its
78
+ ordinary Python entry point. `pyjs serve` is also available as a convenience and uses the
79
+ application recorded in `pyproject.toml`.
87
80
  `--single-file` explicitly requests one standalone Python file and requires a file template when
88
81
  combined with `--template`. The `pyjs-examples` distribution registers both file and directory
89
82
  templates and contains the source copied by `pyjs create`; templates are not embedded in the
@@ -125,6 +118,10 @@ available to the browser compiler, and reachable methods are included in the gen
125
118
  `CustomElement` subclasses render on the server and hydrate as browser-native custom elements.
126
119
  `ref()` reconnects Python attributes to existing server-rendered nodes rather than recreating them.
127
120
 
121
+ Module values cross the same explicit compilation boundary through a `JS[T]` annotation. Combine
122
+ it with `Final` for constants, such as `heartbeat_interval: Final[JS[int]] = 5_000`; unmarked
123
+ module values remain server-only and cannot be included by an accidental browser-side reference.
124
+
128
125
  Values that must survive rendering and hydration can live on the custom element as DOM attributes.
129
126
  The `state()` descriptor and `@effect(...)` provide a small typed reactive layer for updating the
130
127
  DOM imperatively. Server-only handlers and browser methods can coexist in the same module.
@@ -327,8 +324,9 @@ python -m pytest -q
327
324
  python -m pytest -q --pyjs-target=web
328
325
  ```
329
326
 
330
- Use `pytest.mark.pyjs_web` for tests requiring native browser behavior and
331
- `pytest.mark.pyjs_python` for tests that cannot be compiled. A filename such as
327
+ Use `pytest.mark.pyjs_web` for tests that should be compiled and run in the browser.
328
+ Unmarked tests run only as ordinary Python tests; `pytest.mark.pyjs_python` can make that intent
329
+ explicit. A filename such as
332
330
  `test_browser_dialog.py` is only an organizational convention and has no implicit behavior.
333
331
 
334
332
  Browser tests retain console output and errors. Tests that render meaningful UI retain their iframe
@@ -344,12 +342,14 @@ preview, and render assertions can compare screenshots against checked-in PNG ba
344
342
  | `pyjs --src-all INPUT` | Include all tree-shaken dependency sources |
345
343
  | `pyjs --perf INPUT` | Compare Python and generated-JavaScript performance |
346
344
  | `pyjs create NAME [DESTINATION]` | Create a starter project |
345
+ | `pyjs serve [TARGET]` | Serve a configured project, module, or Python file |
347
346
  | `pyjs template` | List templates registered by installed packages |
348
347
  | `pyjs template NAME` | Print the complete materialized template source |
349
348
  | `pyjs template NAME --src` | Print the transpiled entry-module JavaScript |
350
349
  | `pyjs build MODULE[:ENTRY]` | Write generated JavaScript, CSS, and HTML |
351
350
  | `pyjs docs build` | Build a static documentation site |
352
351
  | `pyjs docs serve` | Build and serve documentation locally |
352
+ | `pyjs inspect URL` | Capture a screenshot and structured browser diagnostics |
353
353
  | `pyjs skill` | Print version-matched instructions for coding agents |
354
354
 
355
355
  The built-in application server is run from Python source with `serve(__file__)`; the generated
@@ -357,7 +357,7 @@ starter and examples already provide this entry point.
357
357
 
358
358
  ## Current limitations and missing features
359
359
 
360
- PyJS is intentionally a typed subset of Python, and the first release remains pre-alpha:
360
+ PyJS is intentionally a typed subset of Python, and the current releases remain pre-alpha:
361
361
 
362
362
  - Multiple inheritance is not supported.
363
363
  - Reflection, runtime monkey-patching, `eval()`, and arbitrary dynamic imports are outside the
@@ -379,27 +379,13 @@ PyJS is intentionally a typed subset of Python, and the first release remains pr
379
379
  - NativeScript output is experimental; the first proof of concept currently targets Android and
380
380
  covers a small set of core views.
381
381
 
382
- See [TESTING.md](TESTING.md) and [TREE_SHAKING.md](TREE_SHAKING.md) for focused implementation
382
+ See the [testing guide](docs/guide/testing.md) and
383
+ [TREE_SHAKING.md](TREE_SHAKING.md) for focused behavior and implementation
383
384
  status. The broader guides and references live in [docs/](docs/).
384
385
 
385
- ## Development from a checkout
386
-
387
- PyJS currently requires Python 3.14:
388
-
389
- ```bash
390
- python -m pip install -e .
391
- python -m pytest -q
392
- ```
393
-
394
- The examples are a separate distribution:
395
-
396
- ```bash
397
- python -m pip install -e examples
398
- cd examples
399
- python -m pytest -q
400
- ```
386
+ ## Contributing
401
387
 
402
- Run Ruff against changed Python files before submitting changes. Generated `.main.js`, `.main.css`,
403
- and `.main.html` files are build artifacts rather than hand-authored source.
388
+ The development environment, repository structure, compiler contracts, and
389
+ verification workflow are documented in [CONTRIBUTING.md](CONTRIBUTING.md).
404
390
 
405
391
  PyJS is distributed under the [BSD 3-Clause License](LICENSE).
@@ -1,4 +1,4 @@
1
- __version__ = (0, 0, 1)
1
+ __version__ = (0, 0, 2)
2
2
 
3
3
  from .decorators import *
4
4
  from .state import effect, state
@@ -4,9 +4,11 @@ import importlib
4
4
  import importlib.util
5
5
  import json
6
6
  import os
7
+ import runpy
7
8
  import shutil
8
9
  import sys
9
10
  import textwrap
11
+ import tomllib
10
12
  import traceback
11
13
  from dataclasses import dataclass
12
14
  from importlib import resources
@@ -23,6 +25,7 @@ from pyjs.scaffolding import (
23
25
  version_string,
24
26
  )
25
27
  from pyjs.server import page
28
+ from pyjs.server import serve as serve_application
26
29
  from pyjs.testing.capture import capture_url
27
30
  from pyjs.tooling.node import Node
28
31
  from pyjs.tooling.perf import (
@@ -34,9 +37,16 @@ from pyjs.tooling.perf import (
34
37
  javascript_benchmark,
35
38
  run_python,
36
39
  )
37
- from pyjs.transpiler import SourceCompilation, bundle, compile_source, prepare_bundle
40
+ from pyjs.transpiler import (
41
+ CompilationError,
42
+ SourceCompilation,
43
+ bundle,
44
+ compile_source,
45
+ format_compilation_error,
46
+ prepare_bundle,
47
+ )
38
48
 
39
- SUBCOMMANDS = {"build", "create", "template", "inspect", "skill", "docs"}
49
+ SUBCOMMANDS = {"build", "create", "serve", "template", "inspect", "skill", "docs"}
40
50
 
41
51
 
42
52
  @dataclass(frozen=True)
@@ -73,6 +83,13 @@ def parser() -> argparse.ArgumentParser:
73
83
  )
74
84
  build.add_argument("--args", help="JSON list of arguments passed to the entry point")
75
85
 
86
+ serve = subcommands.add_parser("serve", help="serve a PyJS web application")
87
+ serve.add_argument(
88
+ "target",
89
+ nargs="?",
90
+ help="application module or Python file; defaults to the project configuration",
91
+ )
92
+
76
93
  create_command = subcommands.add_parser("create", help="create a PyJS project or file")
77
94
  create_command.add_argument(
78
95
  "name",
@@ -278,6 +295,28 @@ def _direct(args, command_parser: argparse.ArgumentParser) -> int:
278
295
  try:
279
296
  program = _direct_input(args, command_parser)
280
297
  compilation = _compile_direct(program)
298
+ except CompilationError as error:
299
+ if args.json:
300
+ print(json.dumps({"error": error.diagnostic.to_dict()}, indent=2))
301
+ else:
302
+ print(format_compilation_error(error), file=sys.stderr, end="")
303
+ return 2
304
+ except SyntaxError as error:
305
+ if args.json:
306
+ details = {
307
+ "type": "SyntaxError",
308
+ "message": error.msg,
309
+ "file": error.filename,
310
+ "line": error.lineno,
311
+ "column": error.offset,
312
+ "end_line": error.end_lineno,
313
+ "end_column": error.end_offset,
314
+ }
315
+ print(json.dumps({"error": details}, indent=2))
316
+ else:
317
+ formatted = "".join(traceback.format_exception_only(error))
318
+ print(formatted, file=sys.stderr, end="")
319
+ return 2
281
320
  except Exception as error:
282
321
  if args.json:
283
322
  details = {
@@ -619,6 +658,53 @@ def _build(args, command_parser: argparse.ArgumentParser) -> int:
619
658
  return 0
620
659
 
621
660
 
661
+ def _configured_application(command_parser: argparse.ArgumentParser) -> str:
662
+ for directory in (Path.cwd(), *Path.cwd().parents):
663
+ configuration = directory / "pyproject.toml"
664
+ if not configuration.is_file():
665
+ continue
666
+ try:
667
+ project = tomllib.loads(configuration.read_text(encoding="utf-8"))
668
+ except tomllib.TOMLDecodeError as error:
669
+ command_parser.error(f"could not read {configuration}: {error}")
670
+ application = project.get("tool", {}).get("pyjs", {}).get("application")
671
+ if not isinstance(application, str) or not application:
672
+ command_parser.error(
673
+ "no application is configured; provide a module or Python file"
674
+ )
675
+ sys.path.insert(0, str(directory))
676
+ return application
677
+ command_parser.error("no application is configured; provide a module or Python file")
678
+
679
+
680
+ def _serve(args, command_parser: argparse.ArgumentParser) -> int:
681
+ target = args.target or _configured_application(command_parser)
682
+ path = Path(target)
683
+ if path.is_file():
684
+ path = path.resolve()
685
+ sys.path.insert(0, str(path.parent))
686
+ serve_application(str(path))
687
+ return 0
688
+ if path.suffix == ".py" or os.sep in target:
689
+ command_parser.error(f"cannot open {target!r}: no such file")
690
+ try:
691
+ spec = importlib.util.find_spec(target)
692
+ except (ImportError, ModuleNotFoundError, ValueError) as error:
693
+ command_parser.error(str(error))
694
+ if spec is None:
695
+ command_parser.error(f"cannot find module {target!r}")
696
+ if spec.submodule_search_locations is not None:
697
+ try:
698
+ main_spec = importlib.util.find_spec(f"{target}.__main__")
699
+ except (ImportError, ModuleNotFoundError, ValueError):
700
+ main_spec = None
701
+ if main_spec is not None:
702
+ runpy.run_module(target, run_name="__main__", alter_sys=True)
703
+ return 0
704
+ serve_application(target)
705
+ return 0
706
+
707
+
622
708
  def _create(args, command_parser: argparse.ArgumentParser) -> int:
623
709
  try:
624
710
  destination = create(
@@ -644,6 +730,10 @@ def _create(args, command_parser: argparse.ArgumentParser) -> int:
644
730
  print(' python -m pip install -e ".[test]"')
645
731
  if args.template is None:
646
732
  print(f" python -m {args.name}")
733
+ print()
734
+ print("Or run directly with PyJS (including the npm distribution):")
735
+ print()
736
+ print(" pyjs serve")
647
737
  else:
648
738
  print(" See README.md for the run command")
649
739
  return 0
@@ -799,6 +889,8 @@ def main(argv: list[str] | None = None) -> int:
799
889
  return 0
800
890
  if args.command == "build":
801
891
  return _build(args, command_parser)
892
+ if args.command == "serve":
893
+ return _serve(args, command_parser)
802
894
  if args.command == "create":
803
895
  return _create(args, command_parser)
804
896
  if args.command == "template":
@@ -1,4 +1,6 @@
1
1
  import inspect
2
+ from collections.abc import Mapping
3
+ from typing import Annotated
2
4
 
3
5
  DECORATIONS = {
4
6
  # safe to analyze and transpile
@@ -24,6 +26,9 @@ DECORATIONS = {
24
26
  # every call site where this function is called
25
27
  "__js_rewrite_call_site__", # function
26
28
 
29
+ # functions referenced by an inline rewrite and retained in generated code
30
+ "__js_inline_dependencies__", # dict[str, function]
31
+
27
32
  # returns JavaScript source as string, appending the code
28
33
  # after the definition of the wrapped code object
29
34
  "__js_append__", # function
@@ -84,12 +89,21 @@ def should_include(obj):
84
89
  ) and not getattr(obj.py_obj, "__dict__", {}).get("__builtin__", False)
85
90
 
86
91
 
87
- def js(*cls_func_args, inline=None, builtin=None, include=None, analyze=None, client=None):
92
+ def js(
93
+ *cls_func_args,
94
+ inline=None,
95
+ dependencies=None,
96
+ builtin=None,
97
+ include=None,
98
+ analyze=None,
99
+ client=None,
100
+ ):
88
101
 
89
102
  class Wrapper:
90
103
 
91
- def __init__(self, inline, builtin, include, analyze, client):
104
+ def __init__(self, inline, dependencies, builtin, include, analyze, client):
92
105
  self.inline = inline
106
+ self.dependencies = dependencies
93
107
  self.builtin = builtin
94
108
  self.include = include
95
109
  self.analyze = analyze
@@ -110,23 +124,79 @@ def js(*cls_func_args, inline=None, builtin=None, include=None, analyze=None, cl
110
124
  else:
111
125
  cls_func.__js_rewrite_call_site__ = self.inline
112
126
 
127
+ if self.dependencies is not None:
128
+ target = cls_func.__qualname__
129
+ if self.inline is None:
130
+ raise TypeError(
131
+ f"@js dependencies for {target!r} require an inline= argument."
132
+ )
133
+ if not isinstance(self.dependencies, Mapping):
134
+ raise TypeError(
135
+ f"@js dependencies for {target!r} must be a mapping."
136
+ )
137
+ invalid_names = [
138
+ name
139
+ for name in self.dependencies
140
+ if not isinstance(name, str) or not name.isidentifier()
141
+ ]
142
+ if invalid_names:
143
+ names = ", ".join(repr(name) for name in invalid_names)
144
+ raise TypeError(
145
+ f"@js dependency names for {target!r} must be Python "
146
+ f"identifiers; invalid: {names}."
147
+ )
148
+ invalid_dependencies = [
149
+ (name, type(dependency).__name__)
150
+ for name, dependency in self.dependencies.items()
151
+ if not inspect.isfunction(dependency)
152
+ ]
153
+ if invalid_dependencies:
154
+ dependencies = ", ".join(
155
+ f"{name!r} ({type_name})"
156
+ for name, type_name in invalid_dependencies
157
+ )
158
+ raise TypeError(
159
+ f"@js dependencies for {target!r} must be functions; "
160
+ f"invalid: {dependencies}."
161
+ )
162
+ reserved = {
163
+ "_arg_strs",
164
+ "_arg_types",
165
+ "_keyword_strs",
166
+ "_args_joined",
167
+ "_args_suffix",
168
+ "self",
169
+ }
170
+ parameter_names = set(inspect.signature(cls_func).parameters)
171
+ conflicts = set(self.dependencies) & (reserved | parameter_names)
172
+ if conflicts:
173
+ raise TypeError(
174
+ f"@js dependency names for {target!r} conflict with call "
175
+ f"arguments: {', '.join(sorted(conflicts))}."
176
+ )
177
+ cls_func.__js_inline_dependencies__ = dict(self.dependencies)
178
+
113
179
  if inspect.isclass(cls_func):
114
- assert self.include is None, (
115
- "@js(include=True) is only supported for class methods."
116
- )
117
- assert self.client_implementation is None, (
118
- "@js(client=...) is not supported for classes."
119
- )
180
+ if self.include is not None:
181
+ raise TypeError(
182
+ "@js(include=True) is only supported for class methods."
183
+ )
184
+ if self.client_implementation is not None:
185
+ raise TypeError("@js(client=...) is not supported for classes.")
120
186
  return cls_func
121
187
 
122
188
  if self.client_implementation is not None:
123
- assert self.inline is None, "@js(client=...) cannot be combined with inline=."
189
+ if self.inline is not None:
190
+ raise TypeError(
191
+ "@js(client=...) cannot be combined with inline=."
192
+ )
124
193
  cls_func.__js_replace__ = self.client_implementation
125
194
 
126
195
  if self.include is True:
127
- assert "." in cls_func.__qualname__, (
128
- "@js(include=True) is only supported for class methods."
129
- )
196
+ if "." not in cls_func.__qualname__:
197
+ raise TypeError(
198
+ "@js(include=True) is only supported for class methods."
199
+ )
130
200
  cls_func.__js_include__ = True
131
201
 
132
202
  if self.analyze is False:
@@ -150,9 +220,11 @@ def js(*cls_func_args, inline=None, builtin=None, include=None, analyze=None, cl
150
220
  return cls_func
151
221
 
152
222
  if cls_func_args and is_cls_or_func(cls_func_args[0]):
153
- return Wrapper(inline, builtin, include, analyze, client)(cls_func_args[0])
223
+ return Wrapper(
224
+ inline, dependencies, builtin, include, analyze, client
225
+ )(cls_func_args[0])
154
226
 
155
- return Wrapper(inline, builtin, include, analyze, client)
227
+ return Wrapper(inline, dependencies, builtin, include, analyze, client)
156
228
 
157
229
 
158
230
  def nojs(cls_func):
@@ -168,3 +240,6 @@ def js_object(obj, builtin=None, include=None):
168
240
  if include is True:
169
241
  obj.__js_include__ = True
170
242
  return obj
243
+
244
+
245
+ type JS[T] = Annotated[T, js]
@@ -1,9 +1,27 @@
1
+ from typing import TypedDict
2
+
1
3
  from pyjs import js
4
+ from pyjs.javascript import JSON
2
5
  from pyjs.web.dom import document, localStorage, navigator, window
3
- from pyjs.web.domx import CustomElement, button, dialog, div, input, ref, tag
6
+ from pyjs.web.domx import (
7
+ CustomElement,
8
+ button,
9
+ dialog,
10
+ div,
11
+ input,
12
+ ref,
13
+ require_element,
14
+ tag,
15
+ )
4
16
  from pyjs.web.events import Event, EventTarget, KeyboardEvent
5
17
  from pyjs.web.html import HTMLElement
6
- from pyjs.web.javascript import JSON
18
+
19
+
20
+ class SearchRecord(TypedDict):
21
+ title: str
22
+ section: str
23
+ text: str
24
+ url: str
7
25
 
8
26
 
9
27
  @js
@@ -214,7 +232,11 @@ class DocsApp(CustomElement):
214
232
  bind(self.search_button, "click", self.open_search)
215
233
  bind(self.theme_button, "click", self.toggle_theme)
216
234
  bind(self.search_input, "input", self.update_search)
217
- bind(self.search_dialog.querySelector(".search-close"), "click", self.close_search)
235
+ bind(
236
+ require_element(self.search_dialog, ".search-close"),
237
+ "click",
238
+ self.close_search,
239
+ )
218
240
  bind(self.search_dialog, "click", self.handle_dialog_click)
219
241
  bind(window, "keydown", self.handle_keyboard)
220
242
  self.apply_theme(localStorage.getItem("pyjs-docs-theme"))
@@ -289,8 +311,8 @@ class DocsApp(CustomElement):
289
311
  search_data = self.search_data.textContent
290
312
  if search_data is None:
291
313
  return
292
- records: list[dict[str, str]] = JSON.parse(search_data)
293
- matches: list[dict[str, str]] = []
314
+ records: list[SearchRecord] = JSON.parse(search_data)
315
+ matches: list[SearchRecord] = []
294
316
  for record in records:
295
317
  searchable = (
296
318
  record["title"].lower()
@@ -1,3 +1,6 @@
1
+ import json
2
+ import random
3
+
1
4
  from pyjs import js
2
5
 
3
6
 
@@ -14,6 +17,18 @@ class ArrayBuffer:
14
17
  def slice(self, begin: int = 0, end: int | None = None) -> ArrayBuffer: ...
15
18
 
16
19
 
20
+ @js(builtin=True)
21
+ class SharedArrayBuffer:
22
+ def __init__(self, length: int):
23
+ self.byteLength: int = length
24
+ self.growable: bool = False
25
+ self.maxByteLength: int = length
26
+
27
+ def grow(self, newLength: int) -> None: ...
28
+
29
+ def slice(self, begin: int = 0, end: int | None = None) -> SharedArrayBuffer: ...
30
+
31
+
17
32
  @js(builtin=True)
18
33
  class DataView:
19
34
  def __init__(
@@ -99,13 +114,25 @@ class Uint16Array(TypedArray): ...
99
114
  class Uint32Array(TypedArray): ...
100
115
 
101
116
 
117
+ @js(builtin=True)
118
+ class Math:
119
+ @js(analyze=False)
120
+ @staticmethod
121
+ def random() -> float:
122
+ return random.random()
123
+
124
+
102
125
  @js(builtin=True)
103
126
  class JSON:
127
+ @js(analyze=False)
104
128
  @staticmethod
105
- def parse(value: str) -> object: ...
129
+ def parse(value: str) -> object:
130
+ return json.loads(value)
106
131
 
132
+ @js(analyze=False)
107
133
  @staticmethod
108
- def stringify(value: object) -> str: ...
134
+ def stringify(value: object) -> str:
135
+ return json.dumps(value, default=vars, separators=(",", ":"))
109
136
 
110
137
 
111
138
  @js(builtin=True)