prev-cli 0.24.20 → 0.25.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.
Files changed (150) hide show
  1. package/dist/cli.js +2006 -1714
  2. package/dist/previews/components/cart-item/index.d.ts +5 -0
  3. package/dist/previews/components/price-tag/index.d.ts +6 -0
  4. package/dist/previews/screens/cart/empty.d.ts +1 -0
  5. package/dist/previews/screens/cart/index.d.ts +1 -0
  6. package/dist/previews/screens/payment/error.d.ts +1 -0
  7. package/dist/previews/screens/payment/index.d.ts +1 -0
  8. package/dist/previews/screens/payment/processing.d.ts +1 -0
  9. package/dist/previews/screens/receipt/index.d.ts +1 -0
  10. package/dist/previews/shared/data.d.ts +30 -0
  11. package/dist/src/content/config-parser.d.ts +30 -0
  12. package/dist/src/content/flow-verifier.d.ts +21 -0
  13. package/dist/src/content/preview-types.d.ts +288 -0
  14. package/dist/{vite → src/content}/previews.d.ts +3 -11
  15. package/dist/{preview-runtime → src/preview-runtime}/build-optimized.d.ts +2 -0
  16. package/dist/{preview-runtime → src/preview-runtime}/build.d.ts +1 -1
  17. package/dist/src/preview-runtime/region-bridge.d.ts +1 -0
  18. package/dist/{preview-runtime → src/preview-runtime}/types.d.ts +18 -0
  19. package/dist/src/preview-runtime/vendors.d.ts +11 -0
  20. package/dist/{renderers → src/renderers}/index.d.ts +1 -1
  21. package/dist/{renderers → src/renderers}/types.d.ts +3 -31
  22. package/dist/src/server/build.d.ts +6 -0
  23. package/dist/src/server/dev.d.ts +13 -0
  24. package/dist/src/server/plugins/aliases.d.ts +5 -0
  25. package/dist/src/server/plugins/mdx.d.ts +5 -0
  26. package/dist/src/server/plugins/virtual-modules.d.ts +8 -0
  27. package/dist/src/server/preview.d.ts +10 -0
  28. package/dist/src/server/routes/component-bundle.d.ts +1 -0
  29. package/dist/src/server/routes/jsx-bundle.d.ts +3 -0
  30. package/dist/src/server/routes/og-image.d.ts +15 -0
  31. package/dist/src/server/routes/preview-bundle.d.ts +1 -0
  32. package/dist/src/server/routes/preview-config.d.ts +1 -0
  33. package/dist/src/server/routes/tokens.d.ts +1 -0
  34. package/dist/{vite → src/server}/start.d.ts +5 -2
  35. package/dist/{ui → src/ui}/button.d.ts +1 -1
  36. package/dist/{validators → src/validators}/index.d.ts +0 -5
  37. package/dist/{validators → src/validators}/semantic-validator.d.ts +2 -3
  38. package/package.json +8 -11
  39. package/src/jsx/CLAUDE.md +18 -0
  40. package/src/jsx/jsx-runtime.ts +1 -1
  41. package/src/preview-runtime/CLAUDE.md +21 -0
  42. package/src/preview-runtime/build-optimized.ts +189 -73
  43. package/src/preview-runtime/build.ts +75 -79
  44. package/src/preview-runtime/fast-template.html +5 -1
  45. package/src/preview-runtime/region-bridge.test.ts +41 -0
  46. package/src/preview-runtime/region-bridge.ts +101 -0
  47. package/src/preview-runtime/types.ts +6 -0
  48. package/src/preview-runtime/vendors.ts +215 -22
  49. package/src/primitives/CLAUDE.md +17 -0
  50. package/src/theme/CLAUDE.md +20 -0
  51. package/src/theme/Preview.tsx +10 -4
  52. package/src/theme/Toolbar.tsx +2 -2
  53. package/src/theme/entry.tsx +247 -121
  54. package/src/theme/hooks/useAnnotations.ts +77 -0
  55. package/src/theme/hooks/useApprovalStatus.ts +50 -0
  56. package/src/theme/hooks/useSnapshots.ts +147 -0
  57. package/src/theme/hooks/useStorage.ts +26 -0
  58. package/src/theme/hooks/useTokenOverrides.ts +56 -0
  59. package/src/theme/hooks/useViewport.ts +23 -0
  60. package/src/theme/icons.tsx +39 -1
  61. package/src/theme/index.html +18 -0
  62. package/src/theme/mdx-components.tsx +1 -1
  63. package/src/theme/previews/AnnotationLayer.tsx +285 -0
  64. package/src/theme/previews/AnnotationPin.tsx +61 -0
  65. package/src/theme/previews/AnnotationThread.tsx +257 -0
  66. package/src/theme/previews/CLAUDE.md +18 -0
  67. package/src/theme/previews/ComponentPreview.tsx +487 -107
  68. package/src/theme/previews/FlowDiagram.tsx +111 -0
  69. package/src/theme/previews/FlowPreview.tsx +938 -174
  70. package/src/theme/previews/PreviewRouter.tsx +1 -4
  71. package/src/theme/previews/ScreenPreview.tsx +515 -175
  72. package/src/theme/previews/SnapshotButton.tsx +68 -0
  73. package/src/theme/previews/SnapshotCompare.tsx +216 -0
  74. package/src/theme/previews/SnapshotPanel.tsx +274 -0
  75. package/src/theme/previews/StatusBadge.tsx +66 -0
  76. package/src/theme/previews/StatusDropdown.tsx +158 -0
  77. package/src/theme/previews/TokenPlayground.tsx +438 -0
  78. package/src/theme/previews/ViewportControls.tsx +67 -0
  79. package/src/theme/previews/flow-diagram.test.ts +141 -0
  80. package/src/theme/previews/flow-diagram.ts +109 -0
  81. package/src/theme/previews/flow-navigation.test.ts +90 -0
  82. package/src/theme/previews/flow-navigation.ts +47 -0
  83. package/src/theme/previews/machines/derived.test.ts +225 -0
  84. package/src/theme/previews/machines/derived.ts +73 -0
  85. package/src/theme/previews/machines/flow-machine.test.ts +379 -0
  86. package/src/theme/previews/machines/flow-machine.ts +207 -0
  87. package/src/theme/previews/machines/screen-machine.test.ts +149 -0
  88. package/src/theme/previews/machines/screen-machine.ts +76 -0
  89. package/src/theme/previews/stores/flow-store.test.ts +157 -0
  90. package/src/theme/previews/stores/flow-store.ts +49 -0
  91. package/src/theme/previews/stores/screen-store.test.ts +68 -0
  92. package/src/theme/previews/stores/screen-store.ts +33 -0
  93. package/src/theme/storage.test.ts +97 -0
  94. package/src/theme/storage.ts +71 -0
  95. package/src/theme/styles.css +296 -25
  96. package/src/theme/types.ts +64 -0
  97. package/src/tokens/CLAUDE.md +16 -0
  98. package/src/tokens/resolver.ts +1 -1
  99. package/dist/preview-runtime/vendors.d.ts +0 -6
  100. package/dist/vite/config-parser.d.ts +0 -13
  101. package/dist/vite/config.d.ts +0 -12
  102. package/dist/vite/plugins/config-plugin.d.ts +0 -3
  103. package/dist/vite/plugins/debug-plugin.d.ts +0 -3
  104. package/dist/vite/plugins/entry-plugin.d.ts +0 -2
  105. package/dist/vite/plugins/fumadocs-plugin.d.ts +0 -9
  106. package/dist/vite/plugins/pages-plugin.d.ts +0 -5
  107. package/dist/vite/plugins/previews-plugin.d.ts +0 -2
  108. package/dist/vite/plugins/tokens-plugin.d.ts +0 -2
  109. package/dist/vite/preview-types.d.ts +0 -70
  110. package/src/theme/previews/AtlasPreview.tsx +0 -528
  111. package/dist/{cli.d.ts → src/cli.d.ts} +0 -0
  112. package/dist/{config → src/config}/index.d.ts +0 -0
  113. package/dist/{config → src/config}/loader.d.ts +0 -0
  114. package/dist/{config → src/config}/schema.d.ts +0 -0
  115. package/dist/{vite → src/content}/pages.d.ts +0 -0
  116. package/dist/{jsx → src/jsx}/adapters/html.d.ts +0 -0
  117. package/dist/{jsx → src/jsx}/adapters/react.d.ts +0 -0
  118. package/dist/{jsx → src/jsx}/define-component.d.ts +0 -0
  119. package/dist/{jsx → src/jsx}/index.d.ts +0 -0
  120. package/dist/{jsx → src/jsx}/jsx-runtime.d.ts +0 -0
  121. package/dist/{jsx → src/jsx}/migrate.d.ts +0 -0
  122. package/dist/{jsx → src/jsx}/schemas/index.d.ts +0 -0
  123. package/dist/{jsx → src/jsx}/schemas/primitives.d.ts +10 -10
  124. package/dist/{jsx → src/jsx}/schemas/tokens.d.ts +3 -3
  125. /package/dist/{jsx → src/jsx}/validation.d.ts +0 -0
  126. /package/dist/{jsx → src/jsx}/vnode.d.ts +0 -0
  127. /package/dist/{migrate.d.ts → src/migrate.d.ts} +0 -0
  128. /package/dist/{preview-runtime → src/preview-runtime}/tailwind.d.ts +0 -0
  129. /package/dist/{primitives → src/primitives}/index.d.ts +0 -0
  130. /package/dist/{primitives → src/primitives}/migrate.d.ts +0 -0
  131. /package/dist/{primitives → src/primitives}/parser.d.ts +0 -0
  132. /package/dist/{primitives → src/primitives}/template-parser.d.ts +0 -0
  133. /package/dist/{primitives → src/primitives}/template-renderer.d.ts +0 -0
  134. /package/dist/{primitives → src/primitives}/types.d.ts +0 -0
  135. /package/dist/{renderers → src/renderers}/html/index.d.ts +0 -0
  136. /package/dist/{renderers → src/renderers}/react/index.d.ts +0 -0
  137. /package/dist/{renderers → src/renderers}/registry.d.ts +0 -0
  138. /package/dist/{renderers → src/renderers}/render.d.ts +0 -0
  139. /package/dist/{tokens → src/tokens}/defaults.d.ts +0 -0
  140. /package/dist/{tokens → src/tokens}/resolver.d.ts +0 -0
  141. /package/dist/{tokens → src/tokens}/utils.d.ts +0 -0
  142. /package/dist/{tokens → src/tokens}/validation.d.ts +0 -0
  143. /package/dist/{typecheck → src/typecheck}/index.d.ts +0 -0
  144. /package/dist/{ui → src/ui}/card.d.ts +0 -0
  145. /package/dist/{ui → src/ui}/index.d.ts +0 -0
  146. /package/dist/{ui → src/ui}/utils.d.ts +0 -0
  147. /package/dist/{utils → src/utils}/cache.d.ts +0 -0
  148. /package/dist/{utils → src/utils}/debug.d.ts +0 -0
  149. /package/dist/{utils → src/utils}/port.d.ts +0 -0
  150. /package/dist/{validators → src/validators}/schema-validator.d.ts +0 -0
