@storybook-astro/framework 1.1.0 → 1.1.1-canary.1

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.
@@ -66,4 +66,4 @@ export {
66
66
  composeStory,
67
67
  composeStories
68
68
  };
69
- //# sourceMappingURL=chunk-5EF25G5S.js.map
69
+ //# sourceMappingURL=chunk-KXAAX3GN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/portable-stories.ts"],"sourcesContent":["// @ts-ignore - Storybook internal modules have complex module resolution\nimport type {\n Args,\n ComponentAnnotations,\n NamedOrDefaultProjectAnnotations,\n NormalizedProjectAnnotations,\n ProjectAnnotations,\n StoryAnnotationsOrFn,\n WebRenderer,\n} from 'storybook/internal/types';\n// @ts-ignore - Storybook internal modules have complex module resolution\nimport {\n composeStory as originalComposeStory,\n composeStories as originalComposeStories,\n setProjectAnnotations as originalSetProjectAnnotations,\n} from 'storybook/internal/preview-api';\n\n// Define the AstroRenderer type to match other frameworks\nexport interface AstroRenderer extends WebRenderer {\n component: any;\n storyResult: any;\n}\n\n// Create a render function for testing that mimics Storybook's render behavior\nconst render = (args: Args, context?: any) => {\n const Component = context?.component;\n const renderer = context?.parameters?.renderer;\n const id = context?.id || 'test-story';\n \n // Renderers that are known to not work in the current integration\n const brokenRenderers: string[] = [];\n \n // Mimic the renderer detection logic from the main renderer\n if (renderer && brokenRenderers.includes(renderer)) {\n throw new Error(`Renderer '${renderer}' not found. Available renderers: react, vue, svelte, solid, preact`);\n }\n \n // For Astro components and working integrations, return a renderable object\n if (!Component) {\n throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);\n }\n \n // Astro components can be identified by isAstroComponentFactory\n if (typeof Component === 'function' && (Component as any).isAstroComponentFactory) {\n // This is an Astro component - return it for server-side rendering\n return Component;\n }\n \n // For framework components that have working integrations\n if (typeof Component === 'function') {\n if (renderer && !brokenRenderers.includes(renderer)) {\n // This would delegate to working framework renderer\n return Component;\n }\n \n // If no renderer specified for function component\n if (!renderer) {\n throw new Error(\n `Component appears to be a framework component but no renderer is specified. ` +\n `Add 'parameters: { renderer: \"framework-name\" }' to your story configuration.`\n );\n }\n }\n \n // Return a basic representation for testing\n return {\n component: Component,\n args: args,\n renderer: renderer || 'astro'\n };\n};\n\n/**\n * Function that sets the globalConfig of your storybook. The global config is the preview module of\n * your .storybook folder.\n *\n * It should be run a single time, so that your global config (e.g. decorators) is applied to your\n * stories when using `composeStories` or `composeStory`.\n *\n * Example:\n *\n * ```jsx\n * // setup-file.js\n * import { setProjectAnnotations } from '@storybook-astro/framework';\n * import projectAnnotations from './.storybook/preview';\n *\n * setProjectAnnotations(projectAnnotations);\n * ```\n *\n * @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')\n */\nexport function setProjectAnnotations<R extends AstroRenderer = AstroRenderer>(\n projectAnnotations:\n | NamedOrDefaultProjectAnnotations<R>\n | NamedOrDefaultProjectAnnotations<R>[]\n): NormalizedProjectAnnotations<R> {\n return originalSetProjectAnnotations<R>(projectAnnotations);\n}\n\n/**\n * Function that will receive a story along with meta (e.g. a default export from a .stories file)\n * and optionally projectAnnotations e.g. (import * as projectAnnotations from '../.storybook/preview')\n * and will return a composed component that has all args/parameters/decorators/etc combined and applied to it.\n *\n * It's very useful for reusing a story in scenarios outside of Storybook like unit testing.\n *\n * Example:\n * ```jsx\n * import { render } from '@testing-library/react';\n * import { composeStory } from '@storybook-astro/framework';\n * import meta, { Primary as PrimaryStory } from './Button.stories';\n *\n * const Primary = composeStory(PrimaryStory, meta);\n *\n * test('renders primary button', () => {\n * const { getByRole } = render(<Primary>Hello world</Primary>);\n * expect(getByRole('button')).toBeInTheDocument();\n * });\n * ```\n *\n * @param story - E.g. (import { Primary } from './Button.stories')\n * @param componentAnnotations - E.g. (import meta from './Button.stories')\n * @param projectAnnotations - E.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.\n * @param exportsName - In case your story does not contain a name and you want it to have a name.\n */\nexport function composeStory<TArgs extends Args = Args, R extends AstroRenderer = AstroRenderer>(\n story: StoryAnnotationsOrFn<R, TArgs>,\n componentAnnotations: ComponentAnnotations<R, TArgs>,\n projectAnnotations?: ProjectAnnotations<R>,\n exportsName?: string\n) {\n // Merge project annotations with Astro renderer\n const mergedProjectAnnotations: any = projectAnnotations ? {\n ...projectAnnotations,\n render: projectAnnotations.render || render\n } : {\n render\n };\n \n return originalComposeStory<AstroRenderer, TArgs>(\n story as any,\n componentAnnotations as any,\n mergedProjectAnnotations as any,\n exportsName as any\n );\n}\n\n/**\n * Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`)\n * and optionally a globalConfig (e.g. `import * from '../.storybook/preview`)\n * and will return an object containing all the stories passed, but now as a composed component that has all args/parameters/decorators/etc combined and applied to it.\n *\n * It's very useful for reusing stories in scenarios outside of Storybook like unit testing.\n *\n * Example:\n * ```jsx\n * import { render } from '@testing-library/react';\n * import { composeStories } from '@storybook-astro/framework';\n * import * as stories from './Button.stories';\n *\n * const { Primary, Secondary } = composeStories(stories);\n *\n * test('renders primary button', () => {\n * const { getByRole } = render(<Primary>Hello world</Primary>);\n * expect(getByRole('button')).toBeInTheDocument();\n * });\n * ```\n *\n * @param storiesImport - E.g. (import * as stories from './Button.stories')\n * @param projectAnnotations - E.g. (import * as globalConfig from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.\n */\nexport function composeStories<TModule extends Record<string, any>, R extends AstroRenderer = AstroRenderer>(\n storiesImport: TModule,\n projectAnnotations?: ProjectAnnotations<R>\n): { [K in keyof Omit<TModule, 'default'>]: any } {\n // Merge project annotations with Astro renderer\n const mergedProjectAnnotations: any = projectAnnotations ? {\n ...projectAnnotations,\n render: projectAnnotations.render || render\n } : {\n render\n };\n \n return originalComposeStories(storiesImport as any, mergedProjectAnnotations as any) as { [K in keyof Omit<TModule, 'default'>]: any };\n}\n"],"mappings":";AAWA;AAAA,EACE,gBAAgB;AAAA,EAChB,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@ function isRecord(value) {
232
232
  return !Array.isArray(value);
233
233
  }
234
234
 
235
+ // src/lib/passthrough-image-service.ts
236
+ function installPassthroughImageService() {
237
+ if (!globalThis.astroAsset) {
238
+ globalThis.astroAsset = {};
239
+ }
240
+ globalThis.astroAsset.imageService = {
241
+ propertiesToHash: ["src"],
242
+ validateOptions(options) {
243
+ return options;
244
+ },
245
+ getURL(options) {
246
+ const src = options.src;
247
+ if (src != null && typeof src === "object" && "src" in src && typeof src.src === "string") {
248
+ return src.src;
249
+ }
250
+ return typeof src === "string" ? src : "";
251
+ },
252
+ getHTMLAttributes(options) {
253
+ const {
254
+ src,
255
+ width,
256
+ height,
257
+ format: _format,
258
+ quality: _quality,
259
+ densities: _densities,
260
+ widths: _widths,
261
+ formats: _formats,
262
+ layout: _layout,
263
+ priority: _priority,
264
+ fit: _fit,
265
+ position: _position,
266
+ background: _background,
267
+ ...attrs
268
+ } = options;
269
+ const srcObj = src != null && typeof src === "object" ? src : null;
270
+ return {
271
+ ...attrs,
272
+ width: width ?? srcObj?.width,
273
+ height: height ?? srcObj?.height,
274
+ loading: attrs.loading ?? "lazy",
275
+ decoding: attrs.decoding ?? "async"
276
+ };
277
+ },
278
+ getSrcSet() {
279
+ return [];
280
+ }
281
+ };
282
+ }
283
+
235
284
  // src/lib/sanitization.ts
236
285
  import sanitizeHtml from "sanitize-html";
