@storybook-astro/framework 1.4.0 → 1.5.0-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{chunk-E4LB75JN.js → chunk-5MNCPWIU.js} +49 -15
  2. package/dist/chunk-5MNCPWIU.js.map +1 -0
  3. package/dist/{chunk-VZXGPM6P.js → chunk-7UF6LK4Z.js} +62 -14
  4. package/dist/{chunk-VZXGPM6P.js.map → chunk-7UF6LK4Z.js.map} +1 -1
  5. package/dist/{chunk-BV6V2Z4X.js → chunk-XVVIGJV6.js} +2 -2
  6. package/dist/preset.js +32 -5
  7. package/dist/preset.js.map +1 -1
  8. package/dist/renderer/renderer-dev.js +2 -0
  9. package/dist/renderer/renderer-dev.js.map +1 -1
  10. package/dist/renderer/renderer-server.js +3 -1
  11. package/dist/renderer/renderer-server.js.map +1 -1
  12. package/dist/renderer/renderer-static.js +2 -0
  13. package/dist/renderer/renderer-static.js.map +1 -1
  14. package/dist/testing.js +3 -3
  15. package/dist/{viteStorybookAstroMiddlewarePlugin-246I5D3Y.js → viteStorybookAstroMiddlewarePlugin-LUMKF7NG.js} +2 -2
  16. package/dist/vitest/global-setup.js +2 -2
  17. package/dist/vitest/index.js +1 -1
  18. package/package.json +5 -2
  19. package/src/loadUserAstroConfig.test.ts +149 -0
  20. package/src/loadUserAstroConfig.ts +126 -25
  21. package/src/preset.ts +45 -2
  22. package/src/renderer/renderer-dev.ts +2 -0
  23. package/src/renderer/renderer-server.ts +2 -0
  24. package/src/renderer/renderer-static.ts +2 -0
  25. package/src/shim.d.ts +21 -0
  26. package/src/virtual.d.ts +1 -0
  27. package/src/vitePluginAstroComponentMarker.test.ts +178 -0
  28. package/src/vitePluginAstroComponentMarker.ts +79 -14
  29. package/src/viteStorybookAstroRendererPlugin.ts +2 -1
  30. package/dist/chunk-E4LB75JN.js.map +0 -1
  31. /package/dist/{chunk-BV6V2Z4X.js.map → chunk-XVVIGJV6.js.map} +0 -0
  32. /package/dist/{viteStorybookAstroMiddlewarePlugin-246I5D3Y.js.map → viteStorybookAstroMiddlewarePlugin-LUMKF7NG.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/preset.ts","../src/viteStorybookRendererFallbackPlugin.ts","../src/viteStorybookAstroRendererPlugin.ts","../src/vitePluginAstroBuildPrerender.ts","../src/vitePluginAstroBuildShared.ts","../src/productionRenderRuntime.ts","../src/storySsrVite.ts","../src/lib/hydratedComponentBuild.ts","../src/vitePluginAstro.ts","../src/lib/staticHtmlRewriting.ts","../src/vitePluginAstroBuildServer.ts","../src/vite/sanitizeConfigPlugin.ts","../src/vite/serverAuthPlugin.ts","../src/vite/serverRuntimePlugin.ts","../src/vitePluginAstroToolbarFallback.ts"],"sourcesContent":["import { dirname } from 'node:path';\nimport 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, storybookOptions) => {\n const { configType, presets, configDir } = storybookOptions;\n const frameworkOptions = await presets.apply<FrameworkOptions>('frameworkOptions');\n const options = {\n ...frameworkOptions,\n resolveFrom: frameworkOptions.resolveFrom ?? dirname(configDir)\n } satisfies FrameworkOptions;\n\n if (!config.plugins) {\n config.plugins = [];\n }\n\n const integrations = options.integrations ?? [];\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(\n config,\n integrations,\n options.resolveFrom,\n mode,\n command\n );\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 [\n '@astrojs/vue',\n '@astrojs/vue/client.js',\n '@astrojs/vue/server.js',\n '@astrojs/react',\n '@astrojs/react/client.js',\n '@astrojs/react/server.js',\n '@astrojs/preact',\n '@astrojs/preact/client.js',\n '@astrojs/preact/server.js'\n ]) {\n if (!finalConfig.optimizeDeps.exclude.includes(pkg)) {\n finalConfig.optimizeDeps.exclude.push(pkg);\n }\n }\n // Exclude the renderer and framework from Vite's esbuild pre-bundler.\n //\n // Renderer: import.meta.hot must be preserved so the HMR channel works.\n // When esbuild pre-bundles it, import.meta.hot is stripped and render\n // responses are never received, producing an infinite loading spinner.\n //\n // Framework: the main entry re-exports browser-safe helpers (definePreview,\n // composeStories, etc.) but also has subpath exports that depend on Vite\n // server APIs. If Vite's dep optimizer scans the package transitively it\n // can pull in createServer and other Node-only code, creating a >50k-line\n // browser bundle that causes duplicate __vite__injectQuery declarations\n // and a SyntaxError that crashes the preview iframe.\n for (const pkg of ['@storybook-astro/renderer', '@storybook-astro/framework']) {\n if (!finalConfig.optimizeDeps.exclude.includes(pkg)) {\n finalConfig.optimizeDeps.exclude.push(pkg);\n }\n }\n // fsevents is a macOS-only native chokidar dep with a .node binary that\n // esbuild's prebundler can't load. storybook/internal/preview-api can pass\n // through the transform pipeline twice when used by CSF Next portable\n // stories, producing a duplicate __vite__injectQuery import in the\n // generated chunk; excluding it from prebundling collapses the duplicate.\n for (const pkg of ['fsevents', 'storybook/internal/preview-api']) {\n if (!finalConfig.optimizeDeps.exclude.includes(pkg)) {\n finalConfig.optimizeDeps.exclude.push(pkg);\n }\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+ uses Rolldown for dependency optimization.\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","import type { Integration } from './integrations/index.ts';\nimport { createVirtualModule } from './vite/virtualModulePlugin.ts';\n\nexport function viteStorybookRendererFallbackPlugin(integrations: Integration[]) {\n const safeIntegrations = integrations ?? [];\n\n return createVirtualModule({\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 { fileURLToPath } from 'node:url';\nimport type { RenderMode, ServerBuildOptions } from './types.ts';\nimport { createVirtualModule } from './vite/virtualModulePlugin.ts';\n\nconst rendererDevModulePath = fileURLToPath(new URL('./renderer/renderer-dev.js', import.meta.url));\nconst rendererStaticModulePath = fileURLToPath(new URL('./renderer/renderer-static.js', import.meta.url));\nconst rendererServerModulePath = fileURLToPath(new URL('./renderer/renderer-server.js', import.meta.url));\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 createVirtualModule({\n pluginName,\n virtualModuleId,\n load() {\n if (!isProduction) {\n return `export * from ${JSON.stringify(normalizePath(rendererDevModulePath))};`;\n }\n\n if (isStaticMode) {\n return `export * from ${JSON.stringify(normalizePath(rendererStaticModulePath))};`;\n }\n\n return [\n `import { createServerRenderer } from ${JSON.stringify(normalizePath(rendererServerModulePath))};`,\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\nfunction normalizePath(value: string) {\n return value.replace(/\\\\/g, '/');\n}\n","import { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport type { Plugin, Rollup } from 'vite';\nimport type { Integration } from './integrations/index.ts';\nimport {\n buildStaticModuleMap,\n emitHydratedComponentEntriesFromAstroFile,\n collectTrackedSpecifiers,\n emitBuildEntrypoints,\n loadVirtualBuildModule,\n resolveVirtualBuildModuleId,\n stripQuery\n} from './vitePluginAstroBuildShared.ts';\nimport {\n createProductionRenderRuntime,\n renderProductionStoryToHtml,\n type ProductionStoryEntry\n} from './productionRenderRuntime.ts';\nimport { buildHydratedComponentAssets } from './lib/hydratedComponentBuild.ts';\nimport {\n addStaticStylesheets,\n rewriteBuiltModulePaths,\n type StaticCssMap,\n type StaticModuleMap\n} from './lib/staticHtmlRewriting.ts';\nimport { resolveRulesConfigFilePath } from './rules-options.ts';\nimport type { FrameworkOptions } from './types.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\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 async resolveId(this: Rollup.PluginContext, id: string, importer?: string) {\n const importerPath = stripQuery(importer);\n\n if (importerPath?.endsWith('.astro')) {\n await emitHydratedComponentEntriesFromAstroFile({\n pluginContext: this,\n astroFilePath: importerPath,\n resolveFrom,\n componentEntrypointRefs\n });\n }\n\n return resolveVirtualBuildModuleId(id);\n },\n\n load(id: string) {\n return loadVirtualBuildModule(id);\n },\n\n async buildStart(this: Rollup.PluginContext) {\n await emitBuildEntrypoints({\n pluginContext: this,\n integrations,\n resolveFrom,\n trackedSpecifiers,\n staticEntrypointRefs\n });\n },\n\n async writeBundle(\n this: Rollup.PluginContext,\n _outputOptions: Rollup.NormalizedOutputOptions,\n bundle: Rollup.OutputBundle\n ) {\n const trackedModuleMap = buildStaticModuleMap(\n this,\n staticEntrypointRefs,\n componentEntrypointRefs\n );\n\n const astroStories = await collectAstroStories(outDir);\n\n if (astroStories.length === 0) {\n await writePrerenderedStoriesFile(outDir, {});\n\n return;\n }\n\n const storyAstroComponentPaths = Array.from(\n new Set(astroStories.map((story) => story.componentPath))\n );\n // Bundle the framework components hydrated inside Astro stories so the\n // static preview has matching JS chunks and extracted CSS for them.\n // Storybook's own iframe build skips these files when no per-framework\n // .stories.* exists, which left CSS-module styling absent from the\n // prerendered output.\n const hydratedComponentAssets = await buildHydratedComponentAssets({\n componentPaths: storyAstroComponentPaths,\n integrations,\n resolveFrom,\n outDir\n });\n const staticModuleMap: StaticModuleMap = {\n ...trackedModuleMap,\n ...hydratedComponentAssets.staticModuleMap\n };\n const staticCssMap: StaticCssMap = hydratedComponentAssets.staticCssMap;\n\n const prerenderedStories = await prerenderAstroStories({\n astroStories,\n integrations,\n sanitization: options.sanitization,\n storyRulesConfigFilePath,\n staticModuleMap,\n staticCssMap,\n trackedSpecifiers,\n resolveFrom,\n fonts: options.fonts,\n bundle\n });\n\n await writePrerenderedStoriesFile(outDir, prerenderedStories);\n }\n };\n}\n\n/** Writes the prerendered Astro story payload consumed by the static renderer. */\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\n/** Renders Astro stories during the static build and stores the HTML by story id. */\nasync function prerenderAstroStories(options: {\n astroStories: ProductionStoryEntry[];\n integrations: Integration[];\n sanitization?: FrameworkOptions['sanitization'];\n storyRulesConfigFilePath?: string;\n staticModuleMap: StaticModuleMap;\n staticCssMap: StaticCssMap;\n trackedSpecifiers: Set<string>;\n resolveFrom: string;\n fonts?: FrameworkOptions['fonts'];\n bundle: Rollup.OutputBundle;\n}) {\n const runtime = await createProductionRenderRuntime({\n integrations: options.integrations,\n sanitization: options.sanitization,\n storyRulesConfigFilePath: options.storyRulesConfigFilePath,\n staticModuleMap: options.staticModuleMap,\n trackedSpecifiers: options.trackedSpecifiers,\n resolveFrom: options.resolveFrom,\n fonts: options.fonts\n });\n const assetPathMap = buildAssetPathMap(options.bundle);\n\n try {\n const output: Record<string, string> = {};\n\n for (const story of options.astroStories) {\n const html = await renderProductionStoryToHtml({\n story,\n runtime,\n resolveFrom: options.resolveFrom\n });\n\n if (html === undefined) {\n continue;\n }\n\n // Image asset URLs from Vite SSR still point at /@fs/ paths, so rewrite\n // them first; then rewrite hydrated framework component module paths and\n // prepend their extracted CSS so the static preview matches dev styling.\n const htmlWithAssetUrls = rewriteAssetPaths(html, assetPathMap);\n const htmlWithBuiltModules = rewriteBuiltModulePaths(\n htmlWithAssetUrls,\n options.staticModuleMap\n );\n const htmlWithStylesheets = addStaticStylesheets(htmlWithBuiltModules, {\n staticModuleMap: options.staticModuleMap,\n staticCssMap: options.staticCssMap\n });\n\n output[story.id] = htmlWithStylesheets;\n }\n\n return output;\n } finally {\n await runtime.close();\n }\n}\n\n/** Reads the built Storybook index and keeps only Astro stories that can be prerendered. */\nasync function collectAstroStories(outDir: string): Promise<ProductionStoryEntry[]> {\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 // Static prerender only owns Astro stories. Framework-rendered stories stay\n // with Storybook's normal preview pipeline and are not pre-rendered here.\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 || !entry.componentPath) {\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 componentPath: entry.componentPath,\n exportName: entry.exportName,\n title: entry.title,\n name: entry.name\n };\n });\n}\n\n/** Builds lookup tables that map original asset paths to emitted static asset URLs. */\nfunction buildAssetPathMap(bundle: Rollup.OutputBundle): Map<string, string> {\n const exactMap = new Map<string, string>();\n const stemMap = new Map<string, string>();\n\n for (const chunk of Object.values(bundle)) {\n if (chunk.type !== 'asset') {\n continue;\n }\n\n const asset = chunk as Rollup.OutputAsset;\n\n if (asset.originalFileNames && asset.originalFileNames.length > 0) {\n for (const originalPath of asset.originalFileNames) {\n exactMap.set(originalPath, `/${asset.fileName}`);\n }\n }\n\n // Vite does not populate originalFileNames for image assets processed\n // through its asset pipeline. Build a secondary lookup by the filename\n // stem so /@fs/ URLs in prerendered HTML can still be mapped to their\n // content-hashed output paths. e.g. \"storybook-astro-CfMmZdup.png\" ⟶\n // stem key \"storybook-astro.png\" ⟶ \"/_astro/storybook-astro-CfMmZdup.png\".\n const baseName = asset.fileName.split('/').pop() ?? '';\n const stemMatch = baseName.match(/^(.+)-[A-Za-z0-9]{6,12}\\.(png|jpe?g|gif|webp|svg|avif|ico)$/);\n\n if (stemMatch) {\n stemMap.set(`${stemMatch[1]}.${stemMatch[2]}`, `/${asset.fileName}`);\n }\n }\n\n return { exactMap, stemMap } as unknown as Map<string, string>;\n}\n\n/** Rewrites dev-only /@fs/ asset URLs in prerendered HTML to emitted build asset paths. */\nfunction rewriteAssetPaths(\n html: string,\n assetPathMap: ReturnType<typeof buildAssetPathMap>\n): string {\n const { exactMap, stemMap } = assetPathMap as unknown as {\n exactMap: Map<string, string>;\n stemMap: Map<string, string>;\n };\n\n if (exactMap.size === 0 && stemMap.size === 0) {\n return html;\n }\n\n // Prerendering happens through a Vite SSR server, so image/style URLs can\n // still point at dev-only /@fs/ paths. Rewrite them to the emitted assets.\n return html.replace(/\\/@fs\\/[^\"']+/g, (match) => {\n const pathOnly = match.replace(/\\?.*$/, '');\n const fsPath = pathOnly.slice('/@fs'.length);\n // Handle /@fs//abs/path (double leading slash on Unix)\n const absolutePath = fsPath.startsWith('//') ? fsPath.slice(1) : fsPath;\n\n // Try exact match by originalFileNames first\n const exact = exactMap.get(absolutePath);\n\n if (exact) {\n return exact;\n }\n\n // Fall back to stem-based matching for image assets whose\n // originalFileNames are empty (standard Vite asset pipeline behaviour).\n const baseName = absolutePath.split('/').pop() ?? '';\n const stemHit = stemMap.get(baseName);\n\n if (stemHit) {\n return stemHit;\n }\n\n return match;\n });\n}\n","import { createHash } from 'node:crypto';\nimport { access, copyFile, mkdir, readFile, readdir, stat } from 'node:fs/promises';\nimport { dirname, resolve } from 'node:path';\nimport type { Rollup } from 'vite';\nimport type { Integration } from './integrations/index.ts';\nimport { resolveAliasedIsland } from './lib/resolve-aliased-island.ts';\n\n/** Resolves the shared virtual module ids used by both build pipelines. */\nexport function resolveVirtualBuildModuleId(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/** Loads the virtual modules that stand in for tracked runtime and component entrypoints. */\nexport function loadVirtualBuildModule(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 }\n\n return [`import '${specifier}';`, 'export default undefined;'].join('\\n');\n }\n\n if (id.startsWith('\\0virtual:astro-component-module/')) {\n const withoutPrefix = id.replace('\\0virtual:astro-component-module/', '');\n const encodedSpecifier = withoutPrefix.replace(/\\?.*$/, '');\n const specifier = decodeURIComponent(encodedSpecifier);\n\n return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join('\\n');\n }\n}\n\n/** Emits build entrypoints for framework client runtimes that Astro stories may reference. */\nexport async function emitBuildEntrypoints(options: {\n pluginContext: Rollup.PluginContext;\n integrations: Integration[];\n resolveFrom: string;\n trackedSpecifiers: Set<string>;\n staticEntrypointRefs: Map<string, string>;\n}) {\n const { pluginContext, integrations, resolveFrom } = options;\n\n // Keep framework client entrypoints in the build so Astro islands can\n // still hydrate after the preview iframe switches to built assets.\n integrations.forEach((integration) => {\n const entrypoint = integration.renderer.client?.entrypoint;\n\n if (entrypoint) {\n pluginContext.addWatchFile(entrypoint);\n }\n });\n\n options.trackedSpecifiers.forEach((specifier) => {\n const fileReferenceId = pluginContext.emitFile({\n type: 'chunk',\n id: toStaticVirtualId(specifier),\n name: createEntrypointName(resolveFrom, specifier)\n });\n\n options.staticEntrypointRefs.set(specifier, fileReferenceId);\n });\n}\n\n/** Emits framework component entry chunks for one Astro component file used in the build graph. */\nexport async function emitHydratedComponentEntriesFromAstroFile(options: {\n pluginContext: Rollup.PluginContext;\n astroFilePath: string;\n resolveFrom: string;\n componentEntrypointRefs: Map<string, string>;\n}) {\n const hydratedComponentPaths = await collectHydratedComponentPaths(\n options.astroFilePath,\n options.resolveFrom\n );\n\n for (const resolvedImportPath of hydratedComponentPaths) {\n\n if (options.componentEntrypointRefs.has(resolvedImportPath)) {\n continue;\n }\n\n const fileReferenceId = options.pluginContext.emitFile({\n type: 'chunk',\n id: toComponentChunkId(resolvedImportPath),\n name: createEntrypointName(options.resolveFrom, resolvedImportPath)\n });\n\n options.componentEntrypointRefs.set(resolvedImportPath, fileReferenceId);\n }\n}\n\n/** Collects the framework component files one Astro component hydrates in the browser. */\nexport async function collectHydratedComponentPaths(astroFilePath: string, resolveFrom: string) {\n // Only Astro components create islands, so only their framework imports\n // need standalone client chunks in built Storybook output.\n const allImportSpecifiers = await readAllImportSpecifiers(astroFilePath);\n const hydratedComponentPaths: string[] = [];\n\n for (const specifier of allImportSpecifiers) {\n // Resolve the specifier to an on-disk path — relative imports use the\n // importer's directory; aliased imports go through the tsconfig paths map.\n const resolvedImportPath = specifier.startsWith('.')\n ? await resolveLocalImportPath(astroFilePath, specifier)\n : await resolveAliasedIsland(specifier, resolveFrom);\n\n if (!resolvedImportPath) {\n continue;\n }\n\n if (\n !isHydratableSourceFile(resolvedImportPath) ||\n isNonHydratableSourceFile(resolvedImportPath)\n ) {\n continue;\n }\n\n // Only .jsx/.tsx files go through toComponentVirtualId, which emits\n // `export { default } from '<file>'`. A file with no default export\n // crashes Rollup with '\"default\" is not exported'. Svelte/Vue SFCs are\n // passed directly to their compilers, which generate the default export —\n // checking their source for a literal `export default` would falsely\n // exclude them.\n if (/\\.(jsx|tsx)$/.test(resolvedImportPath) && !(await hasDefaultExport(resolvedImportPath))) {\n continue;\n }\n\n hydratedComponentPaths.push(resolvedImportPath);\n }\n\n return hydratedComponentPaths;\n}\n\n/** Collects framework client runtimes that must stay addressable after the preview is built. */\nexport function collectTrackedSpecifiers(integrations: Integration[]) {\n const specifiers = new Set<string>([\n 'astro:scripts/page.js',\n 'astro:scripts/before-hydration.js'\n ]);\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\n/** Builds the browser module map used to rewrite source specifiers to built asset URLs. */\nexport function 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\n/** Normalizes one emitted file name to the relative public path used in built HTML. */\nexport function toPublicPath(fileName: string) {\n return `./${fileName}`;\n}\n\nexport function stripQuery(input: string | undefined) {\n return input?.replace(/\\?.*$/, '');\n}\n\n/** Converts a project file path into the stable path used inside the snapshot tree. */\nexport function relativePathFromRoot(resolveFrom: string, filePath: string) {\n return filePath.slice(resolveFrom.length).replace(/^[/\\\\]+/, '');\n}\n\n/** Copies one file or directory tree into the standalone runtime snapshot. */\nexport async function copyPath(sourcePath: string, targetPath: string): Promise<void> {\n const sourceStats = await stat(sourcePath);\n\n if (sourceStats.isDirectory()) {\n await mkdir(targetPath, { recursive: true });\n const entries = await readdir(sourcePath, { withFileTypes: true });\n\n await Promise.all(\n entries.map((entry) =>\n copyPath(resolve(sourcePath, entry.name), resolve(targetPath, entry.name))\n )\n );\n\n return;\n }\n\n await mkdir(dirname(targetPath), { recursive: true });\n await copyFile(sourcePath, targetPath);\n}\n\n/** Maps an original source file path to its location inside the snapshot tree. */\nexport function buildSnapshotFilePath(\n resolveFrom: string,\n filePath: string,\n snapshotDirName: string\n) {\n const normalizedResolveFrom = resolveFrom.replace(/\\\\/g, '/').replace(/\\/$/, '');\n const normalizedFilePath = filePath.replace(/\\\\/g, '/');\n\n if (normalizedFilePath.startsWith(`${normalizedResolveFrom}/`)) {\n return `${snapshotDirName}/${relativePathFromRoot(resolveFrom, filePath)}`.replace(/\\\\/g, '/');\n }\n\n return `${snapshotDirName}/__external/${normalizedFilePath.replace(/^[/\\\\]+/, '')}`.replace(\n /\\\\/g,\n '/'\n );\n}\n\n/** Copies the source files and config files the standalone render server needs at runtime. */\nexport async function copyRuntimeSnapshot(options: {\n resolveFrom: string;\n snapshotRoot: string;\n snapshotDirName: string;\n astroComponents: string[];\n storyRulesConfigFilePath?: string;\n}) {\n // The standalone render server still spins up a Vite SSR runtime, so it\n // needs the exact source/config files that runtime will read from disk.\n const runtimeInputFiles = new Set<string>([\n ...options.astroComponents,\n ...(options.storyRulesConfigFilePath ? [options.storyRulesConfigFilePath] : []),\n ...(await listRuntimeConfigFiles(options.resolveFrom))\n ]);\n const copiedFiles = new Set<string>();\n\n for (const runtimeInputFile of runtimeInputFiles) {\n await copyLocalRuntimeDependencies(runtimeInputFile, options, copiedFiles);\n }\n}\n\n/** Reports whether a JS/TS source file has a default export.\n * Only call for .jsx/.tsx — Svelte and Vue SFCs have no literal `export default`\n * in source, but their compilers generate one. On read error the file is kept,\n * preserving prior behaviour rather than silently dropping a component.\n *\n * The regex scan is intentionally conservative: it can match inside comments\n * or string literals, which produces a false-positive (file kept, Rollup crashes\n * as before) rather than a false-negative (file silently dropped). */\nasync function hasDefaultExport(absPath: string) {\n try {\n const source = await readFile(absPath, 'utf-8');\n\n return /export\\s+default\\b/.test(source) || /export\\s*\\{[^}]*\\bdefault\\b/.test(source);\n } catch {\n return true;\n }\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)}?component-wrapper`;\n}\n\nfunction toComponentChunkId(specifier: string) {\n return /\\.(svelte|vue)$/.test(specifier) ? specifier : toComponentVirtualId(specifier);\n}\n\nfunction createEntrypointName(resolveFrom: string, specifier: string) {\n const normalizedResolveFrom = resolveFrom.replace(/\\\\/g, '/');\n const normalizedSpecifier = specifier.replace(/\\\\/g, '/');\n const relativeName = normalizedSpecifier.startsWith(`${normalizedResolveFrom}/`)\n ? normalizedSpecifier.slice(normalizedResolveFrom.length + 1)\n : normalizedSpecifier.split('/').slice(-2).join('/');\n const sanitizedName = relativeName.replace(/[^a-zA-Z0-9/_-]/g, '_').replace(/_+/g, '_');\n const hash = createHash('sha1').update(normalizedSpecifier).digest('hex').slice(0, 8);\n\n return `${sanitizedName}-${hash}`;\n}\n\nfunction isClientEntrypoint(specifier: string) {\n return specifier.startsWith('@astrojs/') && specifier.endsWith('/client.js');\n}\n\nfunction isHydratableSourceFile(input: string) {\n return /\\.(jsx|tsx|vue|svelte)$/.test(input);\n}\n\nfunction isNonHydratableSourceFile(input: string) {\n return /\\.stories\\.[jt]sx?$|\\.stories\\.vue$|\\.stories\\.svelte$|\\.(spec|test)\\.[jt]sx?$/.test(\n input\n );\n}\n\n/** Finds project config files that the standalone render server may load through Vite. */\nasync function listRuntimeConfigFiles(resolveFrom: string) {\n const candidates = [\n 'package.json',\n 'tsconfig.json',\n 'tsconfig.base.json',\n 'jsconfig.json',\n 'astro.config.mjs',\n 'astro.config.js',\n 'astro.config.ts',\n 'vite.config.js',\n 'vite.config.ts',\n 'svelte.config.js'\n ];\n const existing: string[] = [];\n\n await Promise.all(\n candidates.map(async (candidate) => {\n const filePath = resolve(resolveFrom, candidate);\n\n try {\n await access(filePath);\n existing.push(filePath);\n } catch {\n return;\n }\n })\n );\n\n return existing;\n}\n\n/** Copies one local source file and follows its local imports into the snapshot. */\nasync function copyLocalRuntimeDependencies(\n sourcePath: string,\n options: {\n resolveFrom: string;\n snapshotRoot: string;\n snapshotDirName: string;\n },\n copiedFiles: Set<string>\n) {\n const normalizedSourcePath = sourcePath.replace(/\\\\/g, '/');\n\n if (copiedFiles.has(normalizedSourcePath)) {\n return;\n }\n\n copiedFiles.add(normalizedSourcePath);\n\n const snapshotRelativePath = buildSnapshotFilePath(\n options.resolveFrom,\n normalizedSourcePath,\n options.snapshotDirName\n );\n\n await copyPath(\n normalizedSourcePath,\n resolve(dirname(options.snapshotRoot), snapshotRelativePath)\n );\n\n // Follow only local imports here. Package dependencies stay external and are\n // resolved by Node/Vite from the deployed install, not copied into snapshot.\n const localImportSpecifiers = await readLocalImportSpecifiers(normalizedSourcePath);\n\n for (const specifier of localImportSpecifiers) {\n const resolvedDependency = await resolveLocalImportPath(normalizedSourcePath, specifier);\n\n if (!resolvedDependency) {\n continue;\n }\n\n await copyLocalRuntimeDependencies(resolvedDependency, options, copiedFiles);\n }\n}\n\nconst IMPORT_RE =\n /(?:import|export)\\s+(?:[^'\"`]*?\\s+from\\s+)?['\"`]([^'\"`]+)['\"`]|import\\(\\s*['\"`]([^'\"`]+)['\"`]\\s*\\)/g;\n\n/** Returns all import specifiers found in the file (relative, aliased, and package). */\nasync function readAllImportSpecifiers(filePath: string): Promise<string[]> {\n if (!/\\.(astro|[cm]?[jt]sx?|vue|svelte)$/.test(filePath)) {\n return [];\n }\n\n const source = await readFile(filePath, 'utf-8');\n\n return Array.from(source.matchAll(IMPORT_RE), (match) => match[1] ?? match[2]).filter(\n (specifier): specifier is string => Boolean(specifier)\n );\n}\n\n/** Reads local (relative) import specifiers from source files that can participate in the SSR runtime. */\nasync function readLocalImportSpecifiers(filePath: string) {\n return (await readAllImportSpecifiers(filePath)).filter((s) => s.startsWith('.'));\n}\n\n/** Resolves one relative import the same way the project source tree would on disk. */\nasync function resolveLocalImportPath(importerPath: string, specifier: string) {\n const basePath = resolve(dirname(importerPath), specifier);\n const candidates = [\n basePath,\n `${basePath}.ts`,\n `${basePath}.tsx`,\n `${basePath}.js`,\n `${basePath}.jsx`,\n `${basePath}.mjs`,\n `${basePath}.cjs`,\n `${basePath}.astro`,\n `${basePath}.vue`,\n `${basePath}.svelte`,\n resolve(basePath, 'index.ts'),\n resolve(basePath, 'index.tsx'),\n resolve(basePath, 'index.js'),\n resolve(basePath, 'index.jsx'),\n resolve(basePath, 'index.mjs'),\n resolve(basePath, 'index.cjs'),\n resolve(basePath, 'index.astro'),\n resolve(basePath, 'index.vue'),\n resolve(basePath, 'index.svelte')\n ];\n\n for (const candidate of candidates) {\n try {\n const candidateStats = await stat(candidate);\n\n if (candidateStats.isFile()) {\n return candidate.replace(/\\\\/g, '/');\n }\n } catch {\n continue;\n }\n }\n\n return undefined;\n}\n","import { resolve } from 'node:path';\nimport { createAstroRenderHandler, type HandlerProps } from './astroRenderHandler.ts';\nimport type { Integration } from './integrations/index.ts';\nimport type { SanitizationOptions } from './lib/sanitization.ts';\nimport type { FrameworkOptions } from './types.ts';\nimport {\n createClientModuleResolver,\n createProductionAstroContainer,\n createStorySsrViteServer,\n loadRulesConfigModule\n} from './storySsrVite.ts';\n\ntype LoadedStoryModule = Record<string, unknown>;\n\nexport type ProductionRenderRuntime = {\n loadModule: (moduleId: string) => Promise<LoadedStoryModule>;\n renderAstroStory: (data: HandlerProps) => Promise<string>;\n close: () => Promise<void>;\n};\n\nexport type ProductionStoryEntry = {\n id: string;\n importPath: string;\n componentPath: string;\n exportName: string;\n title?: string;\n name?: string;\n};\n\ntype ProductionRenderRuntimeOptions = {\n integrations: Integration[];\n sanitization?: SanitizationOptions;\n storyRulesConfigFilePath?: string;\n staticModuleMap: Record<string, string>;\n trackedSpecifiers: Set<string>;\n resolveFrom: string;\n resolveComponentId?: (id: string) => string;\n fonts?: FrameworkOptions['fonts'];\n};\n\n/** Creates the shared SSR runtime used by both build-time prerendering and the standalone render server. */\nexport async function createProductionRenderRuntime(\n options: ProductionRenderRuntimeOptions\n): Promise<ProductionRenderRuntime> {\n const viteServer = await createStorySsrViteServer({\n integrations: options.integrations,\n trackedSpecifiers: options.trackedSpecifiers,\n resolveFrom: options.resolveFrom,\n fonts: options.fonts\n });\n\n try {\n const rulesConfigModule = await loadRulesConfigModule(\n viteServer,\n options.storyRulesConfigFilePath\n );\n const resolveClientModule = createClientModuleResolver(\n options.integrations,\n options.staticModuleMap\n );\n const astroContainer = await createProductionAstroContainer({\n integrations: options.integrations,\n resolveClientModule,\n viteServer,\n resolveFrom: options.resolveFrom\n });\n\n const loadModule = async (moduleId: string) => {\n return (await viteServer.ssrLoadModule(\n options.resolveComponentId?.(moduleId) ?? moduleId\n )) as LoadedStoryModule;\n };\n const renderAstroStory = createAstroRenderHandler({\n container: astroContainer,\n sanitization: options.sanitization,\n rulesConfigFilePath: options.storyRulesConfigFilePath,\n resolveRulesConfigModule: () => rulesConfigModule,\n loadModule: async (moduleId: string) => {\n const loadedModule = await loadModule(moduleId);\n\n return {\n default: loadedModule.default\n };\n },\n invalidateModuleGraph: () => {\n viteServer.moduleGraph.invalidateAll();\n }\n });\n\n return {\n loadModule,\n renderAstroStory,\n close: () => viteServer.close()\n };\n } catch (error) {\n await viteServer.close();\n throw error;\n }\n}\n\n/** Loads one Astro story module, merges its args, and renders the Astro component to HTML. */\nexport async function renderProductionStoryToHtml(options: {\n story: ProductionStoryEntry;\n runtime: ProductionRenderRuntime;\n resolveFrom: string;\n}) {\n const storyModulePath = resolveProjectImportPath(options.story.importPath, options.resolveFrom);\n const componentPath = resolveProjectImportPath(options.story.componentPath, options.resolveFrom);\n const storyModule = await options.runtime.loadModule(storyModulePath);\n const defaultStoryMeta = isRecord(storyModule.default) ? storyModule.default : {};\n const selectedStoryExport = isRecord(storyModule[options.story.exportName])\n ? storyModule[options.story.exportName]\n : {};\n\n if (typeof defaultStoryMeta.component !== 'function') {\n throw new Error(\n `Unable to prerender story \"${options.story.id}\". Missing default export component in ${options.story.importPath}.`\n );\n }\n\n // Build-time prerender only supports stories that keep the meta-level Astro component.\n if (selectedStoryExport.component && selectedStoryExport.component !== defaultStoryMeta.component) {\n return undefined;\n }\n\n const storyArgs = mergeMetaArgsWithStoryArgs(\n toRecord(defaultStoryMeta.args),\n toRecord(selectedStoryExport.args)\n );\n const { componentArgs, storySlots } = separateStorySlots(storyArgs);\n\n return options.runtime.renderAstroStory({\n component: componentPath,\n args: componentArgs,\n slots: storySlots,\n story: {\n id: options.story.id,\n title: options.story.title,\n name: options.story.name\n }\n });\n}\n\nfunction resolveProjectImportPath(importPath: string, resolveFrom: string) {\n if (importPath.startsWith('./') || importPath.startsWith('../')) {\n return resolve(resolveFrom, importPath);\n }\n\n return importPath;\n}\n\nfunction mergeMetaArgsWithStoryArgs(\n metaArgs: Record<string, unknown> | undefined,\n storyArgs: Record<string, unknown> | undefined\n) {\n return {\n ...(metaArgs ?? {}),\n ...(storyArgs ?? {})\n };\n}\n\nfunction separateStorySlots(storyArgs: Record<string, unknown>) {\n const componentArgs = { ...storyArgs };\n const storySlots = componentArgs.slots;\n\n delete componentArgs.slots;\n\n if (!isRecord(storySlots)) {\n return {\n componentArgs,\n storySlots: {}\n };\n }\n\n return {\n componentArgs,\n storySlots: storySlots as Record<string, string>\n };\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","import { createRequire } from 'node:module';\nimport { createServer, mergeConfig, type Plugin, type ViteDevServer } from 'vite';\nimport type { experimental_AstroContainer as AstroContainer } from 'astro/container';\nimport { ensureAstroPassthroughImageService } from './astroImageService.ts';\nimport { importAstroConfig } from './importAstroConfig.ts';\nimport type { Integration } from './integrations/index.ts';\nimport { resolveAliasedIsland } from './lib/resolve-aliased-island.ts';\nimport { ssrLoadModuleWithFsFallback } from './lib/ssr-load-module-with-fs-fallback.ts';\nimport { resolveStoryModuleMock } from './module-mocks.ts';\nimport type { FrameworkOptions } from './types.ts';\nimport { vitePluginAstroFonts } from './vitePluginAstroFonts.ts';\nimport { vitePluginAstroIntegrationOptsFallback } from './vitePluginAstroIntegrationOptsFallback.ts';\nimport { vitePluginAstroRoutesFallback } from './vitePluginAstroRoutesFallback.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\nimport { vitePluginStoryModuleMocks } from './vitePluginStoryModuleMocks.ts';\n\nexport async function createStorySsrViteServer(options: {\n integrations: Integration[];\n trackedSpecifiers: Set<string>;\n resolveFrom: string;\n fonts?: FrameworkOptions['fonts'];\n}) {\n const { getViteConfig, passthroughImageService } = await importAstroConfig(options.resolveFrom);\n const astroConfig = await getViteConfig(\n { root: options.resolveFrom },\n {\n configFile: false,\n integrations: await Promise.all(\n options.integrations.map((integration) => integration.loadIntegration(options.resolveFrom))\n ),\n image: { service: passthroughImageService() }\n }\n )({\n mode: 'production',\n command: 'serve'\n });\n\n const config = mergeConfig(astroConfig, {\n appType: 'custom',\n server: {\n middlewareMode: true\n },\n ssr: {\n // Keep Astro runtime classes in the Vite SSR graph so containers and\n // components share SlotString/HTMLString instances during prerendering.\n noExternal: /^astro(\\/.+)?$/\n },\n plugins: [\n createProjectAstroResolutionPlugin(options.resolveFrom),\n vitePluginAstroFonts({ fonts: options.fonts, root: options.resolveFrom }),\n vitePluginAstroIntegrationOptsFallback(),\n vitePluginAstroVueFallback(),\n vitePluginAstroRoutesFallback(),\n vitePluginStoryModuleMocks(),\n createTrackedSpecifierStubPlugin(options.trackedSpecifiers)\n ]\n });\n\n const viteServer = await createServer(config);\n\n await viteServer.pluginContainer.buildStart({});\n\n return viteServer;\n}\n\nexport async function loadRulesConfigModule(viteServer: ViteDevServer, configFilePath?: string) {\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\nexport function 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\nexport async function createProductionAstroContainer(options: {\n integrations: Integration[];\n resolveClientModule: (specifier: string) => string | undefined;\n viteServer: ViteDevServer;\n resolveFrom: string;\n}) {\n ensureAstroPassthroughImageService();\n\n // Astro 6's container wraps each slot value in a SlotString, and the\n // rendering pipeline detects raw-HTML slot chunks via `instanceof SlotString`.\n // If the container is loaded by Node's ESM resolver while components are\n // loaded through Vite's SSR graph, the two paths produce different\n // SlotString classes and the instanceof check fails — slot content then\n // takes the escaping code path. Loading the container via the same Vite\n // SSR server keeps the class identity consistent.\n const containerModule = (await options.viteServer.ssrLoadModule('astro/container')) as {\n experimental_AstroContainer: typeof AstroContainer;\n };\n const ViteAstroContainer = containerModule.experimental_AstroContainer;\n\n const container = await ViteAstroContainer.create({\n resolve: async (specifier) => {\n const mockedModule = resolveStoryModuleMock(specifier);\n\n if (mockedModule) {\n return mockedModule;\n }\n\n const resolution = options.resolveClientModule(specifier);\n\n if (resolution) {\n return resolution;\n }\n\n // Last resort: an island imported via a tsconfig path alias (e.g. `@/...`)\n // never matches the static map under its raw specifier. Resolve the alias\n // to an on-disk path and look that up in the built module map instead.\n const abs = await resolveAliasedIsland(specifier, options.resolveFrom);\n\n if (abs) {\n return options.resolveClientModule(abs) ?? specifier;\n }\n\n return specifier;\n }\n });\n\n await addContainerRenderers(\n container,\n options.integrations,\n options.resolveClientModule,\n options.viteServer\n );\n\n return container;\n}\n\nexport async function addContainerRenderers(\n container: Awaited<ReturnType<typeof AstroContainer.create>>,\n integrations: Integration[],\n resolveClientModule: (specifier: string) => string | undefined,\n viteServer: ViteDevServer\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 never\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 createProjectAstroResolutionPlugin(resolveFrom: string): Plugin {\n const require = createRequire(import.meta.url);\n\n return {\n name: 'storybook-astro:resolve-project-astro-shared',\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 } satisfies Plugin;\n}\n\nfunction createTrackedSpecifierStubPlugin(trackedSpecifiers: Set<string>): Plugin {\n return {\n name: 'storybook-astro:shared-ssr-stubs',\n resolveId(id: string) {\n if (trackedSpecifiers.has(id)) {\n return `\\0storybook-astro-shared-ssr-stub:${encodeURIComponent(id)}`;\n }\n\n return null;\n },\n load(id: string) {\n if (id.startsWith('\\0storybook-astro-shared-ssr-stub:')) {\n return 'export default undefined;';\n }\n\n return null;\n }\n } satisfies Plugin;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n","import { createRequire } from 'node:module';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { build, type Rollup } from 'vite';\nimport type { Integration } from '../integrations/index.ts';\nimport { mergeWithAstroConfig } from '../vitePluginAstro.ts';\nimport { collectHydratedComponentPaths } from '../vitePluginAstroBuildShared.ts';\nimport type { StaticCssMap, StaticModuleMap } from './staticHtmlRewriting.ts';\n\nexport type HydratedComponentAssets = {\n staticModuleMap: StaticModuleMap;\n staticCssMap: StaticCssMap;\n};\n\nexport type BuildHydratedComponentAssetsOptions = {\n componentPaths: string[];\n integrations: Integration[];\n resolveFrom: string;\n outDir: string;\n};\n\n/**\n * Bundles the framework components hydrated inside Astro stories into the static\n * output directory and returns the path/CSS lookups needed to rewrite rendered HTML.\n *\n * Storybook's main Vite build does not include these framework files unless they\n * are imported directly by a `.stories.*` file. Astro stories typically import\n * only the `.astro` wrapper (which gets replaced by a client stub), so without\n * this step their `client:load` islands have no built JS chunk and no extracted\n * CSS — leading to unstyled, unhydrated previews in the static build.\n *\n * Component paths may be absolute filesystem paths, paths relative to `resolveFrom`,\n * or bare package specifiers (e.g. `@my-pkg/components/Foo.astro`). All three are\n * normalized to absolute filesystem paths before reading sources from disk.\n */\nexport async function buildHydratedComponentAssets(\n options: BuildHydratedComponentAssetsOptions\n): Promise<HydratedComponentAssets> {\n const resolveSpecifier = createSpecifierResolver(options.resolveFrom);\n const resolvedComponentPaths = options.componentPaths\n .map(resolveSpecifier)\n .filter((path): path is string => Boolean(path));\n const hydratedComponentPaths = Array.from(\n new Set(\n (\n await Promise.all(\n resolvedComponentPaths.map((componentPath) =>\n collectHydratedComponentPaths(componentPath)\n )\n )\n ).flat()\n )\n );\n\n if (hydratedComponentPaths.length === 0) {\n return { staticModuleMap: {}, staticCssMap: {} };\n }\n\n const clientEntrypoints = Array.from(\n new Set(\n options.integrations\n .map((integration) => integration.renderer.client?.entrypoint)\n .filter((entrypoint): entrypoint is string => Boolean(entrypoint))\n )\n );\n const entryNames = Object.fromEntries([\n ...hydratedComponentPaths.map((componentPath, index) => [`component-${index}`, componentPath]),\n ...clientEntrypoints.map((entrypoint, index) => [`renderer-${index}`, entrypoint])\n ]);\n const buildConfig = {\n root: options.resolveFrom,\n build: {\n write: false,\n outDir: options.outDir,\n emptyOutDir: false,\n manifest: false,\n rollupOptions: {\n input: entryNames,\n preserveEntrySignatures: 'strict',\n output: {\n entryFileNames: '_astro/[name]-[hash].js',\n chunkFileNames: '_astro/[name]-[hash].js',\n assetFileNames: '_astro/[name]-[hash][extname]'\n }\n }\n }\n };\n const finalConfig = await mergeWithAstroConfig(\n buildConfig,\n options.integrations,\n options.resolveFrom,\n 'production',\n 'build'\n );\n const buildOutput = await build(finalConfig);\n const output = Array.isArray(buildOutput)\n ? buildOutput.flatMap((result) => result.output)\n : buildOutput.output;\n const chunksByFileName = new Map<string, Rollup.OutputChunk>();\n\n for (const item of output) {\n await writeBuildOutputFile(options.outDir, item);\n\n if (item.type === 'chunk') {\n chunksByFileName.set(item.fileName, item);\n }\n }\n\n const staticModuleMap: StaticModuleMap = {};\n const staticCssMap: StaticCssMap = {};\n\n for (const item of output) {\n if (item.type !== 'chunk' || !item.facadeModuleId) {\n continue;\n }\n\n const normalizedFacadeId = item.facadeModuleId.replace(/\\\\/g, '/');\n const originalInputSpecifier = entryNames[item.name];\n\n staticModuleMap[normalizedFacadeId] = `./${item.fileName}`;\n\n if (originalInputSpecifier && originalInputSpecifier !== normalizedFacadeId) {\n staticModuleMap[originalInputSpecifier] = `./${item.fileName}`;\n }\n\n // CSS Modules and other shared stylesheets get hoisted into shared chunks\n // when multiple entries reference them. The entry chunk's own importedCss\n // does not list those, so walk transitively through `imports` to find every\n // stylesheet the browser must load alongside this hydrated component.\n const importedCss = collectTransitiveImportedCss(item, chunksByFileName);\n\n if (importedCss.length > 0) {\n const cssPaths = importedCss.map((fileName) => `./${fileName}`);\n\n staticCssMap[normalizedFacadeId] = cssPaths;\n\n if (originalInputSpecifier && originalInputSpecifier !== normalizedFacadeId) {\n staticCssMap[originalInputSpecifier] = cssPaths;\n }\n }\n }\n\n return { staticModuleMap, staticCssMap };\n}\n\n/** Collects every CSS file reachable from the chunk through its transitive JS imports. */\nfunction collectTransitiveImportedCss(\n entry: Rollup.OutputChunk,\n chunksByFileName: Map<string, Rollup.OutputChunk>\n): string[] {\n const visited = new Set<string>();\n const css = new Set<string>();\n const queue: Rollup.OutputChunk[] = [entry];\n\n while (queue.length > 0) {\n const chunk = queue.shift();\n\n if (!chunk || visited.has(chunk.fileName)) {\n continue;\n }\n\n visited.add(chunk.fileName);\n\n for (const file of chunk.viteMetadata?.importedCss ?? new Set<string>()) {\n css.add(file);\n }\n\n for (const importedFileName of chunk.imports ?? []) {\n const next = chunksByFileName.get(importedFileName);\n\n if (next) {\n queue.push(next);\n }\n }\n }\n\n return Array.from(css);\n}\n\nasync function writeBuildOutputFile(outDir: string, item: Rollup.OutputAsset | Rollup.OutputChunk) {\n const outputPath = resolve(outDir, item.fileName);\n\n await mkdir(dirname(outputPath), { recursive: true });\n\n if (item.type === 'asset') {\n await writeFile(outputPath, item.source);\n\n return;\n }\n\n await writeFile(outputPath, item.code);\n}\n\n/** Resolves Storybook story `componentPath` values (absolute, relative, or bare specifier) to absolute paths. */\nfunction createSpecifierResolver(resolveFrom: string) {\n // createRequire needs a real filename in `resolveFrom`; package.json works\n // even when it does not exist (require.resolve only reads it to find roots).\n const require_ = createRequire(pathToFileURL(resolve(resolveFrom, 'package.json')));\n\n return (componentPath: string): string | undefined => {\n if (isAbsolute(componentPath)) {\n return componentPath;\n }\n\n if (componentPath.startsWith('./') || componentPath.startsWith('../')) {\n return resolve(resolveFrom, componentPath);\n }\n\n try {\n return require_.resolve(componentPath);\n } catch {\n return undefined;\n }\n };\n}\n","import { mergeConfig, type InlineConfig } from 'vite';\nimport type { Integration } from './integrations/index.ts';\nimport { importAstroConfig } from './importAstroConfig.ts';\nimport { loadUserAstroIntegrations } from './loadUserAstroConfig.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 frameworkIntegrations = await Promise.all(\n safeIntegrations.map((integration) => integration.loadIntegration(resolveFrom))\n );\n\n const userIntegrations = await loadUserAstroIntegrations(resolveFrom);\n const frameworkNames = new Set(frameworkIntegrations.map(i => i.name));\n const extraIntegrations = userIntegrations.filter(i => !frameworkNames.has(i.name));\n\n const astroConfig = await getViteConfig(\n {},\n {\n configFile: false,\n integrations: [...frameworkIntegrations, ...extraIntegrations]\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","/**\n * Shared helpers used by both the static prerender build and the standalone\n * render server to turn dev-server rendered Astro HTML into production output.\n *\n * Both pipelines render Astro stories through a Vite SSR runtime, which leaves\n * source-tree module paths (e.g. `/abs/path/Component.jsx`) inside emitted\n * markup such as `<astro-island component-url=\"...\">`. The browser receives\n * built chunks at hashed `/_astro/*` URLs, so the source paths must be\n * rewritten before the HTML is served. Hydrated framework component chunks\n * also have their CSS extracted at build time — without an explicit `<link>`\n * tag, those styles never reach the page.\n */\n\nexport type StaticModuleMap = Record<string, string>;\nexport type StaticCssMap = Record<string, string[]>;\n\n/** Rewrites every reference to a source module path in the rendered HTML to its built-asset URL. */\nexport function rewriteBuiltModulePaths(html: string, staticModuleMap: StaticModuleMap): string {\n let output = html;\n const entries = Object.entries(staticModuleMap).sort(\n ([left], [right]) => right.length - left.length\n );\n\n for (const [sourcePath, builtPath] of entries) {\n // Replace the /@fs/-prefixed form first so the bare-path replace below\n // can't truncate it and leave a stray \"/@fs\" stub in the output.\n output = output.split(toFsPath(sourcePath)).join(builtPath);\n output = output.split(sourcePath).join(builtPath);\n }\n\n return output;\n}\n\n/** Prepends stylesheet links for any built framework chunks referenced by the rendered HTML. */\nexport function addStaticStylesheets(\n html: string,\n options: { staticModuleMap: StaticModuleMap; staticCssMap: StaticCssMap }\n): string {\n const stylesheets = new Set<string>();\n\n for (const [sourcePath, cssPaths] of Object.entries(options.staticCssMap)) {\n const builtModulePath = options.staticModuleMap[sourcePath];\n\n // Match either the original source path or the rewritten built module URL.\n if (!html.includes(sourcePath) && (!builtModulePath || !html.includes(builtModulePath))) {\n continue;\n }\n\n cssPaths.forEach((cssPath) => stylesheets.add(cssPath));\n }\n\n if (stylesheets.size === 0) {\n return html;\n }\n\n const stylesheetTags = Array.from(stylesheets)\n .map((href) => `<link rel=\"stylesheet\" href=\"${href}\">`)\n .join('');\n\n return `${stylesheetTags}${html}`;\n}\n\n/** Converts one source file path into the Vite /@fs/ URL form used during SSR. */\nfunction toFsPath(sourcePath: string) {\n const normalizedPath = sourcePath.replace(/\\\\/g, '/');\n\n return normalizedPath.startsWith('/') ? `/@fs${normalizedPath}` : `/@fs/${normalizedPath}`;\n}\n","import { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { build, type Rollup } from 'vite';\nimport { resolveRulesConfigFilePath } from './rules-options.ts';\nimport type { FrameworkOptions } from './types.ts';\nimport {\n buildStaticModuleMap,\n buildSnapshotFilePath,\n copyRuntimeSnapshot,\n collectTrackedSpecifiers,\n emitBuildEntrypoints,\n loadVirtualBuildModule,\n resolveVirtualBuildModuleId,\n} from './vitePluginAstroBuildShared.ts';\nimport { buildHydratedComponentAssets } from './lib/hydratedComponentBuild.ts';\nimport { mergeWithAstroConfig } from './vitePluginAstro.ts';\nimport { viteAstroContainerRenderersPlugin } from './viteAstroContainerRenderersPlugin.ts';\nimport { sanitizeConfigPlugin } from './vite/sanitizeConfigPlugin.ts';\nimport { serverAuthPlugin } from './vite/serverAuthPlugin.ts';\nimport { serverRuntimePlugin } from './vite/serverRuntimePlugin.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 trackedSpecifiers = collectTrackedSpecifiers(integrations);\n const staticEntrypointRefs = 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) {\n return resolveVirtualBuildModuleId(id);\n },\n\n load(id: string) {\n return loadVirtualBuildModule(id);\n },\n\n async buildStart(this: Rollup.PluginContext) {\n await emitBuildEntrypoints({\n pluginContext: this,\n integrations,\n resolveFrom,\n trackedSpecifiers,\n staticEntrypointRefs\n });\n },\n\n async writeBundle(\n this: Rollup.PluginContext,\n _outputOptions: Rollup.NormalizedOutputOptions\n ) {\n const serverOutDir = resolve(dirname(storybookStaticOutDir), 'storybook-server');\n const snapshotDirName = 'project';\n const astroStories = await collectAstroStories(storybookStaticOutDir, resolveFrom);\n const storyAstroComponentPaths = Array.from(new Set(astroStories.map((story) => story.componentPath)));\n const componentPathMap = buildComponentPathMap(storyAstroComponentPaths, resolveFrom, snapshotDirName);\n const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, resolveFrom);\n const trackedModuleMap = buildStaticModuleMap(this, staticEntrypointRefs, new Map());\n const hydratedComponentAssets = await buildHydratedComponentAssets({\n componentPaths: storyAstroComponentPaths,\n integrations,\n resolveFrom,\n outDir: storybookStaticOutDir\n });\n const staticModuleMap = addSnapshotModuleAliases(\n {\n ...trackedModuleMap,\n ...hydratedComponentAssets.staticModuleMap\n },\n {\n resolveFrom,\n snapshotRoot: resolve(serverOutDir, snapshotDirName),\n snapshotDirName\n }\n );\n const staticCssMap = hydratedComponentAssets.staticCssMap;\n\n await buildAstroServer({\n integrations,\n sanitization: options.sanitization,\n storyRules: options.storyRules,\n server: options.server,\n outDir: serverOutDir,\n snapshotDirName,\n componentPathMap,\n staticModuleMap,\n staticCssMap,\n trackedSpecifiers: Array.from(trackedSpecifiers),\n resolveFrom\n });\n\n await copyRuntimeSnapshot({\n resolveFrom,\n snapshotRoot: resolve(serverOutDir, snapshotDirName),\n snapshotDirName,\n astroComponents: storyAstroComponentPaths,\n storyRulesConfigFilePath\n });\n }\n };\n}\n\n/** Builds the standalone Astro render server used by server-mode Storybook output. */\nasync function buildAstroServer(options: {\n integrations: NonNullable<FrameworkOptions['integrations']>;\n sanitization?: FrameworkOptions['sanitization'];\n storyRules?: FrameworkOptions['storyRules'];\n server?: FrameworkOptions['server'];\n outDir: string;\n snapshotDirName: string;\n componentPathMap: Record<string, string>;\n staticModuleMap: Record<string, string>;\n staticCssMap: Record<string, string[]>;\n trackedSpecifiers: 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 sanitizeConfigPlugin(options.sanitization),\n serverAuthPlugin(options.server),\n serverRuntimePlugin({\n integrations: options.integrations,\n storyRules: options.storyRules,\n resolveFrom: options.resolveFrom,\n snapshotDirName: options.snapshotDirName,\n componentPathMap: options.componentPathMap,\n staticModuleMap: options.staticModuleMap,\n staticCssMap: options.staticCssMap,\n trackedSpecifiers: options.trackedSpecifiers\n }),\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\n/** Rewrites Astro component module ids so the standalone server loads them from the snapshot tree. */\nfunction buildComponentPathMap(\n astroComponents: string[],\n resolveFrom: string,\n snapshotDirName: string\n) {\n // The built render server loads Astro component modules from the snapshot,\n // not from the original project root that existed during the build.\n return Object.fromEntries(\n astroComponents.map((componentPath) => [\n componentPath,\n buildSnapshotFilePath(resolveFrom, componentPath, snapshotDirName).replace(\n new RegExp(`^${snapshotDirName}/`),\n ''\n )\n ])\n );\n}\n\nasync function collectAstroStories(outDir: string, resolveFrom: string) {\n const indexFile = resolve(outDir, 'index.json');\n const indexRaw = await import('node:fs/promises').then(({ readFile }) => readFile(indexFile, 'utf-8'));\n const indexJson = JSON.parse(indexRaw) as {\n entries?: Record<string, { type?: string; componentPath?: string; importPath?: string; exportName?: string }>\n };\n\n return Object.values(indexJson.entries ?? [])\n .filter((entry) => entry.type === 'story' && entry.componentPath?.endsWith('.astro'))\n .map((entry) => ({\n componentPath: entry.componentPath?.startsWith('./') || entry.componentPath?.startsWith('../')\n ? resolve(resolveFrom, entry.componentPath)\n : entry.componentPath\n }))\n .filter((entry): entry is { componentPath: string } => Boolean(entry.componentPath));\n}\n\nfunction addSnapshotModuleAliases(\n staticModuleMap: Record<string, string>,\n options: {\n resolveFrom: string;\n snapshotRoot: string;\n snapshotDirName: string;\n }\n) {\n const mapWithSnapshotPaths = { ...staticModuleMap };\n\n for (const [sourcePath, builtPath] of Object.entries(staticModuleMap)) {\n if (!sourcePath.startsWith('/')) {\n continue;\n }\n\n const snapshotPath = resolve(\n dirname(options.snapshotRoot),\n buildSnapshotFilePath(options.resolveFrom, sourcePath, options.snapshotDirName)\n ).replace(/\\\\/g, '/');\n\n mapWithSnapshotPaths[snapshotPath] = builtPath;\n }\n\n return mapWithSnapshotPaths;\n}\n","import type { Plugin } from 'vite';\nimport type { SanitizationOptions } from '../lib/sanitization.ts';\nimport { serializeSanitizationOptions } from '../lib/sanitization.ts';\nimport { createVirtualModule } from './virtualModulePlugin.ts';\n\nexport const SANITIZE_CONFIG_MODULE_ID = 'virtual:storybook-astro/sanitize-config';\n\nexport function sanitizeConfigPlugin(options?: SanitizationOptions): Plugin {\n return createVirtualModule({\n pluginName: 'storybook-astro:sanitize-config',\n virtualModuleId: SANITIZE_CONFIG_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 { createVirtualModule } from './virtualModulePlugin.ts';\n\nexport const SERVER_AUTH_MODULE_ID = 'virtual:storybook-astro/server-auth';\n\nexport function serverAuthPlugin(options?: ServerBuildOptions): Plugin {\n const authToken = normalizeOptionalString(options?.authToken);\n const authHeader = normalizeAuthHeader(options?.authHeader);\n\n return createVirtualModule({\n pluginName: 'storybook-astro:server-auth',\n virtualModuleId: SERVER_AUTH_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 { relative } from 'node:path';\nimport type { Integration } from '../integrations/index.ts';\nimport { resolveRulesConfigFilePath } from '../rules-options.ts';\nimport type { FrameworkOptions } from '../types.ts';\nimport { createVirtualModule } from './virtualModulePlugin.ts';\n\nexport const SERVER_RUNTIME_MODULE_ID = 'virtual:storybook-astro/server-runtime';\nconst integrationsModuleId = '@storybook-astro/framework/integrations';\n\nfunction getIntegrationFactoryName(integration: Integration): string {\n return integration.factoryName ?? integration.name;\n}\n\n/** Produces the virtual module that hands the standalone render server its build-time config. */\nexport function serverRuntimePlugin(options: {\n integrations?: FrameworkOptions['integrations'];\n storyRules?: FrameworkOptions['storyRules'];\n resolveFrom: string;\n snapshotDirName: string;\n componentPathMap: Record<string, string>;\n staticModuleMap: Record<string, string>;\n staticCssMap: Record<string, string[]>;\n trackedSpecifiers: string[];\n}) {\n return createVirtualModule({\n pluginName: 'storybook-astro:server-runtime',\n virtualModuleId: SERVER_RUNTIME_MODULE_ID,\n load() {\n const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, options.resolveFrom);\n const storyRulesConfigRelativePath = storyRulesConfigFilePath\n ? relative(options.resolveFrom, storyRulesConfigFilePath).replace(/\\\\/g, '/')\n : undefined;\n const integrations = options.integrations ?? [];\n // Keep the generated module small: one config object for plain data,\n // one integrations export for real factory calls.\n const runtimeConfig = {\n snapshotDirName: options.snapshotDirName,\n storyRulesConfigRelativePath,\n componentPathMap: options.componentPathMap,\n staticModuleMap: options.staticModuleMap,\n staticCssMap: options.staticCssMap,\n trackedSpecifiers: options.trackedSpecifiers\n };\n\n return [\n createIntegrationImports(integrations),\n `export const runtimeConfig = ${serializeValue(runtimeConfig)};`,\n `export const integrations = [${createIntegrationFactoryCalls(integrations)}];`\n ].join('\\n');\n }\n });\n}\n\n/** Imports only the integration factories used by this runtime bundle. */\nfunction createIntegrationImports(integrations: Integration[]) {\n const factoryNames = Array.from(new Set(integrations.map(getIntegrationFactoryName)));\n\n if (factoryNames.length === 0) {\n return '';\n }\n\n return `import { ${factoryNames.join(', ')} } from ${JSON.stringify(integrationsModuleId)};`;\n}\n\n/** Recreates the configured integration list inside the generated runtime module. */\nfunction createIntegrationFactoryCalls(integrations: Integration[]) {\n return integrations\n .map((integration) => `${getIntegrationFactoryName(integration)}(${serializeValue(integration.options)})`)\n .join(', ');\n}\n\n/** Serializes plain runtime config values into executable module source. */\nfunction serializeValue(value: unknown): string {\n if (value === undefined) {\n return 'undefined';\n }\n\n if (value === null) {\n return 'null';\n }\n\n if (typeof value === 'string') {\n return JSON.stringify(value);\n }\n\n if (typeof value === 'number' || typeof value === 'boolean') {\n return JSON.stringify(value);\n }\n\n if (value instanceof RegExp) {\n return value.toString();\n }\n\n if (Array.isArray(value)) {\n return `[${value.map((entry) => serializeValue(entry)).join(', ')}]`;\n }\n\n if (isRecord(value)) {\n return `{${Object.entries(value)\n .map(([key, entryValue]) => `${JSON.stringify(key)}: ${serializeValue(entryValue)}`)\n .join(', ')}}`;\n }\n\n throw new Error('Unable to serialize Storybook Astro server runtime configuration.');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAAA,gBAAe;;;ACGjB,SAAS,oCAAoC,cAA6B;AAC/E,QAAM,mBAAmB,gBAAgB,CAAC;AAE1C,SAAO,oBAAoB;AAAA,IACzB,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,OAAO;AACL,aAAO,iBACJ,OAAO,CAAC,gBAAgB,YAAY,qBAAqB,EACzD;AAAA,QACC,C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AAC,6BAA6B,4BAA4B,GAAG;AAC7E,QAAI,CAAC,YAAY,aAAa,QAAQ,SAAS,GAAG,GAAG;AACnD,kBAAY,aAAa,QAAQ,KAAK,GAAG;AAAA,IAC3C;AAAA,EACF;AAMA,aAAW,OAAO,CAAC,YAAY,gCAAgC,GAAG;AAChE,QAAI,CAAC,YAAY,aAAa,QAAQ,SAAS,GAAG,GAAG;AACnD,kBAAY,aAAa,QAAQ,KAAK,GAAG;AAAA,IAC3C;AAAA,EACF;AAKA,QAAM,4BAA4B;AAAA,IAChC;AAAA,IACA;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;AAGA,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":["dirname","mkdir","readFile","writeFile","resolve","resolve","require","isRecord","resolve","createRequire","mkdir","dirname","resolve","mergeConfig","mergeConfig","resolve","mkdir","dirname","createRequire","resolve","mkdir","writeFile","readFile","dirname","resolve","fileURLToPath","build","isRecord","resolve","dirname","fileURLToPath","collectAstroStories","build","readFile","dirname"]}
