@vertz/ui-compiler 0.2.3 → 1.0.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
@@ -1,19 +1,3 @@
1
1
  # @vertz/ui-compiler
2
2
 
3
- > **Internal package** — You don't use this directly. It powers the reactive compiler behind `@vertz/ui`.
4
-
5
- The UI compiler transforms `@vertz/ui` components at build time — converting `let` declarations into signals, wrapping derived `const` values in `computed()`, inserting `.value` accessors, and generating getter-based props for cross-component reactivity.
6
-
7
- ## Who uses this
8
-
9
- - **`@vertz/ui-server`** — The Bun plugin loads this compiler to transform `.tsx` files during development and SSR.
10
- - **Framework contributors** — If you're working on the compiler itself, see the source in `src/` for architecture details.
11
-
12
- ## Related Packages
13
-
14
- - [`@vertz/ui`](../ui) — The UI framework this compiler targets
15
- - [`@vertz/ui-server`](../ui-server) — Dev server and SSR runtime that invokes the compiler
16
-
17
- ## License
18
-
19
- MIT
3
+ > ⚠️ **Internal package** — This package is an implementation detail of the Vertz framework. It is published for use by other `@vertz/*` packages. No API stability is guaranteed between versions.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,4 @@
1
1
  import { SourceFile } from "ts-morph";
2
- /** Options for the compile() function. */
3
- interface CompileOptions {
4
- /** Filename for source map generation. Defaults to 'input.tsx'. */
5
- filename?: string;
6
- /** Compilation target. 'dom' uses @vertz/ui/internals, 'tui' uses @vertz/tui/internals. */
7
- target?: "dom" | "tui";
8
- }
9
2
  /** Severity of a compiler diagnostic. */
10
3
  type DiagnosticSeverity = "error" | "warning" | "info";
11
4
  /** A diagnostic message emitted during compilation. */
@@ -60,14 +53,6 @@ interface VariableInfo {
60
53
  * the Set on deserialization.
61
54
  */
62
55
  signalProperties?: Set<string>;
63
- /** Plain (non-signal) properties on this variable. */
64
- plainProperties?: Set<string>;
65
- /** Per-field signal properties (e.g., form().title.error). */
66
- fieldSignalProperties?: Set<string>;
67
- /** Synthetic variable name this binding was destructured from (e.g., `__query_0`). */
68
- destructuredFrom?: string;
69
- /** Whether this variable is a reactive source (e.g., useContext result). */
70
- isReactiveSource?: boolean;
71
56
  }
72
57
  /** Information about a detected component function. */
