@storybook-astro/framework 1.1.0 → 1.1.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.
@@ -932,10 +932,40 @@ function isNonHydratableSourceFile2(input) {
932
932
  );
933
933
  }
934
934
 
935
+ // src/vitePluginAstroToolbarFallback.ts
936
+ var TOOLBAR_INTERNAL_STUB = `
937
+ export const loadDevToolbarApps = async () => [];
938
+ `;
939
+ function vitePluginAstroToolbarFallback() {
940
+ const VIRTUAL_ID = "astro:toolbar:internal";
941
+ const RESOLVED_ID = "\0" + VIRTUAL_ID;
942
+ return {
943
+ name: "storybook-astro-toolbar-fallback",
944
+ enforce: "pre",
945
+ resolveId(id) {
946
+ if (id === VIRTUAL_ID) {
947
+ return RESOLVED_ID;
948
+ }
949
+ },
950
+ load(id) {
951
+ if (id === RESOLVED_ID) {
952
+ return { code: TOOLBAR_INTERNAL_STUB };
953
+ }
954
+ }
955
+ };
956
+ }
957
+
935
958
  // src/preset.ts
936
959
  var core = {
937
960
  builder: "@storybook/builder-vite",
938
- renderer: "@storybook-astro/renderer"
961
+ // Use import.meta.resolve so Storybook receives an absolute file:// URL
962
+ // to the renderer preset rather than a bare package specifier. When
963
+ // package managers like pnpm use strict node_modules isolation, bare
964
+ // specifiers are resolved from the *project root*, where the renderer
965
+ // (a dep of this framework, not the user's project) is not hoisted.
966
+ // The absolute URL is resolved from *this* file's location where the
967
+ // renderer is always accessible as a direct dependency.
968
+ renderer: import.meta.resolve("@storybook-astro/renderer")
939
969
  };
940
970
  var viteFinal = async (config, { configType, presets }) => {
941
971
  const options = await presets.apply("frameworkOptions");
@@ -960,6 +990,7 @@ var viteFinal = async (config, { configType, presets }) => {
960
990
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
961
991
  vitePluginAstroComponentMarker(),
962
992
  vitePluginAstroIntegrationOptsFallback(),
993
+ vitePluginAstroToolbarFallback(),
963
994
  vitePluginAstroVueFallback()
964
995
  );
965
996
  if (configType === "DEVELOPMENT") {
@@ -1011,7 +1042,8 @@ var viteFinal = async (config, { configType, presets }) => {
1011
1042
  "virtual:@astrojs/vue/app",
1012
1043
  "virtual:astro:vue-app",
1013
1044
  "astro:react:opts",
1014
- "astro:preact:opts"
1045
+ "astro:preact:opts",
1046
+ "astro:toolbar:internal"
1015
1047
  ];
1016
1048
  if (!finalConfig.optimizeDeps.esbuildOptions) {
1017
1049
  finalConfig.optimizeDeps.esbuildOptions = {};
@@ -1041,4 +1073,4 @@ export {
1041
1073
  core,
1042
1074
  viteFinal
1043
1075
  };
1044
- //# sourceMappingURL=chunk-VPJDFGB5.js.map
1076
+ //# sourceMappingURL=chunk-4HECE7IW.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 { 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 { 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 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 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 });\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}) {\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\n try {\n const container = await AstroContainer.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] = html;\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 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 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\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\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oint","toStaticVirtualId","collectHydratableSourceModules","toComponentVirtualId","buildStaticModuleMap","toPublicPath","readdir","isHydratableSourceFile","isNonHydratableSourceFile"]}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  core,
3
3
  viteFinal
4
- } from "./chunk-VPJDFGB5.js";
4
+ } from "./chunk-4HECE7IW.js";
5
5
  import {
6
6
  defineStoryRules
7
7
  } from "./chunk-V76WSNSP.js";
package/dist/preset.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  core,
3
3
  viteFinal
4
- } from "./chunk-VPJDFGB5.js";
4
+ } from "./chunk-4HECE7IW.js";
5
5
  import "./chunk-V76WSNSP.js";
