@pyreon/compiler 0.13.1 → 0.15.0
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.
- package/README.md +14 -4
- package/lib/analysis/index.js.html +1 -1
- package/lib/index.js +1330 -409
- package/lib/types/index.d.ts +152 -14
- package/package.json +12 -1
- package/src/event-names.ts +65 -0
- package/src/index.ts +10 -1
- package/src/jsx.ts +974 -784
- package/src/pyreon-intercept.ts +728 -0
- package/src/test-audit.ts +435 -0
- package/src/tests/depth-stress.test.ts +16 -0
- package/src/tests/detector-tag-consistency.test.ts +86 -0
- package/src/tests/jsx.test.ts +1170 -4
- package/src/tests/native-equivalence.test.ts +731 -0
- package/src/tests/project-scanner.test.ts +30 -0
- package/src/tests/pyreon-intercept.test.ts +486 -0
- package/src/tests/react-intercept.test.ts +354 -0
- package/src/tests/runtime/control-flow.test.ts +159 -0
- package/src/tests/runtime/dom-properties.test.ts +138 -0
- package/src/tests/runtime/events.test.ts +301 -0
- package/src/tests/runtime/harness.ts +94 -0
- package/src/tests/runtime/pr-352-shapes.test.ts +121 -0
- package/src/tests/runtime/reactive-props.test.ts +81 -0
- package/src/tests/runtime/signals.test.ts +129 -0
- package/src/tests/runtime/whitespace.test.ts +106 -0
- package/src/tests/test-audit.test.ts +549 -0
- package/lib/index.js.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -52,18 +52,28 @@ const App = () => <div>{_$h0}</div>
|
|
|
52
52
|
|
|
53
53
|
## API
|
|
54
54
|
|
|
55
|
-
- **`transformJSX(code
|
|
55
|
+
- **`transformJSX(code, filename?, options?): TransformResult`** -- Transforms JSX source code. Uses the Rust native binary when available, falls back to JS.
|
|
56
|
+
- **`transformJSX_JS(code, filename?, options?): TransformResult`** -- JS-only transform (bypasses native binary). Useful for debugging or cross-backend testing.
|
|
56
57
|
|
|
57
58
|
### Types
|
|
58
59
|
|
|
59
|
-
- **`TransformResult`** -- `{ code: string
|
|
60
|
+
- **`TransformResult`** -- `{ code: string; usesTemplates?: boolean; warnings: CompilerWarning[] }`
|
|
61
|
+
- **`TransformOptions`** -- `{ ssr?: boolean }` -- Set `ssr: true` to skip `_tpl()` template emission for server-side rendering.
|
|
62
|
+
|
|
63
|
+
## Architecture
|
|
64
|
+
|
|
65
|
+
**Dual-backend**: Rust native binary (napi-rs, 3.7-8.9x faster) with automatic JS fallback.
|
|
66
|
+
|
|
67
|
+
- **Rust path** (`native/`): full reactive pass using `oxc_parser`/`oxc_ast` Rust crates directly. Zero JSON serialization, zero JS AST traversal. Single-pass recursive walk with cached analysis.
|
|
68
|
+
- **JS fallback** (`src/jsx.ts`): uses `oxc-parser` (Rust NAPI binding) for parsing + JS reactive pass. Activated automatically when the native binary isn't available.
|
|
69
|
+
- **Auto-detection**: `transformJSX()` loads the native binary via `createRequire` (ESM-safe), falls back per-call with try/catch.
|
|
60
70
|
|
|
61
71
|
## Implementation Notes
|
|
62
72
|
|
|
63
|
-
- Uses the TypeScript parser for AST positions and magic-string for source replacements.
|
|
64
73
|
- Props named `key` and `ref` are never wrapped.
|
|
65
74
|
- Props matching `on[A-Z]*` (event handlers) are never wrapped.
|
|
66
|
-
-
|
|
75
|
+
- Prop-derived variable resolution is fully AST-based — walks `IdentifierReference` nodes, never scans source text.
|
|
76
|
+
- 527 tests: 347 original + 180 cross-backend equivalence tests (Unicode, TypeScript syntax, control flow, string collision resistance).
|
|
67
77
|
|
|
68
78
|
## License
|
|
69
79
|
|
|
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
|
|
|
5386
5386
|
</script>
|
|
5387
5387
|
<script>
|
|
5388
5388
|
/*<!--*/
|
|
5389
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"7624ee76-1","name":"event-names.ts"},{"uid":"7624ee76-3","name":"jsx.ts"},{"uid":"7624ee76-5","name":"project-scanner.ts"},{"uid":"7624ee76-7","name":"react-intercept.ts"},{"uid":"7624ee76-9","name":"pyreon-intercept.ts"},{"uid":"7624ee76-11","name":"test-audit.ts"},{"uid":"7624ee76-13","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"7624ee76-1":{"renderedLength":2941,"gzipLength":1335,"brotliLength":0,"metaUid":"7624ee76-0"},"7624ee76-3":{"renderedLength":43854,"gzipLength":10520,"brotliLength":0,"metaUid":"7624ee76-2"},"7624ee76-5":{"renderedLength":4762,"gzipLength":1730,"brotliLength":0,"metaUid":"7624ee76-4"},"7624ee76-7":{"renderedLength":27698,"gzipLength":6923,"brotliLength":0,"metaUid":"7624ee76-6"},"7624ee76-9":{"renderedLength":20090,"gzipLength":6573,"brotliLength":0,"metaUid":"7624ee76-8"},"7624ee76-11":{"renderedLength":13163,"gzipLength":5058,"brotliLength":0,"metaUid":"7624ee76-10"},"7624ee76-13":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"7624ee76-12"}},"nodeMetas":{"7624ee76-0":{"id":"/src/event-names.ts","moduleParts":{"index.js":"7624ee76-1"},"imported":[],"importedBy":[{"uid":"7624ee76-2"}]},"7624ee76-2":{"id":"/src/jsx.ts","moduleParts":{"index.js":"7624ee76-3"},"imported":[{"uid":"7624ee76-14"},{"uid":"7624ee76-15"},{"uid":"7624ee76-16"},{"uid":"7624ee76-17"},{"uid":"7624ee76-0"}],"importedBy":[{"uid":"7624ee76-12"}]},"7624ee76-4":{"id":"/src/project-scanner.ts","moduleParts":{"index.js":"7624ee76-5"},"imported":[{"uid":"7624ee76-18"},{"uid":"7624ee76-17"}],"importedBy":[{"uid":"7624ee76-12"}]},"7624ee76-6":{"id":"/src/react-intercept.ts","moduleParts":{"index.js":"7624ee76-7"},"imported":[{"uid":"7624ee76-19"}],"importedBy":[{"uid":"7624ee76-12"}]},"7624ee76-8":{"id":"/src/pyreon-intercept.ts","moduleParts":{"index.js":"7624ee76-9"},"imported":[{"uid":"7624ee76-19"}],"importedBy":[{"uid":"7624ee76-12"}]},"7624ee76-10":{"id":"/src/test-audit.ts","moduleParts":{"index.js":"7624ee76-11"},"imported":[{"uid":"7624ee76-18"},{"uid":"7624ee76-17"}],"importedBy":[{"uid":"7624ee76-12"}]},"7624ee76-12":{"id":"/src/index.ts","moduleParts":{"index.js":"7624ee76-13"},"imported":[{"uid":"7624ee76-2"},{"uid":"7624ee76-4"},{"uid":"7624ee76-6"},{"uid":"7624ee76-8"},{"uid":"7624ee76-10"}],"importedBy":[],"isEntry":true},"7624ee76-14":{"id":"oxc-parser","moduleParts":{},"imported":[],"importedBy":[{"uid":"7624ee76-2"}]},"7624ee76-15":{"id":"node:module","moduleParts":{},"imported":[],"importedBy":[{"uid":"7624ee76-2"}]},"7624ee76-16":{"id":"node:url","moduleParts":{},"imported":[],"importedBy":[{"uid":"7624ee76-2"}]},"7624ee76-17":{"id":"node:path","moduleParts":{},"imported":[],"importedBy":[{"uid":"7624ee76-2"},{"uid":"7624ee76-4"},{"uid":"7624ee76-10"}]},"7624ee76-18":{"id":"node:fs","moduleParts":{},"imported":[],"importedBy":[{"uid":"7624ee76-4"},{"uid":"7624ee76-10"}]},"7624ee76-19":{"id":"typescript","moduleParts":{},"imported":[],"importedBy":[{"uid":"7624ee76-6"},{"uid":"7624ee76-8"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|