@@ -0,0 +1,5 @@
1
+ import { type Product } from '../../shared/data';
2
+ export declare function CartItem({ product }: {
3
+ product: Product;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ export default function CartItemDemo(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export declare function PriceTag({ amount, original, size, }: {
2
+ amount: number;
3
+ original?: number;
4
+ size?: 'sm' | 'md' | 'lg';
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ export default function PriceTagDemo(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function CartEmpty(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function Cart(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function PaymentError(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function PaymentForm(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function PaymentProcessing(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function Receipt(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,30 @@
1
+ export declare const brand: {
2
+ readonly name: "Luminary";
3
+ readonly tagline: "Curated essentials, delivered.";
4
+ };
5
+ export declare const colors: {
6
+ readonly primary: "#1a1a2e";
7
+ readonly accent: "#e94560";
8
+ readonly success: "#10b981";
9
+ readonly error: "#ef4444";
10
+ readonly warning: "#f59e0b";
11
+ readonly muted: "#6b7280";
12
+ readonly border: "#e5e7eb";
13
+ readonly surface: "#f9fafb";
14
+ readonly white: "#ffffff";
15
+ };
16
+ export interface Product {
17
+ id: string;
18
+ name: string;
19
+ description: string;
20
+ price: number;
21
+ quantity: number;
22
+ image: string;
23
+ }
24
+ export declare const products: Product[];
25
+ export declare const TAX_RATE = 0.0875;
26
+ export declare function subtotal(items?: Product[]): number;
27
+ export declare function tax(items?: Product[]): number;
28
+ export declare function total(items?: Product[]): number;
29
+ export declare function formatPrice(amount: number): string;
30
+ export declare const orderNumber = "LMN-2026-48291";
@@ -0,0 +1,30 @@
1
+ import { type PreviewConfig, type PreviewType, type FlowDefinition, type FlowConfig } from './preview-types';
2
+ export interface ParseOptions {
3
+ /** Inject id from folder name if not present */
4
+ injectId?: boolean;
5
+ /** Inject kind from directory type if not present */
6
+ injectKind?: boolean;
7
+ /** The preview type (for kind inference) */
8
+ previewType?: PreviewType;
9
+ /** The folder name (for id inference) */
10
+ folderName?: string;
11
+ }
12
+ export interface ParseResult<T> {
13
+ data: T | null;
14
+ errors: string[];
15
+ warnings: string[];
16
+ }
17
+ /**
18
+ * Parse a config.yaml or config.yml file and validate against schema
19
+ */
20
+ export declare function parsePreviewConfig(filePath: string, options?: ParseOptions): Promise<ParseResult<PreviewConfig>>;
21
+ /**
22
+ * Parse a flow config from config.yaml (new format)
23
+ * Falls back to legacy index.yaml format for backwards compatibility
24
+ */
25
+ export declare function parseFlowConfig(configPath: string, options?: ParseOptions): Promise<ParseResult<FlowConfig>>;
26
+ /**
27
+ * Parse a flow index.yaml file (legacy format)
28
+ * @deprecated Use parseFlowConfig with config.yaml instead
29
+ */
30
+ export declare function parseFlowDefinition(filePath: string): Promise<FlowDefinition | null>;
@@ -0,0 +1,21 @@
1
+ import type { FlowConfig } from './preview-types';
2
+ export interface VerifyResult {
3
+ errors: string[];
4
+ warnings: string[];
5
+ }
6
+ /**
7
+ * Extract data-region names from TSX/JSX source code.
8
+ * Uses Bun.Transpiler to normalize JSX → JS, then regex to find region attributes.
9
+ */
10
+ export declare function extractRegions(source: string): string[];
11
+ /**
12
+ * Verify a flow config structurally:
13
+ * - Screen dirs exist
14
+ * - State files exist
15
+ * - Referenced regions exist in screen source
16
+ * - Goto targets reference valid step IDs
17
+ * - No duplicate step IDs
18
+ * - Warn on dead-end steps (no regions, not terminal)
19
+ * - Warn on orphan steps (unreachable from step[0])
20
+ */
21
+ export declare function verifyFlow(config: FlowConfig, rootDir: string): VerifyResult;
@@ -0,0 +1,288 @@
1
+ import { z } from 'zod';
2
+ export type PreviewType = 'component' | 'screen' | 'flow';
3
+ export declare const componentConfigSchema: z.ZodObject<{
4
+ id: z.ZodOptional<z.ZodString>;
5
+ title: z.ZodString;
6
+ description: z.ZodOptional<z.ZodString>;
7
+ tags: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>>;
8
+ category: z.ZodOptional<z.ZodString>;
9
+ status: z.ZodOptional<z.ZodEnum<{
10
+ draft: "draft";
11
+ stable: "stable";
12
+ deprecated: "deprecated";
13
+ }>>;
14
+ schemaVersion: z.ZodOptional<z.ZodEnum<{
15
+ "1.0": "1.0";
16
+ "2.0": "2.0";
17
+ }>>;
18
+ order: z.ZodOptional<z.ZodNumber>;
19
+ kind: z.ZodOptional<z.ZodLiteral<"component">>;
20
+ props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
21
+ type: z.ZodOptional<z.ZodString>;
22
+ required: z.ZodOptional<z.ZodBoolean>;
23
+ default: z.ZodOptional<z.ZodUnknown>;
24
+ enum: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
25
+ }, z.core.$strip>>>;
26
+ slots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
27
+ description: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strip>>>;
29
+ }, z.core.$strip>;
30
+ export declare const screenConfigSchema: z.ZodObject<{
31
+ id: z.ZodOptional<z.ZodString>;
32
+ title: z.ZodString;
33
+ description: z.ZodOptional<z.ZodString>;
34
+ tags: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>>;
35
+ category: z.ZodOptional<z.ZodString>;
36
+ status: z.ZodOptional<z.ZodEnum<{
37
+ draft: "draft";
38
+ stable: "stable";
39
+ deprecated: "deprecated";
40
+ }>>;
41
+ schemaVersion: z.ZodOptional<z.ZodEnum<{
42
+ "1.0": "1.0";
43
+ "2.0": "2.0";
44
+ }>>;
45
+ order: z.ZodOptional<z.ZodNumber>;
46
+ kind: z.ZodOptional<z.ZodLiteral<"screen">>;
47
+ states: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
48
+ description: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strip>>>;
50
+ layoutByRenderer: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnknown>>>;
51
+ }, z.core.$strip>;
52
+ declare const regionGotoSchema: z.ZodObject<{
53
+ goto: z.ZodString;
54
+ }, z.core.$strip>;
55
+ declare const regionOutcomesSchema: z.ZodObject<{
56
+ outcomes: z.ZodRecord<z.ZodString, z.ZodObject<{
57
+ goto: z.ZodString;
58
+ label: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strip>>;
60
+ }, z.core.$strip>;
61
+ declare const regionSchema: z.ZodUnion<readonly [z.ZodObject<{
62
+ goto: z.ZodString;
63
+ }, z.core.$strip>, z.ZodObject<{
64
+ outcomes: z.ZodRecord<z.ZodString, z.ZodObject<{
65
+ goto: z.ZodString;
66
+ label: z.ZodOptional<z.ZodString>;
67
+ }, z.core.$strip>>;
68
+ }, z.core.$strip>]>;
69
+ declare const flowStepSchema: z.ZodObject<{
70
+ id: z.ZodOptional<z.ZodString>;
71
+ title: z.ZodOptional<z.ZodString>;
72
+ description: z.ZodOptional<z.ZodString>;
73
+ screen: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
74
+ ref: z.ZodString;
75
+ state: z.ZodOptional<z.ZodString>;
76
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
77
+ }, z.core.$strip>]>;
78
+ state: z.ZodOptional<z.ZodString>;
79
+ note: z.ZodOptional<z.ZodString>;
80
+ trigger: z.ZodOptional<z.ZodString>;
81
+ highlight: z.ZodOptional<z.ZodArray<z.ZodString>>;
82
+ regions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
83
+ goto: z.ZodString;
84
+ }, z.core.$strip>, z.ZodObject<{
85
+ outcomes: z.ZodRecord<z.ZodString, z.ZodObject<{
86
+ goto: z.ZodString;
87
+ label: z.ZodOptional<z.ZodString>;
88
+ }, z.core.$strip>>;
89
+ }, z.core.$strip>]>>>;
90
+ terminal: z.ZodOptional<z.ZodBoolean>;
91
+ }, z.core.$strip>;
92
+ export declare const flowConfigSchema: z.ZodObject<{
93
+ id: z.ZodOptional<z.ZodString>;
94
+ title: z.ZodString;
95
+ description: z.ZodOptional<z.ZodString>;
96
+ tags: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>>;
97
+ category: z.ZodOptional<z.ZodString>;
98
+ status: z.ZodOptional<z.ZodEnum<{
99
+ draft: "draft";
100
+ stable: "stable";
101
+ deprecated: "deprecated";
102
+ }>>;
103
+ schemaVersion: z.ZodOptional<z.ZodEnum<{
104
+ "1.0": "1.0";
105
+ "2.0": "2.0";
106
+ }>>;
107
+ order: z.ZodOptional<z.ZodNumber>;
108
+ kind: z.ZodOptional<z.ZodLiteral<"flow">>;
109
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
110
+ id: z.ZodOptional<z.ZodString>;
111
+ title: z.ZodOptional<z.ZodString>;
112
+ description: z.ZodOptional<z.ZodString>;
113
+ screen: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
114
+ ref: z.ZodString;
115
+ state: z.ZodOptional<z.ZodString>;
116
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
117
+ }, z.core.$strip>]>;
118
+ state: z.ZodOptional<z.ZodString>;
119
+ note: z.ZodOptional<z.ZodString>;
120
+ trigger: z.ZodOptional<z.ZodString>;
121
+ highlight: z.ZodOptional<z.ZodArray<z.ZodString>>;
122
+ regions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
123
+ goto: z.ZodString;
124
+ }, z.core.$strip>, z.ZodObject<{
125
+ outcomes: z.ZodRecord<z.ZodString, z.ZodObject<{
126
+ goto: z.ZodString;
127
+ label: z.ZodOptional<z.ZodString>;
128
+ }, z.core.$strip>>;
129
+ }, z.core.$strip>]>>>;
130
+ terminal: z.ZodOptional<z.ZodBoolean>;
131
+ }, z.core.$strip>>>;
132
+ transitions: z.ZodOptional<z.ZodArray<z.ZodObject<{
133
+ from: z.ZodString;
134
+ to: z.ZodString;
135
+ trigger: z.ZodString;
136
+ }, z.core.$strip>>>;
137
+ }, z.core.$strip>;
138
+ export declare const configSchema: z.ZodUnion<readonly [z.ZodObject<{
139
+ id: z.ZodOptional<z.ZodString>;
140
+ title: z.ZodString;
141
+ description: z.ZodOptional<z.ZodString>;
142
+ tags: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>>;
143
+ category: z.ZodOptional<z.ZodString>;
144
+ status: z.ZodOptional<z.ZodEnum<{
145
+ draft: "draft";
146
+ stable: "stable";
147
+ deprecated: "deprecated";
148
+ }>>;
149
+ schemaVersion: z.ZodOptional<z.ZodEnum<{
150
+ "1.0": "1.0";
151
+ "2.0": "2.0";
152
+ }>>;
153
+ order: z.ZodOptional<z.ZodNumber>;
154
+ kind: z.ZodOptional<z.ZodLiteral<"component">>;
155
+ props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
156
+ type: z.ZodOptional<z.ZodString>;
157
+ required: z.ZodOptional<z.ZodBoolean>;
158
+ default: z.ZodOptional<z.ZodUnknown>;
159
+ enum: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
160
+ }, z.core.$strip>>>;
161
+ slots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
162
+ description: z.ZodOptional<z.ZodString>;
163
+ }, z.core.$strip>>>;
164
+ }, z.core.$strip>, z.ZodObject<{
165
+ id: z.ZodOptional<z.ZodString>;
166
+ title: z.ZodString;
167
+ description: z.ZodOptional<z.ZodString>;
168
+ tags: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>>;
169
+ category: z.ZodOptional<z.ZodString>;
170
+ status: z.ZodOptional<z.ZodEnum<{
171
+ draft: "draft";
172
+ stable: "stable";
173
+ deprecated: "deprecated";
174
+ }>>;
175
+ schemaVersion: z.ZodOptional<z.ZodEnum<{
176
+ "1.0": "1.0";
177
+ "2.0": "2.0";
178
+ }>>;
179
+ order: z.ZodOptional<z.ZodNumber>;
180
+ kind: z.ZodOptional<z.ZodLiteral<"screen">>;
181
+ states: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
182
+ description: z.ZodOptional<z.ZodString>;
183
+ }, z.core.$strip>>>;
184
+ layoutByRenderer: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnknown>>>;
185
+ }, z.core.$strip>, z.ZodObject<{
186
+ id: z.ZodOptional<z.ZodString>;
187
+ title: z.ZodString;
188
+ description: z.ZodOptional<z.ZodString>;
189
+ tags: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>>;
190
+ category: z.ZodOptional<z.ZodString>;
191
+ status: z.ZodOptional<z.ZodEnum<{
192
+ draft: "draft";
193
+ stable: "stable";
194
+ deprecated: "deprecated";
195
+ }>>;
196
+ schemaVersion: z.ZodOptional<z.ZodEnum<{
197
+ "1.0": "1.0";
198
+ "2.0": "2.0";
199
+ }>>;
200
+ order: z.ZodOptional<z.ZodNumber>;
201
+ kind: z.ZodOptional<z.ZodLiteral<"flow">>;
202
+ steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
203
+ id: z.ZodOptional<z.ZodString>;
204
+ title: z.ZodOptional<z.ZodString>;
205
+ description: z.ZodOptional<z.ZodString>;
206
+ screen: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
207
+ ref: z.ZodString;
208
+ state: z.ZodOptional<z.ZodString>;
209
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
210
+ }, z.core.$strip>]>;
211
+ state: z.ZodOptional<z.ZodString>;
212
+ note: z.ZodOptional<z.ZodString>;
213
+ trigger: z.ZodOptional<z.ZodString>;
214
+ highlight: z.ZodOptional<z.ZodArray<z.ZodString>>;
215
+ regions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
216
+ goto: z.ZodString;
217
+ }, z.core.$strip>, z.ZodObject<{
218
+ outcomes: z.ZodRecord<z.ZodString, z.ZodObject<{
219
+ goto: z.ZodString;
220
+ label: z.ZodOptional<z.ZodString>;
221
+ }, z.core.$strip>>;
222
+ }, z.core.$strip>]>>>;
223
+ terminal: z.ZodOptional<z.ZodBoolean>;
224
+ }, z.core.$strip>>>;
225
+ transitions: z.ZodOptional<z.ZodArray<z.ZodObject<{
226
+ from: z.ZodString;
227
+ to: z.ZodString;
228
+ trigger: z.ZodString;
229
+ }, z.core.$strip>>>;
230
+ }, z.core.$strip>, z.ZodObject<{
231
+ kind: z.ZodOptional<z.ZodEnum<{
232
+ component: "component";
233
+ screen: "screen";
234
+ flow: "flow";
235
+ }>>;
236
+ id: z.ZodOptional<z.ZodString>;
237
+ title: z.ZodString;
238
+ description: z.ZodOptional<z.ZodString>;
239
+ tags: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>]>>;
240
+ category: z.ZodOptional<z.ZodString>;
241
+ status: z.ZodOptional<z.ZodEnum<{
242
+ draft: "draft";
243
+ stable: "stable";
244
+ deprecated: "deprecated";
245
+ }>>;
246
+ schemaVersion: z.ZodOptional<z.ZodEnum<{
247
+ "1.0": "1.0";
248
+ "2.0": "2.0";
249
+ }>>;
250
+ order: z.ZodOptional<z.ZodNumber>;
251
+ }, z.core.$strip>]>;
252
+ export type PreviewConfig = z.infer<typeof configSchema>;
253
+ export type ComponentConfig = z.infer<typeof componentConfigSchema>;
254
+ export type ScreenConfig = z.infer<typeof screenConfigSchema>;
255
+ export type FlowConfig = z.infer<typeof flowConfigSchema>;
256
+ export type RegionGoto = z.infer<typeof regionGotoSchema>;
257
+ export type RegionOutcomes = z.infer<typeof regionOutcomesSchema>;
258
+ export type Region = z.infer<typeof regionSchema>;
259
+ export type FlowStep = z.infer<typeof flowStepSchema>;
260
+ export interface PreviewUnit {
261
+ type: PreviewType;
262
+ name: string;
263
+ path: string;
264
+ route: string;
265
+ config: PreviewConfig | null;
266
+ files: {
267
+ index: string;
268
+ states?: string[];
269
+ schema?: string;
270
+ docs?: string;
271
+ };
272
+ }
273
+ export interface LegacyFlowStep {
274
+ id?: string;
275
+ title?: string;
276
+ description?: string;
277
+ screen: string;
278
+ state?: string;
279
+ note?: string;
280
+ trigger?: string;
281
+ highlight?: string[];
282
+ }
283
+ export interface FlowDefinition {
284
+ name: string;
285
+ description?: string;
286
+ steps: LegacyFlowStep[];
287
+ }
288
+ export {};
@@ -1,15 +1,5 @@
1
1
  import type { PreviewFile, PreviewConfig } from '../preview-runtime/types';
