pyjs 0.0.1__tar.gz → 0.3.0__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 (205) hide show
  1. {pyjs-0.0.1 → pyjs-0.3.0}/PKG-INFO +52 -40
  2. {pyjs-0.0.1 → pyjs-0.3.0}/README.md +46 -36
  3. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/__init__.py +2 -2
  4. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/cli.py +94 -2
  5. pyjs-0.3.0/pyjs/decorators.py +396 -0
  6. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/docs/ui.py +27 -7
  7. pyjs-0.3.0/pyjs/javascript.py +178 -0
  8. pyjs-0.3.0/pyjs/lib/__init__.py +1 -0
  9. pyjs-0.3.0/pyjs/lib/pydantic/__init__.py +1 -0
  10. pyjs-0.3.0/pyjs/lib/pydantic/v2.py +199 -0
  11. pyjs-0.3.0/pyjs/nativescript/__init__.py +475 -0
  12. pyjs-0.3.0/pyjs/nativescript/collectionview.py +104 -0
  13. pyjs-0.3.0/pyjs/nativescript/keyboard.py +52 -0
  14. pyjs-0.3.0/pyjs/nativescript/masonry.py +399 -0
  15. pyjs-0.3.0/pyjs/nativescript/reorderable.py +293 -0
  16. pyjs-0.3.0/pyjs/nativescript/simulator.py +944 -0
  17. pyjs-0.3.0/pyjs/nativescript/transport.py +40 -0
  18. pyjs-0.3.0/pyjs/python.py +2225 -0
  19. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/scaffolding/__init__.py +4 -0
  20. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/scaffolding/templates/app/README.md.template +7 -0
  21. pyjs-0.3.0/pyjs/server/__init__.py +1401 -0
  22. pyjs-0.3.0/pyjs/server/django/__init__.py +16 -0
  23. pyjs-0.3.0/pyjs/server/django/api.py +136 -0
  24. pyjs-0.3.0/pyjs/server/django/application.py +182 -0
  25. pyjs-0.3.0/pyjs/server/django/jsonapi.py +277 -0
  26. pyjs-0.3.0/pyjs/server/django/live.py +381 -0
  27. pyjs-0.3.0/pyjs/server/django/model.py +172 -0
  28. pyjs-0.3.0/pyjs/server/django/queryset.py +29 -0
  29. pyjs-0.3.0/pyjs/server/errors.py +129 -0
  30. pyjs-0.3.0/pyjs/server/jsonapi.py +267 -0
  31. pyjs-0.3.0/pyjs/server/live.py +167 -0
  32. pyjs-0.3.0/pyjs/server/protocol.py +7 -0
  33. pyjs-0.3.0/pyjs/server/transport.py +68 -0
  34. pyjs-0.3.0/pyjs/server/watch.py +623 -0
  35. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/skills/pyjs/SKILL.md +20 -2
  36. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/state.py +1 -1
  37. pyjs-0.3.0/pyjs/stdlib/__init__.py +1 -0
  38. pyjs-0.3.0/pyjs/stdlib/dataclasses.py +168 -0
  39. pyjs-0.3.0/pyjs/stdlib/math.py +92 -0
  40. pyjs-0.3.0/pyjs/stdlib/typing.py +10 -0
  41. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/android.py +69 -0
  42. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/builder.py +9 -0
  43. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/client/app.py +62 -37
  44. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/client/assertions.py +2 -2
  45. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/client/runtime.py +6 -6
  46. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/client/sidebar.py +3 -1
  47. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/client/state.py +12 -13
  48. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/client/viewer.py +8 -8
  49. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/daemon.py +83 -40
  50. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/helpers.py +89 -13
  51. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/pytest_plugin.py +29 -28
  52. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/web.py +68 -18
  53. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/tooling/browser.py +51 -22
  54. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/tooling/nativescript.py +54 -5
  55. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/transpiler/__init__.py +10 -0
  56. pyjs-0.3.0/pyjs/transpiler/analyzer.py +5694 -0
  57. pyjs-0.3.0/pyjs/transpiler/diagnostics.py +416 -0
  58. pyjs-0.3.0/pyjs/transpiler/libraries.py +182 -0
  59. pyjs-0.3.0/pyjs/transpiler/objects.py +2403 -0
  60. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/transpiler/source.py +130 -14
  61. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/transpiler/transpiler.py +650 -64
  62. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/transpiler/utils.py +23 -4
  63. pyjs-0.3.0/pyjs/ui/__init__.py +70 -0
  64. pyjs-0.3.0/pyjs/ui/gesture.py +161 -0
  65. pyjs-0.3.0/pyjs/ui/interaction.py +681 -0
  66. pyjs-0.3.0/pyjs/ui/reorder_trace.py +359 -0
  67. pyjs-0.3.0/pyjs/ui/reorderable.py +255 -0
  68. pyjs-0.3.0/pyjs/web/__init__.py +1 -0
  69. pyjs-0.3.0/pyjs/web/clipboard.py +139 -0
  70. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/console.py +1 -1
  71. pyjs-0.3.0/pyjs/web/crypto.py +1155 -0
  72. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/dom.py +1781 -417
  73. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/domx.py +65 -40
  74. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/dragdrop.py +8 -12
  75. pyjs-0.3.0/pyjs/web/encoding.py +128 -0
  76. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/events.py +1100 -568
  77. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/files.py +44 -25
  78. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/geometry.py +137 -60
  79. pyjs-0.3.0/pyjs/web/html.py +4571 -0
  80. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/indexeddb.py +141 -61
  81. pyjs-0.3.0/pyjs/web/navigation.py +175 -0
  82. pyjs-0.3.0/pyjs/web/network.py +602 -0
  83. pyjs-0.3.0/pyjs/web/serviceworker.py +1042 -0
  84. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ssr.py +10 -8
  85. pyjs-0.3.0/pyjs/web/storage.py +43 -0
  86. pyjs-0.3.0/pyjs/web/streams.py +478 -0
  87. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/svg.py +573 -39
  88. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/timers.py +7 -7
  89. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/__init__.py +1 -1
  90. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/accordion.py +4 -2
  91. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/calendar.py +3 -1
  92. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/combobox.py +3 -1
  93. pyjs-0.3.0/pyjs/web/ui/date.py +55 -0
  94. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/dialog.py +8 -4
  95. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/dropdown_menu.py +6 -4
  96. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/hover_card.py +2 -2
  97. pyjs-0.3.0/pyjs/web/ui/model.py +923 -0
  98. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/navigation_menu.py +5 -1
  99. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/popover.py +7 -5
  100. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/radio_group.py +3 -1
  101. pyjs-0.3.0/pyjs/web/ui/reorderable.py +201 -0
  102. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/resizable.py +6 -4
  103. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/select.py +2 -4
  104. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/sheet.py +10 -1
  105. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/sidebar.py +42 -1
  106. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/sonner.py +3 -1
  107. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/tabs.py +4 -2
  108. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/toggle.py +3 -1
  109. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/tooltip.py +2 -2
  110. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/url.py +5 -4
  111. pyjs-0.3.0/pyjs/web/webgpu.py +2231 -0
  112. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs.egg-info/PKG-INFO +52 -40
  113. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs.egg-info/SOURCES.txt +45 -3
  114. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs.egg-info/requires.txt +5 -1
  115. {pyjs-0.0.1 → pyjs-0.3.0}/pyproject.toml +22 -3
  116. pyjs-0.0.1/pyjs/decorators.py +0 -170
  117. pyjs-0.0.1/pyjs/nativescript/__init__.py +0 -77
  118. pyjs-0.0.1/pyjs/server.py +0 -468
  119. pyjs-0.0.1/pyjs/transpiler/_builtins.py +0 -485
  120. pyjs-0.0.1/pyjs/transpiler/analyzer.py +0 -1495
  121. pyjs-0.0.1/pyjs/transpiler/objects.py +0 -1015
  122. pyjs-0.0.1/pyjs/web/__init__.py +0 -5
  123. pyjs-0.0.1/pyjs/web/html.py +0 -927
  124. pyjs-0.0.1/pyjs/web/javascript.py +0 -112
  125. pyjs-0.0.1/pyjs/web/network.py +0 -193
  126. pyjs-0.0.1/pyjs/web/streams.py +0 -17
  127. pyjs-0.0.1/pyjs/web/webgpu.py +0 -496
  128. {pyjs-0.0.1 → pyjs-0.3.0}/LICENSE +0 -0
  129. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/__main__.py +0 -0
  130. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/docs/__init__.py +0 -0
  131. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/docs/builder.py +0 -0
  132. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/docs/cli.py +0 -0
  133. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/docs/config.py +0 -0
  134. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/docs/favicon.svg +0 -0
  135. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/docs/markdown.py +0 -0
  136. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/docs/models.py +0 -0
  137. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/docs/navigation.py +0 -0
  138. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/docs/style.css +0 -0
  139. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__PYJS_PACKAGE__.py.template +0 -0
  140. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__init__.py.template +0 -0
  141. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__main__.py.template +0 -0
  142. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/scaffolding/templates/app/tests/test_app.py.template +0 -0
  143. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/scaffolding/templates/app/tests/test_browser_app.py.template +0 -0
  144. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/scaffolding/templates/app_test.py.template +0 -0
  145. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/__init__.py +0 -0
  146. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/artifacts.py +0 -0
  147. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/assertion_rewriter.py +0 -0
  148. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/capture.py +0 -0
  149. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/client/__init__.py +0 -0
  150. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/protocol.py +0 -0
  151. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/testing/webgpu.py +0 -0
  152. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/tooling/__init__.py +0 -0
  153. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/tooling/android.py +0 -0
  154. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/tooling/command.py +0 -0
  155. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/tooling/node.py +0 -0
  156. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/tooling/perf.py +0 -0
  157. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/alert.py +0 -0
  158. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/alert_dialog.py +0 -0
  159. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/aspect_ratio.py +0 -0
  160. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/attachment.py +0 -0
  161. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/avatar.py +0 -0
  162. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/badge.py +0 -0
  163. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/breadcrumb.py +0 -0
  164. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/bubble.py +0 -0
  165. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/button.py +0 -0
  166. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/card.py +0 -0
  167. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/carousel.py +0 -0
  168. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/chart.py +0 -0
  169. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/checkbox.py +0 -0
  170. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/collapsible.py +0 -0
  171. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/command.py +0 -0
  172. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/context_menu.py +0 -0
  173. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/date_picker.py +0 -0
  174. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/direction.py +0 -0
  175. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/drawer.py +0 -0
  176. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/empty.py +0 -0
  177. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/field.py +0 -0
  178. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/floating.py +0 -0
  179. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/input.py +0 -0
  180. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/input_group.py +0 -0
  181. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/input_otp.py +0 -0
  182. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/item.py +0 -0
  183. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/kbd.py +0 -0
  184. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/label.py +0 -0
  185. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/marker.py +0 -0
  186. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/menubar.py +0 -0
  187. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/message.py +0 -0
  188. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/message_scroller.py +0 -0
  189. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/native_select.py +0 -0
  190. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/pagination.py +0 -0
  191. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/progress.py +0 -0
  192. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/scroll_area.py +0 -0
  193. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/separator.py +0 -0
  194. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/skeleton.py +0 -0
  195. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/slider.py +0 -0
  196. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/spinner.py +0 -0
  197. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/switch.py +0 -0
  198. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/table.py +0 -0
  199. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/text.py +0 -0
  200. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/textarea.py +0 -0
  201. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs/web/ui/typography.py +0 -0
  202. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs.egg-info/dependency_links.txt +0 -0
  203. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs.egg-info/entry_points.txt +0 -0
  204. {pyjs-0.0.1 → pyjs-0.3.0}/pyjs.egg-info/top_level.txt +0 -0
  205. {pyjs-0.0.1 → pyjs-0.3.0}/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.3.0
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
@@ -27,17 +26,20 @@ Description-Content-Type: text/markdown
27
26
  License-File: LICENSE
