@pyreon/compiler 0.19.0 → 0.21.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/lib/analysis/index.js.html +1 -1
- package/lib/index.js +418 -18
- package/lib/types/index.d.ts +92 -1
- package/package.json +13 -12
- package/src/index.ts +2 -1
- package/src/jsx.ts +669 -17
- package/src/tests/backend-parity-r7-r9.test.ts +91 -0
- package/src/tests/backend-prop-derived-callback-divergence.test.ts +74 -0
- package/src/tests/collapse-bail-census.test.ts +245 -0
- package/src/tests/collapse-key-source-hygiene.test.ts +88 -0
- package/src/tests/element-valued-const-child.test.ts +61 -0
- package/src/tests/falsy-child-characterization.test.ts +48 -0
- package/src/tests/malformed-input-resilience.test.ts +50 -0
- package/src/tests/partial-collapse-detector.test.ts +121 -0
- package/src/tests/partial-collapse-emit.test.ts +104 -0
- package/src/tests/partial-collapse-robustness.test.ts +53 -0
- package/src/tests/prop-derived-shadow.test.ts +96 -0
- package/src/tests/pure-call-reactive-args.test.ts +50 -0
- package/src/tests/r13-callback-stmt-equivalence.test.ts +58 -0
- package/src/tests/r14-ssr-mode-parity.test.ts +51 -0
- package/src/tests/r15-elemconst-propderived.test.ts +47 -0
- package/src/tests/r19-defer-inline-robust.test.ts +54 -0
- package/src/tests/r20-backend-equivalence-sweep.test.ts +50 -0
- package/src/tests/rocketstyle-collapse.test.ts +208 -0
- package/src/tests/signal-autocall-shadow.test.ts +86 -0
- package/src/tests/sourcemap-fidelity.test.ts +77 -0
- package/src/tests/static-text-baking.test.ts +64 -0
- package/src/tests/transform-state-isolation.test.ts +49 -0
package/lib/types/index.d.ts
CHANGED
|
@@ -84,6 +84,22 @@ declare function transformDeferInline(code: string, filename?: string): DeferInl
|
|
|
84
84
|
*
|
|
85
85
|
* Implementation: Rust native binary (napi-rs) when available, JS fallback via oxc-parser.
|
|
86
86
|
*/
|
|
87
|
+
/**
|
|
88
|
+
* V3 source map shape returned by the JS backend. Structurally exactly
|
|
89
|
+
* magic-string's `SourceMap` (a valid V3 map plus `.toString()`/`.toUrl()`),
|
|
90
|
+
* declared locally so `TransformResult` carries no hard type dependency on
|
|
91
|
+
* magic-string's exported types.
|
|
92
|
+
*/
|
|
93
|
+
interface GeneratedSourceMap {
|
|
94
|
+
version: number;
|
|
95
|
+
file?: string;
|
|
96
|
+
sources: string[];
|
|
97
|
+
sourcesContent?: (string | null)[];
|
|
98
|
+
names: string[];
|
|
99
|
+
mappings: string;
|
|
100
|
+
toString(): string;
|
|
101
|
+
toUrl(): string;
|
|
102
|
+
}
|
|
87
103
|
interface CompilerWarning {
|
|
88
104
|
/** Warning message */
|
|
89
105
|
message: string;
|
|
@@ -129,6 +145,15 @@ interface TransformResult {
|
|
|
129
145
|
usesTemplates?: boolean;
|
|
130
146
|
/** Compiler warnings for common mistakes */
|
|
131
147
|
warnings: CompilerWarning[];
|
|
148
|
+
/**
|
|
149
|
+
* Source map (V3) for the transform — present on the JS backend whenever a
|
|
150
|
+
* transformation actually occurred. `undefined` when nothing changed (the
|
|
151
|
+
* emitted code is byte-identical to the input, so no remapping is needed)
|
|
152
|
+
* and on the native backend (a Rust-side map is a scoped follow-up). The
|
|
153
|
+
* object is magic-string's `SourceMap`: it is a valid V3 map AND has
|
|
154
|
+
* `.toString()` / `.toUrl()`, so Vite/Rollup consume it directly.
|
|
155
|
+
*/
|
|
156
|
+
map?: GeneratedSourceMap;
|
|
132
157
|
/**
|
|
133
158
|
* Reactivity-lens spans — populated ONLY when `TransformOptions.reactivityLens`
|
|
134
159
|
* is `true`. Additive: codegen output is byte-identical whether or not this is
|
|
@@ -165,7 +190,73 @@ interface TransformOptions {
|
|
|
165
190
|
* codegen; it never runs a second analysis pass.
|
|
166
191
|
*/
|
|
167
192
|
reactivityLens?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* P0 — compile-time rocketstyle wrapper collapse. OFF unless the Vite
|
|
195
|
+
* plugin supplies this (opt-in `pyreon({ collapse: true })`). The plugin
|
|
196
|
+
* scans the module's imports for collapsible component candidates,
|
|
197
|
+
* SSR-resolves each literal-prop call site once (real component, light
|
|
198
|
+
* + dark), and passes the resolved `sites` map keyed by
|
|
199
|
+
* {@link rocketstyleCollapseKey}. The compiler only DETECTS the
|
|
200
|
+
* collapsible shape (bail catalogue — every dimension prop a string
|
|
201
|
+
* literal, no spread, static-text children) and EMITS the collapsed
|
|
202
|
+
* `_rsCollapse` call + the once-per-module rule injection; it never
|
|
203
|
+
* runs the rocketstyle chain itself (RFC decision 2).
|
|
204
|
+
*/
|
|
205
|
+
collapseRocketstyle?: {
|
|
206
|
+
/** Component names imported into this module that MAY collapse. */candidates: Set<string>; /** key → resolved emission data (absent ⇒ bail, keep normal mount). */
|
|
207
|
+
sites: Map<string, {
|
|
208
|
+
templateHtml: string;
|
|
209
|
+
lightClass: string;
|
|
210
|
+
darkClass: string;
|
|
211
|
+
rules: string[];
|
|
212
|
+
ruleKey: string;
|
|
213
|
+
}>; /** Live mode accessor to thread for dual-emit (RFC decision 1). */
|
|
214
|
+
mode: {
|
|
215
|
+
name: string;
|
|
216
|
+
source: string;
|
|
217
|
+
}; /** Module specifier for `_rsCollapse`. Default `@pyreon/runtime-dom`. */
|
|
218
|
+
runtimeDomSource?: string; /** Module specifier for the styler `sheet`. Default `@pyreon/styler`. */
|
|
219
|
+
stylerSource?: string;
|
|
220
|
+
};
|
|
168
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Canonical key for a collapsible rocketstyle call site. The Vite plugin
|
|
224
|
+
* computes this when it resolves a site; the compiler recomputes the
|
|
225
|
+
* IDENTICAL key from the JSX node to look the resolution up. Stable
|
|
226
|
+
* ordering of props so attribute order in source doesn't change the key.
|
|
227
|
+
*/
|
|
228
|
+
declare function rocketstyleCollapseKey(componentName: string, props: Record<string, string>, childrenText: string): string;
|
|
229
|
+
/**
|
|
230
|
+
* A collapsible call site found by {@link scanCollapsibleSites}.
|
|
231
|
+
* `componentName` is the LOCAL JSX tag (post-import-alias) — it MUST be
|
|
232
|
+
* what `rocketstyleCollapseKey` is computed from on BOTH sides so the
|
|
233
|
+
* plugin's resolved `sites` map keys match the compiler's lookups.
|
|
234
|
+
*/
|
|
235
|
+
interface CollapsibleSite {
|
|
236
|
+
/** Local JSX tag name (the key + the compiler's detection use this). */
|
|
237
|
+
componentName: string;
|
|
238
|
+
/** Module specifier the component was imported from (for the resolver). */
|
|
239
|
+
source: string;
|
|
240
|
+
/** Imported binding name at `source` (may differ from local if aliased). */
|
|
241
|
+
importedName: string;
|
|
242
|
+
/** Literal string-valued props (the only shape the slice collapses). */
|
|
243
|
+
props: Record<string, string>;
|
|
244
|
+
/** Static text children (trimmed; empty ⇒ none). */
|
|
245
|
+
childrenText: string;
|
|
246
|
+
/** `rocketstyleCollapseKey(componentName, props, childrenText)`. */
|
|
247
|
+
key: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Pure detector — finds every collapsible rocketstyle call site in a
|
|
251
|
+
* module. Used by `@pyreon/vite-plugin` to know which (component, props,
|
|
252
|
+
* text) tuples to SSR-resolve. The bail catalogue here MUST stay
|
|
253
|
+
* byte-identical to `tryRocketstyleCollapse`'s (RFC decision 3): a
|
|
254
|
+
* candidate PascalCase tag whose import source is in `collapsibleSources`,
|
|
255
|
+
* every attr a plain string literal (no spread, no `{expr}`, no boolean
|
|
256
|
+
* attr), children empty or static text only. A consistency test asserts
|
|
257
|
+
* the keys this produces equal the keys the compiler looks up.
|
|
258
|
+
*/
|
|
259
|
+
declare function scanCollapsibleSites(code: string, filename: string, collapsibleSources: Set<string>): CollapsibleSite[];
|
|
169
260
|
declare function transformJSX(code: string, filename?: string, options?: TransformOptions): TransformResult;
|
|
170
261
|
/** JS fallback implementation — used when the native binary isn't available. */
|
|
171
262
|
declare function transformJSX_JS(code: string, filename?: string, options?: TransformOptions): TransformResult;
|
|
@@ -551,5 +642,5 @@ interface SsgAuditFormatOptions {
|
|
|
551
642
|
}
|
|
552
643
|
declare function formatSsgAudit(result: SsgAuditResult, _options?: SsgAuditFormatOptions): string;
|
|
553
644
|
//#endregion
|
|
554
|
-
export { type AnalyzeReactivityResult, type AuditFormatOptions, type AuditRisk, type CompilerWarning, type ComponentInfo, type DeferInlineResult, type DeferInlineWarning, type ErrorDiagnosis, type IslandAuditFormatOptions, type IslandAuditResult, type IslandFinding, type IslandFindingCode, type IslandInfo, type IslandLocation, type MigrationChange, type MigrationResult, type ProjectContext, type PyreonDiagnostic, type PyreonDiagnosticCode, type ReactDiagnostic, type ReactDiagnosticCode, type ReactivityFinding, type ReactivityFindingKind, type ReactivityKind, type ReactivitySpan, type RouteInfo, type SsgAuditFormatOptions, type SsgAuditResult, type SsgFinding, type SsgFindingCode, type SsgLocation, type TestAuditEntry, type TestAuditResult, type TransformResult, analyzeReactivity, auditIslands, auditSsg, auditTestEnvironment, detectPyreonPatterns, detectReactPatterns, diagnoseError, formatIslandAudit, formatReactivityLens, formatSsgAudit, formatTestAudit, generateContext, hasPyreonPatterns, hasReactPatterns, migrateReactCode, transformDeferInline, transformJSX, transformJSX_JS };
|
|
645
|
+
export { type AnalyzeReactivityResult, type AuditFormatOptions, type AuditRisk, type CollapsibleSite, type CompilerWarning, type ComponentInfo, type DeferInlineResult, type DeferInlineWarning, type ErrorDiagnosis, type IslandAuditFormatOptions, type IslandAuditResult, type IslandFinding, type IslandFindingCode, type IslandInfo, type IslandLocation, type MigrationChange, type MigrationResult, type ProjectContext, type PyreonDiagnostic, type PyreonDiagnosticCode, type ReactDiagnostic, type ReactDiagnosticCode, type ReactivityFinding, type ReactivityFindingKind, type ReactivityKind, type ReactivitySpan, type RouteInfo, type SsgAuditFormatOptions, type SsgAuditResult, type SsgFinding, type SsgFindingCode, type SsgLocation, type TestAuditEntry, type TestAuditResult, type TransformResult, analyzeReactivity, auditIslands, auditSsg, auditTestEnvironment, detectPyreonPatterns, detectReactPatterns, diagnoseError, formatIslandAudit, formatReactivityLens, formatSsgAudit, formatTestAudit, generateContext, hasPyreonPatterns, hasReactPatterns, migrateReactCode, rocketstyleCollapseKey, scanCollapsibleSites, transformDeferInline, transformJSX, transformJSX_JS };
|
|
555
646
|
//# sourceMappingURL=index2.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Template and JSX compiler for Pyreon",
|
|
5
5
|
"homepage": "https://github.com/pyreon/pyreon/tree/main/packages/compiler#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -44,23 +44,24 @@
|
|
|
44
44
|
"prepublishOnly": "bun run build"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
+
"magic-string": "^0.30.21",
|
|
47
48
|
"oxc-parser": "^0.129.0"
|
|
48
49
|
},
|
|
49
50
|
"optionalDependencies": {
|
|
50
|
-
"@pyreon/compiler-darwin-arm64": "^0.
|
|
51
|
-
"@pyreon/compiler-darwin-x64": "^0.
|
|
52
|
-
"@pyreon/compiler-linux-arm64-gnu": "^0.
|
|
53
|
-
"@pyreon/compiler-linux-arm64-musl": "^0.
|
|
54
|
-
"@pyreon/compiler-linux-x64-gnu": "^0.
|
|
55
|
-
"@pyreon/compiler-linux-x64-musl": "^0.
|
|
56
|
-
"@pyreon/compiler-win32-x64-msvc": "^0.
|
|
51
|
+
"@pyreon/compiler-darwin-arm64": "^0.21.0",
|
|
52
|
+
"@pyreon/compiler-darwin-x64": "^0.21.0",
|
|
53
|
+
"@pyreon/compiler-linux-arm64-gnu": "^0.21.0",
|
|
54
|
+
"@pyreon/compiler-linux-arm64-musl": "^0.21.0",
|
|
55
|
+
"@pyreon/compiler-linux-x64-gnu": "^0.21.0",
|
|
56
|
+
"@pyreon/compiler-linux-x64-musl": "^0.21.0",
|
|
57
|
+
"@pyreon/compiler-win32-x64-msvc": "^0.21.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@pyreon/core": "^0.
|
|
60
|
+
"@pyreon/core": "^0.21.0",
|
|
60
61
|
"@pyreon/manifest": "0.13.1",
|
|
61
|
-
"@pyreon/reactivity": "^0.
|
|
62
|
-
"@pyreon/runtime-dom": "^0.
|
|
63
|
-
"@pyreon/test-utils": "^0.13.
|
|
62
|
+
"@pyreon/reactivity": "^0.21.0",
|
|
63
|
+
"@pyreon/runtime-dom": "^0.21.0",
|
|
64
|
+
"@pyreon/test-utils": "^0.13.8",
|
|
64
65
|
"happy-dom": "^20.8.3"
|
|
65
66
|
},
|
|
66
67
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,8 @@ export type {
|
|
|
8
8
|
ReactivitySpan,
|
|
9
9
|
TransformResult,
|
|
10
10
|
} from './jsx'
|
|
11
|
-
export { transformJSX, transformJSX_JS } from './jsx'
|
|
11
|
+
export { transformJSX, transformJSX_JS, rocketstyleCollapseKey, scanCollapsibleSites } from './jsx'
|
|
12
|
+
export type { CollapsibleSite } from './jsx'
|
|
12
13
|
export type {
|
|
13
14
|
AnalyzeReactivityResult,
|
|
14
15
|
ReactivityFinding,
|