73
58
  interface ComponentInfo {
@@ -151,16 +136,13 @@ declare class CSSAnalyzer {
151
136
  private classifyArgument;
152
137
  /** Check if a nested object (for complex selectors) is fully static. */
153
138
  private isStaticNestedObject;
154
- /** Check if a node is a static raw declaration: { property: '...', value: '...' } */
155
- private isStaticRawDeclaration;
156
139
  /** Extract block names from a static css() argument. */
157
140
  private extractBlockNames;
158
141
  }
159
142
  import { SourceFile as SourceFile3 } from "ts-morph";
160
143
  /**
161
144
  * Map each JSX expression/attribute to its dependencies.
162
- * Classify as reactive or static based on whether any dependency is a signal,
163
- * computed, or a signal API property access (e.g., query().data, form().submitting).
145
+ * Classify as reactive or static based on whether any dependency is a signal or computed.
164
146
  */
165
147
  declare class JsxAnalyzer {
166
148
  analyze(sourceFile: SourceFile3, component: ComponentInfo, variables: VariableInfo[]): JsxExpressionInfo[];
@@ -195,7 +177,7 @@ declare class ReactivityAnalyzer {
195
177
  * 8. JSX transform (includes prop transform) →
196
178
  * 9. Diagnostics → 10. Add imports → 11. Return { code, map, diagnostics }
197
179
  */
198
- declare function compile(source: string, optionsOrFilename?: CompileOptions | string): CompileOutput;
180
+ declare function compile(source: string, filename?: string): CompileOutput;
199
181
  /** Result of extracting CSS from a source file. */
200
182
  interface CSSExtractionResult {
201
183
  /** The extracted CSS rules as a string. */
@@ -343,45 +325,17 @@ import { SourceFile as SourceFile8 } from "ts-morph";
343
325
  declare class PropsDestructuringDiagnostics {
344
326
  analyze(sourceFile: SourceFile8, components: ComponentInfo[]): CompilerDiagnostic[];
345
327
  }
346
- import { SourceFile as SourceFile9 } from "ts-morph";
347
- /**
348
- * Detect browser-only API usage at component top level that would crash during SSR.
349
- *
350
- * Flags globals like `localStorage`, `navigator`, observer constructors, and
351
- * browser-only `document` properties when used outside of callbacks (arrow
352
- * functions, function expressions). Usage inside `onMount()`, event handlers,
353
- * or any nested function is safe and not flagged.
354
- */
355
- declare class SSRSafetyDiagnostics {
356
- analyze(sourceFile: SourceFile9, component: ComponentInfo): CompilerDiagnostic[];
357
- }
358
- import { BunPlugin } from "bun";
359
- /** Options for the Vertz library compilation plugin. */
360
- interface VertzLibraryPluginOptions {
361
- /** File filter regex. Defaults to /\.tsx$/. */
362
- filter?: RegExp;
363
- /** Compilation target. Defaults to 'dom'. */
364
- target?: "dom" | "tui";
365
- }
366
- /**
367
- * Creates a Bun plugin for compiling Vertz library packages.
368
- *
369
- * Runs hydration transform + compile on .tsx files during bunup build.
370
- * CSS extraction is intentionally skipped — CSS hashing is path-dependent
371
- * and must be done by the consuming app's build pipeline.
372
- */
373
- declare function createVertzLibraryPlugin(options?: VertzLibraryPluginOptions): BunPlugin;
374
328
  import MagicString from "magic-string";
375
- import { SourceFile as SourceFile10 } from "ts-morph";
329
+ import { SourceFile as SourceFile9 } from "ts-morph";
376
330
  /**
377
331
  * Transform `const x = expr` → `const x = computed(() => expr)` when classified as computed.
378
332
  * Also handles destructuring: `const { a, b } = expr` → individual computed declarations.
379
333
  */
380
334
  declare class ComputedTransformer {
381
- transform(source: MagicString, sourceFile: SourceFile10, component: ComponentInfo, variables: VariableInfo[]): void;
335
+ transform(source: MagicString, sourceFile: SourceFile9, component: ComponentInfo, variables: VariableInfo[]): void;
382
336
  }
383
337
  import MagicString2 from "magic-string";
384
- import { SourceFile as SourceFile11 } from "ts-morph";
338
+ import { SourceFile as SourceFile10 } from "ts-morph";
385
339
  /** Result of CSS transformation. */
386
340
  interface CSSTransformResult {
387
341
  /** Extracted CSS rules. */
@@ -393,14 +347,14 @@ interface CSSTransformResult {
393
347
  * Transform static css() calls in the source.
394
348
  */
395
349
  declare class CSSTransformer {
396
- transform(s: MagicString2, sourceFile: SourceFile11, cssCalls: CSSCallInfo[], filePath: string): CSSTransformResult;
350
+ transform(s: MagicString2, sourceFile: SourceFile10, cssCalls: CSSCallInfo[], filePath: string): CSSTransformResult;
397
351
  /** Process a static css() call to extract CSS and generate class names. */
398
352
  private processStaticCall;
399
353
  /** Build the replacement JS expression: { card: '_a1b2c3d4', title: '_e5f6g7h8' } */
400
354
  private buildReplacement;
401
355
  }
402
356
  import MagicString3 from "magic-string";
403
- import { SourceFile as SourceFile12 } from "ts-morph";
357
+ import { SourceFile as SourceFile11 } from "ts-morph";
404
358
  /**
405
359
  * Marks interactive components with `data-v-id` hydration markers.
406
360
  *
@@ -412,7 +366,7 @@ import { SourceFile as SourceFile12 } from "ts-morph";
412
366
  * with `data-v-id="ComponentName"`.
413
367
  */
414
368
  declare class HydrationTransformer {
415
- transform(s: MagicString3, sourceFile: SourceFile12): void;
369
+ transform(s: MagicString3, sourceFile: SourceFile11): void;
416
370
  /**
417
371
  * Determine whether a component is interactive by checking for `let`
418
372
  * declarations in the component body.
@@ -427,7 +381,7 @@ declare class HydrationTransformer {
427
381
  private _injectAttribute;
428
382
  }
429
383
  import MagicString4 from "magic-string";
430
- import { SourceFile as SourceFile13 } from "ts-morph";
384
+ import { SourceFile as SourceFile12 } from "ts-morph";
431
385
  /**
432
386
  * Transform JSX into DOM helper calls.
433
387
  * Reactive expressions are wrapped in functions, static expressions are passed directly.
@@ -436,7 +390,7 @@ import { SourceFile as SourceFile13 } from "ts-morph";
436
390
  * so that it picks up .value transforms from the signal/computed transformers.
437
391
  */
438
392
  declare class JsxTransformer {
439
- transform(source: MagicString4, sourceFile: SourceFile13, component: ComponentInfo, variables: VariableInfo[], jsxExpressions: JsxExpressionInfo[]): void;
393
+ transform(source: MagicString4, sourceFile: SourceFile12, component: ComponentInfo, variables: VariableInfo[], jsxExpressions: JsxExpressionInfo[]): void;
440
394
  /**
441
395
  * Walk the full function body and transform every top-level JSX node.
442
396
  * "Top-level" means JSX that isn't nested inside other JSX (children are
@@ -465,7 +419,7 @@ declare class MutationTransformer {
465
419
  private _transformObjectAssign;
466
420
  }
467
421
  import MagicString6 from "magic-string";
468
- import { Node, SourceFile as SourceFile14 } from "ts-morph";
422
+ import { Node, SourceFile as SourceFile13 } from "ts-morph";
469
423
  /**
470
424
  * Transform component props: reactive → getter, static → plain value.
471
425
  *
@@ -474,12 +428,12 @@ import { Node, SourceFile as SourceFile14 } from "ts-morph";
474
428
  * cases where prop transformation is needed independently.
475
429
  */
476
430
  declare class PropTransformer {
477
- transform(_source: MagicString6, _sourceFile: SourceFile14, _component: ComponentInfo, _variables: VariableInfo[], _jsxExpressions: JsxExpressionInfo[]): void;
431
+ transform(_source: MagicString6, _sourceFile: SourceFile13, _component: ComponentInfo, _variables: VariableInfo[], _jsxExpressions: JsxExpressionInfo[]): void;
478
432
  /** Build a props object string for a component call. */
479
433
  buildPropsObject(attrs: Node[], jsxMap: Map<number, JsxExpressionInfo>): string;
480
434
  }
481
435
  import MagicString7 from "magic-string";
482
- import { SourceFile as SourceFile15 } from "ts-morph";
436
+ import { SourceFile as SourceFile14 } from "ts-morph";
483
437
  /**
484
438
  * Transform `let x = val` → `const x = signal(val)` and all reads/writes
485
439
  * for variables classified as signals.
@@ -488,7 +442,7 @@ import { SourceFile as SourceFile15 } from "ts-morph";
488
442
  * expressions are handled by the MutationTransformer instead.
489
443
  */
490
444
  declare class SignalTransformer {
491
- transform(source: MagicString7, sourceFile: SourceFile15, component: ComponentInfo, variables: VariableInfo[], mutationRanges?: Array<{
445
+ transform(source: MagicString7, sourceFile: SourceFile14, component: ComponentInfo, variables: VariableInfo[], mutationRanges?: Array<{
492
446
  start: number;
493
447
  end: number;
494
448
  }>): void;
@@ -561,4 +515,49 @@ interface ThemeTypeInput {
561
515
  * @returns TypeScript source string with exported ThemeTokens type.
562
516
  */
563
517
  declare function generateThemeTypes(input: ThemeTypeInput): string;
564
- export { generateThemeTypes, generateCSSProperties, createVertzLibraryPlugin, compile, VertzLibraryPluginOptions, VariableInfo, ThemeTypeInput, SignalTransformer, SSRSafetyDiagnostics, RouteCSSManifest, ReactivityKind, ReactivityAnalyzer, PropsDestructuringDiagnostics, PropTransformer, MutationTransformer, MutationKind, MutationInfo, MutationDiagnostics, MutationAnalyzer, JsxTransformer, JsxExpressionInfo, JsxAnalyzer, HydrationTransformer, DiagnosticSeverity, DeadCSSEliminator, ComputedTransformer, ComponentInfo, ComponentAnalyzer, CompilerDiagnostic, CompileOutput, CompileOptions, CSSTransformer, CSSTransformResult, CSSPropertiesInput, CSSHMRUpdateResult, CSSHMRHandler, CSSExtractor, CSSExtractionResult, CSSDiagnostics, CSSCodeSplitter, CSSCallKind, CSSCallInfo, CSSAnalyzer };
518
+ import { Plugin } from "vite";
519
+ /** SSR configuration options. */
520
+ interface SSROptions {
521
+ /**
522
+ * Path to the root component. Auto-detected from index.html if omitted.
523
+ * @default auto-detect from <script type="module" src="..."> in index.html
524
+ */
525
+ entry?: string;
526
+ /**
527
+ * Streaming SSR vs buffered.
528
+ * @default 'buffered'
529
+ */
530
+ mode?: "buffered" | "streaming";
531
+ /**
532
+ * Port override for the dev server (uses Vite's default if unset).
533
+ */
534
+ port?: number;
535
+ }
536
+ /** Options for the Vertz Vite plugin. */
537
+ interface VertzPluginOptions {
538
+ /** Glob patterns for component files. Defaults to tsx and jsx. */
539
+ include?: string[];
540
+ /** Glob patterns to exclude. */
541
+ exclude?: string[];
542
+ /** Enable CSS extraction in production. Defaults to true. */
543
+ cssExtraction?: boolean;
544
+ /** Route-to-file mapping for CSS code splitting (production only). */
545
+ routeMap?: Map<string, string[]>;
546
+ /**
547
+ * Enable SSR in development mode.
548
+ * When true, `vite dev` serves SSR'd HTML automatically.
549
+ * When an object, provides SSR configuration options.
550
+ */
551
+ ssr?: boolean | SSROptions;
552
+ }
553
+ /**
554
+ * Vite plugin that transforms tsx/jsx files using the vertz/ui compiler.
555
+ *
556
+ * Chains all compiler passes: reactive transforms, component transforms,
557
+ * hydration markers, and CSS extraction. In dev mode, provides HMR for
558
+ * both component code and CSS changes. In production, extracts CSS to
559
+ * virtual modules and performs dead CSS elimination and route-level
560
+ * code splitting.
561
+ */
562
+ declare function vertzPlugin(options?: VertzPluginOptions): Plugin;
563
+ export { generateThemeTypes, generateCSSProperties, vertzPlugin as default, compile, VertzPluginOptions, VariableInfo, ThemeTypeInput, SignalTransformer, RouteCSSManifest, ReactivityKind, ReactivityAnalyzer, PropsDestructuringDiagnostics, PropTransformer, MutationTransformer, MutationKind, MutationInfo, MutationDiagnostics, MutationAnalyzer, JsxTransformer, JsxExpressionInfo, JsxAnalyzer, HydrationTransformer, DiagnosticSeverity, DeadCSSEliminator, ComputedTransformer, ComponentInfo, ComponentAnalyzer, CompilerDiagnostic, CompileOutput, CSSTransformer, CSSTransformResult, CSSPropertiesInput, CSSHMRUpdateResult, CSSHMRHandler, CSSExtractor, CSSExtractionResult, CSSDiagnostics, CSSCodeSplitter, CSSCallKind, CSSCallInfo, CSSAnalyzer };