28
27
  Requires-Dist: markdown>=3.8
29
28
  Requires-Dist: pillow
29
+ Requires-Dist: pydantic<3,>=2
30
30
  Requires-Dist: pyyaml>=6.0
31
31
  Requires-Dist: pytest
32
32
  Requires-Dist: websockets
33
33
  Provides-Extra: examples
34
- Requires-Dist: pyjs-examples==0.0.1; extra == "examples"
34
+ Requires-Dist: pyjs-examples==0.3.0; extra == "examples"
35
+ Provides-Extra: django
36
+ Requires-Dist: django<6.2,>=6.0; extra == "django"
35
37
  Dynamic: license-file
36
38
 
37
39
  # PyJS: Python to JavaScript
38
40
 
39
- > Pre-alpha: useful applications and tests work today, but APIs may change before the first
40
- > release.
41
+ > Pre-alpha: useful applications and tests work today, but APIs may change during the early
42
+ > releases.
41
43
 
42
44
  PyJS is a statically analyzed Python-to-JavaScript compiler. It turns reachable, typed Python code
43
45
  into readable, tree-shaken JavaScript without shipping a Python runtime. Its current libraries make
@@ -87,17 +89,8 @@ python -m pytest -q
87
89
  python -m pytest -q --pyjs-target=web