2
2
  import type { PreviewUnit } from './preview-types';
3
- export interface Preview {
4
- name: string;
5
- route: string;
6
- htmlPath: string;
7
- }
8
- export interface PreviewWithFiles extends Preview {
9
- files: PreviewFile[];
10
- entry: string;
11
- }
12
- export declare function scanPreviews(rootDir: string): Promise<Preview[]>;
13
3
  /**
14
4
  * Scan all files in a preview directory for WASM bundling
15
5
  */
@@ -20,8 +10,10 @@ export declare function scanPreviewFiles(previewDir: string): Promise<PreviewFil
20
10
  export declare function detectEntry(files: PreviewFile[]): string;
21
11
  /**
22
12
  * Build a PreviewConfig for WASM runtime
13
+ * @param previewDir - Directory containing the preview files
14
+ * @param entryOverride - Optional entry file override (for building alternate states)
23
15
  */
24
- export declare function buildPreviewConfig(previewDir: string): Promise<PreviewConfig>;
16
+ export declare function buildPreviewConfig(previewDir: string, entryOverride?: string): Promise<PreviewConfig>;
25
17
  /**
26
18
  * Scan previews with multi-type folder structure support
27
19
  * Supports: components/, screens/, flows/, atlas/
@@ -1,6 +1,8 @@
1
1
  import type { PreviewConfig } from './types';
2
2
  export interface OptimizedBuildOptions {
3
3
  vendorPath: string;
4
+ jsxPath?: string;
5
+ resolveDir?: string;
4
6
  }
5
7
  export interface OptimizedBuildResult {
6
8
  success: boolean;
@@ -5,6 +5,6 @@ export interface PreviewBuildResult {
5
5
  }
6
6
  /**
7
7
  * Build a preview into a standalone HTML file for production
8
- * Uses esbuild (native) to bundle at build time
8
+ * Uses Bun.build (native) to bundle at build time
9
9
  */