6
6
  import "./chunk-POHTFYST.js";
7
7
  import "./chunk-E4LB75JN.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook-astro/framework",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Community-supported Storybook framework for Astro 5 & 6 components",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -167,7 +167,7 @@
167
167
  }
168
168
  },
169
169
  "dependencies": {
170
- "@storybook-astro/renderer": "1.1.0",
170
+ "@storybook-astro/renderer": "1.1.1",
171
171
  "hono": "^4.11.12",
172
172
  "sanitize-html": "^2.17.0",
173
173
  "vite": "^6.4.1 || ^7.0.0 || ^8.0.0"
package/src/preset.ts CHANGED
@@ -7,12 +7,20 @@ import { vitePluginAstroBuildPrerender } from './vitePluginAstroBuildPrerender.t
7
7
  import { vitePluginAstroBuildServer } from './vitePluginAstroBuildServer.ts';
8
8
  import { vitePluginAstroIntegrationOptsFallback } from './vitePluginAstroIntegrationOptsFallback.ts';
9
9
  import { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';
10
+ import { vitePluginAstroToolbarFallback } from './vitePluginAstroToolbarFallback.ts';
10
11
  import { resolveSanitizationOptions } from './lib/sanitization.ts';
11
12
  import { mergeWithAstroConfig } from './vitePluginAstro.ts';
12
13
 
13
14
  export const core = {
14
15
  builder: '@storybook/builder-vite',
15
- renderer: '@storybook-astro/renderer'
16
+ // Use import.meta.resolve so Storybook receives an absolute file:// URL
17
+ // to the renderer preset rather than a bare package specifier. When
18
+ // package managers like pnpm use strict node_modules isolation, bare
19
+ // specifiers are resolved from the *project root*, where the renderer
20
+ // (a dep of this framework, not the user's project) is not hoisted.
21
+ // The absolute URL is resolved from *this* file's location where the
22
+ // renderer is always accessible as a direct dependency.
23
+ renderer: import.meta.resolve('@storybook-astro/renderer')
16
24
  };
17
25
 
18
26
  export const viteFinal: StorybookConfigVite['viteFinal'] = async (config, { configType, presets }) => {
@@ -45,6 +53,7 @@ export const viteFinal: StorybookConfigVite['viteFinal'] = async (config, { conf
45
53
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
54
  vitePluginAstroComponentMarker() as any,
47
55
  vitePluginAstroIntegrationOptsFallback(),
56
+ vitePluginAstroToolbarFallback(),
48
57
  vitePluginAstroVueFallback(),
49
58
  );
50
59
 
@@ -120,7 +129,8 @@ export const viteFinal: StorybookConfigVite['viteFinal'] = async (config, { conf
120
129
  'virtual:@astrojs/vue/app',
121
130
  'virtual:astro:vue-app',
122
131
  'astro:react:opts',
123
- 'astro:preact:opts'
132
+ 'astro:preact:opts',
133
+ 'astro:toolbar:internal'
124
134
  ];
125
135
 
126
136
  // Vite ≤7 (esbuild-based optimizer)
@@ -0,0 +1,38 @@
1
+ import type { Plugin } from 'vite';
2
+
3
+ const TOOLBAR_INTERNAL_STUB = `
4
+ export const loadDevToolbarApps = async () => [];
5
+ `;
6
+
7
+ /**
8
+ * Provides a fallback stub for Astro's dev toolbar virtual module.
9
+ *
10
+ * Astro's `astro/dist/runtime/client/dev-toolbar/entrypoint.js` imports
11
+ * from `astro:toolbar:internal`, a virtual module normally provided by
12
+ * Astro's own `vite-plugin-dev-toolbar` Vite plugin. In the Storybook
13
+ * context that plugin is not active, causing esbuild to fail during
14
+ * dependency optimisation when it encounters the unresolvable import.
15
+ *
16
+ * Storybook doesn't use Astro's dev toolbar, so a no-op stub is safe.
17
+ */
18
+ export function vitePluginAstroToolbarFallback(): Plugin {
19
+ const VIRTUAL_ID = 'astro:toolbar:internal';
20
+ const RESOLVED_ID = '\0' + VIRTUAL_ID;
21
+
22
+ return {
23
+ name: 'storybook-astro-toolbar-fallback',
24
+ enforce: 'pre',
25
+
26
+ resolveId(id) {
27
+ if (id === VIRTUAL_ID) {
28
+ return RESOLVED_ID;
29
+ }
30
+ },
31
+
32
+ load(id) {
33
+ if (id === RESOLVED_ID) {
34
+ return { code: TOOLBAR_INTERNAL_STUB };
35
+ }
36
+ }
37
+ };
38
+ }
@@ -1 +0,0 @@
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/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 { 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 { 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 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 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 });\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}) {\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\n try {\n const container = await AstroContainer.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] = html;\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 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 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\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 { 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 { resolveSanitizationOptions } from './lib/sanitization.ts';\nimport { mergeWithAstroConfig } from './vitePluginAstro.ts';\n\nexport const core = {\n builder: '@storybook/builder-vite',\n renderer: '@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 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 ];\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([...prefixes, additionalPrefix]));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,oCAAoC,cAA6B;AAC/E,QAAM,mBAAmB,gBAAgB,CAAC;AAE1C,SAAO,0BAA0B;AAAA,IAC/B,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,OAAO;AACL,aAAO,iBACJ,OAAO,CAAC,gBAAgB,YAAY,qBAAqB,EACzD;AAAA,QACC,CAAC,gBACC,eAAe,YAAY,IAAI,UAAU,YAAY,qBAAqB;AAAA,MAC9E,EACC,KAAK,IAAI;AAAA,IACd;AAAA,EACF,CAAC;AACH;;;AChBA,IAAM,cAAc;AAEb,SAAS,iCAAiC,SAI9C;AACD,QAAM,aAAa;AACnB,QAAM,kBAAkB;AACxB,QAAM,eAAe,QAAQ,SAAS;AACtC,QAAM,eAAe,QAAQ,eAAe;AAE5C,SAAO,0BAA0B;AAAA,IAC/B;AAAA,IACA;AAAA,IACA,OAAO;AACL,UAAI,CAAC,cAAc;AACjB,eAAO,kBAAkB,WAAW;AAAA,MACtC;AAEA,UAAI,cAAc;AAChB,eAAO,kBAAkB,WAAW;AAAA,MACtC;AAEA,aAAO;AAAA,QACL,yCAAyC,WAAW;AAAA,QACpD,yCAAyC,KAAK;AAAA,UAC5C;AAAA,YACE,WAAW,QAAQ,QAAQ;AAAA,YAC3B,WAAW,QAAQ,QAAQ;AAAA,YAC3B,YAAY,QAAQ,QAAQ;AAAA,UAC9B;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD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Aa,QAAQ,KAAK,GAAG;AAAA,IAC3C;AAAA,EACF;AAOA,MAAI,CAAC,YAAY,aAAa,QAAQ,SAAS,2BAA2B,GAAG;AAC3E,gBAAY,aAAa,QAAQ,KAAK,2BAA2B;AAAA,EACnE;AAKA,QAAM,4BAA4B;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGA,MAAI,CAAC,YAAY,aAAa,gBAAgB;AAC5C,gBAAY,aAAa,iBAAiB,CAAC;AAAA,EAC7C;AACA,MAAI,CAAC,YAAY,aAAa,eAAe,UAAU;AACrD,gBAAY,aAAa,eAAe,WAAW,CAAC;AAAA,EACtD;AACA,aAAW,OAAO,2BAA2B;AAC3C,QAAI,CAAC,YAAY,aAAa,eAAe,SAAS,SAAS,GAAG,GAAG;AACnE,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"]}