@storybook-astro/framework 0.1.0-beta.11 → 0.1.0-beta.13
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.
- package/README.md +38 -0
- package/dist/{chunk-KTGNRGDJ.js → chunk-ZV57UBEZ.js} +80 -3
- package/dist/chunk-ZV57UBEZ.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/preset.js +1 -1
- package/dist/testing.js +20 -2
- package/dist/testing.js.map +1 -1
- package/package.json +5 -5
- package/src/preset.ts +29 -0
- package/src/testing.ts +32 -3
- package/src/vitePluginAstroRoutesFallback.ts +37 -0
- package/src/vitePluginAstroVueFallback.ts +47 -0
- package/src/viteStorybookAstroMiddlewarePlugin.ts +7 -2
- package/dist/chunk-KTGNRGDJ.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @storybook-astro/framework
|
|
2
|
+
|
|
3
|
+
The community-supported [Storybook](https://storybook.js.org/) framework for [Astro](https://astro.build/).
|
|
4
|
+
|
|
5
|
+
> **Beta** · Astro 5 & 6 + Storybook 10
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save-dev storybook @storybook/builder-vite @storybook-astro/framework
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
// .storybook/main.js
|
|
17
|
+
export default {
|
|
18
|
+
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
19
|
+
framework: {
|
|
20
|
+
name: '@storybook-astro/framework',
|
|
21
|
+
options: {},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
|
|
28
|
+
Node.js 20.16+, Storybook 10, Astro 5.5.3+ or 6.0.0-beta, Vite 6+
|
|
29
|
+
|
|
30
|
+
## Links
|
|
31
|
+
|
|
32
|
+
- [Getting Started](https://storybook-astro.org/getting-started)
|
|
33
|
+
- [Live Demo](https://demo.storybook-astro.org)
|
|
34
|
+
- [GitHub](https://github.com/storybook-astro/storybook-astro)
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT
|
|
@@ -114,6 +114,58 @@ function vitePluginAstroFontsFallback() {
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
// src/vitePluginAstroVueFallback.ts
|
|
118
|
+
var VUE_APP_STUB = `
|
|
119
|
+
export const setup = () => {};
|
|
120
|
+
`;
|
|
121
|
+
var VIRTUAL_IDS = ["virtual:astro:vue-app", "virtual:@astrojs/vue/app"];
|
|
122
|
+
function vitePluginAstroVueFallback() {
|
|
123
|
+
const resolvedIds = new Map(VIRTUAL_IDS.map((id) => [id, "\0" + id]));
|
|
124
|
+
const resolvedIdSet = new Set(resolvedIds.values());
|
|
125
|
+
return {
|
|
126
|
+
name: "storybook-astro-vue-fallback",
|
|
127
|
+
// Must run before vite:resolve to intercept virtual modules
|
|
128
|
+
// before Vite tries to resolve them as Node package imports
|
|
129
|
+
enforce: "pre",
|
|
130
|
+
resolveId(id) {
|
|
131
|
+
const resolved = resolvedIds.get(id);
|
|
132
|
+
if (resolved) {
|
|
133
|
+
return resolved;
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
load(id) {
|
|
137
|
+
if (resolvedIdSet.has(id)) {
|
|
138
|
+
return { code: VUE_APP_STUB };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/vitePluginAstroRoutesFallback.ts
|
|
145
|
+
var ROUTES_STUB = `
|
|
146
|
+
export const routes = [];
|
|
147
|
+
`;
|
|
148
|
+
function vitePluginAstroRoutesFallback() {
|
|
149
|
+
const VIRTUAL_ID = "virtual:astro:routes";
|
|
150
|
+
const RESOLVED_VIRTUAL_ID = "\0" + VIRTUAL_ID;
|
|
151
|
+
return {
|
|
152
|
+
name: "storybook-astro-routes-fallback",
|
|
153
|
+
// Must run before vite:resolve to intercept virtual modules
|
|
154
|
+
// before Vite tries to resolve them as Node package imports
|
|
155
|
+
enforce: "pre",
|
|
156
|
+
resolveId(id) {
|
|
157
|
+
if (id === VIRTUAL_ID) {
|
|
158
|
+
return RESOLVED_VIRTUAL_ID;
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
load(id) {
|
|
162
|
+
if (id === RESOLVED_VIRTUAL_ID) {
|
|
163
|
+
return { code: ROUTES_STUB };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
117
169
|
// src/viteStorybookAstroMiddlewarePlugin.ts
|
|
118
170
|
async function vitePluginStorybookAstroMiddleware(options) {
|
|
119
171
|
let viteServer = null;
|
|
@@ -190,9 +242,12 @@ async function createViteServer(integrations) {
|
|
|
190
242
|
configFile: false,
|
|
191
243
|
...config,
|
|
192
244
|
plugins: [
|
|
245
|
+
// Fallbacks must come first to intercept before Astro's plugins
|
|
246
|
+
vitePluginAstroFontsFallback(),
|
|
247
|
+
vitePluginAstroVueFallback(),
|
|
248
|
+
vitePluginAstroRoutesFallback(),
|
|
193
249
|
...config.plugins?.filter(Boolean) ?? [],
|
|
194
|
-
viteAstroContainerRenderersPlugin(safeIntegrations)
|
|
195
|
-
vitePluginAstroFontsFallback()
|
|
250
|
+
viteAstroContainerRenderersPlugin(safeIntegrations)
|
|
196
251
|
]
|
|
197
252
|
});
|
|
198
253
|
await viteServer.pluginContainer.buildStart({});
|
|
@@ -535,6 +590,7 @@ var viteFinal = async (config, { presets }) => {
|
|
|
535
590
|
vitePluginAstroComponentMarker(),
|
|
536
591
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
537
592
|
vitePluginAstroBuildPrerender(integrations),
|
|
593
|
+
vitePluginAstroVueFallback(),
|
|
538
594
|
...viteConfig.plugins
|
|
539
595
|
);
|
|
540
596
|
if (!config.resolve) {
|
|
@@ -551,6 +607,27 @@ var viteFinal = async (config, { presets }) => {
|
|
|
551
607
|
aliases["react-dom"] = "react-dom";
|
|
552
608
|
}
|
|
553
609
|
const finalConfig = await mergeWithAstroConfig(config, integrations);
|
|
610
|
+
if (!finalConfig.optimizeDeps) {
|
|
611
|
+
finalConfig.optimizeDeps = {};
|
|
612
|
+
}
|
|
613
|
+
if (!finalConfig.optimizeDeps.exclude) {
|
|
614
|
+
finalConfig.optimizeDeps.exclude = [];
|
|
615
|
+
}
|
|
616
|
+
if (!finalConfig.optimizeDeps.exclude.includes("@astrojs/vue")) {
|
|
617
|
+
finalConfig.optimizeDeps.exclude.push("@astrojs/vue");
|
|
618
|
+
}
|
|
619
|
+
if (!finalConfig.optimizeDeps.esbuildOptions) {
|
|
620
|
+
finalConfig.optimizeDeps.esbuildOptions = {};
|
|
621
|
+
}
|
|
622
|
+
if (!finalConfig.optimizeDeps.esbuildOptions.external) {
|
|
623
|
+
finalConfig.optimizeDeps.esbuildOptions.external = [];
|
|
624
|
+
}
|
|
625
|
+
const vueVirtualModules = ["virtual:@astrojs/vue/app", "virtual:astro:vue-app"];
|
|
626
|
+
for (const mod of vueVirtualModules) {
|
|
627
|
+
if (!finalConfig.optimizeDeps.esbuildOptions.external.includes(mod)) {
|
|
628
|
+
finalConfig.optimizeDeps.esbuildOptions.external.push(mod);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
554
631
|
return finalConfig;
|
|
555
632
|
};
|
|
556
633
|
|
|
@@ -558,4 +635,4 @@ export {
|
|
|
558
635
|
core,
|
|
559
636
|
viteFinal
|
|
560
637
|
};
|
|
561
|
-
//# sourceMappingURL=chunk-
|
|
638
|
+
//# sourceMappingURL=chunk-ZV57UBEZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/viteStorybookAstroMiddlewarePlugin.ts","../src/viteAstroContainerRenderersPlugin.ts","../src/vitePluginAstroFontsFallback.ts","../src/vitePluginAstroVueFallback.ts","../src/vitePluginAstroRoutesFallback.ts","../src/viteStorybookRendererFallbackPlugin.ts","../src/vitePluginAstroComponentMarker.ts","../src/vitePluginAstroBuildPrerender.ts","../src/vitePluginAstro.ts","../src/preset.ts"],"sourcesContent":["import { fileURLToPath } from 'node:url';\nimport { createServer, type PluginOption, type ViteDevServer } from 'vite';\nimport type { RenderRequestMessage, RenderResponseMessage } from '@storybook-astro/renderer/types';\nimport type { FrameworkOptions } from './types.ts';\nimport type { Integration } from './integrations/index.ts';\nimport { viteAstroContainerRenderersPlugin } from './viteAstroContainerRenderersPlugin.ts';\nimport { vitePluginAstroFontsFallback } from './vitePluginAstroFontsFallback.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\nimport { vitePluginAstroRoutesFallback } from './vitePluginAstroRoutesFallback.ts';\n\nexport async function vitePluginStorybookAstroMiddleware(options: FrameworkOptions) {\n // The internal Vite server is created lazily inside configureServer (dev-only).\n // During builds, configureServer never fires, so no server is created.\n let viteServer: ViteDevServer | null = null;\n\n const vitePlugin = {\n name: 'storybook-astro-middleware-plugin',\n async configureServer(server) {\n viteServer = await createViteServer(options.integrations);\n\n const filePath = fileURLToPath(new URL('./middleware', import.meta.url));\n const middleware = await viteServer.ssrLoadModule(filePath, {\n fixStacktrace: true\n });\n const handler = await middleware.handlerFactory(options.integrations ?? []);\n\n server.ws.on('astro:render:request', async (data: RenderRequestMessage['data']) => {\n try {\n const html = await handler(data);\n\n server.ws.send('astro:render:response', {\n html,\n id: data.id\n } satisfies RenderResponseMessage['data']);\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n const errorStack = err instanceof Error ? err.stack : '';\n\n console.error('[storybook-astro] Render error:', errorMessage);\n if (errorStack) {console.error(errorStack);}\n server.ws.send('astro:render:response', {\n id: data.id,\n html:\n '<div style=\"background: #d73838; padding: 12px; color: #f0f0f0; font-family: monospace; border-radius: 4px\">' +\n '<strong>Error rendering Astro component</strong><br/>' +\n '<pre style=\"white-space: pre-wrap; margin-top: 8px; font-size: 12px\">' +\n errorMessage.replace(/</g, '<').replace(/>/g, '>') +\n '</pre></div>'\n } satisfies RenderResponseMessage['data']);\n }\n });\n }\n } satisfies PluginOption;\n\n // Create asset serving plugin (only active in dev when viteServer exists)\n const assetServingPlugin = {\n name: 'storybook-astro-assets',\n configureServer(server) {\n server.middlewares.use('/_image', (req, res, next) => {\n if (!viteServer) {\n next();\n \nreturn;\n }\n // Forward the request to the Astro vite server\n viteServer.middlewares.handle(req, res, (err) => {\n if (err) {\n console.error('Asset serving error:', err);\n next();\n }\n });\n });\n }\n };\n\n // The extracted CSS plugins from Astro's internal Vite server cause Vue SFC\n // <style> blocks to be double-processed (once by these plugins, once by\n // Storybook's built-in CSS plugins), resulting in PostCSS errors.\n // \n // Solution: Don't extract Astro's CSS plugins. Storybook's built-in CSS\n // plugins handle both Vue styles AND Astro style sub-modules (which are\n // standard CSS imports like `Component.astro?astro&type=style&index=0&lang.css`).\n // \n // The Astro internal server's CSS plugins are only needed for SSR rendering\n // within that server - they don't need to be shared with Storybook's server.\n return {\n vitePlugin,\n viteConfig: {\n plugins: [\n assetServingPlugin\n ].filter(Boolean)\n }\n };\n}\n\nexport async function createViteServer(integrations: Integration[]) {\n const { getViteConfig } = await import('astro/config');\n const safeIntegrations = integrations ?? [];\n\n const config = await getViteConfig(\n {},\n {\n configFile: false,\n integrations: await Promise.all(\n safeIntegrations.map((integration) => integration.loadIntegration())\n )\n }\n )({ mode: 'development', command: 'serve' });\n\n const viteServer = await createServer({\n configFile: false,\n ...config,\n plugins: [\n // Fallbacks must come first to intercept before Astro's plugins\n vitePluginAstroFontsFallback(),\n vitePluginAstroVueFallback(),\n vitePluginAstroRoutesFallback(),\n ...(config.plugins?.filter(Boolean) ?? []),\n viteAstroContainerRenderersPlugin(safeIntegrations)\n ]\n });\n\n // Initialize the server's plugin container to ensure all plugins are ready.\n // Without this, some plugins (like vite:css) may have uninitialized state\n // when ssrLoadModule is called.\n await viteServer.pluginContainer.buildStart({});\n\n return viteServer;\n}\n","import type { Integration } from './integrations/index.ts';\n\nexport function viteAstroContainerRenderersPlugin(integrations: Integration[]) {\n const safeIntegrations = integrations ?? [];\n const name = 'astro-container-renderers';\n const virtualModuleId = `virtual:${name}`;\n const resolvedVirtualModuleId = `\\0${virtualModuleId}`;\n\n return {\n name,\n\n resolveId(id: string) {\n if (id === virtualModuleId) {\n return resolvedVirtualModuleId;\n }\n },\n\n load(id: string) {\n if (id === resolvedVirtualModuleId) {\n const importStatements = buildImportStatements(safeIntegrations);\n\n const code = `\n ${importStatements}\n export function addRenderers(container) {\n ${safeIntegrations.map((integration) => buildServerRenderer(integration) + '\\n' + buildClientRenderer(integration)).join('\\n')}\n }\n `;\n\n return code;\n }\n }\n };\n}\n\nfunction buildImportStatements(integrations: Integration[]) {\n return integrations\n .filter((integration) => integration.renderer.server)\n .map(\n (integration) =>\n `import ${integration.name}Renderer from '${integration.renderer.server?.entrypoint}';`\n )\n .join('\\n');\n}\n\nfunction buildServerRenderer(integration: Integration) {\n const serverRenderer = integration.renderer.server;\n\n if (!serverRenderer) {\n return '';\n }\n\n if (integration.name === 'solid') {\n return `\n container.addServerRenderer({\n name: '${serverRenderer.name}',\n renderer: {\n ...${integration.name}Renderer,\n name: '${serverRenderer.name}'\n }\n });\n `;\n }\n\n return `\n container.addServerRenderer({\n name: '${serverRenderer.name}',\n renderer: ${integration.name}Renderer\n });\n `;\n}\n\nfunction buildClientRenderer(integration: Integration) {\n const clientRenderer = integration.renderer.client;\n\n if (clientRenderer) {\n return `\n container.addClientRenderer({\n name: '${clientRenderer.name}',\n entrypoint: '${clientRenderer.entrypoint}'\n });\n `;\n }\n\n return '';\n}\n","import type { Plugin } from 'vite';\n\nconst FONTS_RUNTIME_STUB = `\nexport const fontData = {};\nexport function createGetFontData(fontsMod) {\n return fontsMod?.fontDataByCssVariable ?? {};\n}\n`;\n\nconst FONTS_INTERNAL_STUB = `\nexport const componentDataByCssVariable = new Map();\nexport const fontDataByCssVariable = {};\n`;\n\n/**\n * Provides fallback resolution for Astro's font-related virtual modules\n * and package import paths in Storybook's SSR Vite server.\n *\n * In Astro 6, the `astro:assets` virtual module depends on font-related\n * modules through virtual modules and a bare `astro/assets/fonts/runtime`\n * import. In the Storybook SSR context:\n *\n * 1. The fonts plugin's filter-based `resolveId` may not trigger for\n * the virtual module IDs.\n * 2. A Vite transform rewrites the `astro:assets` module to import\n * `createGetFontData` from `astro/assets/fonts/runtime` (without\n * `.js`), which fails against Astro's package.json exports map.\n * 3. The `createGetFontData` function is injected by a runtime Vite\n * transform that doesn't run in our SSR context.\n *\n * This plugin stubs all three font module paths with no-op exports,\n * since Storybook doesn't need Astro's font system.\n */\nexport function vitePluginAstroFontsFallback(): Plugin {\n const VIRTUAL_ID = 'virtual:astro:assets/fonts/internal';\n const RUNTIME_VIRTUAL_ID = 'virtual:astro:assets/fonts/runtime';\n const RESOLVED_VIRTUAL_ID = '\\0' + VIRTUAL_ID;\n const RESOLVED_RUNTIME_VIRTUAL_ID = '\\0' + RUNTIME_VIRTUAL_ID;\n const RESOLVED_FONTS_RUNTIME_ID = '\\0storybook:astro-fonts-runtime';\n\n return {\n name: 'storybook-astro-fonts-fallback',\n // Must run before vite:resolve to intercept virtual modules\n // before Vite tries to resolve them as Node package imports\n enforce: 'pre',\n\n resolveId(id) {\n if (id === VIRTUAL_ID) {\n return RESOLVED_VIRTUAL_ID;\n }\n if (id === RUNTIME_VIRTUAL_ID) {\n return RESOLVED_RUNTIME_VIRTUAL_ID;\n }\n // Intercept the bare package import (without .js) and the .js variant\n if (id === 'astro/assets/fonts/runtime' || id === 'astro/assets/fonts/runtime.js') {\n return RESOLVED_FONTS_RUNTIME_ID;\n }\n },\n\n load(id) {\n if (id === RESOLVED_VIRTUAL_ID) {\n return { code: FONTS_INTERNAL_STUB };\n }\n if (id === RESOLVED_RUNTIME_VIRTUAL_ID || id === RESOLVED_FONTS_RUNTIME_ID) {\n return { code: FONTS_RUNTIME_STUB };\n }\n }\n };\n}\n","import type { Plugin } from 'vite';\n\nconst VUE_APP_STUB = `\nexport const setup = () => {};\n`;\n\n// Different versions of @astrojs/vue use different virtual module names\nconst VIRTUAL_IDS = ['virtual:astro:vue-app', 'virtual:@astrojs/vue/app'];\n\n/**\n * Provides fallback resolution for @astrojs/vue's virtual module\n * in Storybook's SSR Vite server.\n *\n * @astrojs/vue's server.js imports a virtual module to get a setup function\n * for configuring the Vue app instance. The virtual module name varies by version:\n * - v6.0.0-beta.1: \"virtual:astro:vue-app\"\n * - Later versions: \"virtual:@astrojs/vue/app\"\n *\n * The Vite plugin that normally creates this virtual module may not run in\n * Storybook's SSR context, so this plugin stubs it with a no-op setup function\n * (the default behavior when no appEntrypoint is configured).\n */\nexport function vitePluginAstroVueFallback(): Plugin {\n const resolvedIds = new Map(VIRTUAL_IDS.map((id) => [id, '\\0' + id]));\n const resolvedIdSet = new Set(resolvedIds.values());\n\n return {\n name: 'storybook-astro-vue-fallback',\n // Must run before vite:resolve to intercept virtual modules\n // before Vite tries to resolve them as Node package imports\n enforce: 'pre',\n\n resolveId(id) {\n const resolved = resolvedIds.get(id);\n\n if (resolved) {\n return resolved;\n }\n },\n\n load(id) {\n if (resolvedIdSet.has(id)) {\n return { code: VUE_APP_STUB };\n }\n }\n };\n}\n","import type { Plugin } from 'vite';\n\nconst ROUTES_STUB = `\nexport const routes = [];\n`;\n\n/**\n * Provides fallback resolution for Astro's routes virtual module\n * in Storybook's SSR Vite server.\n *\n * In Astro 6, the manifest and app entrypoints import from \"virtual:astro:routes\"\n * to get route data. In Storybook's context, there are no routes, so this plugin\n * stubs the virtual module with an empty routes array.\n */\nexport function vitePluginAstroRoutesFallback(): Plugin {\n const VIRTUAL_ID = 'virtual:astro:routes';\n const RESOLVED_VIRTUAL_ID = '\\0' + VIRTUAL_ID;\n\n return {\n name: 'storybook-astro-routes-fallback',\n // Must run before vite:resolve to intercept virtual modules\n // before Vite tries to resolve them as Node package imports\n enforce: 'pre',\n\n resolveId(id) {\n if (id === VIRTUAL_ID) {\n return RESOLVED_VIRTUAL_ID;\n }\n },\n\n load(id) {\n if (id === RESOLVED_VIRTUAL_ID) {\n return { code: ROUTES_STUB };\n }\n }\n };\n}\n","import type { Integration } from './integrations/index.ts';\n\nexport function viteStorybookRendererFallbackPlugin(integrations: Integration[]) {\n const safeIntegrations = integrations ?? [];\n const name = 'storybook-renderer-fallback';\n const virtualModuleId = `virtual:${name}`;\n const resolvedVirtualModuleId = `\\0${virtualModuleId}`;\n\n return {\n name,\n\n resolveId(id: string) {\n if (id === virtualModuleId) {\n return resolvedVirtualModuleId;\n }\n },\n\n load(id: string) {\n if (id === resolvedVirtualModuleId) {\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}\n","import { readFileSync } from 'node:fs';\nimport type { PluginOption } from 'vite';\n\n/**\n * Vite plugin that patches Astro 6's client-side .astro file transforms for Storybook.\n *\n * In Astro 6, the client-side transform of .astro files produces a stub function that\n * throws \"Astro components cannot be used in the browser\" without setting the\n * `isAstroComponentFactory` marker. Storybook's renderer relies on this marker to detect\n * Astro components and route them to server-side rendering via the Container API.\n *\n * This plugin also preserves the component's scoped CSS by importing the style sub-modules\n * that the Astro Vite plugin exposes. Without this, the client-side stub would strip all\n * CSS since Astro 6 no longer includes style imports in client-side .astro transforms.\n *\n * During builds, Astro's compile metadata cache is not populated for client-side transforms,\n * so style sub-module imports would fail. Instead, raw CSS is extracted directly from the\n * .astro source and inlined.\n */\nexport function vitePluginAstroComponentMarker(): PluginOption {\n let isBuild = false;\n\n return {\n name: 'storybook-astro-component-marker',\n enforce: 'post',\n\n configResolved(config) {\n isBuild = config.command === 'build';\n },\n\n transform(code: string, id: string) {\n // Only process main .astro modules (not sub-modules like ?astro&type=style)\n if (!id.endsWith('.astro')) {return null;}\n\n // Detect the Astro 6 client-side stub pattern\n if (!code.includes('Astro components cannot be used in the browser')) {return null;}\n\n const moduleId = id;\n\n // In dev mode, import style sub-modules via Astro's Vite plugin (which has\n // compile metadata cached from the SSR transform).\n // In build mode, Astro's compile metadata cache is not populated for client-side\n // transforms, so sub-module imports would fail. Extract raw CSS instead.\n const styleCode = isBuild\n ? generateInlineStyles(moduleId)\n : generateStyleImports(moduleId);\n\n return {\n code: `\n${styleCode}\nconst __astro_component = () => {\n throw new Error('Astro components are rendered server-side by Storybook.');\n};\n__astro_component.isAstroComponentFactory = true;\n__astro_component.moduleId = ${JSON.stringify(moduleId)};\nexport default __astro_component;\n`,\n map: null,\n };\n },\n };\n}\n\n/**\n * Reads the original .astro source file and generates import statements\n * for each <style> block, using the Astro Vite plugin's sub-module convention.\n */\nfunction generateStyleImports(filePath: string): string {\n try {\n const source = readFileSync(filePath, 'utf-8');\n const styleCount = countStyleBlocks(source);\n\n return Array.from({ length: styleCount }, (_, i) =>\n `import ${JSON.stringify(`${filePath}?astro&type=style&index=${i}&lang.css`)};`\n ).join('\\n');\n } catch {\n return '';\n }\n}\n\n/**\n * Reads the original .astro source file and generates a JS snippet that injects\n * the raw CSS from each <style> block into the document. Used during builds where\n * Astro's compile metadata cache is unavailable.\n *\n * The CSS is unscoped (no Astro scoping transforms), which is acceptable because\n * Astro components show a fallback message in static builds.\n */\nfunction generateInlineStyles(filePath: string): string {\n try {\n const source = readFileSync(filePath, 'utf-8');\n const cssBlocks = extractStyleBlocks(source);\n\n if (cssBlocks.length === 0) {return '';}\n\n // Create a side-effect that injects styles into the document\n return cssBlocks.map((css, i) => {\n const escaped = JSON.stringify(css);\n\n \nreturn `\n(function() {\n if (typeof document !== 'undefined') {\n const style = document.createElement('style');\n style.setAttribute('data-astro-build', ${JSON.stringify(filePath + ':' + i)});\n style.textContent = ${escaped};\n document.head.appendChild(style);\n }\n})();`;\n }).join('\\n');\n } catch {\n return '';\n }\n}\n\n/**\n * Extracts the content of all top-level <style> blocks from an Astro component's source.\n * Strips frontmatter before parsing.\n */\nfunction extractStyleBlocks(source: string): string[] {\n const withoutFrontmatter = source.replace(/^---[\\s\\S]*?---/m, '');\n const blocks: string[] = [];\n const regex = /<style(?:\\s[^>]*)?>([\\s\\S]*?)<\\/style>/g;\n let match;\n\n while ((match = regex.exec(withoutFrontmatter)) !== null) {\n blocks.push(match[1].trim());\n }\n\n return blocks;\n}\n\n/**\n * Counts the number of top-level <style> blocks in an Astro component's source.\n * Only counts opening tags that are NOT inside the frontmatter fence (---).\n */\nfunction countStyleBlocks(source: string): number {\n // Strip frontmatter\n const withoutFrontmatter = source.replace(/^---[\\s\\S]*?---/m, '');\n // Match <style> opening tags (with optional attributes)\n const matches = withoutFrontmatter.match(/<style(\\s|>)/g);\n\n \nreturn matches ? matches.length : 0;\n}\n","import { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { basename } from 'node:path';\nimport type { Plugin, ViteDevServer } from 'vite';\nimport type { Integration } from './integrations/index.ts';\nimport type { HandlerProps } from './middleware.ts';\nimport { createViteServer } from './viteStorybookAstroMiddlewarePlugin.ts';\n\n/**\n * Vite plugin that pre-renders Astro component stories at build time.\n *\n * During `storybook build`, this plugin:\n * 1. Creates an internal Vite SSR server with AstroContainer\n * 2. Detects story files that import Astro components\n * 3. Loads each story module via ssrLoadModule to get fully evaluated args\n * (including imported assets, computed values, etc.)\n * 4. Renders each story variant using AstroContainer\n * 5. Injects the pre-rendered HTML as a story parameter (`__astroPrerendered`)\n *\n * The renderer checks for this parameter in static builds and uses the\n * pre-rendered HTML directly instead of showing a fallback message.\n *\n * Limitations:\n * - Controls panel changes won't update Astro components (HTML is static)\n * - Build time increases with the number of Astro stories\n * - Stories that override the meta component are skipped\n */\nexport function vitePluginAstroBuildPrerender(integrations: Integration[]): Plugin {\n const safeIntegrations = integrations ?? [];\n let viteServer: ViteDevServer | null = null;\n let handler: ((data: HandlerProps) => Promise<string>) | null = null;\n\n // Maps placeholder strings to Rollup emitted-file reference IDs.\n // Placeholders are injected into pre-rendered HTML during transform,\n // then resolved to final asset paths in renderChunk.\n const assetRefIds = new Map<string, string>();\n\n return {\n name: 'storybook-astro-build-prerender',\n apply: 'build',\n enforce: 'post',\n\n async buildStart() {\n try {\n viteServer = await createViteServer(safeIntegrations);\n\n const filePath = fileURLToPath(new URL('./middleware', import.meta.url));\n const middleware = await viteServer.ssrLoadModule(filePath, {\n fixStacktrace: true\n });\n\n handler = await middleware.handlerFactory(safeIntegrations);\n } catch (err) {\n console.warn(\n '[storybook-astro] Failed to create pre-render server:',\n err instanceof Error ? err.message : err\n );\n }\n },\n\n async transform(code, id) {\n if (!handler || !viteServer) {return null;}\n\n // Only process story files\n if (!/\\.stories\\.(jsx?|tsx?|mjs)$/.test(id)) {return null;}\n\n // Parse AST to find .astro imports\n const ast = this.parse(code);\n const astroImport = findFirstAstroImport(ast);\n\n if (!astroImport) {return null;}\n\n // Resolve the .astro import to an absolute path\n const resolved = await this.resolve(astroImport.source, id);\n\n if (!resolved) {return null;}\n const componentPath = resolved.id;\n\n // Load the story module via SSR to get fully evaluated args\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let storyModule: Record<string, any>;\n\n try {\n storyModule = await viteServer.ssrLoadModule(id);\n } catch (err) {\n console.warn(\n `[storybook-astro] Failed to load story for pre-render: ${id}`,\n err instanceof Error ? err.message : err\n );\n \nreturn null;\n }\n\n const meta = storyModule.default || {};\n\n // Confirm the meta component is an Astro component\n if (!meta.component?.isAstroComponentFactory) {return null;}\n\n // Find all named exports that are story objects\n const storyNames = Object.keys(storyModule).filter(\n (k) =>\n k !== 'default' &&\n k !== '__esModule' &&\n typeof storyModule[k] === 'object' &&\n storyModule[k] !== null\n );\n\n if (storyNames.length === 0) {return null;}\n\n // Pre-render each story\n const prerendered: Record<string, string> = {};\n\n for (const name of storyNames) {\n const story = storyModule[name];\n\n // Skip stories that override the component — the resolved path\n // corresponds to the meta component and may not match\n if (story.component && story.component !== meta.component) {continue;}\n\n // Merge meta args with story args (story args take precedence)\n const mergedArgs = { ...meta.args, ...story.args };\n const { slots = {}, ...componentArgs } = mergedArgs;\n\n try {\n const html = await handler({\n component: componentPath,\n args: componentArgs,\n slots: (slots ?? {}) as Record<string, unknown>\n });\n // Rewrite /@fs dev-server URLs to Rollup asset placeholders.\n // The actual files are emitted via this.emitFile and the\n // placeholders are resolved to final paths in renderChunk.\n\n prerendered[name] = emitAndRewriteAssetUrls(html, this, assetRefIds);\n } catch (err) {\n console.warn(\n `[storybook-astro] Pre-render failed for \"${name}\" in ${id}:`,\n err instanceof Error ? err.message : err\n );\n }\n }\n\n if (Object.keys(prerendered).length === 0) {return null;}\n\n // Append code that injects pre-rendered HTML as story parameters.\n // This runs as module-level side effects during import, before\n // Storybook reads the story exports.\n const injections = Object.entries(prerendered).map(\n ([name, html]) =>\n `if (typeof ${name} !== 'undefined' && ${name} && typeof ${name} === 'object') {\\n` +\n ` ${name}.parameters = Object.assign({}, ${name}.parameters, ` +\n `{ __astroPrerendered: ${JSON.stringify(html)} });\\n` +\n `}`\n );\n\n return {\n code:\n code +\n '\\n// Pre-rendered by storybook-astro-build-prerender\\n' +\n injections.join('\\n'),\n map: null\n };\n },\n\n renderChunk(code) {\n if (assetRefIds.size === 0) {return null;}\n\n let result = code;\n let modified = false;\n\n for (const [placeholder, refId] of assetRefIds) {\n if (!result.includes(placeholder)) {continue;}\n const fileName = this.getFileName(refId);\n\n result = result.replaceAll(placeholder, fileName);\n modified = true;\n }\n\n return modified ? { code: result, map: null } : null;\n },\n\n async buildEnd() {\n if (viteServer) {\n await viteServer.close();\n viteServer = null;\n handler = null;\n }\n }\n };\n}\n\n/**\n * Finds the first import declaration with a .astro source in the ESTree AST.\n */\nfunction findFirstAstroImport(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ast: any\n): { local: string; source: string } | null {\n for (const node of ast.body) {\n if (\n node.type === 'ImportDeclaration' &&\n typeof node.source.value === 'string' &&\n node.source.value.endsWith('.astro')\n ) {\n const defaultSpecifier = node.specifiers?.find(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (s: any) => s.type === 'ImportDefaultSpecifier'\n );\n\n if (defaultSpecifier) {\n return {\n local: defaultSpecifier.local.name,\n source: node.source.value\n };\n }\n }\n }\n \nreturn null;\n}\n\n/**\n * Finds /@fs dev-server URLs in pre-rendered HTML, emits the referenced\n * files as Rollup assets, and replaces the URLs with placeholders that\n * are resolved to final paths in renderChunk.\n */\nfunction emitAndRewriteAssetUrls(\n html: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ctx: any,\n refIds: Map<string, string>\n): string {\n // Match /@fs URLs in HTML attribute values.\n // The URL may have a query string with HTML-encoded & (&).\n // Note: file paths may contain spaces, so we match until the closing quote.\n return html.replace(/\\/@fs([^\"'>]+)/g, (fullMatch, rawPath: string) => {\n // Strip query string (may contain & or &)\n const pathOnly = rawPath.split('?')[0];\n\n try {\n const source = readFileSync(pathOnly);\n const name = basename(pathOnly);\n const refId = ctx.emitFile({ type: 'asset', name, source });\n const placeholder = `__ASTRO_PRERENDER_ASSET_${refId}__`;\n\n refIds.set(placeholder, refId);\n \nreturn placeholder;\n } catch {\n return fullMatch;\n }\n });\n}\n","import { mergeConfig, type InlineConfig } from 'vite';\nimport type { Integration } from './integrations/index.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(config: InlineConfig, integrations: Integration[] = []) {\n const { getViteConfig } = await import('astro/config');\n const safeIntegrations = integrations ?? [];\n\n const astroConfig = await getViteConfig(\n {},\n {\n configFile: false,\n integrations: await Promise.all(\n safeIntegrations.map((integration) => integration.loadIntegration())\n )\n }\n )({\n mode: 'development',\n command: 'serve'\n });\n\n const filteredPlugins = astroConfig\n .plugins!.flat()\n .filter(\n (plugin) =>\n plugin &&\n 'name' in plugin &&\n !ASTRO_PLUGINS_THAT_ARE_SUPPOSEDLY_NOT_NEEDED_IN_STORYBOOK.includes(plugin.name)\n );\n\n return mergeConfig(config, {\n ...astroConfig,\n plugins: filteredPlugins\n });\n}\n","import type { StorybookConfigVite, FrameworkOptions } from './types.ts';\nimport { vitePluginStorybookAstroMiddleware } from './viteStorybookAstroMiddlewarePlugin.ts';\nimport { viteStorybookRendererFallbackPlugin } from './viteStorybookRendererFallbackPlugin.ts';\nimport { vitePluginAstroComponentMarker } from './vitePluginAstroComponentMarker.ts';\nimport { vitePluginAstroBuildPrerender } from './vitePluginAstroBuildPrerender.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\nimport { mergeWithAstroConfig } from './vitePluginAstro.ts';\n\nexport const core = {\n builder: '@storybook/builder-vite',\n renderer: '@storybook-astro/renderer'\n};\n\nexport const viteFinal: StorybookConfigVite['viteFinal'] = async (config, { presets }) => {\n const options = await presets.apply<FrameworkOptions>('frameworkOptions');\n const { vitePlugin: storybookAstroMiddlewarePlugin, viteConfig } =\n await vitePluginStorybookAstroMiddleware(options);\n\n if (!config.plugins) {\n config.plugins = [];\n }\n\n const integrations = options.integrations ?? [];\n\n config.plugins.push(\n storybookAstroMiddlewarePlugin,\n viteStorybookRendererFallbackPlugin(integrations),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n vitePluginAstroComponentMarker() as any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n vitePluginAstroBuildPrerender(integrations) as any,\n vitePluginAstroVueFallback(),\n ...viteConfig.plugins\n );\n\n // Add React/ReactDOM aliases for storybook-solidjs compatibility\n if (!config.resolve) {\n config.resolve = {};\n }\n if (!config.resolve.alias) {\n config.resolve.alias = {};\n }\n \n // Ensure React is available for storybook-solidjs\n const aliases = config.resolve.alias as Record<string, string>;\n\n if (!aliases['react']) {\n aliases['react'] = 'react';\n }\n if (!aliases['react-dom']) {\n aliases['react-dom'] = 'react-dom';\n }\n\n const finalConfig = await mergeWithAstroConfig(config, integrations);\n\n // Exclude @astrojs/vue from dependency optimization because it imports\n // virtual modules that esbuild cannot resolve (virtual:@astrojs/vue/app).\n // This must be done after mergeWithAstroConfig to avoid being overwritten.\n if (!finalConfig.optimizeDeps) {\n finalConfig.optimizeDeps = {};\n }\n if (!finalConfig.optimizeDeps.exclude) {\n finalConfig.optimizeDeps.exclude = [];\n }\n if (!finalConfig.optimizeDeps.exclude.includes('@astrojs/vue')) {\n finalConfig.optimizeDeps.exclude.push('@astrojs/vue');\n }\n // Mark Vue virtual modules as external so esbuild doesn't try to resolve them\n if (!finalConfig.optimizeDeps.esbuildOptions) {\n finalConfig.optimizeDeps.esbuildOptions = {};\n }\n if (!finalConfig.optimizeDeps.esbuildOptions.external) {\n finalConfig.optimizeDeps.esbuildOptions.external = [];\n }\n const vueVirtualModules = ['virtual:@astrojs/vue/app', 'virtual:astro:vue-app'];\n\n for (const mod of vueVirtualModules) {\n if (!finalConfig.optimizeDeps.esbuildOptions.external.includes(mod)) {\n finalConfig.optimizeDeps.esbuildOptions.external.push(mod);\n }\n }\n\n return finalConfig;\n};\n"],"mappings":";AAAA,SAAS,qBAAqB;AAC9B,SAAS,oBAA2D;;;ACC7D,SAAS,kCAAkC,cAA6B;AAC7E,QAAM,mBAAmB,gBAAgB,CAAC;AAC1C,QAAM,OAAO;AACb,QAAM,kBAAkB,WAAW,IAAI;AACvC,QAAM,0BAA0B,KAAK,eAAe;AAEpD,SAAO;AAAA,IACL;AAAA,IAEA,UAAU,IAAY;A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GED
|
@@ -15458,7 +15458,7 @@ import "vite/module-runner";
|
|
|
15458
15458
|
|
|
15459
15459
|
// src/testing.ts
|
|
15460
15460
|
import { existsSync, readFileSync } from "fs";
|
|
15461
|
-
import { join as join2 } from "path";
|
|
15461
|
+
import { join as join2, dirname as dirname2 } from "path";
|
|
15462
15462
|
function testStoryRenders(storyName, story) {
|
|
15463
15463
|
test3(`${storyName} renders in Storybook`, async () => {
|
|
15464
15464
|
globalExpect(story).toBeDefined();
|
|
@@ -15505,6 +15505,21 @@ function testStoryComposition(storyName, story, expectedArgs) {
|
|
|
15505
15505
|
}
|
|
15506
15506
|
});
|
|
15507
15507
|
}
|
|
15508
|
+
function findPackageDir(pkgName) {
|
|
15509
|
+
let dir = process.cwd();
|
|
15510
|
+
while (true) {
|
|
15511
|
+
const candidate = join2(dir, "node_modules", pkgName);
|
|
15512
|
+
if (existsSync(join2(candidate, "package.json"))) {
|
|
15513
|
+
return candidate;
|
|
15514
|
+
}
|
|
15515
|
+
const parent = dirname2(dir);
|
|
15516
|
+
if (parent === dir) {
|
|
15517
|
+
break;
|
|
15518
|
+
}
|
|
15519
|
+
dir = parent;
|
|
15520
|
+
}
|
|
15521
|
+
return null;
|
|
15522
|
+
}
|
|
15508
15523
|
function cjsInteropPlugin() {
|
|
15509
15524
|
return {
|
|
15510
15525
|
name: "cjs-esm-interop",
|
|
@@ -15520,7 +15535,10 @@ function cjsInteropPlugin() {
|
|
|
15520
15535
|
return;
|
|
15521
15536
|
}
|
|
15522
15537
|
try {
|
|
15523
|
-
const nmDir =
|
|
15538
|
+
const nmDir = findPackageDir(pkgName);
|
|
15539
|
+
if (!nmDir) {
|
|
15540
|
+
return;
|
|
15541
|
+
}
|
|
15524
15542
|
const pkgJsonPath = join2(nmDir, "package.json");
|
|
15525
15543
|
if (!existsSync(pkgJsonPath)) {
|
|
15526
15544
|
return;
|