@vertz/ui-server 0.2.14 → 0.2.16

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.
@@ -1,3 +1,30 @@
1
+ import { AccessSet } from "@vertz/ui/auth";
2
+ interface SessionData {
3
+ user: {
4
+ id: string;
5
+ email: string;
6
+ role: string;
7
+ [key: string]: unknown;
8
+ };
9
+ /** Unix timestamp in milliseconds (JWT exp * 1000). */
10
+ expiresAt: number;
11
+ }
12
+ /** Resolved session data for SSR injection. */
13
+ interface SSRSessionInfo {
14
+ session: SessionData;
15
+ /**
16
+ * Access set from JWT acl claim.
17
+ * - Present (object): inline access set (no overflow)
18
+ * - null: access control is configured but the set overflowed the JWT
19
+ * - undefined: access control is not configured
20
+ */
21
+ accessSet?: AccessSet | null;
22
+ }
23
+ /**
24
+ * Callback that extracts session data from a request.
25
+ * Returns null when no valid session exists (expired, missing, or invalid cookie).
26
+ */
27
+ type SessionResolver = (request: Request) => Promise<SSRSessionInfo | null>;
1
28
  interface BunDevServerOptions {
2
29
  /** SSR entry module (e.g., './src/app.tsx') */
3
30
  entry: string;
@@ -31,6 +58,12 @@ interface BunDevServerOptions {
31
58
  editor?: string;
32
59
  /** Extra HTML tags to inject into the <head> (e.g., font preloads, meta tags). */
33
60
  headTags?: string;
61
+ /**
62
+ * Resolves session data from request cookies for SSR injection.
63
+ * When provided, SSR HTML includes `window.__VERTZ_SESSION__` and
64
+ * optionally `window.__VERTZ_ACCESS_SET__` for instant auth hydration.
65
+ */
66
+ sessionResolver?: SessionResolver;
34
67
  }
35
68
  interface ErrorDetail {
36
69
  message: string;
@@ -96,11 +129,13 @@ interface SSRPageHtmlOptions {
96
129
  scriptTag: string;
97
130
  editor?: string;
98
131
  headTags?: string;
132
+ /** Pre-built session + access set script tags for SSR injection. */
133
+ sessionScript?: string;
99
134
  }
100
135
  /**
101
136
  * Generate a full SSR HTML page with the given content, CSS, SSR data, and script tag.
102
137
  */
103
- declare function generateSSRPageHtml({ title, css, bodyHtml, ssrData, scriptTag, editor, headTags }: SSRPageHtmlOptions): string;
138
+ declare function generateSSRPageHtml({ title, css, bodyHtml, ssrData, scriptTag, editor, headTags, sessionScript }: SSRPageHtmlOptions): string;
104
139
  interface FetchInterceptorOptions {
105
140
  apiHandler: (req: Request) => Promise<Response>;
106
141
  origin: string;
@@ -130,9 +165,16 @@ declare function createFetchInterceptor({ apiHandler, origin, skipSSRPaths, orig
130
165
  */
131
166
  declare function buildScriptTag(bundledScriptUrl: string | null, hmrBootstrapScript: string | null, clientSrc: string): string;
132
167
  /**
168
+ * Clear the entire require.cache so SSR module re-import picks up all changes,
169
+ * including files outside src/ (e.g., generated files, shared libs).
170
+ *
171
+ * Returns the number of cache entries cleared.
172
+ */
173
+ declare function clearSSRRequireCache(): number;
174
+ /**
133
175
  * Create a unified Bun dev server with SSR + HMR.
134
176
  *
135
177
  * SSR is always on. HMR always works. No mode toggle needed.
136
178
  */
137
179
  declare function createBunDevServer(options: BunDevServerOptions): BunDevServer;
138
- export { parseHMRAssets, generateSSRPageHtml, formatTerminalRuntimeError, createRuntimeErrorDeduplicator, createFetchInterceptor, createBunDevServer, buildScriptTag, SSRPageHtmlOptions, HMRAssets, FetchInterceptorOptions, ErrorDetail, ErrorCategory, BunDevServerOptions, BunDevServer };
180
+ export { parseHMRAssets, generateSSRPageHtml, formatTerminalRuntimeError, createRuntimeErrorDeduplicator, createFetchInterceptor, createBunDevServer, clearSSRRequireCache, buildScriptTag, SSRPageHtmlOptions, HMRAssets, FetchInterceptorOptions, ErrorDetail, ErrorCategory, BunDevServerOptions, BunDevServer };