88
90
  ```
89
91
 
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
- ```
92
+ To develop PyJS itself from a source checkout, see
93
+ [CONTRIBUTING.md](CONTRIBUTING.md).
101
94
 
102
95
  ## Start from an example
103
96
 
@@ -119,7 +112,9 @@ pyjs create dialog_demo --template pyjs_examples.samples.ui_dialog
119
112
  `pyjs create NAME` creates a project in `NAME/`, with application code in
120
113
  `NAME/NAME/NAME.py` and tests in `NAME/tests/`. Pass a destination as the second positional argument
121
114
  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.
115
+ package under `src/`. After installation, `python -m NAME` starts either package layout through its
116
+ ordinary Python entry point. `pyjs serve` is also available as a convenience and uses the
117
+ application recorded in `pyproject.toml`.
123
118
  `--single-file` explicitly requests one standalone Python file and requires a file template when
124
119
  combined with `--template`. The `pyjs-examples` distribution registers both file and directory
125
120
  templates and contains the source copied by `pyjs create`; templates are not embedded in the
@@ -161,6 +156,10 @@ available to the browser compiler, and reachable methods are included in the gen
161
156
  `CustomElement` subclasses render on the server and hydrate as browser-native custom elements.
162
157
  `ref()` reconnects Python attributes to existing server-rendered nodes rather than recreating them.
