@storybook-astro/framework 1.3.0 → 1.4.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-N3WTUD2A.js → chunk-A4DQ67HA.js} +53 -2
- package/dist/chunk-A4DQ67HA.js.map +1 -0
- package/dist/{chunk-2EABPTOY.js → chunk-BV6V2Z4X.js} +2 -2
- package/dist/{chunk-AYYMNFI6.js → chunk-VZXGPM6P.js} +218 -34
- package/dist/chunk-VZXGPM6P.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/middleware.js +10 -2
- package/dist/middleware.js.map +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/preset.d.ts +1 -1
- package/dist/preset.js +39 -21
- package/dist/preset.js.map +1 -1
- package/dist/testing.js +3 -3
- package/dist/{types-BCpJLSTo.d.ts → types--SvYP5Ri.d.ts} +55 -0
- package/dist/{viteStorybookAstroMiddlewarePlugin-UB6ZLJ4B.js → viteStorybookAstroMiddlewarePlugin-246I5D3Y.js} +2 -2
- package/dist/vitest/global-setup.js +2 -2
- package/package.json +3 -2
- package/src/lib/resolve-aliased-island.test.ts +150 -0
- package/src/lib/resolve-aliased-island.ts +97 -0
- package/src/loadUserAstroConfig.ts +59 -0
- package/src/middleware.ts +15 -0
- package/src/productionRenderRuntime.ts +6 -2
- package/src/storySsrVite.ts +15 -2
- package/src/types.ts +9 -1
- package/src/vitePluginAstro.ts +10 -3
- package/src/vitePluginAstroBuildPrerender.ts +4 -1
- package/src/vitePluginAstroBuildShared.test.ts +25 -6
- package/src/vitePluginAstroBuildShared.ts +25 -12
- package/src/vitePluginAstroFonts.test.ts +153 -0
- package/src/vitePluginAstroFonts.ts +302 -0
- package/src/viteStorybookAstroMiddlewarePlugin.ts +20 -8
- package/dist/chunk-AYYMNFI6.js.map +0 -1
- package/dist/chunk-N3WTUD2A.js.map +0 -1
- package/src/vitePluginAstroFontsFallback.ts +0 -69
- /package/dist/{chunk-2EABPTOY.js.map → chunk-BV6V2Z4X.js.map} +0 -0
- /package/dist/{viteStorybookAstroMiddlewarePlugin-UB6ZLJ4B.js.map → viteStorybookAstroMiddlewarePlugin-246I5D3Y.js.map} +0 -0
|
@@ -544,10 +544,61 @@ function isRecord3(value) {
|
|
|
544
544
|
return typeof value === "object" && value !== null;
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
+
// src/lib/resolve-aliased-island.ts
|
|
548
|
+
import { access } from "fs/promises";
|
|
549
|
+
import { resolve } from "path";
|
|
550
|
+
import { parse } from "tsconfck";
|
|
551
|
+
var ALIAS_EXTS = [".tsx", ".ts", ".jsx", ".js", ".vue", ".svelte", ".mts", ".mjs"];
|
|
552
|
+
async function isFile(candidate) {
|
|
553
|
+
try {
|
|
554
|
+
await access(candidate);
|
|
555
|
+
return true;
|
|
556
|
+
} catch {
|
|
557
|
+
return false;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
async function resolveAliasedIsland(specifier, resolveFrom) {
|
|
561
|
+
if (!specifier || specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || specifier.startsWith("\0") || specifier.startsWith("virtual:") || specifier.startsWith("astro:") || specifier.startsWith("@astrojs/") || specifier.startsWith("@id/") || specifier.startsWith("/@fs/")) {
|
|
562
|
+
return void 0;
|
|
563
|
+
}
|
|
564
|
+
let result;
|
|
565
|
+
try {
|
|
566
|
+
result = await parse(resolve(resolveFrom, "tsconfig.json"));
|
|
567
|
+
} catch {
|
|
568
|
+
return void 0;
|
|
569
|
+
}
|
|
570
|
+
const compilerOptions = result.tsconfig?.compilerOptions ?? {};
|
|
571
|
+
const paths = compilerOptions.paths ?? {};
|
|
572
|
+
if (Object.keys(paths).length === 0) {
|
|
573
|
+
return void 0;
|
|
574
|
+
}
|
|
575
|
+
const tsconfigDir = result.tsconfigFile ? resolve(result.tsconfigFile, "..") : resolveFrom;
|
|
576
|
+
const root = compilerOptions.baseUrl ? resolve(tsconfigDir, compilerOptions.baseUrl) : tsconfigDir;
|
|
577
|
+
for (const [pattern, targets] of Object.entries(paths)) {
|
|
578
|
+
const prefix = pattern.replace(/\*$/, "");
|
|
579
|
+
if (!specifier.startsWith(prefix)) {
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
const rest = specifier.slice(prefix.length);
|
|
583
|
+
for (const target of targets) {
|
|
584
|
+
const resolvedTarget = target.replace(/\*$/, "");
|
|
585
|
+
const base = resolve(root, resolvedTarget, rest);
|
|
586
|
+
const candidates = [base, ...ALIAS_EXTS.map((ext) => `${base}${ext}`)];
|
|
587
|
+
for (const candidate of candidates) {
|
|
588
|
+
if (await isFile(candidate)) {
|
|
589
|
+
return candidate.replace(/\\/g, "/");
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return void 0;
|
|
595
|
+
}
|
|
596
|
+
|
|
547
597
|
export {
|
|
548
598
|
ensureAstroPassthroughImageService,
|
|
549
599
|
resolveSanitizationOptions,
|
|
550
600
|
serializeSanitizationOptions,
|
|
551
|
-
createAstroRenderHandler
|
|
601
|
+
createAstroRenderHandler,
|
|
602
|
+
resolveAliasedIsland
|
|
552
603
|
};
|
|
553
|
-
//# sourceMappingURL=chunk-
|
|
604
|
+
//# sourceMappingURL=chunk-A4DQ67HA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/astroImageService.ts","../src/lib/sanitization.ts","../src/lib/revive-dates.ts","../src/storyRulesRuntime.ts","../src/astroRenderHandler.ts","../src/lib/resolve-aliased-island.ts"],"sourcesContent":["export function ensureAstroPassthroughImageService() {\n if (!globalThis.astroAsset) {\n (globalThis as Record<string, unknown>).astroAsset = {};\n }\n\n (globalThis.astroAsset as Record<string, unknown>).imageService = {\n propertiesToHash: ['src'],\n validateOptions(options: Record<string, unknown>) {\n return options;\n },\n getURL(options: { src: unknown }) {\n const src = options.src;\n\n if (\n src != null &&\n typeof src === 'object' &&\n 'src' in src &&\n typeof (src as Record<string, unknown>).src === 'string'\n ) {\n return (src as Record<string, unknown>).src as string;\n }\n\n return typeof src === 'string' ? src : '';\n },\n getHTMLAttributes(options: Record<string, unknown>) {\n const {\n src,\n width,\n height,\n format,\n quality,\n densities,\n widths,\n formats,\n layout,\n priority,\n fit,\n position,\n background,\n ...attrs\n } = options;\n const srcObject =\n src != null && typeof src === 'object' ? (src as Record<string, unknown>) : null;\n\n return {\n ...attrs,\n width: width ?? srcObject?.width,\n height: height ?? srcObject?.height,\n loading: (attrs.loading as string | undefined) ?? 'lazy',\n decoding: (attrs.decoding as string | undefined) ?? 'async'\n };\n },\n getSrcSet() {\n return [];\n }\n };\n}\n","import sanitizeHtml from 'sanitize-html';\nimport type { IOptions } from 'sanitize-html';\n\ntype SanitizationPayload = {\n args: Record<string, unknown>;\n slots: Record<string, unknown>;\n};\n\nexport type SanitizationOptions = {\n enabled?: boolean;\n args?: string[];\n slots?: string[];\n sanitizeHtml?: IOptions;\n};\n\nexport type ResolvedSanitizationOptions = {\n enabled: boolean;\n args: string[];\n slots: string[];\n sanitizeHtml: IOptions;\n};\n\nconst DEFAULT_SANITIZE_HTML_OPTIONS: IOptions = {\n allowedTags: [\n 'a',\n 'abbr',\n 'b',\n 'blockquote',\n 'br',\n 'caption',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'dd',\n 'details',\n 'dfn',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'figure',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'i',\n 'img',\n 'kbd',\n 'li',\n 'mark',\n 'ol',\n 'p',\n 'pre',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'u',\n 'ul',\n 'var',\n 'wbr'\n ],\n allowedAttributes: {\n '*': [\n 'aria-describedby',\n 'aria-hidden',\n 'aria-label',\n 'aria-labelledby',\n 'class',\n 'id',\n 'lang',\n 'role',\n 'title'\n ],\n a: ['href', 'name', 'target', 'rel'],\n img: ['src', 'srcset', 'alt', 'title', 'width', 'height', 'loading', 'decoding'],\n td: ['colspan', 'rowspan'],\n th: ['colspan', 'rowspan', 'scope'],\n time: ['datetime']\n },\n allowedSchemes: ['http', 'https', 'mailto', 'tel', 'data'],\n allowedSchemesByTag: {\n a: ['http', 'https', 'mailto', 'tel'],\n img: ['http', 'https', 'data']\n },\n allowedSchemesAppliedToAttributes: ['href', 'src', 'cite', 'srcset'],\n allowProtocolRelative: false,\n disallowedTagsMode: 'discard',\n enforceHtmlBoundary: true,\n parseStyleAttributes: false\n};\n\nexport function resolveSanitizationOptions(options?: SanitizationOptions): ResolvedSanitizationOptions {\n if (!options) {\n return {\n enabled: true,\n args: [],\n slots: ['**'],\n sanitizeHtml: mergeSanitizeHtmlOptions()\n };\n }\n\n const enabled = options.enabled ?? true;\n const args = normalizePathList(options.args, 'framework.options.sanitization.args');\n const slots =\n options.slots === undefined\n ? ['**']\n : normalizePathList(options.slots, 'framework.options.sanitization.slots');\n\n return {\n enabled,\n args,\n slots,\n sanitizeHtml: mergeSanitizeHtmlOptions(options.sanitizeHtml)\n };\n}\n\nexport function sanitizeRenderPayload(\n payload: SanitizationPayload,\n options: ResolvedSanitizationOptions\n): SanitizationPayload {\n if (!options.enabled) {\n return payload;\n }\n\n const sanitizedArgs =\n options.args.length > 0\n ? sanitizeRecord(payload.args, options.args, options.sanitizeHtml)\n : payload.args;\n\n const sanitizedSlots =\n options.slots.length > 0\n ? sanitizeRecord(payload.slots, options.slots, options.sanitizeHtml)\n : payload.slots;\n\n return {\n args: sanitizedArgs,\n slots: sanitizedSlots\n };\n}\n\nexport function serializeSanitizationOptions(options?: SanitizationOptions): string {\n if (!options) {\n return 'undefined';\n }\n\n assertNoFunctions(options.sanitizeHtml, 'framework.options.sanitization.sanitizeHtml');\n\n const state = {\n seen: new WeakSet<object>()\n };\n\n return serializeValue(options, 'framework.options.sanitization', state);\n}\n\nfunction mergeSanitizeHtmlOptions(userOptions?: IOptions): IOptions {\n const merged: IOptions = {\n ...DEFAULT_SANITIZE_HTML_OPTIONS,\n ...userOptions\n };\n\n if (\n isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes) &&\n isRecord(userOptions?.allowedAttributes)\n ) {\n merged.allowedAttributes = {\n ...DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes,\n ...userOptions.allowedAttributes\n };\n }\n\n if (isRecord(userOptions?.allowedClasses)) {\n merged.allowedClasses = {\n ...(isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses)\n ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses\n : {}),\n ...userOptions.allowedClasses\n };\n }\n\n if (isRecord(userOptions?.allowedStyles)) {\n merged.allowedStyles = {\n ...(isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles)\n ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles\n : {}),\n ...userOptions.allowedStyles\n };\n }\n\n return merged;\n}\n\nfunction normalizePathList(value: unknown, path: string): string[] {\n if (value === undefined) {\n return [];\n }\n\n if (!Array.isArray(value)) {\n throw new Error(`${path} must be an array of dot-path patterns.`);\n }\n\n const unique = new Set<string>();\n\n value.forEach((entry, index) => {\n if (typeof entry !== 'string') {\n throw new Error(`${path}[${index}] must be a string.`);\n }\n\n const normalized = entry.trim();\n\n if (!normalized) {\n throw new Error(`${path}[${index}] cannot be an empty string.`);\n }\n\n unique.add(normalized);\n });\n\n return Array.from(unique);\n}\n\nfunction sanitizeRecord(\n record: Record<string, unknown>,\n patterns: string[],\n options: IOptions\n): Record<string, unknown> {\n const sanitized: Record<string, unknown> = {};\n\n Object.entries(record).forEach(([key, value]) => {\n sanitized[key] = sanitizeValue(value, key, patterns, options);\n });\n\n return sanitized;\n}\n\nfunction sanitizeValue(\n value: unknown,\n currentPath: string,\n patterns: string[],\n options: IOptions\n): unknown {\n if (typeof value === 'string') {\n if (shouldSanitizePath(currentPath, patterns)) {\n return sanitizeHtml(value, options);\n }\n\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item, index) => {\n const nextPath = `${currentPath}.${index}`;\n\n return sanitizeValue(item, nextPath, patterns, options);\n });\n }\n\n if (isRecord(value)) {\n const sanitized: Record<string, unknown> = {};\n\n Object.entries(value).forEach(([key, nestedValue]) => {\n const nextPath = `${currentPath}.${key}`;\n\n sanitized[key] = sanitizeValue(nestedValue, nextPath, patterns, options);\n });\n\n return sanitized;\n }\n\n return value;\n}\n\nfunction shouldSanitizePath(path: string, patterns: string[]): boolean {\n return patterns.some((pattern) => matchesPathPattern(path, pattern));\n}\n\nfunction matchesPathPattern(path: string, pattern: string): boolean {\n const pathSegments = path.split('.');\n const patternSegments = pattern.split('.');\n\n return matchSegments(pathSegments, patternSegments);\n}\n\nfunction serializeValue(value: unknown, path: string, state: { seen: WeakSet<object> }): string {\n if (value === null) {\n return 'null';\n }\n\n if (value === undefined) {\n return 'undefined';\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return JSON.stringify(value);\n }\n\n if (value instanceof RegExp) {\n return value.toString();\n }\n\n if (Array.isArray(value)) {\n const serializedItems = value.map((item, index) =>\n serializeValue(item, `${path}[${index}]`, state)\n );\n\n return `[${serializedItems.join(', ')}]`;\n }\n\n if (isRecord(value)) {\n if (state.seen.has(value)) {\n throw new Error(`${path} contains a circular reference.`);\n }\n\n state.seen.add(value);\n\n const serializedEntries = Object.entries(value)\n .filter(([, nestedValue]) => nestedValue !== undefined)\n .map(([key, nestedValue]) => {\n const serializedNestedValue = serializeValue(nestedValue, `${path}.${key}`, state);\n\n return `${JSON.stringify(key)}: ${serializedNestedValue}`;\n });\n\n return `{ ${serializedEntries.join(', ')} }`;\n }\n\n throw new Error(\n `${path} contains an unsupported value of type ${typeof value}. ` +\n 'Only plain objects, arrays, primitives, and regular expressions are supported.'\n );\n}\n\nfunction assertNoFunctions(value: unknown, path: string): void {\n const state = {\n seen: new WeakSet<object>()\n };\n\n assertNoFunctionsRecursive(value, path, state);\n}\n\nfunction assertNoFunctionsRecursive(\n value: unknown,\n path: string,\n state: { seen: WeakSet<object> }\n): void {\n if (typeof value === 'function') {\n throw new Error(\n `${path} cannot contain functions. ` +\n 'Function-valued sanitization hooks are not supported in framework options.'\n );\n }\n\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n assertNoFunctionsRecursive(item, `${path}[${index}]`, state);\n });\n\n return;\n }\n\n if (isRecord(value)) {\n if (state.seen.has(value)) {\n return;\n }\n\n state.seen.add(value);\n\n Object.entries(value).forEach(([key, nestedValue]) => {\n assertNoFunctionsRecursive(nestedValue, `${path}.${key}`, state);\n });\n }\n}\n\nfunction matchSegments(pathSegments: string[], patternSegments: string[]): boolean {\n if (patternSegments.length === 0) {\n return pathSegments.length === 0;\n }\n\n const [patternHead, ...patternTail] = patternSegments;\n\n if (patternHead === '**') {\n if (patternTail.length === 0) {\n return true;\n }\n\n for (let index = 0; index <= pathSegments.length; index += 1) {\n const remainingPath = pathSegments.slice(index);\n\n if (matchSegments(remainingPath, patternTail)) {\n return true;\n }\n }\n\n return false;\n }\n\n if (pathSegments.length === 0) {\n return false;\n }\n\n const [pathHead, ...pathTail] = pathSegments;\n\n if (patternHead === '*' || patternHead === pathHead) {\n return matchSegments(pathTail, patternTail);\n }\n\n return false;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n if (Array.isArray(value) || value instanceof RegExp) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n\n return prototype === Object.prototype || prototype === null;\n}\n","/**\n * Revives Date objects that were lost during JSON serialization.\n *\n * When story args travel over Vite HMR (dev) or HTTP (server mode), Date\n * values are serialized by JSON.stringify into ISO 8601 strings like\n * \"2025-04-12T00:00:00.000Z\". This function walks the args tree and\n * converts those strings back into Date objects so Astro components\n * receive the types they expect.\n *\n * Only the exact format produced by Date.toJSON() is matched\n * (YYYY-MM-DDTHH:mm:ss.sssZ) to minimize false positives.\n */\n\n// Matches the exact output of Date.toJSON() / JSON.stringify(date).\nconst ISO_DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$/;\n\nexport function reviveDateStrings(args: Record<string, unknown>): Record<string, unknown> {\n const revived: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(args)) {\n revived[key] = reviveValue(value);\n }\n\n return revived;\n}\n\nfunction reviveValue(value: unknown): unknown {\n if (typeof value === 'string' && ISO_DATE_PATTERN.test(value)) {\n const date = new Date(value);\n\n if (!Number.isNaN(date.getTime())) {\n return date;\n }\n\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map(reviveValue);\n }\n\n if (isRecord(value)) {\n return reviveDateStrings(value);\n }\n\n return value;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","import { withStoryModuleMocks } from './module-mocks.ts';\nimport { selectStoryRules, withStoryRuleCleanups, type StoryRuleSelection } from './rules.ts';\nimport type { RenderStoryInput } from './types.ts';\n\nexport type ResolveRulesConfigModule = () => unknown | Promise<unknown>;\n\ntype RunWithStoryRulesOptions = {\n story?: RenderStoryInput;\n rulesConfigFilePath?: string;\n resolveRulesConfigModule?: ResolveRulesConfigModule;\n invalidateModuleGraph?: () => void;\n};\n\nexport async function runWithStoryRules<T>(\n options: RunWithStoryRulesOptions,\n callback: (selection: StoryRuleSelection) => Promise<T>\n): Promise<T> {\n const rulesConfigModule = options.resolveRulesConfigModule\n ? await options.resolveRulesConfigModule()\n : undefined;\n const selectedRules = await selectStoryRules({\n configModule: rulesConfigModule,\n configFilePath: options.rulesConfigFilePath,\n story: options.story\n });\n\n if (selectedRules.moduleMocks.size > 0) {\n options.invalidateModuleGraph?.();\n }\n\n return withStoryRuleCleanups(selectedRules.cleanups, async () => {\n return withStoryModuleMocks(selectedRules.moduleMocks, async () => callback(selectedRules));\n });\n}\n","import type { experimental_AstroContainer as AstroContainer } from 'astro/container';\nimport type { SanitizationOptions } from './lib/sanitization.ts';\nimport { resolveSanitizationOptions, sanitizeRenderPayload } from './lib/sanitization.ts';\nimport { reviveDateStrings } from './lib/revive-dates.ts';\nimport { runWithStoryRules, type ResolveRulesConfigModule } from './storyRulesRuntime.ts';\nimport type { RenderStoryInput } from './types.ts';\n\ntype AstroCreateResult = {\n createAstro?: (...args: unknown[]) => unknown;\n};\n\ntype AstroComponentFactory = ((\n result: AstroCreateResult,\n props: unknown,\n slots: unknown\n) => unknown) & {\n isAstroComponentFactory?: boolean;\n moduleId?: string;\n propagation?: unknown;\n};\n\nexport type HandlerProps = {\n component: string;\n args?: Record<string, unknown>;\n slots?: Record<string, unknown>;\n story?: RenderStoryInput;\n};\n\ntype CreateAstroRenderHandlerOptions = {\n container: Awaited<ReturnType<typeof AstroContainer.create>>;\n sanitization?: SanitizationOptions;\n rulesConfigFilePath?: string;\n resolveRulesConfigModule?: ResolveRulesConfigModule;\n loadModule: (id: string) => Promise<{ default: unknown }>;\n invalidateModuleGraph?: () => void;\n};\n\nexport function createAstroRenderHandler(options: CreateAstroRenderHandlerOptions) {\n const sanitizationOptions = resolveSanitizationOptions(options.sanitization);\n const componentCache = new Map<string, Promise<AstroComponentFactory>>();\n let renderQueue = Promise.resolve<void>(undefined);\n\n async function loadPatchedComponent(componentId: string, useCache = true) {\n if (!useCache) {\n const { default: component } = await options.loadModule(componentId);\n\n return patchCreateAstroCompat(component);\n }\n\n if (!componentCache.has(componentId)) {\n componentCache.set(\n componentId,\n (async () => {\n const { default: component } = await options.loadModule(componentId);\n\n return patchCreateAstroCompat(component);\n })()\n );\n }\n\n const cachedComponent = componentCache.get(componentId);\n\n if (!cachedComponent) {\n throw new Error(`Failed to load Astro component: ${componentId}`);\n }\n\n try {\n return await cachedComponent;\n } catch (error) {\n componentCache.delete(componentId);\n throw error;\n }\n }\n\n return async function handler(data: HandlerProps) {\n const executeRender = async () => {\n return runWithStoryRules(\n {\n story: data.story,\n rulesConfigFilePath: options.rulesConfigFilePath,\n resolveRulesConfigModule: options.resolveRulesConfigModule,\n invalidateModuleGraph: options.invalidateModuleGraph\n },\n async (selectedRules) => {\n const patchedComponent = await loadPatchedComponent(\n data.component,\n selectedRules.moduleMocks.size === 0\n );\n const processedArgs = await processImageMetadata(data.args ?? {});\n const revivedArgs = reviveDateStrings(processedArgs);\n const sanitizedPayload = sanitizeRenderPayload(\n {\n args: revivedArgs,\n slots: data.slots ?? {}\n },\n sanitizationOptions\n );\n\n return options.container.renderToString(\n patchedComponent as Parameters<typeof options.container.renderToString>[0],\n {\n props: sanitizedPayload.args,\n slots: sanitizedPayload.slots\n }\n );\n }\n );\n };\n\n const resultPromise = renderQueue.then(executeRender, executeRender);\n\n renderQueue = resultPromise.then(\n () => undefined,\n () => undefined\n );\n\n return resultPromise;\n };\n}\n\nexport function patchCreateAstroCompat(component: unknown): AstroComponentFactory {\n if (typeof component !== 'function') {\n throw new Error('Expected Astro component factory to be a function.');\n }\n\n const originalComponent = component as AstroComponentFactory;\n const wrapped = ((result: AstroCreateResult, props: unknown, slots: unknown) => {\n if (result && typeof result.createAstro === 'function') {\n const originalCreateAstro = result.createAstro;\n const runtimeExpectsAstroGlobal = originalCreateAstro.length >= 3;\n\n result.createAstro = (...args: unknown[]) => {\n if (args.length === 3 && !runtimeExpectsAstroGlobal) {\n return originalCreateAstro(args[1], args[2]);\n }\n\n return originalCreateAstro(...args);\n };\n }\n\n return originalComponent(result, props, slots);\n }) as AstroComponentFactory;\n\n wrapped.isAstroComponentFactory = originalComponent.isAstroComponentFactory;\n wrapped.moduleId = originalComponent.moduleId;\n wrapped.propagation = originalComponent.propagation;\n\n return wrapped;\n}\n\nasync function processImageMetadata(\n args: Record<string, unknown>\n): Promise<Record<string, unknown>> {\n const processed: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(args)) {\n if (isImageMetadata(value)) {\n // Keep ImageMetadata as an object so Astro's image pipeline still\n // recognizes it as an imported image and skips local path validation.\n processed[key] = value;\n\n continue;\n }\n\n if (Array.isArray(value)) {\n processed[key] = await Promise.all(\n value.map(async (item) => {\n if (isImageMetadata(item)) {\n return item;\n }\n\n if (isRecord(item)) {\n return processImageMetadata(item);\n }\n\n return item;\n })\n );\n\n continue;\n }\n\n if (isRecord(value)) {\n processed[key] = await processImageMetadata(value);\n\n continue;\n }\n\n processed[key] = value;\n }\n\n return processed;\n}\n\nfunction isImageMetadata(value: unknown): value is Record<string, unknown> {\n return (\n isRecord(value) &&\n typeof value.src === 'string' &&\n ('width' in value || 'height' in value || 'format' in value)\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n","import { access } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { parse } from 'tsconfck';\n\n// Islands embedded in `.astro` components are frequently imported through a\n// tsconfig path alias (e.g. `@/components/Counter`). The raw aliased specifier\n// is baked into `<astro-island component-url>` and `import()`d verbatim, so it\n// must be turned into an on-disk path before it can hydrate. This helper is\n// used as a last resort after the existing resolution has already had its\n// chance.\n\nconst ALIAS_EXTS = ['.tsx', '.ts', '.jsx', '.js', '.vue', '.svelte', '.mts', '.mjs'];\n\nasync function isFile(candidate: string): Promise<boolean> {\n try {\n await access(candidate);\n\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Resolves a tsconfig-aliased island specifier (e.g. `@/components/Counter`)\n * to an absolute on-disk file path, or `undefined` when it is not a tsconfig\n * alias or no matching file exists. Already-resolvable specifiers are skipped\n * so this runs only as a genuine last resort.\n */\nexport async function resolveAliasedIsland(\n specifier: string,\n resolveFrom: string\n): Promise<string | undefined> {\n // Skip specifiers the existing resolution can already handle.\n if (\n !specifier ||\n specifier.startsWith('./') ||\n specifier.startsWith('../') ||\n specifier.startsWith('/') ||\n specifier.startsWith('\\0') ||\n specifier.startsWith('virtual:') ||\n specifier.startsWith('astro:') ||\n specifier.startsWith('@astrojs/') ||\n specifier.startsWith('@id/') ||\n specifier.startsWith('/@fs/')\n ) {\n return undefined;\n }\n\n let result;\n\n try {\n result = await parse(resolve(resolveFrom, 'tsconfig.json'));\n } catch {\n return undefined;\n }\n\n const compilerOptions = result.tsconfig?.compilerOptions ?? {};\n const paths: Record<string, string[]> = compilerOptions.paths ?? {};\n\n if (Object.keys(paths).length === 0) {\n return undefined;\n }\n\n // tsconfig paths resolve relative to baseUrl when present, otherwise the\n // tsconfig directory (which tsconfck gives us as the tsconfig file's dir).\n const tsconfigDir = result.tsconfigFile\n ? resolve(result.tsconfigFile, '..')\n : resolveFrom;\n const root = compilerOptions.baseUrl\n ? resolve(tsconfigDir, compilerOptions.baseUrl)\n : tsconfigDir;\n\n for (const [pattern, targets] of Object.entries(paths)) {\n const prefix = pattern.replace(/\\*$/, '');\n\n if (!specifier.startsWith(prefix)) {\n continue;\n }\n\n const rest = specifier.slice(prefix.length);\n\n for (const target of targets) {\n const resolvedTarget = target.replace(/\\*$/, '');\n const base = resolve(root, resolvedTarget, rest);\n const candidates = [base, ...ALIAS_EXTS.map((ext) => `${base}${ext}`)];\n\n for (const candidate of candidates) {\n if (await isFile(candidate)) {\n return candidate.replace(/\\\\/g, '/');\n }\n }\n }\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;AAAO,SAAS,qCAAqC;AACnD,MAAI,CAAC,WAAW,YAAY;AAC1B,IAAC,WAAuC,aAAa,CAAC;AAAA,EACxD;AAEA,EAAC,WAAW,WAAuC,eAAe;AAAA,IAChE,kBAAkB,CAAC,KAAK;AAAA,IACxB,gBAAgB,SAAkC;AAChD,aAAO;AAAA,IACT;AAAA,IACA,OAAO,SAA2B;AAChC,YAAM,MAAM,QAAQ;AAEpB,UACE,OAAO,QACP,OAAO,QAAQ,YACf,SAAS,OACT,OAAQ,IAAgC,QAAQ,UAChD;AACA,eAAQ,IAAgC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S,GAAG;AAC3B,iBAAO,UAAU,QAAQ,OAAO,GAAG;AAAA,QACrC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":["isRecord","isRecord"]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
createViteServer,
|
|
6
6
|
ssrLoadModuleWithFsFallback
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VZXGPM6P.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-BV6V2Z4X.js.map
|
|
@@ -184,46 +184,182 @@ function buildClientRenderer(integration) {
|
|
|
184
184
|
return "";
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
// src/
|
|
188
|
-
|
|
187
|
+
// src/vitePluginAstroFonts.ts
|
|
188
|
+
import { pathToFileURL } from "url";
|
|
189
|
+
var DEFAULTS = {
|
|
190
|
+
weights: ["400"],
|
|
191
|
+
styles: ["normal", "italic"],
|
|
192
|
+
subsets: ["latin"],
|
|
193
|
+
formats: ["woff2"],
|
|
194
|
+
fallbacks: ["sans-serif"]
|
|
195
|
+
};
|
|
196
|
+
var VIRTUAL_INTERNAL_ID = "virtual:astro:assets/fonts/internal";
|
|
197
|
+
var VIRTUAL_RUNTIME_ID = "virtual:astro:assets/fonts/runtime";
|
|
198
|
+
var VIRTUAL_RUNTIME_RESOLVER_ID = "virtual:astro:assets/fonts/runtime/font-file-url-resolver";
|
|
199
|
+
var PACKAGE_RUNTIME_IDS = ["astro/assets/fonts/runtime", "astro/assets/fonts/runtime.js"];
|
|
200
|
+
var RUNTIME_STUB = `
|
|
189
201
|
export const fontData = {};
|
|
190
202
|
export function createGetFontData(fontsMod) {
|
|
191
203
|
return fontsMod?.fontDataByCssVariable ?? {};
|
|
192
204
|
}
|
|
205
|
+
export const experimental_getFontFileURL = () => undefined;
|
|
193
206
|
`;
|
|
194
|
-
var
|
|
195
|
-
export const
|
|
196
|
-
export const fontDataByCssVariable = {};
|
|
207
|
+
var RESOLVER_STUB = `
|
|
208
|
+
export const runtimeFontFileUrlResolver = { resolve: () => undefined };
|
|
197
209
|
`;
|
|
198
|
-
function
|
|
199
|
-
const
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
210
|
+
function vitePluginAstroFonts(options = {}) {
|
|
211
|
+
const families = options.fonts ?? [];
|
|
212
|
+
const rootDir = options.root ?? process.cwd();
|
|
213
|
+
const root = pathToFileURL(rootDir.endsWith("/") ? rootDir : rootDir + "/");
|
|
214
|
+
let resolved = null;
|
|
215
|
+
let resolvePromise = null;
|
|
216
|
+
const ensureResolved = async () => {
|
|
217
|
+
if (!resolvePromise) {
|
|
218
|
+
resolvePromise = resolveAllFamilies(families, root);
|
|
219
|
+
}
|
|
220
|
+
resolved = await resolvePromise;
|
|
221
|
+
return resolved;
|
|
222
|
+
};
|
|
204
223
|
return {
|
|
205
|
-
name: "storybook-astro-fonts
|
|
206
|
-
// Must run before vite:resolve to intercept virtual modules
|
|
207
|
-
// before Vite tries to resolve them as Node package imports
|
|
224
|
+
name: "storybook-astro-fonts",
|
|
208
225
|
enforce: "pre",
|
|
226
|
+
async buildStart() {
|
|
227
|
+
await ensureResolved();
|
|
228
|
+
},
|
|
209
229
|
resolveId(id) {
|
|
210
|
-
if (id ===
|
|
211
|
-
return
|
|
230
|
+
if (id === VIRTUAL_INTERNAL_ID) {
|
|
231
|
+
return "\0" + VIRTUAL_INTERNAL_ID;
|
|
212
232
|
}
|
|
213
|
-
if (id ===
|
|
214
|
-
return
|
|
233
|
+
if (id === VIRTUAL_RUNTIME_ID) {
|
|
234
|
+
return "\0" + VIRTUAL_RUNTIME_ID;
|
|
215
235
|
}
|
|
216
|
-
if (id ===
|
|
217
|
-
return
|
|
236
|
+
if (id === VIRTUAL_RUNTIME_RESOLVER_ID) {
|
|
237
|
+
return "\0" + VIRTUAL_RUNTIME_RESOLVER_ID;
|
|
218
238
|
}
|
|
239
|
+
if (PACKAGE_RUNTIME_IDS.includes(id)) {
|
|
240
|
+
return "\0storybook:astro-fonts-runtime";
|
|
241
|
+
}
|
|
242
|
+
return void 0;
|
|
219
243
|
},
|
|
220
|
-
load(id) {
|
|
221
|
-
if (id ===
|
|
222
|
-
|
|
244
|
+
async load(id) {
|
|
245
|
+
if (id === "\0" + VIRTUAL_INTERNAL_ID) {
|
|
246
|
+
const data = resolved ?? await ensureResolved();
|
|
247
|
+
return {
|
|
248
|
+
code: `export const componentDataByCssVariable = new Map(${JSON.stringify(data.componentEntries)});
|
|
249
|
+
export const fontDataByCssVariable = ${JSON.stringify(data.fontDataByCssVariable)};
|
|
250
|
+
`
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (id === "\0" + VIRTUAL_RUNTIME_ID || id === "\0storybook:astro-fonts-runtime") {
|
|
254
|
+
return { code: RUNTIME_STUB };
|
|
223
255
|
}
|
|
224
|
-
if (id ===
|
|
225
|
-
return { code:
|
|
256
|
+
if (id === "\0" + VIRTUAL_RUNTIME_RESOLVER_ID) {
|
|
257
|
+
return { code: RESOLVER_STUB };
|
|
226
258
|
}
|
|
259
|
+
return void 0;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
async function resolveAllFamilies(families, root) {
|
|
264
|
+
const componentEntries = [];
|
|
265
|
+
const fontDataByCssVariable = {};
|
|
266
|
+
const storage = createMemoryStorage();
|
|
267
|
+
for (const family of families) {
|
|
268
|
+
try {
|
|
269
|
+
if (family.provider.init) {
|
|
270
|
+
await family.provider.init({ storage, root });
|
|
271
|
+
}
|
|
272
|
+
const result = await family.provider.resolveFont({
|
|
273
|
+
familyName: family.name,
|
|
274
|
+
weights: (family.weights ?? DEFAULTS.weights).map(String),
|
|
275
|
+
styles: family.styles ?? [...DEFAULTS.styles],
|
|
276
|
+
subsets: family.subsets ?? [...DEFAULTS.subsets],
|
|
277
|
+
formats: family.formats ?? [...DEFAULTS.formats]
|
|
278
|
+
});
|
|
279
|
+
const faces = result?.fonts ?? [];
|
|
280
|
+
if (faces.length === 0) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
componentEntries.push([
|
|
284
|
+
family.cssVariable,
|
|
285
|
+
{ css: buildFamilyCss(family, faces), preloads: [] }
|
|
286
|
+
]);
|
|
287
|
+
fontDataByCssVariable[family.cssVariable] = faces.map(toFontData);
|
|
288
|
+
} catch (err) {
|
|
289
|
+
console.warn(
|
|
290
|
+
`[storybook-astro-fonts] Failed to resolve font family "${family.name}":`,
|
|
291
|
+
err instanceof Error ? err.message : err
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return { componentEntries, fontDataByCssVariable };
|
|
296
|
+
}
|
|
297
|
+
function buildFamilyCss(family, faces) {
|
|
298
|
+
const fallbacks = family.fallbacks ?? [...DEFAULTS.fallbacks];
|
|
299
|
+
const familyList = [JSON.stringify(family.name), ...fallbacks].join(", ");
|
|
300
|
+
const faceBlocks = faces.map((face) => buildFontFaceBlock(family, face)).join("\n");
|
|
301
|
+
const rootRule = `:root { ${family.cssVariable}: ${familyList}; }`;
|
|
302
|
+
return `${faceBlocks}
|
|
303
|
+
${rootRule}`;
|
|
304
|
+
}
|
|
305
|
+
function buildFontFaceBlock(family, face) {
|
|
306
|
+
const src = face.src.map((source) => {
|
|
307
|
+
if (source.url) {
|
|
308
|
+
const format = source.format ? ` format(${JSON.stringify(source.format)})` : "";
|
|
309
|
+
const tech = source.tech ? ` tech(${source.tech})` : "";
|
|
310
|
+
return `url(${JSON.stringify(source.url)})${format}${tech}`;
|
|
311
|
+
}
|
|
312
|
+
if (source.name) {
|
|
313
|
+
return `local(${JSON.stringify(source.name)})`;
|
|
314
|
+
}
|
|
315
|
+
return "";
|
|
316
|
+
}).filter(Boolean).join(", ");
|
|
317
|
+
const descriptors = [
|
|
318
|
+
`font-family: ${JSON.stringify(family.name)};`,
|
|
319
|
+
`src: ${src};`,
|
|
320
|
+
`font-display: ${family.display ?? "swap"};`
|
|
321
|
+
];
|
|
322
|
+
if (face.weight !== void 0) {
|
|
323
|
+
const weight = Array.isArray(face.weight) ? face.weight.join(" ") : String(face.weight);
|
|
324
|
+
descriptors.push(`font-weight: ${weight};`);
|
|
325
|
+
}
|
|
326
|
+
if (face.style) {
|
|
327
|
+
descriptors.push(`font-style: ${face.style};`);
|
|
328
|
+
}
|
|
329
|
+
if (face.unicodeRange?.length) {
|
|
330
|
+
descriptors.push(`unicode-range: ${face.unicodeRange.join(", ")};`);
|
|
331
|
+
}
|
|
332
|
+
if (face.featureSettings) {
|
|
333
|
+
descriptors.push(`font-feature-settings: ${face.featureSettings};`);
|
|
334
|
+
}
|
|
335
|
+
if (face.variationSettings) {
|
|
336
|
+
descriptors.push(`font-variation-settings: ${face.variationSettings};`);
|
|
337
|
+
}
|
|
338
|
+
return `@font-face { ${descriptors.join(" ")} }`;
|
|
339
|
+
}
|
|
340
|
+
function toFontData(face) {
|
|
341
|
+
return {
|
|
342
|
+
src: face.src.filter((source) => source.url).map((source) => ({ url: source.url, format: source.format, tech: source.tech })),
|
|
343
|
+
weight: face.weight !== void 0 ? Array.isArray(face.weight) ? face.weight.join(" ") : String(face.weight) : void 0,
|
|
344
|
+
style: face.style
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function createMemoryStorage() {
|
|
348
|
+
const store = /* @__PURE__ */ new Map();
|
|
349
|
+
return {
|
|
350
|
+
async getItem(key, init) {
|
|
351
|
+
if (store.has(key)) {
|
|
352
|
+
return store.get(key);
|
|
353
|
+
}
|
|
354
|
+
if (init) {
|
|
355
|
+
const value = await init();
|
|
356
|
+
store.set(key, value);
|
|
357
|
+
return value;
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
},
|
|
361
|
+
async setItem(key, value) {
|
|
362
|
+
store.set(key, value);
|
|
227
363
|
}
|
|
228
364
|
};
|
|
229
365
|
}
|
|
@@ -394,6 +530,48 @@ function resolveConfigFilePath(filePath) {
|
|
|
394
530
|
return void 0;
|
|
395
531
|
}
|
|
396
532
|
|
|
533
|
+
// src/loadUserAstroConfig.ts
|
|
534
|
+
import { loadConfigFromFile } from "vite";
|
|
535
|
+
import { existsSync as existsSync2 } from "fs";
|
|
536
|
+
import { resolve as resolve2 } from "path";
|
|
537
|
+
var CONFIG_FILENAMES = [
|
|
538
|
+
"astro.config.ts",
|
|
539
|
+
"astro.config.mjs",
|
|
540
|
+
"astro.config.js",
|
|
541
|
+
"astro.config.cjs"
|
|
542
|
+
];
|
|
543
|
+
async function loadUserAstroIntegrations(resolveFrom) {
|
|
544
|
+
const configFile = CONFIG_FILENAMES.find((name) => existsSync2(resolve2(resolveFrom, name)));
|
|
545
|
+
if (!configFile) {
|
|
546
|
+
return [];
|
|
547
|
+
}
|
|
548
|
+
try {
|
|
549
|
+
const result = await loadConfigFromFile(
|
|
550
|
+
{ command: "serve", mode: "development" },
|
|
551
|
+
configFile,
|
|
552
|
+
resolveFrom
|
|
553
|
+
);
|
|
554
|
+
if (!result?.config) {
|
|
555
|
+
return [];
|
|
556
|
+
}
|
|
557
|
+
const config = result.config;
|
|
558
|
+
const raw = config.integrations;
|
|
559
|
+
if (!raw) {
|
|
560
|
+
return [];
|
|
561
|
+
}
|
|
562
|
+
const flat = (Array.isArray(raw) ? raw : [raw]).flat(Infinity);
|
|
563
|
+
return flat.filter(
|
|
564
|
+
(i) => Boolean(i) && typeof i === "object" && "name" in i && "hooks" in i
|
|
565
|
+
);
|
|
566
|
+
} catch (err) {
|
|
567
|
+
console.warn(
|
|
568
|
+
"[storybook-astro] Could not load astro.config to discover integrations:",
|
|
569
|
+
err instanceof Error ? err.message : String(err)
|
|
570
|
+
);
|
|
571
|
+
return [];
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
397
575
|
// src/viteStorybookAstroMiddlewarePlugin.ts
|
|
398
576
|
async function vitePluginStorybookAstroMiddleware(options) {
|
|
399
577
|
let viteServer = null;
|
|
@@ -401,7 +579,7 @@ async function vitePluginStorybookAstroMiddleware(options) {
|
|
|
401
579
|
const vitePlugin = {
|
|
402
580
|
name: "storybook-astro-middleware-plugin",
|
|
403
581
|
async configureServer(server) {
|
|
404
|
-
viteServer = await createViteServer(options.integrations ?? [], resolveFrom);
|
|
582
|
+
viteServer = await createViteServer(options.integrations ?? [], resolveFrom, options.fonts);
|
|
405
583
|
const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, resolveFrom);
|
|
406
584
|
const filePath = fileURLToPath(new URL("./middleware", import.meta.url));
|
|
407
585
|
const middleware = await viteServer.ssrLoadModule(filePath, {
|
|
@@ -416,7 +594,8 @@ async function vitePluginStorybookAstroMiddleware(options) {
|
|
|
416
594
|
},
|
|
417
595
|
loadModule: (id) => ssrLoadModuleWithFsFallback(viteServer, id, {
|
|
418
596
|
fixStacktrace: true
|
|
419
|
-
})
|
|
597
|
+
}),
|
|
598
|
+
resolveFrom
|
|
420
599
|
});
|
|
421
600
|
let handlerPromise = createHandler();
|
|
422
601
|
const resetHandler = () => {
|
|
@@ -488,17 +667,21 @@ function createSsrServerLogger() {
|
|
|
488
667
|
};
|
|
489
668
|
return logger;
|
|
490
669
|
}
|
|
491
|
-
async function createViteServer(integrations, resolveFrom = process.cwd()) {
|
|
670
|
+
async function createViteServer(integrations, resolveFrom = process.cwd(), fonts) {
|
|
492
671
|
const { getViteConfig, passthroughImageService } = await importAstroConfig(resolveFrom);
|
|
493
672
|
const safeIntegrations = integrations ?? [];
|
|
494
673
|
const projectAstroResolutionPlugin = createProjectAstroResolutionPlugin(resolveFrom);
|
|
674
|
+
const frameworkIntegrations = await Promise.all(
|
|
675
|
+
safeIntegrations.map((integration) => integration.loadIntegration(resolveFrom))
|
|
676
|
+
);
|
|
677
|
+
const userIntegrations = await loadUserAstroIntegrations(resolveFrom);
|
|
678
|
+
const frameworkNames = new Set(frameworkIntegrations.map((i) => i.name));
|
|
679
|
+
const extraIntegrations = userIntegrations.filter((i) => !frameworkNames.has(i.name));
|
|
495
680
|
const config = await getViteConfig(
|
|
496
681
|
{ root: resolveFrom },
|
|
497
682
|
{
|
|
498
683
|
configFile: false,
|
|
499
|
-
integrations:
|
|
500
|
-
safeIntegrations.map((integration) => integration.loadIntegration(resolveFrom))
|
|
501
|
-
),
|
|
684
|
+
integrations: [...frameworkIntegrations, ...extraIntegrations],
|
|
502
685
|
// Use the passthrough image service so nested components that use <Image>
|
|
503
686
|
// from astro:assets render as plain <img> tags without triggering image
|
|
504
687
|
// optimization (which fails in the Storybook SSR context).
|
|
@@ -512,7 +695,7 @@ async function createViteServer(integrations, resolveFrom = process.cwd()) {
|
|
|
512
695
|
plugins: [
|
|
513
696
|
projectAstroResolutionPlugin,
|
|
514
697
|
// Fallbacks must come first to intercept before Astro's plugins
|
|
515
|
-
|
|
698
|
+
vitePluginAstroFonts({ fonts, root: resolveFrom }),
|
|
516
699
|
vitePluginAstroIntegrationOptsFallback(),
|
|
517
700
|
vitePluginAstroVueFallback(),
|
|
518
701
|
vitePluginAstroRoutesFallback(),
|
|
@@ -562,14 +745,15 @@ async function loadRulesConfigModule(viteServer, configFilePath) {
|
|
|
562
745
|
export {
|
|
563
746
|
createVirtualModule,
|
|
564
747
|
viteAstroContainerRenderersPlugin,
|
|
565
|
-
|
|
748
|
+
vitePluginAstroFonts,
|
|
566
749
|
vitePluginAstroIntegrationOptsFallback,
|
|
567
750
|
vitePluginAstroVueFallback,
|
|
568
751
|
vitePluginAstroRoutesFallback,
|
|
569
752
|
vitePluginStoryModuleMocks,
|
|
570
753
|
ssrLoadModuleWithFsFallback,
|
|
571
754
|
resolveRulesConfigFilePath,
|
|
755
|
+
loadUserAstroIntegrations,
|
|
572
756
|
vitePluginStorybookAstroMiddleware,
|
|
573
757
|
createViteServer
|
|
574
758
|
};
|
|
575
|
-
//# sourceMappingURL=chunk-
|
|
759
|
+
//# sourceMappingURL=chunk-VZXGPM6P.js.map
|
|
@@ -0,0 +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,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,kCAAkC,IAAI;AACjE,YAAM,0BACJ,SAAS,gBAAgB,6BAA6B,gBAAgB,IAAI;AAC5E,YAAM,kBACJ,SAAS,gBACL,iBACG,OAAO,CAAC,gBAAgB,OAAO,YAAY,kBAAkB,UAAU,EACvE;AAAA,QAAI,CAAC,gBACJ,YAAY,cAAc,SAAS,EAAE,QAAQ,kBAAkB,UAAU;AAAA,MAC3E,EACC,KAAK,KAAK,IACb;AAEN,aAAO;AAAA,UACH,gBAAgB;AAAA,UAChB,4BAA4B;AAAA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AAQ,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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { ArgTypes, Args, Parameters, ProjectAnnotations, StrictArgs } from 'stor
|
|
|
3
3
|
import { PreviewAddon, Preview as Preview$1, InferTypes } from 'storybook/internal/csf';
|
|
4
4
|
import { A as AstroRenderer } from './portable-stories-DXT_GOf6.js';
|
|
5
5
|
export { c as composeStories, a as composeStory, s as setProjectAnnotations } from './portable-stories-DXT_GOf6.js';
|
|
6
|
-
export { F as FrameworkOptions, R as RenderMode, a as RenderStoryInput, S as SanitizationOptions, b as ServerBuildOptions, c as StoryRulesOptions, d as StorybookConfig } from './types
|
|
6
|
+
export { F as FrameworkOptions, R as RenderMode, a as RenderStoryInput, S as SanitizationOptions, b as ServerBuildOptions, c as StoryRulesOptions, d as StorybookConfig } from './types--SvYP5Ri.js';
|
|
7
7
|
import 'vite';
|
|
8
8
|
import './base-DT67T5pi.js';
|
|
9
9
|
import 'astro';
|