237
286
  var DEFAULT_SANITIZE_HTML_OPTIONS = {
@@ -560,10 +609,11 @@ export {
560
609
  defineStoryRules,
561
610
  selectStoryRules,
562
611
  withStoryRuleCleanups,
612
+ installPassthroughImageService,
563
613
  resolveSanitizationOptions,
564
614
  sanitizeRenderPayload,
565
615
  serializeSanitizationOptions,
566
616
  withStoryModuleMocks,
567
617
  resolveStoryModuleMock
568
618
  };
569
- //# sourceMappingURL=chunk-V76WSNSP.js.map
619
+ //# sourceMappingURL=chunk-OUEDTRBO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rules.ts","../src/lib/passthrough-image-service.ts","../src/lib/sanitization.ts","../src/module-mocks.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport type { RenderStoryInput } from './types.ts';\n\nexport type StoryRuleCleanup = () => void | Promise<void>;\ntype StoryRuleUseResult = void | StoryRuleCleanup | Promise<void | StoryRuleCleanup>;\n\nexport type StoryRuleUseContext = {\n story: StoryRuleStory;\n mock: (specifier: string, replacement: string) => void;\n};\n\nexport type StoryRuleUse = (context: StoryRuleUseContext) => StoryRuleUseResult;\n\nexport type StoryRule = {\n match: string | string[];\n use: StoryRuleUse | StoryRuleUse[];\n};\n\nexport type StoryRulesConfig = {\n rules: StoryRule[];\n};\n\nexport type StoryRuleStory = {\n id: string;\n title?: string;\n name?: string;\n keys: string[];\n};\n\nexport type StoryRuleSelectionInput = {\n configModule: unknown;\n configFilePath?: string;\n story?: RenderStoryInput;\n};\n\nexport type StoryRuleSelection = {\n moduleMocks: Map<string, string>;\n cleanups: StoryRuleCleanup[];\n};\n\ntype MutableStoryRuleSelection = {\n moduleMocks: Map<string, string>;\n cleanups: StoryRuleCleanup[];\n};\n\nexport function defineStoryRules(config: StoryRulesConfig): StoryRulesConfig {\n return config;\n}\n\nexport async function selectStoryRules(\n input: StoryRuleSelectionInput\n): Promise<StoryRuleSelection> {\n const config = normalizeRulesConfig(input.configModule);\n const story = normalizeStory(input.story);\n const selection = createEmptySelection();\n\n for (const rule of config.rules) {\n if (!isStoryRuleMatch(rule.match, story)) {\n continue;\n }\n\n const uses = Array.isArray(rule.use) ? rule.use : [rule.use];\n\n for (const use of uses) {\n if (typeof use !== 'function') {\n throw new Error('Each story rule \"use\" entry must be a function.');\n }\n\n const cleanup = await use({\n story,\n mock: (specifier, replacement) => {\n const normalizedSpecifier = normalizeMockSpecifier(specifier);\n const normalizedReplacement = normalizeMockReplacement(replacement, input.configFilePath);\n\n selection.moduleMocks.set(normalizedSpecifier, normalizedReplacement);\n }\n });\n\n if (cleanup !== undefined) {\n if (typeof cleanup !== 'function') {\n throw new Error('Story rule \"use\" must return either nothing or a cleanup function.');\n }\n\n selection.cleanups.push(cleanup);\n }\n }\n }\n\n return selection;\n}\n\nexport async function withStoryRuleCleanups<T>(\n cleanups: StoryRuleCleanup[],\n callback: () => Promise<T>\n): Promise<T> {\n let result: T | undefined;\n let callbackError: unknown;\n\n try {\n result = await callback();\n } catch (error) {\n callbackError = error;\n }\n\n try {\n await runStoryRuleCleanups(cleanups);\n } catch (cleanupError) {\n if (callbackError) {\n throw new AggregateError(\n [callbackError, cleanupError],\n 'Story rule execution and cleanup both failed.'\n );\n }\n\n throw cleanupError;\n }\n\n if (callbackError) {\n throw callbackError;\n }\n\n return result as T;\n}\n\nexport async function runStoryRuleCleanups(cleanups: StoryRuleCleanup[]): Promise<void> {\n const errors: unknown[] = [];\n\n for (let index = cleanups.length - 1; index >= 0; index -= 1) {\n try {\n await cleanups[index]();\n } catch (error) {\n errors.push(error);\n }\n }\n\n if (errors.length === 1) {\n throw errors[0];\n }\n\n if (errors.length > 1) {\n throw new AggregateError(errors, 'Story rule cleanup failed.');\n }\n}\n\nfunction normalizeRulesConfig(configModule: unknown): StoryRulesConfig {\n const configExport = getRulesConfigExport(configModule);\n\n if (configExport === undefined || configExport === null) {\n return {\n rules: []\n };\n }\n\n if (!isRecord(configExport)) {\n throw new Error(\n 'Story rules config must export an object with a \"rules\" array via a default export or named export.'\n );\n }\n\n const rules = configExport.rules;\n\n if (rules === undefined) {\n return {\n rules: []\n };\n }\n\n if (!Array.isArray(rules)) {\n throw new Error('Story rules config \"rules\" must be an array.');\n }\n\n return {\n rules: rules as StoryRule[]\n };\n}\n\nfunction getRulesConfigExport(configModule: unknown): unknown {\n if (!isRecord(configModule)) {\n return configModule;\n }\n\n if ('default' in configModule && configModule.default !== undefined) {\n return configModule.default;\n }\n\n if ('rules' in configModule) {\n return {\n rules: configModule.rules\n };\n }\n\n return undefined;\n}\n\nfunction normalizeStory(story?: RenderStoryInput): StoryRuleStory {\n const id = normalizeStoryId(story?.id);\n const title = normalizeOptionalString(story?.title);\n const name = normalizeOptionalString(story?.name);\n const keys = Array.from(resolveStoryKeys({ id, title, name }));\n\n return {\n id,\n title,\n name,\n keys\n };\n}\n\nfunction resolveStoryKeys(story: { id: string; title?: string; name?: string }) {\n const keys = new Set<string>();\n\n keys.add('');\n\n const storyId = story.id;\n const idPath = storyId ? storyId.replaceAll('--', '/') : '';\n\n if (storyId) {\n keys.add(storyId);\n keys.add(`/story/${storyId}`);\n }\n\n if (idPath) {\n keys.add(idPath);\n keys.add(`/story/${idPath}`);\n }\n\n const titlePath = story.title\n ? story.title\n .split('/')\n .map((segment) => slugify(segment))\n .filter(Boolean)\n .join('/')\n : '';\n\n const storyNamePath = story.name ? slugify(story.name) : '';\n\n if (titlePath && storyNamePath) {\n const composedPath = `${titlePath}/${storyNamePath}`;\n\n keys.add(composedPath);\n keys.add(`/story/${composedPath}`);\n }\n\n return keys;\n}\n\nfunction isStoryRuleMatch(match: string | string[], story: StoryRuleStory): boolean {\n const patterns = Array.isArray(match) ? match : [match];\n\n return patterns.some((pattern) => {\n if (typeof pattern !== 'string') {\n throw new Error('Story rule \"match\" must be a string or an array of strings.');\n }\n\n const normalizedPattern = pattern.trim();\n\n if (!normalizedPattern) {\n throw new Error('Story rule \"match\" cannot be empty.');\n }\n\n return story.keys.some((key) => isWildcardMatch(normalizedPattern, key));\n });\n}\n\nfunction isWildcardMatch(pattern: string, candidate: string): boolean {\n const escapedPattern = escapeRegExp(pattern).replaceAll('*', '.*');\n const regex = new RegExp(`^${escapedPattern}$`);\n\n return regex.test(candidate);\n}\n\nfunction normalizeStoryId(id?: string): string {\n const value = normalizeOptionalString(id) ?? '';\n\n if (!value) {\n return '';\n }\n\n return value.startsWith('/story/') ? value.slice('/story/'.length) : value;\n}\n\nfunction normalizeOptionalString(value: unknown): string | undefined {\n if (typeof value !== 'string') {\n return undefined;\n }\n\n const normalizedValue = value.trim();\n\n return normalizedValue || undefined;\n}\n\nfunction normalizeMockSpecifier(value: unknown): string {\n if (typeof value !== 'string') {\n throw new Error('Story rule mock specifier must be a string.');\n }\n\n const normalizedValue = value.trim();\n\n if (!normalizedValue) {\n throw new Error('Story rule mock specifier cannot be empty.');\n }\n\n return normalizedValue;\n}\n\nfunction normalizeMockReplacement(value: unknown, configFilePath?: string): string {\n if (typeof value !== 'string') {\n throw new Error('Story rule mock replacement must be a string.');\n }\n\n const normalizedValue = value.trim();\n\n if (!normalizedValue) {\n throw new Error('Story rule mock replacement cannot be empty.');\n }\n\n if (isAbsolute(normalizedValue)) {\n return toPosixPath(normalizedValue);\n }\n\n if (normalizedValue.startsWith('.')) {\n if (!configFilePath) {\n throw new Error(\n 'Story rule mock replacement uses a relative path, but rules config path is unavailable.'\n );\n }\n\n return toPosixPath(resolve(dirname(configFilePath), normalizedValue));\n }\n\n return normalizedValue;\n}\n\nfunction slugify(input: string): string {\n return input\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n\nfunction createEmptySelection(): MutableStoryRuleSelection {\n return {\n moduleMocks: new Map(),\n cleanups: []\n };\n}\n\nfunction toPosixPath(input: string): string {\n return input.replaceAll('\\\\', '/');\n}\n\nfunction escapeRegExp(input: string) {\n return input.replace(/[|\\\\{}()[\\]^$+?.]/g, '\\\\$&');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n return !Array.isArray(value);\n}\n","/**\n * Install a passthrough image service on `globalThis.astroAsset.imageService`.\n *\n * AstroContainer has no image service configuration API, and the default\n * `getConfiguredImageService()` tries to dynamically import \"virtual:image-service\"\n * which fails in astro6/Vite 7's module runner. Even when it succeeds (astro5),\n * the noop service still routes through /_image?href=... URLs that the Storybook\n * dev server cannot serve.\n *\n * Pre-populating `globalThis.astroAsset.imageService` bypasses the dynamic import\n * entirely — `getConfiguredImageService()` checks this global first and returns\n * it without going through the broken virtual module. Our service returns the\n * direct /@fs/... Vite URL from the ImageMetadata object, which Vite can serve\n * as a static asset in the browser; in static (build-time prerender) mode the\n * URL ends up being rewritten to a content-hashed Rollup asset.\n *\n * This must be called on the same Node process that hosts AstroContainer,\n * before `container.renderToString()` is invoked.\n */\nexport function installPassthroughImageService() {\n if (!globalThis.astroAsset) {\n (globalThis as Record<string, unknown>).astroAsset = {};\n }\n\n (globalThis.astroAsset as Record<string, unknown>).imageService = {\n propertiesToHash: ['src'],\n validateOptions(options: Record<string, unknown>) {\n return options;\n },\n getURL(options: { src: unknown }) {\n const src = options.src;\n\n if (\n src != null &&\n typeof src === 'object' &&\n 'src' in src &&\n typeof (src as Record<string, unknown>).src === 'string'\n ) {\n // ImageMetadata object — return the /@fs/... Vite URL directly\n return (src as Record<string, unknown>).src as string;\n }\n\n return typeof src === 'string' ? src : '';\n },\n getHTMLAttributes(options: Record<string, unknown>) {\n const {\n src,\n width,\n height,\n format: _format,\n quality: _quality,\n densities: _densities,\n widths: _widths,\n formats: _formats,\n layout: _layout,\n priority: _priority,\n fit: _fit,\n position: _position,\n background: _background,\n ...attrs\n } = options;\n const srcObj = src != null && typeof src === 'object' ? (src as Record<string, unknown>) : null;\n\n return {\n ...attrs,\n width: width ?? srcObj?.width,\n height: height ?? srcObj?.height,\n loading: (attrs.loading as string | undefined) ?? 'lazy',\n decoding: (attrs.decoding as string | undefined) ?? 'async'\n };\n },\n getSrcSet() {\n return [];\n }\n };\n}\n","import sanitizeHtml from 'sanitize-html';\nimport type { IOptions } from 'sanitize-html';\n\ntype SanitizationPayload = {\n args: Record<string, unknown>;\n slots: Record<string, unknown>;\n};\n\nexport type SanitizationOptions = {\n enabled?: boolean;\n args?: string[];\n slots?: string[];\n sanitizeHtml?: IOptions;\n};\n\nexport type ResolvedSanitizationOptions = {\n enabled: boolean;\n args: string[];\n slots: string[];\n sanitizeHtml: IOptions;\n};\n\nconst DEFAULT_SANITIZE_HTML_OPTIONS: IOptions = {\n allowedTags: [\n 'a',\n 'abbr',\n 'b',\n 'blockquote',\n 'br',\n 'caption',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'dd',\n 'details',\n 'dfn',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'figure',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'i',\n 'img',\n 'kbd',\n 'li',\n 'mark',\n 'ol',\n 'p',\n 'pre',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'u',\n 'ul',\n 'var',\n 'wbr'\n ],\n allowedAttributes: {\n '*': [\n 'aria-describedby',\n 'aria-hidden',\n 'aria-label',\n 'aria-labelledby',\n 'class',\n 'id',\n 'lang',\n 'role',\n 'title'\n ],\n a: ['href', 'name', 'target', 'rel'],\n img: ['src', 'srcset', 'alt', 'title', 'width', 'height', 'loading', 'decoding'],\n td: ['colspan', 'rowspan'],\n th: ['colspan', 'rowspan', 'scope'],\n time: ['datetime']\n },\n allowedSchemes: ['http', 'https', 'mailto', 'tel', 'data'],\n allowedSchemesByTag: {\n a: ['http', 'https', 'mailto', 'tel'],\n img: ['http', 'https', 'data']\n },\n allowedSchemesAppliedToAttributes: ['href', 'src', 'cite', 'srcset'],\n allowProtocolRelative: false,\n disallowedTagsMode: 'discard',\n enforceHtmlBoundary: true,\n parseStyleAttributes: false\n};\n\nexport function resolveSanitizationOptions(options?: SanitizationOptions): ResolvedSanitizationOptions {\n if (!options) {\n return {\n enabled: true,\n args: [],\n slots: ['**'],\n sanitizeHtml: mergeSanitizeHtmlOptions()\n };\n }\n\n const enabled = options.enabled ?? true;\n const args = normalizePathList(options.args, 'framework.options.sanitization.args');\n const slots =\n options.slots === undefined\n ? ['**']\n : normalizePathList(options.slots, 'framework.options.sanitization.slots');\n\n return {\n enabled,\n args,\n slots,\n sanitizeHtml: mergeSanitizeHtmlOptions(options.sanitizeHtml)\n };\n}\n\nexport function sanitizeRenderPayload(\n payload: SanitizationPayload,\n options: ResolvedSanitizationOptions\n): SanitizationPayload {\n if (!options.enabled) {\n return payload;\n }\n\n const sanitizedArgs =\n options.args.length > 0\n ? sanitizeRecord(payload.args, options.args, options.sanitizeHtml)\n : payload.args;\n\n const sanitizedSlots =\n options.slots.length > 0\n ? sanitizeRecord(payload.slots, options.slots, options.sanitizeHtml)\n : payload.slots;\n\n return {\n args: sanitizedArgs,\n slots: sanitizedSlots\n };\n}\n\nexport function serializeSanitizationOptions(options?: SanitizationOptions): string {\n if (!options) {\n return 'undefined';\n }\n\n assertNoFunctions(options.sanitizeHtml, 'framework.options.sanitization.sanitizeHtml');\n\n const state = {\n seen: new WeakSet<object>()\n };\n\n return serializeValue(options, 'framework.options.sanitization', state);\n}\n\nfunction mergeSanitizeHtmlOptions(userOptions?: IOptions): IOptions {\n const merged: IOptions = {\n ...DEFAULT_SANITIZE_HTML_OPTIONS,\n ...userOptions\n };\n\n if (\n isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes) &&\n isRecord(userOptions?.allowedAttributes)\n ) {\n merged.allowedAttributes = {\n ...DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes,\n ...userOptions.allowedAttributes\n };\n }\n\n if (isRecord(userOptions?.allowedClasses)) {\n merged.allowedClasses = {\n ...(isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses)\n ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses\n : {}),\n ...userOptions.allowedClasses\n };\n }\n\n if (isRecord(userOptions?.allowedStyles)) {\n merged.allowedStyles = {\n ...(isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles)\n ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles\n : {}),\n ...userOptions.allowedStyles\n };\n }\n\n return merged;\n}\n\nfunction normalizePathList(value: unknown, path: string): string[] {\n if (value === undefined) {\n return [];\n }\n\n if (!Array.isArray(value)) {\n throw new Error(`${path} must be an array of dot-path patterns.`);\n }\n\n const unique = new Set<string>();\n\n value.forEach((entry, index) => {\n if (typeof entry !== 'string') {\n throw new Error(`${path}[${index}] must be a string.`);\n }\n\n const normalized = entry.trim();\n\n if (!normalized) {\n throw new Error(`${path}[${index}] cannot be an empty string.`);\n }\n\n unique.add(normalized);\n });\n\n return Array.from(unique);\n}\n\nfunction sanitizeRecord(\n record: Record<string, unknown>,\n patterns: string[],\n options: IOptions\n): Record<string, unknown> {\n const sanitized: Record<string, unknown> = {};\n\n Object.entries(record).forEach(([key, value]) => {\n sanitized[key] = sanitizeValue(value, key, patterns, options);\n });\n\n return sanitized;\n}\n\nfunction sanitizeValue(\n value: unknown,\n currentPath: string,\n patterns: string[],\n options: IOptions\n): unknown {\n if (typeof value === 'string') {\n if (shouldSanitizePath(currentPath, patterns)) {\n return sanitizeHtml(value, options);\n }\n\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item, index) => {\n const nextPath = `${currentPath}.${index}`;\n\n return sanitizeValue(item, nextPath, patterns, options);\n });\n }\n\n if (isRecord(value)) {\n const sanitized: Record<string, unknown> = {};\n\n Object.entries(value).forEach(([key, nestedValue]) => {\n const nextPath = `${currentPath}.${key}`;\n\n sanitized[key] = sanitizeValue(nestedValue, nextPath, patterns, options);\n });\n\n return sanitized;\n }\n\n return value;\n}\n\nfunction shouldSanitizePath(path: string, patterns: string[]): boolean {\n return patterns.some((pattern) => matchesPathPattern(path, pattern));\n}\n\nfunction matchesPathPattern(path: string, pattern: string): boolean {\n const pathSegments = path.split('.');\n const patternSegments = pattern.split('.');\n\n return matchSegments(pathSegments, patternSegments);\n}\n\nfunction serializeValue(value: unknown, path: string, state: { seen: WeakSet<object> }): string {\n if (value === null) {\n return 'null';\n }\n\n if (value === undefined) {\n return 'undefined';\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return JSON.stringify(value);\n }\n\n if (value instanceof RegExp) {\n return value.toString();\n }\n\n if (Array.isArray(value)) {\n const serializedItems = value.map((item, index) =>\n serializeValue(item, `${path}[${index}]`, state)\n );\n\n return `[${serializedItems.join(', ')}]`;\n }\n\n if (isRecord(value)) {\n if (state.seen.has(value)) {\n throw new Error(`${path} contains a circular reference.`);\n }\n\n state.seen.add(value);\n\n const serializedEntries = Object.entries(value)\n .filter(([, nestedValue]) => nestedValue !== undefined)\n .map(([key, nestedValue]) => {\n const serializedNestedValue = serializeValue(nestedValue, `${path}.${key}`, state);\n\n return `${JSON.stringify(key)}: ${serializedNestedValue}`;\n });\n\n return `{ ${serializedEntries.join(', ')} }`;\n }\n\n throw new Error(\n `${path} contains an unsupported value of type ${typeof value}. ` +\n 'Only plain objects, arrays, primitives, and regular expressions are supported.'\n );\n}\n\nfunction assertNoFunctions(value: unknown, path: string): void {\n const state = {\n seen: new WeakSet<object>()\n };\n\n assertNoFunctionsRecursive(value, path, state);\n}\n\nfunction assertNoFunctionsRecursive(\n value: unknown,\n path: string,\n state: { seen: WeakSet<object> }\n): void {\n if (typeof value === 'function') {\n throw new Error(\n `${path} cannot contain functions. ` +\n 'Function-valued sanitization hooks are not supported in framework options.'\n );\n }\n\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n assertNoFunctionsRecursive(item, `${path}[${index}]`, state);\n });\n\n return;\n }\n\n if (isRecord(value)) {\n if (state.seen.has(value)) {\n return;\n }\n\n state.seen.add(value);\n\n Object.entries(value).forEach(([key, nestedValue]) => {\n assertNoFunctionsRecursive(nestedValue, `${path}.${key}`, state);\n });\n }\n}\n\nfunction matchSegments(pathSegments: string[], patternSegments: string[]): boolean {\n if (patternSegments.length === 0) {\n return pathSegments.length === 0;\n }\n\n const [patternHead, ...patternTail] = patternSegments;\n\n if (patternHead === '**') {\n if (patternTail.length === 0) {\n return true;\n }\n\n for (let index = 0; index <= pathSegments.length; index += 1) {\n const remainingPath = pathSegments.slice(index);\n\n if (matchSegments(remainingPath, patternTail)) {\n return true;\n }\n }\n\n return false;\n }\n\n if (pathSegments.length === 0) {\n return false;\n }\n\n const [pathHead, ...pathTail] = pathSegments;\n\n if (patternHead === '*' || patternHead === pathHead) {\n return matchSegments(pathTail, patternTail);\n }\n\n return false;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n if (Array.isArray(value) || value instanceof RegExp) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n\n return prototype === Object.prototype || prototype === null;\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\n\nexport type StoryModuleMocks = Map<string, string>;\n\nconst moduleMockStorage = new AsyncLocalStorage<StoryModuleMocks>();\n\nexport async function withStoryModuleMocks<T>(\n moduleMocks: StoryModuleMocks,\n callback: () => Promise<T>\n): Promise<T> {\n return moduleMockStorage.run(moduleMocks, callback);\n}\n\nexport function resolveStoryModuleMock(specifier: string): string | undefined {\n return moduleMockStorage.getStore()?.get(specifier);\n}\n"],"mappings":";AAAA,SAAS,SAAS,YAAY,eAAe;AA6CtC,SAAS,iBAAiB,QAA4C;AAC3E,SAAO;AACT;AAEA,eAAsB,iBACpB,OAC6B;AAC7B,QAAM,SAAS,qBAAqB,MAAM,YAAY;AACtD,QAAM,QAAQ,eAAe,MAAM,KAAK;AACxC,QAAM,YAAY,qBAAqB;AAEvC,aAAW,QAAQ,OAAO,OAAO;AAC/B,QAAI,CAAC,iBAAiB,KAAK,OAAO,KAAK,GAAG;AACxC;AAAA,IACF;AAEA,UAAM,OAAO,MAAM,QAAQ,KAAK,GAAG,IAAI,KAAK,MAAM,CAAC,KAAK,GAAG;AAE3D,eAAW,OAAO,MAAM;AACtB,UAAI,OAAO,QAAQ,YAAY;AAC7B,cAAM,IAAI,MAAM,iDAAiD;AAAA,MACnE;AAEA,YAAM,UAAU,MAAM,IAAI;AAAA,QACxB;AAAA,QACA,MAAM,CAAC,WAAW,gBAAgB;AAChC,gBAAM,sBAAsB,uBAAuB,SAAS;AAC5D,gBA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}
@@ -1,4 +1,5 @@
1
1
  import {
2
+ installPassthroughImageService,
2
3
  resolveSanitizationOptions,
3
4
  resolveStoryModuleMock,
4
5
  sanitizeRenderPayload,
@@ -6,7 +7,7 @@ import {
6
7
  serializeSanitizationOptions,
7
8
  withStoryModuleMocks,
8
9
  withStoryRuleCleanups
9
- } from "./chunk-V76WSNSP.js";
10
+ } from "./chunk-OUEDTRBO.js";
10
11
  import {
11
12
  createVirtualModulePlugin,
12
13
  resolveRulesConfigFilePath,
@@ -79,7 +80,6 @@ function viteStorybookAstroRendererPlugin(options) {
79
80
  import { createRequire } from "module";
80
81
  import { mkdir, readFile, readdir, writeFile } from "fs/promises";
81
82
  import { resolve } from "path";
82
- import { experimental_AstroContainer as AstroContainer } from "astro/container";
83
83
  import { createServer, mergeConfig } from "vite";
84
84
  var PRERENDERED_STORIES_FILE = "astro-prerendered-stories.json";
85
85
  function vitePluginAstroBuildPrerender(options) {
@@ -115,7 +115,8 @@ function vitePluginAstroBuildPrerender(options) {
115
115
  return [`import '${specifier}';`, "export default undefined;"].join("\n");
116
116
  }
117
117
  if (id.startsWith("\0virtual:astro-component-module/")) {
118
- const encodedSpecifier = id.replace("\0virtual:astro-component-module/", "");
118
+ const withoutPrefix = id.replace("\0virtual:astro-component-module/", "");
119
+ const encodedSpecifier = withoutPrefix.replace(/\?.*$/, "");
119
120
  const specifier = decodeURIComponent(encodedSpecifier);
120
121
  return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join("\n");
121
122
  }
@@ -134,17 +135,21 @@ function vitePluginAstroBuildPrerender(options) {
134
135
  });
135
136
  staticEntrypointRefs.set(specifier, fileReferenceId);
136
137
  });
137
- const srcRoot = resolve(resolveFrom, "src/components");
138
- const specifiers = await collectHydratableSourceModules(srcRoot);
138
+ const componentRootPaths = [
139
+ resolve(resolveFrom, "src/components"),
140
+ ...options.renderMode === "static" && options.componentRoots ? options.componentRoots.map((root) => resolve(resolveFrom, root)) : []
141
+ ];
142
+ const specifierArrays = await Promise.all(
143
+ componentRootPaths.map((root) => collectHydratableSourceModules(root))
144
+ );
145
+ const specifiers = specifierArrays.flat();
139
146
  specifiers.forEach((specifier) => {
140
- const fileReferenceId = this.emitFile({
141
- type: "chunk",
142
- id: toComponentVirtualId(specifier)
143
- });
147
+ const chunkId = /\.(svelte|vue)$/.test(specifier) ? specifier : toComponentVirtualId(specifier);
148
+ const fileReferenceId = this.emitFile({ type: "chunk", id: chunkId });
144
149
  componentEntrypointRefs.set(specifier, fileReferenceId);
145
150
  });
146
151
  },
