@vertz/ui-server 0.2.31 → 0.2.33
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 +54 -50
- package/dist/bun-dev-server.d.ts +14 -1
- package/dist/bun-dev-server.js +56 -4
- package/dist/index.d.ts +301 -233
- package/dist/index.js +81 -151
- package/dist/node-handler.d.ts +76 -23
- package/dist/node-handler.js +2 -2
- package/dist/shared/{chunk-wb5fv233.js → chunk-2kx402c1.js} +62 -8
- package/dist/shared/{chunk-34fexgex.js → chunk-hx7drzm3.js} +599 -409
- package/dist/shared/{chunk-es0406qq.js → chunk-xdb8qn68.js} +17 -5
- package/dist/ssr/index.d.ts +119 -57
- package/dist/ssr/index.js +5 -4
- package/package.json +18 -16
package/dist/index.d.ts
CHANGED
|
@@ -1,76 +1,7 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import { FontFallbackMetrics as FontFallbackMetrics4 } from "@vertz/ui";
|
|
2
3
|
import { FontFallbackMetrics as FontFallbackMetrics3 } from "@vertz/ui";
|
|
3
|
-
import {
|
|
4
|
-
import { SSRAuth as SSRAuth_jq1nwm } from "@vertz/ui/internals";
|
|
5
|
-
interface SSRModule {
|
|
6
|
-
default?: () => unknown;
|
|
7
|
-
App?: () => unknown;
|
|
8
|
-
theme?: Theme;
|
|
9
|
-
/** Global CSS strings to include in every SSR response (e.g. resets, body styles). */
|
|
10
|
-
styles?: string[];
|
|
11
|
-
/**
|
|
12
|
-
* Return all CSS tracked by the bundled @vertz/ui instance.
|
|
13
|
-
* The Vite SSR build inlines @vertz/ui into the server bundle, creating
|
|
14
|
-
* a separate module instance from @vertz/ui-server's dependency. Without
|
|
15
|
-
* this, component CSS from module-level css() calls is invisible to the
|
|
16
|
-
* SSR renderer. Export `getInjectedCSS` from @vertz/ui in the app entry.
|
|
17
|
-
*/
|
|
18
|
-
getInjectedCSS?: () => string[];
|
|
19
|
-
/** Compiled routes exported from the app for build-time SSG with generateParams. */
|
|
20
|
-
routes?: CompiledRoute[];
|
|
21
|
-
/** Code-generated API client for manifest-driven zero-discovery prefetching. */
|
|
22
|
-
api?: Record<string, Record<string, (...args: unknown[]) => unknown>>;
|
|
23
|
-
}
|
|
24
|
-
interface SSRRenderResult {
|
|
25
|
-
html: string;
|
|
26
|
-
css: string;
|
|
27
|
-
ssrData: Array<{
|
|
28
|
-
key: string;
|
|
29
|
-
data: unknown;
|
|
30
|
-
}>;
|
|
31
|
-
/** Font preload link tags for injection into <head>. */
|
|
32
|
-
headTags: string;
|
|
33
|
-
/** Route patterns discovered by createRouter() during SSR (for build-time pre-rendering). */
|
|
34
|
-
discoveredRoutes?: string[];
|
|
35
|
-
/** Route patterns that matched the current URL (for per-route modulepreload). */
|
|
36
|
-
matchedRoutePatterns?: string[];
|
|
37
|
-
/** Set when ProtectedRoute writes a redirect during SSR. Server should return 302. */
|
|
38
|
-
redirect?: {
|
|
39
|
-
to: string;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
interface SSRDiscoverResult {
|
|
43
|
-
resolved: Array<{
|
|
44
|
-
key: string;
|
|
45
|
-
data: unknown;
|
|
46
|
-
}>;
|
|
47
|
-
pending: string[];
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Render an SSR module to an HTML string with CSS and pre-fetched query data.
|
|
51
|
-
*
|
|
52
|
-
* Performs a two-pass render:
|
|
53
|
-
* - Pass 1: Discovery — calls the app to trigger query() registrations, awaits them
|
|
54
|
-
* - Pass 2: Render — calls the app again with data populated, renders to HTML
|
|
55
|
-
*/
|
|
56
|
-
declare function ssrRenderToString(module: SSRModule, url: string, options?: {
|
|
57
|
-
ssrTimeout?: number;
|
|
58
|
-
/** Pre-computed font fallback metrics (computed at server startup). */
|
|
59
|
-
fallbackMetrics?: Record<string, FontFallbackMetrics>;
|
|
60
|
-
/** Auth state resolved from session cookie. Passed to SSRRenderContext for AuthProvider. */
|
|
61
|
-
ssrAuth?: SSRAuth_jq1nwm;
|
|
62
|
-
}): Promise<SSRRenderResult>;
|
|
63
|
-
/**
|
|
64
|
-
* Discover queries for a given URL without rendering.
|
|
65
|
-
* Runs only Pass 1 (query registration + resolution), no Pass 2 render.
|
|
66
|
-
* Used by the production handler to pre-fetch query data for client-side navigations.
|
|
67
|
-
*/
|
|
68
|
-
declare function ssrDiscoverQueries(module: SSRModule, url: string, options?: {
|
|
69
|
-
ssrTimeout?: number;
|
|
70
|
-
}): Promise<SSRDiscoverResult>;
|
|
71
|
-
import { FontFallbackMetrics as FontFallbackMetrics2 } from "@vertz/ui";
|
|
72
|
-
import { SSRAuth } from "@vertz/ui/internals";
|
|
73
|
-
import { ExtractedQuery } from "@vertz/ui-compiler";
|
|
4
|
+
import { SSRAuth as SSRAuth2 } from "@vertz/ui/internals";
|
|
74
5
|
/**
|
|
75
6
|
* SSR prefetch access rule evaluator.
|
|
76
7
|
*
|
|
@@ -162,6 +93,147 @@ declare function toPrefetchSession(ssrAuth: {
|
|
|
162
93
|
* evaluate the rule.
|
|
163
94
|
*/
|
|
164
95
|
declare function evaluateAccessRule(rule: SerializedAccessRule, session: PrefetchSession): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* AOT SSR Diagnostics
|
|
98
|
+
*
|
|
99
|
+
* Tracks AOT compilation results and provides a JSON snapshot
|
|
100
|
+
* for the `/__vertz_ssr_aot` dev endpoint.
|
|
101
|
+
*/
|
|
102
|
+
/** AOT tier classification (mirrored from @vertz/ui-compiler to avoid cross-package dependency). */
|
|
103
|
+
type AotTier = "static" | "data-driven" | "conditional" | "runtime-fallback";
|
|
104
|
+
/** Per-component diagnostic entry in the snapshot. */
|
|
105
|
+
interface AotComponentDiagnostic {
|
|
106
|
+
tier: AotTier;
|
|
107
|
+
holes: string[];
|
|
108
|
+
}
|
|
109
|
+
/** A recorded divergence between AOT and DOM shim output. */
|
|
110
|
+
interface AotDivergenceEntry {
|
|
111
|
+
component: string;
|
|
112
|
+
aotHtml: string;
|
|
113
|
+
domHtml: string;
|
|
114
|
+
timestamp: string;
|
|
115
|
+
}
|
|
116
|
+
/** JSON snapshot returned by the `/__vertz_ssr_aot` endpoint. */
|
|
117
|
+
interface AotDiagnosticsSnapshot {
|
|
118
|
+
components: Record<string, AotComponentDiagnostic>;
|
|
119
|
+
coverage: {
|
|
120
|
+
total: number;
|
|
121
|
+
aot: number;
|
|
122
|
+
runtime: number;
|
|
123
|
+
percentage: number;
|
|
124
|
+
};
|
|
125
|
+
divergences: AotDivergenceEntry[];
|
|
126
|
+
}
|
|
127
|
+
/** Input shape matching AotComponentInfo from @vertz/ui-compiler. */
|
|
128
|
+
interface ComponentInput {
|
|
129
|
+
name: string;
|
|
130
|
+
tier: AotTier;
|
|
131
|
+
holes: string[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Collects AOT compilation diagnostics and produces JSON snapshots.
|
|
135
|
+
*
|
|
136
|
+
* Used by the dev server to power the `/__vertz_ssr_aot` endpoint
|
|
137
|
+
* and by the build pipeline for classification logging.
|
|
138
|
+
*/
|
|
139
|
+
declare class AotDiagnostics {
|
|
140
|
+
private _components;
|
|
141
|
+
private _divergences;
|
|
142
|
+
/**
|
|
143
|
+
* Record components from an AOT compilation result.
|
|
144
|
+
* Called once per file during compilation or hot rebuild.
|
|
145
|
+
*/
|
|
146
|
+
recordCompilation(components: ComponentInput[]): void;
|
|
147
|
+
/** Record a divergence between AOT and DOM shim HTML output. */
|
|
148
|
+
recordDivergence(component: string, aotHtml: string, domHtml: string): void;
|
|
149
|
+
/** Clear all recorded data (used during full rebuild). */
|
|
150
|
+
clear(): void;
|
|
151
|
+
/** Clear only component classifications (preserves divergences). */
|
|
152
|
+
clearComponents(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Generate per-component classification log lines.
|
|
155
|
+
* Used by the build pipeline and VERTZ_DEBUG=aot logging.
|
|
156
|
+
*
|
|
157
|
+
* Returns lines like:
|
|
158
|
+
* - "Header: static"
|
|
159
|
+
* - "Dashboard: conditional, 1 hole (SidePanel)"
|
|
160
|
+
* - "Coverage: 3/4 components (75%)"
|
|
161
|
+
*/
|
|
162
|
+
getClassificationLog(): string[];
|
|
163
|
+
/** Produce a JSON-serializable snapshot for the diagnostic endpoint. */
|
|
164
|
+
getSnapshot(): AotDiagnosticsSnapshot;
|
|
165
|
+
}
|
|
166
|
+
import { CompiledRoute, FontFallbackMetrics, Theme } from "@vertz/ui";
|
|
167
|
+
import { SSRAuth as SSRAuth_jq1nwm } from "@vertz/ui/internals";
|
|
168
|
+
interface SSRModule {
|
|
169
|
+
default?: () => unknown;
|
|
170
|
+
App?: () => unknown;
|
|
171
|
+
theme?: Theme;
|
|
172
|
+
/** Global CSS strings to include in every SSR response (e.g. resets, body styles). */
|
|
173
|
+
styles?: string[];
|
|
174
|
+
/**
|
|
175
|
+
* Return all CSS tracked by the bundled @vertz/ui instance.
|
|
176
|
+
* The Vite SSR build inlines @vertz/ui into the server bundle, creating
|
|
177
|
+
* a separate module instance from @vertz/ui-server's dependency. Without
|
|
178
|
+
* this, component CSS from module-level css() calls is invisible to the
|
|
179
|
+
* SSR renderer. Export `getInjectedCSS` from @vertz/ui in the app entry.
|
|
180
|
+
*/
|
|
181
|
+
getInjectedCSS?: () => string[];
|
|
182
|
+
/** Compiled routes exported from the app for build-time SSG with generateParams. */
|
|
183
|
+
routes?: CompiledRoute[];
|
|
184
|
+
/** Code-generated API client for manifest-driven zero-discovery prefetching. */
|
|
185
|
+
api?: Record<string, Record<string, (...args: unknown[]) => unknown>>;
|
|
186
|
+
}
|
|
187
|
+
interface SSRRenderResult {
|
|
188
|
+
html: string;
|
|
189
|
+
css: string;
|
|
190
|
+
ssrData: Array<{
|
|
191
|
+
key: string;
|
|
192
|
+
data: unknown;
|
|
193
|
+
}>;
|
|
194
|
+
/** Font preload link tags for injection into <head>. */
|
|
195
|
+
headTags: string;
|
|
196
|
+
/** Route patterns discovered by createRouter() during SSR (for build-time pre-rendering). */
|
|
197
|
+
discoveredRoutes?: string[];
|
|
198
|
+
/** Route patterns that matched the current URL (for per-route modulepreload). */
|
|
199
|
+
matchedRoutePatterns?: string[];
|
|
200
|
+
/** Set when ProtectedRoute writes a redirect during SSR. Server should return 302. */
|
|
201
|
+
redirect?: {
|
|
202
|
+
to: string;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
interface SSRDiscoverResult {
|
|
206
|
+
resolved: Array<{
|
|
207
|
+
key: string;
|
|
208
|
+
data: unknown;
|
|
209
|
+
}>;
|
|
210
|
+
pending: string[];
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Render an SSR module to an HTML string with CSS and pre-fetched query data.
|
|
214
|
+
*
|
|
215
|
+
* Performs a two-pass render:
|
|
216
|
+
* - Pass 1: Discovery — calls the app to trigger query() registrations, awaits them
|
|
217
|
+
* - Pass 2: Render — calls the app again with data populated, renders to HTML
|
|
218
|
+
*/
|
|
219
|
+
declare function ssrRenderToString(module: SSRModule, url: string, options?: {
|
|
220
|
+
ssrTimeout?: number;
|
|
221
|
+
/** Pre-computed font fallback metrics (computed at server startup). */
|
|
222
|
+
fallbackMetrics?: Record<string, FontFallbackMetrics>;
|
|
223
|
+
/** Auth state resolved from session cookie. Passed to SSRRenderContext for AuthProvider. */
|
|
224
|
+
ssrAuth?: SSRAuth_jq1nwm;
|
|
225
|
+
}): Promise<SSRRenderResult>;
|
|
226
|
+
/**
|
|
227
|
+
* Discover queries for a given URL without rendering.
|
|
228
|
+
* Runs only Pass 1 (query registration + resolution), no Pass 2 render.
|
|
229
|
+
* Used by the production handler to pre-fetch query data for client-side navigations.
|
|
230
|
+
*/
|
|
231
|
+
declare function ssrDiscoverQueries(module: SSRModule, url: string, options?: {
|
|
232
|
+
ssrTimeout?: number;
|
|
233
|
+
}): Promise<SSRDiscoverResult>;
|
|
234
|
+
import { FontFallbackMetrics as FontFallbackMetrics2 } from "@vertz/ui";
|
|
235
|
+
import { SSRAuth } from "@vertz/ui/internals";
|
|
236
|
+
import { ExtractedQuery } from "@vertz/ui-compiler";
|
|
165
237
|
/** Serialized entity access rules from the prefetch manifest. */
|
|
166
238
|
type EntityAccessMap = Record<string, Partial<Record<string, SerializedAccessRule>>>;
|
|
167
239
|
interface SSRPrefetchManifest {
|
|
@@ -199,6 +271,90 @@ interface SSRSinglePassOptions {
|
|
|
199
271
|
* - A redirect is detected during discovery
|
|
200
272
|
*/
|
|
201
273
|
declare function ssrRenderSinglePass(module: SSRModule, url: string, options?: SSRSinglePassOptions): Promise<SSRRenderResult>;
|
|
274
|
+
/** Context passed to AOT render functions for accessing data and runtime holes. */
|
|
275
|
+
interface SSRAotContext {
|
|
276
|
+
/** Pre-generated closures for runtime-rendered components. */
|
|
277
|
+
holes: Record<string, () => string>;
|
|
278
|
+
/** Access query data by cache key. */
|
|
279
|
+
getData(key: string): unknown;
|
|
280
|
+
/** Auth session for conditional rendering. */
|
|
281
|
+
session: PrefetchSession | undefined;
|
|
282
|
+
/** Route params for the current request. */
|
|
283
|
+
params: Record<string, string>;
|
|
284
|
+
}
|
|
285
|
+
/** An AOT render function: takes props/data and context, returns HTML string. */
|
|
286
|
+
type AotRenderFn = (data: Record<string, unknown>, ctx: SSRAotContext) => string;
|
|
287
|
+
/** Per-route AOT entry in the manifest. */
|
|
288
|
+
interface AotRouteEntry {
|
|
289
|
+
/** The pre-compiled render function. */
|
|
290
|
+
render: AotRenderFn;
|
|
291
|
+
/** Component names that need runtime fallback (holes). */
|
|
292
|
+
holes: string[];
|
|
293
|
+
/** Query cache keys this route reads via ctx.getData(). */
|
|
294
|
+
queryKeys?: string[];
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* AOT manifest — maps route patterns to pre-compiled render functions.
|
|
298
|
+
*
|
|
299
|
+
* Generated at build time by the AOT compiler pipeline.
|
|
300
|
+
*/
|
|
301
|
+
interface AotManifest {
|
|
302
|
+
/** Route pattern → AOT entry. */
|
|
303
|
+
routes: Record<string, AotRouteEntry>;
|
|
304
|
+
}
|
|
305
|
+
/** Options for `ssrRenderAot()`. */
|
|
306
|
+
interface SSRRenderAotOptions {
|
|
307
|
+
/** AOT manifest with pre-compiled render functions. */
|
|
308
|
+
aotManifest: AotManifest;
|
|
309
|
+
/** Prefetch manifest for route matching and data fetching. */
|
|
310
|
+
manifest?: SSRPrefetchManifest;
|
|
311
|
+
/** SSR timeout in ms. */
|
|
312
|
+
ssrTimeout?: number;
|
|
313
|
+
/** Pre-computed font fallback metrics. */
|
|
314
|
+
fallbackMetrics?: Record<string, FontFallbackMetrics3>;
|
|
315
|
+
/** Auth state resolved from session cookie. */
|
|
316
|
+
ssrAuth?: SSRAuth2;
|
|
317
|
+
/** Session data for access rule evaluation. */
|
|
318
|
+
prefetchSession?: PrefetchSession;
|
|
319
|
+
/** AOT diagnostics collector (dev mode). When provided with VERTZ_DEBUG=aot, enables dual rendering and divergence detection. */
|
|
320
|
+
diagnostics?: AotDiagnostics;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Create closure-based runtime fallback renderers for components
|
|
324
|
+
* that cannot be AOT-compiled.
|
|
325
|
+
*
|
|
326
|
+
* Each hole closure:
|
|
327
|
+
* 1. Runs inside `ssrStorage.run()` to provide SSRRenderContext
|
|
328
|
+
* 2. Calls the component factory via the SSR module
|
|
329
|
+
* 3. Converts the result to VNode and serializes to HTML string
|
|
330
|
+
* 4. Shares the query cache with the AOT function
|
|
331
|
+
*
|
|
332
|
+
* @param holeNames - Component names that need runtime rendering
|
|
333
|
+
* @param module - SSR module with component factories
|
|
334
|
+
* @param url - Request URL for context
|
|
335
|
+
* @param queryCache - Pre-populated query cache (shared with AOT)
|
|
336
|
+
* @param ssrAuth - Auth state for the request
|
|
337
|
+
*/
|
|
338
|
+
declare function createHoles(holeNames: string[], module: SSRModule, url: string, queryCache: Map<string, unknown>, ssrAuth?: SSRAuth2): Record<string, () => string>;
|
|
339
|
+
/**
|
|
340
|
+
* Render a page using pre-compiled AOT string-builder functions.
|
|
341
|
+
*
|
|
342
|
+
* Falls back to `ssrRenderSinglePass()` when:
|
|
343
|
+
* - No route match in the AOT manifest
|
|
344
|
+
* - No prefetch manifest for route matching
|
|
345
|
+
*
|
|
346
|
+
* Pipeline:
|
|
347
|
+
* 1. Match URL to route pattern
|
|
348
|
+
* 2. Look up AOT entry in manifest
|
|
349
|
+
* 3. Prefetch query data (reuses single-pass prefetch logic)
|
|
350
|
+
* 4. Create runtime holes (closures for non-AOT components)
|
|
351
|
+
* 5. Call AOT render function with data + context
|
|
352
|
+
* 6. Collect CSS, ssrData, headTags
|
|
353
|
+
* 7. Return SSRRenderResult
|
|
354
|
+
*/
|
|
355
|
+
declare function ssrRenderAot(module: SSRModule, url: string, options: SSRRenderAotOptions): Promise<SSRRenderResult>;
|
|
356
|
+
/** Check if VERTZ_DEBUG includes the 'aot' category. */
|
|
357
|
+
declare function isAotDebugEnabled(): boolean;
|
|
202
358
|
import { AccessSet } from "@vertz/ui/auth";
|
|
203
359
|
interface SessionData {
|
|
204
360
|
user: {
|
|
@@ -260,7 +416,7 @@ interface SSRHandlerOptions {
|
|
|
260
416
|
*/
|
|
261
417
|
nonce?: string;
|
|
262
418
|
/** Pre-computed font fallback metrics (computed at server startup). */
|
|
263
|
-
fallbackMetrics?: Record<string,
|
|
419
|
+
fallbackMetrics?: Record<string, FontFallbackMetrics4>;
|
|
264
420
|
/** Paths to inject as `<link rel="modulepreload">` in `<head>`. */
|
|
265
421
|
modulepreload?: string[];
|
|
266
422
|
/**
|
|
@@ -299,23 +455,91 @@ interface SSRHandlerOptions {
|
|
|
299
455
|
* which always use buffered rendering.
|
|
300
456
|
*/
|
|
301
457
|
progressiveHTML?: boolean;
|
|
458
|
+
/**
|
|
459
|
+
* AOT manifest with pre-compiled render functions.
|
|
460
|
+
*
|
|
461
|
+
* When provided, routes matching AOT entries are rendered via string-builder
|
|
462
|
+
* functions (no DOM shim), bypassing the reactive runtime for 4-6x speedup.
|
|
463
|
+
* Routes not in the manifest fall back to `ssrRenderSinglePass()`.
|
|
464
|
+
*
|
|
465
|
+
* Load via `loadAotManifest(serverDir)` at startup.
|
|
466
|
+
*/
|
|
467
|
+
aotManifest?: AotManifest;
|
|
302
468
|
}
|
|
303
469
|
declare function createSSRHandler(options: SSRHandlerOptions): (request: Request) => Promise<Response>;
|
|
304
470
|
type NodeHandlerOptions = SSRHandlerOptions;
|
|
305
471
|
declare function createNodeHandler(options: NodeHandlerOptions): (req: IncomingMessage, res: ServerResponse) => void;
|
|
306
472
|
import { FallbackFontName as FallbackFontName2, FontFallbackMetrics as FontFallbackMetrics7 } from "@vertz/ui";
|
|
473
|
+
import { ExtractedRoute } from "@vertz/ui-compiler";
|
|
474
|
+
import { extractRoutes } from "@vertz/ui-compiler";
|
|
475
|
+
import { AotComponentInfo } from "@vertz/ui-compiler";
|
|
307
476
|
interface AotBuildComponentEntry {
|
|
308
477
|
tier: "static" | "data-driven" | "conditional" | "runtime-fallback";
|
|
309
478
|
holes: string[];
|
|
479
|
+
queryKeys: string[];
|
|
480
|
+
}
|
|
481
|
+
/** Compiled file output from AOT compilation. */
|
|
482
|
+
interface AotCompiledFile {
|
|
483
|
+
/** Transformed source code containing __ssr_* functions. */
|
|
484
|
+
code: string;
|
|
485
|
+
/** Per-component AOT info from the compilation. */
|
|
486
|
+
components: AotComponentInfo[];
|
|
487
|
+
}
|
|
488
|
+
/** Route map entry for the AOT manifest JSON. */
|
|
489
|
+
interface AotRouteMapEntry {
|
|
490
|
+
/** Name of the __ssr_* render function (e.g., '__ssr_HomePage'). */
|
|
491
|
+
renderFn: string;
|
|
492
|
+
/** Component names that need runtime fallback rendering. */
|
|
493
|
+
holes: string[];
|
|
494
|
+
/** Query cache keys this route reads via ctx.getData(). */
|
|
495
|
+
queryKeys: string[];
|
|
310
496
|
}
|
|
311
497
|
interface AotBuildManifest {
|
|
312
498
|
components: Record<string, AotBuildComponentEntry>;
|
|
499
|
+
/** Compiled files keyed by source file path. */
|
|
500
|
+
compiledFiles: Record<string, AotCompiledFile>;
|
|
313
501
|
classificationLog: string[];
|
|
314
502
|
}
|
|
315
503
|
/**
|
|
316
504
|
* Scan all TSX files in srcDir and generate an AOT build manifest.
|
|
317
505
|
*/
|
|
318
506
|
declare function generateAotBuildManifest(srcDir: string): AotBuildManifest;
|
|
507
|
+
/**
|
|
508
|
+
* Build AOT route map — maps route patterns to render function names.
|
|
509
|
+
*
|
|
510
|
+
* Skips routes for runtime-fallback components (they can't be AOT-rendered)
|
|
511
|
+
* and routes for unknown components (not found in AOT manifest).
|
|
512
|
+
*/
|
|
513
|
+
declare function buildAotRouteMap(components: Record<string, AotBuildComponentEntry>, routes: Array<{
|
|
514
|
+
pattern: string;
|
|
515
|
+
componentName: string;
|
|
516
|
+
}>): Record<string, AotRouteMapEntry>;
|
|
517
|
+
/** Result of barrel generation — barrel source + file mapping for temp dir. */
|
|
518
|
+
interface AotBarrelResult {
|
|
519
|
+
/** Barrel module source code (import/re-statements). */
|
|
520
|
+
barrelSource: string;
|
|
521
|
+
/**
|
|
522
|
+
* Mapping of temp file names → compiled source code.
|
|
523
|
+
* Write each entry as `<tempDir>/<filename>.ts` alongside the barrel.
|
|
524
|
+
*/
|
|
525
|
+
files: Record<string, string>;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Generate a barrel module that re-exports __ssr_* functions from compiled files.
|
|
529
|
+
*
|
|
530
|
+
* Returns the barrel source code and a mapping of temp filenames → compiled code
|
|
531
|
+
* that must be written alongside the barrel for bundling.
|
|
532
|
+
*/
|
|
533
|
+
declare function generateAotBarrel(compiledFiles: Record<string, AotCompiledFile>, routeMap: Record<string, AotRouteMapEntry>): AotBarrelResult;
|
|
534
|
+
/**
|
|
535
|
+
* Load AOT manifest and routes module from a server build directory.
|
|
536
|
+
*
|
|
537
|
+
* Returns `null` if either `aot-manifest.json` or `aot-routes.js` is missing,
|
|
538
|
+
* or if no routes can be wired to render functions.
|
|
539
|
+
*
|
|
540
|
+
* @param serverDir - Path to `dist/server/` directory
|
|
541
|
+
*/
|
|
542
|
+
declare function loadAotManifest(serverDir: string): Promise<AotManifest | null>;
|
|
319
543
|
/** A raw HTML string that bypasses escaping during serialization. */
|
|
320
544
|
interface RawHtml {
|
|
321
545
|
__raw: true;
|
|
@@ -398,7 +622,7 @@ declare function renderAssetTags(assets: AssetDescriptor[]): string;
|
|
|
398
622
|
* Returns an empty string if the CSS is empty.
|
|
399
623
|
*/
|
|
400
624
|
declare function inlineCriticalCss(css: string): string;
|
|
401
|
-
import { FallbackFontName, FontDescriptor, FontFallbackMetrics as
|
|
625
|
+
import { FallbackFontName, FontDescriptor, FontFallbackMetrics as FontFallbackMetrics5 } from "@vertz/ui";
|
|
402
626
|
/**
|
|
403
627
|
* Auto-detect which system font to use as fallback base.
|
|
404
628
|
*
|
|
@@ -418,7 +642,7 @@ declare function detectFallbackFont(fallback: readonly string[]): FallbackFontNa
|
|
|
418
642
|
* @param rootDir - Project root directory for resolving font file paths.
|
|
419
643
|
* @returns Map of font key → computed fallback metrics.
|
|
420
644
|
*/
|
|
421
|
-
declare function extractFontMetrics(fonts: Record<string, FontDescriptor>, rootDir: string): Promise<Record<string,
|
|
645
|
+
declare function extractFontMetrics(fonts: Record<string, FontDescriptor>, rootDir: string): Promise<Record<string, FontFallbackMetrics5>>;
|
|
422
646
|
/**
|
|
423
647
|
* Collector for `<head>` metadata during SSR.
|
|
424
648
|
*
|
|
@@ -529,7 +753,7 @@ interface PageOptions {
|
|
|
529
753
|
* ```
|
|
530
754
|
*/
|
|
531
755
|
declare function renderPage(vnode: VNode, options?: PageOptions): Response;
|
|
532
|
-
import { FontFallbackMetrics as
|
|
756
|
+
import { FontFallbackMetrics as FontFallbackMetrics6, Theme as Theme2 } from "@vertz/ui";
|
|
533
757
|
interface RenderToHTMLOptions<AppFn extends () => VNode> {
|
|
534
758
|
/** The app component function */
|
|
535
759
|
app: AppFn;
|
|
@@ -555,7 +779,7 @@ interface RenderToHTMLOptions<AppFn extends () => VNode> {
|
|
|
555
779
|
/** Container selector (default '#app') */
|
|
556
780
|
container?: string;
|
|
557
781
|
/** Pre-computed font fallback metrics (computed at server startup). */
|
|
558
|
-
fallbackMetrics?: Record<string,
|
|
782
|
+
fallbackMetrics?: Record<string, FontFallbackMetrics6>;
|
|
559
783
|
}
|
|
560
784
|
interface RenderToHTMLStreamOptions<AppFn extends () => VNode> extends RenderToHTMLOptions<AppFn> {
|
|
561
785
|
/** CSP nonce for inline scripts */
|
|
@@ -660,76 +884,6 @@ import { RenderAdapter } from "@vertz/ui/internals";
|
|
|
660
884
|
* Replaces `installDomShim()` — no global mutation needed.
|
|
661
885
|
*/
|
|
662
886
|
declare function createSSRAdapter(): RenderAdapter;
|
|
663
|
-
/**
|
|
664
|
-
* AOT SSR Diagnostics
|
|
665
|
-
*
|
|
666
|
-
* Tracks AOT compilation results and provides a JSON snapshot
|
|
667
|
-
* for the `/__vertz_ssr_aot` dev endpoint.
|
|
668
|
-
*/
|
|
669
|
-
/** AOT tier classification (mirrored from @vertz/ui-compiler to avoid cross-package dependency). */
|
|
670
|
-
type AotTier = "static" | "data-driven" | "conditional" | "runtime-fallback";
|
|
671
|
-
/** Per-component diagnostic entry in the snapshot. */
|
|
672
|
-
interface AotComponentDiagnostic {
|
|
673
|
-
tier: AotTier;
|
|
674
|
-
holes: string[];
|
|
675
|
-
}
|
|
676
|
-
/** A recorded divergence between AOT and DOM shim output. */
|
|
677
|
-
interface AotDivergenceEntry {
|
|
678
|
-
component: string;
|
|
679
|
-
aotHtml: string;
|
|
680
|
-
domHtml: string;
|
|
681
|
-
timestamp: string;
|
|
682
|
-
}
|
|
683
|
-
/** JSON snapshot returned by the `/__vertz_ssr_aot` endpoint. */
|
|
684
|
-
interface AotDiagnosticsSnapshot {
|
|
685
|
-
components: Record<string, AotComponentDiagnostic>;
|
|
686
|
-
coverage: {
|
|
687
|
-
total: number;
|
|
688
|
-
aot: number;
|
|
689
|
-
runtime: number;
|
|
690
|
-
percentage: number;
|
|
691
|
-
};
|
|
692
|
-
divergences: AotDivergenceEntry[];
|
|
693
|
-
}
|
|
694
|
-
/** Input shape matching AotComponentInfo from @vertz/ui-compiler. */
|
|
695
|
-
interface ComponentInput {
|
|
696
|
-
name: string;
|
|
697
|
-
tier: AotTier;
|
|
698
|
-
holes: string[];
|
|
699
|
-
}
|
|
700
|
-
/**
|
|
701
|
-
* Collects AOT compilation diagnostics and produces JSON snapshots.
|
|
702
|
-
*
|
|
703
|
-
* Used by the dev server to power the `/__vertz_ssr_aot` endpoint
|
|
704
|
-
* and by the build pipeline for classification logging.
|
|
705
|
-
*/
|
|
706
|
-
declare class AotDiagnostics {
|
|
707
|
-
private _components;
|
|
708
|
-
private _divergences;
|
|
709
|
-
/**
|
|
710
|
-
* Record components from an AOT compilation result.
|
|
711
|
-
* Called once per file during compilation or hot rebuild.
|
|
712
|
-
*/
|
|
713
|
-
recordCompilation(components: ComponentInput[]): void;
|
|
714
|
-
/** Record a divergence between AOT and DOM shim HTML output. */
|
|
715
|
-
recordDivergence(component: string, aotHtml: string, domHtml: string): void;
|
|
716
|
-
/** Clear all recorded data (used during full rebuild). */
|
|
717
|
-
clear(): void;
|
|
718
|
-
/** Clear only component classifications (preserves divergences). */
|
|
719
|
-
clearComponents(): void;
|
|
720
|
-
/**
|
|
721
|
-
* Generate per-component classification log lines.
|
|
722
|
-
* Used by the build pipeline and VERTZ_DEBUG=aot logging.
|
|
723
|
-
*
|
|
724
|
-
* Returns lines like:
|
|
725
|
-
* - "Header: static"
|
|
726
|
-
* - "Dashboard: conditional, 1 hole (SidePanel)"
|
|
727
|
-
* - "Coverage: 3/4 components (75%)"
|
|
728
|
-
*/
|
|
729
|
-
getClassificationLog(): string[];
|
|
730
|
-
/** Produce a JSON-serializable snapshot for the diagnostic endpoint. */
|
|
731
|
-
getSnapshot(): AotDiagnosticsSnapshot;
|
|
732
|
-
}
|
|
733
887
|
/** Per-component entry in the dev AOT manifest. */
|
|
734
888
|
interface AotDevComponentEntry {
|
|
735
889
|
tier: "static" | "data-driven" | "conditional" | "runtime-fallback";
|
|
@@ -766,92 +920,6 @@ interface AotManifestManager {
|
|
|
766
920
|
getDiagnostics(): AotDiagnostics;
|
|
767
921
|
}
|
|
768
922
|
declare function createAotManifestManager(options: AotManifestManagerOptions): AotManifestManager;
|
|
769
|
-
import { FontFallbackMetrics as FontFallbackMetrics6 } from "@vertz/ui";
|
|
770
|
-
import { SSRAuth as SSRAuth2 } from "@vertz/ui/internals";
|
|
771
|
-
/** Context passed to AOT render functions for accessing data and runtime holes. */
|
|
772
|
-
interface SSRAotContext {
|
|
773
|
-
/** Pre-generated closures for runtime-rendered components. */
|
|
774
|
-
holes: Record<string, () => string>;
|
|
775
|
-
/** Access query data by cache key. */
|
|
776
|
-
getData(key: string): unknown;
|
|
777
|
-
/** Auth session for conditional rendering. */
|
|
778
|
-
session: PrefetchSession | undefined;
|
|
779
|
-
/** Route params for the current request. */
|
|
780
|
-
params: Record<string, string>;
|
|
781
|
-
}
|
|
782
|
-
/** An AOT render function: takes props/data and context, returns HTML string. */
|
|
783
|
-
type AotRenderFn = (data: Record<string, unknown>, ctx: SSRAotContext) => string;
|
|
784
|
-
/** Per-route AOT entry in the manifest. */
|
|
785
|
-
interface AotRouteEntry {
|
|
786
|
-
/** The pre-compiled render function. */
|
|
787
|
-
render: AotRenderFn;
|
|
788
|
-
/** Component names that need runtime fallback (holes). */
|
|
789
|
-
holes: string[];
|
|
790
|
-
/** Query cache keys this route reads via ctx.getData(). */
|
|
791
|
-
queryKeys?: string[];
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* AOT manifest — maps route patterns to pre-compiled render functions.
|
|
795
|
-
*
|
|
796
|
-
* Generated at build time by the AOT compiler pipeline.
|
|
797
|
-
*/
|
|
798
|
-
interface AotManifest {
|
|
799
|
-
/** Route pattern → AOT entry. */
|
|
800
|
-
routes: Record<string, AotRouteEntry>;
|
|
801
|
-
}
|
|
802
|
-
/** Options for `ssrRenderAot()`. */
|
|
803
|
-
interface SSRRenderAotOptions {
|
|
804
|
-
/** AOT manifest with pre-compiled render functions. */
|
|
805
|
-
aotManifest: AotManifest;
|
|
806
|
-
/** Prefetch manifest for route matching and data fetching. */
|
|
807
|
-
manifest?: SSRPrefetchManifest;
|
|
808
|
-
/** SSR timeout in ms. */
|
|
809
|
-
ssrTimeout?: number;
|
|
810
|
-
/** Pre-computed font fallback metrics. */
|
|
811
|
-
fallbackMetrics?: Record<string, FontFallbackMetrics6>;
|
|
812
|
-
/** Auth state resolved from session cookie. */
|
|
813
|
-
ssrAuth?: SSRAuth2;
|
|
814
|
-
/** Session data for access rule evaluation. */
|
|
815
|
-
prefetchSession?: PrefetchSession;
|
|
816
|
-
/** AOT diagnostics collector (dev mode). When provided with VERTZ_DEBUG=aot, enables dual rendering and divergence detection. */
|
|
817
|
-
diagnostics?: AotDiagnostics;
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* Create closure-based runtime fallback renderers for components
|
|
821
|
-
* that cannot be AOT-compiled.
|
|
822
|
-
*
|
|
823
|
-
* Each hole closure:
|
|
824
|
-
* 1. Runs inside `ssrStorage.run()` to provide SSRRenderContext
|
|
825
|
-
* 2. Calls the component factory via the SSR module
|
|
826
|
-
* 3. Converts the result to VNode and serializes to HTML string
|
|
827
|
-
* 4. Shares the query cache with the AOT function
|
|
828
|
-
*
|
|
829
|
-
* @param holeNames - Component names that need runtime rendering
|
|
830
|
-
* @param module - SSR module with component factories
|
|
831
|
-
* @param url - Request URL for context
|
|
832
|
-
* @param queryCache - Pre-populated query cache (shared with AOT)
|
|
833
|
-
* @param ssrAuth - Auth state for the request
|
|
834
|
-
*/
|
|
835
|
-
declare function createHoles(holeNames: string[], module: SSRModule, url: string, queryCache: Map<string, unknown>, ssrAuth?: SSRAuth2): Record<string, () => string>;
|
|
836
|
-
/**
|
|
837
|
-
* Render a page using pre-compiled AOT string-builder functions.
|
|
838
|
-
*
|
|
839
|
-
* Falls back to `ssrRenderSinglePass()` when:
|
|
840
|
-
* - No route match in the AOT manifest
|
|
841
|
-
* - No prefetch manifest for route matching
|
|
842
|
-
*
|
|
843
|
-
* Pipeline:
|
|
844
|
-
* 1. Match URL to route pattern
|
|
845
|
-
* 2. Look up AOT entry in manifest
|
|
846
|
-
* 3. Prefetch query data (reuses single-pass prefetch logic)
|
|
847
|
-
* 4. Create runtime holes (closures for non-AOT components)
|
|
848
|
-
* 5. Call AOT render function with data + context
|
|
849
|
-
* 6. Collect CSS, ssrData, headTags
|
|
850
|
-
* 7. Return SSRRenderResult
|
|
851
|
-
*/
|
|
852
|
-
declare function ssrRenderAot(module: SSRModule, url: string, options: SSRRenderAotOptions): Promise<SSRRenderResult>;
|
|
853
|
-
/** Check if VERTZ_DEBUG includes the 'aot' category. */
|
|
854
|
-
declare function isAotDebugEnabled(): boolean;
|
|
855
923
|
/**
|
|
856
924
|
* SSR AOT Runtime Helpers
|
|
857
925
|
*
|
|
@@ -1058,4 +1126,4 @@ declare function collectStreamChunks(stream: ReadableStream<Uint8Array>): Promis
|
|
|
1058
1126
|
* @param nonce - Optional CSP nonce to add to the inline script tag.
|
|
1059
1127
|
*/
|
|
1060
1128
|
declare function createTemplateChunk(slotId: number, resolvedHtml: string, nonce?: string): string;
|
|
1061
|
-
export { wrapWithHydrationMarkers, toPrefetchSession, streamToString, ssrStorage, ssrRenderToString, ssrRenderSinglePass, ssrRenderAot, ssrDiscoverQueries, setGlobalSSRTimeout, serializeToHtml, safeSerialize, resetSlotCounter, renderToStream, renderToHTMLStream, renderToHTML, renderPage, renderHeadToHtml, renderAssetTags, registerSSRQuery, reconstructDescriptors, rawHtml, matchUrlToPatterns, isInSSR, isAotDebugEnabled, inlineCriticalCss, getStreamingRuntimeScript, getSSRUrl, getSSRQueries, getGlobalSSRTimeout, getAccessSetForSSR, generateSSRHtml, generateAotBuildManifest, extractFontMetrics, evaluateAccessRule, encodeChunk, detectFallbackFont, createTemplateChunk, createSlotPlaceholder, createSessionScript, createSSRHandler, createSSRDataChunk, createSSRAdapter, createPrefetchManifestManager, createNodeHandler, createHoles, createAotManifestManager, createAccessSetScript, collectStreamChunks, clearGlobalSSRTimeout, __ssr_style_object, __ssr_spread, __esc_attr, __esc, VNode, SessionResolver, SessionData, SerializedAccessRule, SSRSinglePassOptions, SSRSessionInfo, SSRRenderResult, SSRRenderAotOptions, SSRQueryEntry2 as SSRQueryEntry, SSRPrefetchManifest, SSRModule, SSRHandlerOptions, SSRDiscoverResult, SSRAotContext, RenderToStreamOptions, RenderToHTMLStreamOptions, RenderToHTMLOptions, ReconstructedDescriptor, RawHtml, PrefetchSession, PrefetchManifestSnapshot, PrefetchManifestManagerOptions, PrefetchManifestManager, PageOptions, NodeHandlerOptions, MatchedRoute, HydrationOptions, HeadEntry, HeadCollector, GenerateSSRHtmlOptions, FontFallbackMetrics7 as FontFallbackMetrics, FallbackFontName2 as FallbackFontName, EntityAccessMap, AssetDescriptor, AotTier, AotRouteEntry, AotRenderFn, AotManifestSnapshot, AotManifestManagerOptions, AotManifestManager, AotManifest, AotDivergenceEntry, AotDiagnosticsSnapshot, AotDiagnostics, AotDevManifest, AotDevComponentEntry, AotComponentDiagnostic, AotBuildManifest, AotBuildComponentEntry };
|
|
1129
|
+
export { wrapWithHydrationMarkers, toPrefetchSession, streamToString, ssrStorage, ssrRenderToString, ssrRenderSinglePass, ssrRenderAot, ssrDiscoverQueries, setGlobalSSRTimeout, serializeToHtml, safeSerialize, resetSlotCounter, renderToStream, renderToHTMLStream, renderToHTML, renderPage, renderHeadToHtml, renderAssetTags, registerSSRQuery, reconstructDescriptors, rawHtml, matchUrlToPatterns, loadAotManifest, isInSSR, isAotDebugEnabled, inlineCriticalCss, getStreamingRuntimeScript, getSSRUrl, getSSRQueries, getGlobalSSRTimeout, getAccessSetForSSR, generateSSRHtml, generateAotBuildManifest, generateAotBarrel, extractRoutes, extractFontMetrics, evaluateAccessRule, encodeChunk, detectFallbackFont, createTemplateChunk, createSlotPlaceholder, createSessionScript, createSSRHandler, createSSRDataChunk, createSSRAdapter, createPrefetchManifestManager, createNodeHandler, createHoles, createAotManifestManager, createAccessSetScript, collectStreamChunks, clearGlobalSSRTimeout, buildAotRouteMap, __ssr_style_object, __ssr_spread, __esc_attr, __esc, VNode, SessionResolver, SessionData, SerializedAccessRule, SSRSinglePassOptions, SSRSessionInfo, SSRRenderResult, SSRRenderAotOptions, SSRQueryEntry2 as SSRQueryEntry, SSRPrefetchManifest, SSRModule, SSRHandlerOptions, SSRDiscoverResult, SSRAotContext, RenderToStreamOptions, RenderToHTMLStreamOptions, RenderToHTMLOptions, ReconstructedDescriptor, RawHtml, PrefetchSession, PrefetchManifestSnapshot, PrefetchManifestManagerOptions, PrefetchManifestManager, PageOptions, NodeHandlerOptions, MatchedRoute, HydrationOptions, HeadEntry, HeadCollector, GenerateSSRHtmlOptions, FontFallbackMetrics7 as FontFallbackMetrics, FallbackFontName2 as FallbackFontName, ExtractedRoute, EntityAccessMap, AssetDescriptor, AotTier, AotRouteMapEntry, AotRouteEntry, AotRenderFn, AotManifestSnapshot, AotManifestManagerOptions, AotManifestManager, AotManifest, AotDivergenceEntry, AotDiagnosticsSnapshot, AotDiagnostics, AotDevManifest, AotDevComponentEntry, AotComponentDiagnostic, AotCompiledFile, AotBuildManifest, AotBuildComponentEntry, AotBarrelResult };
|