echidnae-javascript 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: echidnae-javascript
3
+ Version: 0.3.0
4
+ Summary: JavaScript-style Python values and a bounded Python-to-JavaScript compiler
5
+ Author: ellainng
6
+ Author-email: ellainng <299958882+ellainng@users.noreply.github.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE.md
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Programming Language :: Python :: 3.14
11
+ Requires-Dist: echidnae-fetch>=0.2.1,<0.3.0
12
+ Requires-Dist: echidnae-json>=0.1.1,<0.2.0
13
+ Requires-Python: >=3.14
14
+ Project-URL: Repository, https://github.com/wispsy/echidnae
15
+ Project-URL: Issues, https://github.com/wispsy/echidnae/issues
16
+ Description-Content-Type: text/markdown
17
+
18
+ # echidnae-javascript
19
+
20
+ JavaScript-style objects, methods and functions for Python 3.14+, using the
21
+ shared `echidnae.javascript` namespace. An alpha compatibility layer with a
22
+ documented subset of ECMAScript behavior.
23
+
24
+ ```sh
25
+ python -m pip install echidnae-javascript==0.3.0
26
+ ```
27
+
28
+ ```python
29
+ from echidnae.javascript import Array, JSON, Math, Object, String, undefined
30
+
31
+ people = JSON.parse('[{"name":"Ada","score":8},{"name":"Lin","score":6}]')
32
+ names = people.filter(lambda person: person.score >= 7).map(
33
+ lambda person: person.name.toUpperCase()
34
+ )
35
+ assert names.join(", ") == "ADA"
36
+
37
+ profile = Object({"name": String("Ada"), "scores": Array.of(8, 6)})
38
+ assert profile.missing is undefined
39
+ assert profile.scores.reduce(lambda total, score: total + score, 0) == 14
40
+ assert Math.round(2.5) == 3
41
+ assert JSON.stringify(profile) == '{"name":"Ada","scores":[8,6]}'
42
+ ```
43
+
44
+ Explicit `Object`, `Array`, `String` and `Number` values expose JavaScript names
45
+ and behavior. Ordinary Python literals and operators retain Python semantics.
46
+ Objects and arrays compare by identity and remain truthy when empty. Use
47
+ `Boolean(value)` or `truthy(value)` when testing JavaScript truthiness of values
48
+ that might include Python containers.
49
+
50
+ ## Standalone packages
51
+
52
+ Installation includes two independently useful dependencies:
53
+
54
+ | Distribution | Import | Purpose |
55
+ | --- | --- | --- |
56
+ | `echidnae-fetch>=0.2.1,<0.3.0` | `echidnae.fetch` | Standard-library HTTP Fetch and Promise APIs |
57
+ | `echidnae-json>=0.1.1,<0.2.0` | `JSON` | Python-friendly JSON parsing, serialization and dot traversal |
58
+
59
+ ```python
60
+ import asyncio
61
+ from echidnae.fetch import fetch
62
+ from echidnae.javascript import echidnae.json as JSON
63
+
64
+ async def main():
65
+ response = await fetch("https://example.com/api/people")
66
+ if not response.ok:
67
+ raise RuntimeError(f"HTTP {response.status}")
68
+ people = JSON.parse(await response.text())
69
+ return people
70
+
71
+ # Run against your own JSON endpoint:
72
+ # people = asyncio.run(main())
73
+ ```
74
+
75
+ `echidnae.javascript.fetch`, `Promise`, `Headers`, `Request`, `Response` and `FetchError`
76
+ are the same objects exported by `echidnae.fetch`. Fetch 0.2.0 changes the old
77
+ `from javascript import fetch` spelling to `from echidnae.fetch import fetch`.
78
+
79
+ `response.json()` retains Fetch's standalone `JSONObject`/list result. Use
80
+ `echidnae.javascript.JSON.parse(await response.text())` for runtime Object/Array/String
81
+ values. Standalone `import echidnae.json as JSON` preserves Python integers and containers;
82
+ `from echidnae.javascript import echidnae.json as JSON` uses binary64 numbers and JavaScript serialization
83
+ rules for its supported subset.
84
+
85
+ ## Supported surface
86
+
87
+ Core data objects and sparse arrays; UTF-16 String methods; Number predicates and
88
+ prefix parsers; Boolean conversion; selected Math functions; JSON; and the
89
+ standalone Fetch/Promise APIs. See the complete
90
+ [compatibility matrix](docs/compatibility.md) for method lists and limits.
91
+
92
+ Python keywords require `Array.from_`, `Object.is_`, and `Promise.finally_`.
93
+ `None` represents `null`; `undefined` is a separate singleton. Array bracket
94
+ indices follow JavaScript rules: `values[-1]` is a named property, and
95
+ `values.at(-1)` accesses the last element. `Array(3)` creates three holes;
96
+ `Array.of(3)` creates one element containing 3.
97
+
98
+ Version 0.3.0 retains a bounded Python-to-JavaScript compiler: a
99
+ [binding-aware front end](docs/compiler-front-end.md), [ES module emitter](docs/compiler-emitter.md),
100
+ [local-module compiler](docs/compiler-modules.md), [async profile](docs/compiler-async.md)
101
+ and [browser worker/host target](docs/compiler-browser.md). Python parses source
102
+ at build time; generated modules and selected helpers execute on the client.
103
+ The separate pocket-python interpreter will parse newly entered Python in the browser.
104
+
105
+ ```python
106
+ from echidnae.javascript.emitter import compile_source
107
+
108
+ artifact = compile_source("def count(text):\n return len(text)", filename="counter.py")
109
+ # artifact.files contains emitted echidnae.javascript, source map and provenance notice.
110
+ ```
111
+
112
+ This alpha supports the explicit [compiler language](docs/compiler-language.md),
113
+ not arbitrary Python dependencies or complete ECMAScript. Prototypes, descriptors,
114
+ Date, RegExp, Map/Set, typed arrays and unlisted APIs remain future work. See
115
+ [0.2.0 release notes](docs/release-0.2.0.md), the [implementation plan](IMPLEMENTATION_PLAN.md),
116
+ [issues](https://github.com/wispsy/echidnae/issues) and
117
+ [Project](https://github.com/orgs/wispsy/projects/11).
118
+
119
+ ## Development
120
+
121
+ ```sh
122
+ uv sync
123
+ uv run python -m unittest discover -s tests -v
124
+ uv build
125
+ ```
126
+
127
+ Node.js 24 runs the native ECMAScript differential fixture. That test is skipped
128
+ when Node is absent locally; CI and release builds require it. Runtime code
129
+ needs only Python and the two declared companions. Tests make no external
130
+ network requests.
131
+
132
+ The [compiler emitter](docs/compiler-emitter.md) produces deterministic
133
+ ES modules for the approved single-module Python profile. The compiler APIs are included in the 0.3.0 distribution.
134
+
135
+ The explicit [async compiler profile](docs/compiler-async.md) adds lazy coroutines,
136
+ awaited Promise values, callbacks and context cancellation. The [browser target](docs/compiler-browser.md) adds named DOM controls, callbacks,
137
+ native Fetch text and worker stop/restart.
138
+
139
+ Build the local [text_metrics browser example](docs/compiler-browser.md#run-the-example)
140
+ with `uv run python examples/browser_text_metrics.py --output build/browser-text-metrics`.
141
+ It uses our emitted modules and helpers in a worker; source parsing remains the
142
+ separate independent-interpreter milestone.
143
+
144
+ The compiler has a versioned [CPython/Node/browser parity suite](docs/compiler-conformance.md) with typed results, source-map error checks and explicit unsupported boundaries.
@@ -0,0 +1,21 @@
1
+ echidnae/javascript/__init__.py,sha256=aLl96i9S43utwLsiZlp10HP7RScsimSEGLJG0d6Ar_4,764
2
+ echidnae/javascript/_array.py,sha256=aEYgMTtwIkCTmnvib84pyQPIlVHfv-DaU-rMSfVHQ_M,11461
3
+ echidnae/javascript/_browser/browser-host.mjs,sha256=EirtftvaN__pLE2C78hM7U7542h828KZ6gmADbsPAio,12195
4
+ echidnae/javascript/_browser/browser-protocol.mjs,sha256=hBYCuOYFUpCT-GOKbOSXdDy9cNC7BaOe1V9Q9l6Gk_E,9628
5
+ echidnae/javascript/_browser/browser-worker.mjs,sha256=sNQtxUKiB4dhi8hZcVl-3DFrMOd5w6xoJut8hdmzIZg,6947
6
+ echidnae/javascript/_compiler_runtime.py,sha256=MNGo74jLaW5ddT1FQtV0HZGJFQDEpbA9okgAWd7_h2k,25151
7
+ echidnae/javascript/_json.py,sha256=UsXxP8tRibY9KYjXEj_mtubaWVkSlnyvTt5C3qchIec,4740
8
+ echidnae/javascript/_math.py,sha256=znk-HF5ztys1323KUcxdiJ7sZ4W2QBJ_zjqPLbnvQ_c,3253
9
+ echidnae/javascript/_number.py,sha256=RXQ5hlqBNfKGwHcZJA9-I_1MhiDXh9ccDLr8dlhCFVE,2617
10
+ echidnae/javascript/_object.py,sha256=kZUbL_w44ObuqeKjoKFhd5tS1xVsA6U20jrKA4avvG4,6628
11
+ echidnae/javascript/_string.py,sha256=iZPCD_UYwmiQSgsy3gJ6WDs5MnlatBw2NffUuGlRX14,5970
12
+ echidnae/javascript/_values.py,sha256=2TOauZZ323sXVgtmGDH0DMfO4Z1OMxhn6bbevUfLloQ,6116
13
+ echidnae/javascript/browser.py,sha256=lN9k_naLQeZdJD-MIC-w66KmyGEP_afGYMDht6X3gzk,3885
14
+ echidnae/javascript/compiler.py,sha256=I-Fas2ijG2iZxmnIkYX58YyEYgRHi2aPOHW3hvorIHg,27881
15
+ echidnae/javascript/emitter.py,sha256=JJrhlj-GkjSmRJt71z1ewes5UWT3fY36nnI5zeNxrPs,15765
16
+ echidnae/javascript/modules.py,sha256=iZ0Uw7raL1Or-NQbz7fOuCcc5_j0w4PylbZXnIbWlds,17610
17
+ echidnae/javascript/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ echidnae_javascript-0.3.0.dist-info/licenses/LICENSE.md,sha256=dJjxPlUliHO6iuJiKxsIn0HSnRRb-dp_8lpVtAunRj8,1063
19
+ echidnae_javascript-0.3.0.dist-info/WHEEL,sha256=e4_1dyBeezi8ZjfxrZ3bnVOxFDa3ksqVqH0jTHkUZ3k,81
20
+ echidnae_javascript-0.3.0.dist-info/METADATA,sha256=PymNxOBGXxmqp8vB93oEu38MqCx5cnRYPl76w5ETt7k,6409
21
+ echidnae_javascript-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.12.19
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wispsy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.