UNPKG

histoire

Version:

A fast story book powered by Vite

53 lines • 2.82 kB
import type { PreviewRuntimeStoryFile } from './preamble.js'; /** * Prefix of the per-story entry modules the dev preview runtime imports. Each * entry carries one story's metadata and module loader, so a sandbox document * only receives the story it shows instead of every collected story. */ export declare const PREVIEW_STORY_ENTRY_ID_PREFIX = "virtual:$histoire-preview-story:"; /** Resolved form of {@link PREVIEW_STORY_ENTRY_ID_PREFIX}. */ export declare const RESOLVED_PREVIEW_STORY_ENTRY_ID_PREFIX = "\0virtual:$histoire-preview-story:"; /** * Import specifier of a story's entry module. * * The `v` query hashes everything the entry emits. Vite serves versioned URLs * immutable, so unchanged stories are read from the browser cache by every * later sandbox document; a collection that changes the story regenerates the * runtime with a new URL instead of needing to invalidate the entry. * @param file Story metadata. * @param hmr Whether the entry emits the hot-update loader form. * @param salt Changes every version, so entries transformed by another run's * plugins (e.g. a different Vitest mocker setup) are never reused. */ export declare function getStoryEntrySpecifier(file: PreviewRuntimeStoryFile, hmr: boolean, salt?: string): string; /** * Story id encoded in a (resolved) entry module id. * @param id Resolved module id, starting with {@link RESOLVED_PREVIEW_STORY_ENTRY_ID_PREFIX}. */ export declare function parseStoryEntryId(id: string): string; /** * Emitted `"<story id>": () => import("<entry specifier>")` entries, one per * story. Literal specifiers let Vite resolve and rewrite them like any import. * @param files Story files to emit an entry loader for. * @param hmr Whether entries emit the hot-update loader form. * @param salt Version salt (see {@link getStoryEntrySpecifier}). */ export declare function buildStoryEntryLoaders(files: PreviewRuntimeStoryFile[], hmr: boolean, salt?: string): string[]; /** * Source of a story entry module: its metadata as `file` and its module * loader as `load`, both `null` for a story the collection does not know. * @param file Story metadata, `undefined` when unknown. * @param options Loader options. * @param options.hmr Whether `load` takes the cache-busting version argument. */ export declare function buildStoryEntryModule(file: PreviewRuntimeStoryFile | undefined, { hmr }: { hmr: boolean; }): string; /** * Emits the runtime side of lazy story entries: the entry loader table and * `loadStoryEntry`, which imports a story's entry once and registers it in * the `files` / `moduleLoaders` tables the variant test session reads. * @param entryLoaders Emitted entry loader entries. */ export declare function previewStoryEntries(entryLoaders: string[]): string; //# sourceMappingURL=story-entries.d.ts.map