@vertz/ui-server 0.2.0 → 0.2.3
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 +298 -310
- package/dist/bun-dev-server.d.ts +115 -0
- package/dist/bun-dev-server.js +2032 -0
- package/dist/bun-plugin/fast-refresh-dom-state.d.ts +51 -0
- package/dist/bun-plugin/fast-refresh-dom-state.js +10 -0
- package/dist/bun-plugin/fast-refresh-runtime.d.ts +43 -0
- package/dist/bun-plugin/fast-refresh-runtime.js +150 -0
- package/dist/bun-plugin/index.d.ts +44 -0
- package/dist/bun-plugin/index.js +197 -0
- package/dist/dom-shim/index.d.ts +37 -6
- package/dist/dom-shim/index.js +12 -324
- package/dist/index.d.ts +331 -64
- package/dist/index.js +285 -292
- package/dist/jsx-runtime/index.js +15 -2
- package/dist/shared/chunk-2qsqp9xj.js +150 -0
- package/dist/shared/chunk-32688jav.js +564 -0
- package/dist/shared/chunk-4t0ekdyv.js +513 -0
- package/dist/shared/chunk-eb80r8e8.js +4 -0
- package/dist/ssr/index.d.ts +86 -0
- package/dist/ssr/index.js +11 -0
- package/package.json +35 -18
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
interface BunDevServerOptions {
|
|
2
|
+
/** SSR entry module (e.g., './src/app.tsx') */
|
|
3
|
+
entry: string;
|
|
4
|
+
/** Port to listen on. @default 3000 */
|
|
5
|
+
port?: number;
|
|
6
|
+
/** Host to bind to. @default 'localhost' */
|
|
7
|
+
host?: string;
|
|
8
|
+
/** API handler for full-stack mode */
|
|
9
|
+
apiHandler?: (req: Request) => Promise<Response>;
|
|
10
|
+
/** Paths to skip SSR (delegate to apiHandler). @default ['/api/'] */
|
|
11
|
+
skipSSRPaths?: string[];
|
|
12
|
+
/** OpenAPI spec options */
|
|
13
|
+
openapi?: {
|
|
14
|
+
specPath: string;
|
|
15
|
+
};
|
|
16
|
+
/** When true, entry is SSRModule (exports App/theme/styles). @default false */
|
|
17
|
+
ssrModule?: boolean;
|
|
18
|
+
/** Client entry path (for hydration). */
|
|
19
|
+
clientEntry?: string;
|
|
20
|
+
/** HTML page title. @default 'Vertz App' */
|
|
21
|
+
title?: string;
|
|
22
|
+
/** Project root. @default process.cwd() */
|
|
23
|
+
projectRoot?: string;
|
|
24
|
+
/** Log requests. @default true */
|
|
25
|
+
logRequests?: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface ErrorDetail {
|
|
28
|
+
message: string;
|
|
29
|
+
file?: string;
|
|
30
|
+
absFile?: string;
|
|
31
|
+
line?: number;
|
|
32
|
+
column?: number;
|
|
33
|
+
lineText?: string;
|
|
34
|
+
stack?: string;
|
|
35
|
+
}
|
|
36
|
+
type ErrorCategory = "build" | "resolve" | "runtime" | "ssr";
|
|
37
|
+
interface BunDevServer {
|
|
38
|
+
start(): Promise<void>;
|
|
39
|
+
stop(): Promise<void>;
|
|
40
|
+
/** Broadcast an error to all connected WebSocket clients. */
|
|
41
|
+
broadcastError(category: ErrorCategory, errors: ErrorDetail[]): void;
|
|
42
|
+
/** Clear current error and notify all connected WebSocket clients.
|
|
43
|
+
* Sets a 5s grace period that suppresses stale runtime errors. */
|
|
44
|
+
clearError(): void;
|
|
45
|
+
/** Clear error for a file change — no grace period, since HMR may trigger new errors. */
|
|
46
|
+
clearErrorForFileChange(): void;
|
|
47
|
+
/** Set the last changed file path (for testing). */
|
|
48
|
+
setLastChangedFile(file: string): void;
|
|
49
|
+
}
|
|
50
|
+
interface IndexHtmlStasher {
|
|
51
|
+
stash(): void;
|
|
52
|
+
restore(): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a stasher that renames index.html during dev so Bun's built-in
|
|
56
|
+
* HMR server doesn't auto-serve it, bypassing our SSR fetch handler.
|
|
57
|
+
*/
|
|
58
|
+
declare function createIndexHtmlStasher(projectRoot: string): IndexHtmlStasher;
|
|
59
|
+
interface HMRAssets {
|
|
60
|
+
/** Discovered `/_bun/client/<hash>.js` URL, or null if not found */
|
|
61
|
+
scriptUrl: string | null;
|
|
62
|
+
/** HMR bootstrap `<script>` tag, or null if not found */
|
|
63
|
+
bootstrapScript: string | null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Parse the HTML returned by the HMR shell route (`/__vertz_hmr`) to extract
|
|
67
|
+
* the bundled client script URL and HMR bootstrap snippet.
|
|
68
|
+
*/
|
|
69
|
+
declare function parseHMRAssets(html: string): HMRAssets;
|
|
70
|
+
interface SSRPageHtmlOptions {
|
|
71
|
+
title: string;
|
|
72
|
+
css: string;
|
|
73
|
+
bodyHtml: string;
|
|
74
|
+
ssrData: unknown[];
|
|
75
|
+
scriptTag: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Generate a full SSR HTML page with the given content, CSS, SSR data, and script tag.
|
|
79
|
+
*/
|
|
80
|
+
declare function generateSSRPageHtml({ title, css, bodyHtml, ssrData, scriptTag }: SSRPageHtmlOptions): string;
|
|
81
|
+
interface FetchInterceptorOptions {
|
|
82
|
+
apiHandler: (req: Request) => Promise<Response>;
|
|
83
|
+
origin: string;
|
|
84
|
+
skipSSRPaths: string[];
|
|
85
|
+
originalFetch: typeof fetch;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create a fetch interceptor that routes local API requests through the
|
|
89
|
+
* in-memory apiHandler instead of making HTTP self-fetch calls.
|
|
90
|
+
* Matches production (Cloudflare) behavior where fetch('/api/...') during
|
|
91
|
+
* SSR goes through the same handler.
|
|
92
|
+
*/
|
|
93
|
+
declare function createFetchInterceptor({ apiHandler, origin, skipSSRPaths, originalFetch }: FetchInterceptorOptions): typeof fetch;
|
|
94
|
+
/**
|
|
95
|
+
* Build the `<script>` tag for SSR HTML output.
|
|
96
|
+
*
|
|
97
|
+
* When `bundledScriptUrl` is available (HMR discovered), generates a
|
|
98
|
+
* non-executing placeholder (`type="text/plain"`) plus a loader script that
|
|
99
|
+
* fetch-validates the bundle before loading it. This prevents the infinite
|
|
100
|
+
* reload loop when Bun serves its reload stub for a failed compilation.
|
|
101
|
+
*
|
|
102
|
+
* The placeholder preserves `data-bun-dev-server-script` and `src` attributes
|
|
103
|
+
* so Bun's HMR bootstrap (which reads `.src` via IDL) still works.
|
|
104
|
+
*
|
|
105
|
+
* Falls back to a plain `<script type="module">` when no bundled URL is
|
|
106
|
+
* available (source-only mode, no Bun compilation).
|
|
107
|
+
*/
|
|
108
|
+
declare function buildScriptTag(bundledScriptUrl: string | null, hmrBootstrapScript: string | null, clientSrc: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* Create a unified Bun dev server with SSR + HMR.
|
|
111
|
+
*
|
|
112
|
+
* SSR is always on. HMR always works. No mode toggle needed.
|
|
113
|
+
*/
|
|
114
|
+
declare function createBunDevServer(options: BunDevServerOptions): BunDevServer;
|
|
115
|
+
export { parseHMRAssets, generateSSRPageHtml, createIndexHtmlStasher, createFetchInterceptor, createBunDevServer, buildScriptTag, SSRPageHtmlOptions, IndexHtmlStasher, HMRAssets, FetchInterceptorOptions, ErrorDetail, ErrorCategory, BunDevServerOptions, BunDevServer };
|