163
158
 
159
+ Module values cross the same explicit compilation boundary through a `JS[T]` annotation. Combine
160
+ it with `Final` for constants, such as `heartbeat_interval: Final[JS[int]] = 5_000`; unmarked
161
+ module values remain server-only and cannot be included by an accidental browser-side reference.
162
+
164
163
  Values that must survive rendering and hydration can live on the custom element as DOM attributes.
165
164
  The `state()` descriptor and `@effect(...)` provide a small typed reactive layer for updating the
166
165
  DOM imperatively. Server-only handlers and browser methods can coexist in the same module.
@@ -295,6 +294,11 @@ The analyzer preserves concrete element and key/value types for built-in collect
295
294
  `list[T]`, `dict[K, V]`, and `tuple[...]`. User-defined generic specialization exists in the
296
295
  analyzer but remains experimental and is not yet a stable application-facing feature.
297
296
 
297
+ Typed tuples and lists can be unpacked into local names. Tuple and literal-list
298
+ arity is checked during compilation; dynamic lists retain Python's runtime
299
+ arity errors. Nested, starred, and chained unpacking targets are not yet
300
+ supported.
301
+
298
302
  ### Async code and exceptions
299
303
 
300
304
  Async functions and `await` lower to JavaScript promises. Typed browser APIs such as `fetch()`,
@@ -363,8 +367,9 @@ python -m pytest -q
363
367
  python -m pytest -q --pyjs-target=web