147
- async writeBundle() {
152
+ async writeBundle(_outputOptions, bundle) {
148
153
  const staticModuleMap = buildStaticModuleMap(
149
154
  this,
150
155
  staticEntrypointRefs,
@@ -162,7 +167,8 @@ function vitePluginAstroBuildPrerender(options) {
162
167
  storyRulesConfigFilePath,
163
168
  staticModuleMap,
164
169
  trackedSpecifiers,
165
- resolveFrom
170
+ resolveFrom,
171
+ bundle
166
172
  });
167
173
  await writePrerenderedStoriesFile(outDir, prerenderedStories);
168
174
  }
@@ -184,8 +190,12 @@ async function prerenderStories(options) {
184
190
  options.resolveFrom
185
191
  );
186
192
  const rulesConfigModule = await loadRulesConfigModule(viteServer, options.storyRulesConfigFilePath);
193
+ const assetPathMap = buildAssetPathMap(options.bundle);
194
+ installPassthroughImageService();
187
195
  try {
188
- const container = await AstroContainer.create({
196
+ const containerModule = await viteServer.ssrLoadModule("astro/container");
197
+ const AstroContainerRuntime = containerModule.experimental_AstroContainer;
198
+ const container = await AstroContainerRuntime.create({
189
199
  resolve: async (specifier) => {
190
200
  const mockedModule = resolveStoryModuleMock(specifier);
191
201
  if (mockedModule) {
@@ -247,7 +257,7 @@ async function prerenderStories(options) {
247
257
  });
248
258
  });
249
259
  if (html !== void 0) {
250
- output[story.id] = html;
260
+ output[story.id] = rewriteAssetPaths(html, assetPathMap);
251
261
  }
252
262
  }
253
263
  return output;
@@ -278,6 +288,15 @@ async function createStorySsrServer(integrations, trackedSpecifiers, resolveFrom
278
288
  server: {
279
289
  middlewareMode: true
280
290
  },
291
+ ssr: {
292
+ // Force Astro runtime modules to be loaded through Vite's SSR transform
293
+ // pipeline rather than being externalized via Node.js native import().
294
+ // Without this, the AstroContainer (loaded via ssrLoadModule) and the
295
+ // component rendering pipeline may resolve internal classes like
296
+ // SlotString/HTMLString from separate module instances, causing
297
+ // instanceof checks to fail and slot HTML to be escaped.
298
+ noExternal: /^astro(\/.+)?$/
299
+ },
281
300
  plugins: [
282
301
  createProjectAstroResolutionPlugin(resolveFrom),
283
302
  vitePluginAstroFontsFallback(),
@@ -447,7 +466,7 @@ function toStaticVirtualId(specifier) {
447
466
  return `virtual:astro-static-module/${encodeURIComponent(specifier)}`;
448
467
  }
449
468
  function toComponentVirtualId(specifier) {
450
- return `virtual:astro-component-module/${encodeURIComponent(specifier)}`;
469
+ return `virtual:astro-component-module/${encodeURIComponent(specifier)}?component-wrapper`;
451
470
  }
452
471
  function isClientEntrypoint(specifier) {
453
472
  return specifier.startsWith("@astrojs/") && specifier.endsWith("/client.js");
@@ -455,6 +474,48 @@ function isClientEntrypoint(specifier) {
455
474
  function toPublicPath(fileName) {
456
475
  return `./${fileName}`;
457
476
  }
477
+ function buildAssetPathMap(bundle) {
478
+ const exactMap = /* @__PURE__ */ new Map();
479
+ const stemMap = /* @__PURE__ */ new Map();
480
+ for (const chunk of Object.values(bundle)) {
481
+ if (chunk.type !== "asset") {
482
+ continue;
483
+ }
484
+ const asset = chunk;
485
+ if (asset.originalFileNames && asset.originalFileNames.length > 0) {
486
+ for (const originalPath of asset.originalFileNames) {
487
+ exactMap.set(originalPath, `/${asset.fileName}`);
488
+ }
489
+ }
490
+ const baseName = asset.fileName.split("/").pop() ?? "";
491
+ const stemMatch = baseName.match(/^(.+)-[A-Za-z0-9]{6,12}\.(png|jpe?g|gif|webp|svg|avif|ico)$/);
492
+ if (stemMatch) {
493
+ stemMap.set(`${stemMatch[1]}.${stemMatch[2]}`, `/${asset.fileName}`);
494
+ }
495
+ }
496
+ return { exactMap, stemMap };
497
+ }
498
+ function rewriteAssetPaths(html, assetPathMap) {
499
+ const { exactMap, stemMap } = assetPathMap;
500
+ if (exactMap.size === 0 && stemMap.size === 0) {
501
+ return html;
502
+ }
503
+ return html.replace(/\/@fs\/[^"']+/g, (match) => {
504
+ const pathOnly = match.replace(/\?.*$/, "");
505
+ const fsPath = pathOnly.slice("/@fs".length);
506
+ const absolutePath = fsPath.startsWith("//") ? fsPath.slice(1) : fsPath;
507
+ const exact = exactMap.get(absolutePath);
508
+ if (exact) {
509
+ return exact;
510
+ }
511
+ const baseName = absolutePath.split("/").pop() ?? "";
512
+ const stemHit = stemMap.get(baseName);
513
+ if (stemHit) {
514
+ return stemHit;
515
+ }
516
+ return match;
517
+ });
518
+ }
458
519
  async function collectHydratableSourceModules(srcRoot) {
459
520
  const modules = [];
460
521
  async function walk(directory) {
@@ -489,7 +550,7 @@ async function collectHydratableSourceModules(srcRoot) {
489
550
  return modules;
490
551
  }
491
552
  function isHydratableSourceFile(input) {
492
- return /\.(jsx|tsx|vue|svelte|js|ts)$/.test(input);
553
+ return /\.(jsx|tsx|vue|svelte)$/.test(input);
493
554
  }
494
555
  function isNonHydratableSourceFile(input) {
495
556
  return /\.stories\.[jt]sx?$|\.stories\.vue$|\.stories\.svelte$|\.(spec|test)\.[jt]sx?$/.test(
@@ -932,10 +993,40 @@ function isNonHydratableSourceFile2(input) {
932
993
  );
933
994
  }
934
995
 
996
+ // src/vitePluginAstroToolbarFallback.ts
997
+ var TOOLBAR_INTERNAL_STUB = `
998
+ export const loadDevToolbarApps = async () => [];
999
+ `;
1000
+ function vitePluginAstroToolbarFallback() {
1001
+ const VIRTUAL_ID = "astro:toolbar:internal";
1002
+ const RESOLVED_ID = "\0" + VIRTUAL_ID;
1003
+ return {
1004
+ name: "storybook-astro-toolbar-fallback",
1005
+ enforce: "pre",
1006
+ resolveId(id) {
1007
+ if (id === VIRTUAL_ID) {
1008
+ return RESOLVED_ID;
1009
+ }
1010
+ },
1011
+ load(id) {
1012
+ if (id === RESOLVED_ID) {
1013
+ return { code: TOOLBAR_INTERNAL_STUB };
1014
+ }
1015
+ }
1016
+ };
1017
+ }
1018
+
935
1019
  // src/preset.ts
936
1020
  var core = {
937
1021
  builder: "@storybook/builder-vite",
938
- renderer: "@storybook-astro/renderer"
1022
+ // Use import.meta.resolve so Storybook receives an absolute file:// URL
1023
+ // to the renderer preset rather than a bare package specifier. When
1024
+ // package managers like pnpm use strict node_modules isolation, bare
1025
+ // specifiers are resolved from the *project root*, where the renderer
1026
+ // (a dep of this framework, not the user's project) is not hoisted.
1027
+ // The absolute URL is resolved from *this* file's location where the
1028
+ // renderer is always accessible as a direct dependency.
1029
+ renderer: import.meta.resolve("@storybook-astro/renderer")
939
1030
  };
940
1031
  var viteFinal = async (config, { configType, presets }) => {
941
1032
  const options = await presets.apply("frameworkOptions");
@@ -960,6 +1051,7 @@ var viteFinal = async (config, { configType, presets }) => {
960
1051
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
961
1052
  vitePluginAstroComponentMarker(),
962
1053
  vitePluginAstroIntegrationOptsFallback(),
1054
+ vitePluginAstroToolbarFallback(),
963
1055
  vitePluginAstroVueFallback()
964
1056
  );
965
1057
  if (configType === "DEVELOPMENT") {
@@ -1011,7 +1103,8 @@ var viteFinal = async (config, { configType, presets }) => {
1011
1103
  "virtual:@astrojs/vue/app",
1012
1104
  "virtual:astro:vue-app",
1013
1105
  "astro:react:opts",
1014
- "astro:preact:opts"
1106
+ "astro:preact:opts",
1107
+ "astro:toolbar:internal"
1015
1108
  ];
1016
1109
  if (!finalConfig.optimizeDeps.esbuildOptions) {
1017
1110
  finalConfig.optimizeDeps.esbuildOptions = {};
@@ -1041,4 +1134,4 @@ export {
1041
1134
  core,
1042
1135
  viteFinal
1043
1136
  };
1044
- //# sourceMappingURL=chunk-VPJDFGB5.js.map
1137
+ //# sourceMappingURL=chunk-PBISP7PA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/viteStorybookRendererFallbackPlugin.ts","../src/viteStorybookAstroRendererPlugin.ts","../src/vitePluginAstroBuildPrerender.ts","../src/vitePluginAstroBuildServer.ts","../src/vitePluginAstro.ts","../src/vite/astroFilesVirtualModulePlugin.ts","../src/vite/storybookAstroRulesConfigVirtualModulePlugin.ts","../src/vite/storybookAstroSanitizationConfigVirtualModulePlugin.ts","../src/vite/storybookAstroServerAuthConfigVirtualModulePlugin.ts","../src/vitePluginAstroToolbarFallback.ts","../src/preset.ts"],"sourcesContent":["import type { Integration } from './integrations/index.ts';\nimport { createVirtualModulePlugin } from './vite/createVirtualModulePlugin.ts';\n\nexport function viteStorybookRendererFallbackPlugin(integrations: Integration[]) {\n const safeIntegrations = integrations ?? [];\n\n return createVirtualModulePlugin({\n pluginName: 'storybook-renderer-fallback',\n virtualModuleId: 'virtual:storybook-renderer-fallback',\n load() {\n return safeIntegrations\n .filter((integration) => integration.storybookEntryPreview)\n .map(\n (integration) =>\n `export * as ${integration.name} from '${integration.storybookEntryPreview}';`\n )\n .join('\\n');\n }\n });\n}\n","import type { RenderMode, ServerBuildOptions } from './types.ts';\nimport { createVirtualModulePlugin } from './vite/createVirtualModulePlugin.ts';\n\nconst packageName = '@storybook-astro/framework';\n\nexport function viteStorybookAstroRendererPlugin(options: {\n mode: 'development' | 'production';\n renderMode?: RenderMode;\n server?: ServerBuildOptions;\n}) {\n const pluginName = 'storybook-astro:renderer-module';\n const virtualModuleId = 'virtual:storybook-astro-renderer';\n const isProduction = options.mode === 'production';\n const isStaticMode = options.renderMode === 'static';\n\n return createVirtualModulePlugin({\n pluginName,\n virtualModuleId,\n load() {\n if (!isProduction) {\n return `export * from '${packageName}/renderer/renderer-dev.ts';`;\n }\n\n if (isStaticMode) {\n return `export * from '${packageName}/renderer/renderer-static.ts';`;\n }\n\n return [\n `import { createServerRenderer } from '${packageName}/renderer/renderer-server.ts';`,\n `const renderer = createServerRenderer(${JSON.stringify(\n {\n serverUrl: options.server?.serverUrl,\n authToken: options.server?.authToken,\n authHeader: options.server?.authHeader\n },\n null,\n 2\n )});`,\n 'export const render = renderer.render;',\n 'export const init = renderer.init;',\n 'export const applyStyles = renderer.applyStyles;'\n ].join('\\n');\n }\n });\n}\n","import { createRequire } from 'node:module';\nimport type { Dirent } from 'node:fs';\nimport { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport type { experimental_AstroContainer as AstroContainer } from 'astro/container';\nimport { createServer, mergeConfig, type Plugin, type Rollup } from 'vite';\nimport { importAstroConfig } from './importAstroConfig.ts';\nimport type { Integration } from './integrations/index.ts';\nimport { installPassthroughImageService } from './lib/passthrough-image-service.ts';\nimport { ssrLoadModuleWithFsFallback } from './lib/ssr-load-module-with-fs-fallback.ts';\nimport { resolveSanitizationOptions, sanitizeRenderPayload } from './lib/sanitization.ts';\nimport { resolveStoryModuleMock, withStoryModuleMocks } from './module-mocks.ts';\nimport { resolveRulesConfigFilePath } from './rules-options.ts';\nimport { selectStoryRules, withStoryRuleCleanups } from './rules.ts';\nimport type { FrameworkOptions } from './types.ts';\nimport { vitePluginAstroFontsFallback } from './vitePluginAstroFontsFallback.ts';\nimport { vitePluginAstroIntegrationOptsFallback } from './vitePluginAstroIntegrationOptsFallback.ts';\nimport { vitePluginAstroRoutesFallback } from './vitePluginAstroRoutesFallback.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\n\nconst PRERENDERED_STORIES_FILE = 'astro-prerendered-stories.json';\n\ntype StoryIndex = {\n entries?: Record<\n string,\n {\n type?: string;\n id?: string;\n importPath?: string;\n exportName?: string;\n componentPath?: string;\n title?: string;\n name?: string;\n }\n >;\n};\n\ntype StoryEntry = {\n id: string;\n importPath: string;\n exportName: string;\n title?: string;\n name?: string;\n};\n\ntype AstroCreateResult = {\n createAstro?: (...args: unknown[]) => unknown;\n};\n\ntype AstroComponentFactory = ((\n result: AstroCreateResult,\n props: unknown,\n slots: unknown\n) => unknown) & {\n isAstroComponentFactory?: boolean;\n moduleId?: string;\n propagation?: unknown;\n};\n\nexport function vitePluginAstroBuildPrerender(options: FrameworkOptions): Plugin {\n const integrations = options.integrations ?? [];\n const resolveFrom = options.resolveFrom ?? process.cwd();\n const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, resolveFrom);\n const trackedSpecifiers = collectTrackedSpecifiers(integrations);\n const staticEntrypointRefs = new Map<string, string>();\n const componentEntrypointRefs = new Map<string, string>();\n let outDir = resolve(resolveFrom, 'storybook-static');\n\n return {\n name: 'storybook-astro:build-prerender',\n apply: 'build',\n enforce: 'post',\n\n configResolved(config) {\n outDir = resolve(resolveFrom, config.build.outDir ?? 'storybook-static');\n },\n\n resolveId(id: string) {\n if (id.startsWith('virtual:astro-static-module/')) {\n return `\\0${id}`;\n }\n\n if (id.startsWith('virtual:astro-component-module/')) {\n return `\\0${id}`;\n }\n },\n\n load(id: string) {\n if (id.startsWith('\\0virtual:astro-static-module/')) {\n const encodedSpecifier = id.replace('\\0virtual:astro-static-module/', '');\n const specifier = decodeURIComponent(encodedSpecifier);\n\n if (isClientEntrypoint(specifier)) {\n return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join('\\n');\n }\n\n return [`import '${specifier}';`, 'export default undefined;'].join('\\n');\n }\n\n if (id.startsWith('\\0virtual:astro-component-module/')) {\n const withoutPrefix = id.replace('\\0virtual:astro-component-module/', '');\n // Strip the ?component-wrapper query appended by toComponentVirtualId\n const encodedSpecifier = withoutPrefix.replace(/\\?.*$/, '');\n const specifier = decodeURIComponent(encodedSpecifier);\n\n return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join('\\n');\n }\n },\n\n async buildStart(this: Rollup.PluginContext) {\n integrations.forEach((integration) => {\n const entrypoint = integration.renderer.client?.entrypoint;\n\n if (entrypoint) {\n this.addWatchFile(entrypoint);\n }\n });\n\n trackedSpecifiers.forEach((specifier) => {\n const fileReferenceId = this.emitFile({\n type: 'chunk',\n id: toStaticVirtualId(specifier)\n });\n\n staticEntrypointRefs.set(specifier, fileReferenceId);\n });\n\n const componentRootPaths = [\n resolve(resolveFrom, 'src/components'),\n ...(options.renderMode === 'static' && options.componentRoots\n ? options.componentRoots.map((root) => resolve(resolveFrom, root))\n : [])\n ];\n const specifierArrays = await Promise.all(\n componentRootPaths.map((root) => collectHydratableSourceModules(root))\n );\n const specifiers = specifierArrays.flat();\n\n specifiers.forEach((specifier) => {\n // .svelte and .vue files must be emitted as direct chunks so their\n // native Vite compile plugins process them correctly. The virtual\n // module wrapper exposes a JS re-export stub; vite-plugin-svelte and\n // @vitejs/plugin-vue strip the query string before checking the\n // extension, so they still try to compile the stub as framework source.\n const chunkId = /\\.(svelte|vue)$/.test(specifier)\n ? specifier\n : toComponentVirtualId(specifier);\n\n const fileReferenceId = this.emitFile({ type: 'chunk', id: chunkId });\n\n componentEntrypointRefs.set(specifier, fileReferenceId);\n });\n },\n\n async writeBundle(this: Rollup.PluginContext, _outputOptions: Rollup.NormalizedOutputOptions, bundle: Rollup.OutputBundle) {\n const staticModuleMap = buildStaticModuleMap(\n this,\n staticEntrypointRefs,\n componentEntrypointRefs\n );\n\n const stories = await collectAstroStories(outDir);\n\n if (stories.length === 0) {\n await writePrerenderedStoriesFile(outDir, {});\n\n return;\n }\n\n const prerenderedStories = await prerenderStories({\n stories,\n integrations,\n sanitization: options.sanitization,\n storyRulesConfigFilePath,\n staticModuleMap,\n trackedSpecifiers,\n resolveFrom,\n bundle\n });\n\n await writePrerenderedStoriesFile(outDir, prerenderedStories);\n }\n };\n}\n\nasync function writePrerenderedStoriesFile(outDir: string, payload: Record<string, string>) {\n await mkdir(outDir, { recursive: true });\n await writeFile(resolve(outDir, PRERENDERED_STORIES_FILE), JSON.stringify(payload), 'utf-8');\n}\n\nasync function prerenderStories(options: {\n stories: StoryEntry[];\n integrations: Integration[];\n sanitization?: FrameworkOptions['sanitization'];\n storyRulesConfigFilePath?: string;\n staticModuleMap: Record<string, string>;\n trackedSpecifiers: Set<string>;\n resolveFrom: string;\n bundle: Rollup.OutputBundle;\n}) {\n const sanitizationOptions = resolveSanitizationOptions(options.sanitization ?? undefined);\n const resolveClientModule = createClientModuleResolver(\n options.integrations,\n options.staticModuleMap\n );\n const viteServer = await createStorySsrServer(\n options.integrations,\n options.trackedSpecifiers,\n options.resolveFrom\n );\n const rulesConfigModule = await loadRulesConfigModule(viteServer, options.storyRulesConfigFilePath);\n const assetPathMap = buildAssetPathMap(options.bundle);\n\n // Inject a passthrough image service before the container renders any\n // components. The `image: { service: passthroughImageService() }` config\n // passed to Astro above is not sufficient on Astro 6: at render time\n // `getConfiguredImageService()` still dynamically imports\n // \"virtual:image-service\", which fails in Vite 7's module runner with\n // `InvalidImageService`. Pre-populating globalThis.astroAsset.imageService\n // short-circuits that dynamic import. See `lib/passthrough-image-service.ts`.\n installPassthroughImageService();\n\n try {\n // Load AstroContainer through the SSR module graph so that internal\n // classes (SlotString, HTMLString) share the same module instance as the\n // Astro components loaded via ssrLoadModule below. Cross-module instanceof\n // checks fail when AstroContainer is imported statically (Node.js context)\n // and components are loaded via Vite SSR (separate module graph), which\n // causes slot HTML to be escaped character-by-character instead of being\n // passed through as raw HTML.\n const containerModule = await viteServer.ssrLoadModule('astro/container');\n const AstroContainerRuntime = containerModule.experimental_AstroContainer as typeof AstroContainer;\n\n const container = await AstroContainerRuntime.create({\n resolve: async (specifier) => {\n const mockedModule = resolveStoryModuleMock(specifier);\n\n if (mockedModule) {\n return mockedModule;\n }\n\n const resolution = resolveClientModule(specifier);\n\n if (resolution) {\n return resolution;\n }\n\n return specifier;\n }\n });\n\n await addContainerRenderers(container, options.integrations, resolveClientModule, viteServer);\n\n const output: Record<string, string> = {};\n\n for (const story of options.stories) {\n const selectedRules = await selectStoryRules({\n configModule: rulesConfigModule,\n configFilePath: options.storyRulesConfigFilePath,\n story: {\n id: story.id,\n title: story.title,\n name: story.name\n }\n });\n\n if (selectedRules.moduleMocks.size > 0) {\n viteServer.moduleGraph.invalidateAll();\n }\n\n const html = await withStoryRuleCleanups(selectedRules.cleanups, async () => {\n return withStoryModuleMocks(selectedRules.moduleMocks, async () => {\n const modulePath = resolveImportPath(story.importPath, options.resolveFrom);\n const storyModule = await viteServer.ssrLoadModule(modulePath);\n const meta = isRecord(storyModule.default) ? storyModule.default : {};\n const storyExport = isRecord(storyModule[story.exportName])\n ? storyModule[story.exportName]\n : {};\n\n if (typeof meta.component !== 'function') {\n throw new Error(\n `Unable to prerender story \"${story.id}\". Missing default export component in ${story.importPath}.`\n );\n }\n\n if (storyExport.component && storyExport.component !== meta.component) {\n return undefined;\n }\n\n const mergedArgs = mergeStoryArgs(toRecord(meta.args), toRecord(storyExport.args));\n const { args, slots } = separateSlots(mergedArgs);\n const processedArgs = await processImageMetadata(args);\n const sanitizedPayload = sanitizeRenderPayload(\n {\n args: processedArgs,\n slots\n },\n sanitizationOptions\n );\n\n return container.renderToString(\n patchCreateAstroCompat(meta.component) as Parameters<typeof container.renderToString>[0],\n {\n props: sanitizedPayload.args,\n slots: sanitizedPayload.slots\n }\n );\n });\n });\n\n if (html !== undefined) {\n output[story.id] = rewriteAssetPaths(html, assetPathMap);\n }\n }\n\n return output;\n } finally {\n await viteServer.close();\n }\n}\n\nasync function createStorySsrServer(\n integrations: Integration[],\n trackedSpecifiers: Set<string>,\n resolveFrom: string\n) {\n const { getViteConfig, passthroughImageService } = await importAstroConfig(resolveFrom);\n const astroConfig = await getViteConfig(\n { root: resolveFrom },\n {\n configFile: false,\n integrations: await Promise.all(\n integrations.map((integration) => integration.loadIntegration(resolveFrom))\n ),\n // Use the passthrough image service so nested components that use <Image>\n // from astro:assets render as plain <img> tags without triggering image\n // optimization (which fails in the Storybook SSR context).\n image: { service: passthroughImageService() }\n }\n )({\n mode: 'production',\n command: 'serve'\n });\n\n const config = mergeConfig(astroConfig, {\n appType: 'custom',\n server: {\n middlewareMode: true\n },\n ssr: {\n // Force Astro runtime modules to be loaded through Vite's SSR transform\n // pipeline rather than being externalized via Node.js native import().\n // Without this, the AstroContainer (loaded via ssrLoadModule) and the\n // component rendering pipeline may resolve internal classes like\n // SlotString/HTMLString from separate module instances, causing\n // instanceof checks to fail and slot HTML to be escaped.\n noExternal: /^astro(\\/.+)?$/\n },\n plugins: [\n createProjectAstroResolutionPlugin(resolveFrom),\n vitePluginAstroFontsFallback(),\n vitePluginAstroIntegrationOptsFallback(),\n vitePluginAstroVueFallback(),\n vitePluginAstroRoutesFallback(),\n {\n name: 'storybook-astro:static-prerender-ssr-stubs',\n resolveId(id: string) {\n if (trackedSpecifiers.has(id)) {\n return `\\0storybook-astro-static-prerender-stub:${encodeURIComponent(id)}`;\n }\n },\n load(id: string) {\n if (id.startsWith('\\0storybook-astro-static-prerender-stub:')) {\n return 'export default undefined;';\n }\n }\n }\n ]\n });\n\n return createServer(config);\n}\n\nasync function loadRulesConfigModule(\n viteServer: Awaited<ReturnType<typeof createStorySsrServer>>,\n configFilePath?: string\n) {\n if (!configFilePath) {\n return undefined;\n }\n\n try {\n return await ssrLoadModuleWithFsFallback(viteServer, configFilePath, {\n fixStacktrace: true\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n\n throw new Error(\n `Unable to load framework.options.storyRules config module at ${configFilePath}: ${reason}`\n );\n }\n}\n\nasync function addContainerRenderers(\n container: Awaited<ReturnType<typeof AstroContainer.create>>,\n integrations: Integration[],\n resolveClientModule: (specifier: string) => string | undefined,\n viteServer: Awaited<ReturnType<typeof createStorySsrServer>>\n) {\n for (const integration of integrations) {\n const serverRenderer = integration.renderer.server;\n\n if (serverRenderer) {\n const serverRendererModule = await viteServer.ssrLoadModule(serverRenderer.entrypoint);\n const renderer = serverRendererModule.default ?? serverRendererModule;\n\n if (integration.name === 'solid' && isRecord(renderer)) {\n container.addServerRenderer({\n name: serverRenderer.name,\n renderer: {\n ...renderer,\n name: serverRenderer.name\n } as Parameters<typeof container.addServerRenderer>[0]['renderer']\n });\n } else {\n container.addServerRenderer({\n name: serverRenderer.name,\n renderer\n });\n }\n }\n\n const clientRenderer = integration.renderer.client;\n\n if (clientRenderer) {\n const resolvedEntrypoint =\n resolveClientModule(clientRenderer.entrypoint) ?? clientRenderer.entrypoint;\n\n container.addClientRenderer({\n name: clientRenderer.name,\n entrypoint: resolvedEntrypoint\n });\n }\n }\n}\n\nfunction createClientModuleResolver(\n integrations: Integration[],\n staticModuleMap: Record<string, string>\n) {\n return function resolveClientModule(specifier: string) {\n if (Object.hasOwn(staticModuleMap, specifier)) {\n return staticModuleMap[specifier];\n }\n\n const normalizedSpecifier = specifier.replace(/\\\\/g, '/').replace(/\\?.*$/, '');\n\n if (Object.hasOwn(staticModuleMap, normalizedSpecifier)) {\n return staticModuleMap[normalizedSpecifier];\n }\n\n for (const integration of integrations) {\n const resolution = integration.resolveClient(specifier);\n\n if (resolution) {\n return resolution;\n }\n }\n };\n}\n\nasync function collectAstroStories(outDir: string): Promise<StoryEntry[]> {\n const indexFile = resolve(outDir, 'index.json');\n const indexRaw = await readFile(indexFile, 'utf-8');\n const indexJson = JSON.parse(indexRaw) as StoryIndex;\n\n return Object.values(indexJson.entries ?? {})\n .filter((entry) => entry.type === 'story' && entry.componentPath?.endsWith('.astro'))\n .map((entry) => {\n if (!entry.id || !entry.importPath || !entry.exportName) {\n throw new Error(`Encountered an invalid Storybook index entry in ${indexFile}.`);\n }\n\n return {\n id: entry.id,\n importPath: entry.importPath,\n exportName: entry.exportName,\n title: entry.title,\n name: entry.name\n };\n });\n}\n\nfunction mergeStoryArgs(\n metaArgs: Record<string, unknown> | undefined,\n storyArgs: Record<string, unknown> | undefined\n) {\n return {\n ...(metaArgs ?? {}),\n ...(storyArgs ?? {})\n };\n}\n\nfunction separateSlots(inputArgs: Record<string, unknown>) {\n const args = { ...inputArgs };\n const slotsCandidate = args.slots;\n\n delete args.slots;\n\n if (!isRecord(slotsCandidate)) {\n return {\n args,\n slots: {}\n };\n }\n\n return {\n args,\n slots: slotsCandidate as Record<string, string>\n };\n}\n\nfunction resolveImportPath(importPath: string, resolveFrom: string) {\n if (importPath.startsWith('./')) {\n return resolve(resolveFrom, importPath.slice(2));\n }\n\n return resolve(resolveFrom, importPath);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction toRecord(value: unknown): Record<string, unknown> | undefined {\n if (!isRecord(value)) {\n return undefined;\n }\n\n return value;\n}\n\nfunction collectTrackedSpecifiers(integrations: Integration[]) {\n const specifiers = new Set<string>(['astro:scripts/page.js', 'astro:scripts/before-hydration.js']);\n\n integrations.forEach((integration) => {\n const entrypoint = integration.renderer.client?.entrypoint;\n\n if (entrypoint) {\n specifiers.add(entrypoint);\n }\n });\n\n return specifiers;\n}\n\nfunction buildStaticModuleMap(\n pluginContext: Rollup.PluginContext,\n staticEntrypointRefs: Map<string, string>,\n componentEntrypointRefs: Map<string, string>\n) {\n const map: Record<string, string> = {};\n\n staticEntrypointRefs.forEach((fileReferenceId, specifier) => {\n const fileName = pluginContext.getFileName(fileReferenceId);\n\n if (fileName) {\n map[specifier] = toPublicPath(fileName);\n }\n });\n\n componentEntrypointRefs.forEach((fileReferenceId, specifier) => {\n const fileName = pluginContext.getFileName(fileReferenceId);\n\n if (fileName) {\n map[specifier] = toPublicPath(fileName);\n }\n });\n\n return map;\n}\n\nfunction toStaticVirtualId(specifier: string) {\n return `virtual:astro-static-module/${encodeURIComponent(specifier)}`;\n}\n\nfunction toComponentVirtualId(specifier: string) {\n // Append a non-extension suffix so framework compile plugins (e.g. vite-plugin-svelte)\n // don't match the virtual module ID by extension and try to compile the JS re-export stub.\n return `virtual:astro-component-module/${encodeURIComponent(specifier)}?component-wrapper`;\n}\n\nfunction isClientEntrypoint(specifier: string) {\n return specifier.startsWith('@astrojs/') && specifier.endsWith('/client.js');\n}\n\nfunction toPublicPath(fileName: string) {\n return `./${fileName}`;\n}\n\nfunction buildAssetPathMap(bundle: Rollup.OutputBundle): Map<string, string> {\n const exactMap = new Map<string, string>();\n const stemMap = new Map<string, string>();\n\n for (const chunk of Object.values(bundle)) {\n if (chunk.type !== 'asset') {\n continue;\n }\n\n const asset = chunk as Rollup.OutputAsset;\n\n if (asset.originalFileNames && asset.originalFileNames.length > 0) {\n for (const originalPath of asset.originalFileNames) {\n exactMap.set(originalPath, `/${asset.fileName}`);\n }\n }\n\n // Vite does not populate originalFileNames for image assets processed\n // through its asset pipeline. Build a secondary lookup by the filename\n // stem so /@fs/ URLs in prerendered HTML can still be mapped to their\n // content-hashed output paths. e.g. \"storybook-astro-CfMmZdup.png\" ⟶\n // stem key \"storybook-astro.png\" ⟶ \"/_astro/storybook-astro-CfMmZdup.png\".\n const baseName = asset.fileName.split('/').pop() ?? '';\n const stemMatch = baseName.match(/^(.+)-[A-Za-z0-9]{6,12}\\.(png|jpe?g|gif|webp|svg|avif|ico)$/);\n\n if (stemMatch) {\n stemMap.set(`${stemMatch[1]}.${stemMatch[2]}`, `/${asset.fileName}`);\n }\n }\n\n return { exactMap, stemMap } as unknown as Map<string, string>;\n}\n\nfunction rewriteAssetPaths(html: string, assetPathMap: ReturnType<typeof buildAssetPathMap>): string {\n const { exactMap, stemMap } = assetPathMap as unknown as {\n exactMap: Map<string, string>;\n stemMap: Map<string, string>;\n };\n\n if (exactMap.size === 0 && stemMap.size === 0) {\n return html;\n }\n\n // Match /@fs/ URLs in HTML attribute values, stripping any query string.\n // Vite dev server uses /@fs//absolute/path for filesystem assets; in static\n // builds these are emitted as /_astro/name.hash.ext output assets.\n // The character class deliberately excludes only quotes (the attribute\n // delimiters) so that paths containing spaces are captured in full.\n return html.replace(/\\/@fs\\/[^\"']+/g, (match) => {\n const pathOnly = match.replace(/\\?.*$/, '');\n const fsPath = pathOnly.slice('/@fs'.length);\n // Handle /@fs//abs/path (double leading slash on Unix)\n const absolutePath = fsPath.startsWith('//') ? fsPath.slice(1) : fsPath;\n\n // Try exact match by originalFileNames first\n const exact = exactMap.get(absolutePath);\n\n if (exact) {\n return exact;\n }\n\n // Fall back to stem-based matching for image assets whose\n // originalFileNames are empty (standard Vite asset pipeline behaviour).\n const baseName = absolutePath.split('/').pop() ?? '';\n const stemHit = stemMap.get(baseName);\n\n if (stemHit) {\n return stemHit;\n }\n\n return match;\n });\n}\n\nasync function collectHydratableSourceModules(srcRoot: string): Promise<string[]> {\n const modules: string[] = [];\n\n async function walk(directory: string) {\n let entries: Dirent[];\n\n try {\n entries = await readdir(directory, { withFileTypes: true });\n } catch {\n return;\n }\n\n await Promise.all(\n entries.map(async (entry) => {\n const absolutePath = resolve(directory, entry.name);\n\n if (entry.isDirectory()) {\n await walk(absolutePath);\n\n return;\n }\n\n if (!entry.isFile()) {\n return;\n }\n\n const normalizedPath = absolutePath.replace(/\\\\/g, '/');\n\n if (!isHydratableSourceFile(normalizedPath)) {\n return;\n }\n\n if (isNonHydratableSourceFile(normalizedPath)) {\n return;\n }\n\n modules.push(normalizedPath);\n })\n );\n }\n\n await walk(srcRoot);\n\n return modules;\n}\n\nfunction isHydratableSourceFile(input: string) {\n // Only framework component extensions — plain .js/.ts are utilities/data\n // files that are not hydratable client components and must not be emitted\n // as entry chunks (they may lack a default export, causing a build error).\n return /\\.(jsx|tsx|vue|svelte)$/.test(input);\n}\n\nfunction isNonHydratableSourceFile(input: string) {\n return /\\.stories\\.[jt]sx?$|\\.stories\\.vue$|\\.stories\\.svelte$|\\.(spec|test)\\.[jt]sx?$/.test(\n input\n );\n}\n\nfunction patchCreateAstroCompat(component: unknown): AstroComponentFactory {\n if (typeof component !== 'function') {\n throw new Error('Expected Astro component factory to be a function.');\n }\n\n const originalComponent = component as AstroComponentFactory;\n const wrapped = ((result: AstroCreateResult, props: unknown, slots: unknown) => {\n if (result && typeof result.createAstro === 'function') {\n const originalCreateAstro = result.createAstro;\n const runtimeExpectsAstroGlobal = originalCreateAstro.length >= 3;\n\n result.createAstro = (...args: unknown[]) => {\n if (args.length === 3 && !runtimeExpectsAstroGlobal) {\n return originalCreateAstro(args[1], args[2]);\n }\n\n return originalCreateAstro(...args);\n };\n }\n\n return originalComponent(result, props, slots);\n }) as AstroComponentFactory;\n\n wrapped.isAstroComponentFactory = originalComponent.isAstroComponentFactory;\n wrapped.moduleId = originalComponent.moduleId;\n wrapped.propagation = originalComponent.propagation;\n\n return wrapped;\n}\n\nasync function processImageMetadata(\n args: Record<string, unknown>\n): Promise<Record<string, unknown>> {\n const processed: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(args)) {\n if (isImageMetadata(value)) {\n // Keep ImageMetadata as a plain object — Astro's image service checks\n // isESMImportedImage (typeof src === 'object') and skips the /@fs/ string\n // validation that throws LocalImageUsedWrongly. Converting to a URL string\n // causes that error when the string starts with /@fs/.\n processed[key] = value;\n\n continue;\n }\n\n if (Array.isArray(value)) {\n processed[key] = await Promise.all(\n value.map(async (item) => {\n if (isImageMetadata(item)) {\n return item;\n }\n\n if (isRecord(item)) {\n return processImageMetadata(item);\n }\n\n return item;\n })\n );\n\n continue;\n }\n\n if (isRecord(value)) {\n processed[key] = await processImageMetadata(value);\n\n continue;\n }\n\n processed[key] = value;\n }\n\n return processed;\n}\n\nfunction isImageMetadata(value: unknown): value is Record<string, unknown> {\n return (\n isRecord(value) &&\n typeof value.src === 'string' &&\n ('width' in value || 'height' in value || 'format' in value)\n );\n}\n\n\nfunction createProjectAstroResolutionPlugin(resolveFrom: string): Plugin {\n const require = createRequire(import.meta.url);\n\n return {\n name: 'storybook-astro:resolve-project-astro-prerender',\n enforce: 'pre',\n resolveId(id: string) {\n if (id !== 'astro' && !id.startsWith('astro/')) {\n return null;\n }\n\n try {\n return require.resolve(id, {\n paths: [resolveFrom]\n });\n } catch {\n return null;\n }\n }\n };\n}\n","import type { Dirent } from 'node:fs';\nimport { readdir } from 'node:fs/promises';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { build, type Rollup } from 'vite';\nimport type { FrameworkOptions } from './types.ts';\nimport { mergeWithAstroConfig } from './vitePluginAstro.ts';\nimport { viteAstroContainerRenderersPlugin } from './viteAstroContainerRenderersPlugin.ts';\nimport { astroFilesVirtualModulePlugin } from './vite/astroFilesVirtualModulePlugin.ts';\nimport { storybookAstroStoryRulesConfigVirtualModulePlugin } from './vite/storybookAstroRulesConfigVirtualModulePlugin.ts';\nimport { storybookAstroSanitizationConfigVirtualModulePlugin } from './vite/storybookAstroSanitizationConfigVirtualModulePlugin.ts';\nimport { storybookAstroServerAuthConfigVirtualModulePlugin } from './vite/storybookAstroServerAuthConfigVirtualModulePlugin.ts';\n\nconst moduleRoot = resolve(dirname(fileURLToPath(import.meta.url)), '.');\n// packageRoot works regardless of whether this file is running from src/ or dist/\nconst packageRoot = resolve(moduleRoot, '..');\n\nexport function vitePluginAstroBuildServer(options: FrameworkOptions) {\n const integrations = options.integrations ?? [];\n const resolveFrom = options.resolveFrom ?? process.cwd();\n const storiesMap = new Map<string, Set<string>>();\n const trackedSpecifiers = collectTrackedSpecifiers(integrations);\n const staticEntrypointRefs = new Map<string, string>();\n const componentEntrypointRefs = new Map<string, string>();\n let storybookStaticOutDir = resolve(resolveFrom, 'storybook-static');\n\n return {\n name: 'storybook-astro:build-server',\n apply: 'build',\n enforce: 'post',\n\n configResolved(config: { build: { outDir?: string } }) {\n storybookStaticOutDir = resolve(resolveFrom, config.build.outDir ?? 'storybook-static');\n },\n\n resolveId(id: string, importer?: string) {\n if (id.endsWith('.astro') && importer) {\n const absoluteAstroPath = resolve(dirname(importer), id);\n\n if (!storiesMap.has(absoluteAstroPath)) {\n storiesMap.set(absoluteAstroPath, new Set());\n }\n\n storiesMap.get(absoluteAstroPath)?.add(importer);\n }\n\n if (id.startsWith('virtual:astro-static-module/')) {\n return `\\0${id}`;\n }\n\n if (id.startsWith('virtual:astro-component-module/')) {\n return `\\0${id}`;\n }\n },\n\n load(id: string) {\n if (id.startsWith('\\0virtual:astro-static-module/')) {\n const encodedSpecifier = id.replace('\\0virtual:astro-static-module/', '');\n const specifier = decodeURIComponent(encodedSpecifier);\n\n if (isClientEntrypoint(specifier)) {\n return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join('\\n');\n }\n\n return [`import '${specifier}';`, 'export default undefined;'].join('\\n');\n }\n\n if (id.startsWith('\\0virtual:astro-component-module/')) {\n const encodedSpecifier = id.replace('\\0virtual:astro-component-module/', '');\n const specifier = decodeURIComponent(encodedSpecifier);\n\n return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join('\\n');\n }\n },\n\n async buildStart(this: Rollup.PluginContext) {\n integrations.forEach((integration) => {\n const entrypoint = integration.renderer.client?.entrypoint;\n\n if (entrypoint) {\n this.addWatchFile(entrypoint);\n }\n });\n\n trackedSpecifiers.forEach((specifier) => {\n const fileReferenceId = this.emitFile({\n type: 'chunk',\n id: toStaticVirtualId(specifier)\n });\n\n staticEntrypointRefs.set(specifier, fileReferenceId);\n });\n\n const srcRoot = resolve(resolveFrom, 'src/components');\n const specifiers = await collectHydratableSourceModules(srcRoot);\n\n specifiers.forEach((specifier) => {\n const fileReferenceId = this.emitFile({\n type: 'chunk',\n id: toComponentVirtualId(specifier)\n });\n\n componentEntrypointRefs.set(specifier, fileReferenceId);\n });\n },\n\n async writeBundle(this: Rollup.PluginContext) {\n const astroComponents = Array.from(storiesMap.keys());\n const staticModuleMap = buildStaticModuleMap(\n this,\n staticEntrypointRefs,\n componentEntrypointRefs\n );\n const serverOutDir = resolve(dirname(storybookStaticOutDir), 'storybook-server');\n\n await buildAstroServer({\n astroComponents,\n integrations,\n sanitization: options.sanitization,\n storyRules: options.storyRules,\n server: options.server,\n outDir: serverOutDir,\n staticModuleMap,\n resolveFrom\n });\n }\n };\n}\n\nasync function buildAstroServer(options: {\n astroComponents: string[];\n integrations: FrameworkOptions['integrations'];\n sanitization?: FrameworkOptions['sanitization'];\n storyRules?: FrameworkOptions['storyRules'];\n server?: FrameworkOptions['server'];\n outDir: string;\n staticModuleMap: Record<string, string>;\n resolveFrom: string;\n}) {\n const buildConfig = {\n root: resolve(packageRoot, 'src/server'),\n ssr: {\n noExternal: /(@astrojs\\/.+|react|react-dom)/\n },\n build: {\n ssr: true,\n outDir: options.outDir,\n emptyOutDir: true,\n sourcemap: true,\n manifest: false,\n rollupOptions: {\n input: resolve(packageRoot, 'src/server/index.ts'),\n treeshake: true\n }\n },\n plugins: [\n astroFilesVirtualModulePlugin(options.astroComponents),\n storybookAstroSanitizationConfigVirtualModulePlugin(options.sanitization),\n storybookAstroStoryRulesConfigVirtualModulePlugin(options.storyRules, options.resolveFrom),\n storybookAstroServerAuthConfigVirtualModulePlugin(options.server),\n viteAstroContainerRenderersPlugin(options.integrations, {\n mode: 'production',\n staticModuleMap: options.staticModuleMap\n })\n ]\n };\n\n const finalConfig = await mergeWithAstroConfig(\n buildConfig,\n options.integrations,\n options.resolveFrom,\n 'production',\n 'build'\n );\n\n await build(finalConfig);\n}\n\nfunction collectTrackedSpecifiers(integrations: FrameworkOptions['integrations']) {\n const specifiers = new Set<string>(['astro:scripts/page.js', 'astro:scripts/before-hydration.js']);\n\n integrations.forEach((integration) => {\n const entrypoint = integration.renderer.client?.entrypoint;\n\n if (entrypoint) {\n specifiers.add(entrypoint);\n }\n });\n\n return specifiers;\n}\n\nfunction buildStaticModuleMap(\n pluginContext: Rollup.PluginContext,\n staticEntrypointRefs: Map<string, string>,\n componentEntrypointRefs: Map<string, string>\n) {\n const map: Record<string, string> = {};\n\n staticEntrypointRefs.forEach((fileReferenceId, specifier) => {\n const fileName = pluginContext.getFileName(fileReferenceId);\n\n if (fileName) {\n map[specifier] = toPublicPath(fileName);\n }\n });\n\n componentEntrypointRefs.forEach((fileReferenceId, specifier) => {\n const fileName = pluginContext.getFileName(fileReferenceId);\n\n if (fileName) {\n map[specifier] = toPublicPath(fileName);\n }\n });\n\n return map;\n}\n\nfunction toStaticVirtualId(specifier: string) {\n return `virtual:astro-static-module/${encodeURIComponent(specifier)}`;\n}\n\nfunction toComponentVirtualId(specifier: string) {\n return `virtual:astro-component-module/${encodeURIComponent(specifier)}`;\n}\n\nfunction isClientEntrypoint(specifier: string) {\n return specifier.startsWith('@astrojs/') && specifier.endsWith('/client.js');\n}\n\nfunction toPublicPath(fileName: string) {\n return `./${fileName}`;\n}\n\nasync function collectHydratableSourceModules(srcRoot: string): Promise<string[]> {\n const modules: string[] = [];\n\n async function walk(directory: string) {\n let entries: Dirent[];\n\n try {\n entries = await readdir(directory, { withFileTypes: true });\n } catch {\n return;\n }\n\n await Promise.all(\n entries.map(async (entry) => {\n const absolutePath = resolve(directory, entry.name);\n\n if (entry.isDirectory()) {\n await walk(absolutePath);\n\n return;\n }\n\n if (!entry.isFile()) {\n return;\n }\n\n const normalizedPath = absolutePath.replace(/\\\\/g, '/');\n\n if (!isHydratableSourceFile(normalizedPath)) {\n return;\n }\n\n if (isNonHydratableSourceFile(normalizedPath)) {\n return;\n }\n\n modules.push(normalizedPath);\n })\n );\n }\n\n await walk(srcRoot);\n\n return modules;\n}\n\nfunction isHydratableSourceFile(input: string) {\n return /\\.(jsx|tsx|vue|svelte|js|ts)$/.test(input);\n}\n\nfunction isNonHydratableSourceFile(input: string) {\n return /\\.stories\\.[jt]sx?$|\\.stories\\.vue$|\\.stories\\.svelte$|\\.(spec|test)\\.[jt]sx?$/.test(\n input\n );\n}\n","import { mergeConfig, type InlineConfig } from 'vite';\nimport type { Integration } from './integrations/index.ts';\nimport { importAstroConfig } from './importAstroConfig.ts';\n\nconst ASTRO_PLUGINS_THAT_ARE_SUPPOSEDLY_NOT_NEEDED_IN_STORYBOOK = [\n '@astro/plugin-actions',\n '@astrojs/vite-plugin-astro-ssr-manifest',\n 'astro-content-virtual-mod-plugin',\n 'astro:actions',\n 'astro:build:normal',\n 'astro:container',\n 'astro:content-asset-propagation',\n 'astro:content-imports',\n 'astro:content-listen',\n 'astro:dev-toolbar',\n 'astro:head-metadata',\n 'astro:html',\n 'astro:i18n',\n 'astro:integration-container',\n 'astro:jsx',\n 'astro:markdown',\n 'astro:postprocess',\n 'astro:prefetch',\n 'astro:scanner',\n 'astro:scripts:page-ssr',\n 'astro:server',\n 'astro:vite-plugin-env',\n 'astro:vite-plugin-file-url'\n];\n\nexport async function mergeWithAstroConfig(\n config: InlineConfig,\n integrations: Integration[] = [],\n resolveFrom = process.cwd(),\n mode = 'development',\n command: 'build' | 'serve' = 'serve'\n) {\n const { getViteConfig } = await importAstroConfig(resolveFrom);\n const safeIntegrations = integrations ?? [];\n\n const astroConfig = await getViteConfig(\n {},\n {\n configFile: false,\n integrations: await Promise.all(\n safeIntegrations.map((integration) => integration.loadIntegration(resolveFrom))\n )\n }\n )({\n mode,\n command\n });\n\n const filteredPlugins = astroConfig\n .plugins!.flat()\n .filter(\n (plugin) =>\n plugin &&\n 'name' in plugin &&\n !ASTRO_PLUGINS_THAT_ARE_SUPPOSEDLY_NOT_NEEDED_IN_STORYBOOK.includes(plugin.name)\n );\n\n return mergeConfig(config, {\n ...astroConfig,\n plugins: filteredPlugins\n });\n}\n","import type { Plugin } from 'vite';\nimport { createVirtualModulePlugin } from './createVirtualModulePlugin.ts';\n\ntype ImportRecord = {\n id: string;\n file: string;\n importStatement: string;\n};\n\nexport function astroFilesVirtualModulePlugin(astroComponents: string[]): Plugin {\n return createVirtualModulePlugin({\n pluginName: 'storybook-astro:virtual-astro-files',\n virtualModuleId: 'virtual:astro-files',\n load() {\n const imports = astroComponents.reduce<ImportRecord[]>((records, file, index) => {\n const moduleId = `_astroFile${index}`;\n\n return [\n ...records,\n {\n id: moduleId,\n file,\n importStatement: `import ${moduleId} from '${file}';`\n }\n ];\n }, []);\n\n return [\n imports.map(({ importStatement }) => importStatement).join('\\n'),\n 'export default {',\n imports.map(({ file, id }) => `'${file}': ${id}`).join(',\\n'),\n '};'\n ].join('\\n');\n }\n });\n}\n","import type { Plugin } from 'vite';\nimport type { StoryRulesOptions } from '../rules-options.ts';\nimport { resolveRulesConfigFilePath } from '../rules-options.ts';\nimport { createVirtualModulePlugin } from './createVirtualModulePlugin.ts';\n\nexport const STORYBOOK_ASTRO_STORY_RULES_CONFIG_VIRTUAL_MODULE_ID =\n 'virtual:storybook-astro-story-rules-config';\n\nexport function storybookAstroStoryRulesConfigVirtualModulePlugin(\n options?: StoryRulesOptions,\n resolveFrom = process.cwd()\n): Plugin {\n return createVirtualModulePlugin({\n pluginName: 'storybook-astro:virtual-story-rules-config',\n virtualModuleId: STORYBOOK_ASTRO_STORY_RULES_CONFIG_VIRTUAL_MODULE_ID,\n load() {\n const configFilePath = resolveRulesConfigFilePath(options, resolveFrom);\n\n if (!configFilePath) {\n return [\n 'const storybookAstroStoryRulesConfig = { rules: [] };',\n 'export default storybookAstroStoryRulesConfig;',\n 'export const storybookAstroStoryRulesConfigFilePath = undefined;'\n ].join('\\n');\n }\n\n const importPath = JSON.stringify(configFilePath.replace(/\\\\/g, '/'));\n const configPath = JSON.stringify(configFilePath.replace(/\\\\/g, '/'));\n\n return [\n `import * as storybookAstroStoryRulesConfigModule from ${importPath};`,\n 'export default storybookAstroStoryRulesConfigModule;',\n `export const storybookAstroStoryRulesConfigFilePath = ${configPath};`\n ].join('\\n');\n }\n });\n}\n","import type { Plugin } from 'vite';\nimport type { SanitizationOptions } from '../lib/sanitization.ts';\nimport { serializeSanitizationOptions } from '../lib/sanitization.ts';\nimport { createVirtualModulePlugin } from './createVirtualModulePlugin.ts';\n\nexport const STORYBOOK_ASTRO_SANITIZATION_CONFIG_VIRTUAL_MODULE_ID =\n 'virtual:storybook-astro-sanitization-config';\n\nexport function storybookAstroSanitizationConfigVirtualModulePlugin(\n options?: SanitizationOptions\n): Plugin {\n return createVirtualModulePlugin({\n pluginName: 'storybook-astro:virtual-sanitization-config',\n virtualModuleId: STORYBOOK_ASTRO_SANITIZATION_CONFIG_VIRTUAL_MODULE_ID,\n load() {\n const serializedConfig = serializeSanitizationOptions(options);\n\n return `export default ${serializedConfig};`;\n }\n });\n}\n","import type { Plugin } from 'vite';\nimport type { ServerBuildOptions } from '../types.ts';\nimport { createVirtualModulePlugin } from './createVirtualModulePlugin.ts';\n\nexport const STORYBOOK_ASTRO_SERVER_AUTH_CONFIG_VIRTUAL_MODULE_ID =\n 'virtual:storybook-astro-server-auth-config';\n\nexport function storybookAstroServerAuthConfigVirtualModulePlugin(\n options?: ServerBuildOptions\n): Plugin {\n const authToken = normalizeOptionalString(options?.authToken);\n const authHeader = normalizeAuthHeader(options?.authHeader);\n\n return createVirtualModulePlugin({\n pluginName: 'storybook-astro:virtual-server-auth-config',\n virtualModuleId: STORYBOOK_ASTRO_SERVER_AUTH_CONFIG_VIRTUAL_MODULE_ID,\n load() {\n return [\n `export const storybookAstroServerAuthToken = ${\n authToken ? JSON.stringify(authToken) : 'undefined'\n };`,\n `export const storybookAstroServerAuthHeader = ${JSON.stringify(authHeader)};`\n ].join('\\n');\n }\n });\n}\n\nfunction normalizeOptionalString(value: string | undefined) {\n if (!value) {\n return undefined;\n }\n\n const normalizedValue = value.trim();\n\n return normalizedValue || undefined;\n}\n\nfunction normalizeAuthHeader(value: string | undefined) {\n const normalizedValue = normalizeOptionalString(value);\n\n return (normalizedValue ?? 'authorization').toLowerCase();\n}\n","import type { Plugin } from 'vite';\n\nconst TOOLBAR_INTERNAL_STUB = `\nexport const loadDevToolbarApps = async () => [];\n`;\n\n/**\n * Provides a fallback stub for Astro's dev toolbar virtual module.\n *\n * Astro's `astro/dist/runtime/client/dev-toolbar/entrypoint.js` imports\n * from `astro:toolbar:internal`, a virtual module normally provided by\n * Astro's own `vite-plugin-dev-toolbar` Vite plugin. In the Storybook\n * context that plugin is not active, causing esbuild to fail during\n * dependency optimisation when it encounters the unresolvable import.\n *\n * Storybook doesn't use Astro's dev toolbar, so a no-op stub is safe.\n */\nexport function vitePluginAstroToolbarFallback(): Plugin {\n const VIRTUAL_ID = 'astro:toolbar:internal';\n const RESOLVED_ID = '\\0' + VIRTUAL_ID;\n\n return {\n name: 'storybook-astro-toolbar-fallback',\n enforce: 'pre',\n\n resolveId(id) {\n if (id === VIRTUAL_ID) {\n return RESOLVED_ID;\n }\n },\n\n load(id) {\n if (id === RESOLVED_ID) {\n return { code: TOOLBAR_INTERNAL_STUB };\n }\n }\n };\n}\n","import type { StorybookConfigVite, FrameworkOptions } from './types.ts';\nimport { vitePluginStorybookAstroMiddleware } from './viteStorybookAstroMiddlewarePlugin.ts';\nimport { viteStorybookRendererFallbackPlugin } from './viteStorybookRendererFallbackPlugin.ts';\nimport { viteStorybookAstroRendererPlugin } from './viteStorybookAstroRendererPlugin.ts';\nimport { vitePluginAstroComponentMarker } from './vitePluginAstroComponentMarker.ts';\nimport { vitePluginAstroBuildPrerender } from './vitePluginAstroBuildPrerender.ts';\nimport { vitePluginAstroBuildServer } from './vitePluginAstroBuildServer.ts';\nimport { vitePluginAstroIntegrationOptsFallback } from './vitePluginAstroIntegrationOptsFallback.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\nimport { vitePluginAstroToolbarFallback } from './vitePluginAstroToolbarFallback.ts';\nimport { resolveSanitizationOptions } from './lib/sanitization.ts';\nimport { mergeWithAstroConfig } from './vitePluginAstro.ts';\n\nexport const core = {\n builder: '@storybook/builder-vite',\n // Use import.meta.resolve so Storybook receives an absolute file:// URL\n // to the renderer preset rather than a bare package specifier. When\n // package managers like pnpm use strict node_modules isolation, bare\n // specifiers are resolved from the *project root*, where the renderer\n // (a dep of this framework, not the user's project) is not hoisted.\n // The absolute URL is resolved from *this* file's location where the\n // renderer is always accessible as a direct dependency.\n renderer: import.meta.resolve('@storybook-astro/renderer')\n};\n\nexport const viteFinal: StorybookConfigVite['viteFinal'] = async (config, { configType, presets }) => {\n const options = await presets.apply<FrameworkOptions>('frameworkOptions');\n\n if (!config.plugins) {\n config.plugins = [];\n }\n\n const integrations = options.integrations ?? [];\n const resolveFrom = options.resolveFrom ?? process.cwd();\n const renderMode = options.renderMode ?? 'server';\n const mode = configType === 'DEVELOPMENT' ? 'development' : 'production';\n const command = configType === 'DEVELOPMENT' ? 'serve' : 'build';\n\n resolveSanitizationOptions(options.sanitization);\n\n config.envPrefix = mergeEnvPrefixes(config.envPrefix, 'STORYBOOK_');\n\n const { vitePlugin: storybookAstroMiddlewarePlugin, viteConfig } =\n await vitePluginStorybookAstroMiddleware(options);\n\n config.plugins.push(\n viteStorybookRendererFallbackPlugin(integrations),\n viteStorybookAstroRendererPlugin({\n mode,\n renderMode,\n server: options.server\n }),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n vitePluginAstroComponentMarker() as any,\n vitePluginAstroIntegrationOptsFallback(),\n vitePluginAstroToolbarFallback(),\n vitePluginAstroVueFallback(),\n );\n\n if (configType === 'DEVELOPMENT') {\n config.plugins.push(storybookAstroMiddlewarePlugin, ...viteConfig.plugins);\n } else if (renderMode === 'static') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config.plugins.push(vitePluginAstroBuildPrerender(options) as any);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config.plugins.push(vitePluginAstroBuildServer(options) as any);\n }\n\n if (configType !== 'DEVELOPMENT') {\n config.build = {\n ...(config.build ?? {}),\n manifest: true\n };\n\n config.build.rollupOptions = {\n ...(config.build.rollupOptions ?? {}),\n preserveEntrySignatures: 'strict'\n };\n }\n\n // Add React/ReactDOM aliases for storybook-solidjs compatibility\n if (!config.resolve) {\n config.resolve = {};\n }\n if (!config.resolve.alias) {\n config.resolve.alias = {};\n }\n \n // Ensure React is available for storybook-solidjs\n const aliases = config.resolve.alias as Record<string, string>;\n\n if (!aliases['react']) {\n aliases['react'] = 'react';\n }\n if (!aliases['react-dom']) {\n aliases['react-dom'] = 'react-dom';\n }\n\n const finalConfig = await mergeWithAstroConfig(config, integrations, resolveFrom, mode, command);\n\n // Exclude Astro integration packages from dependency optimization because\n // they import virtual modules that esbuild cannot resolve.\n if (!finalConfig.optimizeDeps) {\n finalConfig.optimizeDeps = {};\n }\n if (!finalConfig.optimizeDeps.exclude) {\n finalConfig.optimizeDeps.exclude = [];\n }\n for (const pkg of ['@astrojs/vue', '@astrojs/react', '@astrojs/preact']) {\n if (!finalConfig.optimizeDeps.exclude.includes(pkg)) {\n finalConfig.optimizeDeps.exclude.push(pkg);\n }\n }\n // Exclude the renderer from Vite's esbuild pre-bundler so that\n // import.meta.hot is preserved in the preview iframe. When installed\n // via npm (not workspace:*), Vite would otherwise pre-bundle the\n // renderer with esbuild, which strips import.meta.hot and causes the\n // renderer to fall back to fetching astro-prerendered-stories.json\n // (a 404 in dev mode) rather than using the Vite HMR channel.\n if (!finalConfig.optimizeDeps.exclude.includes('@storybook-astro/renderer')) {\n finalConfig.optimizeDeps.exclude.push('@storybook-astro/renderer');\n }\n // Mark integration virtual modules as external so the dep bundler doesn't\n // try to resolve them (they are Vite virtual modules with no real package).\n // Set both esbuildOptions (Vite ≤7) and rolldownOptions (Vite 8+, Rolldown)\n // so the correct key is populated regardless of Vite version.\n const integrationVirtualModules = [\n 'virtual:@astrojs/vue/app',\n 'virtual:astro:vue-app',\n 'astro:react:opts',\n 'astro:preact:opts',\n 'astro:toolbar:internal'\n ];\n\n // Vite ≤7 (esbuild-based optimizer)\n if (!finalConfig.optimizeDeps.esbuildOptions) {\n finalConfig.optimizeDeps.esbuildOptions = {};\n }\n if (!finalConfig.optimizeDeps.esbuildOptions.external) {\n finalConfig.optimizeDeps.esbuildOptions.external = [];\n }\n for (const mod of integrationVirtualModules) {\n if (!finalConfig.optimizeDeps.esbuildOptions.external.includes(mod)) {\n finalConfig.optimizeDeps.esbuildOptions.external.push(mod);\n }\n }\n\n // Vite 8+ (Rolldown-based optimizer) — same semantics, different key\n // Use a loose cast because rolldownOptions is absent from Vite <8 types.\n const optimizeDepsMut = finalConfig.optimizeDeps as Record<string, unknown>;\n const rolldownOpts = (optimizeDepsMut.rolldownOptions ?? {}) as { external?: string[] };\n\n rolldownOpts.external = Array.from(\n new Set([...(rolldownOpts.external ?? []), ...integrationVirtualModules])\n );\n optimizeDepsMut.rolldownOptions = rolldownOpts;\n\n return finalConfig;\n};\n\nfunction mergeEnvPrefixes(\n existing: string | string[] | undefined,\n additionalPrefix: string\n): string[] {\n const prefixes = Array.isArray(existing) ? existing : existing ? [existing] : [];\n\n return Array.from(new Set([...pref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kBAAY,aAAa,eAAe,SAAS,KAAK,GAAG;AAAA,IAC3D;AAAA,EACF;AAIA,QAAM,kBAAkB,YAAY;AACpC,QAAM,eAAgB,gBAAgB,mBAAmB,CAAC;AAE1D,eAAa,WAAW,MAAM;AAAA,IAC5B,oBAAI,IAAI,CAAC,GAAI,aAAa,YAAY,CAAC,GAAI,GAAG,yBAAyB,CAAC;AAAA,EAC1E;AACA,kBAAgB,kBAAkB;AAElC,SAAO;AACT;AAEA,SAAS,iBACP,UACA,kBACU;AACV,QAAM,WAAW,MAAM,QAAQ,QAAQ,IAAI,WAAW,WAAW,CAAC,QAAQ,IAAI,CAAC;AAE/E,SAAO,MAAM,KAAK,oBAAI,IAAI,CAAC,GAAG,UAAU,gBAAgB,CAAC,CAAC;AAC5D;","names":["require","readdir","resolve","mergeConfig","mergeConfig","resolve","collectTrackedSpecifiers","isClientEntrypoint","toStaticVirtualId","collectHydratableSourceModules","toComponentVirtualId","buildStaticModuleMap","toPublicPath","readdir","isHydratableSourceFile","isNonHydratableSourceFile"]}