/** * TSX View Compiler * * Transpiles and bundles .tsx view files into self-contained HTML documents * using esbuild. Ships a tiny built-in JSX runtime (~1KB) that maps directly * to DOM calls — no React, no Preact, no virtual DOM. * * Users can override with `@jsxImportSource` pragma or tsconfig.json in the * ui/ folder to use React/Preact/Solid if they prefer. */ /** * Result of compiling a .tsx view. * * The bundled JS is written to a content-hashed sidecar file rather than * inlined, so every serving path (local server, Beam, `photon build`, the * Cloudflare [assets] binding) gets URL-level cache-busting for free: the * hash changes whenever the source or the esbuild toolchain changes, so a * browser never executes a stale bundle. The tiny HTML shell carries no * code and is served with revalidation; the hashed JS is immutable. */ export interface CompiledTsx { /** sha256 of (bundle + esbuild version), 12 hex chars. Empty on build error. */ hash: string; /** Hashed JS filename the shell references, e.g. `app.1a2b3c4d5e6f.js`. */ jsFileName: string; /** The HTML shell (references `./`). On error this is the error page. */ html: string; /** The bundled browser JS. Empty on build error. */ js: string; /** On-disk cache directory holding `` and `index.html`. */ dir: string; /** Absolute path to the written HTML shell. */ htmlPath: string; /** Absolute path to the written hashed JS (empty string on build error). */ jsPath: string; /** Absolute paths of every module in the bundle (entry + imports). */ inputs: string[]; } /** * Self-contained document with the bundle inlined. Used only by the MCP * resource path (Claude Desktop apps): an MCP-app webview renders the * returned HTML with no HTTP origin, so a `./.js` sibling reference * would not resolve. Cache-busting is irrelevant there — the client * re-reads the resource on every `resources/read`. */ export declare function inlineHtml(js: string): string; /** Immutable: hash in the URL changes whenever the bundle changes. */ export declare const TSX_JS_CACHE_CONTROL = "public, max-age=31536000, immutable"; /** Tiny, code-free shell — always revalidate so a new hash is picked up. */ export declare const TSX_SHELL_CACHE_CONTROL = "no-cache"; export interface TsxHttpResponse { status: 200 | 404; /** Response body. */ body: string; headers: Record; } /** * Resolve an HTTP request for a compiled `.tsx` view into a response. * * - `restPath` empty / `index.html` → the HTML shell (revalidated, ETag). * - `restPath` === the hashed JS filename → the bundle (immutable). * - anything else → 404 (caller may then try its own sibling resolution). * * Used by every browser-facing serving path (local server, Beam, * streamable-http, and — via precompiled files — the Cloudflare * [assets] binding) so the cache contract is identical everywhere. */ export declare function tsxHttpResponse(result: CompiledTsx, restPath: string): TsxHttpResponse; /** * Compile a TSX file into a hashed JS bundle plus an HTML shell. */ export declare function compileTsx(filePath: string): Promise; /** * Compile with dependency-graph-aware caching. Re-transpiles when the * entry file OR any imported module changes (the previous mtime-only * cache silently served a stale bundle after an imported-component edit). */ export declare function compileTsxCached(filePath: string): Promise; /** * Synchronous variant for the build command (uses esbuild.buildSync). */ export declare function compileTsxSync(filePath: string): CompiledTsx; //# sourceMappingURL=tsx-compiler.d.ts.map