364
368
  ```
365
369
 
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
370
+ Use `pytest.mark.pyjs_web` for tests that should be compiled and run in the browser.
371
+ Unmarked tests run only as ordinary Python tests; `pytest.mark.pyjs_python` can make that intent
372
+ explicit. A filename such as
368
373
  `test_browser_dialog.py` is only an organizational convention and has no implicit behavior.
369
374
 
370
375
  Browser tests retain console output and errors. Tests that render meaningful UI retain their iframe
@@ -380,20 +385,41 @@ preview, and render assertions can compare screenshots against checked-in PNG ba
380
385
  | `pyjs --src-all INPUT` | Include all tree-shaken dependency sources |
381
386
  | `pyjs --perf INPUT` | Compare Python and generated-JavaScript performance |
382
387
  | `pyjs create NAME [DESTINATION]` | Create a starter project |
388
+ | `pyjs serve [TARGET]` | Serve a configured project, module, or Python file |
383
389
  | `pyjs template` | List templates registered by installed packages |
384
390
  | `pyjs template NAME` | Print the complete materialized template source |
385
391
  | `pyjs template NAME --src` | Print the transpiled entry-module JavaScript |
386
392
  | `pyjs build MODULE[:ENTRY]` | Write generated JavaScript, CSS, and HTML |
387
393
  | `pyjs docs build` | Build a static documentation site |
388
394
  | `pyjs docs serve` | Build and serve documentation locally |
395
+ | `pyjs inspect URL` | Capture a screenshot and structured browser diagnostics |
389
396
  | `pyjs skill` | Print version-matched instructions for coding agents |
390
397
 
391
398
  The built-in application server is run from Python source with `serve(__file__)`; the generated
392
399
  starter and examples already provide this entry point.
393
400
 
401
+ NativeScript projects can declare external npm modules without editing the
402
+ generated build directory:
403
+
404
+ ```python
405
+ from pyjs.nativescript import NativeScriptModule
406
+ from pyjs.tooling.nativescript import NativeScriptProject
407
+
408
+ widgets = NativeScriptModule("@example/widgets", "1.2.3", ("Widget",))
409
+ project = NativeScriptProject(
410
+ main,
411
+ name="Example",
412
+ app_id="org.example.app",
413
+ modules=(widgets,),
414
+ )
415
+ ```
416
+
417
+ PyJS installs the pinned package and emits its CommonJS imports before the
418
+ transpiled application bundle.
419
+
394
420
  ## Current limitations and missing features
395
421
 
396
- PyJS is intentionally a typed subset of Python, and the first release remains pre-alpha:
422
+ PyJS is intentionally a typed subset of Python, and the current releases remain pre-alpha:
397
423
 
398
424
  - Multiple inheritance is not supported.
399
425
  - Reflection, runtime monkey-patching, `eval()`, and arbitrary dynamic imports are outside the
@@ -415,27 +441,13 @@ PyJS is intentionally a typed subset of Python, and the first release remains pr
415
441
  - NativeScript output is experimental; the first proof of concept currently targets Android and
416
442
  covers a small set of core views.
417
443
 
418
- See [TESTING.md](TESTING.md) and [TREE_SHAKING.md](TREE_SHAKING.md) for focused implementation
444
+ See the [testing guide](docs/guide/testing.md) and
445
+ [TREE_SHAKING.md](TREE_SHAKING.md) for focused behavior and implementation
419
446
  status. The broader guides and references live in [docs/](docs/).
420
447
 
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
- ```
448
+ ## Contributing
437
449
 
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.
450
+ The development environment, repository structure, compiler contracts, and
451
+ verification workflow are documented in [CONTRIBUTING.md](CONTRIBUTING.md).
440
452
 
441
453
  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.
@@ -259,6 +256,11 @@ The analyzer preserves concrete element and key/value types for built-in collect
259
256
  `list[T]`, `dict[K, V]`, and `tuple[...]`. User-defined generic specialization exists in the
260
257
  analyzer but remains experimental and is not yet a stable application-facing feature.
261
258
 
259
+ Typed tuples and lists can be unpacked into local names. Tuple and literal-list
260
+ arity is checked during compilation; dynamic lists retain Python's runtime
261
+ arity errors. Nested, starred, and chained unpacking targets are not yet
262
+ supported.
263
+
262
264
  ### Async code and exceptions
263
265
 
264
266
  Async functions and `await` lower to JavaScript promises. Typed browser APIs such as `fetch()`,
@@ -327,8 +329,9 @@ python -m pytest -q
327
329
  python -m pytest -q --pyjs-target=web