1
+ {"version":3,"sources":["../src/preset.ts","../src/viteStorybookRendererFallbackPlugin.ts","../src/viteStorybookAstroRendererPlugin.ts","../src/vitePluginAstroBuildPrerender.ts","../src/vitePluginAstroBuildShared.ts","../src/productionRenderRuntime.ts","../src/storySsrVite.ts","../src/lib/hydratedComponentBuild.ts","../src/vitePluginAstro.ts","../src/lib/staticHtmlRewriting.ts","../src/vitePluginAstroBuildServer.ts","../src/vite/sanitizeConfigPlugin.ts","../src/vite/serverAuthPlugin.ts","../src/vite/serverRuntimePlugin.ts","../src/vitePluginAstroToolbarFallback.ts"],"sourcesContent":["import { dirname } from 'node:path';\nimport 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';\nimport { loadUserAstroFonts, loadUserAstroVitePlugins } from './loadUserAstroConfig.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, storybookOptions) => {\n const { configType, presets, configDir } = storybookOptions;\n const frameworkOptions = await presets.apply<FrameworkOptions>('frameworkOptions');\n const resolveFrom = frameworkOptions.resolveFrom ?? dirname(configDir);\n\n // Auto-load fonts from the user's astro.config.* when the framework option\n // is omitted entirely. An explicit empty array means \"I want no fonts\" and\n // is honored as-is.\n const fonts =\n frameworkOptions.fonts === undefined\n ? await loadUserAstroFonts(resolveFrom)\n : frameworkOptions.fonts;\n\n if (frameworkOptions.fonts === undefined && fonts.length > 0) {\n console.warn(\n `[storybook-astro] Auto-loaded ${fonts.length} font famil${fonts.length === 1 ? 'y' : 'ies'} from astro.config: ${fonts.map((f) => f.cssVariable).join(', ')}`\n );\n }\n\n const options = {\n ...frameworkOptions,\n resolveFrom,\n fonts\n } satisfies FrameworkOptions;\n\n if (!config.plugins) {\n config.plugins = [];\n }\n\n const integrations = options.integrations ?? [];\n const renderMode = options.renderMode ?? 'static';\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(\n config,\n integrations,\n options.resolveFrom,\n mode,\n command\n );\n\n // Auto-merge raw Vite plugins declared at `vite.plugins` in the user's\n // astro.config.*. This covers CSS frameworks added as Vite plugins rather\n // than Astro integrations (e.g. `@tailwindcss/vite`, `unocss/vite`) which\n // the integration auto-loader does not pick up.\n const userVitePlugins = await loadUserAstroVitePlugins(options.resolveFrom);\n\n if (userVitePlugins.length > 0) {\n const existingNames = new Set<string>();\n\n for (const plugin of (finalConfig.plugins ?? []).flat(Infinity) as Array<{ name?: string }>) {\n if (plugin && typeof plugin === 'object' && typeof plugin.name === 'string') {\n existingNames.add(plugin.name);\n }\n }\n\n const newPlugins = userVitePlugins.filter((plugin) => !existingNames.has(plugin.name));\n\n if (newPlugins.length > 0) {\n console.warn(\n `[storybook-astro] Auto-loaded ${newPlugins.length} vite plugin${newPlugins.length === 1 ? '' : 's'} from astro.config: ${newPlugins.map((p) => p.name).join(', ')}`\n );\n finalConfig.plugins = [...(finalConfig.plugins ?? []), ...newPlugins];\n }\n }\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 [\n '@astrojs/vue',\n '@astrojs/vue/client.js',\n '@astrojs/vue/server.js',\n '@astrojs/react',\n '@astrojs/react/client.js',\n '@astrojs/react/server.js',\n '@astrojs/preact',\n '@astrojs/preact/client.js',\n '@astrojs/preact/server.js'\n ]) {\n if (!finalConfig.optimizeDeps.exclude.includes(pkg)) {\n finalConfig.optimizeDeps.exclude.push(pkg);\n }\n }\n // Exclude the renderer and framework from Vite's esbuild pre-bundler.\n //\n // Renderer: import.meta.hot must be preserved so the HMR channel works.\n // When esbuild pre-bundles it, import.meta.hot is stripped and render\n // responses are never received, producing an infinite loading spinner.\n //\n // Framework: the main entry re-exports browser-safe helpers (definePreview,\n // composeStories, etc.) but also has subpath exports that depend on Vite\n // server APIs. If Vite's dep optimizer scans the package transitively it\n // can pull in createServer and other Node-only code, creating a >50k-line\n // browser bundle that causes duplicate __vite__injectQuery declarations\n // and a SyntaxError that crashes the preview iframe.\n for (const pkg of ['@storybook-astro/renderer', '@storybook-astro/framework']) {\n if (!finalConfig.optimizeDeps.exclude.includes(pkg)) {\n finalConfig.optimizeDeps.exclude.push(pkg);\n }\n }\n // fsevents is a macOS-only native chokidar dep with a .node binary that\n // esbuild's prebundler can't load. storybook/internal/preview-api can pass\n // through the transform pipeline twice when used by CSF Next portable\n // stories, producing a duplicate __vite__injectQuery import in the\n // generated chunk; excluding it from prebundling collapses the duplicate.\n for (const pkg of ['fsevents', 'storybook/internal/preview-api']) {\n if (!finalConfig.optimizeDeps.exclude.includes(pkg)) {\n finalConfig.optimizeDeps.exclude.push(pkg);\n }\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+ uses Rolldown for dependency optimization.\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","import type { Integration } from './integrations/index.ts';\nimport { createVirtualModule } from './vite/virtualModulePlugin.ts';\n\nexport function viteStorybookRendererFallbackPlugin(integrations: Integration[]) {\n const safeIntegrations = integrations ?? [];\n\n return createVirtualModule({\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 { fileURLToPath } from 'node:url';\nimport type { RenderMode, ServerBuildOptions } from './types.ts';\nimport { createVirtualModule } from './vite/virtualModulePlugin.ts';\n\nconst rendererDevModulePath = fileURLToPath(new URL('./renderer/renderer-dev.js', import.meta.url));\nconst rendererStaticModulePath = fileURLToPath(new URL('./renderer/renderer-static.js', import.meta.url));\nconst rendererServerModulePath = fileURLToPath(new URL('./renderer/renderer-server.js', import.meta.url));\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 createVirtualModule({\n pluginName,\n virtualModuleId,\n load() {\n if (!isProduction) {\n return `export * from ${JSON.stringify(normalizePath(rendererDevModulePath))};`;\n }\n\n if (isStaticMode) {\n return `export * from ${JSON.stringify(normalizePath(rendererStaticModulePath))};`;\n }\n\n return [\n `import { createServerRenderer } from ${JSON.stringify(normalizePath(rendererServerModulePath))};`,\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 'export const isStaticMode = false;'\n ].join('\\n');\n }\n });\n}\n\nfunction normalizePath(value: string) {\n return value.replace(/\\\\/g, '/');\n}\n","import { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport type { Plugin, Rollup } from 'vite';\nimport type { Integration } from './integrations/index.ts';\nimport {\n buildStaticModuleMap,\n emitHydratedComponentEntriesFromAstroFile,\n collectTrackedSpecifiers,\n emitBuildEntrypoints,\n loadVirtualBuildModule,\n resolveVirtualBuildModuleId,\n stripQuery\n} from './vitePluginAstroBuildShared.ts';\nimport {\n createProductionRenderRuntime,\n renderProductionStoryToHtml,\n type ProductionStoryEntry\n} from './productionRenderRuntime.ts';\nimport { buildHydratedComponentAssets } from './lib/hydratedComponentBuild.ts';\nimport {\n addStaticStylesheets,\n rewriteBuiltModulePaths,\n type StaticCssMap,\n type StaticModuleMap\n} from './lib/staticHtmlRewriting.ts';\nimport { resolveRulesConfigFilePath } from './rules-options.ts';\nimport type { FrameworkOptions } from './types.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\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 async resolveId(this: Rollup.PluginContext, id: string, importer?: string) {\n const importerPath = stripQuery(importer);\n\n if (importerPath?.endsWith('.astro')) {\n await emitHydratedComponentEntriesFromAstroFile({\n pluginContext: this,\n astroFilePath: importerPath,\n resolveFrom,\n componentEntrypointRefs\n });\n }\n\n return resolveVirtualBuildModuleId(id);\n },\n\n load(id: string) {\n return loadVirtualBuildModule(id);\n },\n\n async buildStart(this: Rollup.PluginContext) {\n await emitBuildEntrypoints({\n pluginContext: this,\n integrations,\n resolveFrom,\n trackedSpecifiers,\n staticEntrypointRefs\n });\n },\n\n async writeBundle(\n this: Rollup.PluginContext,\n _outputOptions: Rollup.NormalizedOutputOptions,\n bundle: Rollup.OutputBundle\n ) {\n const trackedModuleMap = buildStaticModuleMap(\n this,\n staticEntrypointRefs,\n componentEntrypointRefs\n );\n\n const astroStories = await collectAstroStories(outDir);\n\n if (astroStories.length === 0) {\n await writePrerenderedStoriesFile(outDir, {});\n\n return;\n }\n\n const storyAstroComponentPaths = Array.from(\n new Set(astroStories.map((story) => story.componentPath))\n );\n // Bundle the framework components hydrated inside Astro stories so the\n // static preview has matching JS chunks and extracted CSS for them.\n // Storybook's own iframe build skips these files when no per-framework\n // .stories.* exists, which left CSS-module styling absent from the\n // prerendered output.\n const hydratedComponentAssets = await buildHydratedComponentAssets({\n componentPaths: storyAstroComponentPaths,\n integrations,\n resolveFrom,\n outDir\n });\n const staticModuleMap: StaticModuleMap = {\n ...trackedModuleMap,\n ...hydratedComponentAssets.staticModuleMap\n };\n const staticCssMap: StaticCssMap = hydratedComponentAssets.staticCssMap;\n\n const prerenderedStories = await prerenderAstroStories({\n astroStories,\n integrations,\n sanitization: options.sanitization,\n storyRulesConfigFilePath,\n staticModuleMap,\n staticCssMap,\n trackedSpecifiers,\n resolveFrom,\n fonts: options.fonts,\n bundle\n });\n\n await writePrerenderedStoriesFile(outDir, prerenderedStories);\n }\n };\n}\n\n/** Writes the prerendered Astro story payload consumed by the static renderer. */\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\n/** Renders Astro stories during the static build and stores the HTML by story id. */\nasync function prerenderAstroStories(options: {\n astroStories: ProductionStoryEntry[];\n integrations: Integration[];\n sanitization?: FrameworkOptions['sanitization'];\n storyRulesConfigFilePath?: string;\n staticModuleMap: StaticModuleMap;\n staticCssMap: StaticCssMap;\n trackedSpecifiers: Set<string>;\n resolveFrom: string;\n fonts?: FrameworkOptions['fonts'];\n bundle: Rollup.OutputBundle;\n}) {\n const runtime = await createProductionRenderRuntime({\n integrations: options.integrations,\n sanitization: options.sanitization,\n storyRulesConfigFilePath: options.storyRulesConfigFilePath,\n staticModuleMap: options.staticModuleMap,\n trackedSpecifiers: options.trackedSpecifiers,\n resolveFrom: options.resolveFrom,\n fonts: options.fonts\n });\n const assetPathMap = buildAssetPathMap(options.bundle);\n\n try {\n const output: Record<string, string> = {};\n\n for (const story of options.astroStories) {\n const html = await renderProductionStoryToHtml({\n story,\n runtime,\n resolveFrom: options.resolveFrom\n });\n\n if (html === undefined) {\n continue;\n }\n\n // Image asset URLs from Vite SSR still point at /@fs/ paths, so rewrite\n // them first; then rewrite hydrated framework component module paths and\n // prepend their extracted CSS so the static preview matches dev styling.\n const htmlWithAssetUrls = rewriteAssetPaths(html, assetPathMap);\n const htmlWithBuiltModules = rewriteBuiltModulePaths(\n htmlWithAssetUrls,\n options.staticModuleMap\n );\n const htmlWithStylesheets = addStaticStylesheets(htmlWithBuiltModules, {\n staticModuleMap: options.staticModuleMap,\n staticCssMap: options.staticCssMap\n });\n\n output[story.id] = htmlWithStylesheets;\n }\n\n return output;\n } finally {\n await runtime.close();\n }\n}\n\n/** Reads the built Storybook index and keeps only Astro stories that can be prerendered. */\nasync function collectAstroStories(outDir: string): Promise<ProductionStoryEntry[]> {\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 // Static prerender only owns Astro stories. Framework-rendered stories stay\n // with Storybook's normal preview pipeline and are not pre-rendered here.\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 || !entry.componentPath) {\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 componentPath: entry.componentPath,\n exportName: entry.exportName,\n title: entry.title,\n name: entry.name\n };\n });\n}\n\n/** Builds lookup tables that map original asset paths to emitted static asset URLs. */\nfunction buildAssetPathMap(bundle: Rollup.OutputBundle): Map<string, string> {\n const exactMap = new Map<string, string>();\n const stemMap = new Map<string, string>();\n\n for (const chunk of Object.values(bundle)) {\n if (chunk.type !== 'asset') {\n continue;\n }\n\n const asset = chunk as Rollup.OutputAsset;\n\n if (asset.originalFileNames && asset.originalFileNames.length > 0) {\n for (const originalPath of asset.originalFileNames) {\n exactMap.set(originalPath, `/${asset.fileName}`);\n }\n }\n\n // Vite does not populate originalFileNames for image assets processed\n // through its asset pipeline. Build a secondary lookup by the filename\n // stem so /@fs/ URLs in prerendered HTML can still be mapped to their\n // content-hashed output paths. e.g. \"storybook-astro-CfMmZdup.png\" ⟶\n // stem key \"storybook-astro.png\" ⟶ \"/_astro/storybook-astro-CfMmZdup.png\".\n const baseName = asset.fileName.split('/').pop() ?? '';\n const stemMatch = baseName.match(/^(.+)-[A-Za-z0-9]{6,12}\\.(png|jpe?g|gif|webp|svg|avif|ico)$/);\n\n if (stemMatch) {\n stemMap.set(`${stemMatch[1]}.${stemMatch[2]}`, `/${asset.fileName}`);\n }\n }\n\n return { exactMap, stemMap } as unknown as Map<string, string>;\n}\n\n/** Rewrites dev-only /@fs/ asset URLs in prerendered HTML to emitted build asset paths. */\nfunction rewriteAssetPaths(\n html: string,\n assetPathMap: ReturnType<typeof buildAssetPathMap>\n): string {\n const { exactMap, stemMap } = assetPathMap as unknown as {\n exactMap: Map<string, string>;\n stemMap: Map<string, string>;\n };\n\n if (exactMap.size === 0 && stemMap.size === 0) {\n return html;\n }\n\n // Prerendering happens through a Vite SSR server, so image/style URLs can\n // still point at dev-only /@fs/ paths. Rewrite them to the emitted assets.\n return html.replace(/\\/@fs\\/[^\"']+/g, (match) => {\n const pathOnly = match.replace(/\\?.*$/, '');\n const fsPath = pathOnly.slice('/@fs'.length);\n // Handle /@fs//abs/path (double leading slash on Unix)\n const absolutePath = fsPath.startsWith('//') ? fsPath.slice(1) : fsPath;\n\n // Try exact match by originalFileNames first\n const exact = exactMap.get(absolutePath);\n\n if (exact) {\n return exact;\n }\n\n // Fall back to stem-based matching for image assets whose\n // originalFileNames are empty (standard Vite asset pipeline behaviour).\n const baseName = absolutePath.split('/').pop() ?? '';\n const stemHit = stemMap.get(baseName);\n\n if (stemHit) {\n return stemHit;\n }\n\n return match;\n });\n}\n","import { createHash } from 'node:crypto';\nimport { access, copyFile, mkdir, readFile, readdir, stat } from 'node:fs/promises';\nimport { dirname, resolve } from 'node:path';\nimport type { Rollup } from 'vite';\nimport type { Integration } from './integrations/index.ts';\nimport { resolveAliasedIsland } from './lib/resolve-aliased-island.ts';\n\n/** Resolves the shared virtual module ids used by both build pipelines. */\nexport function resolveVirtualBuildModuleId(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/** Loads the virtual modules that stand in for tracked runtime and component entrypoints. */\nexport function loadVirtualBuildModule(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 }\n\n return [`import '${specifier}';`, 'export default undefined;'].join('\\n');\n }\n\n if (id.startsWith('\\0virtual:astro-component-module/')) {\n const withoutPrefix = id.replace('\\0virtual:astro-component-module/', '');\n const encodedSpecifier = withoutPrefix.replace(/\\?.*$/, '');\n const specifier = decodeURIComponent(encodedSpecifier);\n\n return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join('\\n');\n }\n}\n\n/** Emits build entrypoints for framework client runtimes that Astro stories may reference. */\nexport async function emitBuildEntrypoints(options: {\n pluginContext: Rollup.PluginContext;\n integrations: Integration[];\n resolveFrom: string;\n trackedSpecifiers: Set<string>;\n staticEntrypointRefs: Map<string, string>;\n}) {\n const { pluginContext, integrations, resolveFrom } = options;\n\n // Keep framework client entrypoints in the build so Astro islands can\n // still hydrate after the preview iframe switches to built assets.\n integrations.forEach((integration) => {\n const entrypoint = integration.renderer.client?.entrypoint;\n\n if (entrypoint) {\n pluginContext.addWatchFile(entrypoint);\n }\n });\n\n options.trackedSpecifiers.forEach((specifier) => {\n const fileReferenceId = pluginContext.emitFile({\n type: 'chunk',\n id: toStaticVirtualId(specifier),\n name: createEntrypointName(resolveFrom, specifier)\n });\n\n options.staticEntrypointRefs.set(specifier, fileReferenceId);\n });\n}\n\n/** Emits framework component entry chunks for one Astro component file used in the build graph. */\nexport async function emitHydratedComponentEntriesFromAstroFile(options: {\n pluginContext: Rollup.PluginContext;\n astroFilePath: string;\n resolveFrom: string;\n componentEntrypointRefs: Map<string, string>;\n}) {\n const hydratedComponentPaths = await collectHydratedComponentPaths(\n options.astroFilePath,\n options.resolveFrom\n );\n\n for (const resolvedImportPath of hydratedComponentPaths) {\n\n if (options.componentEntrypointRefs.has(resolvedImportPath)) {\n continue;\n }\n\n const fileReferenceId = options.pluginContext.emitFile({\n type: 'chunk',\n id: toComponentChunkId(resolvedImportPath),\n name: createEntrypointName(options.resolveFrom, resolvedImportPath)\n });\n\n options.componentEntrypointRefs.set(resolvedImportPath, fileReferenceId);\n }\n}\n\n/** Collects the framework component files one Astro component hydrates in the browser. */\nexport async function collectHydratedComponentPaths(astroFilePath: string, resolveFrom: string) {\n // Only Astro components create islands, so only their framework imports\n // need standalone client chunks in built Storybook output.\n const allImportSpecifiers = await readAllImportSpecifiers(astroFilePath);\n const hydratedComponentPaths: string[] = [];\n\n for (const specifier of allImportSpecifiers) {\n // Resolve the specifier to an on-disk path — relative imports use the\n // importer's directory; aliased imports go through the tsconfig paths map.\n const resolvedImportPath = specifier.startsWith('.')\n ? await resolveLocalImportPath(astroFilePath, specifier)\n : await resolveAliasedIsland(specifier, resolveFrom);\n\n if (!resolvedImportPath) {\n continue;\n }\n\n if (\n !isHydratableSourceFile(resolvedImportPath) ||\n isNonHydratableSourceFile(resolvedImportPath)\n ) {\n continue;\n }\n\n // Only .jsx/.tsx files go through toComponentVirtualId, which emits\n // `export { default } from '<file>'`. A file with no default export\n // crashes Rollup with '\"default\" is not exported'. Svelte/Vue SFCs are\n // passed directly to their compilers, which generate the default export —\n // checking their source for a literal `export default` would falsely\n // exclude them.\n if (/\\.(jsx|tsx)$/.test(resolvedImportPath) && !(await hasDefaultExport(resolvedImportPath))) {\n continue;\n }\n\n hydratedComponentPaths.push(resolvedImportPath);\n }\n\n return hydratedComponentPaths;\n}\n\n/** Collects framework client runtimes that must stay addressable after the preview is built. */\nexport function collectTrackedSpecifiers(integrations: Integration[]) {\n const specifiers = new Set<string>([\n 'astro:scripts/page.js',\n 'astro:scripts/before-hydration.js'\n ]);\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\n/** Builds the browser module map used to rewrite source specifiers to built asset URLs. */\nexport function 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\n/** Normalizes one emitted file name to the relative public path used in built HTML. */\nexport function toPublicPath(fileName: string) {\n return `./${fileName}`;\n}\n\nexport function stripQuery(input: string | undefined) {\n return input?.replace(/\\?.*$/, '');\n}\n\n/** Converts a project file path into the stable path used inside the snapshot tree. */\nexport function relativePathFromRoot(resolveFrom: string, filePath: string) {\n return filePath.slice(resolveFrom.length).replace(/^[/\\\\]+/, '');\n}\n\n/** Copies one file or directory tree into the standalone runtime snapshot. */\nexport async function copyPath(sourcePath: string, targetPath: string): Promise<void> {\n const sourceStats = await stat(sourcePath);\n\n if (sourceStats.isDirectory()) {\n await mkdir(targetPath, { recursive: true });\n const entries = await readdir(sourcePath, { withFileTypes: true });\n\n await Promise.all(\n entries.map((entry) =>\n copyPath(resolve(sourcePath, entry.name), resolve(targetPath, entry.name))\n )\n );\n\n return;\n }\n\n await mkdir(dirname(targetPath), { recursive: true });\n await copyFile(sourcePath, targetPath);\n}\n\n/** Maps an original source file path to its location inside the snapshot tree. */\nexport function buildSnapshotFilePath(\n resolveFrom: string,\n filePath: string,\n snapshotDirName: string\n) {\n const normalizedResolveFrom = resolveFrom.replace(/\\\\/g, '/').replace(/\\/$/, '');\n const normalizedFilePath = filePath.replace(/\\\\/g, '/');\n\n if (normalizedFilePath.startsWith(`${normalizedResolveFrom}/`)) {\n return `${snapshotDirName}/${relativePathFromRoot(resolveFrom, filePath)}`.replace(/\\\\/g, '/');\n }\n\n return `${snapshotDirName}/__external/${normalizedFilePath.replace(/^[/\\\\]+/, '')}`.replace(\n /\\\\/g,\n '/'\n );\n}\n\n/** Copies the source files and config files the standalone render server needs at runtime. */\nexport async function copyRuntimeSnapshot(options: {\n resolveFrom: string;\n snapshotRoot: string;\n snapshotDirName: string;\n astroComponents: string[];\n storyRulesConfigFilePath?: string;\n}) {\n // The standalone render server still spins up a Vite SSR runtime, so it\n // needs the exact source/config files that runtime will read from disk.\n const runtimeInputFiles = new Set<string>([\n ...options.astroComponents,\n ...(options.storyRulesConfigFilePath ? [options.storyRulesConfigFilePath] : []),\n ...(await listRuntimeConfigFiles(options.resolveFrom))\n ]);\n const copiedFiles = new Set<string>();\n\n for (const runtimeInputFile of runtimeInputFiles) {\n await copyLocalRuntimeDependencies(runtimeInputFile, options, copiedFiles);\n }\n}\n\n/** Reports whether a JS/TS source file has a default export.\n * Only call for .jsx/.tsx — Svelte and Vue SFCs have no literal `export default`\n * in source, but their compilers generate one. On read error the file is kept,\n * preserving prior behaviour rather than silently dropping a component.\n *\n * The regex scan is intentionally conservative: it can match inside comments\n * or string literals, which produces a false-positive (file kept, Rollup crashes\n * as before) rather than a false-negative (file silently dropped). */\nasync function hasDefaultExport(absPath: string) {\n try {\n const source = await readFile(absPath, 'utf-8');\n\n return /export\\s+default\\b/.test(source) || /export\\s*\\{[^}]*\\bdefault\\b/.test(source);\n } catch {\n return true;\n }\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)}?component-wrapper`;\n}\n\nfunction toComponentChunkId(specifier: string) {\n return /\\.(svelte|vue)$/.test(specifier) ? specifier : toComponentVirtualId(specifier);\n}\n\nfunction createEntrypointName(resolveFrom: string, specifier: string) {\n const normalizedResolveFrom = resolveFrom.replace(/\\\\/g, '/');\n const normalizedSpecifier = specifier.replace(/\\\\/g, '/');\n const relativeName = normalizedSpecifier.startsWith(`${normalizedResolveFrom}/`)\n ? normalizedSpecifier.slice(normalizedResolveFrom.length + 1)\n : normalizedSpecifier.split('/').slice(-2).join('/');\n const sanitizedName = relativeName.replace(/[^a-zA-Z0-9/_-]/g, '_').replace(/_+/g, '_');\n const hash = createHash('sha1').update(normalizedSpecifier).digest('hex').slice(0, 8);\n\n return `${sanitizedName}-${hash}`;\n}\n\nfunction isClientEntrypoint(specifier: string) {\n return specifier.startsWith('@astrojs/') && specifier.endsWith('/client.js');\n}\n\nfunction isHydratableSourceFile(input: string) {\n return /\\.(jsx|tsx|vue|svelte)$/.test(input);\n}\n\nfunction isNonHydratableSourceFile(input: string) {\n return /\\.stories\\.[jt]sx?$|\\.stories\\.vue$|\\.stories\\.svelte$|\\.(spec|test)\\.[jt]sx?$/.test(\n input\n );\n}\n\n/** Finds project config files that the standalone render server may load through Vite. */\nasync function listRuntimeConfigFiles(resolveFrom: string) {\n const candidates = [\n 'package.json',\n 'tsconfig.json',\n 'tsconfig.base.json',\n 'jsconfig.json',\n 'astro.config.mjs',\n 'astro.config.js',\n 'astro.config.ts',\n 'vite.config.js',\n 'vite.config.ts',\n 'svelte.config.js'\n ];\n const existing: string[] = [];\n\n await Promise.all(\n candidates.map(async (candidate) => {\n const filePath = resolve(resolveFrom, candidate);\n\n try {\n await access(filePath);\n existing.push(filePath);\n } catch {\n return;\n }\n })\n );\n\n return existing;\n}\n\n/** Copies one local source file and follows its local imports into the snapshot. */\nasync function copyLocalRuntimeDependencies(\n sourcePath: string,\n options: {\n resolveFrom: string;\n snapshotRoot: string;\n snapshotDirName: string;\n },\n copiedFiles: Set<string>\n) {\n const normalizedSourcePath = sourcePath.replace(/\\\\/g, '/');\n\n if (copiedFiles.has(normalizedSourcePath)) {\n return;\n }\n\n copiedFiles.add(normalizedSourcePath);\n\n const snapshotRelativePath = buildSnapshotFilePath(\n options.resolveFrom,\n normalizedSourcePath,\n options.snapshotDirName\n );\n\n await copyPath(\n normalizedSourcePath,\n resolve(dirname(options.snapshotRoot), snapshotRelativePath)\n );\n\n // Follow only local imports here. Package dependencies stay external and are\n // resolved by Node/Vite from the deployed install, not copied into snapshot.\n const localImportSpecifiers = await readLocalImportSpecifiers(normalizedSourcePath);\n\n for (const specifier of localImportSpecifiers) {\n const resolvedDependency = await resolveLocalImportPath(normalizedSourcePath, specifier);\n\n if (!resolvedDependency) {\n continue;\n }\n\n await copyLocalRuntimeDependencies(resolvedDependency, options, copiedFiles);\n }\n}\n\nconst IMPORT_RE =\n /(?:import|export)\\s+(?:[^'\"`]*?\\s+from\\s+)?['\"`]([^'\"`]+)['\"`]|import\\(\\s*['\"`]([^'\"`]+)['\"`]\\s*\\)/g;\n\n/** Returns all import specifiers found in the file (relative, aliased, and package). */\nasync function readAllImportSpecifiers(filePath: string): Promise<string[]> {\n if (!/\\.(astro|[cm]?[jt]sx?|vue|svelte)$/.test(filePath)) {\n return [];\n }\n\n const source = await readFile(filePath, 'utf-8');\n\n return Array.from(source.matchAll(IMPORT_RE), (match) => match[1] ?? match[2]).filter(\n (specifier): specifier is string => Boolean(specifier)\n );\n}\n\n/** Reads local (relative) import specifiers from source files that can participate in the SSR runtime. */\nasync function readLocalImportSpecifiers(filePath: string) {\n return (await readAllImportSpecifiers(filePath)).filter((s) => s.startsWith('.'));\n}\n\n/** Resolves one relative import the same way the project source tree would on disk. */\nasync function resolveLocalImportPath(importerPath: string, specifier: string) {\n const basePath = resolve(dirname(importerPath), specifier);\n const candidates = [\n basePath,\n `${basePath}.ts`,\n `${basePath}.tsx`,\n `${basePath}.js`,\n `${basePath}.jsx`,\n `${basePath}.mjs`,\n `${basePath}.cjs`,\n `${basePath}.astro`,\n `${basePath}.vue`,\n `${basePath}.svelte`,\n resolve(basePath, 'index.ts'),\n resolve(basePath, 'index.tsx'),\n resolve(basePath, 'index.js'),\n resolve(basePath, 'index.jsx'),\n resolve(basePath, 'index.mjs'),\n resolve(basePath, 'index.cjs'),\n resolve(basePath, 'index.astro'),\n resolve(basePath, 'index.vue'),\n resolve(basePath, 'index.svelte')\n ];\n\n for (const candidate of candidates) {\n try {\n const candidateStats = await stat(candidate);\n\n if (candidateStats.isFile()) {\n return candidate.replace(/\\\\/g, '/');\n }\n } catch {\n continue;\n }\n }\n\n return undefined;\n}\n","import { resolve } from 'node:path';\nimport { createAstroRenderHandler, type HandlerProps } from './astroRenderHandler.ts';\nimport type { Integration } from './integrations/index.ts';\nimport type { SanitizationOptions } from './lib/sanitization.ts';\nimport type { FrameworkOptions } from './types.ts';\nimport {\n createClientModuleResolver,\n createProductionAstroContainer,\n createStorySsrViteServer,\n loadRulesConfigModule\n} from './storySsrVite.ts';\n\ntype LoadedStoryModule = Record<string, unknown>;\n\nexport type ProductionRenderRuntime = {\n loadModule: (moduleId: string) => Promise<LoadedStoryModule>;\n renderAstroStory: (data: HandlerProps) => Promise<string>;\n close: () => Promise<void>;\n};\n\nexport type ProductionStoryEntry = {\n id: string;\n importPath: string;\n componentPath: string;\n exportName: string;\n title?: string;\n name?: string;\n};\n\ntype ProductionRenderRuntimeOptions = {\n integrations: Integration[];\n sanitization?: SanitizationOptions;\n storyRulesConfigFilePath?: string;\n staticModuleMap: Record<string, string>;\n trackedSpecifiers: Set<string>;\n resolveFrom: string;\n resolveComponentId?: (id: string) => string;\n fonts?: FrameworkOptions['fonts'];\n};\n\n/** Creates the shared SSR runtime used by both build-time prerendering and the standalone render server. */\nexport async function createProductionRenderRuntime(\n options: ProductionRenderRuntimeOptions\n): Promise<ProductionRenderRuntime> {\n const viteServer = await createStorySsrViteServer({\n integrations: options.integrations,\n trackedSpecifiers: options.trackedSpecifiers,\n resolveFrom: options.resolveFrom,\n fonts: options.fonts\n });\n\n try {\n const rulesConfigModule = await loadRulesConfigModule(\n viteServer,\n options.storyRulesConfigFilePath\n );\n const resolveClientModule = createClientModuleResolver(\n options.integrations,\n options.staticModuleMap\n );\n const astroContainer = await createProductionAstroContainer({\n integrations: options.integrations,\n resolveClientModule,\n viteServer,\n resolveFrom: options.resolveFrom\n });\n\n const loadModule = async (moduleId: string) => {\n return (await viteServer.ssrLoadModule(\n options.resolveComponentId?.(moduleId) ?? moduleId\n )) as LoadedStoryModule;\n };\n const renderAstroStory = createAstroRenderHandler({\n container: astroContainer,\n sanitization: options.sanitization,\n rulesConfigFilePath: options.storyRulesConfigFilePath,\n resolveRulesConfigModule: () => rulesConfigModule,\n loadModule: async (moduleId: string) => {\n const loadedModule = await loadModule(moduleId);\n\n return {\n default: loadedModule.default\n };\n },\n invalidateModuleGraph: () => {\n viteServer.moduleGraph.invalidateAll();\n }\n });\n\n return {\n loadModule,\n renderAstroStory,\n close: () => viteServer.close()\n };\n } catch (error) {\n await viteServer.close();\n throw error;\n }\n}\n\n/** Loads one Astro story module, merges its args, and renders the Astro component to HTML. */\nexport async function renderProductionStoryToHtml(options: {\n story: ProductionStoryEntry;\n runtime: ProductionRenderRuntime;\n resolveFrom: string;\n}) {\n const storyModulePath = resolveProjectImportPath(options.story.importPath, options.resolveFrom);\n const componentPath = resolveProjectImportPath(options.story.componentPath, options.resolveFrom);\n const storyModule = await options.runtime.loadModule(storyModulePath);\n const defaultStoryMeta = isRecord(storyModule.default) ? storyModule.default : {};\n const selectedStoryExport = isRecord(storyModule[options.story.exportName])\n ? storyModule[options.story.exportName]\n : {};\n\n if (typeof defaultStoryMeta.component !== 'function') {\n throw new Error(\n `Unable to prerender story \"${options.story.id}\". Missing default export component in ${options.story.importPath}.`\n );\n }\n\n // Build-time prerender only supports stories that keep the meta-level Astro component.\n if (selectedStoryExport.component && selectedStoryExport.component !== defaultStoryMeta.component) {\n return undefined;\n }\n\n const storyArgs = mergeMetaArgsWithStoryArgs(\n toRecord(defaultStoryMeta.args),\n toRecord(selectedStoryExport.args)\n );\n const { componentArgs, storySlots } = separateStorySlots(storyArgs);\n\n return options.runtime.renderAstroStory({\n component: componentPath,\n args: componentArgs,\n slots: storySlots,\n story: {\n id: options.story.id,\n title: options.story.title,\n name: options.story.name\n }\n });\n}\n\nfunction resolveProjectImportPath(importPath: string, resolveFrom: string) {\n if (importPath.startsWith('./') || importPath.startsWith('../')) {\n return resolve(resolveFrom, importPath);\n }\n\n return importPath;\n}\n\nfunction mergeMetaArgsWithStoryArgs(\n metaArgs: Record<string, unknown> | undefined,\n storyArgs: Record<string, unknown> | undefined\n) {\n return {\n ...(metaArgs ?? {}),\n ...(storyArgs ?? {})\n };\n}\n\nfunction separateStorySlots(storyArgs: Record<string, unknown>) {\n const componentArgs = { ...storyArgs };\n const storySlots = componentArgs.slots;\n\n delete componentArgs.slots;\n\n if (!isRecord(storySlots)) {\n return {\n componentArgs,\n storySlots: {}\n };\n }\n\n return {\n componentArgs,\n storySlots: storySlots as Record<string, string>\n };\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","import { createRequire } from 'node:module';\nimport { createServer, mergeConfig, type Plugin, type ViteDevServer } from 'vite';\nimport type { experimental_AstroContainer as AstroContainer } from 'astro/container';\nimport { ensureAstroPassthroughImageService } from './astroImageService.ts';\nimport { importAstroConfig } from './importAstroConfig.ts';\nimport type { Integration } from './integrations/index.ts';\nimport { resolveAliasedIsland } from './lib/resolve-aliased-island.ts';\nimport { ssrLoadModuleWithFsFallback } from './lib/ssr-load-module-with-fs-fallback.ts';\nimport { resolveStoryModuleMock } from './module-mocks.ts';\nimport type { FrameworkOptions } from './types.ts';\nimport { vitePluginAstroFonts } from './vitePluginAstroFonts.ts';\nimport { vitePluginAstroIntegrationOptsFallback } from './vitePluginAstroIntegrationOptsFallback.ts';\nimport { vitePluginAstroRoutesFallback } from './vitePluginAstroRoutesFallback.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\nimport { vitePluginStoryModuleMocks } from './vitePluginStoryModuleMocks.ts';\n\nexport async function createStorySsrViteServer(options: {\n integrations: Integration[];\n trackedSpecifiers: Set<string>;\n resolveFrom: string;\n fonts?: FrameworkOptions['fonts'];\n}) {\n const { getViteConfig, passthroughImageService } = await importAstroConfig(options.resolveFrom);\n const astroConfig = await getViteConfig(\n { root: options.resolveFrom },\n {\n configFile: false,\n integrations: await Promise.all(\n options.integrations.map((integration) => integration.loadIntegration(options.resolveFrom))\n ),\n image: { service: passthroughImageService() }\n }\n )({\n mode: 'production',\n command: 'serve'\n });\n\n const config = mergeConfig(astroConfig, {\n appType: 'custom',\n server: {\n middlewareMode: true\n },\n ssr: {\n // Keep Astro runtime classes in the Vite SSR graph so containers and\n // components share SlotString/HTMLString instances during prerendering.\n noExternal: /^astro(\\/.+)?$/\n },\n plugins: [\n createProjectAstroResolutionPlugin(options.resolveFrom),\n vitePluginAstroFonts({ fonts: options.fonts, root: options.resolveFrom }),\n vitePluginAstroIntegrationOptsFallback(),\n vitePluginAstroVueFallback(),\n vitePluginAstroRoutesFallback(),\n vitePluginStoryModuleMocks(),\n createTrackedSpecifierStubPlugin(options.trackedSpecifiers)\n ]\n });\n\n const viteServer = await createServer(config);\n\n await viteServer.pluginContainer.buildStart({});\n\n return viteServer;\n}\n\nexport async function loadRulesConfigModule(viteServer: ViteDevServer, configFilePath?: string) {\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\nexport function 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\nexport async function createProductionAstroContainer(options: {\n integrations: Integration[];\n resolveClientModule: (specifier: string) => string | undefined;\n viteServer: ViteDevServer;\n resolveFrom: string;\n}) {\n ensureAstroPassthroughImageService();\n\n // Astro 6's container wraps each slot value in a SlotString, and the\n // rendering pipeline detects raw-HTML slot chunks via `instanceof SlotString`.\n // If the container is loaded by Node's ESM resolver while components are\n // loaded through Vite's SSR graph, the two paths produce different\n // SlotString classes and the instanceof check fails — slot content then\n // takes the escaping code path. Loading the container via the same Vite\n // SSR server keeps the class identity consistent.\n const containerModule = (await options.viteServer.ssrLoadModule('astro/container')) as {\n experimental_AstroContainer: typeof AstroContainer;\n };\n const ViteAstroContainer = containerModule.experimental_AstroContainer;\n\n const container = await ViteAstroContainer.create({\n resolve: async (specifier) => {\n const mockedModule = resolveStoryModuleMock(specifier);\n\n if (mockedModule) {\n return mockedModule;\n }\n\n const resolution = options.resolveClientModule(specifier);\n\n if (resolution) {\n return resolution;\n }\n\n // Last resort: an island imported via a tsconfig path alias (e.g. `@/...`)\n // never matches the static map under its raw specifier. Resolve the alias\n // to an on-disk path and look that up in the built module map instead.\n const abs = await resolveAliasedIsland(specifier, options.resolveFrom);\n\n if (abs) {\n return options.resolveClientModule(abs) ?? specifier;\n }\n\n return specifier;\n }\n });\n\n await addContainerRenderers(\n container,\n options.integrations,\n options.resolveClientModule,\n options.viteServer\n );\n\n return container;\n}\n\nexport async function addContainerRenderers(\n container: Awaited<ReturnType<typeof AstroContainer.create>>,\n integrations: Integration[],\n resolveClientModule: (specifier: string) => string | undefined,\n viteServer: ViteDevServer\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 never\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 createProjectAstroResolutionPlugin(resolveFrom: string): Plugin {\n const require = createRequire(import.meta.url);\n\n return {\n name: 'storybook-astro:resolve-project-astro-shared',\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 } satisfies Plugin;\n}\n\nfunction createTrackedSpecifierStubPlugin(trackedSpecifiers: Set<string>): Plugin {\n return {\n name: 'storybook-astro:shared-ssr-stubs',\n resolveId(id: string) {\n if (trackedSpecifiers.has(id)) {\n return `\\0storybook-astro-shared-ssr-stub:${encodeURIComponent(id)}`;\n }\n\n return null;\n },\n load(id: string) {\n if (id.startsWith('\\0storybook-astro-shared-ssr-stub:')) {\n return 'export default undefined;';\n }\n\n return null;\n }\n } satisfies Plugin;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n","import { createRequire } from 'node:module';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { build, type Rollup } from 'vite';\nimport type { Integration } from '../integrations/index.ts';\nimport { mergeWithAstroConfig } from '../vitePluginAstro.ts';\nimport { collectHydratedComponentPaths } from '../vitePluginAstroBuildShared.ts';\nimport type { StaticCssMap, StaticModuleMap } from './staticHtmlRewriting.ts';\n\nexport type HydratedComponentAssets = {\n staticModuleMap: StaticModuleMap;\n staticCssMap: StaticCssMap;\n};\n\nexport type BuildHydratedComponentAssetsOptions = {\n componentPaths: string[];\n integrations: Integration[];\n resolveFrom: string;\n outDir: string;\n};\n\n/**\n * Bundles the framework components hydrated inside Astro stories into the static\n * output directory and returns the path/CSS lookups needed to rewrite rendered HTML.\n *\n * Storybook's main Vite build does not include these framework files unless they\n * are imported directly by a `.stories.*` file. Astro stories typically import\n * only the `.astro` wrapper (which gets replaced by a client stub), so without\n * this step their `client:load` islands have no built JS chunk and no extracted\n * CSS — leading to unstyled, unhydrated previews in the static build.\n *\n * Component paths may be absolute filesystem paths, paths relative to `resolveFrom`,\n * or bare package specifiers (e.g. `@my-pkg/components/Foo.astro`). All three are\n * normalized to absolute filesystem paths before reading sources from disk.\n */\nexport async function buildHydratedComponentAssets(\n options: BuildHydratedComponentAssetsOptions\n): Promise<HydratedComponentAssets> {\n const resolveSpecifier = createSpecifierResolver(options.resolveFrom);\n const resolvedComponentPaths = options.componentPaths\n .map(resolveSpecifier)\n .filter((path): path is string => Boolean(path));\n const hydratedComponentPaths = Array.from(\n new Set(\n (\n await Promise.all(\n resolvedComponentPaths.map((componentPath) =>\n collectHydratedComponentPaths(componentPath)\n )\n )\n ).flat()\n )\n );\n\n if (hydratedComponentPaths.length === 0) {\n return { staticModuleMap: {}, staticCssMap: {} };\n }\n\n const clientEntrypoints = Array.from(\n new Set(\n options.integrations\n .map((integration) => integration.renderer.client?.entrypoint)\n .filter((entrypoint): entrypoint is string => Boolean(entrypoint))\n )\n );\n const entryNames = Object.fromEntries([\n ...hydratedComponentPaths.map((componentPath, index) => [`component-${index}`, componentPath]),\n ...clientEntrypoints.map((entrypoint, index) => [`renderer-${index}`, entrypoint])\n ]);\n const buildConfig = {\n root: options.resolveFrom,\n build: {\n write: false,\n outDir: options.outDir,\n emptyOutDir: false,\n manifest: false,\n rollupOptions: {\n input: entryNames,\n preserveEntrySignatures: 'strict',\n output: {\n entryFileNames: '_astro/[name]-[hash].js',\n chunkFileNames: '_astro/[name]-[hash].js',\n assetFileNames: '_astro/[name]-[hash][extname]'\n }\n }\n }\n };\n const finalConfig = await mergeWithAstroConfig(\n buildConfig,\n options.integrations,\n options.resolveFrom,\n 'production',\n 'build'\n );\n const buildOutput = await build(finalConfig);\n const output = Array.isArray(buildOutput)\n ? buildOutput.flatMap((result) => result.output)\n : buildOutput.output;\n const chunksByFileName = new Map<string, Rollup.OutputChunk>();\n\n for (const item of output) {\n await writeBuildOutputFile(options.outDir, item);\n\n if (item.type === 'chunk') {\n chunksByFileName.set(item.fileName, item);\n }\n }\n\n const staticModuleMap: StaticModuleMap = {};\n const staticCssMap: StaticCssMap = {};\n\n for (const item of output) {\n if (item.type !== 'chunk' || !item.facadeModuleId) {\n continue;\n }\n\n const normalizedFacadeId = item.facadeModuleId.replace(/\\\\/g, '/');\n const originalInputSpecifier = entryNames[item.name];\n\n staticModuleMap[normalizedFacadeId] = `./${item.fileName}`;\n\n if (originalInputSpecifier && originalInputSpecifier !== normalizedFacadeId) {\n staticModuleMap[originalInputSpecifier] = `./${item.fileName}`;\n }\n\n // CSS Modules and other shared stylesheets get hoisted into shared chunks\n // when multiple entries reference them. The entry chunk's own importedCss\n // does not list those, so walk transitively through `imports` to find every\n // stylesheet the browser must load alongside this hydrated component.\n const importedCss = collectTransitiveImportedCss(item, chunksByFileName);\n\n if (importedCss.length > 0) {\n const cssPaths = importedCss.map((fileName) => `./${fileName}`);\n\n staticCssMap[normalizedFacadeId] = cssPaths;\n\n if (originalInputSpecifier && originalInputSpecifier !== normalizedFacadeId) {\n staticCssMap[originalInputSpecifier] = cssPaths;\n }\n }\n }\n\n return { staticModuleMap, staticCssMap };\n}\n\n/** Collects every CSS file reachable from the chunk through its transitive JS imports. */\nfunction collectTransitiveImportedCss(\n entry: Rollup.OutputChunk,\n chunksByFileName: Map<string, Rollup.OutputChunk>\n): string[] {\n const visited = new Set<string>();\n const css = new Set<string>();\n const queue: Rollup.OutputChunk[] = [entry];\n\n while (queue.length > 0) {\n const chunk = queue.shift();\n\n if (!chunk || visited.has(chunk.fileName)) {\n continue;\n }\n\n visited.add(chunk.fileName);\n\n for (const file of chunk.viteMetadata?.importedCss ?? new Set<string>()) {\n css.add(file);\n }\n\n for (const importedFileName of chunk.imports ?? []) {\n const next = chunksByFileName.get(importedFileName);\n\n if (next) {\n queue.push(next);\n }\n }\n }\n\n return Array.from(css);\n}\n\nasync function writeBuildOutputFile(outDir: string, item: Rollup.OutputAsset | Rollup.OutputChunk) {\n const outputPath = resolve(outDir, item.fileName);\n\n await mkdir(dirname(outputPath), { recursive: true });\n\n if (item.type === 'asset') {\n await writeFile(outputPath, item.source);\n\n return;\n }\n\n await writeFile(outputPath, item.code);\n}\n\n/** Resolves Storybook story `componentPath` values (absolute, relative, or bare specifier) to absolute paths. */\nfunction createSpecifierResolver(resolveFrom: string) {\n // createRequire needs a real filename in `resolveFrom`; package.json works\n // even when it does not exist (require.resolve only reads it to find roots).\n const require_ = createRequire(pathToFileURL(resolve(resolveFrom, 'package.json')));\n\n return (componentPath: string): string | undefined => {\n if (isAbsolute(componentPath)) {\n return componentPath;\n }\n\n if (componentPath.startsWith('./') || componentPath.startsWith('../')) {\n return resolve(resolveFrom, componentPath);\n }\n\n try {\n return require_.resolve(componentPath);\n } catch {\n return undefined;\n }\n };\n}\n","import { mergeConfig, type InlineConfig } from 'vite';\nimport type { Integration } from './integrations/index.ts';\nimport { importAstroConfig } from './importAstroConfig.ts';\nimport { loadUserAstroIntegrations } from './loadUserAstroConfig.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 frameworkIntegrations = await Promise.all(\n safeIntegrations.map((integration) => integration.loadIntegration(resolveFrom))\n );\n\n const userIntegrations = await loadUserAstroIntegrations(resolveFrom);\n const frameworkNames = new Set(frameworkIntegrations.map(i => i.name));\n const extraIntegrations = userIntegrations.filter(i => !frameworkNames.has(i.name));\n\n const astroConfig = await getViteConfig(\n {},\n {\n configFile: false,\n integrations: [...frameworkIntegrations, ...extraIntegrations]\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","/**\n * Shared helpers used by both the static prerender build and the standalone\n * render server to turn dev-server rendered Astro HTML into production output.\n *\n * Both pipelines render Astro stories through a Vite SSR runtime, which leaves\n * source-tree module paths (e.g. `/abs/path/Component.jsx`) inside emitted\n * markup such as `<astro-island component-url=\"...\">`. The browser receives\n * built chunks at hashed `/_astro/*` URLs, so the source paths must be\n * rewritten before the HTML is served. Hydrated framework component chunks\n * also have their CSS extracted at build time — without an explicit `<link>`\n * tag, those styles never reach the page.\n */\n\nexport type StaticModuleMap = Record<string, string>;\nexport type StaticCssMap = Record<string, string[]>;\n\n/** Rewrites every reference to a source module path in the rendered HTML to its built-asset URL. */\nexport function rewriteBuiltModulePaths(html: string, staticModuleMap: StaticModuleMap): string {\n let output = html;\n const entries = Object.entries(staticModuleMap).sort(\n ([left], [right]) => right.length - left.length\n );\n\n for (const [sourcePath, builtPath] of entries) {\n // Replace the /@fs/-prefixed form first so the bare-path replace below\n // can't truncate it and leave a stray \"/@fs\" stub in the output.\n output = output.split(toFsPath(sourcePath)).join(builtPath);\n output = output.split(sourcePath).join(builtPath);\n }\n\n return output;\n}\n\n/** Prepends stylesheet links for any built framework chunks referenced by the rendered HTML. */\nexport function addStaticStylesheets(\n html: string,\n options: { staticModuleMap: StaticModuleMap; staticCssMap: StaticCssMap }\n): string {\n const stylesheets = new Set<string>();\n\n for (const [sourcePath, cssPaths] of Object.entries(options.staticCssMap)) {\n const builtModulePath = options.staticModuleMap[sourcePath];\n\n // Match either the original source path or the rewritten built module URL.\n if (!html.includes(sourcePath) && (!builtModulePath || !html.includes(builtModulePath))) {\n continue;\n }\n\n cssPaths.forEach((cssPath) => stylesheets.add(cssPath));\n }\n\n if (stylesheets.size === 0) {\n return html;\n }\n\n const stylesheetTags = Array.from(stylesheets)\n .map((href) => `<link rel=\"stylesheet\" href=\"${href}\">`)\n .join('');\n\n return `${stylesheetTags}${html}`;\n}\n\n/** Converts one source file path into the Vite /@fs/ URL form used during SSR. */\nfunction toFsPath(sourcePath: string) {\n const normalizedPath = sourcePath.replace(/\\\\/g, '/');\n\n return normalizedPath.startsWith('/') ? `/@fs${normalizedPath}` : `/@fs/${normalizedPath}`;\n}\n","import { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { build, type Rollup } from 'vite';\nimport { resolveRulesConfigFilePath } from './rules-options.ts';\nimport type { FrameworkOptions } from './types.ts';\nimport {\n buildStaticModuleMap,\n buildSnapshotFilePath,\n copyRuntimeSnapshot,\n collectTrackedSpecifiers,\n emitBuildEntrypoints,\n loadVirtualBuildModule,\n resolveVirtualBuildModuleId,\n} from './vitePluginAstroBuildShared.ts';\nimport { buildHydratedComponentAssets } from './lib/hydratedComponentBuild.ts';\nimport { mergeWithAstroConfig } from './vitePluginAstro.ts';\nimport { viteAstroContainerRenderersPlugin } from './viteAstroContainerRenderersPlugin.ts';\nimport { sanitizeConfigPlugin } from './vite/sanitizeConfigPlugin.ts';\nimport { serverAuthPlugin } from './vite/serverAuthPlugin.ts';\nimport { serverRuntimePlugin } from './vite/serverRuntimePlugin.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 trackedSpecifiers = collectTrackedSpecifiers(integrations);\n const staticEntrypointRefs = 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) {\n return resolveVirtualBuildModuleId(id);\n },\n\n load(id: string) {\n return loadVirtualBuildModule(id);\n },\n\n async buildStart(this: Rollup.PluginContext) {\n await emitBuildEntrypoints({\n pluginContext: this,\n integrations,\n resolveFrom,\n trackedSpecifiers,\n staticEntrypointRefs\n });\n },\n\n async writeBundle(\n this: Rollup.PluginContext,\n _outputOptions: Rollup.NormalizedOutputOptions\n ) {\n const serverOutDir = resolve(dirname(storybookStaticOutDir), 'storybook-server');\n const snapshotDirName = 'project';\n const astroStories = await collectAstroStories(storybookStaticOutDir, resolveFrom);\n const storyAstroComponentPaths = Array.from(new Set(astroStories.map((story) => story.componentPath)));\n const componentPathMap = buildComponentPathMap(storyAstroComponentPaths, resolveFrom, snapshotDirName);\n const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, resolveFrom);\n const trackedModuleMap = buildStaticModuleMap(this, staticEntrypointRefs, new Map());\n const hydratedComponentAssets = await buildHydratedComponentAssets({\n componentPaths: storyAstroComponentPaths,\n integrations,\n resolveFrom,\n outDir: storybookStaticOutDir\n });\n const staticModuleMap = addSnapshotModuleAliases(\n {\n ...trackedModuleMap,\n ...hydratedComponentAssets.staticModuleMap\n },\n {\n resolveFrom,\n snapshotRoot: resolve(serverOutDir, snapshotDirName),\n snapshotDirName\n }\n );\n const staticCssMap = hydratedComponentAssets.staticCssMap;\n\n await buildAstroServer({\n integrations,\n sanitization: options.sanitization,\n storyRules: options.storyRules,\n server: options.server,\n outDir: serverOutDir,\n snapshotDirName,\n componentPathMap,\n staticModuleMap,\n staticCssMap,\n trackedSpecifiers: Array.from(trackedSpecifiers),\n resolveFrom\n });\n\n await copyRuntimeSnapshot({\n resolveFrom,\n snapshotRoot: resolve(serverOutDir, snapshotDirName),\n snapshotDirName,\n astroComponents: storyAstroComponentPaths,\n storyRulesConfigFilePath\n });\n }\n };\n}\n\n/** Builds the standalone Astro render server used by server-mode Storybook output. */\nasync function buildAstroServer(options: {\n integrations: NonNullable<FrameworkOptions['integrations']>;\n sanitization?: FrameworkOptions['sanitization'];\n storyRules?: FrameworkOptions['storyRules'];\n server?: FrameworkOptions['server'];\n outDir: string;\n snapshotDirName: string;\n componentPathMap: Record<string, string>;\n staticModuleMap: Record<string, string>;\n staticCssMap: Record<string, string[]>;\n trackedSpecifiers: 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 sanitizeConfigPlugin(options.sanitization),\n serverAuthPlugin(options.server),\n serverRuntimePlugin({\n integrations: options.integrations,\n storyRules: options.storyRules,\n resolveFrom: options.resolveFrom,\n snapshotDirName: options.snapshotDirName,\n componentPathMap: options.componentPathMap,\n staticModuleMap: options.staticModuleMap,\n staticCssMap: options.staticCssMap,\n trackedSpecifiers: options.trackedSpecifiers\n }),\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\n/** Rewrites Astro component module ids so the standalone server loads them from the snapshot tree. */\nfunction buildComponentPathMap(\n astroComponents: string[],\n resolveFrom: string,\n snapshotDirName: string\n) {\n // The built render server loads Astro component modules from the snapshot,\n // not from the original project root that existed during the build.\n return Object.fromEntries(\n astroComponents.map((componentPath) => [\n componentPath,\n buildSnapshotFilePath(resolveFrom, componentPath, snapshotDirName).replace(\n new RegExp(`^${snapshotDirName}/`),\n ''\n )\n ])\n );\n}\n\nasync function collectAstroStories(outDir: string, resolveFrom: string) {\n const indexFile = resolve(outDir, 'index.json');\n const indexRaw = await import('node:fs/promises').then(({ readFile }) => readFile(indexFile, 'utf-8'));\n const indexJson = JSON.parse(indexRaw) as {\n entries?: Record<string, { type?: string; componentPath?: string; importPath?: string; exportName?: string }>\n };\n\n return Object.values(indexJson.entries ?? [])\n .filter((entry) => entry.type === 'story' && entry.componentPath?.endsWith('.astro'))\n .map((entry) => ({\n componentPath: entry.componentPath?.startsWith('./') || entry.componentPath?.startsWith('../')\n ? resolve(resolveFrom, entry.componentPath)\n : entry.componentPath\n }))\n .filter((entry): entry is { componentPath: string } => Boolean(entry.componentPath));\n}\n\nfunction addSnapshotModuleAliases(\n staticModuleMap: Record<string, string>,\n options: {\n resolveFrom: string;\n snapshotRoot: string;\n snapshotDirName: string;\n }\n) {\n const mapWithSnapshotPaths = { ...staticModuleMap };\n\n for (const [sourcePath, builtPath] of Object.entries(staticModuleMap)) {\n if (!sourcePath.startsWith('/')) {\n continue;\n }\n\n const snapshotPath = resolve(\n dirname(options.snapshotRoot),\n buildSnapshotFilePath(options.resolveFrom, sourcePath, options.snapshotDirName)\n ).replace(/\\\\/g, '/');\n\n mapWithSnapshotPaths[snapshotPath] = builtPath;\n }\n\n return mapWithSnapshotPaths;\n}\n","import type { Plugin } from 'vite';\nimport type { SanitizationOptions } from '../lib/sanitization.ts';\nimport { serializeSanitizationOptions } from '../lib/sanitization.ts';\nimport { createVirtualModule } from './virtualModulePlugin.ts';\n\nexport const SANITIZE_CONFIG_MODULE_ID = 'virtual:storybook-astro/sanitize-config';\n\nexport function sanitizeConfigPlugin(options?: SanitizationOptions): Plugin {\n return createVirtualModule({\n pluginName: 'storybook-astro:sanitize-config',\n virtualModuleId: SANITIZE_CONFIG_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 { createVirtualModule } from './virtualModulePlugin.ts';\n\nexport const SERVER_AUTH_MODULE_ID = 'virtual:storybook-astro/server-auth';\n\nexport function serverAuthPlugin(options?: ServerBuildOptions): Plugin {\n const authToken = normalizeOptionalString(options?.authToken);\n const authHeader = normalizeAuthHeader(options?.authHeader);\n\n return createVirtualModule({\n pluginName: 'storybook-astro:server-auth',\n virtualModuleId: SERVER_AUTH_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 { relative } from 'node:path';\nimport type { Integration } from '../integrations/index.ts';\nimport { resolveRulesConfigFilePath } from '../rules-options.ts';\nimport type { FrameworkOptions } from '../types.ts';\nimport { createVirtualModule } from './virtualModulePlugin.ts';\n\nexport const SERVER_RUNTIME_MODULE_ID = 'virtual:storybook-astro/server-runtime';\nconst integrationsModuleId = '@storybook-astro/framework/integrations';\n\nfunction getIntegrationFactoryName(integration: Integration): string {\n return integration.factoryName ?? integration.name;\n}\n\n/** Produces the virtual module that hands the standalone render server its build-time config. */\nexport function serverRuntimePlugin(options: {\n integrations?: FrameworkOptions['integrations'];\n storyRules?: FrameworkOptions['storyRules'];\n resolveFrom: string;\n snapshotDirName: string;\n componentPathMap: Record<string, string>;\n staticModuleMap: Record<string, string>;\n staticCssMap: Record<string, string[]>;\n trackedSpecifiers: string[];\n}) {\n return createVirtualModule({\n pluginName: 'storybook-astro:server-runtime',\n virtualModuleId: SERVER_RUNTIME_MODULE_ID,\n load() {\n const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, options.resolveFrom);\n const storyRulesConfigRelativePath = storyRulesConfigFilePath\n ? relative(options.resolveFrom, storyRulesConfigFilePath).replace(/\\\\/g, '/')\n : undefined;\n const integrations = options.integrations ?? [];\n // Keep the generated module small: one config object for plain data,\n // one integrations export for real factory calls.\n const runtimeConfig = {\n snapshotDirName: options.snapshotDirName,\n storyRulesConfigRelativePath,\n componentPathMap: options.componentPathMap,\n staticModuleMap: options.staticModuleMap,\n staticCssMap: options.staticCssMap,\n trackedSpecifiers: options.trackedSpecifiers\n };\n\n return [\n createIntegrationImports(integrations),\n `export const runtimeConfig = ${serializeValue(runtimeConfig)};`,\n `export const integrations = [${createIntegrationFactoryCalls(integrations)}];`\n ].join('\\n');\n }\n });\n}\n\n/** Imports only the integration factories used by this runtime bundle. */\nfunction createIntegrationImports(integrations: Integration[]) {\n const factoryNames = Array.from(new Set(integrations.map(getIntegrationFactoryName)));\n\n if (factoryNames.length === 0) {\n return '';\n }\n\n return `import { ${factoryNames.join(', ')} } from ${JSON.stringify(integrationsModuleId)};`;\n}\n\n/** Recreates the configured integration list inside the generated runtime module. */\nfunction createIntegrationFactoryCalls(integrations: Integration[]) {\n return integrations\n .map((integration) => `${getIntegrationFactoryName(integration)}(${serializeValue(integration.options)})`)\n .join(', ');\n}\n\n/** Serializes plain runtime config values into executable module source. */\nfunction serializeValue(value: unknown): string {\n if (value === undefined) {\n return 'undefined';\n }\n\n if (value === null) {\n return 'null';\n }\n\n if (typeof value === 'string') {\n return JSON.stringify(value);\n }\n\n if (typeof value === 'number' || typeof value === 'boolean') {\n return JSON.stringify(value);\n }\n\n if (value instanceof RegExp) {\n return value.toString();\n }\n\n if (Array.isArray(value)) {\n return `[${value.map((entry) => serializeValue(entry)).join(', ')}]`;\n }\n\n if (isRecord(value)) {\n return `{${Object.entries(value)\n .map(([key, entryValue]) => `${JSON.stringify(key)}: ${serializeValue(entryValue)}`)\n .join(', ')}}`;\n }\n\n throw new Error('Unable to serialize Storybook Astro server runtime configuration.');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAAA,gBAAe;;;ACGjB,SAAS,oCAAoC,cAA6B;AAC/E,QAAM,mBAAmB,gBAAgB,CAAC;AAE1C,SAAO,oBAAoB;AAAA,IACzB,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;;;ACnBA,SAAS,qBAAqB;AAI9B,IAAM,wBAAwB,cAAc,IAAI,IAAI,8BAA8B,YAAY,GAAG,CAAC;AAClG,IAAM,2BAA2B,cAAc,IAAI,IAAI,iC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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;AAGA,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":["dirname","mkdir","readFile","writeFile","resolve","resolve","require","isRecord","resolve","createRequire","mkdir","dirname","resolve","mergeConfig","mergeConfig","resolve","mkdir","dirname","createRequire","resolve","mkdir","writeFile","readFile","dirname","resolve","fileURLToPath","build","isRecord","resolve","dirname","fileURLToPath","collectAstroStories","build","readFile","dirname"]}
@@ -3,6 +3,7 @@ import "../chunk-G3PMV62Z.js";
3
3
  // src/renderer/renderer-dev.ts
4
4
  var pendingMessages = /* @__PURE__ */ new Map();
5
5
  var ASTRO_SERVER_UNAVAILABLE_ERROR_NAME = "AstroRenderServerUnavailableError";
6
+ var isStaticMode = false;
6
7
  async function render(data, timeoutMs = 5e3) {
7
8
  const id = crypto.randomUUID();
8
9
  const promise = new Promise((resolve, reject) => {
@@ -57,6 +58,7 @@ function isAstroStyleUpdate(path) {
57
58
  export {
58
59
  applyStyles,
59
60
  init,
61
+ isStaticMode,
60
62
  render
61
63
  };
62
64
  //# sourceMappingURL=renderer-dev.js.map