@pyreon/compiler 0.13.1 → 0.14.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 CHANGED
@@ -52,18 +52,28 @@ const App = () => <div>{_$h0}</div>
52
52
 
53
53
  ## API
54
54
 
55
- - **`transformJSX(code: string, filename?: string): TransformResult`** -- Transforms JSX source code. Returns an object with the transformed `code` string.
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 }` -- The output of a transform pass.
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
- - No extra runtime dependencies beyond TypeScript (already a dev dependency).
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":"75ad5d2d-1","name":"jsx.ts"},{"uid":"75ad5d2d-3","name":"project-scanner.ts"},{"uid":"75ad5d2d-5","name":"react-intercept.ts"},{"uid":"75ad5d2d-7","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"75ad5d2d-1":{"renderedLength":37221,"gzipLength":10092,"brotliLength":0,"metaUid":"75ad5d2d-0"},"75ad5d2d-3":{"renderedLength":4762,"gzipLength":1730,"brotliLength":0,"metaUid":"75ad5d2d-2"},"75ad5d2d-5":{"renderedLength":27692,"gzipLength":6920,"brotliLength":0,"metaUid":"75ad5d2d-4"},"75ad5d2d-7":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"75ad5d2d-6"}},"nodeMetas":{"75ad5d2d-0":{"id":"/src/jsx.ts","moduleParts":{"index.js":"75ad5d2d-1"},"imported":[{"uid":"75ad5d2d-8"}],"importedBy":[{"uid":"75ad5d2d-6"}]},"75ad5d2d-2":{"id":"/src/project-scanner.ts","moduleParts":{"index.js":"75ad5d2d-3"},"imported":[{"uid":"75ad5d2d-9"},{"uid":"75ad5d2d-10"}],"importedBy":[{"uid":"75ad5d2d-6"}]},"75ad5d2d-4":{"id":"/src/react-intercept.ts","moduleParts":{"index.js":"75ad5d2d-5"},"imported":[{"uid":"75ad5d2d-8"}],"importedBy":[{"uid":"75ad5d2d-6"}]},"75ad5d2d-6":{"id":"/src/index.ts","moduleParts":{"index.js":"75ad5d2d-7"},"imported":[{"uid":"75ad5d2d-0"},{"uid":"75ad5d2d-2"},{"uid":"75ad5d2d-4"}],"importedBy":[],"isEntry":true},"75ad5d2d-8":{"id":"typescript","moduleParts":{},"imported":[],"importedBy":[{"uid":"75ad5d2d-0"},{"uid":"75ad5d2d-4"}]},"75ad5d2d-9":{"id":"node:fs","moduleParts":{},"imported":[],"importedBy":[{"uid":"75ad5d2d-2"}]},"75ad5d2d-10":{"id":"node:path","moduleParts":{},"imported":[],"importedBy":[{"uid":"75ad5d2d-2"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5389
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"106fae60-1","name":"jsx.ts"},{"uid":"106fae60-3","name":"project-scanner.ts"},{"uid":"106fae60-5","name":"react-intercept.ts"},{"uid":"106fae60-7","name":"pyreon-intercept.ts"},{"uid":"106fae60-9","name":"test-audit.ts"},{"uid":"106fae60-11","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"106fae60-1":{"renderedLength":42528,"gzipLength":10166,"brotliLength":0,"metaUid":"106fae60-0"},"106fae60-3":{"renderedLength":4762,"gzipLength":1730,"brotliLength":0,"metaUid":"106fae60-2"},"106fae60-5":{"renderedLength":27698,"gzipLength":6923,"brotliLength":0,"metaUid":"106fae60-4"},"106fae60-7":{"renderedLength":12664,"gzipLength":4204,"brotliLength":0,"metaUid":"106fae60-6"},"106fae60-9":{"renderedLength":13163,"gzipLength":5058,"brotliLength":0,"metaUid":"106fae60-8"},"106fae60-11":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"106fae60-10"}},"nodeMetas":{"106fae60-0":{"id":"/src/jsx.ts","moduleParts":{"index.js":"106fae60-1"},"imported":[{"uid":"106fae60-12"},{"uid":"106fae60-13"},{"uid":"106fae60-14"},{"uid":"106fae60-15"}],"importedBy":[{"uid":"106fae60-10"}]},"106fae60-2":{"id":"/src/project-scanner.ts","moduleParts":{"index.js":"106fae60-3"},"imported":[{"uid":"106fae60-16"},{"uid":"106fae60-15"}],"importedBy":[{"uid":"106fae60-10"}]},"106fae60-4":{"id":"/src/react-intercept.ts","moduleParts":{"index.js":"106fae60-5"},"imported":[{"uid":"106fae60-17"}],"importedBy":[{"uid":"106fae60-10"}]},"106fae60-6":{"id":"/src/pyreon-intercept.ts","moduleParts":{"index.js":"106fae60-7"},"imported":[{"uid":"106fae60-17"}],"importedBy":[{"uid":"106fae60-10"}]},"106fae60-8":{"id":"/src/test-audit.ts","moduleParts":{"index.js":"106fae60-9"},"imported":[{"uid":"106fae60-16"},{"uid":"106fae60-15"}],"importedBy":[{"uid":"106fae60-10"}]},"106fae60-10":{"id":"/src/index.ts","moduleParts":{"index.js":"106fae60-11"},"imported":[{"uid":"106fae60-0"},{"uid":"106fae60-2"},{"uid":"106fae60-4"},{"uid":"106fae60-6"},{"uid":"106fae60-8"}],"importedBy":[],"isEntry":true},"106fae60-12":{"id":"oxc-parser","moduleParts":{},"imported":[],"importedBy":[{"uid":"106fae60-0"}]},"106fae60-13":{"id":"node:module","moduleParts":{},"imported":[],"importedBy":[{"uid":"106fae60-0"}]},"106fae60-14":{"id":"node:url","moduleParts":{},"imported":[],"importedBy":[{"uid":"106fae60-0"}]},"106fae60-15":{"id":"node:path","moduleParts":{},"imported":[],"importedBy":[{"uid":"106fae60-0"},{"uid":"106fae60-2"},{"uid":"106fae60-8"}]},"106fae60-16":{"id":"node:fs","moduleParts":{},"imported":[],"importedBy":[{"uid":"106fae60-2"},{"uid":"106fae60-8"}]},"106fae60-17":{"id":"typescript","moduleParts":{},"imported":[],"importedBy":[{"uid":"106fae60-4"},{"uid":"106fae60-6"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
5390
5390
 
5391
5391
  const run = () => {
5392
5392
  const width = window.innerWidth;