10
10
  export declare function buildPreviewHtml(config: PreviewConfig): Promise<PreviewBuildResult>;
@@ -0,0 +1 @@
1
+ export declare const REGION_BRIDGE_SCRIPT = "\n(function() {\n // Click handler: delegate clicks on [data-region] elements\n document.addEventListener('click', function(e) {\n var el = e.target;\n while (el && el !== document.body) {\n if (el.getAttribute && el.getAttribute('data-region')) {\n e.preventDefault();\n e.stopPropagation();\n window.parent.postMessage({\n type: 'region-click',\n region: el.getAttribute('data-region')\n }, '*');\n return;\n }\n el = el.parentElement;\n }\n }, true);\n\n // Highlight handler: parent sends list of region names to highlight\n window.addEventListener('message', function(e) {\n if (!e.data || e.data.type !== 'highlight-regions') return;\n\n // Remove existing highlights\n var existing = document.querySelectorAll('[data-region-highlight]');\n for (var i = 0; i < existing.length; i++) {\n existing[i].removeAttribute('data-region-highlight');\n existing[i].style.cursor = '';\n }\n\n var regions = e.data.regions || [];\n if (regions.length === 0) {\n // Report empty rects when cleared\n window.parent.postMessage({ type: 'region-rects', rects: [] }, '*');\n return;\n }\n\n for (var j = 0; j < regions.length; j++) {\n var els = document.querySelectorAll('[data-region=\"' + regions[j] + '\"]');\n for (var k = 0; k < els.length; k++) {\n els[k].setAttribute('data-region-highlight', 'true');\n els[k].style.cursor = 'pointer';\n }\n }\n\n // Report bounding rects to parent\n reportRegionRects();\n });\n\n // Measure and report region rects to parent\n function reportRegionRects() {\n var highlighted = document.querySelectorAll('[data-region-highlight]');\n var rects = [];\n for (var i = 0; i < highlighted.length; i++) {\n var el = highlighted[i];\n var rect = el.getBoundingClientRect();\n rects.push({\n name: el.getAttribute('data-region') || '',\n x: rect.left,\n y: rect.top,\n width: rect.width,\n height: rect.height\n });\n }\n window.parent.postMessage({ type: 'region-rects', rects: rects }, '*');\n }\n\n // Debounced re-report on scroll/resize\n var debounceTimer = null;\n function debouncedReport() {\n if (debounceTimer) clearTimeout(debounceTimer);\n debounceTimer = setTimeout(function() {\n var highlighted = document.querySelectorAll('[data-region-highlight]');\n if (highlighted.length > 0) reportRegionRects();\n }, 100);\n }\n window.addEventListener('scroll', debouncedReport, true);\n window.addEventListener('resize', debouncedReport);\n\n // Token override handler: parent sends CSS overrides to inject\n window.addEventListener('message', function(e) {\n if (!e.data || e.data.type !== 'token-overrides') return;\n var styleId = 'prev-token-overrides';\n var existing = document.getElementById(styleId);\n if (e.data.css) {\n if (!existing) {\n existing = document.createElement('style');\n existing.id = styleId;\n document.head.appendChild(existing);\n }\n existing.textContent = e.data.css;\n } else if (existing) {\n existing.remove();\n }\n });\n})();\n";
@@ -29,4 +29,22 @@ export type PreviewMessage = {
29
29
  } | {
30
30
  type: 'error';
31
31
  error: string;
32
+ } | {
33
+ type: 'region-click';
34
+ region: string;
35
+ } | {
36
+ type: 'highlight-regions';
37
+ regions: string[];
38
+ } | {
39
+ type: 'region-rects';
40
+ rects: Array<{
41
+ name: string;
42
+ x: number;
43
+ y: number;
44
+ width: number;
45
+ height: number;
46
+ }>;
47
+ } | {
48
+ type: 'token-overrides';
49
+ css: string;
32
50
  };