328
330
  ```
329
331
 
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
332
+ Use `pytest.mark.pyjs_web` for tests that should be compiled and run in the browser.
333
+ Unmarked tests run only as ordinary Python tests; `pytest.mark.pyjs_python` can make that intent
334
+ explicit. A filename such as
332
335
  `test_browser_dialog.py` is only an organizational convention and has no implicit behavior.
333
336
 
334
337
  Browser tests retain console output and errors. Tests that render meaningful UI retain their iframe
@@ -344,20 +347,41 @@ preview, and render assertions can compare screenshots against checked-in PNG ba
344
347
  | `pyjs --src-all INPUT` | Include all tree-shaken dependency sources |
345
348
  | `pyjs --perf INPUT` | Compare Python and generated-JavaScript performance |
346
349
  | `pyjs create NAME [DESTINATION]` | Create a starter project |
350
+ | `pyjs serve [TARGET]` | Serve a configured project, module, or Python file |
347
351
  | `pyjs template` | List templates registered by installed packages |
348
352
  | `pyjs template NAME` | Print the complete materialized template source |
349
353
  | `pyjs template NAME --src` | Print the transpiled entry-module JavaScript |
350
354
  | `pyjs build MODULE[:ENTRY]` | Write generated JavaScript, CSS, and HTML |
351
355
  | `pyjs docs build` | Build a static documentation site |
352
356
  | `pyjs docs serve` | Build and serve documentation locally |
357
+ | `pyjs inspect URL` | Capture a screenshot and structured browser diagnostics |
353
358
  | `pyjs skill` | Print version-matched instructions for coding agents |
354
359
 
355
360
  The built-in application server is run from Python source with `serve(__file__)`; the generated
356
361
  starter and examples already provide this entry point.
357
362
 
363
+ NativeScript projects can declare external npm modules without editing the
364
+ generated build directory:
365
+
366
+ ```python
367
+ from pyjs.nativescript import NativeScriptModule
368
+ from pyjs.tooling.nativescript import NativeScriptProject
369
+
370
+ widgets = NativeScriptModule("@example/widgets", "1.2.3", ("Widget",))
371
+ project = NativeScriptProject(
372
+ main,
373
+ name="Example",
374
+ app_id="org.example.app",
375
+ modules=(widgets,),
376
+ )
377
+ ```
378
+
379
+ PyJS installs the pinned package and emits its CommonJS imports before the
380
+ transpiled application bundle.
381
+
358
382
  ## Current limitations and missing features
359
383
 
360
- PyJS is intentionally a typed subset of Python, and the first release remains pre-alpha:
384
+ PyJS is intentionally a typed subset of Python, and the current releases remain pre-alpha:
361
385
 
362
386
  - Multiple inheritance is not supported.
363
387
  - Reflection, runtime monkey-patching, `eval()`, and arbitrary dynamic imports are outside the
@@ -379,27 +403,13 @@ PyJS is intentionally a typed subset of Python, and the first release remains pr
379
403
  - NativeScript output is experimental; the first proof of concept currently targets Android and
380
404
  covers a small set of core views.
381
405
 
382
- See [TESTING.md](TESTING.md) and [TREE_SHAKING.md](TREE_SHAKING.md) for focused implementation
406
+ See the [testing guide](docs/guide/testing.md) and
407
+ [TREE_SHAKING.md](TREE_SHAKING.md) for focused behavior and implementation
383
408
  status. The broader guides and references live in [docs/](docs/).
384
409
 
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
- ```
410
+ ## Contributing
401
411
 
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.
412
+ The development environment, repository structure, compiler contracts, and
413
+ verification workflow are documented in [CONTRIBUTING.md](CONTRIBUTING.md).
404
414
 
405
415
  PyJS is distributed under the [BSD 3-Clause License](LICENSE).
@@ -1,6 +1,6 @@
1
- __version__ = (0, 0, 1)
1
+ __version__ = (0, 3, 0)
2
2
 
3
3
  from .decorators import *
4
4
  from .state import effect, state
5
5
 
6
- __all__ = ["effect", "state"]
6
+ __all__ = ["effect", "state", "js"]
@@ -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":