UNPKG

histoire

Version:

A fast story book powered by Vite

78 lines • 3.66 kB
import type { SerializedStoryFile } from '../variant-test-session/types.js'; /** * Story metadata baked into the generated preview runtime, one entry per * collected story file. Same shape the session reads back at runtime — the two * are passed interchangeably, so they must stay one type. */ export type PreviewRuntimeStoryFile = SerializedStoryFile; /** * Options of {@link previewRuntimePreamble}. */ export interface PreviewRuntimePreambleOptions { /** * True when Vitest and its mocker packages resolved from the project root. * Gates the `@vitest/spy` / `@vitest/mocker` imports and the static mock * runtime import, which do not exist in a project without Vitest. */ hasVitestPreview: boolean; /** * True when the book configures at least one frame plugin. Without one the * runtime never imports the frame plugin manifest, saving a module request * on every interactive document. */ hasFramePlugins: boolean; /** Resolved id of `@vitest/spy` (only used when `hasVitestPreview`). */ vitestSpyId: string | null; /** Resolved id of `@vitest/mocker/browser` (only used when `hasVitestPreview`). */ vitestMockerBrowserId: string | null; /** Resolved id of the `@histoire/shared` runtime entry. */ histoireSharedId: string; /** Resolved id of the variant test session module. */ variantTestSessionId: string; /** Resolved id of the static (build mode) mock runtime module. */ staticMockRuntimeId: string; /** Browser scanner and optional local axe module, present only when enabled and resolved. */ accessibilityRuntime?: { scannerId: string; axeId: string; }; /** * Resolved sandbox entry of the bundled `@histoire/app` build. Baked as absolute * paths because a bare specifier in this virtual module would be resolved * from the user's project, which only depends on `histoire`. */ histoireAppSandboxId: string; /** Vendor entries resolved from Histoire, never the consumer's virtual root. */ histoireVendorIds: { /** Bundled floating-vue browser entry. */ floatingVue: string; /** Bundled Pinia browser entry. */ pinia: string; /** Bundled Vue browser entry. */ vue: string; }; /** Baked story metadata. */ files: PreviewRuntimeStoryFile[]; /** Emitted `"<story id>": () => import("<module id>")` loader entries. */ loaders: string[]; /** * Emitted per-story entry loaders (see `buildStoryEntryLoaders`). When set, * `files` and `loaders` start empty and each story's metadata and module * loader are imported on first use instead of being baked in. */ storyEntryLoaders?: string[]; } /** * Emits the head of the preview runtime: every module import, the story * metadata and dynamic module loaders baked at transform time, the sandbox * selection parsed from the iframe URL, the plugin API setup and the mock * resolution RPC used by the mocker wiring below it. */ export declare function previewRuntimePreamble({ hasVitestPreview, hasFramePlugins, vitestSpyId, vitestMockerBrowserId, histoireSharedId, variantTestSessionId, staticMockRuntimeId, accessibilityRuntime, histoireAppSandboxId, histoireVendorIds, files, loaders, storyEntryLoaders, }: PreviewRuntimePreambleOptions): string; /** * Emits the `initialSelection` declaration: target, presentation flags and * runtime purpose parsed from the sandbox iframe URL. Needs `getFramePurpose` * from `@histoire/shared` in scope. */ export declare function previewInitialSelection(): string; //# sourceMappingURL=preamble.d.ts.map