histoire
Version:
A fast story book powered by Vite
34 lines • 1.68 kB
TypeScript
import type { ServerResponse } from 'node:http';
import type { Connect, ViteDevServer } from 'vite';
import type { Context } from '../context.js';
/** Early Histoire routes inherit Vite headers without replacing caller-owned response policy. */
export declare function applyDevResponseHeaders(server: ViteDevServer, res: ServerResponse): void;
/**
* Head and entry script of the sandbox document.
*
* Built Histoire styles load as `<link>` stylesheets: with versioned URLs the
* browser caches and reuses them across sandbox documents, instead of every
* iframe evaluating ~270KB of CSS wrapped in JS modules and injecting it
* through the HMR client. The entry script is then the preview runtime itself.
* Local Histoire development keeps the CSS imports of its `-dev` bundle, whose
* source styles hot-update.
* @param version Maps an absolute file path to its versioned module path.
*/
export declare function renderSandboxEntry(version: (file: string) => string): {
head: string;
script: string;
};
/**
* Middleware serving the story sandbox document on `<base>__sandbox`.
* @param server The Vite dev server the middleware is registered on.
*/
export declare function createSandboxHtmlMiddleware(server: ViteDevServer): Connect.NextHandleFunction;
/**
* Middleware serving the Histoire app shell for every `.html` request.
*
* Registered after Vite's history fallback so real files still win.
* @param server The Vite dev server the middleware is registered on.
* @param ctx The histoire context.
*/
export declare function createAppHtmlMiddleware(server: ViteDevServer, ctx: Context): Connect.NextHandleFunction;
//# sourceMappingURL=dev-html.d.ts.map