@storybook-astro/framework 1.4.0 → 1.5.0-canary.2
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/dist/chunk-6RIGYMZP.js +144 -0
- package/dist/chunk-6RIGYMZP.js.map +1 -0
- package/dist/{chunk-VZXGPM6P.js → chunk-7UF6LK4Z.js} +62 -14
- package/dist/{chunk-VZXGPM6P.js.map → chunk-7UF6LK4Z.js.map} +1 -1
- package/dist/{chunk-BV6V2Z4X.js → chunk-XVVIGJV6.js} +2 -2
- package/dist/preset.js +32 -5
- package/dist/preset.js.map +1 -1
- package/dist/renderer/renderer-dev.js +2 -0
- package/dist/renderer/renderer-dev.js.map +1 -1
- package/dist/renderer/renderer-server.js +3 -1
- package/dist/renderer/renderer-server.js.map +1 -1
- package/dist/renderer/renderer-static.js +2 -0
- package/dist/renderer/renderer-static.js.map +1 -1
- package/dist/testing.js +3 -3
- package/dist/{viteStorybookAstroMiddlewarePlugin-246I5D3Y.js → viteStorybookAstroMiddlewarePlugin-LUMKF7NG.js} +2 -2
- package/dist/vitest/global-setup.js +2 -2
- package/dist/vitest/index.js +1 -1
- package/package.json +5 -2
- package/src/loadUserAstroConfig.test.ts +149 -0
- package/src/loadUserAstroConfig.ts +126 -25
- package/src/preset.ts +45 -2
- package/src/renderer/renderer-dev.ts +2 -0
- package/src/renderer/renderer-server.ts +2 -0
- package/src/renderer/renderer-static.ts +2 -0
- package/src/shim.d.ts +21 -0
- package/src/virtual.d.ts +1 -0
- package/src/vitePluginAstroComponentMarker.test.ts +231 -0
- package/src/vitePluginAstroComponentMarker.ts +173 -51
- package/src/viteStorybookAstroRendererPlugin.ts +2 -1
- package/dist/chunk-E4LB75JN.js +0 -89
- package/dist/chunk-E4LB75JN.js.map +0 -1
- /package/dist/{chunk-BV6V2Z4X.js.map → chunk-XVVIGJV6.js.map} +0 -0
- /package/dist/{viteStorybookAstroMiddlewarePlugin-246I5D3Y.js.map → viteStorybookAstroMiddlewarePlugin-LUMKF7NG.js.map} +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// src/vitePluginAstroComponentMarker.ts
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
import { dirname, resolve } from "path";
|
|
4
|
+
function vitePluginAstroComponentMarker() {
|
|
5
|
+
let isBuild = false;
|
|
6
|
+
return {
|
|
7
|
+
name: "storybook-astro-component-marker",
|
|
8
|
+
enforce: "post",
|
|
9
|
+
configResolved(config) {
|
|
10
|
+
isBuild = config.command === "build";
|
|
11
|
+
},
|
|
12
|
+
transform(code, id) {
|
|
13
|
+
if (!id.endsWith(".astro")) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (!code.includes("Astro components cannot be used in the browser")) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const moduleId = id;
|
|
20
|
+
const styleCode = isBuild ? generateInlineStyles(moduleId) : generateHybridStyles(moduleId);
|
|
21
|
+
return {
|
|
22
|
+
code: `
|
|
23
|
+
${styleCode}
|
|
24
|
+
const __astro_component = () => {
|
|
25
|
+
throw new Error('Astro components are rendered server-side by Storybook.');
|
|
26
|
+
};
|
|
27
|
+
__astro_component.isAstroComponentFactory = true;
|
|
28
|
+
__astro_component.moduleId = ${JSON.stringify(moduleId)};
|
|
29
|
+
export default __astro_component;
|
|
30
|
+
`,
|
|
31
|
+
map: null
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function generateHybridStyles(filePath) {
|
|
37
|
+
try {
|
|
38
|
+
const source = readFileSync(filePath, "utf-8");
|
|
39
|
+
const inlinedCss = extractStyleBlocksWithLang(source).map((block, i) => {
|
|
40
|
+
if (block.lang && block.lang !== "css") {
|
|
41
|
+
return warnUnsupportedStyleLang(filePath, block.lang);
|
|
42
|
+
}
|
|
43
|
+
return styleInjectionSnippet(
|
|
44
|
+
"data-astro-dev",
|
|
45
|
+
`${filePath}:${i}`,
|
|
46
|
+
unwrapGlobalSelectors(block.css)
|
|
47
|
+
);
|
|
48
|
+
}).join("\n");
|
|
49
|
+
const childImports = extractAstroImportSpecifiers(source).map(
|
|
50
|
+
(specifier) => `import ${JSON.stringify(specifier)};`
|
|
51
|
+
);
|
|
52
|
+
return [inlinedCss, ...childImports].filter(Boolean).join("\n");
|
|
53
|
+
} catch {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function unwrapGlobalSelectors(css) {
|
|
58
|
+
return css.replace(/:global\(\s*([^)]*?)\s*\)/g, "$1");
|
|
59
|
+
}
|
|
60
|
+
function warnUnsupportedStyleLang(filePath, lang) {
|
|
61
|
+
const message = `[storybook-astro] Skipping <style lang="${lang}"> in ${filePath}: preprocessed styles are not supported in Storybook dev mode.`;
|
|
62
|
+
return `
|
|
63
|
+
(function() {
|
|
64
|
+
if (typeof console !== 'undefined') { console.warn(${JSON.stringify(message)}); }
|
|
65
|
+
})();`;
|
|
66
|
+
}
|
|
67
|
+
function styleInjectionSnippet(markerAttr, markerValue, css) {
|
|
68
|
+
const attr = JSON.stringify(markerAttr);
|
|
69
|
+
const value = JSON.stringify(markerValue);
|
|
70
|
+
return `
|
|
71
|
+
(function() {
|
|
72
|
+
if (typeof document === 'undefined') { return; }
|
|
73
|
+
const tagged = document.head.querySelectorAll('style[' + ${attr} + ']');
|
|
74
|
+
for (const node of tagged) {
|
|
75
|
+
if (node.getAttribute(${attr}) === ${value}) { return; }
|
|
76
|
+
}
|
|
77
|
+
const style = document.createElement('style');
|
|
78
|
+
style.setAttribute(${attr}, ${value});
|
|
79
|
+
style.textContent = ${JSON.stringify(css)};
|
|
80
|
+
document.head.appendChild(style);
|
|
81
|
+
})();`;
|
|
82
|
+
}
|
|
83
|
+
function extractAstroImportSpecifiers(source) {
|
|
84
|
+
const frontmatterMatch = source.match(/^---([\s\S]*?)---/m);
|
|
85
|
+
if (!frontmatterMatch) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
const frontmatter = frontmatterMatch[1].replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "");
|
|
89
|
+
const importPattern = /(?:from|import)\s*\(?\s*['"]([^'"]+\.astro)['"]/g;
|
|
90
|
+
const specifiers = /* @__PURE__ */ new Set();
|
|
91
|
+
let match;
|
|
92
|
+
while ((match = importPattern.exec(frontmatter)) !== null) {
|
|
93
|
+
specifiers.add(match[1]);
|
|
94
|
+
}
|
|
95
|
+
return [...specifiers];
|
|
96
|
+
}
|
|
97
|
+
function generateInlineStyles(filePath) {
|
|
98
|
+
const cssBlocks = collectStyleBlocks(filePath, /* @__PURE__ */ new Set());
|
|
99
|
+
if (cssBlocks.length === 0) {
|
|
100
|
+
return "";
|
|
101
|
+
}
|
|
102
|
+
return cssBlocks.map(
|
|
103
|
+
({ file, css }, i) => styleInjectionSnippet("data-astro-build", `${file}:${i}`, unwrapGlobalSelectors(css))
|
|
104
|
+
).join("\n");
|
|
105
|
+
}
|
|
106
|
+
function collectStyleBlocks(filePath, visited) {
|
|
107
|
+
if (visited.has(filePath)) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
visited.add(filePath);
|
|
111
|
+
let source;
|
|
112
|
+
try {
|
|
113
|
+
source = readFileSync(filePath, "utf-8");
|
|
114
|
+
} catch {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
const blocks = extractStyleBlocks(source).map((css) => ({ file: filePath, css }));
|
|
118
|
+
for (const specifier of extractAstroImportSpecifiers(source)) {
|
|
119
|
+
if (!specifier.startsWith(".")) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
blocks.push(...collectStyleBlocks(resolve(dirname(filePath), specifier), visited));
|
|
123
|
+
}
|
|
124
|
+
return blocks;
|
|
125
|
+
}
|
|
126
|
+
function extractStyleBlocks(source) {
|
|
127
|
+
return extractStyleBlocksWithLang(source).map((block) => block.css);
|
|
128
|
+
}
|
|
129
|
+
function extractStyleBlocksWithLang(source) {
|
|
130
|
+
const withoutFrontmatter = source.replace(/^---[\s\S]*?---/m, "");
|
|
131
|
+
const blocks = [];
|
|
132
|
+
const regex = /<style((?:\s[^>]*)?)>([\s\S]*?)<\/style>/g;
|
|
133
|
+
let match;
|
|
134
|
+
while ((match = regex.exec(withoutFrontmatter)) !== null) {
|
|
135
|
+
const langMatch = match[1].match(/\blang\s*=\s*['"]?([\w-]+)/);
|
|
136
|
+
blocks.push({ css: match[2].trim(), lang: langMatch ? langMatch[1] : null });
|
|
137
|
+
}
|
|
138
|
+
return blocks;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
vitePluginAstroComponentMarker
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=chunk-6RIGYMZP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/vitePluginAstroComponentMarker.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\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 Storybook's Vite 6 setup with separate client/SSR environments, Astro's\n // CSS cache isn't populated for client-side transforms. CSS sub-module imports\n // fail with \"No Astro CSS at index N\", so we inline the CSS directly.\n // However, we still import child .astro components to bring them into the module\n // graph so the plugin processes them (fix for issue #114).\n const styleCode = isBuild\n ? generateInlineStyles(moduleId)\n : generateHybridStyles(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 * Hybrid approach for dev mode: inline CSS for the current component (to avoid\n * Astro's cache issues) but import child .astro components (to bring them into\n * the module graph for processing). This preserves the fix for issue #114 while\n * avoiding \"No Astro CSS at index N\" errors.\n *\n * Two caveats follow from inlining raw <style> source instead of routing it\n * through Astro's compiler:\n * - Styles are injected globally, not scoped to the component. Plain class\n * selectors still match the SSR-rendered HTML, but there is no scope isolation\n * between components in dev.\n * - `:global(...)` wrappers are unwrapped (the browser can't parse them), and\n * preprocessed blocks (`<style lang=\"scss\">` etc.) are skipped with a warning\n * since the preprocessor isn't reachable here.\n */\nfunction generateHybridStyles(filePath: string): string {\n try {\n const source = readFileSync(filePath, 'utf-8');\n\n // Inline this component's own CSS (no recursion into children).\n const inlinedCss = extractStyleBlocksWithLang(source).map((block, i) => {\n if (block.lang && block.lang !== 'css') {\n return warnUnsupportedStyleLang(filePath, block.lang);\n }\n\n return styleInjectionSnippet(\n 'data-astro-dev',\n `${filePath}:${i}`,\n unwrapGlobalSelectors(block.css)\n );\n }).join('\\n');\n\n // Import child .astro components so they enter the module graph\n const childImports = extractAstroImportSpecifiers(source).map(\n (specifier) => `import ${JSON.stringify(specifier)};`\n );\n\n return [inlinedCss, ...childImports].filter(Boolean).join('\\n');\n } catch {\n return '';\n }\n}\n\n/**\n * Astro's `:global(...)` wrapper marks a selector as un-scoped. Dev-mode styles\n * are already injected globally, so the wrapper carries no meaning here — and the\n * browser treats `:global()` as an invalid pseudo-class and drops the whole rule.\n * Unwrap it to its inner selector so the rule applies.\n */\nfunction unwrapGlobalSelectors(css: string): string {\n return css.replace(/:global\\(\\s*([^)]*?)\\s*\\)/g, '$1');\n}\n\n/**\n * Builds a snippet that warns about a preprocessed <style> block we can't inline.\n * Astro's compiler (which would turn scss/less/etc. into CSS) isn't reachable\n * from this client-side transform, and shipping the raw source would break the\n * browser's CSS parser, so we surface a clear console warning instead.\n */\nfunction warnUnsupportedStyleLang(filePath: string, lang: string): string {\n const message =\n `[storybook-astro] Skipping <style lang=\"${lang}\"> in ${filePath}: ` +\n `preprocessed styles are not supported in Storybook dev mode.`;\n\n return `\n(function() {\n if (typeof console !== 'undefined') { console.warn(${JSON.stringify(message)}); }\n})();`;\n}\n\n/**\n * Builds a self-executing snippet that injects a CSS string into <head> as a\n * <style> tag, tagged with a marker attribute. The marker also dedupes\n * re-injection (e.g. when a module re-evaluates after HMR) so styles don't\n * accumulate in the document.\n */\nfunction styleInjectionSnippet(markerAttr: string, markerValue: string, css: string): string {\n const attr = JSON.stringify(markerAttr);\n const value = JSON.stringify(markerValue);\n\n return `\n(function() {\n if (typeof document === 'undefined') { return; }\n const tagged = document.head.querySelectorAll('style[' + ${attr} + ']');\n for (const node of tagged) {\n if (node.getAttribute(${attr}) === ${value}) { return; }\n }\n const style = document.createElement('style');\n style.setAttribute(${attr}, ${value});\n style.textContent = ${JSON.stringify(css)};\n document.head.appendChild(style);\n})();`;\n}\n\n/**\n * Extracts import specifiers ending in `.astro` from a component's frontmatter.\n * Comments are stripped first so commented-out imports don't resurface as\n * broken module requests in the browser.\n */\nexport function extractAstroImportSpecifiers(source: string): string[] {\n const frontmatterMatch = source.match(/^---([\\s\\S]*?)---/m);\n\n if (!frontmatterMatch) {return [];}\n\n const frontmatter = frontmatterMatch[1]\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/[^\\n]*/g, '');\n\n // Matches static imports (`import Child from './Child.astro'`), side-effect\n // imports (`import './Child.astro'`), and dynamic imports (`import('./Child.astro')`).\n const importPattern = /(?:from|import)\\s*\\(?\\s*['\"]([^'\"]+\\.astro)['\"]/g;\n const specifiers = new Set<string>();\n let match;\n\n while ((match = importPattern.exec(frontmatter)) !== null) {\n specifiers.add(match[1]);\n }\n\n return [...specifiers];\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, recursing into child\n * .astro components imported via relative paths. Used during builds where\n * Astro's compile metadata cache is unavailable.\n *\n * The CSS is unscoped (no Astro scoping transforms), so `:global(...)` wrappers\n * are unwrapped here too — without that the browser drops the whole rule (e.g.\n * PageCard's `.page-card__image-wrapper :global(img)` sizing).\n */\nfunction generateInlineStyles(filePath: string): string {\n const cssBlocks = collectStyleBlocks(filePath, new Set());\n\n if (cssBlocks.length === 0) {return '';}\n\n // Create a side-effect that injects styles into the document\n return cssBlocks\n .map(({ file, css }, i) =>\n styleInjectionSnippet('data-astro-build', `${file}:${i}`, unwrapGlobalSelectors(css))\n )\n .join('\\n');\n}\n\n/**\n * Collects <style> block contents from a component and its child .astro imports.\n * Only relative specifiers are followed (aliases and packages can't be resolved\n * from disk here). The visited set guards against import cycles.\n */\nfunction collectStyleBlocks(\n filePath: string,\n visited: Set<string>\n): Array<{ file: string; css: string }> {\n if (visited.has(filePath)) {return [];}\n visited.add(filePath);\n\n let source: string;\n\n try {\n source = readFileSync(filePath, 'utf-8');\n } catch {\n return [];\n }\n\n const blocks = extractStyleBlocks(source).map((css) => ({ file: filePath, css }));\n\n for (const specifier of extractAstroImportSpecifiers(source)) {\n if (!specifier.startsWith('.')) {continue;}\n\n blocks.push(...collectStyleBlocks(resolve(dirname(filePath), specifier), visited));\n }\n\n return blocks;\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 return extractStyleBlocksWithLang(source).map((block) => block.css);\n}\n\n/**\n * Like {@link extractStyleBlocks}, but also reports each block's `lang` attribute\n * (e.g. \"scss\") so callers can tell preprocessed styles apart from plain CSS.\n * Returns `null` for the lang when no attribute is present.\n */\nfunction extractStyleBlocksWithLang(source: string): Array<{ css: string; lang: string | null }> {\n const withoutFrontmatter = source.replace(/^---[\\s\\S]*?---/m, '');\n const blocks: Array<{ css: string; lang: string | null }> = [];\n const regex = /<style((?:\\s[^>]*)?)>([\\s\\S]*?)<\\/style>/g;\n let match;\n\n while ((match = regex.exec(withoutFrontmatter)) !== null) {\n const langMatch = match[1].match(/\\blang\\s*=\\s*['\"]?([\\w-]+)/);\n\n blocks.push({ css: match[2].trim(), lang: langMatch ? langMatch[1] : null });\n }\n\n return blocks;\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS,eAAe;AAmB1B,SAAS,iCAA+C;AAC7D,MAAI,UAAU;AAEd,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IAET,eAAe,QAAQ;AACrB,gBAAU,OAAO,YAAY;AAAA,IAC/B;AAAA,IAEA,UAAU,MAAc,IAAY;AAElC,UAAI,CAAC,GAAG,SAAS,QAAQ,GAAG;AAAC,eAAO;AAAA,MAAK;AAGzC,UAAI,CAAC,KAAK,SAAS,gDAAgD,GAAG;AAAC,eAAO;AAAA,MAAK;AAEnF,YAAM,WAAW;AAOjB,YAAM,YAAY,UACd,qBAAqB,QAAQ,IAC7B,qBAAqB,QAAQ;AAEjC,aAAO;AAAA,QACL,MAAM;AAAA,EACZ,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,+BAKoB,KAAK,UAAU,QAAQ,CAAC;AAAA;AAAA;AAAA,QAG/C,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACF;AAiBA,SAAS,qBAAqB,UA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AC/F,QAAM,qBAAqB,OAAO,QAAQ,oBAAoB,EAAE;AAChE,QAAM,SAAsD,CAAC;AAC7D,QAAM,QAAQ;AACd,MAAI;AAEJ,UAAQ,QAAQ,MAAM,KAAK,kBAAkB,OAAO,MAAM;AACxD,UAAM,YAAY,MAAM,CAAC,EAAE,MAAM,4BAA4B;AAE7D,WAAO,KAAK,EAAE,KAAK,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,YAAY,UAAU,CAAC,IAAI,KAAK,CAAC;AAAA,EAC7E;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -540,10 +540,24 @@ var CONFIG_FILENAMES = [
|
|
|
540
540
|
"astro.config.js",
|
|
541
541
|
"astro.config.cjs"
|
|
542
542
|
];
|
|
543
|
-
|
|
544
|
-
|
|
543
|
+
var EMPTY = {
|
|
544
|
+
integrations: [],
|
|
545
|
+
fonts: [],
|
|
546
|
+
vitePlugins: []
|
|
547
|
+
};
|
|
548
|
+
var configCache = /* @__PURE__ */ new Map();
|
|
549
|
+
async function loadUserAstroConfigData(resolveFrom) {
|
|
550
|
+
let cached = configCache.get(resolveFrom);
|
|
551
|
+
if (!cached) {
|
|
552
|
+
cached = readUserAstroConfig(resolveFrom);
|
|
553
|
+
configCache.set(resolveFrom, cached);
|
|
554
|
+
}
|
|
555
|
+
return cached;
|
|
556
|
+
}
|
|
557
|
+
async function readUserAstroConfig(resolveFrom) {
|
|
558
|
+
const configFile = CONFIG_FILENAMES.map((name) => resolve2(resolveFrom, name)).find((path) => existsSync2(path));
|
|
545
559
|
if (!configFile) {
|
|
546
|
-
return
|
|
560
|
+
return EMPTY;
|
|
547
561
|
}
|
|
548
562
|
try {
|
|
549
563
|
const result = await loadConfigFromFile(
|
|
@@ -552,24 +566,56 @@ async function loadUserAstroIntegrations(resolveFrom) {
|
|
|
552
566
|
resolveFrom
|
|
553
567
|
);
|
|
554
568
|
if (!result?.config) {
|
|
555
|
-
return
|
|
569
|
+
return EMPTY;
|
|
556
570
|
}
|
|
557
571
|
const config = result.config;
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
return flat.filter(
|
|
564
|
-
(i) => Boolean(i) && typeof i === "object" && "name" in i && "hooks" in i
|
|
565
|
-
);
|
|
572
|
+
return {
|
|
573
|
+
integrations: extractIntegrations(config.integrations),
|
|
574
|
+
fonts: extractFonts(config.fonts),
|
|
575
|
+
vitePlugins: extractVitePlugins(config.vite?.plugins)
|
|
576
|
+
};
|
|
566
577
|
} catch (err) {
|
|
567
578
|
console.warn(
|
|
568
|
-
"[storybook-astro] Could not load astro.config to discover integrations:",
|
|
579
|
+
"[storybook-astro] Could not load astro.config to discover integrations / fonts / vite plugins:",
|
|
569
580
|
err instanceof Error ? err.message : String(err)
|
|
570
581
|
);
|
|
582
|
+
return EMPTY;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
function extractIntegrations(raw) {
|
|
586
|
+
if (!raw) {
|
|
587
|
+
return [];
|
|
588
|
+
}
|
|
589
|
+
const flat = (Array.isArray(raw) ? raw : [raw]).flat(Infinity);
|
|
590
|
+
return flat.filter(
|
|
591
|
+
(i) => Boolean(i) && typeof i === "object" && "name" in i && "hooks" in i
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
function extractFonts(raw) {
|
|
595
|
+
if (!Array.isArray(raw)) {
|
|
596
|
+
return [];
|
|
597
|
+
}
|
|
598
|
+
return raw.filter(
|
|
599
|
+
(f) => Boolean(f) && typeof f === "object" && typeof f.name === "string" && typeof f.cssVariable === "string" && typeof f.provider === "object"
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
function extractVitePlugins(raw) {
|
|
603
|
+
if (!raw) {
|
|
571
604
|
return [];
|
|
572
605
|
}
|
|
606
|
+
const flat = (Array.isArray(raw) ? raw : [raw]).flat(Infinity);
|
|
607
|
+
return flat.filter(
|
|
608
|
+
(p) => Boolean(p) && typeof p === "object" && "name" in p && typeof p.name === "string"
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
async function loadUserAstroIntegrations(resolveFrom) {
|
|
612
|
+
return (await loadUserAstroConfigData(resolveFrom)).integrations;
|
|
613
|
+
}
|
|
614
|
+
async function loadUserAstroFonts(resolveFrom) {
|
|
615
|
+
return (await loadUserAstroConfigData(resolveFrom)).fonts;
|
|
616
|
+
}
|
|
617
|
+
async function loadUserAstroVitePlugins(resolveFrom) {
|
|
618
|
+
return (await loadUserAstroConfigData(resolveFrom)).vitePlugins;
|
|
573
619
|
}
|
|
574
620
|
|
|
575
621
|
// src/viteStorybookAstroMiddlewarePlugin.ts
|
|
@@ -753,7 +799,9 @@ export {
|
|
|
753
799
|
ssrLoadModuleWithFsFallback,
|
|
754
800
|
resolveRulesConfigFilePath,
|
|
755
801
|
loadUserAstroIntegrations,
|
|
802
|
+
loadUserAstroFonts,
|
|
803
|
+
loadUserAstroVitePlugins,
|
|
756
804
|
vitePluginStorybookAstroMiddleware,
|
|
757
805
|
createViteServer
|
|
758
806
|
};
|
|
759
|
-
//# sourceMappingURL=chunk-
|
|
807
|
+
//# sourceMappingURL=chunk-7UF6LK4Z.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/viteStorybookAstroMiddlewarePlugin.ts","../src/vite/virtualModulePlugin.ts","../src/viteAstroContainerRenderersPlugin.ts","../src/vitePluginAstroFonts.ts","../src/vitePluginAstroIntegrationOptsFallback.ts","../src/vitePluginAstroVueFallback.ts","../src/vitePluginAstroRoutesFallback.ts","../src/vitePluginStoryModuleMocks.ts","../src/lib/ssr-load-module-with-fs-fallback.ts","../src/rules-options.ts","../src/loadUserAstroConfig.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { fileURLToPath } from 'node:url';\nimport type { ServerResponse } from 'node:http';\nimport { createServer, createLogger, type Connect, 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 { importAstroConfig } from './importAstroConfig.ts';\nimport { viteAstroContainerRenderersPlugin } from './viteAstroContainerRenderersPlugin.ts';\nimport { vitePluginAstroFonts } from './vitePluginAstroFonts.ts';\nimport { vitePluginAstroIntegrationOptsFallback } from './vitePluginAstroIntegrationOptsFallback.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\nimport { vitePluginAstroRoutesFallback } from './vitePluginAstroRoutesFallback.ts';\nimport { vitePluginStoryModuleMocks } from './vitePluginStoryModuleMocks.ts';\nimport { ssrLoadModuleWithFsFallback } from './lib/ssr-load-module-with-fs-fallback.ts';\nimport { resolveRulesConfigFilePath } from './rules-options.ts';\nimport { loadUserAstroIntegrations } from './loadUserAstroConfig.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 resolveFrom = options.resolveFrom ?? process.cwd();\n\n const vitePlugin = {\n name: 'storybook-astro-middleware-plugin',\n async configureServer(server) {\n viteServer = await createViteServer(options.integrations ?? [], resolveFrom, options.fonts);\n const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, resolveFrom);\n\n const filePath = fileURLToPath(new URL('./middleware', import.meta.url));\n const middleware = await viteServer.ssrLoadModule(filePath, {\n fixStacktrace: true\n });\n\n const createHandler = () => middleware.handlerFactory(options.integrations ?? [], {\n sanitization: options.sanitization,\n rulesConfigFilePath: storyRulesConfigFilePath,\n resolveRulesConfigModule: () =>\n loadRulesConfigModule(viteServer!, storyRulesConfigFilePath),\n invalidateModuleGraph: () => {\n viteServer?.moduleGraph.invalidateAll();\n },\n loadModule: (id: string) =>\n ssrLoadModuleWithFsFallback(viteServer!, id, {\n fixStacktrace: true\n }),\n resolveFrom\n });\n\n let handlerPromise = createHandler();\n\n const resetHandler = () => {\n handlerPromise = createHandler();\n };\n\n server.watcher.on('add', resetHandler);\n server.watcher.on('change', resetHandler);\n server.watcher.on('unlink', resetHandler);\n viteServer.watcher.on('add', resetHandler);\n viteServer.watcher.on('change', resetHandler);\n viteServer.watcher.on('unlink', resetHandler);\n\n server.ws.on('astro:render:request', async (data: RenderRequestMessage['data']) => {\n try {\n const handler = await handlerPromise;\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: ViteDevServer) {\n server.middlewares.use('/_image', (req: Connect.IncomingMessage, res: ServerResponse, next: Connect.NextFunction) => {\n if (!viteServer) {\n next();\n\n return;\n }\n // Forward the request to the Astro vite server\n viteServer.middlewares.handle(req, res, (err?: unknown) => {\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\n/**\n * Creates a Vite logger that silences known benign warnings emitted by Astro's\n * Vite plugin in the SSR server context:\n * - \"Missing pages directory\" — Storybook and test contexts have no src/pages.\n * - \"points to missing source files\" — Sourcemap gaps in the `entities` package.\n */\nfunction createSsrServerLogger() {\n const logger = createLogger();\n const originalWarn = logger.warn.bind(logger);\n\n logger.warn = (msg, options) => {\n if (\n msg.includes('Missing pages directory') ||\n msg.includes('points to missing source files') ||\n msg.includes('Failed to load source map for')\n ) {\n return;\n }\n\n originalWarn(msg, options);\n };\n\n return logger;\n}\n\nexport async function createViteServer(\n integrations: Integration[],\n resolveFrom = process.cwd(),\n fonts?: FrameworkOptions['fonts']\n) {\n const { getViteConfig, passthroughImageService } = await importAstroConfig(resolveFrom);\n const safeIntegrations = integrations ?? [];\n const projectAstroResolutionPlugin = createProjectAstroResolutionPlugin(resolveFrom);\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 config = await getViteConfig(\n { root: resolveFrom },\n {\n configFile: false,\n integrations: [...frameworkIntegrations, ...extraIntegrations],\n // Use the passthrough image service so nested components that use <Image>\n // from astro:assets render as plain <img> tags without triggering image\n // optimization (which fails in the Storybook SSR context).\n image: { service: passthroughImageService() }\n }\n )({ mode: 'development', command: 'serve' });\n\n const viteServer = await createServer({\n configFile: false,\n ...config,\n customLogger: createSsrServerLogger(),\n plugins: [\n projectAstroResolutionPlugin,\n // Fallbacks must come first to intercept before Astro's plugins\n vitePluginAstroFonts({ fonts, root: resolveFrom }),\n vitePluginAstroIntegrationOptsFallback(),\n vitePluginAstroVueFallback(),\n vitePluginAstroRoutesFallback(),\n vitePluginStoryModuleMocks(),\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\nfunction createProjectAstroResolutionPlugin(resolveFrom: string): PluginOption {\n const require = createRequire(import.meta.url);\n\n return {\n name: 'storybook-astro:resolve-project-astro',\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 PluginOption;\n}\n\nasync 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","import type { Plugin } from 'vite';\n\ntype CreateVirtualModuleOptions = {\n pluginName: string;\n virtualModuleId: string;\n load: (id: string) => string | Promise<string> | undefined;\n};\n\nexport function createVirtualModule(options: CreateVirtualModuleOptions): Plugin {\n const resolvedVirtualModuleId = `\\0${options.virtualModuleId}`;\n\n return {\n name: options.pluginName,\n resolveId(id) {\n if (id === options.virtualModuleId) {\n return resolvedVirtualModuleId;\n }\n },\n async load(id) {\n if (id === resolvedVirtualModuleId) {\n return options.load(id);\n }\n }\n } satisfies Plugin;\n}\n","import type { Integration } from './integrations/index.ts';\nimport { createVirtualModule } from './vite/virtualModulePlugin.ts';\n\ntype PluginOptions = {\n mode?: 'development' | 'production';\n staticModuleMap?: Record<string, string>;\n};\n\nexport function viteAstroContainerRenderersPlugin(\n integrations: Integration[],\n options: PluginOptions = {}\n) {\n const safeIntegrations = integrations ?? [];\n const mode = options.mode ?? 'development';\n const staticModuleMap = options.staticModuleMap ?? {};\n\n return createVirtualModule({\n pluginName: 'storybook-astro:container-renderers',\n virtualModuleId: 'virtual:astro-container-renderers',\n load() {\n const importStatements = buildImportStatements(safeIntegrations);\n const browserModuleResolverHelpers =\n mode === 'development' ? buildBrowserModuleResolverHelpers() : '';\n const clientModuleEntrypoints =\n mode === 'development' ? buildClientModuleEntrypoints(safeIntegrations) : '[]';\n const clientResolvers =\n mode === 'development'\n ? safeIntegrations\n .filter((integration) => typeof integration.resolveClient === 'function')\n .map((integration) =>\n integration.resolveClient.toString().replace(/^resolveClient/, 'function')\n )\n .join(',\\n')\n : '';\n\n return `\n ${importStatements}\n ${browserModuleResolverHelpers}\n\n export function addRenderers(container) {\n ${safeIntegrations.map((integration) => buildServerRenderer(integration) + '\\n' + buildClientRenderer(integration)).join('\\n')}\n }\n\n const staticClientModules = ${JSON.stringify(staticModuleMap, null, 2)};\n const clientModuleEntrypoints = ${clientModuleEntrypoints};\n\n const clientModulesResolvers = [\n ${clientResolvers}\n ];\n\n export function resolveClientModules(specifier) {\n if (Object.hasOwn(staticClientModules, specifier)) {\n return staticClientModules[specifier];\n }\n\n const normalizedSpecifier = specifier.replace(/\\\\\\\\/g, '/').replace(/\\\\?.*$/, '');\n\n if (Object.hasOwn(staticClientModules, normalizedSpecifier)) {\n return staticClientModules[normalizedSpecifier];\n }\n\n for (const entrypoint of clientModuleEntrypoints) {\n if (normalizedSpecifier === entrypoint || normalizedSpecifier.startsWith(entrypoint)) {\n return storybookAstroResolveBrowserModulePath(normalizedSpecifier);\n }\n }\n\n for (const resolver of clientModulesResolvers) {\n const resolution = resolver(specifier);\n\n if (resolution) {\n return resolution;\n }\n }\n }\n `;\n }\n });\n}\n\nfunction buildClientModuleEntrypoints(integrations: Integration[]) {\n return JSON.stringify(\n Array.from(\n new Set(\n integrations\n .map((integration) => integration.renderer.client?.entrypoint)\n .filter((entrypoint): entrypoint is string => Boolean(entrypoint))\n )\n )\n );\n}\n\nfunction buildBrowserModuleResolverHelpers() {\n return `\n import path from 'node:path';\n import { createRequire } from 'node:module';\n import { pathToFileURL } from 'node:url';\n\n function storybookAstroToFileHref(filePath) {\n return pathToFileURL(filePath).href;\n }\n\n function storybookAstroResolveFrom(moduleName, fromDirectory) {\n const fromFile = path.join(fromDirectory, '__storybook_astro_resolve__.js');\n\n return createRequire(storybookAstroToFileHref(fromFile)).resolve(moduleName);\n }\n\n function storybookAstroResolveFromCandidates(moduleName, primaryDirectory) {\n const directories = [primaryDirectory, process.env.INIT_CWD].filter(Boolean);\n const visited = new Set();\n let lastError;\n\n for (const directory of directories) {\n if (visited.has(directory)) {\n continue;\n }\n\n visited.add(directory);\n\n try {\n return storybookAstroResolveFrom(moduleName, directory);\n } catch (error) {\n lastError = error;\n }\n }\n\n throw lastError;\n }\n\n function storybookAstroResolveBrowserModulePath(moduleName, resolveFrom = process.cwd()) {\n const resolvedPath = storybookAstroResolveFromCandidates(moduleName, resolveFrom).replace(/\\\\\\\\/g, '/');\n\n return '/@fs/' + resolvedPath;\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 { pathToFileURL } from 'node:url';\nimport type { Plugin } from 'vite';\n\n// We avoid a hard import of `astro/assets/fonts/types` here because consumers\n// using older Astro versions without the new fonts API would fail to install.\n// The provider interface we rely on is small and stable enough to type locally.\nexport interface StorybookFontProvider {\n name: string;\n init?: (context: { storage: FontStorage; root: URL }) => Promise<void> | void;\n resolveFont: (options: {\n familyName: string;\n weights: string[];\n styles: string[];\n subsets: string[];\n formats: string[];\n }) => Promise<{ fonts: FontFaceData[] } | undefined> | { fonts: FontFaceData[] } | undefined;\n}\n\nexport interface FontFaceData {\n src: Array<{ url?: string; name?: string; format?: string; tech?: string }>;\n weight?: string | number | [number, number];\n style?: string;\n display?: string;\n unicodeRange?: string[];\n featureSettings?: string;\n variationSettings?: string;\n}\n\nexport interface StorybookFontFamily {\n name: string;\n cssVariable: string;\n provider: StorybookFontProvider;\n weights?: Array<string | number>;\n styles?: string[];\n subsets?: string[];\n formats?: string[];\n fallbacks?: string[];\n display?: string;\n}\n\ninterface FontStorage {\n getItem: <T = unknown>(key: string, init?: () => Promise<T> | T) => Promise<T | null>;\n setItem: (key: string, value: unknown) => Promise<void> | void;\n}\n\ninterface ResolvedFontData {\n componentEntries: Array<[string, { css: string; preloads: never[] }]>;\n fontDataByCssVariable: Record<\n string,\n Array<{\n src: Array<{ url: string; format?: string; tech?: string }>;\n weight?: string;\n style?: string;\n }>\n >;\n}\n\nconst DEFAULTS = {\n weights: ['400'],\n styles: ['normal', 'italic'],\n subsets: ['latin'],\n formats: ['woff2'],\n fallbacks: ['sans-serif']\n} as const;\n\nconst VIRTUAL_INTERNAL_ID = 'virtual:astro:assets/fonts/internal';\nconst VIRTUAL_RUNTIME_ID = 'virtual:astro:assets/fonts/runtime';\nconst VIRTUAL_RUNTIME_RESOLVER_ID = 'virtual:astro:assets/fonts/runtime/font-file-url-resolver';\nconst PACKAGE_RUNTIME_IDS = ['astro/assets/fonts/runtime', 'astro/assets/fonts/runtime.js'];\n\nconst RUNTIME_STUB = `\nexport const fontData = {};\nexport function createGetFontData(fontsMod) {\n return fontsMod?.fontDataByCssVariable ?? {};\n}\nexport const experimental_getFontFileURL = () => undefined;\n`;\n\nconst RESOLVER_STUB = `\nexport const runtimeFontFileUrlResolver = { resolve: () => undefined };\n`;\n\n/**\n * Resolves Astro's font Provider API for Storybook by reading the user's\n * configured font families, calling each provider to produce @font-face data,\n * and emitting CSS through Astro's font virtual modules.\n *\n * Lightweight first cut: generates @font-face declarations and a CSS variable\n * binding to the family name plus fallbacks. Does not handle preload links,\n * Capsize-optimized fallback metrics, or build-time font file emission — those\n * paths fall back to remote URLs returned by the provider directly.\n *\n * If no families are provided, the plugin emits no-op stubs so Astro's\n * font virtual modules still resolve in projects that don't configure fonts.\n */\nexport function vitePluginAstroFonts(\n options: {\n fonts?: StorybookFontFamily[];\n root?: string;\n } = {}\n): Plugin {\n const families = options.fonts ?? [];\n const rootDir = options.root ?? process.cwd();\n const root = pathToFileURL(rootDir.endsWith('/') ? rootDir : rootDir + '/');\n\n let resolved: ResolvedFontData | null = null;\n let resolvePromise: Promise<ResolvedFontData> | null = null;\n\n const ensureResolved = async () => {\n if (!resolvePromise) {\n resolvePromise = resolveAllFamilies(families, root);\n }\n\n resolved = await resolvePromise;\n\n return resolved;\n };\n\n return {\n name: 'storybook-astro-fonts',\n enforce: 'pre',\n\n async buildStart() {\n await ensureResolved();\n },\n\n resolveId(id) {\n if (id === VIRTUAL_INTERNAL_ID) {\n return '\\0' + VIRTUAL_INTERNAL_ID;\n }\n if (id === VIRTUAL_RUNTIME_ID) {\n return '\\0' + VIRTUAL_RUNTIME_ID;\n }\n if (id === VIRTUAL_RUNTIME_RESOLVER_ID) {\n return '\\0' + VIRTUAL_RUNTIME_RESOLVER_ID;\n }\n if (PACKAGE_RUNTIME_IDS.includes(id)) {\n return '\\0storybook:astro-fonts-runtime';\n }\n\n return undefined;\n },\n\n async load(id) {\n if (id === '\\0' + VIRTUAL_INTERNAL_ID) {\n const data = resolved ?? (await ensureResolved());\n\n return {\n code:\n `export const componentDataByCssVariable = new Map(${JSON.stringify(data.componentEntries)});\\n` +\n `export const fontDataByCssVariable = ${JSON.stringify(data.fontDataByCssVariable)};\\n`\n };\n }\n if (id === '\\0' + VIRTUAL_RUNTIME_ID || id === '\\0storybook:astro-fonts-runtime') {\n return { code: RUNTIME_STUB };\n }\n if (id === '\\0' + VIRTUAL_RUNTIME_RESOLVER_ID) {\n return { code: RESOLVER_STUB };\n }\n\n return undefined;\n }\n };\n}\n\nasync function resolveAllFamilies(\n families: StorybookFontFamily[],\n root: URL\n): Promise<ResolvedFontData> {\n const componentEntries: ResolvedFontData['componentEntries'] = [];\n const fontDataByCssVariable: ResolvedFontData['fontDataByCssVariable'] = {};\n const storage = createMemoryStorage();\n\n for (const family of families) {\n try {\n if (family.provider.init) {\n await family.provider.init({ storage, root });\n }\n const result = await family.provider.resolveFont({\n familyName: family.name,\n weights: (family.weights ?? DEFAULTS.weights).map(String),\n styles: family.styles ?? [...DEFAULTS.styles],\n subsets: family.subsets ?? [...DEFAULTS.subsets],\n formats: family.formats ?? [...DEFAULTS.formats]\n });\n const faces = result?.fonts ?? [];\n\n if (faces.length === 0) {\n continue;\n }\n\n componentEntries.push([\n family.cssVariable,\n { css: buildFamilyCss(family, faces), preloads: [] }\n ]);\n fontDataByCssVariable[family.cssVariable] = faces.map(toFontData);\n } catch (err) {\n // Swallow per-family errors so one bad family doesn't break the rest.\n // Errors surface as the family simply not rendering, matching Astro's\n // behavior when a provider can't resolve a font.\n console.warn(\n `[storybook-astro-fonts] Failed to resolve font family \"${family.name}\":`,\n err instanceof Error ? err.message : err\n );\n }\n }\n\n return { componentEntries, fontDataByCssVariable };\n}\n\nexport function buildFamilyCss(family: StorybookFontFamily, faces: FontFaceData[]): string {\n const fallbacks = family.fallbacks ?? [...DEFAULTS.fallbacks];\n const familyList = [JSON.stringify(family.name), ...fallbacks].join(', ');\n const faceBlocks = faces.map((face) => buildFontFaceBlock(family, face)).join('\\n');\n const rootRule = `:root { ${family.cssVariable}: ${familyList}; }`;\n\n return `${faceBlocks}\\n${rootRule}`;\n}\n\nfunction buildFontFaceBlock(family: StorybookFontFamily, face: FontFaceData): string {\n const src = face.src\n .map((source) => {\n if (source.url) {\n const format = source.format ? ` format(${JSON.stringify(source.format)})` : '';\n const tech = source.tech ? ` tech(${source.tech})` : '';\n\n return `url(${JSON.stringify(source.url)})${format}${tech}`;\n }\n if (source.name) {\n return `local(${JSON.stringify(source.name)})`;\n }\n\n return '';\n })\n .filter(Boolean)\n .join(', ');\n\n const descriptors: string[] = [\n `font-family: ${JSON.stringify(family.name)};`,\n `src: ${src};`,\n `font-display: ${family.display ?? 'swap'};`\n ];\n\n if (face.weight !== undefined) {\n const weight = Array.isArray(face.weight) ? face.weight.join(' ') : String(face.weight);\n\n descriptors.push(`font-weight: ${weight};`);\n }\n if (face.style) {\n descriptors.push(`font-style: ${face.style};`);\n }\n if (face.unicodeRange?.length) {\n descriptors.push(`unicode-range: ${face.unicodeRange.join(', ')};`);\n }\n if (face.featureSettings) {\n descriptors.push(`font-feature-settings: ${face.featureSettings};`);\n }\n if (face.variationSettings) {\n descriptors.push(`font-variation-settings: ${face.variationSettings};`);\n }\n\n return `@font-face { ${descriptors.join(' ')} }`;\n}\n\nfunction toFontData(face: FontFaceData) {\n return {\n src: face.src\n .filter((source) => source.url)\n .map((source) => ({ url: source.url!, format: source.format, tech: source.tech })),\n weight:\n face.weight !== undefined\n ? Array.isArray(face.weight)\n ? face.weight.join(' ')\n : String(face.weight)\n : undefined,\n style: face.style\n };\n}\n\nfunction createMemoryStorage(): FontStorage {\n const store = new Map<string, unknown>();\n\n return {\n async getItem(key, init) {\n if (store.has(key)) {\n return store.get(key) as never;\n }\n if (init) {\n const value = await init();\n\n store.set(key, value);\n\n return value as never;\n }\n\n return null;\n },\n async setItem(key, value) {\n store.set(key, value);\n }\n };\n}\n","import type { Plugin } from 'vite';\n\nconst OPTS_STUB = 'export default {}';\n\nconst VIRTUAL_IDS = ['astro:react:opts', 'astro:preact:opts'];\n\nexport function vitePluginAstroIntegrationOptsFallback(): 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-integration-opts-fallback',\n enforce: 'pre',\n\n resolveId(id) {\n return resolvedIds.get(id);\n },\n\n load(id) {\n if (resolvedIdSet.has(id)) {\n return { code: OPTS_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 { PluginOption } from 'vite';\nimport {\n loadStoryInlineModule,\n resolveStoryModuleMock,\n STORYBOOK_ASTRO_INLINE_MODULE_PREFIX\n} from './module-mocks.ts';\n\nexport function vitePluginStoryModuleMocks(): PluginOption {\n return {\n name: 'storybook-astro:story-module-mocks',\n enforce: 'pre',\n resolveId(id) {\n if (id.startsWith(STORYBOOK_ASTRO_INLINE_MODULE_PREFIX)) {\n return `\\0${id}`;\n }\n\n const mockedModule = resolveStoryModuleMock(id);\n\n if (mockedModule) {\n return mockedModule;\n }\n\n return null;\n },\n load(id) {\n return loadStoryInlineModule(id);\n }\n } satisfies PluginOption;\n}\n","import type { ViteDevServer } from 'vite';\n\ntype SsrLoadModuleOptions = {\n fixStacktrace?: boolean;\n};\n\nexport async function ssrLoadModuleWithFsFallback<TModule = unknown>(\n viteServer: Pick<ViteDevServer, 'ssrLoadModule'>,\n id: string,\n options?: SsrLoadModuleOptions\n) {\n const ids = [id];\n\n if (id.startsWith('/') && !id.startsWith('/@fs/')) {\n ids.push(`/@fs${id}`);\n }\n\n let lastError: unknown;\n\n for (const candidate of ids) {\n try {\n return await viteServer.ssrLoadModule(candidate, options) as TModule;\n } catch (error) {\n lastError = error;\n }\n }\n\n throw lastError;\n}\n","import { existsSync, statSync } from 'node:fs';\nimport { extname, resolve } from 'node:path';\n\nexport type StoryRulesOptions =\n | string\n | {\n configFile: string;\n };\n\nexport function resolveRulesConfigFilePath(\n options?: StoryRulesOptions,\n resolveFrom = process.cwd()\n): string | undefined {\n if (options === undefined) {\n return undefined;\n }\n\n const configFile = normalizeConfigFileOption(options);\n const resolvedConfigFilePath = resolve(resolveFrom, configFile);\n const normalizedConfigFilePath = resolveConfigFilePath(resolvedConfigFilePath);\n\n if (!normalizedConfigFilePath) {\n throw new Error(\n `framework.options.storyRules config file was not found: ${resolvedConfigFilePath}. ` +\n 'Provide an existing path in framework.options.storyRules.'\n );\n }\n\n return normalizedConfigFilePath;\n}\n\nfunction normalizeConfigFileOption(options: StoryRulesOptions): string {\n const configFile =\n typeof options === 'string'\n ? options\n : typeof options === 'object' && options !== null\n ? options.configFile\n : undefined;\n\n if (typeof configFile !== 'string') {\n throw new Error(\n 'framework.options.storyRules must be either a string path or an object with a string configFile.'\n );\n }\n\n const normalizedConfigFile = configFile.trim();\n\n if (!normalizedConfigFile) {\n throw new Error('framework.options.storyRules config file path cannot be empty.');\n }\n\n return normalizedConfigFile;\n}\n\nfunction resolveConfigFilePath(filePath: string): string | undefined {\n if (existsSync(filePath)) {\n const fileStats = statSync(filePath);\n\n if (fileStats.isFile()) {\n return filePath;\n }\n }\n\n if (extname(filePath)) {\n return undefined;\n }\n\n const extensions = ['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'];\n\n for (const extension of extensions) {\n const candidateFilePath = `${filePath}${extension}`;\n\n if (existsSync(candidateFilePath)) {\n return candidateFilePath;\n }\n }\n\n for (const extension of extensions) {\n const candidateFilePath = resolve(filePath, `index${extension}`);\n\n if (existsSync(candidateFilePath)) {\n return candidateFilePath;\n }\n }\n\n return undefined;\n}\n","import { loadConfigFromFile } from 'vite';\nimport { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport type { AstroIntegration } from 'astro';\n\nconst CONFIG_FILENAMES = [\n 'astro.config.ts',\n 'astro.config.mjs',\n 'astro.config.js',\n 'astro.config.cjs',\n];\n\n/**\n * Loads integrations declared in the user's astro.config.* so that any Vite\n * plugins they register (e.g. astro-icon's virtual:astro-icon resolver) are\n * present in both the main Storybook Vite server and the internal Astro SSR\n * server. Returns an empty array on any failure so the calling code can\n * continue with only the framework-level integrations.\n */\nexport async function loadUserAstroIntegrations(resolveFrom: string): Promise<AstroIntegration[]> {\n const configFile = CONFIG_FILENAMES.find(name => existsSync(resolve(resolveFrom, name)));\n\n if (!configFile) {\n return [];\n }\n\n try {\n const result = await loadConfigFromFile(\n { command: 'serve', mode: 'development' },\n configFile,\n resolveFrom\n );\n\n if (!result?.config) {\n return [];\n }\n\n const config = result.config as { integrations?: unknown };\n const raw = config.integrations;\n\n if (!raw) {\n return [];\n }\n\n // Astro allows nested arrays from conditional spreads (e.g. ...whenX(() => mdx()))\n const flat = (Array.isArray(raw) ? raw : [raw]).flat(Infinity);\n\n return flat.filter(\n (i): i is AstroIntegration => Boolean(i) && typeof i === 'object' && 'name' in i && 'hooks' in i\n );\n } catch (err) {\n console.warn(\n '[storybook-astro] Could not load astro.config to discover integrations:',\n err instanceof Error ? err.message : String(err)\n );\n\n return [];\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAE9B,SAAS,cAAc,oBAAyE;;;ACKzF,SAAS,oBAAoB,SAA6C;AAC/E,QAAM,0BAA0B,KAAK,QAAQ,eAAe;AAE5D,SAAO;AAAA,IACL,MAAM,QAAQ;AAAA,IACd,UAAU,IAAI;AACZ,UAAI,OAAO,QAAQ,iBAAiB;AAClC,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,MAAM,KAAK,IAAI;AACb,UAAI,OAAO,yBAAyB;AAClC,eAAO,QAAQ,KAAK,EAAE;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACF;;;AChBO,SAAS,kCACd,cACA,UAAyB,CAAC,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AAA,IACpC,SAAS;AAAA,MACP;AAAA;AAAA,MAEA,qBAAqB,EAAE,OAAO,MAAM,YAAY,CAAC;AAAA,MACjD,uCAAuC;AAAA,MACvC,2BAA2B;AAAA,MAC3B,8BAA8B;AAAA,MAC9B,2BAA2B;AAAA,MAC3B,GAAI,OAAO,SAAS,OAAO,OAAO,KAAK,CAAC;AAAA,MACxC,kCAAkC,gBAAgB;AAAA,IACpD;AAAA,EACF,CAAC;AAKD,QAAM,WAAW,gBAAgB,WAAW,CAAC,CAAC;AAE9C,SAAO;AACT;AAEA,SAAS,mCAAmC,aAAmC;AAC7E,QAAMC,WAAU,cAAc,YAAY,GAAG;AAE7C,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,UAAU,IAAY;AACpB,UAAI,OAAO,WAAW,CAAC,GAAG,WAAW,QAAQ,GAAG;AAC9C,eAAO;AAAA,MACT;AAEA,UAAI;AACF,eAAOA,SAAQ,QAAQ,IAAI;AAAA,UACzB,OAAO,CAAC,WAAW;AAAA,QACrB,CAAC;AAAA,MACH,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAe,sBAAsB,YAA2B,gBAAyB;AACvF,MAAI,CAAC,gBAAgB;AACnB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,WAAO,MAAM,4BAA4B,YAAY,gBAAgB;AAAA,MACnE,eAAe;AAAA,IACjB,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAEpE,UAAM,IAAI;AAAA,MACR,gEAAgE,cAAc,KAAK,MAAM;AAAA,IAC3F;AAAA,EACF;AACF;","names":["VIRTUAL_IDS","existsSync","resolve","require"]}
|
|
1
|
+
{"version":3,"sources":["../src/viteStorybookAstroMiddlewarePlugin.ts","../src/vite/virtualModulePlugin.ts","../src/viteAstroContainerRenderersPlugin.ts","../src/vitePluginAstroFonts.ts","../src/vitePluginAstroIntegrationOptsFallback.ts","../src/vitePluginAstroVueFallback.ts","../src/vitePluginAstroRoutesFallback.ts","../src/vitePluginStoryModuleMocks.ts","../src/lib/ssr-load-module-with-fs-fallback.ts","../src/rules-options.ts","../src/loadUserAstroConfig.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { fileURLToPath } from 'node:url';\nimport type { ServerResponse } from 'node:http';\nimport { createServer, createLogger, type Connect, 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 { importAstroConfig } from './importAstroConfig.ts';\nimport { viteAstroContainerRenderersPlugin } from './viteAstroContainerRenderersPlugin.ts';\nimport { vitePluginAstroFonts } from './vitePluginAstroFonts.ts';\nimport { vitePluginAstroIntegrationOptsFallback } from './vitePluginAstroIntegrationOptsFallback.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\nimport { vitePluginAstroRoutesFallback } from './vitePluginAstroRoutesFallback.ts';\nimport { vitePluginStoryModuleMocks } from './vitePluginStoryModuleMocks.ts';\nimport { ssrLoadModuleWithFsFallback } from './lib/ssr-load-module-with-fs-fallback.ts';\nimport { resolveRulesConfigFilePath } from './rules-options.ts';\nimport { loadUserAstroIntegrations } from './loadUserAstroConfig.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 resolveFrom = options.resolveFrom ?? process.cwd();\n\n const vitePlugin = {\n name: 'storybook-astro-middleware-plugin',\n async configureServer(server) {\n viteServer = await createViteServer(options.integrations ?? [], resolveFrom, options.fonts);\n const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, resolveFrom);\n\n const filePath = fileURLToPath(new URL('./middleware', import.meta.url));\n const middleware = await viteServer.ssrLoadModule(filePath, {\n fixStacktrace: true\n });\n\n const createHandler = () => middleware.handlerFactory(options.integrations ?? [], {\n sanitization: options.sanitization,\n rulesConfigFilePath: storyRulesConfigFilePath,\n resolveRulesConfigModule: () =>\n loadRulesConfigModule(viteServer!, storyRulesConfigFilePath),\n invalidateModuleGraph: () => {\n viteServer?.moduleGraph.invalidateAll();\n },\n loadModule: (id: string) =>\n ssrLoadModuleWithFsFallback(viteServer!, id, {\n fixStacktrace: true\n }),\n resolveFrom\n });\n\n let handlerPromise = createHandler();\n\n const resetHandler = () => {\n handlerPromise = createHandler();\n };\n\n server.watcher.on('add', resetHandler);\n server.watcher.on('change', resetHandler);\n server.watcher.on('unlink', resetHandler);\n viteServer.watcher.on('add', resetHandler);\n viteServer.watcher.on('change', resetHandler);\n viteServer.watcher.on('unlink', resetHandler);\n\n server.ws.on('astro:render:request', async (data: RenderRequestMessage['data']) => {\n try {\n const handler = await handlerPromise;\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: ViteDevServer) {\n server.middlewares.use('/_image', (req: Connect.IncomingMessage, res: ServerResponse, next: Connect.NextFunction) => {\n if (!viteServer) {\n next();\n\n return;\n }\n // Forward the request to the Astro vite server\n viteServer.middlewares.handle(req, res, (err?: unknown) => {\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\n/**\n * Creates a Vite logger that silences known benign warnings emitted by Astro's\n * Vite plugin in the SSR server context:\n * - \"Missing pages directory\" — Storybook and test contexts have no src/pages.\n * - \"points to missing source files\" — Sourcemap gaps in the `entities` package.\n */\nfunction createSsrServerLogger() {\n const logger = createLogger();\n const originalWarn = logger.warn.bind(logger);\n\n logger.warn = (msg, options) => {\n if (\n msg.includes('Missing pages directory') ||\n msg.includes('points to missing source files') ||\n msg.includes('Failed to load source map for')\n ) {\n return;\n }\n\n originalWarn(msg, options);\n };\n\n return logger;\n}\n\nexport async function createViteServer(\n integrations: Integration[],\n resolveFrom = process.cwd(),\n fonts?: FrameworkOptions['fonts']\n) {\n const { getViteConfig, passthroughImageService } = await importAstroConfig(resolveFrom);\n const safeIntegrations = integrations ?? [];\n const projectAstroResolutionPlugin = createProjectAstroResolutionPlugin(resolveFrom);\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 config = await getViteConfig(\n { root: resolveFrom },\n {\n configFile: false,\n integrations: [...frameworkIntegrations, ...extraIntegrations],\n // Use the passthrough image service so nested components that use <Image>\n // from astro:assets render as plain <img> tags without triggering image\n // optimization (which fails in the Storybook SSR context).\n image: { service: passthroughImageService() }\n }\n )({ mode: 'development', command: 'serve' });\n\n const viteServer = await createServer({\n configFile: false,\n ...config,\n customLogger: createSsrServerLogger(),\n plugins: [\n projectAstroResolutionPlugin,\n // Fallbacks must come first to intercept before Astro's plugins\n vitePluginAstroFonts({ fonts, root: resolveFrom }),\n vitePluginAstroIntegrationOptsFallback(),\n vitePluginAstroVueFallback(),\n vitePluginAstroRoutesFallback(),\n vitePluginStoryModuleMocks(),\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\nfunction createProjectAstroResolutionPlugin(resolveFrom: string): PluginOption {\n const require = createRequire(import.meta.url);\n\n return {\n name: 'storybook-astro:resolve-project-astro',\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 PluginOption;\n}\n\nasync 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","import type { Plugin } from 'vite';\n\ntype CreateVirtualModuleOptions = {\n pluginName: string;\n virtualModuleId: string;\n load: (id: string) => string | Promise<string> | undefined;\n};\n\nexport function createVirtualModule(options: CreateVirtualModuleOptions): Plugin {\n const resolvedVirtualModuleId = `\\0${options.virtualModuleId}`;\n\n return {\n name: options.pluginName,\n resolveId(id) {\n if (id === options.virtualModuleId) {\n return resolvedVirtualModuleId;\n }\n },\n async load(id) {\n if (id === resolvedVirtualModuleId) {\n return options.load(id);\n }\n }\n } satisfies Plugin;\n}\n","import type { Integration } from './integrations/index.ts';\nimport { createVirtualModule } from './vite/virtualModulePlugin.ts';\n\ntype PluginOptions = {\n mode?: 'development' | 'production';\n staticModuleMap?: Record<string, string>;\n};\n\nexport function viteAstroContainerRenderersPlugin(\n integrations: Integration[],\n options: PluginOptions = {}\n) {\n const safeIntegrations = integrations ?? [];\n const mode = options.mode ?? 'development';\n const staticModuleMap = options.staticModuleMap ?? {};\n\n return createVirtualModule({\n pluginName: 'storybook-astro:container-renderers',\n virtualModuleId: 'virtual:astro-container-renderers',\n load() {\n const importStatements = buildImportStatements(safeIntegrations);\n const browserModuleResolverHelpers =\n mode === 'development' ? buildBrowserModuleResolverHelpers() : '';\n const clientModuleEntrypoints =\n mode === 'development' ? buildClientModuleEntrypoints(safeIntegrations) : '[]';\n const clientResolvers =\n mode === 'development'\n ? safeIntegrations\n .filter((integration) => typeof integration.resolveClient === 'function')\n .map((integration) =>\n integration.resolveClient.toString().replace(/^resolveClient/, 'function')\n )\n .join(',\\n')\n : '';\n\n return `\n ${importStatements}\n ${browserModuleResolverHelpers}\n\n export function addRenderers(container) {\n ${safeIntegrations.map((integration) => buildServerRenderer(integration) + '\\n' + buildClientRenderer(integration)).join('\\n')}\n }\n\n const staticClientModules = ${JSON.stringify(staticModuleMap, null, 2)};\n const clientModuleEntrypoints = ${clientModuleEntrypoints};\n\n const clientModulesResolvers = [\n ${clientResolvers}\n ];\n\n export function resolveClientModules(specifier) {\n if (Object.hasOwn(staticClientModules, specifier)) {\n return staticClientModules[specifier];\n }\n\n const normalizedSpecifier = specifier.replace(/\\\\\\\\/g, '/').replace(/\\\\?.*$/, '');\n\n if (Object.hasOwn(staticClientModules, normalizedSpecifier)) {\n return staticClientModules[normalizedSpecifier];\n }\n\n for (const entrypoint of clientModuleEntrypoints) {\n if (normalizedSpecifier === entrypoint || normalizedSpecifier.startsWith(entrypoint)) {\n return storybookAstroResolveBrowserModulePath(normalizedSpecifier);\n }\n }\n\n for (const resolver of clientModulesResolvers) {\n const resolution = resolver(specifier);\n\n if (resolution) {\n return resolution;\n }\n }\n }\n `;\n }\n });\n}\n\nfunction buildClientModuleEntrypoints(integrations: Integration[]) {\n return JSON.stringify(\n Array.from(\n new Set(\n integrations\n .map((integration) => integration.renderer.client?.entrypoint)\n .filter((entrypoint): entrypoint is string => Boolean(entrypoint))\n )\n )\n );\n}\n\nfunction buildBrowserModuleResolverHelpers() {\n return `\n import path from 'node:path';\n import { createRequire } from 'node:module';\n import { pathToFileURL } from 'node:url';\n\n function storybookAstroToFileHref(filePath) {\n return pathToFileURL(filePath).href;\n }\n\n function storybookAstroResolveFrom(moduleName, fromDirectory) {\n const fromFile = path.join(fromDirectory, '__storybook_astro_resolve__.js');\n\n return createRequire(storybookAstroToFileHref(fromFile)).resolve(moduleName);\n }\n\n function storybookAstroResolveFromCandidates(moduleName, primaryDirectory) {\n const directories = [primaryDirectory, process.env.INIT_CWD].filter(Boolean);\n const visited = new Set();\n let lastError;\n\n for (const directory of directories) {\n if (visited.has(directory)) {\n continue;\n }\n\n visited.add(directory);\n\n try {\n return storybookAstroResolveFrom(moduleName, directory);\n } catch (error) {\n lastError = error;\n }\n }\n\n throw lastError;\n }\n\n function storybookAstroResolveBrowserModulePath(moduleName, resolveFrom = process.cwd()) {\n const resolvedPath = storybookAstroResolveFromCandidates(moduleName, resolveFrom).replace(/\\\\\\\\/g, '/');\n\n return '/@fs/' + resolvedPath;\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 { pathToFileURL } from 'node:url';\nimport type { Plugin } from 'vite';\n\n// We avoid a hard import of `astro/assets/fonts/types` here because consumers\n// using older Astro versions without the new fonts API would fail to install.\n// The provider interface we rely on is small and stable enough to type locally.\nexport interface StorybookFontProvider {\n name: string;\n init?: (context: { storage: FontStorage; root: URL }) => Promise<void> | void;\n resolveFont: (options: {\n familyName: string;\n weights: string[];\n styles: string[];\n subsets: string[];\n formats: string[];\n }) => Promise<{ fonts: FontFaceData[] } | undefined> | { fonts: FontFaceData[] } | undefined;\n}\n\nexport interface FontFaceData {\n src: Array<{ url?: string; name?: string; format?: string; tech?: string }>;\n weight?: string | number | [number, number];\n style?: string;\n display?: string;\n unicodeRange?: string[];\n featureSettings?: string;\n variationSettings?: string;\n}\n\nexport interface StorybookFontFamily {\n name: string;\n cssVariable: string;\n provider: StorybookFontProvider;\n weights?: Array<string | number>;\n styles?: string[];\n subsets?: string[];\n formats?: string[];\n fallbacks?: string[];\n display?: string;\n}\n\ninterface FontStorage {\n getItem: <T = unknown>(key: string, init?: () => Promise<T> | T) => Promise<T | null>;\n setItem: (key: string, value: unknown) => Promise<void> | void;\n}\n\ninterface ResolvedFontData {\n componentEntries: Array<[string, { css: string; preloads: never[] }]>;\n fontDataByCssVariable: Record<\n string,\n Array<{\n src: Array<{ url: string; format?: string; tech?: string }>;\n weight?: string;\n style?: string;\n }>\n >;\n}\n\nconst DEFAULTS = {\n weights: ['400'],\n styles: ['normal', 'italic'],\n subsets: ['latin'],\n formats: ['woff2'],\n fallbacks: ['sans-serif']\n} as const;\n\nconst VIRTUAL_INTERNAL_ID = 'virtual:astro:assets/fonts/internal';\nconst VIRTUAL_RUNTIME_ID = 'virtual:astro:assets/fonts/runtime';\nconst VIRTUAL_RUNTIME_RESOLVER_ID = 'virtual:astro:assets/fonts/runtime/font-file-url-resolver';\nconst PACKAGE_RUNTIME_IDS = ['astro/assets/fonts/runtime', 'astro/assets/fonts/runtime.js'];\n\nconst RUNTIME_STUB = `\nexport const fontData = {};\nexport function createGetFontData(fontsMod) {\n return fontsMod?.fontDataByCssVariable ?? {};\n}\nexport const experimental_getFontFileURL = () => undefined;\n`;\n\nconst RESOLVER_STUB = `\nexport const runtimeFontFileUrlResolver = { resolve: () => undefined };\n`;\n\n/**\n * Resolves Astro's font Provider API for Storybook by reading the user's\n * configured font families, calling each provider to produce @font-face data,\n * and emitting CSS through Astro's font virtual modules.\n *\n * Lightweight first cut: generates @font-face declarations and a CSS variable\n * binding to the family name plus fallbacks. Does not handle preload links,\n * Capsize-optimized fallback metrics, or build-time font file emission — those\n * paths fall back to remote URLs returned by the provider directly.\n *\n * If no families are provided, the plugin emits no-op stubs so Astro's\n * font virtual modules still resolve in projects that don't configure fonts.\n */\nexport function vitePluginAstroFonts(\n options: {\n fonts?: StorybookFontFamily[];\n root?: string;\n } = {}\n): Plugin {\n const families = options.fonts ?? [];\n const rootDir = options.root ?? process.cwd();\n const root = pathToFileURL(rootDir.endsWith('/') ? rootDir : rootDir + '/');\n\n let resolved: ResolvedFontData | null = null;\n let resolvePromise: Promise<ResolvedFontData> | null = null;\n\n const ensureResolved = async () => {\n if (!resolvePromise) {\n resolvePromise = resolveAllFamilies(families, root);\n }\n\n resolved = await resolvePromise;\n\n return resolved;\n };\n\n return {\n name: 'storybook-astro-fonts',\n enforce: 'pre',\n\n async buildStart() {\n await ensureResolved();\n },\n\n resolveId(id) {\n if (id === VIRTUAL_INTERNAL_ID) {\n return '\\0' + VIRTUAL_INTERNAL_ID;\n }\n if (id === VIRTUAL_RUNTIME_ID) {\n return '\\0' + VIRTUAL_RUNTIME_ID;\n }\n if (id === VIRTUAL_RUNTIME_RESOLVER_ID) {\n return '\\0' + VIRTUAL_RUNTIME_RESOLVER_ID;\n }\n if (PACKAGE_RUNTIME_IDS.includes(id)) {\n return '\\0storybook:astro-fonts-runtime';\n }\n\n return undefined;\n },\n\n async load(id) {\n if (id === '\\0' + VIRTUAL_INTERNAL_ID) {\n const data = resolved ?? (await ensureResolved());\n\n return {\n code:\n `export const componentDataByCssVariable = new Map(${JSON.stringify(data.componentEntries)});\\n` +\n `export const fontDataByCssVariable = ${JSON.stringify(data.fontDataByCssVariable)};\\n`\n };\n }\n if (id === '\\0' + VIRTUAL_RUNTIME_ID || id === '\\0storybook:astro-fonts-runtime') {\n return { code: RUNTIME_STUB };\n }\n if (id === '\\0' + VIRTUAL_RUNTIME_RESOLVER_ID) {\n return { code: RESOLVER_STUB };\n }\n\n return undefined;\n }\n };\n}\n\nasync function resolveAllFamilies(\n families: StorybookFontFamily[],\n root: URL\n): Promise<ResolvedFontData> {\n const componentEntries: ResolvedFontData['componentEntries'] = [];\n const fontDataByCssVariable: ResolvedFontData['fontDataByCssVariable'] = {};\n const storage = createMemoryStorage();\n\n for (const family of families) {\n try {\n if (family.provider.init) {\n await family.provider.init({ storage, root });\n }\n const result = await family.provider.resolveFont({\n familyName: family.name,\n weights: (family.weights ?? DEFAULTS.weights).map(String),\n styles: family.styles ?? [...DEFAULTS.styles],\n subsets: family.subsets ?? [...DEFAULTS.subsets],\n formats: family.formats ?? [...DEFAULTS.formats]\n });\n const faces = result?.fonts ?? [];\n\n if (faces.length === 0) {\n continue;\n }\n\n componentEntries.push([\n family.cssVariable,\n { css: buildFamilyCss(family, faces), preloads: [] }\n ]);\n fontDataByCssVariable[family.cssVariable] = faces.map(toFontData);\n } catch (err) {\n // Swallow per-family errors so one bad family doesn't break the rest.\n // Errors surface as the family simply not rendering, matching Astro's\n // behavior when a provider can't resolve a font.\n console.warn(\n `[storybook-astro-fonts] Failed to resolve font family \"${family.name}\":`,\n err instanceof Error ? err.message : err\n );\n }\n }\n\n return { componentEntries, fontDataByCssVariable };\n}\n\nexport function buildFamilyCss(family: StorybookFontFamily, faces: FontFaceData[]): string {\n const fallbacks = family.fallbacks ?? [...DEFAULTS.fallbacks];\n const familyList = [JSON.stringify(family.name), ...fallbacks].join(', ');\n const faceBlocks = faces.map((face) => buildFontFaceBlock(family, face)).join('\\n');\n const rootRule = `:root { ${family.cssVariable}: ${familyList}; }`;\n\n return `${faceBlocks}\\n${rootRule}`;\n}\n\nfunction buildFontFaceBlock(family: StorybookFontFamily, face: FontFaceData): string {\n const src = face.src\n .map((source) => {\n if (source.url) {\n const format = source.format ? ` format(${JSON.stringify(source.format)})` : '';\n const tech = source.tech ? ` tech(${source.tech})` : '';\n\n return `url(${JSON.stringify(source.url)})${format}${tech}`;\n }\n if (source.name) {\n return `local(${JSON.stringify(source.name)})`;\n }\n\n return '';\n })\n .filter(Boolean)\n .join(', ');\n\n const descriptors: string[] = [\n `font-family: ${JSON.stringify(family.name)};`,\n `src: ${src};`,\n `font-display: ${family.display ?? 'swap'};`\n ];\n\n if (face.weight !== undefined) {\n const weight = Array.isArray(face.weight) ? face.weight.join(' ') : String(face.weight);\n\n descriptors.push(`font-weight: ${weight};`);\n }\n if (face.style) {\n descriptors.push(`font-style: ${face.style};`);\n }\n if (face.unicodeRange?.length) {\n descriptors.push(`unicode-range: ${face.unicodeRange.join(', ')};`);\n }\n if (face.featureSettings) {\n descriptors.push(`font-feature-settings: ${face.featureSettings};`);\n }\n if (face.variationSettings) {\n descriptors.push(`font-variation-settings: ${face.variationSettings};`);\n }\n\n return `@font-face { ${descriptors.join(' ')} }`;\n}\n\nfunction toFontData(face: FontFaceData) {\n return {\n src: face.src\n .filter((source) => source.url)\n .map((source) => ({ url: source.url!, format: source.format, tech: source.tech })),\n weight:\n face.weight !== undefined\n ? Array.isArray(face.weight)\n ? face.weight.join(' ')\n : String(face.weight)\n : undefined,\n style: face.style\n };\n}\n\nfunction createMemoryStorage(): FontStorage {\n const store = new Map<string, unknown>();\n\n return {\n async getItem(key, init) {\n if (store.has(key)) {\n return store.get(key) as never;\n }\n if (init) {\n const value = await init();\n\n store.set(key, value);\n\n return value as never;\n }\n\n return null;\n },\n async setItem(key, value) {\n store.set(key, value);\n }\n };\n}\n","import type { Plugin } from 'vite';\n\nconst OPTS_STUB = 'export default {}';\n\nconst VIRTUAL_IDS = ['astro:react:opts', 'astro:preact:opts'];\n\nexport function vitePluginAstroIntegrationOptsFallback(): 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-integration-opts-fallback',\n enforce: 'pre',\n\n resolveId(id) {\n return resolvedIds.get(id);\n },\n\n load(id) {\n if (resolvedIdSet.has(id)) {\n return { code: OPTS_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 { PluginOption } from 'vite';\nimport {\n loadStoryInlineModule,\n resolveStoryModuleMock,\n STORYBOOK_ASTRO_INLINE_MODULE_PREFIX\n} from './module-mocks.ts';\n\nexport function vitePluginStoryModuleMocks(): PluginOption {\n return {\n name: 'storybook-astro:story-module-mocks',\n enforce: 'pre',\n resolveId(id) {\n if (id.startsWith(STORYBOOK_ASTRO_INLINE_MODULE_PREFIX)) {\n return `\\0${id}`;\n }\n\n const mockedModule = resolveStoryModuleMock(id);\n\n if (mockedModule) {\n return mockedModule;\n }\n\n return null;\n },\n load(id) {\n return loadStoryInlineModule(id);\n }\n } satisfies PluginOption;\n}\n","import type { ViteDevServer } from 'vite';\n\ntype SsrLoadModuleOptions = {\n fixStacktrace?: boolean;\n};\n\nexport async function ssrLoadModuleWithFsFallback<TModule = unknown>(\n viteServer: Pick<ViteDevServer, 'ssrLoadModule'>,\n id: string,\n options?: SsrLoadModuleOptions\n) {\n const ids = [id];\n\n if (id.startsWith('/') && !id.startsWith('/@fs/')) {\n ids.push(`/@fs${id}`);\n }\n\n let lastError: unknown;\n\n for (const candidate of ids) {\n try {\n return await viteServer.ssrLoadModule(candidate, options) as TModule;\n } catch (error) {\n lastError = error;\n }\n }\n\n throw lastError;\n}\n","import { existsSync, statSync } from 'node:fs';\nimport { extname, resolve } from 'node:path';\n\nexport type StoryRulesOptions =\n | string\n | {\n configFile: string;\n };\n\nexport function resolveRulesConfigFilePath(\n options?: StoryRulesOptions,\n resolveFrom = process.cwd()\n): string | undefined {\n if (options === undefined) {\n return undefined;\n }\n\n const configFile = normalizeConfigFileOption(options);\n const resolvedConfigFilePath = resolve(resolveFrom, configFile);\n const normalizedConfigFilePath = resolveConfigFilePath(resolvedConfigFilePath);\n\n if (!normalizedConfigFilePath) {\n throw new Error(\n `framework.options.storyRules config file was not found: ${resolvedConfigFilePath}. ` +\n 'Provide an existing path in framework.options.storyRules.'\n );\n }\n\n return normalizedConfigFilePath;\n}\n\nfunction normalizeConfigFileOption(options: StoryRulesOptions): string {\n const configFile =\n typeof options === 'string'\n ? options\n : typeof options === 'object' && options !== null\n ? options.configFile\n : undefined;\n\n if (typeof configFile !== 'string') {\n throw new Error(\n 'framework.options.storyRules must be either a string path or an object with a string configFile.'\n );\n }\n\n const normalizedConfigFile = configFile.trim();\n\n if (!normalizedConfigFile) {\n throw new Error('framework.options.storyRules config file path cannot be empty.');\n }\n\n return normalizedConfigFile;\n}\n\nfunction resolveConfigFilePath(filePath: string): string | undefined {\n if (existsSync(filePath)) {\n const fileStats = statSync(filePath);\n\n if (fileStats.isFile()) {\n return filePath;\n }\n }\n\n if (extname(filePath)) {\n return undefined;\n }\n\n const extensions = ['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'];\n\n for (const extension of extensions) {\n const candidateFilePath = `${filePath}${extension}`;\n\n if (existsSync(candidateFilePath)) {\n return candidateFilePath;\n }\n }\n\n for (const extension of extensions) {\n const candidateFilePath = resolve(filePath, `index${extension}`);\n\n if (existsSync(candidateFilePath)) {\n return candidateFilePath;\n }\n }\n\n return undefined;\n}\n","import { loadConfigFromFile, type Plugin } from 'vite';\nimport { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport type { AstroIntegration } from 'astro';\nimport type { StorybookFontFamily } from './vitePluginAstroFonts.ts';\n\nconst CONFIG_FILENAMES = [\n 'astro.config.ts',\n 'astro.config.mjs',\n 'astro.config.js',\n 'astro.config.cjs',\n];\n\ninterface UserAstroConfigData {\n integrations: AstroIntegration[];\n fonts: StorybookFontFamily[];\n vitePlugins: Plugin[];\n}\n\nconst EMPTY: UserAstroConfigData = {\n integrations: [],\n fonts: [],\n vitePlugins: []\n};\n\n// Cache by resolveFrom — config rarely changes during a Storybook session and\n// several call sites read the same data. Each entry stores the in-flight\n// promise so concurrent callers share the same load.\nconst configCache = new Map<string, Promise<UserAstroConfigData>>();\n\nasync function loadUserAstroConfigData(resolveFrom: string): Promise<UserAstroConfigData> {\n let cached = configCache.get(resolveFrom);\n\n if (!cached) {\n cached = readUserAstroConfig(resolveFrom);\n configCache.set(resolveFrom, cached);\n }\n\n return cached;\n}\n\nasync function readUserAstroConfig(resolveFrom: string): Promise<UserAstroConfigData> {\n // Vite's loadConfigFromFile resolves a relative configFile against\n // process.cwd(), not the configRoot argument, so we always hand it an\n // absolute path to make the lookup deterministic regardless of where\n // Storybook is invoked from.\n const configFile = CONFIG_FILENAMES\n .map((name) => resolve(resolveFrom, name))\n .find((path) => existsSync(path));\n\n if (!configFile) {\n return EMPTY;\n }\n\n try {\n const result = await loadConfigFromFile(\n { command: 'serve', mode: 'development' },\n configFile,\n resolveFrom\n );\n\n if (!result?.config) {\n return EMPTY;\n }\n\n const config = result.config as {\n integrations?: unknown;\n fonts?: unknown;\n vite?: { plugins?: unknown };\n };\n\n return {\n integrations: extractIntegrations(config.integrations),\n fonts: extractFonts(config.fonts),\n vitePlugins: extractVitePlugins(config.vite?.plugins)\n };\n } catch (err) {\n console.warn(\n '[storybook-astro] Could not load astro.config to discover integrations / fonts / vite plugins:',\n err instanceof Error ? err.message : String(err)\n );\n\n return EMPTY;\n }\n}\n\nfunction extractIntegrations(raw: unknown): AstroIntegration[] {\n if (!raw) {\n return [];\n }\n\n // Astro allows nested arrays from conditional spreads (e.g. ...whenX(() => mdx()))\n const flat = (Array.isArray(raw) ? raw : [raw]).flat(Infinity);\n\n return flat.filter(\n (i): i is AstroIntegration =>\n Boolean(i) && typeof i === 'object' && 'name' in i && 'hooks' in i\n );\n}\n\nfunction extractFonts(raw: unknown): StorybookFontFamily[] {\n if (!Array.isArray(raw)) {\n return [];\n }\n\n return raw.filter(\n (f): f is StorybookFontFamily =>\n Boolean(f) &&\n typeof f === 'object' &&\n typeof (f as { name?: unknown }).name === 'string' &&\n typeof (f as { cssVariable?: unknown }).cssVariable === 'string' &&\n typeof (f as { provider?: unknown }).provider === 'object'\n );\n}\n\nfunction extractVitePlugins(raw: unknown): Plugin[] {\n if (!raw) {\n return [];\n }\n\n // vite.plugins accepts Plugin | Plugin[] | (Plugin | false | null | undefined)[][] etc.\n const flat = (Array.isArray(raw) ? raw : [raw]).flat(Infinity);\n\n return flat.filter(\n (p): p is Plugin =>\n Boolean(p) && typeof p === 'object' && 'name' in p && typeof (p as Plugin).name === 'string'\n );\n}\n\n/**\n * Loads integrations declared in the user's astro.config.* so that any Vite\n * plugins they register (e.g. astro-icon's virtual:astro-icon resolver) are\n * present in both the main Storybook Vite server and the internal Astro SSR\n * server. Returns an empty array on any failure so the calling code can\n * continue with only the framework-level integrations.\n */\nexport async function loadUserAstroIntegrations(resolveFrom: string): Promise<AstroIntegration[]> {\n return (await loadUserAstroConfigData(resolveFrom)).integrations;\n}\n\n/**\n * Loads the `fonts:` array from the user's astro.config.* so the Astro 6\n * Font Provider API works in Storybook without duplicating the array into\n * `framework.options.fonts`. Returns [] if the project has no fonts\n * configured or the config can't be read.\n */\nexport async function loadUserAstroFonts(resolveFrom: string): Promise<StorybookFontFamily[]> {\n return (await loadUserAstroConfigData(resolveFrom)).fonts;\n}\n\n/**\n * Loads raw Vite plugins declared at `vite.plugins` in the user's\n * astro.config.* (e.g. `@tailwindcss/vite`, `unocss/vite`). These are not\n * registered through Astro's integration API so `loadUserAstroIntegrations`\n * does not pick them up; this loader fills the gap so CSS frameworks added\n * as raw Vite plugins work in Storybook without `viteFinal`.\n */\nexport async function loadUserAstroVitePlugins(resolveFrom: string): Promise<Plugin[]> {\n return (await loadUserAstroConfigData(resolveFrom)).vitePlugins;\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAE9B,SAAS,cAAc,oBAAyE;;;ACKzF,SAAS,oBAAoB,SAA6C;AAC/E,QAAM,0BAA0B,KAAK,QAAQ,eAAe;AAE5D,SAAO;AAAA,IACL,MAAM,QAAQ;AAAA,IACd,UAAU,IAAI;AACZ,UAAI,OAAO,QAAQ,iBAAiB;AAClC,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,MAAM,KAAK,IAAI;AACb,UAAI,OAAO,yBAAyB;AAClC,eAAO,QAAQ,KAAK,EAAE;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACF;;;AChBO,SAAS,kCACd,cACA,UAAyB,CAAC,GAC1B;AACA,QAAM,mBAAmB,gBAAgB,CAAC;AAC1C,QAAM,OAAO,QAAQ,QAAQ;AAC7B,QAAM,kBAAkB,QAAQ,mBAAmB,CAAC;AAEpD,SAAO,oBAAoB;AAAA,IACzB,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,OAAO;AACL,YAAM,mBAAmB,sBAAsB,gBAAgB;AAC/D,YAAM,+BACJ,SAAS,gBAAgB,kCA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pD;AAAA,EACF,CAAC;AAKD,QAAM,WAAW,gBAAgB,WAAW,CAAC,CAAC;AAE9C,SAAO;AACT;AAEA,SAAS,mCAAmC,aAAmC;AAC7E,QAAME,WAAU,cAAc,YAAY,GAAG;AAE7C,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,UAAU,IAAY;AACpB,UAAI,OAAO,WAAW,CAAC,GAAG,WAAW,QAAQ,GAAG;AAC9C,eAAO;AAAA,MACT;AAEA,UAAI;AACF,eAAOA,SAAQ,QAAQ,IAAI;AAAA,UACzB,OAAO,CAAC,WAAW;AAAA,QACrB,CAAC;AAAA,MACH,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAe,sBAAsB,YAA2B,gBAAyB;AACvF,MAAI,CAAC,gBAAgB;AACnB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,WAAO,MAAM,4BAA4B,YAAY,gBAAgB;AAAA,MACnE,eAAe;AAAA,IACjB,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAEpE,UAAM,IAAI;AAAA,MACR,gEAAgE,cAAc,KAAK,MAAM;AAAA,IAC3F;AAAA,EACF;AACF;","names":["VIRTUAL_IDS","existsSync","resolve","require"]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
createViteServer,
|
|
6
6
|
ssrLoadModuleWithFsFallback
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7UF6LK4Z.js";
|
|
8
8
|
|
|
9
9
|
// src/testing/renderer-daemon.ts
|
|
10
10
|
import { createServer as createHttpServer } from "http";
|
|
@@ -217,4 +217,4 @@ export {
|
|
|
217
217
|
startTestingRendererDaemon,
|
|
218
218
|
renderViaTestingRendererDaemon
|
|
219
219
|
};
|
|
220
|
-
//# sourceMappingURL=chunk-
|
|
220
|
+
//# sourceMappingURL=chunk-XVVIGJV6.js.map
|
package/dist/preset.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
vitePluginAstroComponentMarker
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6RIGYMZP.js";
|
|
4
4
|
import {
|
|
5
5
|
createAstroRenderHandler,
|
|
6
6
|
ensureAstroPassthroughImageService,
|
|
@@ -10,7 +10,9 @@ import {
|
|
|
10
10
|
} from "./chunk-A4DQ67HA.js";
|
|
11
11
|
import {
|
|
12
12
|
createVirtualModule,
|
|
13
|
+
loadUserAstroFonts,
|
|
13
14
|
loadUserAstroIntegrations,
|
|
15
|
+
loadUserAstroVitePlugins,
|
|
14
16
|
resolveRulesConfigFilePath,
|
|
15
17
|
ssrLoadModuleWithFsFallback,
|
|
16
18
|
viteAstroContainerRenderersPlugin,
|
|
@@ -20,7 +22,7 @@ import {
|
|
|
20
22
|
vitePluginAstroVueFallback,
|
|
21
23
|
vitePluginStoryModuleMocks,
|
|
22
24
|
vitePluginStorybookAstroMiddleware
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-7UF6LK4Z.js";
|
|
24
26
|
import {
|
|
25
27
|
importAstroConfig
|
|
26
28
|
} from "./chunk-PUTCAN6X.js";
|
|
@@ -80,7 +82,8 @@ function viteStorybookAstroRendererPlugin(options) {
|
|
|
80
82
|
)});`,
|
|
81
83
|
"export const render = renderer.render;",
|
|
82
84
|
"export const init = renderer.init;",
|
|
83
|
-
"export const applyStyles = renderer.applyStyles;"
|
|
85
|
+
"export const applyStyles = renderer.applyStyles;",
|
|
86
|
+
"export const isStaticMode = false;"
|
|
84
87
|
].join("\n");
|
|
85
88
|
}
|
|
86
89
|
});
|
|
@@ -1404,15 +1407,23 @@ var core = {
|
|
|
1404
1407
|
var viteFinal = async (config, storybookOptions) => {
|
|
1405
1408
|
const { configType, presets, configDir } = storybookOptions;
|
|
1406
1409
|
const frameworkOptions = await presets.apply("frameworkOptions");
|
|
1410
|
+
const resolveFrom = frameworkOptions.resolveFrom ?? dirname4(configDir);
|
|
1411
|
+
const fonts = frameworkOptions.fonts === void 0 ? await loadUserAstroFonts(resolveFrom) : frameworkOptions.fonts;
|
|
1412
|
+
if (frameworkOptions.fonts === void 0 && fonts.length > 0) {
|
|
1413
|
+
console.warn(
|
|
1414
|
+
`[storybook-astro] Auto-loaded ${fonts.length} font famil${fonts.length === 1 ? "y" : "ies"} from astro.config: ${fonts.map((f) => f.cssVariable).join(", ")}`
|
|
1415
|
+
);
|
|
1416
|
+
}
|
|
1407
1417
|
const options = {
|
|
1408
1418
|
...frameworkOptions,
|
|
1409
|
-
resolveFrom
|
|
1419
|
+
resolveFrom,
|
|
1420
|
+
fonts
|
|
1410
1421
|
};
|
|
1411
1422
|
if (!config.plugins) {
|
|
1412
1423
|
config.plugins = [];
|
|
1413
1424
|
}
|
|
1414
1425
|
const integrations = options.integrations ?? [];
|
|
1415
|
-
const renderMode = options.renderMode ?? "
|
|
1426
|
+
const renderMode = options.renderMode ?? "static";
|
|
1416
1427
|
const mode = configType === "DEVELOPMENT" ? "development" : "production";
|
|
1417
1428
|
const command = configType === "DEVELOPMENT" ? "serve" : "build";
|
|
1418
1429
|
resolveSanitizationOptions(options.sanitization);
|
|
@@ -1468,6 +1479,22 @@ var viteFinal = async (config, storybookOptions) => {
|
|
|
1468
1479
|
mode,
|
|
1469
1480
|
command
|
|
1470
1481
|
);
|
|
1482
|
+
const userVitePlugins = await loadUserAstroVitePlugins(options.resolveFrom);
|
|
1483
|
+
if (userVitePlugins.length > 0) {
|
|
1484
|
+
const existingNames = /* @__PURE__ */ new Set();
|
|
1485
|
+
for (const plugin of (finalConfig.plugins ?? []).flat(Infinity)) {
|
|
1486
|
+
if (plugin && typeof plugin === "object" && typeof plugin.name === "string") {
|
|
1487
|
+
existingNames.add(plugin.name);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
const newPlugins = userVitePlugins.filter((plugin) => !existingNames.has(plugin.name));
|
|
1491
|
+
if (newPlugins.length > 0) {
|
|
1492
|
+
console.warn(
|
|
1493
|
+
`[storybook-astro] Auto-loaded ${newPlugins.length} vite plugin${newPlugins.length === 1 ? "" : "s"} from astro.config: ${newPlugins.map((p) => p.name).join(", ")}`
|
|
1494
|
+
);
|
|
1495
|
+
finalConfig.plugins = [...finalConfig.plugins ?? [], ...newPlugins];
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1471
1498
|
if (!finalConfig.optimizeDeps) {
|
|
1472
1499
|
finalConfig.optimizeDeps = {};
|
|
1473
1500
|
}
|