@@ -0,0 +1,11 @@
1
+ export interface VendorBundleResult {
2
+ success: boolean;
3
+ code: string;
4
+ error?: string;
5
+ }
6
+ export declare function buildVendorBundle(): Promise<VendorBundleResult>;
7
+ /**
8
+ * Build @prev/jsx bundle for static preview builds
9
+ * React is externalized, so temp dir location doesn't matter for resolution
10
+ */
11
+ export declare function buildJsxBundle(vendorPath: string): Promise<VendorBundleResult>;
@@ -1,5 +1,5 @@
1
1
  export { registerAdapter, getAdapter, listAdapters, getAllAdapters, isValidRendererKey, getLayoutSchema, clearAdapters, initializeAdapters, validateRendererKeys, } from './registry';
2
2
  export { renderPreview, renderPreviews, selectAdapter, ensureAdaptersInitialized, supportsHMR, type RenderOptions, type RenderResult, } from './render';
3
- export type { RendererAdapter, RenderOutput, DevServer, PreviewKind, PreviewRef, BaseConfig, ComponentConfig, ScreenConfig, FlowConfig, AtlasConfig, PreviewConfig, FlowStep, FlowTransition, AtlasNode, AtlasRelationship, } from './types';
3
+ export type { RendererAdapter, RenderOutput, DevServer, PreviewKind, PreviewRef, BaseConfig, ComponentConfig, ScreenConfig, FlowConfig, PreviewConfig, FlowStep, FlowTransition, } from './types';
4
4
  export { ReactAdapter } from './react';
