@vertz/ui-server 0.2.42 → 0.2.43
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/dist/bun-dev-server.js +188 -318
- package/dist/index.d.ts +21 -38
- package/dist/index.js +5 -7
- package/dist/node-handler.js +2 -2
- package/dist/shared/{chunk-tnsz18ac.js → chunk-05hadnnd.js} +1 -1
- package/dist/shared/{chunk-r1pf7cf2.js → chunk-1v0wakka.js} +188 -365
- package/dist/shared/{chunk-phe490jc.js → chunk-hd03dkxf.js} +1 -1
- package/dist/ssr/index.d.ts +48 -32
- package/dist/ssr/index.js +8 -8
- package/package.json +1 -1
package/dist/ssr/index.d.ts
CHANGED
|
@@ -49,8 +49,7 @@ type PrefetchSession = {
|
|
|
49
49
|
} | {
|
|
50
50
|
status: "unauthenticated";
|
|
51
51
|
};
|
|
52
|
-
import { CompiledRoute,
|
|
53
|
-
import { SSRAuth as SSRAuth_jq1nwm } from "@vertz/ui/internals";
|
|
52
|
+
import { CompiledRoute, Theme } from "@vertz/ui";
|
|
54
53
|
interface SSRModule {
|
|
55
54
|
default?: () => unknown;
|
|
56
55
|
App?: () => unknown;
|
|
@@ -88,35 +87,8 @@ interface SSRRenderResult {
|
|
|
88
87
|
to: string;
|
|
89
88
|
};
|
|
90
89
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
key: string;
|
|
94
|
-
data: unknown;
|
|
95
|
-
}>;
|
|
96
|
-
pending: string[];
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Render an SSR module to an HTML string with CSS and pre-fetched query data.
|
|
100
|
-
*
|
|
101
|
-
* Performs a two-pass render:
|
|
102
|
-
* - Pass 1: Discovery — calls the app to trigger query() registrations, awaits them
|
|
103
|
-
* - Pass 2: Render — calls the app again with data populated, renders to HTML
|
|
104
|
-
*/
|
|
105
|
-
declare function ssrRenderToString(module: SSRModule, url: string, options?: {
|
|
106
|
-
ssrTimeout?: number;
|
|
107
|
-
/** Pre-computed font fallback metrics (computed at server startup). */
|
|
108
|
-
fallbackMetrics?: Record<string, FontFallbackMetrics>;
|
|
109
|
-
/** Auth state resolved from session cookie. Passed to SSRRenderContext for AuthProvider. */
|
|
110
|
-
ssrAuth?: SSRAuth_jq1nwm;
|
|
111
|
-
}): Promise<SSRRenderResult>;
|
|
112
|
-
/**
|
|
113
|
-
* Discover queries for a given URL without rendering.
|
|
114
|
-
* Runs only Pass 1 (query registration + resolution), no Pass 2 render.
|
|
115
|
-
* Used by the production handler to pre-fetch query data for client-side navigations.
|
|
116
|
-
*/
|
|
117
|
-
declare function ssrDiscoverQueries(module: SSRModule, url: string, options?: {
|
|
118
|
-
ssrTimeout?: number;
|
|
119
|
-
}): Promise<SSRDiscoverResult>;
|
|
90
|
+
import { FontFallbackMetrics as FontFallbackMetrics2 } from "@vertz/ui";
|
|
91
|
+
import { SSRAuth } from "@vertz/ui/internals";
|
|
120
92
|
interface QueryBindings {
|
|
121
93
|
where?: Record<string, string | null>;
|
|
122
94
|
select?: Record<string, true>;
|
|
@@ -148,6 +120,50 @@ interface SSRPrefetchManifest {
|
|
|
148
120
|
queries: ExtractedQuery[];
|
|
149
121
|
}>;
|
|
150
122
|
}
|
|
123
|
+
interface SSRSinglePassOptions {
|
|
124
|
+
ssrTimeout?: number;
|
|
125
|
+
/** Pre-computed font fallback metrics (computed at server startup). */
|
|
126
|
+
fallbackMetrics?: Record<string, FontFallbackMetrics2>;
|
|
127
|
+
/** Auth state resolved from session cookie. */
|
|
128
|
+
ssrAuth?: SSRAuth;
|
|
129
|
+
/** Prefetch manifest for entity access filtering. */
|
|
130
|
+
manifest?: SSRPrefetchManifest;
|
|
131
|
+
/** Session data for access rule evaluation. */
|
|
132
|
+
prefetchSession?: PrefetchSession;
|
|
133
|
+
/**
|
|
134
|
+
* Raw Cookie header from the request.
|
|
135
|
+
* When set, `document.cookie` returns this value during SSR rendering,
|
|
136
|
+
* so app code that reads cookies works the same as in a browser.
|
|
137
|
+
*/
|
|
138
|
+
cookies?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Render an SSR module in a single pass via discovery-only execution.
|
|
142
|
+
*
|
|
143
|
+
* 1. Discovery: Run the app factory to capture query registrations (no stream render)
|
|
144
|
+
* 2. Prefetch: Await all discovered queries with timeout
|
|
145
|
+
* 3. Render: Create a fresh context with pre-populated cache, render once
|
|
146
|
+
*/
|
|
147
|
+
declare function ssrRenderSinglePass(module: SSRModule, url: string, options?: SSRSinglePassOptions): Promise<SSRRenderResult>;
|
|
148
|
+
/**
|
|
149
|
+
* Stream nav query results as individual SSE events.
|
|
150
|
+
*
|
|
151
|
+
* Returns a `ReadableStream` that emits each query result as it settles:
|
|
152
|
+
* - `event: data` for resolved queries (with key + data)
|
|
153
|
+
* - `event: done` when all queries have settled
|
|
154
|
+
*
|
|
155
|
+
* Timed-out or rejected queries are silently dropped (no event sent).
|
|
156
|
+
* The client's `doneHandler` detects missing data and falls back to
|
|
157
|
+
* client-side fetch.
|
|
158
|
+
*
|
|
159
|
+
* The render lock is released after query discovery, before
|
|
160
|
+
* streaming begins. This allows concurrent SSR renders while queries
|
|
161
|
+
* are still resolving.
|
|
162
|
+
*/
|
|
163
|
+
declare function ssrStreamNavQueries(module: SSRModule, url: string, options?: {
|
|
164
|
+
ssrTimeout?: number;
|
|
165
|
+
navSsrTimeout?: number;
|
|
166
|
+
}): Promise<ReadableStream<Uint8Array>>;
|
|
151
167
|
/** Context passed to AOT render functions for accessing data and runtime holes. */
|
|
152
168
|
interface SSRAotContext {
|
|
153
169
|
/** Pre-generated closures for runtime-rendered components. */
|
|
@@ -401,4 +417,4 @@ interface InjectIntoTemplateOptions {
|
|
|
401
417
|
* injects CSS before </head>, and ssrData before </body>.
|
|
402
418
|
*/
|
|
403
419
|
declare function injectIntoTemplate(options: InjectIntoTemplateOptions): string;
|
|
404
|
-
export { stripScriptsFromStaticHTML,
|
|
420
|
+
export { stripScriptsFromStaticHTML, ssrStreamNavQueries, ssrRenderSinglePass, prerenderRoutes, loadAotManifest, injectIntoTemplate, filterPrerenderableRoutes, discoverRoutes, createSSRHandler, collectPrerenderPaths, SSRRenderResult, SSRModule, SSRHandlerOptions, PrerenderResult, PrerenderOptions, AotManifest, AotDataResolver };
|
package/dist/ssr/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSSRHandler,
|
|
3
3
|
loadAotManifest
|
|
4
|
-
} from "../shared/chunk-
|
|
4
|
+
} from "../shared/chunk-05hadnnd.js";
|
|
5
5
|
import {
|
|
6
6
|
injectIntoTemplate,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "../shared/chunk-
|
|
7
|
+
ssrRenderSinglePass,
|
|
8
|
+
ssrStreamNavQueries
|
|
9
|
+
} from "../shared/chunk-1v0wakka.js";
|
|
10
10
|
import"../shared/chunk-szvdd1qq.js";
|
|
11
11
|
import"../shared/chunk-bt1px3c4.js";
|
|
12
12
|
// src/prerender.ts
|
|
13
13
|
async function discoverRoutes(module) {
|
|
14
|
-
const result = await
|
|
14
|
+
const result = await ssrRenderSinglePass(module, "/");
|
|
15
15
|
return result.discoveredRoutes ?? [];
|
|
16
16
|
}
|
|
17
17
|
function filterPrerenderableRoutes(patterns, compiledRoutes) {
|
|
@@ -31,7 +31,7 @@ async function prerenderRoutes(module, template, options) {
|
|
|
31
31
|
for (const routePath of options.routes) {
|
|
32
32
|
let renderResult;
|
|
33
33
|
try {
|
|
34
|
-
renderResult = await
|
|
34
|
+
renderResult = await ssrRenderSinglePass(module, routePath, {
|
|
35
35
|
fallbackMetrics: options.fallbackMetrics
|
|
36
36
|
});
|
|
37
37
|
} catch (error) {
|
|
@@ -113,8 +113,8 @@ function joinPatterns(parent, child) {
|
|
|
113
113
|
}
|
|
114
114
|
export {
|
|
115
115
|
stripScriptsFromStaticHTML,
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
ssrStreamNavQueries,
|
|
117
|
+
ssrRenderSinglePass,
|
|
118
118
|
prerenderRoutes,
|
|
119
119
|
loadAotManifest,
|
|
120
120
|
injectIntoTemplate,
|