pyjs 0.4.0__tar.gz → 0.5.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.
- pyjs-0.5.0/PKG-INFO +1512 -0
- pyjs-0.5.0/README.md +1465 -0
- pyjs-0.5.0/pyjs/__init__.py +37 -0
- pyjs-0.5.0/pyjs/analysis/__init__.py +33 -0
- pyjs-0.5.0/pyjs/analysis/analyzer.py +17236 -0
- pyjs-0.5.0/pyjs/analysis/comprehensions.py +156 -0
- {pyjs-0.4.0/pyjs/transpiler → pyjs-0.5.0/pyjs/analysis}/diagnostics.py +48 -4
- pyjs-0.5.0/pyjs/analysis/generic_inference.py +316 -0
- pyjs-0.5.0/pyjs/analysis/ir.py +1911 -0
- pyjs-0.5.0/pyjs/analysis/iterable_protocol.py +313 -0
- pyjs-0.5.0/pyjs/analysis/lambdas.py +31 -0
- {pyjs-0.4.0/pyjs/transpiler → pyjs-0.5.0/pyjs/analysis}/libraries.py +80 -31
- pyjs-0.5.0/pyjs/analysis/lifetime.py +1320 -0
- {pyjs-0.4.0/pyjs/transpiler → pyjs-0.5.0/pyjs/analysis}/objects.py +1335 -152
- pyjs-0.5.0/pyjs/analysis/rendering.py +274 -0
- pyjs-0.5.0/pyjs/analysis/representation.py +435 -0
- {pyjs-0.4.0/pyjs/transpiler → pyjs-0.5.0/pyjs/analysis}/source.py +54 -123
- pyjs-0.5.0/pyjs/analysis/super_proxy.py +117 -0
- pyjs-0.5.0/pyjs/analysis/type_relations.py +518 -0
- pyjs-0.5.0/pyjs/analysis/value_representation.py +377 -0
- pyjs-0.5.0/pyjs/android/__init__.py +1336 -0
- pyjs-0.5.0/pyjs/android/alarms.py +30 -0
- pyjs-0.5.0/pyjs/android/androidx_runtime.json +197 -0
- pyjs-0.5.0/pyjs/android/api.py +355 -0
- pyjs-0.5.0/pyjs/android/appwidget.py +453 -0
- pyjs-0.5.0/pyjs/android/binding_specs.py +629 -0
- pyjs-0.5.0/pyjs/android/controls.py +313 -0
- pyjs-0.5.0/pyjs/android/dates.py +25 -0
- pyjs-0.5.0/pyjs/android/dependencies.py +62 -0
- pyjs-0.5.0/pyjs/android/dialogs.py +49 -0
- pyjs-0.5.0/pyjs/android/dispatch.py +22 -0
- pyjs-0.5.0/pyjs/android/drawables.py +23 -0
- pyjs-0.5.0/pyjs/android/files.py +20 -0
- pyjs-0.5.0/pyjs/android/gestures.py +31 -0
- pyjs-0.5.0/pyjs/android/graphics.py +80 -0
- pyjs-0.5.0/pyjs/android/insets.py +34 -0
- pyjs-0.5.0/pyjs/android/json.py +38 -0
- pyjs-0.5.0/pyjs/android/keystore.py +35 -0
- pyjs-0.5.0/pyjs/android/menus.py +64 -0
- pyjs-0.5.0/pyjs/android/motion.py +68 -0
- pyjs-0.5.0/pyjs/android/notifications.py +125 -0
- pyjs-0.5.0/pyjs/android/pickers.py +56 -0
- pyjs-0.5.0/pyjs/android/recycler_testing.py +100 -0
- pyjs-0.5.0/pyjs/android/recyclerview.py +669 -0
- pyjs-0.5.0/pyjs/android/reorder.py +115 -0
- pyjs-0.5.0/pyjs/android/sqlite.py +96 -0
- pyjs-0.5.0/pyjs/android/testing.py +185 -0
- pyjs-0.5.0/pyjs/android/text.py +49 -0
- pyjs-0.5.0/pyjs/android/uiautomator.py +57 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/cli.py +308 -76
- pyjs-0.5.0/pyjs/decorators.py +1020 -0
- pyjs-0.5.0/pyjs/docs/__init__.py +6 -0
- pyjs-0.5.0/pyjs/docs/api.py +96 -0
- pyjs-0.5.0/pyjs/docs/api_extraction.py +289 -0
- pyjs-0.5.0/pyjs/docs/api_rendering.py +496 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/docs/builder.py +172 -16
- pyjs-0.5.0/pyjs/docs/cli.py +91 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/docs/config.py +46 -0
- pyjs-0.5.0/pyjs/docs/diagram_markdown.py +43 -0
- pyjs-0.5.0/pyjs/docs/diagrams.py +611 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/docs/markdown.py +2 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/docs/models.py +9 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/docs/navigation.py +3 -1
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/docs/style.css +182 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/docs/ui.py +47 -23
- pyjs-0.5.0/pyjs/electron/__init__.py +145 -0
- pyjs-0.5.0/pyjs/electron/_notification_worker.py +67 -0
- pyjs-0.5.0/pyjs/electron/notifications.py +299 -0
- pyjs-0.5.0/pyjs/electron/session.py +102 -0
- pyjs-0.5.0/pyjs/electron/window.py +65 -0
- pyjs-0.5.0/pyjs/java/__init__.py +145 -0
- pyjs-0.5.0/pyjs/java/analysis.py +480 -0
- pyjs-0.5.0/pyjs/java/api.py +116 -0
- pyjs-0.5.0/pyjs/java/base64.py +29 -0
- pyjs-0.5.0/pyjs/java/bindings.py +648 -0
- pyjs-0.5.0/pyjs/java/boxed.py +161 -0
- pyjs-0.5.0/pyjs/java/callables.py +139 -0
- pyjs-0.5.0/pyjs/java/charset.py +17 -0
- pyjs-0.5.0/pyjs/java/classfile.py +477 -0
- pyjs-0.5.0/pyjs/java/classpath.py +612 -0
- pyjs-0.5.0/pyjs/java/collections.py +29 -0
- pyjs-0.5.0/pyjs/java/comprehensions.py +59 -0
- pyjs-0.5.0/pyjs/java/concurrent.py +35 -0
- pyjs-0.5.0/pyjs/java/crypto.py +93 -0
- pyjs-0.5.0/pyjs/java/diagnostics.py +15 -0
- pyjs-0.5.0/pyjs/java/dictionaries.py +28 -0
- pyjs-0.5.0/pyjs/java/errors.py +28 -0
- pyjs-0.5.0/pyjs/java/exception_reporting.py +212 -0
- pyjs-0.5.0/pyjs/java/exceptions.py +424 -0
- pyjs-0.5.0/pyjs/java/io.py +113 -0
- pyjs-0.5.0/pyjs/java/json.py +307 -0
- pyjs-0.5.0/pyjs/java/json_codegen.py +281 -0
- pyjs-0.5.0/pyjs/java/list_equality.py +71 -0
- pyjs-0.5.0/pyjs/java/list_slices.py +162 -0
- pyjs-0.5.0/pyjs/java/local_state.py +102 -0
- pyjs-0.5.0/pyjs/java/math.py +17 -0
- pyjs-0.5.0/pyjs/java/models.py +219 -0
- pyjs-0.5.0/pyjs/java/net.py +114 -0
- pyjs-0.5.0/pyjs/java/primitives.py +53 -0
- pyjs-0.5.0/pyjs/java/reporting.py +15 -0
- pyjs-0.5.0/pyjs/java/security.py +32 -0
- pyjs-0.5.0/pyjs/java/sets.py +85 -0
- pyjs-0.5.0/pyjs/java/sorting.py +68 -0
- pyjs-0.5.0/pyjs/java/stack.py +124 -0
- pyjs-0.5.0/pyjs/java/string_runtime.py +1221 -0
- pyjs-0.5.0/pyjs/java/time.py +87 -0
- pyjs-0.5.0/pyjs/java/transpiler.py +6846 -0
- pyjs-0.5.0/pyjs/java/uuid.py +25 -0
- pyjs-0.5.0/pyjs/java/zip.py +31 -0
- pyjs-0.5.0/pyjs/javascript/__init__.py +743 -0
- pyjs-0.5.0/pyjs/javascript/_async.py +20 -0
- pyjs-0.5.0/pyjs/javascript/source.py +149 -0
- {pyjs-0.4.0/pyjs/transpiler → pyjs-0.5.0/pyjs/javascript}/sourcemap.py +128 -3
- {pyjs-0.4.0/pyjs/transpiler → pyjs-0.5.0/pyjs/javascript}/transpiler.py +863 -208
- pyjs-0.5.0/pyjs/javascript/utils.py +69 -0
- pyjs-0.5.0/pyjs/language/__init__.py +3 -0
- pyjs-0.5.0/pyjs/language/completion.py +283 -0
- pyjs-0.5.0/pyjs/language/diagnostics.py +23 -0
- pyjs-0.5.0/pyjs/language/queries.py +36 -0
- pyjs-0.5.0/pyjs/language/server.py +179 -0
- pyjs-0.5.0/pyjs/language/session.py +292 -0
- pyjs-0.5.0/pyjs/language/signatures.py +271 -0
- pyjs-0.5.0/pyjs/language/snapshots.py +231 -0
- pyjs-0.5.0/pyjs/language/store.py +71 -0
- pyjs-0.5.0/pyjs/language/worker.py +200 -0
- pyjs-0.5.0/pyjs/lib/pydantic/constraints.py +61 -0
- pyjs-0.5.0/pyjs/lib/pydantic/patterns.py +187 -0
- pyjs-0.5.0/pyjs/lib/pydantic/v2.py +423 -0
- pyjs-0.5.0/pyjs/native/PYTHON-LICENSE.txt +52 -0
- pyjs-0.5.0/pyjs/native/UNICODE-LICENSE.txt +39 -0
- pyjs-0.5.0/pyjs/native/__init__.py +203 -0
- pyjs-0.5.0/pyjs/native/analysis.py +1913 -0
- pyjs-0.5.0/pyjs/native/attribute_queries.py +205 -0
- pyjs-0.5.0/pyjs/native/binary.py +332 -0
- pyjs-0.5.0/pyjs/native/bindings.py +26 -0
- pyjs-0.5.0/pyjs/native/bytes_construction.py +138 -0
- pyjs-0.5.0/pyjs/native/callable_adapters.py +368 -0
- pyjs-0.5.0/pyjs/native/callables.py +452 -0
- pyjs-0.5.0/pyjs/native/callback_ops.py +302 -0
- pyjs-0.5.0/pyjs/native/calls.py +1211 -0
- pyjs-0.5.0/pyjs/native/class_constants.py +97 -0
- pyjs-0.5.0/pyjs/native/cli.py +299 -0
- pyjs-0.5.0/pyjs/native/closures.py +214 -0
- pyjs-0.5.0/pyjs/native/collection_ops.py +1630 -0
- pyjs-0.5.0/pyjs/native/comparisons.py +983 -0
- pyjs-0.5.0/pyjs/native/comprehensions.py +23 -0
- pyjs-0.5.0/pyjs/native/coroutines.py +48 -0
- pyjs-0.5.0/pyjs/native/dataclasses.py +142 -0
- pyjs-0.5.0/pyjs/native/datetime.py +860 -0
- pyjs-0.5.0/pyjs/native/delegation.py +323 -0
- pyjs-0.5.0/pyjs/native/delegation_ops.py +101 -0
- pyjs-0.5.0/pyjs/native/dom_ops.py +906 -0
- pyjs-0.5.0/pyjs/native/dom_state.py +266 -0
- pyjs-0.5.0/pyjs/native/dom_types.py +253 -0
- pyjs-0.5.0/pyjs/native/enum.py +24 -0
- pyjs-0.5.0/pyjs/native/enum_ops.py +201 -0
- pyjs-0.5.0/pyjs/native/erased_comparison.py +233 -0
- pyjs-0.5.0/pyjs/native/erased_dom.py +72 -0
- pyjs-0.5.0/pyjs/native/erased_repr.py +117 -0
- pyjs-0.5.0/pyjs/native/errors.py +42 -0
- pyjs-0.5.0/pyjs/native/exception_values.py +191 -0
- pyjs-0.5.0/pyjs/native/expressions.py +594 -0
- pyjs-0.5.0/pyjs/native/format_ops.py +183 -0
- pyjs-0.5.0/pyjs/native/functional.py +40 -0
- pyjs-0.5.0/pyjs/native/gc_layouts.py +147 -0
- pyjs-0.5.0/pyjs/native/generators.py +501 -0
- pyjs-0.5.0/pyjs/native/grouping_ops.py +94 -0
- pyjs-0.5.0/pyjs/native/hashing.py +330 -0
- pyjs-0.5.0/pyjs/native/identity.py +35 -0
- pyjs-0.5.0/pyjs/native/indexing.py +129 -0
- pyjs-0.5.0/pyjs/native/inplace.py +142 -0
- pyjs-0.5.0/pyjs/native/inputs.py +224 -0
- pyjs-0.5.0/pyjs/native/iterable_views.py +220 -0
- pyjs-0.5.0/pyjs/native/iterator_callbacks.py +253 -0
- pyjs-0.5.0/pyjs/native/iterator_ops.py +457 -0
- pyjs-0.5.0/pyjs/native/iterator_views.py +281 -0
- pyjs-0.5.0/pyjs/native/itertools.py +600 -0
- pyjs-0.5.0/pyjs/native/itertools_ops.py +574 -0
- pyjs-0.5.0/pyjs/native/json.py +17 -0
- pyjs-0.5.0/pyjs/native/json_ops.py +641 -0
- pyjs-0.5.0/pyjs/native/llvm.py +7841 -0
- pyjs-0.5.0/pyjs/native/mapping_keys.py +413 -0
- pyjs-0.5.0/pyjs/native/mapping_views.py +293 -0
- pyjs-0.5.0/pyjs/native/math.py +825 -0
- pyjs-0.5.0/pyjs/native/math_aggregates.py +113 -0
- pyjs-0.5.0/pyjs/native/math_ops.py +140 -0
- pyjs-0.5.0/pyjs/native/models.py +156 -0
- pyjs-0.5.0/pyjs/native/nullable.py +254 -0
- pyjs-0.5.0/pyjs/native/numeric_protocols.py +76 -0
- pyjs-0.5.0/pyjs/native/object_values.py +602 -0
- pyjs-0.5.0/pyjs/native/operator.py +512 -0
- pyjs-0.5.0/pyjs/native/output_ops.py +150 -0
- pyjs-0.5.0/pyjs/native/partials.py +264 -0
- pyjs-0.5.0/pyjs/native/pathlib.py +213 -0
- pyjs-0.5.0/pyjs/native/persistent.py +170 -0
- pyjs-0.5.0/pyjs/native/platform.py +22 -0
- pyjs-0.5.0/pyjs/native/properties.py +145 -0
- pyjs-0.5.0/pyjs/native/protocols.py +276 -0
- pyjs-0.5.0/pyjs/native/representation.py +447 -0
- pyjs-0.5.0/pyjs/native/rounding.py +82 -0
- pyjs-0.5.0/pyjs/native/runtime/__init__.py +1 -0
- pyjs-0.5.0/pyjs/native/runtime/accurate_sum.py +103 -0
- pyjs-0.5.0/pyjs/native/runtime/algorithms.py +353 -0
- pyjs-0.5.0/pyjs/native/runtime/arena.py +199 -0
- pyjs-0.5.0/pyjs/native/runtime/buffers.py +180 -0
- pyjs-0.5.0/pyjs/native/runtime/collector.py +379 -0
- pyjs-0.5.0/pyjs/native/runtime/combinatorics.py +68 -0
- pyjs-0.5.0/pyjs/native/runtime/compiler.py +162 -0
- pyjs-0.5.0/pyjs/native/runtime/dom.py +49 -0
- pyjs-0.5.0/pyjs/native/runtime/dom_storage.py +523 -0
- pyjs-0.5.0/pyjs/native/runtime/dom_tokens.py +161 -0
- pyjs-0.5.0/pyjs/native/runtime/error_messages.py +84 -0
- pyjs-0.5.0/pyjs/native/runtime/escaping.py +146 -0
- pyjs-0.5.0/pyjs/native/runtime/float_math.py +235 -0
- pyjs-0.5.0/pyjs/native/runtime/float_text.py +79 -0
- pyjs-0.5.0/pyjs/native/runtime/formatting.py +122 -0
- pyjs-0.5.0/pyjs/native/runtime/hashing.py +95 -0
- pyjs-0.5.0/pyjs/native/runtime/heap.py +89 -0
- pyjs-0.5.0/pyjs/native/runtime/identity.py +155 -0
- pyjs-0.5.0/pyjs/native/runtime/inputs.py +268 -0
- pyjs-0.5.0/pyjs/native/runtime/integer_math.py +221 -0
- pyjs-0.5.0/pyjs/native/runtime/iteration.py +1107 -0
- pyjs-0.5.0/pyjs/native/runtime/json_state.py +198 -0
- pyjs-0.5.0/pyjs/native/runtime/mappings.py +899 -0
- pyjs-0.5.0/pyjs/native/runtime/math_algorithms.py +102 -0
- pyjs-0.5.0/pyjs/native/runtime/math_calls.py +219 -0
- pyjs-0.5.0/pyjs/native/runtime/memory.py +288 -0
- pyjs-0.5.0/pyjs/native/runtime/norm.py +95 -0
- pyjs-0.5.0/pyjs/native/runtime/numeric.py +197 -0
- pyjs-0.5.0/pyjs/native/runtime/numeric_text.py +187 -0
- pyjs-0.5.0/pyjs/native/runtime/objects.py +127 -0
- pyjs-0.5.0/pyjs/native/runtime/ordering.py +211 -0
- pyjs-0.5.0/pyjs/native/runtime/output.py +124 -0
- pyjs-0.5.0/pyjs/native/runtime/pointers.py +222 -0
- pyjs-0.5.0/pyjs/native/runtime/ranges.py +270 -0
- pyjs-0.5.0/pyjs/native/runtime/roots.py +143 -0
- pyjs-0.5.0/pyjs/native/runtime/sequences.py +605 -0
- pyjs-0.5.0/pyjs/native/runtime/summation.py +38 -0
- pyjs-0.5.0/pyjs/native/runtime/system.py +48 -0
- pyjs-0.5.0/pyjs/native/runtime/text.py +325 -0
- pyjs-0.5.0/pyjs/native/runtime/text_buffers.py +166 -0
- pyjs-0.5.0/pyjs/native/runtime/text_edit.py +283 -0
- pyjs-0.5.0/pyjs/native/runtime/text_extra.py +312 -0
- pyjs-0.5.0/pyjs/native/runtime/text_format.py +240 -0
- pyjs-0.5.0/pyjs/native/runtime/text_operations.py +52 -0
- pyjs-0.5.0/pyjs/native/runtime/text_split.py +97 -0
- pyjs-0.5.0/pyjs/native/runtime/traces.py +74 -0
- pyjs-0.5.0/pyjs/native/runtime/unicode.py +227 -0
- pyjs-0.5.0/pyjs/native/runtime/url.py +122 -0
- pyjs-0.5.0/pyjs/native/runtime/values.py +67 -0
- pyjs-0.5.0/pyjs/native/runtime/wide.py +89 -0
- pyjs-0.5.0/pyjs/native/sentinel.py +88 -0
- pyjs-0.5.0/pyjs/native/slices.py +428 -0
- pyjs-0.5.0/pyjs/native/super_proxy.py +19 -0
- pyjs-0.5.0/pyjs/native/tagged.py +631 -0
- pyjs-0.5.0/pyjs/native/text_counts.py +53 -0
- pyjs-0.5.0/pyjs/native/text_ops.py +28 -0
- pyjs-0.5.0/pyjs/native/text_search.py +89 -0
- pyjs-0.5.0/pyjs/native/type_queries.py +282 -0
- pyjs-0.5.0/pyjs/native/unicode_data.py +9254 -0
- pyjs-0.5.0/pyjs/native/unpacking.py +134 -0
- pyjs-0.5.0/pyjs/native/urllib.py +10 -0
- pyjs-0.5.0/pyjs/native/uuid.py +47 -0
- pyjs-0.5.0/pyjs/node/__init__.py +267 -0
- pyjs-0.5.0/pyjs/node/files.py +69 -0
- pyjs-0.5.0/pyjs/node/json.py +14 -0
- pyjs-0.5.0/pyjs/numeric.py +1120 -0
- pyjs-0.4.0/pyjs/python.py → pyjs-0.5.0/pyjs/python/__init__.py +1049 -250
- pyjs-0.5.0/pyjs/python/native.py +1745 -0
- pyjs-0.5.0/pyjs/python/native_libraries.py +31 -0
- pyjs-0.5.0/pyjs/python/wgsl.py +332 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/scaffolding/__init__.py +4 -1
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/scaffolding/templates/app/README.md.template +4 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/__init__.py +251 -38
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/application.py +4 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/atomic.py +8 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/dev.py +70 -12
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/__init__.py +8 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/api.py +80 -4
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/application.py +86 -16
- pyjs-0.5.0/pyjs/server/django/development.py +143 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/dispatch.py +2 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/jsonapi.py +17 -5
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/live.py +1 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/model.py +9 -2
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/queryset.py +37 -2
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/relationship.py +14 -0
- pyjs-0.5.0/pyjs/server/django/stream.py +275 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/transport.py +2 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/errors.py +26 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/jsonapi.py +35 -6
- pyjs-0.5.0/pyjs/server/jvm.py +133 -0
- pyjs-0.5.0/pyjs/server/jvm_client.py +21 -0
- pyjs-0.5.0/pyjs/server/jvm_errors.py +97 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/live.py +16 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/pagination.py +6 -0
- pyjs-0.5.0/pyjs/server/protocol.py +21 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/rendering.py +16 -2
- pyjs-0.5.0/pyjs/server/stream.py +357 -0
- pyjs-0.5.0/pyjs/server/stream_binding.py +122 -0
- pyjs-0.5.0/pyjs/server/stream_client.py +156 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/transport.py +6 -0
- pyjs-0.5.0/pyjs/server/valkey.py +340 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/watch.py +25 -0
- pyjs-0.5.0/pyjs/shader/__init__.py +369 -0
- pyjs-0.5.0/pyjs/shader/analysis.py +137 -0
- pyjs-0.5.0/pyjs/shader/transpiler.py +1427 -0
- pyjs-0.5.0/pyjs/skills/pyjs/SKILL.md +1025 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/state.py +2 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/stdlib/__init__.py +4 -0
- pyjs-0.5.0/pyjs/stdlib/decimal.py +271 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/stdlib/math.py +52 -4
- pyjs-0.5.0/pyjs/testing/__init__.py +7 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/android.py +145 -25
- pyjs-0.5.0/pyjs/testing/android_browser.py +405 -0
- pyjs-0.5.0/pyjs/testing/android_device.py +467 -0
- pyjs-0.5.0/pyjs/testing/android_device_runtime.json +197 -0
- pyjs-0.5.0/pyjs/testing/android_jvm.py +140 -0
- pyjs-0.5.0/pyjs/testing/android_runtime.json +422 -0
- pyjs-0.5.0/pyjs/testing/android_runtime.py +244 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/assertion_rewriter.py +25 -14
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/builder.py +92 -17
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/capture.py +2 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/client/app.py +16 -12
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/client/assertions.py +1 -1
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/daemon.py +139 -47
- pyjs-0.5.0/pyjs/testing/espresso.py +376 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/helpers.py +3 -3
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/interaction/masonry.py +8 -8
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/interaction/scenario.py +2 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/protocol.py +1 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/pytest_plugin.py +462 -15
- pyjs-0.5.0/pyjs/testing/uiautomator.py +255 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/web.py +33 -16
- pyjs-0.5.0/pyjs/tooling/__init__.py +14 -0
- pyjs-0.5.0/pyjs/tooling/android.py +337 -0
- pyjs-0.5.0/pyjs/tooling/android_artifacts.py +161 -0
- pyjs-0.5.0/pyjs/tooling/android_jvm.py +578 -0
- pyjs-0.5.0/pyjs/tooling/android_manifest.py +68 -0
- pyjs-0.5.0/pyjs/tooling/android_manifest_runtime.json +405 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/tooling/browser.py +126 -38
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/tooling/command.py +4 -0
- pyjs-0.5.0/pyjs/tooling/electron.py +195 -0
- pyjs-0.5.0/pyjs/tooling/llvm.py +1162 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/tooling/node.py +85 -84
- pyjs-0.5.0/pyjs/tooling/node_build.py +54 -0
- pyjs-0.5.0/pyjs/tooling/npm.py +327 -0
- pyjs-0.5.0/pyjs/ui/diagram.py +465 -0
- pyjs-0.5.0/pyjs/ui/diagram_geometry.py +47 -0
- pyjs-0.5.0/pyjs/ui/diagram_layout.py +104 -0
- pyjs-0.4.0/pyjs/nativescript/simulator.py → pyjs-0.5.0/pyjs/ui/masonry.py +1 -1
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/ui/reorderable.py +78 -37
- pyjs-0.5.0/pyjs/web/_dom_storage.py +399 -0
- pyjs-0.5.0/pyjs/web/_webgpu.py +85 -0
- pyjs-0.5.0/pyjs/web/async_lock.py +61 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/clipboard.py +10 -2
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/dom.py +471 -102
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/domx.py +326 -79
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/dragdrop.py +5 -3
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/events.py +28 -28
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/html.py +232 -6
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/indexeddb.py +173 -39
- pyjs-0.5.0/pyjs/web/markdown.py +93 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/network.py +17 -6
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/serviceworker.py +5 -5
- pyjs-0.5.0/pyjs/web/sharing.py +40 -0
- pyjs-0.5.0/pyjs/web/ssr.py +181 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/__init__.py +6 -2
- pyjs-0.5.0/pyjs/web/ui/ai.py +126 -0
- pyjs-0.5.0/pyjs/web/ui/button.py +95 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/chart.py +225 -0
- pyjs-0.5.0/pyjs/web/ui/chat.py +145 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/checkbox.py +24 -4
- pyjs-0.5.0/pyjs/web/ui/combobox.py +446 -0
- pyjs-0.5.0/pyjs/web/ui/command.py +303 -0
- pyjs-0.5.0/pyjs/web/ui/diagram.py +223 -0
- pyjs-0.5.0/pyjs/web/ui/diagram_view.py +267 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/dialog.py +79 -9
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/drawer.py +4 -2
- pyjs-0.5.0/pyjs/web/ui/dropdown_menu.py +575 -0
- pyjs-0.5.0/pyjs/web/ui/effects.py +67 -0
- pyjs-0.5.0/pyjs/web/ui/field.py +151 -0
- pyjs-0.5.0/pyjs/web/ui/file_paste.py +67 -0
- pyjs-0.5.0/pyjs/web/ui/floating.py +164 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/hover_card.py +8 -4
- pyjs-0.5.0/pyjs/web/ui/image_preview.py +196 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/infinite_scroll.py +9 -3
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/input.py +11 -2
- pyjs-0.5.0/pyjs/web/ui/input_group.py +110 -0
- pyjs-0.5.0/pyjs/web/ui/markdown.py +131 -0
- pyjs-0.5.0/pyjs/web/ui/message_scroller.py +568 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/model.py +51 -24
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/pagination.py +2 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/popover.py +3 -1
- pyjs-0.5.0/pyjs/web/ui/prompt_input.py +155 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/resizable.py +37 -10
- pyjs-0.5.0/pyjs/web/ui/scroll_area.py +69 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/sidebar.py +2 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/slider.py +5 -2
- pyjs-0.5.0/pyjs/web/ui/sonner.py +138 -0
- pyjs-0.5.0/pyjs/web/ui/streaming_list.py +249 -0
- pyjs-0.5.0/pyjs/web/ui/streaming_log.py +77 -0
- pyjs-0.5.0/pyjs/web/ui/styles.py +21 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/switch.py +6 -3
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/table.py +2 -0
- pyjs-0.5.0/pyjs/web/ui/textarea.py +52 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/theme.py +2 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/tooltip.py +1 -0
- pyjs-0.5.0/pyjs/web/ui/trace.py +57 -0
- pyjs-0.5.0/pyjs/web/ui/typeset.py +55 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/webgpu.py +343 -56
- pyjs-0.5.0/pyjs/web/xterm.py +123 -0
- pyjs-0.5.0/pyjs/webassembly/__init__.py +35 -0
- pyjs-0.5.0/pyjs/webassembly/analysis.py +72 -0
- pyjs-0.5.0/pyjs/webassembly/memory.py +76 -0
- pyjs-0.5.0/pyjs/webassembly/transpiler.py +4199 -0
- pyjs-0.5.0/pyjs.egg-info/PKG-INFO +1512 -0
- pyjs-0.5.0/pyjs.egg-info/SOURCES.txt +564 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs.egg-info/requires.txt +8 -3
- {pyjs-0.4.0 → pyjs-0.5.0}/pyproject.toml +21 -7
- pyjs-0.5.0/tests/test_android_examples.py +34 -0
- pyjs-0.5.0/tests/test_async_lock.py +96 -0
- pyjs-0.5.0/tests/test_ci.py +144 -0
- pyjs-0.5.0/tests/test_ci_timings.py +78 -0
- pyjs-0.5.0/tests/test_cli.py +1063 -0
- pyjs-0.5.0/tests/test_decimal.py +119 -0
- pyjs-0.5.0/tests/test_decorator_signatures.py +167 -0
- pyjs-0.5.0/tests/test_dev_server.py +486 -0
- pyjs-0.5.0/tests/test_diagram.py +101 -0
- pyjs-0.5.0/tests/test_distributions.py +31 -0
- pyjs-0.5.0/tests/test_electron.py +388 -0
- pyjs-0.5.0/tests/test_electron_lifecycle.py +46 -0
- pyjs-0.5.0/tests/test_electron_notification_service.py +280 -0
- pyjs-0.5.0/tests/test_electron_notifications.py +178 -0
- pyjs-0.5.0/tests/test_electron_session.py +198 -0
- pyjs-0.5.0/tests/test_example_modules.py +25 -0
- pyjs-0.5.0/tests/test_examples.py +9 -0
- pyjs-0.5.0/tests/test_fetch.py +91 -0
- pyjs-0.5.0/tests/test_gesture.py +46 -0
- pyjs-0.5.0/tests/test_interaction_trace.py +365 -0
- pyjs-0.5.0/tests/test_javascript_promise.py +282 -0
- pyjs-0.5.0/tests/test_language.py +501 -0
- pyjs-0.5.0/tests/test_language_completion.py +474 -0
- pyjs-0.5.0/tests/test_language_diagnostics.py +190 -0
- pyjs-0.5.0/tests/test_language_queries.py +221 -0
- pyjs-0.5.0/tests/test_language_regressions.py +434 -0
- pyjs-0.5.0/tests/test_language_signatures.py +486 -0
- pyjs-0.5.0/tests/test_masonry_simulator.py +1173 -0
- pyjs-0.5.0/tests/test_masonry_trace.py +187 -0
- pyjs-0.5.0/tests/test_newcomer_experience.py +230 -0
- pyjs-0.5.0/tests/test_node_build.py +240 -0
- pyjs-0.5.0/tests/test_node_files.py +307 -0
- pyjs-0.5.0/tests/test_npm_release.py +397 -0
- pyjs-0.5.0/tests/test_numeric.py +3721 -0
- pyjs-0.5.0/tests/test_numeric_boundaries.py +4561 -0
- pyjs-0.5.0/tests/test_performance_artifacts.py +239 -0
- pyjs-0.5.0/tests/test_performance_lab.py +530 -0
- pyjs-0.5.0/tests/test_promise_adapters.py +183 -0
- pyjs-0.5.0/tests/test_recycler_snapshot.py +59 -0
- pyjs-0.5.0/tests/test_release_artifacts.py +184 -0
- pyjs-0.5.0/tests/test_reorder_scenario.py +6 -0
- pyjs-0.5.0/tests/test_reorderable.py +41 -0
- pyjs-0.5.0/tests/test_reorderable_trace.py +142 -0
- pyjs-0.5.0/tests/test_repository.py +130 -0
- pyjs-0.5.0/tests/test_scaffolding.py +360 -0
- pyjs-0.5.0/tests/test_server.py +789 -0
- pyjs-0.5.0/tests/test_server_errors.py +100 -0
- pyjs-0.5.0/tests/test_server_jsonapi.py +439 -0
- pyjs-0.5.0/tests/test_server_live.py +199 -0
- pyjs-0.5.0/tests/test_server_stream.py +435 -0
- pyjs-0.5.0/tests/test_server_stream_client.py +190 -0
- pyjs-0.5.0/tests/test_server_transport.py +188 -0
- pyjs-0.5.0/tests/test_server_valkey.py +316 -0
- pyjs-0.5.0/tests/test_server_watch.py +994 -0
- pyjs-0.5.0/tests/test_staggered_calibration.py +29 -0
- pyjs-0.5.0/tests/test_update_webidl.py +895 -0
- pyjs-0.5.0/tests/test_web_notifications.py +65 -0
- pyjs-0.5.0/tests/test_web_sharing.py +31 -0
- pyjs-0.5.0/tests/test_xterm.py +248 -0
- pyjs-0.4.0/PKG-INFO +0 -573
- pyjs-0.4.0/README.md +0 -530
- pyjs-0.4.0/pyjs/__init__.py +0 -6
- pyjs-0.4.0/pyjs/decorators.py +0 -408
- pyjs-0.4.0/pyjs/docs/__init__.py +0 -6
- pyjs-0.4.0/pyjs/docs/cli.py +0 -55
- pyjs-0.4.0/pyjs/javascript.py +0 -178
- pyjs-0.4.0/pyjs/lib/pydantic/v2.py +0 -217
- pyjs-0.4.0/pyjs/nativescript/__init__.py +0 -513
- pyjs-0.4.0/pyjs/nativescript/collectionview.py +0 -104
- pyjs-0.4.0/pyjs/nativescript/haptics.py +0 -30
- pyjs-0.4.0/pyjs/nativescript/keyboard.py +0 -52
- pyjs-0.4.0/pyjs/nativescript/masonry.py +0 -784
- pyjs-0.4.0/pyjs/nativescript/masonry_reorder.py +0 -484
- pyjs-0.4.0/pyjs/nativescript/reorderable.py +0 -361
- pyjs-0.4.0/pyjs/nativescript/transport.py +0 -40
- pyjs-0.4.0/pyjs/server/protocol.py +0 -7
- pyjs-0.4.0/pyjs/skills/pyjs/SKILL.md +0 -244
- pyjs-0.4.0/pyjs/testing/__init__.py +0 -3
- pyjs-0.4.0/pyjs/tooling/__init__.py +0 -4
- pyjs-0.4.0/pyjs/tooling/android.py +0 -138
- pyjs-0.4.0/pyjs/tooling/nativescript.py +0 -215
- pyjs-0.4.0/pyjs/transpiler/__init__.py +0 -61
- pyjs-0.4.0/pyjs/transpiler/analyzer.py +0 -8221
- pyjs-0.4.0/pyjs/transpiler/utils.py +0 -214
- pyjs-0.4.0/pyjs/web/ssr.py +0 -72
- pyjs-0.4.0/pyjs/web/ui/button.py +0 -86
- pyjs-0.4.0/pyjs/web/ui/combobox.py +0 -39
- pyjs-0.4.0/pyjs/web/ui/command.py +0 -136
- pyjs-0.4.0/pyjs/web/ui/dropdown_menu.py +0 -275
- pyjs-0.4.0/pyjs/web/ui/field.py +0 -96
- pyjs-0.4.0/pyjs/web/ui/floating.py +0 -90
- pyjs-0.4.0/pyjs/web/ui/input_group.py +0 -77
- pyjs-0.4.0/pyjs/web/ui/message_scroller.py +0 -128
- pyjs-0.4.0/pyjs/web/ui/scroll_area.py +0 -29
- pyjs-0.4.0/pyjs/web/ui/sonner.py +0 -72
- pyjs-0.4.0/pyjs/web/ui/textarea.py +0 -28
- pyjs-0.4.0/pyjs.egg-info/PKG-INFO +0 -573
- pyjs-0.4.0/pyjs.egg-info/SOURCES.txt +0 -213
- {pyjs-0.4.0 → pyjs-0.5.0}/LICENSE +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/__main__.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/docs/favicon.svg +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/lib/__init__.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/lib/pydantic/__init__.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__PYJS_PACKAGE__.py.template +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__init__.py.template +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/scaffolding/templates/app/__PYJS_SOURCE_ROOT__/__PYJS_PACKAGE__/__main__.py.template +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/scaffolding/templates/app/tests/test_app.py.template +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/scaffolding/templates/app/tests/test_browser_app.py.template +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/scaffolding/templates/app_test.py.template +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/build.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/server/django/errors.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/stdlib/dataclasses.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/stdlib/typing.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/artifacts.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/client/__init__.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/client/pytest.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/client/runtime.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/client/sidebar.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/client/state.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/client/viewer.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/interaction/__init__.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/interaction/gesture.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/interaction/reorder.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/interaction/trace.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/testing/webgpu.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/tooling/download.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/tooling/perf.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/ui/__init__.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/ui/interaction.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/__init__.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/console.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/crypto.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/encoding.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/files.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/geometry.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/navigation.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/storage.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/streams.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/svg.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/timers.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/accordion.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/alert.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/alert_dialog.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/aspect_ratio.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/attachment.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/avatar.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/badge.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/breadcrumb.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/bubble.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/calendar.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/card.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/carousel.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/collapsible.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/context_menu.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/date.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/date_picker.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/direction.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/empty.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/input_otp.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/item.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/kbd.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/label.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/marker.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/menubar.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/message.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/native_select.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/navigation_menu.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/progress.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/questionnaire.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/radio_group.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/reorderable.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/select.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/separator.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/sheet.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/skeleton.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/spinner.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/tabs.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/text.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/toggle.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/ui/typography.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs/web/url.py +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs.egg-info/dependency_links.txt +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs.egg-info/entry_points.txt +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/pyjs.egg-info/top_level.txt +0 -0
- {pyjs-0.4.0 → pyjs-0.5.0}/setup.cfg +0 -0
pyjs-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,1512 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyjs
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Python to JavaScript transpiler.
|
|
5
|
+
Author-email: Lex Berezhny <lex@damoti.com>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/pyjs/pyjs
|
|
8
|
+
Project-URL: Release notes, https://github.com/pyjs/pyjs/releases
|
|
9
|
+
Project-URL: Source, https://github.com/pyjs/pyjs
|
|
10
|
+
Project-URL: Tracker, https://github.com/pyjs/pyjs/issues
|
|
11
|
+
Project-URL: Discord, https://discord.gg/YktKpQPG7
|
|
12
|
+
Project-URL: X, https://x.com/pyjsdev
|
|
13
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
14
|
+
Classifier: Environment :: Web Environment
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Requires-Python: >=3.14
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: sdkmgr<0.4,>=0.3.1
|
|
29
|
+
Requires-Dist: markdown>=3.8
|
|
30
|
+
Requires-Dist: pillow
|
|
31
|
+
Requires-Dist: pydantic<3,>=2
|
|
32
|
+
Requires-Dist: pyyaml>=6.0
|
|
33
|
+
Requires-Dist: pytest
|
|
34
|
+
Requires-Dist: websockets
|
|
35
|
+
Requires-Dist: griffelib<3,>=2
|
|
36
|
+
Provides-Extra: examples
|
|
37
|
+
Requires-Dist: pyjs-examples==0.5.0; extra == "examples"
|
|
38
|
+
Provides-Extra: extras
|
|
39
|
+
Requires-Dist: pyjs-extras==0.5.0; extra == "extras"
|
|
40
|
+
Provides-Extra: stripe
|
|
41
|
+
Requires-Dist: pyjs-extras[stripe]==0.5.0; extra == "stripe"
|
|
42
|
+
Provides-Extra: django
|
|
43
|
+
Requires-Dist: django<6.2,>=6.0; extra == "django"
|
|
44
|
+
Provides-Extra: webgpu
|
|
45
|
+
Requires-Dist: wgpu==0.32.0; extra == "webgpu"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
48
|
+
<p align="center">
|
|
49
|
+
<img src="branding/pyjs-logo.svg" alt="PyJS" width="170">
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
# PyJS: Python to JavaScript
|
|
53
|
+
|
|
54
|
+
[![CI][ci-badge]][ci] [![PyPI][pypi-badge]][pypi]
|
|
55
|
+
[![Python][python-badge]][pypi] [![License][license-badge]][license]
|
|
56
|
+
|
|
57
|
+
**Write typed Python for servers, browsers, and Android—without shipping a
|
|
58
|
+
Python runtime to JavaScript targets.**
|
|
59
|
+
|
|
60
|
+
PyJS statically analyzes reachable Python and emits readable, tree-shaken
|
|
61
|
+
JavaScript. The same component can render real HTML on the server, hydrate as a
|
|
62
|
+
native custom element in the browser, and share application logic with a
|
|
63
|
+
direct-JVM Android app.
|
|
64
|
+
|
|
65
|
+
PyJS is early-release software: complete applications and tests work today,
|
|
66
|
+
while APIs can still change between releases.
|
|
67
|
+
|
|
68
|
+
Browser JavaScript and direct-JVM Android are the application-facing targets.
|
|
69
|
+
The JVM, LLVM, and WebAssembly backends remain experimental; their APIs and
|
|
70
|
+
supported subsets may change rapidly.
|
|
71
|
+
|
|
72
|
+
## See it work in 30 seconds
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
python -m pip install "pyjs[examples]"
|
|
76
|
+
python -m pyjs_examples.calculator
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Open the clickable local URL printed by the server. The Calculator is one
|
|
80
|
+
Python application targeting the Web, an installable PWA, and Android. Try the
|
|
81
|
+
[source](examples/calculator/calculator.py), then inspect its browser and
|
|
82
|
+
Android tests beside it.
|
|
83
|
+
|
|
84
|
+
PyJS keeps the generated result recognizable. Given:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from pyjs import js
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@js
|
|
91
|
+
def total(prices: list[int]) -> int:
|
|
92
|
+
return sum(prices)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
print(total([12, 30]))
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`pyjs --src -c '...'` emits:
|
|
99
|
+
|
|
100
|
+
```javascript
|
|
101
|
+
export function total(prices) {
|
|
102
|
+
return (prices).reduce((total,value)=>total+value,0);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function main() {
|
|
106
|
+
console.log(total([12, 30]));
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
There is no bundled Python interpreter, virtual DOM, or JavaScript project to
|
|
111
|
+
maintain.
|
|
112
|
+
|
|
113
|
+
## Create your first project
|
|
114
|
+
|
|
115
|
+
Install PyJS and create a project:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
python -m pip install pyjs
|
|
119
|
+
pyjs create hello_pyjs
|
|
120
|
+
cd hello_pyjs
|
|
121
|
+
python -m pip install -e ".[test]"
|
|
122
|
+
python -m hello_pyjs
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Open <http://127.0.0.1:8000/>. The generated project has no Node.js
|
|
126
|
+
configuration or JavaScript source: it contains a custom element, server entry
|
|
127
|
+
point, Python tests, and a browser test.
|
|
128
|
+
|
|
129
|
+
Run its test suite on either target:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
ruff check .
|
|
133
|
+
python -m pytest -q
|
|
134
|
+
python -m pytest -q --pyjs-target=web --pyjs-browser=managed
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
To develop PyJS itself from a source checkout, see
|
|
138
|
+
[CONTRIBUTING.md](CONTRIBUTING.md).
|
|
139
|
+
|
|
140
|
+
## Try the experimental native compiler
|
|
141
|
+
|
|
142
|
+
The LLVM backend compiles a supported subset of typed Python to machine code,
|
|
143
|
+
without embedding CPython. During development, try it from a source checkout
|
|
144
|
+
with Python 3.14, uv, and a native Clang toolchain installed:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
git clone https://github.com/pyjs/pyjs.git
|
|
148
|
+
cd pyjs
|
|
149
|
+
uv sync
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Save this as `primes.py` in the checkout. It counts primes with a sieve,
|
|
153
|
+
exercising list allocation, indexing, loops, branches and a reduction:
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
def count_primes(limit: int) -> int:
|
|
157
|
+
prime = [True] * (limit + 1)
|
|
158
|
+
prime[0] = prime[1] = False
|
|
159
|
+
factor = 2
|
|
160
|
+
while factor * factor <= limit:
|
|
161
|
+
if prime[factor]:
|
|
162
|
+
for multiple in range(factor * factor, limit + 1, factor):
|
|
163
|
+
prime[multiple] = False
|
|
164
|
+
factor += 1
|
|
165
|
+
return sum(prime)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def main() -> None:
|
|
169
|
+
print(count_primes(2_000_000))
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
if __name__ == "__main__":
|
|
173
|
+
main()
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Run the same file with either interpreter or compiler—no decorators or source
|
|
177
|
+
strings are needed. Both print `148933`:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
uv run python primes.py
|
|
181
|
+
uv run pyjs --target native primes.py
|
|
182
|
+
uv run pyjs --target native --perf primes.py
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The last command compiles once, checks matching output and successful exits on
|
|
186
|
+
every run, then reports paired process timings. A Linux x64 run with CPython
|
|
187
|
+
3.14.4 and Clang 21 at `-O2` produced these timings (shown with the current
|
|
188
|
+
compiler label):
|
|
189
|
+
|
|
190
|
+
```text
|
|
191
|
+
Compilation: 1.818 s (21.1.8, O2)
|
|
192
|
+
Output matches: yes
|
|
193
|
+
148933
|
|
194
|
+
Median of 7 runs after 2 warmups (process startup included):
|
|
195
|
+
CPython 3.14.4: 183.171 ms
|
|
196
|
+
Native: 13.317 ms
|
|
197
|
+
Speedup: 13.75x (compilation excluded)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
These are measurements, not a universal speed guarantee. Compilation costs
|
|
201
|
+
more than a single interpreted run of this example; native execution pays off
|
|
202
|
+
when you reuse the binary or run a larger workload. `--perf` alternates which
|
|
203
|
+
program runs first, includes process startup and captured output for both,
|
|
204
|
+
and excludes compilation and the PyJS CLI's startup from execution timings.
|
|
205
|
+
Use `--samples N`, `--warmups N` or `--json` to inspect your own results.
|
|
206
|
+
On Windows a small CPython launcher configures UTF-8 output without newline
|
|
207
|
+
translation to match native output; its startup is included. Captured output
|
|
208
|
+
is compared byte-for-byte, not normalized after execution.
|
|
209
|
+
|
|
210
|
+
Keep an executable to run repeatedly without recompiling:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
uv run pyjs build --target native primes.py -o primes
|
|
214
|
+
./primes
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
On Windows the output is `primes.exe`; run `.\primes.exe`. Native execution also
|
|
218
|
+
accepts `-m package.module`, `-c 'print(42)'` and stdin (`-`). Native builds
|
|
219
|
+
accept a file or module, optionally followed by `:entry_function`. Use
|
|
220
|
+
`pyjs --target native --src primes.py` to inspect the LLVM IR.
|
|
221
|
+
Default build output uses the source filename's stem (`__main__` for a package
|
|
222
|
+
entry); use `-o build/app` to choose a package executable's name without colliding
|
|
223
|
+
with the package's source directory.
|
|
224
|
+
|
|
225
|
+
Clang also needs the host's linker and C runtime
|
|
226
|
+
development libraries: Xcode Command Line Tools on macOS, or MSVC Build Tools,
|
|
227
|
+
the Windows SDK and Clang's compiler-rt on Windows. Use matching 64-bit Python
|
|
228
|
+
and compiler architectures. Set `PYJS_CLANG` to a compiler path if it is not on PATH.
|
|
229
|
+
|
|
230
|
+
This compiles for the current host, not an arbitrary cross-compilation
|
|
231
|
+
target. CI compiles and executes on Linux, macOS and Windows, each on x64 and
|
|
232
|
+
arm64, including loading native libraries into Python. The executable entry
|
|
233
|
+
point is a zero-argument `main()` returning `None` (success),
|
|
234
|
+
`str` (written to stdout) or `int` (used as the process exit status). Simple
|
|
235
|
+
top-level statements can be wrapped automatically. For scripts with helpers or
|
|
236
|
+
a `__name__` guard, use the guarded `main()` pattern above; pass configuration
|
|
237
|
+
into helpers rather than reading unannotated module globals. This avoids shared
|
|
238
|
+
analysis limitations and gives the same behavior under CPython and native execution;
|
|
239
|
+
CPython normally ignores a function's returned value. Imports, decorators and
|
|
240
|
+
module initialization execute in Python during analysis, so compile only code
|
|
241
|
+
you trust. Program command-line arguments are not yet supported. Arbitrary
|
|
242
|
+
Python packages and dynamic Python features are not automatically supported.
|
|
243
|
+
Initialization output is reported as compilation diagnostics on stderr, or
|
|
244
|
+
under `compilation` with `--json`, rather than mixed into the native result or
|
|
245
|
+
generated LLVM source.
|
|
246
|
+
|
|
247
|
+
Embedded hosts can select source implementations of imported interfaces with
|
|
248
|
+
`library_mappings=` on `transpile_llvm`, `transpile_llvm_module`,
|
|
249
|
+
`LLVM.run_source`, or `LLVM.compile_library` (and their comparison helpers).
|
|
250
|
+
Subclass `pyjs.native.analysis.NativeLibraryMappings`, override `resolve(value)`
|
|
251
|
+
to return the host implementation for a recognized Python class or function,
|
|
252
|
+
and delegate unhandled values to `super().resolve(value)`. Pass the resolver
|
|
253
|
+
instance explicitly for each compilation; it applies during analysis and
|
|
254
|
+
emission without modifying the default native resolver or Python imports.
|
|
255
|
+
The native semantic builtins and ABI remain unchanged. These mappings select
|
|
256
|
+
implementations; they do not provide a browser runtime, event loop, or additional
|
|
257
|
+
language support. Host implementations must use the supported native subset.
|
|
258
|
+
|
|
259
|
+
The native backend supports `async def` and nested `await` through managed
|
|
260
|
+
coroutine frames. Calling an async function creates a coroutine without running
|
|
261
|
+
its body. A synchronous driver can obtain `coroutine.__await__()` and advance
|
|
262
|
+
that iterator with `next`, `send`, `throw`, and `close`; completion arrives as
|
|
263
|
+
`StopIteration.value`. Custom awaitables can define `__await__` returning a
|
|
264
|
+
typed `Generator` and use their concrete class as the annotation. Native
|
|
265
|
+
`Awaitable[T]` storage currently represents coroutine results only; inheriting
|
|
266
|
+
from `Awaitable` is rejected rather than reinterpreting an application object
|
|
267
|
+
as a coroutine frame. Async callbacks and methods use the same call machinery.
|
|
268
|
+
The compiler does not supply an event loop or `asyncio` implementation. Native
|
|
269
|
+
executable and library entry points remain synchronous, and async generators
|
|
270
|
+
are not implemented. A host scheduler must own pending coroutine iterators,
|
|
271
|
+
resume them when operations finish, and close them before disposing its heap.
|
|
272
|
+
|
|
273
|
+
## What makes PyJS different
|
|
274
|
+
|
|
275
|
+
- **Python stays visible.** Generated JavaScript is readable and maps back to
|
|
276
|
+
the original Python in browser DevTools.
|
|
277
|
+
- **HTML is the handoff.** Components render on the server, retain small typed
|
|
278
|
+
state in the DOM, and hydrate the elements already on screen.
|
|
279
|
+
- **The browser is the framework.** Custom elements, attributes, events, and
|
|
280
|
+
Web APIs remain direct platform primitives rather than a virtual DOM.
|
|
281
|
+
- **Types remove runtime weight.** Static analysis specializes Python semantics
|
|
282
|
+
and tree-shakes code from each entry point.
|
|
283
|
+
- **Escape hatches stay open.** Typed browser APIs and raw transports remain
|
|
284
|
+
available beneath the UI and full-stack conveniences.
|
|
285
|
+
|
|
286
|
+
Coding agents can run `pyjs skill` for version-matched guidance and
|
|
287
|
+
`pyjs template` to discover complete executable examples. The
|
|
288
|
+
[installable PyJS skill](pyjs/skills/pyjs/SKILL.md) is included in the package
|
|
289
|
+
and public repository.
|
|
290
|
+
|
|
291
|
+
## Start from an example
|
|
292
|
+
|
|
293
|
+
The separately installed examples progress from a one-file counter to composed
|
|
294
|
+
full-stack applications:
|
|
295
|
+
|
|
296
|
+
| Example | Purpose | Principal coverage |
|
|
297
|
+
| --- | --- | --- |
|
|
298
|
+
| [Counter](examples/counter.py) | Smallest app | DOM, events, tests |
|
|
299
|
+
| [Calculator](examples/calculator/) | Universal app | Web, PWA, Android, SSR |
|
|
300
|
+
| [Components](examples/components/) | UI reference | Widgets, forms, routing |
|
|
301
|
+
| [Notes](examples/notes/) | Personal app | Android, drag/drop, restore |
|
|
302
|
+
| [Chat](examples/chat/) | Real-time starter | WebSockets, multi-window |
|
|
303
|
+
| [Store](examples/store/) | Business app | Django, JSON:API, streams, themes |
|
|
304
|
+
| [Space Invaders](examples/space_invaders/) | GPU game | WebGPU, render tests |
|
|
305
|
+
|
|
306
|
+
Inspect or copy any of them:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
python -m pip install "pyjs[examples]"
|
|
310
|
+
python -m pyjs_examples.calculator
|
|
311
|
+
pyjs template
|
|
312
|
+
pyjs template pyjs_examples.calculator
|
|
313
|
+
pyjs template pyjs_examples.calculator --src
|
|
314
|
+
pyjs create my_calculator --template pyjs_examples.calculator
|
|
315
|
+
pyjs create counter_demo --template pyjs_examples.counter
|
|
316
|
+
pyjs create my_counter --single-file --template pyjs_examples.counter
|
|
317
|
+
pyjs create components_demo --template pyjs_examples.components
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
The template catalog contains examples that can be copied safely out of their
|
|
321
|
+
installed package. Store is a comprehensive runnable application instead of a
|
|
322
|
+
scaffold because its Django package, fixture data, and optional server
|
|
323
|
+
dependencies belong together. Run it directly with:
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
python -m pip install "pyjs-examples[store]"
|
|
327
|
+
python -m pyjs_examples.store
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
`pyjs create NAME` creates a project in `NAME/`, with application code in
|
|
331
|
+
`NAME/NAME/NAME.py` and tests in `NAME/tests/`. Pass a destination as the
|
|
332
|
+
second positional argument to populate another directory, such as
|
|
333
|
+
`pyjs create example .`. Add `--src-layout` to put the package under `src/`.
|
|
334
|
+
After installation, `python -m NAME` starts either package layout through its
|
|
335
|
+
ordinary Python entry point. `pyjs serve` is also available as a convenience
|
|
336
|
+
and uses the application recorded in `pyproject.toml`.
|
|
337
|
+
|
|
338
|
+
`pyjs serve --open /some/path/` opens that local URL after the server starts;
|
|
339
|
+
`--open` alone opens `/`. Use `--host` and `--port` to choose the listener
|
|
340
|
+
(`--port 0` selects an available port). Explicit `module:create_app` targets
|
|
341
|
+
can return a `pyjs.server.dev.Application` for live Python routes.
|
|
342
|
+
|
|
343
|
+
`--single-file` explicitly requests one standalone Python file and requires a
|
|
344
|
+
file template when combined with `--template`. The `pyjs-examples`
|
|
345
|
+
distribution registers both file and directory templates and contains the
|
|
346
|
+
source copied by `pyjs create`; templates are not embedded in the scaffolding
|
|
347
|
+
implementation.
|
|
348
|
+
|
|
349
|
+
## Run or inspect Python as JavaScript
|
|
350
|
+
|
|
351
|
+
For Node-compatible code, PyJS can compile and run a file, module, or command
|
|
352
|
+
string directly with its managed Node runtime:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
pyjs app.py
|
|
356
|
+
pyjs -m package.module
|
|
357
|
+
pyjs -c 'print(6 * 7)'
|
|
358
|
+
pyjs -v -c 'print(6 * 7)' # generated JavaScript followed by Node output
|
|
359
|
+
pyjs --src app.py # generated source only
|
|
360
|
+
pyjs --src-all app.py # entry source and tree-shaken dependencies
|
|
361
|
+
pyjs --perf -c 'print(sum(range(10)))'
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Use `--json` for structured results or `--perf` to compare Python and generated
|
|
365
|
+
JavaScript timing. DOM, WebGPU, and other browser APIs still run through an
|
|
366
|
+
application or browser test.
|
|
367
|
+
|
|
368
|
+
Node provisioning uses [sdkmgr](https://github.com/pyjs/sdkmgr), which reuses
|
|
369
|
+
mise or nvm and installs the requested version only when necessary. Explicit
|
|
370
|
+
`Node(executable=...)` and `PYJS_NODE` selections still take precedence and
|
|
371
|
+
require Node 20 or newer. Previous PyJS-managed Node caches are left untouched;
|
|
372
|
+
new installations belong to the selected manager. Configure mirrors through
|
|
373
|
+
that manager, not the retired `PYJS_NODE_MIRROR` setting. Constructing a `Node`
|
|
374
|
+
does not install anything; `ensure()` provisions it before execution. Path
|
|
375
|
+
properties only discover existing installations and report a missing runtime.
|
|
376
|
+
The optional `root` argument now controls sdkmgr's manager-bootstrap storage,
|
|
377
|
+
not the Node installation directory.
|
|
378
|
+
|
|
379
|
+
## Build an entry point
|
|
380
|
+
|
|
381
|
+
The application server builds and serves browser assets automatically. To
|
|
382
|
+
write the generated JavaScript, CSS, and HTML explicitly:
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
pyjs build hello_pyjs.hello_pyjs:main
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Use `--only-js` when only the browser bundle is needed.
|
|
389
|
+
|
|
390
|
+
### Stock Electron applications
|
|
391
|
+
|
|
392
|
+
Package a Python UI as a desktop application:
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
pyjs build my_app:main --target electron -o dist/my-app
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
The build includes the generated HTML, CSS, JavaScript and Python source maps,
|
|
399
|
+
plus the stock Electron runtime. Python and an HTTP server are not needed to run
|
|
400
|
+
it. Run `dist/my-app/electron` on Linux, `dist/my-app/electron.exe` on Windows,
|
|
401
|
+
or open `dist/my-app/Electron.app` on macOS. These are application directories,
|
|
402
|
+
not signed installers; distribution, signing and updates remain separate steps.
|
|
403
|
+
The first build provisions Electron 45.0.0 through its exact npm package using
|
|
404
|
+
PyJS's managed Node tooling. The build runs Electron's own installer, which
|
|
405
|
+
verifies its published checksums. This requires network access. Use
|
|
406
|
+
`--electron-runtime PATH` to reuse an existing host-platform Electron
|
|
407
|
+
distribution offline. The output must not already exist. Use a distinct output
|
|
408
|
+
directory for each concurrent build; concurrent modification of the destination
|
|
409
|
+
is unsupported. Runtime links used for application resources must resolve inside
|
|
410
|
+
the copied distribution, and the runtime must not contain a pre-existing app.
|
|
411
|
+
|
|
412
|
+
Linux still requires a working Chromium sandbox. Systems that restrict
|
|
413
|
+
unprivileged user namespaces may require an administrator-configured AppArmor
|
|
414
|
+
policy or a correctly installed root-owned setuid sandbox helper. Packaging does
|
|
415
|
+
not configure the operating system or disable Electron's sandbox; handle this in
|
|
416
|
+
your installation process.
|
|
417
|
+
|
|
418
|
+
The default window uses a sandboxed renderer with context isolation and no
|
|
419
|
+
Node globals. UI code, state and DOM access stay in the renderer. Existing
|
|
420
|
+
HTTP backend routes are not automatically translated into desktop services.
|
|
421
|
+
Pages load from `file://`, which can read user-accessible local files despite
|
|
422
|
+
the renderer sandbox. There is no default Content Security Policy restricting
|
|
423
|
+
outbound connections. These defaults are for trusted application UI, not a
|
|
424
|
+
boundary for running untrusted content. For Node filesystem operations (such as
|
|
425
|
+
writes) or other OS services, pass `--electron-host host-directory`.
|
|
426
|
+
A Python host package contains `main.py` with an async `main(context)` entry
|
|
427
|
+
and, optionally, `preload.py` with a zero-argument `main()`. The build compiles
|
|
428
|
+
both entries and their reachable dependencies into self-contained CommonJS
|
|
429
|
+
files with Python source maps. Nothing is compiled at application launch.
|
|
430
|
+
For example, `desktop_host/main.py`:
|
|
431
|
+
|
|
432
|
+
```python
|
|
433
|
+
from pyjs import js
|
|
434
|
+
from pyjs.electron import HostContext, WindowOptions
|
|
435
|
+
|
|
436
|
+
@js
|
|
437
|
+
async def main(context: HostContext):
|
|
438
|
+
window = context.createWindow(WindowOptions("My application"))
|
|
439
|
+
await window.loadFile(context.renderer)
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
`pyjs.electron` exposes typed window, IPC, context-bridge and debugger operations;
|
|
443
|
+
`pyjs.node` exposes typed filesystem, process and timer operations. These are
|
|
444
|
+
JavaScript-host APIs, not CPython implementations of Node. A sandboxed preload
|
|
445
|
+
can use Electron's bridge/IPC APIs but cannot use Node filesystem or subprocess
|
|
446
|
+
bindings. Keep it limited to a small, fixed capability surface. Its Python
|
|
447
|
+
imports are bundled; it does not load other JavaScript files at runtime.
|
|
448
|
+
The host package must be importable and have a unique module name in a build
|
|
449
|
+
process. Existing JavaScript hosts with `main.cjs` exporting `async start(context)`
|
|
450
|
+
remain supported; their files are copied unchanged. If both main files exist,
|
|
451
|
+
Python takes precedence.
|
|
452
|
+
|
|
453
|
+
Electron buffers cookie writes. Await `session.cookies.flushStore()` to request
|
|
454
|
+
that the selected session attempt its pending writes without waiting for the
|
|
455
|
+
periodic flush. Native promise rejections propagate, but Electron can resolve
|
|
456
|
+
the promise even when a disk write fails: completion is not proof of durable
|
|
457
|
+
storage. The call preserves cookie expiry and does not make in-memory
|
|
458
|
+
partitions persistent.
|
|
459
|
+
|
|
460
|
+
Use `pyjs.electron.window.on_close(window, callback)` to handle a native
|
|
461
|
+
close request. Calling `event.preventDefault()` synchronously keeps the
|
|
462
|
+
window open while the application saves state. `window.close()` requests a
|
|
463
|
+
normal close; `window.destroy()` bypasses the close event.
|
|
464
|
+
|
|
465
|
+
A host can notify its renderer with `window.webContents.send(channel, text)`.
|
|
466
|
+
In the preload, `pyjs.electron.listen(channel, callback)` delivers the text
|
|
467
|
+
and returns an unsubscribe function. Removing a subscription does not remove
|
|
468
|
+
other listeners. Expose fixed-channel callbacks through `expose`; the listener
|
|
469
|
+
adapter deliberately does not forward the Electron event into the renderer.
|
|
470
|
+
|
|
471
|
+
`pyjs.electron.notifications` exposes native main-process notifications. After
|
|
472
|
+
app readiness, check `is_supported()`, construct `NotificationOptions(title,
|
|
473
|
+
body=...)`, and call `create_notification(options)`. Retain the returned object,
|
|
474
|
+
register `notification.on("show", callback)` and `on_failed(notification,
|
|
475
|
+
callback)` before `show()`, and handle `"click"` and `"close"` as needed.
|
|
476
|
+
Ordinary event callbacks receive an Electron `Event`; `on_failed` forwards only
|
|
477
|
+
the error string and returns an unsubscribe function. For ordinary listeners,
|
|
478
|
+
retain the callback passed to `on` and pass it to `removeListener` for removal.
|
|
479
|
+
`close()` dismisses the owned notification.
|
|
480
|
+
|
|
481
|
+
To await native publication with an asynchronous event timeout, use
|
|
482
|
+
`await show_notification(notification, timeout_ms=5000)`. It dismisses the
|
|
483
|
+
object's previous alert before subscribing, then resolves on `show` or rejects
|
|
484
|
+
on failure, early close, timeout or a synchronous exception. It removes only
|
|
485
|
+
its own listeners; click handlers remain. Do not show the same object
|
|
486
|
+
concurrently. After rejection, close any uncertain alert before retrying.
|
|
487
|
+
|
|
488
|
+
The timer cannot interrupt synchronous native work. Electron 45 on Linux uses
|
|
489
|
+
blocking libnotify/D-Bus publication: a slow notification daemon stalls the
|
|
490
|
+
main event loop. The helper can resolve after `timeout_ms` or fail only at the
|
|
491
|
+
native timeout (observed around 25 seconds); it is not a hard wall-clock
|
|
492
|
+
deadline. Other main-process work and IPC are delayed during that call.
|
|
493
|
+
|
|
494
|
+
Packaged hosts can isolate these calls from editing and other host work:
|
|
495
|
+
|
|
496
|
+
```python
|
|
497
|
+
from pyjs.electron.notifications import NotificationOptions, notification_service
|
|
498
|
+
|
|
499
|
+
alerts = notification_service("org.example.notes", "Example Notes")
|
|
500
|
+
if await alerts.supported():
|
|
501
|
+
await alerts.show("reminder-1", NotificationOptions("Review notes"), open_note)
|
|
502
|
+
await alerts.close("reminder-1")
|
|
503
|
+
alerts.dispose()
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
Create the service after app readiness. It lazily starts one Electron helper
|
|
507
|
+
with a separate temporary profile and unchanged sandboxing. Native capability,
|
|
508
|
+
publication and dismissal calls run there. Requests time out after 5 seconds
|
|
509
|
+
by default (`timeout_ms`); this timer is independent of the native call but
|
|
510
|
+
still needs the host event loop to run. Up to 128 live alerts and 128 requests
|
|
511
|
+
are allowed per service. Duplicate live keys reject. Click callbacks take no
|
|
512
|
+
arguments; closing an alert revokes its callback before awaiting dismissal.
|
|
513
|
+
Native expiry/dismissal events release the alert's key and capacity slot.
|
|
514
|
+
Request overload rejects only the new request. A busy `close()` still revokes
|
|
515
|
+
clicks; retry closing after capacity becomes available to dismiss that alert.
|
|
516
|
+
Linux uses `<application_id>.desktop`; pass `desktop_name` to the factory when
|
|
517
|
+
the installed desktop-entry filename differs.
|
|
518
|
+
|
|
519
|
+
A timeout or worker failure terminates the helper, rejects pending requests
|
|
520
|
+
and revokes all its click callbacks. The next request starts a fresh helper.
|
|
521
|
+
This cannot retract an uncertain alert from OS notification history; retrying
|
|
522
|
+
can duplicate it. `dispose()` permanently stops the service without waiting
|
|
523
|
+
for native dismissal. Await `close()` for each alert before disposing if native
|
|
524
|
+
cleanup is needed. Normal app quit terminates helpers and waits up to two
|
|
525
|
+
seconds for temporary-profile cleanup, including after disposal. Forced exit
|
|
526
|
+
or unavailable storage can leave temporary files. Cleanup reissues `app.quit()`,
|
|
527
|
+
so host `before-quit` and `will-quit` handlers must tolerate repeated calls;
|
|
528
|
+
guard one-time confirmation or save operations. This API requires the
|
|
529
|
+
generated Electron bootstrap; it does not work in standalone Node bundles.
|
|
530
|
+
Linux has real native acceptance coverage; macOS signing and Windows installed
|
|
531
|
+
application identity still need deployment validation.
|
|
532
|
+
|
|
533
|
+
Presenter support and a returning `show()` do not prove publication; wait for
|
|
534
|
+
the native event, subject to these timeout limits. Publication is not proof
|
|
535
|
+
that the user saw an alert. Signing, OS permission and Windows application
|
|
536
|
+
registration remain deployment responsibilities. Optional `id` and `groupId`
|
|
537
|
+
are supported on macOS/Windows, with a 64-UTF-16-unit Windows limit, but not on
|
|
538
|
+
Linux. Reusing the same object replaces its previous alert; cross-process
|
|
539
|
+
deduplication is not guaranteed on Linux. Applications own consent, durable
|
|
540
|
+
schedules, retry receipts, account isolation and click routing. This API does
|
|
541
|
+
not schedule delivery after the application exits. Electron 45 does not
|
|
542
|
+
implement persistent service-worker notifications.
|
|
543
|
+
|
|
544
|
+
The native Linux notification acceptance test is opt-in. Set
|
|
545
|
+
`PYJS_ELECTRON_RUNTIME` to an installed Electron distribution and run:
|
|
546
|
+
|
|
547
|
+
```bash
|
|
548
|
+
pytest tests/test_electron_notifications.py \
|
|
549
|
+
tests/test_electron_notification_service.py
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
This uses a private D-Bus session
|
|
553
|
+
and a test notification service, not the user's desktop notification daemon.
|
|
554
|
+
It requires `dbus-run-session`, system Python with `dbus` and `gi`, and a working
|
|
555
|
+
Electron sandbox. The default Node contract tests do not require Electron.
|
|
556
|
+
|
|
557
|
+
Build standalone Node programs from an importable Python module with:
|
|
558
|
+
|
|
559
|
+
```bash
|
|
560
|
+
pyjs build my_service:main --target node -o dist/service.cjs
|
|
561
|
+
node --enable-source-maps dist/service.cjs
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
The generated module exports `main` without calling it when imported. Direct
|
|
565
|
+
execution awaits it and reports failures with a nonzero exit status. Source maps
|
|
566
|
+
point back to Python. Use `pyjs.node.json` to exchange ordinary Python dictionaries
|
|
567
|
+
with JSON host APIs. Other Python standard-library modules are not automatically
|
|
568
|
+
translated into Node APIs.
|
|
569
|
+
|
|
570
|
+
For bounded host reads, `pyjs.node.files` provides `open_readonly`, `fstat`
|
|
571
|
+
and `read_into` with caller-owned byte buffers and descriptors. It also exposes
|
|
572
|
+
`lstat`, `fsync` and no-replace hard-link publication through `link`. Close
|
|
573
|
+
descriptors in `finally` with `pyjs.node.close_descriptor`. Requested
|
|
574
|
+
`nofollow`/`nonblocking` flags fail explicitly when the platform lacks them;
|
|
575
|
+
no-follow protects only the final path component. These low-level operations
|
|
576
|
+
do not provide path containment, a snapshot, a lock or a filesystem transaction.
|
|
577
|
+
`FileInfo` uses Node's Number-valued metadata. Compare `dev` and `ino` as file
|
|
578
|
+
identity only after checking `Number.isSafeInteger` for both values; large
|
|
579
|
+
filesystem identifiers can lose precision, especially on Windows.
|
|
580
|
+
`open_directory` returns an async `Directory` handle for incremental `read()`
|
|
581
|
+
calls (ending with `None`); call `close()` in `finally`. Unlike `readdir`, it
|
|
582
|
+
does not first materialize every entry in a large directory. Keep backup,
|
|
583
|
+
recovery and directory validation in the application host.
|
|
584
|
+
|
|
585
|
+
Python-authored Node tests use `@js` and `pytest.mark.pyjs_node` and run with
|
|
586
|
+
`pytest --pyjs-target=node`. Each zero-argument, module-level test is compiled
|
|
587
|
+
and executed in an isolated Node process, including async tests. Fixtures and
|
|
588
|
+
parametrized arguments are not transported into Node; host-side autouse fixtures
|
|
589
|
+
may prepare external resources or environment variables. Ordinary pytest runs
|
|
590
|
+
skip Node-only tests. An entry that exits with an unfinished await fails rather
|
|
591
|
+
than silently passing. Tests time out after 60 seconds; timeout and interruption
|
|
592
|
+
cleanup also terminates child processes still descended from the test, including
|
|
593
|
+
detached children. Tests must not daemonize processes that outlive their parents.
|
|
594
|
+
Generated bundles belong in build/test output, not Git.
|
|
595
|
+
|
|
596
|
+
A custom host owns its preload, IPC handlers and window creation, including
|
|
597
|
+
validating service inputs and keeping any Node dependencies self-contained.
|
|
598
|
+
`createWindow` applies the default window restrictions; callers can customize
|
|
599
|
+
options explicitly. Keep IPC coarse-grained: send a file or a batch of results,
|
|
600
|
+
while updating the UI locally. The host runs with Node privileges; only package
|
|
601
|
+
trusted application code. Source maps embed the Python sources for debugging.
|
|
602
|
+
|
|
603
|
+
## Application model
|
|
604
|
+
|
|
605
|
+
An application entry point returns a server-rendered DOM tree. Classes
|
|
606
|
+
decorated with `@js` are available to the browser compiler, and reachable
|
|
607
|
+
methods are included in the generated bundle. `CustomElement` subclasses
|
|
608
|
+
render on the server and hydrate as browser-native custom elements. `ref()`
|
|
609
|
+
reconnects Python attributes to existing server-rendered nodes rather than
|
|
610
|
+
recreating them.
|
|
611
|
+
|
|
612
|
+
Module values cross the same explicit compilation boundary through a `JS`
|
|
613
|
+
annotation. Combine it with `Final` for constants, such as
|
|
614
|
+
`heartbeat_interval: Final[JS] = 5_000`; unmarked module values remain
|
|
615
|
+
server-only and cannot be included by an accidental browser-side reference.
|
|
616
|
+
|
|
617
|
+
Values that must survive rendering and hydration can live on the custom
|
|
618
|
+
element as DOM attributes. The `state()` descriptor and `@effect(...)` provide
|
|
619
|
+
a small typed reactive layer for updating the DOM imperatively. Server-only
|
|
620
|
+
handlers and browser methods can coexist in the same module.
|
|
621
|
+
|
|
622
|
+
## Feature overview
|
|
623
|
+
|
|
624
|
+
### Tree shaking
|
|
625
|
+
|
|
626
|
+
PyJS starts at the selected entry point and includes reachable browser code.
|
|
627
|
+
In this example, `sleep()` and `run()` are reachable; `eat()` and `bark()` are
|
|
628
|
+
omitted:
|
|
629
|
+
|
|
630
|
+
```python
|
|
631
|
+
from pyjs import js
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
@js
|
|
635
|
+
class Animal:
|
|
636
|
+
def sleep(self):
|
|
637
|
+
pass
|
|
638
|
+
|
|
639
|
+
def eat(self):
|
|
640
|
+
pass
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
@js
|
|
644
|
+
class Dog(Animal):
|
|
645
|
+
def run(self):
|
|
646
|
+
pass
|
|
647
|
+
|
|
648
|
+
def bark(self):
|
|
649
|
+
pass
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
def main():
|
|
653
|
+
dog = Dog()
|
|
654
|
+
dog.sleep()
|
|
655
|
+
dog.run()
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
Ordinary event handlers and called methods do not need `include=True`. That
|
|
659
|
+
option remains an escape hatch for unusual methods invoked dynamically by
|
|
660
|
+
JavaScript.
|
|
661
|
+
|
|
662
|
+
### Type inference and checking
|
|
663
|
+
|
|
664
|
+
The analyzer infers types from literals, constructors, calls, and control flow.
|
|
665
|
+
Empty collections and public boundaries generally need annotations because
|
|
666
|
+
their element or return type cannot be recovered from a value:
|
|
667
|
+
|
|
668
|
+
```python
|
|
669
|
+
from pyjs import js
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
@js
|
|
673
|
+
class Animal:
|
|
674
|
+
def __init__(self, name: str):
|
|
675
|
+
self.name = name
|
|
676
|
+
|
|
677
|
+
def get_name(self) -> str:
|
|
678
|
+
return self.name
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
def main():
|
|
682
|
+
values = {"one": 1, "two": 2}
|
|
683
|
+
animal = Animal("Hazel")
|
|
684
|
+
print(values["one"])
|
|
685
|
+
print(animal.get_name())
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
Type errors are reported during analysis instead of being deferred to generated
|
|
689
|
+
JavaScript. Diagnostics are improving and do not yet cover every invalid
|
|
690
|
+
program equally well.
|
|
691
|
+
|
|
692
|
+
### Type narrowing
|
|
693
|
+
|
|
694
|
+
Union types narrow through `isinstance()`, branches, assertions, and null
|
|
695
|
+
checks:
|
|
696
|
+
|
|
697
|
+
```python
|
|
698
|
+
from pyjs import js
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
@js
|
|
702
|
+
def length(items: dict[str, int] | list[int] | str) -> int:
|
|
703
|
+
if isinstance(items, dict):
|
|
704
|
+
return len(items)
|
|
705
|
+
if isinstance(items, list):
|
|
706
|
+
return len(items)
|
|
707
|
+
assert isinstance(items, str)
|
|
708
|
+
return len(items)
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
def main():
|
|
712
|
+
length(["one"])
|
|
713
|
+
length({"one": 1, "two": 2})
|
|
714
|
+
length("four")
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
`is None` and `is not None` compile to nullish JavaScript comparisons, covering
|
|
718
|
+
both JavaScript `null` and `undefined`, while identity comparisons between
|
|
719
|
+
ordinary objects retain identity semantics.
|
|
720
|
+
|
|
721
|
+
### Operator overloading
|
|
722
|
+
|
|
723
|
+
Built-in operators use their normal JavaScript equivalents for compatible
|
|
724
|
+
primitive values and dispatch to Python special methods for user-defined
|
|
725
|
+
classes:
|
|
726
|
+
|
|
727
|
+
```python
|
|
728
|
+
from pyjs import js
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
@js
|
|
732
|
+
class ListAdder:
|
|
733
|
+
def __init__(self):
|
|
734
|
+
self.values: list[str] = []
|
|
735
|
+
|
|
736
|
+
def __add__(self, other: str):
|
|
737
|
+
self.values.append(other)
|
|
738
|
+
return self
|
|
739
|
+
|
|
740
|
+
def __str__(self) -> str:
|
|
741
|
+
return "|".join(self.values)
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
def main():
|
|
745
|
+
values = ListAdder()
|
|
746
|
+
values += "a"
|
|
747
|
+
values += "b"
|
|
748
|
+
print(values)
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
### Generic types
|
|
752
|
+
|
|
753
|
+
The analyzer preserves concrete element and key/value types for built-in
|
|
754
|
+
collections such as `list[T]`, `dict[K, V]`, and `tuple[...]`. User-defined
|
|
755
|
+
generic specialization exists in the analyzer but remains experimental and is
|
|
756
|
+
not yet a stable application-facing feature.
|
|
757
|
+
|
|
758
|
+
Typed tuples and lists can be unpacked into local names. Tuple and literal-list
|
|
759
|
+
arity is checked during compilation; dynamic lists retain Python's runtime
|
|
760
|
+
arity errors. Nested, starred, and chained unpacking targets are not yet
|
|
761
|
+
supported.
|
|
762
|
+
|
|
763
|
+
### Async code and exceptions
|
|
764
|
+
|
|
765
|
+
Async functions and `await` lower to JavaScript promises. Typed browser APIs
|
|
766
|
+
such as `fetch()`, WebSockets, and WebGPU use the same syntax as asynchronous
|
|
767
|
+
Python code. Basic raising and exception handling are supported, but exception
|
|
768
|
+
semantics are not yet a complete match for CPython.
|
|
769
|
+
|
|
770
|
+
Use `pyjs.web.async_lock.AsyncLock` to serialize overlapping browser callbacks
|
|
771
|
+
that read state, await a request, and then update that state. Acquire before
|
|
772
|
+
reading the shared state, and release in `finally` so errors cannot strand the
|
|
773
|
+
queue:
|
|
774
|
+
|
|
775
|
+
```python
|
|
776
|
+
await lock.acquire()
|
|
777
|
+
try:
|
|
778
|
+
await save_changes()
|
|
779
|
+
finally:
|
|
780
|
+
lock.release()
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
Acquisition is FIFO and non-reentrant. The browser implementation does not
|
|
784
|
+
provide task cancellation or cross-thread synchronization; host-side tests use
|
|
785
|
+
an `asyncio.Lock` with the same acquire/release interface. Create host locks
|
|
786
|
+
per event loop; do not reuse a contended lock across separate `asyncio.run()`
|
|
787
|
+
calls.
|
|
788
|
+
|
|
789
|
+
### Metaprogramming and compiler extensions
|
|
790
|
+
|
|
791
|
+
Module and class bodies execute in Python before analysis, so ordinary Python
|
|
792
|
+
metaprogramming can construct the definitions that PyJS later analyzes. The
|
|
793
|
+
`@js` decorator also supports client replacements and inline call generation
|
|
794
|
+
for typed browser API bindings. Compilation extensions can rewrite function
|
|
795
|
+
ASTs and inject imports before analysis; the browser-testing integration uses
|
|
796
|
+
this mechanism for assertion diagnostics.
|
|
797
|
+
|
|
798
|
+
These are advanced integration tools. Application code should normally use
|
|
799
|
+
typed Python and the APIs already provided by `pyjs.web.dom`,
|
|
800
|
+
`pyjs.web.domx`, and `pyjs.web.ui`.
|
|
801
|
+
|
|
802
|
+
## Web UI and state
|
|
803
|
+
|
|
804
|
+
`pyjs.web.ui` contains reusable custom-element components inspired by shadcn/ui
|
|
805
|
+
and adapted for normal Python imports, subclassing, and imperative DOM
|
|
806
|
+
composition. The catalog includes forms, dialogs, menus, popovers, tabs,
|
|
807
|
+
accordions, data display, navigation, charts, and layout primitives.
|
|
808
|
+
|
|
809
|
+
```python
|
|
810
|
+
from pyjs.web.ui.button import Button
|
|
811
|
+
from pyjs.web.ui.card import (
|
|
812
|
+
Card,
|
|
813
|
+
CardContent,
|
|
814
|
+
CardFooter,
|
|
815
|
+
CardHeader,
|
|
816
|
+
CardTitle,
|
|
817
|
+
)
|
|
818
|
+
|
|
819
|
+
profile = Card(
|
|
820
|
+
CardHeader(CardTitle("Profile")),
|
|
821
|
+
CardContent("Update your public details."),
|
|
822
|
+
CardFooter(Button("Save changes")),
|
|
823
|
+
)
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
Reactive state is backed by custom-element attributes:
|
|
827
|
+
|
|
828
|
+
```python
|
|
829
|
+
from pyjs import effect, js, state
|
|
830
|
+
from pyjs.web.domx import CustomElement, ref, tag
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
@js
|
|
834
|
+
class Counter(CustomElement):
|
|
835
|
+
count = state(0)
|
|
836
|
+
|
|
837
|
+
def __init__(self):
|
|
838
|
+
super().__init__()
|
|
839
|
+
self.value = ref(tag("output"))
|
|
840
|
+
tag(self, self.value)
|
|
841
|
+
|
|
842
|
+
@effect(count)
|
|
843
|
+
def render_count(self):
|
|
844
|
+
self.value.textContent = str(self.count)
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
Effects run during server rendering. Hydration reuses that rendered result
|
|
848
|
+
rather than repeating the initial effect in the browser.
|
|
849
|
+
|
|
850
|
+
## Testing
|
|
851
|
+
|
|
852
|
+
PyJS registers a pytest plugin that can run portable tests in Python or compile
|
|
853
|
+
them for isolated browser iframes:
|
|
854
|
+
|
|
855
|
+
```bash
|
|
856
|
+
python -m pytest -q
|
|
857
|
+
python -m pytest -q --pyjs-target=web
|
|
858
|
+
```
|
|
859
|
+
|
|
860
|
+
Browser tests use isolated headless Chrome by default. Install it with
|
|
861
|
+
`sdkmgr browser install`, or set `CHROME_BIN` to an existing Chrome or Chromium
|
|
862
|
+
executable. Use `--pyjs-headed` to see the isolated window. For interactive use,
|
|
863
|
+
`--pyjs-browser=system` opens your normal browser; close its test tabs yourself.
|
|
864
|
+
|
|
865
|
+
Use `pytest.mark.pyjs_web` for tests that should be compiled and run in the
|
|
866
|
+
browser. Unmarked tests run only as ordinary Python tests;
|
|
867
|
+
`pytest.mark.pyjs_python` can make that intent explicit. A filename such as
|
|
868
|
+
`test_browser_dialog.py` is only an organizational convention and has no
|
|
869
|
+
implicit behavior.
|
|
870
|
+
|
|
871
|
+
Browser tests retain console output and errors. Tests that render meaningful
|
|
872
|
+
UI retain their iframe preview, and render assertions can compare screenshots
|
|
873
|
+
against checked-in PNG baselines.
|
|
874
|
+
|
|
875
|
+
Fresh browser/Android compilation reloads project client and test modules,
|
|
876
|
+
not dependencies installed inside a project-local virtual environment. When
|
|
877
|
+
Django's app registry is already initialized, registered model modules, loaded
|
|
878
|
+
admin autodiscovery modules and their parent packages retain their identity.
|
|
879
|
+
Restart the test process after changing those modules; unrelated client
|
|
880
|
+
children still reload normally. Other import-time registries must tolerate
|
|
881
|
+
reloading or stay outside client/test module imports. After each build, host
|
|
882
|
+
modules and package bindings are restored, including on compilation errors,
|
|
883
|
+
so Django views and model methods continue using their original imports.
|
|
884
|
+
Build generations mutate process-global imports and must run serially.
|
|
885
|
+
|
|
886
|
+
## Commands
|
|
887
|
+
|
|
888
|
+
| Command | Purpose |
|
|
889
|
+
| --- | --- |
|
|
890
|
+
| `pyjs --version` | Show the installed version |
|
|
891
|
+
| `pyjs FILE.py`, `pyjs -m MODULE`, `pyjs -c CODE` | Run with managed Node |
|
|
892
|
+
| `pyjs --src INPUT` | Print generated JavaScript without running it |
|
|
893
|
+
| `pyjs --src-all INPUT` | Include all tree-shaken dependency sources |
|
|
894
|
+
| `pyjs --perf INPUT` | Compare Python and generated-JavaScript performance |
|
|
895
|
+
| `pyjs create NAME [DESTINATION]` | Create a starter project |
|
|
896
|
+
| `pyjs serve [TARGET]` | Serve a configured project, module, or Python file |
|
|
897
|
+
| `pyjs template` | List templates registered by installed packages |
|
|
898
|
+
| `pyjs template NAME` | Print the complete materialized template source |
|
|
899
|
+
| `pyjs template NAME --src` | Print the transpiled entry-module JavaScript |
|
|
900
|
+
| `pyjs build MODULE[:ENTRY]` | Write generated JavaScript, CSS, and HTML |
|
|
901
|
+
| `pyjs docs build` | Build a static documentation site |
|
|
902
|
+
| `pyjs docs serve` | Build and serve documentation locally |
|
|
903
|
+
| `pyjs inspect URL` | Capture a screenshot and structured browser diagnostics |
|
|
904
|
+
| `pyjs npm sync [TARGET]` | Install exact reachable JavaScript dependencies |
|
|
905
|
+
| `pyjs skill` | Print version-matched instructions for coding agents |
|
|
906
|
+
|
|
907
|
+
The built-in development server is run from Python source with
|
|
908
|
+
`pyjs.server.dev.serve(__file__)`; generated starters and examples already
|
|
909
|
+
provide this entry point.
|
|
910
|
+
|
|
911
|
+
For reproducible cross-runtime comparisons, see the [performance lab](perf/README.md).
|
|
912
|
+
It runs shared Python workloads on CPython, JavaScript, LLVM and JVM, alongside
|
|
913
|
+
handwritten JavaScript, Rust and Java references, and saves JSON with raw evidence and explicit
|
|
914
|
+
correctness or support failures. Open the live Python-authored UI with
|
|
915
|
+
`uv run pyjs serve perf.app:create_app --open /perf/`; no report HTML is written.
|
|
916
|
+
Configured docs servers can also mount live routes with
|
|
917
|
+
`pyjs docs serve --app module:mount --open /some/path/`, where `mount(application)`
|
|
918
|
+
registers routes alongside the documentation.
|
|
919
|
+
|
|
920
|
+
Web compatibility modules can declare exact npm dependencies as module
|
|
921
|
+
metadata. `pyjs npm sync` analyzes the configured application and installs only
|
|
922
|
+
the packages reachable from its client bundle into `.pyjs/npm`; no user-owned
|
|
923
|
+
`package.json` or global npm installation is required.
|
|
924
|
+
|
|
925
|
+
`pyjs.web.xterm` provides typed terminal options, terminal instances, input
|
|
926
|
+
subscriptions and the fitting addon. It pins xterm.js 6.0.0 and FitAddon
|
|
927
|
+
0.11.0. Call `create_terminal(TerminalOptions(...))`, mount it with `open`,
|
|
928
|
+
and use the async `write(terminal, text)` helper when output ordering matters.
|
|
929
|
+
Dispose subscriptions and the terminal when their host is removed. These are
|
|
930
|
+
browser bindings; running shell commands requires a separately authorized PTY
|
|
931
|
+
service. Applications that redistribute the bundle must retain the MIT notices
|
|
932
|
+
from the installed xterm packages.
|
|
933
|
+
|
|
934
|
+
Existing terminals expose mutable `terminal.options.fontSize`, `fontFamily`,
|
|
935
|
+
`scrollback` and `cursorBlink`. Assign these properties to change rendering
|
|
936
|
+
preferences without replacing the terminal or its input subscriptions. Call
|
|
937
|
+
the fitting addon's `fit()` after font changes to update the visible dimensions.
|
|
938
|
+
Reducing scrollback removes older lines from the emulator's screen buffer.
|
|
939
|
+
|
|
940
|
+
`NpmImport(..., styles=("css/package.css",))` includes package-relative,
|
|
941
|
+
self-contained styles in the managed vendor module. Styles mount once per
|
|
942
|
+
package/version/path when imported in a document; imports in Node do not
|
|
943
|
+
require a DOM. Package styles precede application styles, so application
|
|
944
|
+
overrides retain their normal cascade priority. The initial validation is
|
|
945
|
+
conservative: CSS imports, URL/image functions and CSS escapes are rejected.
|
|
946
|
+
Asset bundling is not supported. Separate declarations are merged
|
|
947
|
+
deterministically while preserving declared stylesheet order. All namespace
|
|
948
|
+
aliases for a package share that order; contradictory orders are errors,
|
|
949
|
+
including conflicts across aliases. Each package stylesheet is emitted once.
|
|
950
|
+
The styles are part of vendor cache identity and are delivered by the same
|
|
951
|
+
development and packaging paths as other managed npm dependencies.
|
|
952
|
+
|
|
953
|
+
Synchronize an application after adding its first managed JavaScript wrapper,
|
|
954
|
+
then build it normally.
|
|
955
|
+
|
|
956
|
+
## Current limitations and missing features
|
|
957
|
+
|
|
958
|
+
PyJS is intentionally a typed subset of Python, and the current releases remain
|
|
959
|
+
pre-alpha. This section summarizes the current boundary. Run `pyjs skill` for
|
|
960
|
+
guidance matching the installed version and inspect the executable templates
|
|
961
|
+
with `pyjs template`.
|
|
962
|
+
|
|
963
|
+
- Multiple inheritance is not supported.
|
|
964
|
+
- Reflection, runtime monkey-patching, `eval()`, and arbitrary dynamic imports
|
|
965
|
+
are outside the compilation model.
|
|
966
|
+
- Python standard-library and browser API coverage is incomplete; APIs are
|
|
967
|
+
added as typed PyJS definitions.
|
|
968
|
+
- User-defined generic class specialization still has unsupported shapes and
|
|
969
|
+
needs dedicated regression coverage before it is considered stable.
|
|
970
|
+
- Some invalid programs still produce low-level analyzer errors instead of
|
|
971
|
+
concise diagnostics with precise source locations.
|
|
972
|
+
- Generated bundles include source maps back to Python. Mapping coverage and
|
|
973
|
+
browser-runtime presentation will continue to improve.
|
|
974
|
+
- The built-in development server rebuilds when it starts, but does not yet
|
|
975
|
+
trigger browser reload itself. Reloadable Django applications can opt into
|
|
976
|
+
the development browser reload client.
|
|
977
|
+
- Browser-target pytest fixtures and helpers are a subset of normal pytest.
|
|
978
|
+
Browser tests support `pytest.raises()` as a context manager, including its
|
|
979
|
+
`match` argument and captured exception value.
|
|
980
|
+
- Tree shaking still has an `include=True` escape hatch for unusual methods
|
|
981
|
+
reached only through opaque JavaScript dispatch.
|
|
982
|
+
- Reactive effects run immediately for each attribute mutation; updates are
|
|
983
|
+
not currently batched.
|
|
984
|
+
- The bundled HTTP server and documentation server are development tools, not
|
|
985
|
+
production servers.
|
|
986
|
+
- Android uses direct JVM bytecode and native framework/AndroidX APIs.
|
|
987
|
+
Calculator and Notes demonstrate the supported subset; Notes editor parity
|
|
988
|
+
and broader platform coverage remain in progress.
|
|
989
|
+
- Custom Android views can override `onDraw(Canvas)` and
|
|
990
|
+
`onTouchEvent(MotionEvent)` using `pyjs.android.graphics` and
|
|
991
|
+
`pyjs.android.motion`. `pyjs.android.gestures.ScaleGestureDetector` supplies
|
|
992
|
+
native pinch recognition. Callbacks inherited through native superclasses
|
|
993
|
+
are retained without explicit Python calls. Canvas coordinates are physical
|
|
994
|
+
pixels; use display density when sharing logical-pixel geometry with web UI.
|
|
995
|
+
`Canvas.drawCircle(cx, cy, radius, paint)` and
|
|
996
|
+
`drawArc(left, top, right, bottom, start_angle, sweep_angle, use_center, paint)`
|
|
997
|
+
use the paint's fill or stroke style. Arc angles are degrees; positive sweeps
|
|
998
|
+
run clockwise, and `use_center=True` closes the arc through the oval's center.
|
|
999
|
+
Synthetic motion events use `uptime_millis()`, not wall-clock time, and must
|
|
1000
|
+
be recycled after dispatch. Pointer IDs remain stable when indexes change.
|
|
1001
|
+
- `AndroidJVMApplication.permissions` explicitly requests manifest permissions
|
|
1002
|
+
such as `("android.permission.INTERNET",)`. No permissions are added by
|
|
1003
|
+
default without dependencies. AAR manifests contribute their permissions,
|
|
1004
|
+
activities, services, providers and metadata through Android's official
|
|
1005
|
+
manifest merger. Incompatible minimum SDKs, unresolved placeholders and
|
|
1006
|
+
attribute conflicts fail the build. Set `manifest_overlays=(Path(...),)`
|
|
1007
|
+
for explicit application overrides using Android's `tools:` directives.
|
|
1008
|
+
The merger uses a cached, checksum-locked host-only classpath and JDK 21;
|
|
1009
|
+
Gradle is not needed to build an application.
|
|
1010
|
+
`network_security_config="@xml/network_policy"` links an app-owned
|
|
1011
|
+
XML resource from `resources`; Android 7 and newer apply that policy instead
|
|
1012
|
+
of the manifest's default `usesCleartextTraffic="false"`. For local HTTP
|
|
1013
|
+
testing, allow only the emulator host `10.0.2.2` in a development resource,
|
|
1014
|
+
not all hosts. Supply a production policy when building for deployment.
|
|
1015
|
+
See the [Android network-security guide][android-network-security].
|
|
1016
|
+
- Static native interface factories can be declared as standalone functions
|
|
1017
|
+
using `@jvm.native("java/util/List", name="of", interface=True)`. PyJS emits
|
|
1018
|
+
a small Java 8 forwarding class, keeping ordinary generated control flow
|
|
1019
|
+
on its existing verifier contract. This does not add interface default
|
|
1020
|
+
methods or arbitrary native Python `staticmethod` declarations.
|
|
1021
|
+
- JVM exception handling supports ordered handlers, reraising, assertions,
|
|
1022
|
+
and `finally`, including cleanup across returns, breaks and continues.
|
|
1023
|
+
Builtin exceptions can be constructed, stored in fields or collections,
|
|
1024
|
+
passed and returned, then raised repeatedly without losing identity. They
|
|
1025
|
+
accept an optional string, integer or Boolean message. A nullable string
|
|
1026
|
+
or Boolean containing `None` renders as `None`, distinct from omission.
|
|
1027
|
+
Integers retain their signed 64-bit value and
|
|
1028
|
+
Booleans use Python's `True`/`False` spelling. Assertion messages use the same
|
|
1029
|
+
conversion and are evaluated only on failure. Float and container messages
|
|
1030
|
+
remain unsupported. Caught values support `str()`, identity and
|
|
1031
|
+
`isinstance()`.
|
|
1032
|
+
Native Java exceptions retain their native category: `Exception` catches
|
|
1033
|
+
Java exceptions, while `BaseException` also catches Java errors. Declare
|
|
1034
|
+
specific Java exception classes with `@jvm.native` to catch them directly.
|
|
1035
|
+
Controlled Python operations raise Python categories for invalid indexing,
|
|
1036
|
+
division by zero, negative shifts, invalid integer parsing and storage
|
|
1037
|
+
limits; arbitrary Java API failures are not relabeled.
|
|
1038
|
+
- JVM strings support code-point iteration, `ord`, `chr`, `hex`, `replace`
|
|
1039
|
+
with optional positional or keyword `count`, and slices with a literal unit
|
|
1040
|
+
step or omitted step. Dynamic or non-unit steps remain unsupported.
|
|
1041
|
+
These operations retain the UTF-16 surrogate limitation described below.
|
|
1042
|
+
String ordering compares Unicode code points, not UTF-16 units. Chained
|
|
1043
|
+
comparisons short-circuit and evaluate each reached operand once, including
|
|
1044
|
+
nested chains and application comparison methods.
|
|
1045
|
+
- JVM Python property getters support inherited virtual dispatch and retain
|
|
1046
|
+
their declared numeric representation. This does not add property setters
|
|
1047
|
+
or properties overriding ordinary instance fields.
|
|
1048
|
+
- JVM application functions, methods, and constructors accept keyword and
|
|
1049
|
+
keyword-only arguments while preserving source evaluation order. Defaults
|
|
1050
|
+
must be immutable literals. Variadic parameters and keyword arguments to
|
|
1051
|
+
native Java declarations remain unsupported. Overrides with keyword-only
|
|
1052
|
+
parameters must preserve parameter names, kinds, order, and defaults;
|
|
1053
|
+
incompatible runtime binding contracts are rejected. Other virtual calls
|
|
1054
|
+
using keywords or omitted defaults are rejected when reachable overrides
|
|
1055
|
+
would bind them differently. Fully supplied positional calls still permit
|
|
1056
|
+
renamed parameters, and direct child-typed calls use the child's signature.
|
|
1057
|
+
- Plain Pydantic 2 models compile as typed JVM field containers, with
|
|
1058
|
+
keyword-only construction, inherited fields, scalar defaults, nested models,
|
|
1059
|
+
and supported JVM collection types. Compiler type checks apply; Pydantic
|
|
1060
|
+
coercion and constructor-time `Field` constraints remain server-side.
|
|
1061
|
+
Empty list/dictionary defaults and built-in `list`/`dict` default factories
|
|
1062
|
+
allocate fresh collections for each model and each missing JSON field.
|
|
1063
|
+
Explicit `None` remains distinct from an omitted nullable collection.
|
|
1064
|
+
Custom validators/serializers, initialization hooks, aliases, generic models,
|
|
1065
|
+
non-empty collection defaults, custom factories, frozen fields, and dynamic
|
|
1066
|
+
extras are rejected.
|
|
1067
|
+
Field access, `instance.model_dump_json()` and
|
|
1068
|
+
`Model.model_validate_json(text)` are supported. JSON methods use the typed
|
|
1069
|
+
API codec: finite scalars, string literals, nullable values, lists,
|
|
1070
|
+
string-key dictionaries, and acyclic models. A model field containing
|
|
1071
|
+
primitive-valued dictionaries, including nested containers, decodes when
|
|
1072
|
+
the field is non-nullable with an empty default. Required fields and nullable
|
|
1073
|
+
fields or items containing those dictionaries remain unsupported. This does
|
|
1074
|
+
not restrict existing non-nullable API-result decoding. JSON methods validate
|
|
1075
|
+
structure and the field bounds described below, not Pydantic coercion.
|
|
1076
|
+
Nested fields serialize their declared model shape, excluding subclass-only
|
|
1077
|
+
fields. Custom JSON method
|
|
1078
|
+
overrides and optional Pydantic method arguments are not supported.
|
|
1079
|
+
Constructing an unsupported-codec subclass also disables its parent's
|
|
1080
|
+
virtual JSON dump calls, even on an explicitly constructed parent. Static
|
|
1081
|
+
parent JSON factories remain usable. Field-only construction is unaffected.
|
|
1082
|
+
Model equality and dictionary dumping are not yet implemented.
|
|
1083
|
+
- Client `model_validate_json()` reports malformed input and structural
|
|
1084
|
+
mismatches as `ValueError`, including on JavaScript. JSON output rejects
|
|
1085
|
+
non-finite floats rather than replacing them with null. JavaScript JSON
|
|
1086
|
+
output currently rejects date/datetime values: those types share a client
|
|
1087
|
+
representation and cannot yet be serialized unambiguously. Ordinary
|
|
1088
|
+
`model_dump()` retains its existing date values.
|
|
1089
|
+
JavaScript honors `extra="forbid"` and rejects string values for strict
|
|
1090
|
+
integer fields. JSON object keys still decode within union key schemas;
|
|
1091
|
+
an exact string key branch wins over numeric conversion. Dynamic
|
|
1092
|
+
`extra="allow"` models are rejected at compilation rather than losing data.
|
|
1093
|
+
JavaScript model unions prefer the successful schema retaining the most
|
|
1094
|
+
supplied model fields, including nested fields; defaults do not increase
|
|
1095
|
+
this count. Ties retain declaration order. This is not full Pydantic smart
|
|
1096
|
+
coercion. JSON object key order is not a cross-backend canonical format.
|
|
1097
|
+
- JavaScript model validation and JVM model JSON decoding enforce field-level
|
|
1098
|
+
`ge`, `gt`, `le`, `lt`, `min_length`, and `max_length` constraints. Text
|
|
1099
|
+
lengths count Unicode code points, not UTF-16 units. Nested fields and
|
|
1100
|
+
inherited overrides keep their constraints; optional `None` bypasses bounds.
|
|
1101
|
+
Grouped annotations (`Interval`, `Len`, `StringConstraints`) and constrained
|
|
1102
|
+
aliases such as `conint` and `constr` use the same bounds. Duplicate JSON
|
|
1103
|
+
model fields validate their final value, including replacement nested models.
|
|
1104
|
+
Combining text constraints with stripping or case-conversion settings is
|
|
1105
|
+
rejected at compilation; those transformations are not implemented yet.
|
|
1106
|
+
Omitted defaults are not constraint-validated, matching Pydantic's default
|
|
1107
|
+
behavior. This does not implement `validate_default`, item-level `Annotated`
|
|
1108
|
+
constraints, nonnumeric bounds such as dates, multiple-of checks,
|
|
1109
|
+
or custom validators. JVM direct construction remains field-only. Keep
|
|
1110
|
+
server-side validation enabled.
|
|
1111
|
+
- String `Field(pattern=...)` validation shares the same non-backtracking
|
|
1112
|
+
matcher in JavaScript and JVM JSON decoding. It follows default Pydantic
|
|
1113
|
+
search semantics: use `^` and `$` for whole-value matching; `$` does not
|
|
1114
|
+
match before a trailing newline. Supported patterns contain literals,
|
|
1115
|
+
character ranges/negated classes, dot (excluding LF), escaped punctuation
|
|
1116
|
+
or `\n`/`\r`/`\t`, `?`/`*`/`+`, and `{n}`/`{n,m}`/`{n,}` repetitions.
|
|
1117
|
+
Outer anchors are optional. Unsupported syntax fails compilation, including
|
|
1118
|
+
groups, alternation, shorthand/Unicode classes, flags, class set operations,
|
|
1119
|
+
compiled Python regex objects and `regex_engine="python-re"`. Patterns are
|
|
1120
|
+
limited to 4096 source characters, 256 expanded matching states, and 4096
|
|
1121
|
+
integers in their compact program. Repetitions share character-range tables.
|
|
1122
|
+
JVM codecs load those tables from compact constants rather than expanding
|
|
1123
|
+
each state into generated instructions.
|
|
1124
|
+
Matching uses bounded state storage and linear input scanning for a fixed
|
|
1125
|
+
pattern; it does not use platform regex backtracking. Constraints apply to
|
|
1126
|
+
`str` or `str | None` fields, not annotated collection items.
|
|
1127
|
+
- `pyjs.server.jvm.JVMTransport` implements the existing `ClientTransport`
|
|
1128
|
+
HTTP interface using native Java HTTP(S), including on Android. It sends
|
|
1129
|
+
UTF-8 JSON and retains status/body for errors. Headers are explicit;
|
|
1130
|
+
redirects are not followed. Responses default to an 8 MiB byte limit.
|
|
1131
|
+
Set a finite request timeout for network operations; zero disables the
|
|
1132
|
+
connect/read timeouts. These are not total-request deadlines.
|
|
1133
|
+
Calls block the calling JVM thread despite the async interface: use an
|
|
1134
|
+
explicit worker, never Android's UI thread. Native I/O exceptions propagate.
|
|
1135
|
+
An optional `cookies=CookieManager()` from `pyjs.java.net` provides an
|
|
1136
|
+
isolated in-memory cookie jar without installing a global cookie handler.
|
|
1137
|
+
`get()` and `post_form()` support session bootstrap and ordinary Django
|
|
1138
|
+
login/logout, retaining redirects so the app can inspect their status.
|
|
1139
|
+
CSRF headers remain explicit and must follow token rotation after login.
|
|
1140
|
+
For Django over HTTPS, also send an HTTPS `Referer` from the trusted server
|
|
1141
|
+
origin; a CSRF token alone is insufficient. This is the portable choice:
|
|
1142
|
+
desktop OpenJDK silently drops explicit `Origin` headers. Native Java HTTP
|
|
1143
|
+
does not add these browser headers automatically.
|
|
1144
|
+
Managed cookies cannot be combined with explicit Cookie headers. Credential
|
|
1145
|
+
headers are not origin-scoped: keep a transport per trusted server/account.
|
|
1146
|
+
Do not install a process-global CookieHandler while using managed sessions:
|
|
1147
|
+
Java HTTP also consults that global handler. Requests reject one already
|
|
1148
|
+
installed rather than mix its credentials with the transport's private jar.
|
|
1149
|
+
Cookie persistence, cancellation, and lifecycle-aware delivery remain
|
|
1150
|
+
application responsibilities.
|
|
1151
|
+
Native `HttpCookie` construction and attribute access plus
|
|
1152
|
+
`CookieStore.getCookies()`/`add()` support explicit restoration. Direct
|
|
1153
|
+
insertion bypasses response-cookie acceptance policy: validate the original
|
|
1154
|
+
origin and attributes before inserting. `getMaxAge()` is a duration, not a
|
|
1155
|
+
remaining lifetime; record an absolute expiry when accepting a cookie and
|
|
1156
|
+
restore only its remaining duration. Do not renew expiry on every launch.
|
|
1157
|
+
Persist and restore `getVersion()` too: a constructed cookie defaults to
|
|
1158
|
+
version 1, whose quoted header differs from a version 0 response cookie.
|
|
1159
|
+
Android API 21+ `context.get_no_backup_files_dir()` supplies private storage
|
|
1160
|
+
excluded from automatic backup, not encryption or protection from deletion.
|
|
1161
|
+
- JVM clients compile ordinary `API` query, mutation, and action methods into
|
|
1162
|
+
typed remote operations, including nested API children and inherited methods.
|
|
1163
|
+
Pass an absolute HTTP(S) API root and a finite `timeout_ms`; there is no
|
|
1164
|
+
implicit browser origin for the default relative `/api` path on JVM.
|
|
1165
|
+
Server operation bodies are not analyzed or emitted. Supported schemas are
|
|
1166
|
+
scalar values, string literals, nullable values, lists, string-keyed mappings,
|
|
1167
|
+
and the plain Pydantic models described above. Results are decoded by schema;
|
|
1168
|
+
Pydantic coercion and unsupported constraints remain server-side. The compiler
|
|
1169
|
+
rejects recursive schemas, excessive API graphs, streams, JSON:API resources,
|
|
1170
|
+
relationships, variadic operation parameters, and custom API initialization.
|
|
1171
|
+
Operation errors preserve their status, code, title, detail, and field path;
|
|
1172
|
+
malformed error bodies become a generic `OperationError` retaining the body.
|
|
1173
|
+
Calls still block their thread despite their async signatures.
|
|
1174
|
+
- `pyjs.java.json.JSONReader` provides typed JSON tokens for schema-directed
|
|
1175
|
+
decoding without building an untyped object tree. Call `finish()` after
|
|
1176
|
+
reading the root value. `skip()` validates unknown values with a default
|
|
1177
|
+
nesting limit of 64 containers; number tokens keep their original spelling
|
|
1178
|
+
for the schema decoder to check range and precision. Diagnostic positions
|
|
1179
|
+
count UTF-16 units. `quote()` produces an ASCII-escaped JSON string.
|
|
1180
|
+
`integer()` requires a signed 64-bit integer token; `floating()` accepts
|
|
1181
|
+
finite binary64 values, preserving negative zero and ordinary underflow.
|
|
1182
|
+
Both reject overflow instead of silently wrapping or producing infinity.
|
|
1183
|
+
Generated operation codecs use these tokens without an untyped object tree.
|
|
1184
|
+
- JVM dictionaries support ordinary integer, float, Boolean and reference
|
|
1185
|
+
values with integer or reference keys. Integer keys retain signed 64-bit
|
|
1186
|
+
precision and compare by value. Float keys, nullable numeric keys and Boolean
|
|
1187
|
+
operands for integer-keyed dictionaries remain explicit compilation boundaries.
|
|
1188
|
+
Iteration and live, reusable key views preserve
|
|
1189
|
+
insertion order. Updating values does not invalidate an iterator; changing
|
|
1190
|
+
its key set raises `RuntimeError`. Scalar `get` requires a matching default;
|
|
1191
|
+
omitted/`None` defaults for scalar values remain explicit boundaries.
|
|
1192
|
+
`pop` returns and removes present values, evaluates explicit defaults eagerly,
|
|
1193
|
+
and raises `KeyError` for absent keys when no default was supplied.
|
|
1194
|
+
`copy` creates a shallow, insertion-ordered copy with independent keys.
|
|
1195
|
+
Dictionary subscription raises `KeyError` for missing keys without
|
|
1196
|
+
evaluating the mapping or key twice. Present `None` values remain valid.
|
|
1197
|
+
String and nullable-string keys retain Python-style quoted messages;
|
|
1198
|
+
integer keys use their decimal spelling.
|
|
1199
|
+
`KeyError()` and `KeyError("")` remain distinct. Formatting uses pinned
|
|
1200
|
+
Unicode 16 printability rather than the host JDK's Unicode version.
|
|
1201
|
+
The existing UTF-16 representation conflates adjacent high/low surrogate
|
|
1202
|
+
code points with the corresponding astral character; quoting cannot recover
|
|
1203
|
+
that distinction. Isolated surrogates are escaped.
|
|
1204
|
+
Other reference-key lookups are catchable but currently use the generic
|
|
1205
|
+
message `key not found`; their original keys remain available through `.args`.
|
|
1206
|
+
- JVM nullable integers, floats, and Booleans use boxed storage in parameters,
|
|
1207
|
+
returns, fields, and collections. `None` stays distinct from zero; equality
|
|
1208
|
+
keeps integer precision, including above `2**53`. Truth tests treat `None`
|
|
1209
|
+
and zero as false; NaN is true, as in Python. Narrow with `is not None`
|
|
1210
|
+
before arithmetic or formatting.
|
|
1211
|
+
Represented values retain their wrapping and rounding rules. Mixed numeric
|
|
1212
|
+
unions such as `int | float | None` and scalar `isinstance` remain unsupported.
|
|
1213
|
+
Numeric identity checks only support comparison against `None`; nullable
|
|
1214
|
+
numeric dictionary keys remain unsupported.
|
|
1215
|
+
Explicit casts from present nullable numbers use the scalar ABI without
|
|
1216
|
+
losing integer precision. As with other static casts, callers must ensure
|
|
1217
|
+
the value is not `None` before casting to a non-null type.
|
|
1218
|
+
- `pyjs.java.time` binds native ISO `LocalDate` values, device-local today and
|
|
1219
|
+
explicit fixed clocks/time zones. `local_date_at(fixed_clock(...))` makes
|
|
1220
|
+
calendar tests deterministic without replacing the process-wide time zone.
|
|
1221
|
+
This is a JVM API (Android API 26+), not a Python `datetime` implementation.
|
|
1222
|
+
Android applications using it must set `min_sdk` to at least 26; compilation
|
|
1223
|
+
does not yet diagnose lower minima or add core-library desugaring.
|
|
1224
|
+
- JVM list membership supports matching integer, Boolean and string items,
|
|
1225
|
+
including nullable strings. Floats and other mixed item domains remain
|
|
1226
|
+
explicit unsupported boundaries.
|
|
1227
|
+
Dictionary membership checks keys, including nullable strings/Booleans,
|
|
1228
|
+
independently of their values. The dictionary key storage restrictions above
|
|
1229
|
+
still apply. Membership syntax evaluates the needle before the container,
|
|
1230
|
+
including application and declared native `__contains__` methods. Explicit
|
|
1231
|
+
method calls retain receiver-first evaluation order.
|
|
1232
|
+
- JVM `and`/`or` conditions accept mixed string, integer and Boolean operands,
|
|
1233
|
+
preserving short-circuit order in branches, loops, assertions and negation.
|
|
1234
|
+
Nullable strings treat both `None` and the empty string as false. Non-final
|
|
1235
|
+
float, collection and custom-object operands still require explicit tests.
|
|
1236
|
+
This does not add storage for mixed primitive/reference union values.
|
|
1237
|
+
- JVM fixed tuples support local unpacking, including nested tuples, swaps,
|
|
1238
|
+
repeated targets and tuple items in loops. Unpacking into fields or indices,
|
|
1239
|
+
starred targets and variable-length inputs remains unsupported.
|
|
1240
|
+
- JVM `tuple[T, ...]` supports reference-valued items, including nullable
|
|
1241
|
+
references and nested tuples. Literals, calls, returns and fields retain
|
|
1242
|
+
identity; `len`, signed integer/Boolean indexing and `for` loops work.
|
|
1243
|
+
Primitive items, fixed-to-variable tuple conversions, slicing, repetition,
|
|
1244
|
+
membership, unpacking and structural equality remain unsupported.
|
|
1245
|
+
Equality on a reference array erased to `object` raises `TypeError` rather
|
|
1246
|
+
than using Java array identity; `is` and `is not` remain available.
|
|
1247
|
+
Use explicit `cast(object, value)` when erasing reference items to `object`;
|
|
1248
|
+
this does not add general primitive boxing.
|
|
1249
|
+
- JVM synchronous context managers support nested cleanup, suppression and
|
|
1250
|
+
abrupt exits. Exceptional `__exit__` calls receive a Java class token, the
|
|
1251
|
+
actual throwable and a JVM stack-trace array, not Python traceback objects.
|
|
1252
|
+
Normal exits receive three `None` values. Nullable Boolean results preserve
|
|
1253
|
+
the distinction between `None`, `False` and `True`.
|
|
1254
|
+
Native exception construction requires an explicit Java constructor
|
|
1255
|
+
declaration. Python's base-exception initializer does not specify Java
|
|
1256
|
+
overloads; inherited native declarations are trusted to describe the actual
|
|
1257
|
+
Java constructor signatures.
|
|
1258
|
+
Writable chaining state, builtin literal `None` messages
|
|
1259
|
+
and `UnicodeDecodeError` payloads remain unsupported. Explicit
|
|
1260
|
+
reraising keeps the original JVM stack trace rather than adding a Python
|
|
1261
|
+
traceback frame. Async context managers remain unsupported.
|
|
1262
|
+
- JVM managed exceptions expose read-only `.args` containing original
|
|
1263
|
+
positional values, independently of formatted text. Keywords and defaulted
|
|
1264
|
+
parameters are excluded; a base initializer replaces the tuple without
|
|
1265
|
+
changing previously saved tuples. Original references and currently
|
|
1266
|
+
supported numeric constructor payloads retain their values, including
|
|
1267
|
+
custom float and JVM-width arguments. This does not broaden default
|
|
1268
|
+
exception text or builtin constructor signatures. Native Java exceptions
|
|
1269
|
+
have no Python argument tuple: concrete access is rejected, while widened
|
|
1270
|
+
access raises `TypeError`. Tuple operations retain the limits above.
|
|
1271
|
+
Erased numeric payloads compare with Python's numeric equality, but cannot
|
|
1272
|
+
be dictionary keys yet: numeric and reference-array keys through an `object`
|
|
1273
|
+
view raise `TypeError` instead of using incompatible Java hashing.
|
|
1274
|
+
- Native Java file bindings and Android `Context.getFilesDir()` support
|
|
1275
|
+
app-private storage. The Notes example demonstrates bounded card-order
|
|
1276
|
+
snapshots, checked replacement, failure reporting and retry without
|
|
1277
|
+
overwriting an unreadable snapshot. See its README for durability and
|
|
1278
|
+
host-platform limits.
|
|
1279
|
+
- `pyjs.android.json.JsonWriter` writes structured JSON through native Java
|
|
1280
|
+
character writers. Use `StringWriter` for in-memory output or wrap a
|
|
1281
|
+
document provider's `ContentResolver.open_output_stream(uri, "wt")` in an
|
|
1282
|
+
`OutputStreamWriter(stream, "UTF-8")`. The resolver may return `None` or
|
|
1283
|
+
raise a native I/O/security exception. Close owned writers and streams in
|
|
1284
|
+
`finally`; closing `JsonWriter` also closes its underlying writer. A provider
|
|
1285
|
+
failure can leave partial output, so do not report success before close.
|
|
1286
|
+
- Android packages can set `AndroidJVMApplication.application_class` to a
|
|
1287
|
+
source-defined `Application` subclass. Initialize framework-owned state in
|
|
1288
|
+
`onCreate`, not Python `__init__` (including inherited initializers).
|
|
1289
|
+
Compiled tests select the single most-derived Application owner; unrelated
|
|
1290
|
+
owners require separate test selections. Application state lasts only for
|
|
1291
|
+
the current process, not across process termination.
|
|
1292
|
+
- `pyjs.java.uuid` provides `random_uuid()` and `parse_uuid()` returning a
|
|
1293
|
+
native `UUID` with `toString()`, `version()`, and `variant()`. Parsing follows
|
|
1294
|
+
the platform's `UUID.fromString` rules, which can differ across Java and
|
|
1295
|
+
Android releases; it is not a strict canonical-text validator. Catch native
|
|
1296
|
+
parse errors with `pyjs.java.errors.IllegalArgumentException`.
|
|
1297
|
+
- `pyjs.java.io.OutputStream.write(buffer, offset, length)` writes a range of
|
|
1298
|
+
native `JVMArray[int8]` bytes, including through Android document-provider
|
|
1299
|
+
streams. `ByteArrayOutputStream` inherits this operation. Native bounds
|
|
1300
|
+
and I/O errors propagate; close owned streams in `finally` and do not report
|
|
1301
|
+
a completed export before close succeeds. A failed write can leave partial
|
|
1302
|
+
output; this API does not provide atomic replacement or disk synchronization.
|
|
1303
|
+
- `pyjs.java.io.FileInputStream(File(path))` reads local binary files through
|
|
1304
|
+
the existing bounded `read(buffer)` API. `pyjs.java.zip` provides native
|
|
1305
|
+
`ZipEntry`, `ZipOutputStream`, `ZipInputStream` and `ZipException` on JVM and
|
|
1306
|
+
Android. Open each output entry with `putNextEntry`, write byte ranges, then
|
|
1307
|
+
`closeEntry`. `finish` writes the central directory without closing the
|
|
1308
|
+
destination; a successful ZIP close closes the underlying stream too.
|
|
1309
|
+
Close the ZIP wrapper once in an inner `finally` and the owned underlying
|
|
1310
|
+
stream in an outer `finally`: a failed ZIP close can leave it open.
|
|
1311
|
+
Input `read` returns -1 at the current entry's end; `getNextEntry` returns
|
|
1312
|
+
`None` after the last entry. These are blocking primitives, not filesystem
|
|
1313
|
+
extraction helpers. Bound entry counts and decompressed bytes, validate
|
|
1314
|
+
paths before extraction, and handle I/O failures and partial output.
|
|
1315
|
+
`ZipInputStream` reads local headers, not the central directory; completing
|
|
1316
|
+
its entries is not validation of the entire archive structure.
|
|
1317
|
+
- `pyjs.java.io.InputStreamReader(stream, decoder)` reads native character
|
|
1318
|
+
chunks with `read(buffer, offset, length)`. Obtain a strict UTF-8 decoder
|
|
1319
|
+
with `pyjs.java.charset.charset_for_name("UTF-8").newDecoder()`. Malformed
|
|
1320
|
+
and truncated byte sequences raise `IOException`, not replacement text.
|
|
1321
|
+
Use `JVMArray[uint16]` for the buffer and `pyjs.java.string_from_chars()`
|
|
1322
|
+
to copy a returned range. Offsets and counts are UTF-16 code units, so a
|
|
1323
|
+
chunk may split a surrogate pair; joining chunks preserves the text.
|
|
1324
|
+
Reads return -1 at EOF. Bound total input before accumulating chunks and
|
|
1325
|
+
close the reader in `finally`, which also closes its underlying stream.
|
|
1326
|
+
`StringReader` and `ByteArrayInputStream` support in-memory sources.
|
|
1327
|
+
- `pyjs.java.base64` provides `base64_encoder()` and `base64_decoder()` for
|
|
1328
|
+
native byte arrays. Encoding uses the basic alphabet and padding; decoding
|
|
1329
|
+
follows Java's rules, including omitted final padding, rather than enforcing
|
|
1330
|
+
canonical input. Catch invalid input with
|
|
1331
|
+
`pyjs.java.errors.IllegalArgumentException`. Base64 requires Android API 26+.
|
|
1332
|
+
`pyjs.java.security.message_digest(name)` uses installed platform providers;
|
|
1333
|
+
unsupported names raise its native `NoSuchAlgorithmException`.
|
|
1334
|
+
`update(bytes)` accumulates input, `digest()` returns bytes and resets the
|
|
1335
|
+
instance, and `reset()` discards pending input without producing a digest.
|
|
1336
|
+
- `pyjs.java.crypto` exposes native JCA keys, ciphers and key stores.
|
|
1337
|
+
`pyjs.android.keystore` provides API 23+ key-generation parameters for
|
|
1338
|
+
non-exportable Android keys. AES-GCM authenticates ciphertext and associated
|
|
1339
|
+
context; a changed value or wrong key rejects decryption. These bindings
|
|
1340
|
+
do not implement credential storage or backup policy. Android Keystore
|
|
1341
|
+
availability requires a device/emulator, not a desktop JVM provider.
|
|
1342
|
+
- `pyjs.java.concurrent` provides native `Runnable` and `Thread`;
|
|
1343
|
+
`pyjs.android.dispatch` provides `Handler` and `main_looper()`.
|
|
1344
|
+
`Handler.post()` reports queue acceptance, not completed or durable work.
|
|
1345
|
+
Keep UI state on the main thread, pass detached snapshots to workers, and
|
|
1346
|
+
acknowledge results on the main loop. These are not durable Android jobs.
|
|
1347
|
+
Compiled tests can use `pyjs.android.testing.run_on_main()` without a
|
|
1348
|
+
visible Activity.
|
|
1349
|
+
- Notes demonstrates serialized background saves, detached snapshots,
|
|
1350
|
+
main-loop acknowledgements and Activity-scoped status observers.
|
|
1351
|
+
`pyjs.java.concurrent.AtomicBoolean` provides release/acquire publication
|
|
1352
|
+
for worker results; pending edits still require successful persistence to
|
|
1353
|
+
survive process termination.
|
|
1354
|
+
`Handler.postDelayed(task, delay_ms)` schedules on the handler's loop without
|
|
1355
|
+
an attached view; guard stale callbacks after lifecycle or account changes.
|
|
1356
|
+
- `pyjs.android.sqlite` exposes Android's database, cursor, prepared-statement
|
|
1357
|
+
and exception APIs. Bind values instead of interpolating SQL, close cursors
|
|
1358
|
+
and statements, and pair `beginTransaction()` with `endTransaction()` in a
|
|
1359
|
+
`finally` block. Call `setTransactionSuccessful()` only after all operations
|
|
1360
|
+
succeed. These APIs block and transactions belong to one thread; application
|
|
1361
|
+
database work should run on a worker, not the UI thread.
|
|
1362
|
+
Cursor rows are limited by Android's `CursorWindow`; use a statement's
|
|
1363
|
+
`simpleQueryForString()` for large scalar text instead of a cursor row.
|
|
1364
|
+
Android's default corruption handler may delete the database and reopen an
|
|
1365
|
+
empty file. Pass a `DatabaseErrorHandler` as `open_database`'s third argument
|
|
1366
|
+
to choose recovery policy. Its `onCorruption(database)` callback can inspect
|
|
1367
|
+
`database.getPath()` and raise `SQLiteDatabaseCorruptException(message)`
|
|
1368
|
+
to refuse opening without that deletion. Raising prevents Android's retry
|
|
1369
|
+
and replaces the original diagnostic. A non-deleting callback may instead
|
|
1370
|
+
return, retaining native error reporting but allowing the open retry.
|
|
1371
|
+
Neither policy repairs corruption or replaces independent backups.
|
|
1372
|
+
- JVM `sorted()` supports lists, strings, sets and dictionary keys with stable
|
|
1373
|
+
ordering, including `key` callbacks and `reverse=True`. It materializes the
|
|
1374
|
+
input before evaluating each key once, then uses only `<` and bounds
|
|
1375
|
+
comparisons to O(n log n). Sorting itself leaves the input unchanged;
|
|
1376
|
+
callbacks may mutate it. Other iterable kinds, tuple keys and fixed-width
|
|
1377
|
+
item representations remain explicit compilation boundaries.
|
|
1378
|
+
NaNs and inconsistent comparators have no guaranteed order; their output
|
|
1379
|
+
and comparison-call sequence may differ from CPython's sorting algorithm.
|
|
1380
|
+
- JVM callbacks support emitted module functions and non-capturing lambdas
|
|
1381
|
+
with fixed positional signatures. Named module functions retain reference
|
|
1382
|
+
identity across repeated loads; each evaluated lambda creates a new callback.
|
|
1383
|
+
Defaults, bound methods, captures, represented numeric signatures and
|
|
1384
|
+
adaptation between different runtime signatures remain unsupported.
|
|
1385
|
+
- JVM reference-valued sets support literals, empty construction, iteration,
|
|
1386
|
+
membership, truth, length, `add`, `discard`, `clear` and shallow `copy`.
|
|
1387
|
+
Numeric members, custom equality/hash, set algebra and iterable construction
|
|
1388
|
+
remain unsupported; unsupported operations fail during compilation.
|
|
1389
|
+
Structural mutation during iteration raises `RuntimeError`, including
|
|
1390
|
+
same-size remove/add changes that CPython may let continue.
|
|
1391
|
+
- JVM `list(existing_list)` and `existing_list.copy()` copy list storage while
|
|
1392
|
+
retaining shared references to its items. Empty copies can grow normally.
|
|
1393
|
+
Source and result
|
|
1394
|
+
must have matching item storage and representation; converting other
|
|
1395
|
+
iterable kinds or item layouts remains unsupported.
|
|
1396
|
+
- JVM `list.pop()` and `list.pop(index)` remove and return the selected item
|
|
1397
|
+
in place, preserving aliases, shallow identity and numeric storage. Negative
|
|
1398
|
+
indices count from the end. Empty lists and out-of-range indices raise
|
|
1399
|
+
`IndexError`; vacated array slots are cleared. Removing the last element is
|
|
1400
|
+
constant time; removing an earlier element shifts the following items.
|
|
1401
|
+
- JVM list slices preserve item storage and shallow identity in an independent
|
|
1402
|
+
list. Bounds accept integers, Booleans or `None`; negative bounds and steps
|
|
1403
|
+
follow Python clipping rules. A zero step raises `ValueError`. Work and
|
|
1404
|
+
additional storage are proportional to the number of selected items.
|
|
1405
|
+
Slice assignment, deletion and first-class slice objects remain unsupported.
|
|
1406
|
+
- JVM list concatenation creates independent list storage while retaining
|
|
1407
|
+
shallow item identity. Both operands must have matching item storage and
|
|
1408
|
+
representations; other layout combinations remain unsupported.
|
|
1409
|
+
Empty operands need a typed list binding; untyped `[]` operands are not
|
|
1410
|
+
inferred at this binary-operation boundary.
|
|
1411
|
+
List `+=` remains unsupported; use `extend()` for in-place mutation.
|
|
1412
|
+
- JVM `math.sqrt()` accepts integers, Booleans and floats. Negative inputs
|
|
1413
|
+
raise `ValueError`; negative zero, positive infinity and NaN retain their
|
|
1414
|
+
floating-point behavior. The implementation uses Java's native square root
|
|
1415
|
+
after a Python-compatible domain check. Domain errors currently use the
|
|
1416
|
+
message `math domain error`; wording differs from newer CPython releases.
|
|
1417
|
+
- JVM custom Python exception classes retain inherited catches, typed fields,
|
|
1418
|
+
owned identity, custom initializers and module-scoped class identity.
|
|
1419
|
+
String/integer/Boolean positional arguments supply text without `super()`;
|
|
1420
|
+
keywords and defaulted parameters do not become that original text.
|
|
1421
|
+
`super().__init__(message)` can replace the text. Custom `__str__` methods
|
|
1422
|
+
keep virtual dispatch through base-typed and union-typed references.
|
|
1423
|
+
Field-only non-scalar arguments remain valid. Consuming their unsupported
|
|
1424
|
+
default text raises a focused `TypeError`; replacing it with a scalar message
|
|
1425
|
+
or providing a custom formatter avoids that unsupported operation.
|
|
1426
|
+
Java logging preserves the exception and stack trace if formatting fails,
|
|
1427
|
+
using `<exception str() failed>` as its message. Explicitly raised custom
|
|
1428
|
+
exceptions retain their formatters even without a Python `str()` call.
|
|
1429
|
+
The same applies to exceptions passed to native Java calls, exposed through
|
|
1430
|
+
native views, stored in native fields, or returned by Java callbacks,
|
|
1431
|
+
including typed map contents, `cast(object, ...)` and nullable native views.
|
|
1432
|
+
Conditional values retain a shared custom exception base when returning
|
|
1433
|
+
through that base. Raw sibling unions also retain formatting in conditional
|
|
1434
|
+
locals, list items and multi-type exception handlers.
|
|
1435
|
+
Optional exceptions format absent values as `None` through `str()`, f-strings
|
|
1436
|
+
and no-argument `__str__()` calls; present values keep custom dispatch.
|
|
1437
|
+
Python-authored subclasses of native Java throwables keep their formatters
|
|
1438
|
+
through these Python text operations, including mixed exception unions.
|
|
1439
|
+
Their Java `getMessage()` behavior is unchanged.
|
|
1440
|
+
`raise error from cause` retains cause identity for Python-managed
|
|
1441
|
+
exceptions; `from None` clears it and sets suppression. Read-only
|
|
1442
|
+
`__cause__` and `__suppress_context__` expose this state. Replacing causes,
|
|
1443
|
+
self-cycles, cleanup and reraising preserve Python semantics; Java stack
|
|
1444
|
+
traces show explicit causes. Native Java failures may be causes, but cannot
|
|
1445
|
+
receive Python-managed chaining state: concrete native targets are rejected
|
|
1446
|
+
at compile time, and widened targets raise `TypeError`. Foreign exceptions
|
|
1447
|
+
expose their existing Java cause and report no Python suppression flag.
|
|
1448
|
+
On managed exceptions, Java `initCause()` remains visible until Python
|
|
1449
|
+
explicitly sets or clears the cause; that Python state then takes priority.
|
|
1450
|
+
Use exception instances rather than classes for the raise/cause operands.
|
|
1451
|
+
Read-only `__context__` retains the active handled exception when a Python
|
|
1452
|
+
raise or runtime check fails, including in called helpers and cleanup.
|
|
1453
|
+
`from None` suppresses reporting without discarding this context. Nested
|
|
1454
|
+
handlers restore their enclosing state on return and unwind, and separate
|
|
1455
|
+
threads never share active handlers. Reusing exceptions breaks implicit
|
|
1456
|
+
context cycles without altering explicit causes. Native Java failures may
|
|
1457
|
+
be context values, but expose no Python context themselves.
|
|
1458
|
+
`pyjs.java.format_exception(error)` renders causes or unsuppressed context
|
|
1459
|
+
oldest-first, with Java frames, generated class names and native suppressed
|
|
1460
|
+
details. Managed exceptions use that rendering in all Java `printStackTrace`
|
|
1461
|
+
overloads too. Native roots keep Java's printer; use `format_exception` to
|
|
1462
|
+
include Python context beneath them. Reports handle cycles iteratively and
|
|
1463
|
+
do not mutate exception relationships or stack traces. Native suppressed
|
|
1464
|
+
subtrees retain Java's cause traversal. Invalid managed formatters render
|
|
1465
|
+
`<exception str() failed>` without losing the original failure.
|
|
1466
|
+
Reports use the host line separator and preserve PrintWriter auto-flush
|
|
1467
|
+
settings. For uncaught chains, Java's thread prefix precedes the oldest
|
|
1468
|
+
entry; the escaping exception appears last, following Python chain order.
|
|
1469
|
+
Assignment to chaining attributes remains unsupported.
|
|
1470
|
+
Explicit optional calls require string-compatible formatter results; narrow
|
|
1471
|
+
the receiver before consuming a differently typed custom result.
|
|
1472
|
+
`object` locals retain existing inferred union/collection storage, but
|
|
1473
|
+
cannot erase exception values or exception-bearing containers. Other plain
|
|
1474
|
+
`object` initializers remain unsupported unless the value is already erased,
|
|
1475
|
+
such as an argument-tuple item or explicit cast. Use explicit casts to expose
|
|
1476
|
+
supported reference values to Java.
|
|
1477
|
+
Explicit `__str__()` calls through base views require compatible override
|
|
1478
|
+
result types; narrow to the concrete type for a differently typed result.
|
|
1479
|
+
Local `super()` aliases keep lexical dispatch; mixed or escaping proxies
|
|
1480
|
+
receive a focused compilation diagnostic.
|
|
1481
|
+
Python methods are isolated from native Throwable method names. Custom
|
|
1482
|
+
`__new__`, unbound builtin initialization and multiple exception bases remain
|
|
1483
|
+
unsupported. Construct a custom-initializer class before raising it.
|
|
1484
|
+
|
|
1485
|
+
Run `pyjs skill` for the installed-version guidance and `pyjs template` for
|
|
1486
|
+
complete executable examples.
|
|
1487
|
+
|
|
1488
|
+
## Editor analysis
|
|
1489
|
+
|
|
1490
|
+
Run `pyjs lsp --root PATH` for experimental, versioned module snapshots and
|
|
1491
|
+
compiler-backed completion and signature queries. Pass
|
|
1492
|
+
`--python /path/to/python` to execute analysis with project dependencies in a
|
|
1493
|
+
separate interpreter containing PyJS. See the
|
|
1494
|
+
[editor analysis protocol](pyjs/language/README.md) for source synchronization,
|
|
1495
|
+
execution behavior, and current limitations.
|
|
1496
|
+
|
|
1497
|
+
## Contributing
|
|
1498
|
+
|
|
1499
|
+
The development environment, repository structure, compiler contracts, and
|
|
1500
|
+
verification workflow are documented in [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
1501
|
+
|
|
1502
|
+
PyJS is distributed under the [BSD 3-Clause License](LICENSE).
|
|
1503
|
+
|
|
1504
|
+
[ci]: https://github.com/pyjs/pyjs/actions/workflows/ci.yml
|
|
1505
|
+
[ci-badge]: https://github.com/pyjs/pyjs/actions/workflows/ci.yml/badge.svg
|
|
1506
|
+
[pypi]: https://pypi.org/project/pyjs/
|
|
1507
|
+
[pypi-badge]: https://img.shields.io/pypi/v/pyjs.svg
|
|
1508
|
+
[python-badge]: https://img.shields.io/pypi/pyversions/pyjs.svg
|
|
1509
|
+
[license]: LICENSE
|
|
1510
|
+
[license-badge]: https://img.shields.io/pypi/l/pyjs.svg
|
|
1511
|
+
[android-network-security]:
|
|
1512
|
+
https://developer.android.com/privacy-and-security/security-config
|