5
5
  export { HTMLAdapter } from './html';
@@ -2,7 +2,7 @@ import type { JSONSchema7 } from 'json-schema';
2
2
  /**
3
3
  * Preview type discriminator
4
4
  */
5
- export type PreviewKind = 'component' | 'screen' | 'flow' | 'atlas';
5
+ export type PreviewKind = 'component' | 'screen' | 'flow';
6
6
  /**
7
7
  * Reference to another preview unit
8
8
  */
@@ -97,34 +97,10 @@ export interface FlowConfig extends BaseConfig {
97
97
  steps: FlowStep[];
98
98
  transitions?: FlowTransition[];
99
99
  }
100
- /**
101
- * Atlas node definition
102
- */
103
- export interface AtlasNode {
104
- id: string;
105
- title: string;
106
- ref?: PreviewRef;
107
- }
108
- /**
109
- * Atlas relationship definition
110
- */
111
- export interface AtlasRelationship {
112
- from: string;
113
- to: string;
114
- type: string;
115
- }
116
- /**
117
- * Atlas config - defines information architecture
118
- */
119
- export interface AtlasConfig extends BaseConfig {
120
- kind: 'atlas';
121
- nodes: AtlasNode[];
122
- relationships?: AtlasRelationship[];
123
- }
124
100
  /**
125
101
  * Union of all config types
126
102
  */
