@vertz/ui-server 0.2.42 → 0.2.44

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.
@@ -10,7 +10,7 @@ import {
10
10
  ssrRenderSinglePass,
11
11
  ssrStreamNavQueries,
12
12
  toPrefetchSession
13
- } from "./chunk-r1pf7cf2.js";
13
+ } from "./chunk-1v0wakka.js";
14
14
 
15
15
  // src/node-handler.ts
16
16
  function createNodeHandler(options) {
@@ -49,8 +49,7 @@ type PrefetchSession = {
49
49
  } | {
50
50
  status: "unauthenticated";
51
51
  };
52
- import { CompiledRoute, FontFallbackMetrics, Theme } from "@vertz/ui";
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
- interface SSRDiscoverResult {
92
- resolved: Array<{
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, ssrRenderToString, ssrDiscoverQueries, prerenderRoutes, loadAotManifest, injectIntoTemplate, filterPrerenderableRoutes, discoverRoutes, createSSRHandler, collectPrerenderPaths, SSRRenderResult, SSRModule, SSRHandlerOptions, SSRDiscoverResult, PrerenderResult, PrerenderOptions, AotManifest, AotDataResolver };
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-tnsz18ac.js";
4
+ } from "../shared/chunk-05hadnnd.js";
5
5
  import {
6
6
  injectIntoTemplate,
7
- ssrDiscoverQueries,
8
- ssrRenderToString
9
- } from "../shared/chunk-r1pf7cf2.js";
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 ssrRenderToString(module, "/");
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 ssrRenderToString(module, routePath, {
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
- ssrRenderToString,
117
- ssrDiscoverQueries,
116
+ ssrStreamNavQueries,
117
+ ssrRenderSinglePass,
118
118
  prerenderRoutes,
119
119
  loadAotManifest,
120
120
  injectIntoTemplate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertz/ui-server",
3
- "version": "0.2.42",
3
+ "version": "0.2.44",
4
4
  "description": "Vertz UI server-side rendering runtime",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -67,15 +67,15 @@
67
67
  "@ampproject/remapping": "^2.3.0",
68
68
  "@capsizecss/unpack": "^4.0.0",
69
69
  "@jridgewell/trace-mapping": "^0.3.31",
70
- "@vertz/core": "^0.2.41",
71
- "@vertz/ui": "^0.2.41",
70
+ "@vertz/core": "^0.2.43",
71
+ "@vertz/ui": "^0.2.43",
72
72
  "magic-string": "^0.30.0",
73
73
  "sharp": "^0.34.5"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@happy-dom/global-registrator": "^20.8.3",
77
77
  "@playwright/test": "^1.58.2",
78
- "@vertz/codegen": "^0.2.41",
78
+ "@vertz/codegen": "^0.2.43",
79
79
  "bun-types": "^1.3.10",
80
80
  "bunup": "^0.16.31",
81
81
  "happy-dom": "^20.8.3",