127
- export type PreviewConfig = ComponentConfig | ScreenConfig | FlowConfig | AtlasConfig;
103
+ export type PreviewConfig = ComponentConfig | ScreenConfig | FlowConfig;
128
104
  /**
129
105
  * Output from rendering a preview
130
106
  */
@@ -148,7 +124,7 @@ export interface DevServer {
148
124
  * Renderer adapter interface - implementations for React, HTML, Solid, etc.
149
125
  *
150
126
  * The adapter interface is intentionally thin. Bundling, asset management,
151
- * and hydration are handled by the build system (Vite/esbuild), not the adapter.
127
+ * and hydration are handled by the build system (Bun.build), not the adapter.
152
128
  */
153
129
  export interface RendererAdapter {
154
130
  /**
@@ -173,10 +149,6 @@ export interface RendererAdapter {
173
149
  * Render the current step's screen with navigation UI (prev/next)
174
150
  */
175
151
  renderFlow(config: FlowConfig, step?: string): RenderOutput;
176
- /**
177
- * Render a graph visualization with node thumbnails
178
- */
179
- renderAtlas(config: AtlasConfig): RenderOutput;
180
152
  /**
181
153
  * Whether this adapter supports Hot Module Replacement
182
154
  */
@@ -0,0 +1,6 @@
1
+ export interface BuildOptions {
2
+ rootDir: string;
3
+ include?: string[];
4
+ base?: string;
5
+ }
6
+ export declare function buildProductionSite(options: BuildOptions): Promise<void>;
@@ -0,0 +1,13 @@
1
+ import type { PrevConfig } from '../config';
2
+ export interface DevServerOptions {
3
+ rootDir: string;
4
+ port: number;
5
+ include?: string[];
6
+ config?: PrevConfig;
7
+ }
8
+ export declare function startDevServer(options: DevServerOptions): Promise<{
9
+ server: Bun.Server<undefined>;
10
+ port: number | undefined;
11
+ url: string;
12
+ stop: () => void;
13
+ }>;
@@ -0,0 +1,5 @@
1
+ import type { BunPlugin } from 'bun';
2
+ export interface AliasesOptions {
3
+ cliRoot: string;
4
+ }
5
+ export declare function aliasesPlugin(options: AliasesOptions): BunPlugin;
@@ -0,0 +1,5 @@
1
+ import type { BunPlugin } from 'bun';
2
+ export interface MdxPluginOptions {
3
+ rootDir: string;
4
+ }
5
+ export declare function mdxPlugin(options: MdxPluginOptions): BunPlugin;
@@ -0,0 +1,8 @@
1
+ import type { BunPlugin } from 'bun';
2
+ import { type PrevConfig } from '../../config';
3
+ export interface VirtualModulesOptions {
4
+ rootDir: string;
5
+ include?: string[];
6
+ config?: PrevConfig;
7
+ }
8
+ export declare function virtualModulesPlugin(options: VirtualModulesOptions): BunPlugin;
@@ -0,0 +1,10 @@
1
+ export interface PreviewServerOptions {
2
+ rootDir: string;
3
+ port: number;
4
+ }
5
+ export declare function startPreviewServer(options: PreviewServerOptions): Promise<{
6
+ server: Bun.Server<undefined>;
7
+ port: number | undefined;
8
+ url: string;
9
+ stop: () => Promise<void>;
10
+ }>;
@@ -0,0 +1 @@
1
+ export declare function createComponentBundleHandler(rootDir: string): (req: Request) => Promise<Response | null>;
@@ -0,0 +1,3 @@
1
+ export declare function createJsxBundleHandler(cliRoot: string): (req: Request) => Promise<Response | null>;
2
+ /** Invalidate the JSX bundle cache */
3
+ export declare function invalidateJsxCache(handler: ReturnType<typeof createJsxBundleHandler>): void;
@@ -0,0 +1,15 @@
1
+ export declare function generateOgImage(opts: {
2
+ title: string;
3
+ type: string;
4
+ state?: string;
5
+ step?: string;
6
+ description?: string;
7
+ }): string;
8
+ export declare function handleOgImageRequest(req: Request, previewUnits: Array<{
9
+ name: string;
10
+ type: string;
11
+ config?: {
12
+ title?: string;
13
+ description?: string;
14
+ } | null;
15
+ }>): Response | null;
@@ -0,0 +1 @@
1
+ export declare function createPreviewBundleHandler(rootDir: string): (req: Request) => Promise<Response | null>;
@@ -0,0 +1 @@
1
+ export declare function createPreviewConfigHandler(rootDir: string): (req: Request) => Promise<Response | null>;