@storybook-astro/framework 1.6.0 → 1.7.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.
@@ -1 +0,0 @@
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,UAA0B;AACtD,MAAI;AACF,UAAM,SAAS,aAAa,UAAU,OAAO;AAG7C,UAAM,aAAa,2BAA2B,MAAM,EAAE,IAAI,CAAC,OAAO,MAAM;AACtE,UAAI,MAAM,QAAQ,MAAM,SAAS,OAAO;AACtC,eAAO,yBAAyB,UAAU,MAAM,IAAI;AAAA,MACtD;AAEA,aAAO;AAAA,QACL;AAAA,QACA,GAAG,QAAQ,IAAI,CAAC;AAAA,QAChB,sBAAsB,MAAM,GAAG;AAAA,MACjC;AAAA,IACF,CAAC,EAAE,KAAK,IAAI;AAGZ,UAAM,eAAe,6BAA6B,MAAM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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 { getTsconfig } from 'get-tsconfig';\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 // getTsconfig walks up from `resolveFrom` to the nearest tsconfig and merges\n // `extends` for us. We keep our own (deliberately lenient) path matching\n // below rather than its strict `createPathsMatcher`, which rejects the\n // non-relative-without-baseUrl paths that the Astro/Vite resolver accepts.\n let found;\n\n try {\n found = getTsconfig(resolveFrom);\n } catch {\n // Malformed tsconfig (bad JSON, circular extends). This is a last-resort\n // resolver, so swallow it rather than crash hydration.\n return undefined;\n }\n\n if (!found) {\n return undefined;\n }\n\n const compilerOptions = found.config.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 get-tsconfig reports as `found.path`).\n const tsconfigDir = resolve(found.path, '..');\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;AAAA,MAC1C;AAEA,aAAO,OAAO,QAAQ,WAAW,MAAM;AAAA,IACzC;AAAA,IACA,kBAAkB,SAAkC;AAClD,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACL,IAAI;AACJ,YAAM,YACJ,OAAO,QAAQ,OAAO,QAAQ,WAAY,MAAkC;AAE9E,aAAO;AAAA,QACL,GAAG;AAAA,QACH,OAAO,SAAS,WAAW;AAAA,QAC3B,QAAQ,UAAU,WAAW;AAAA,QAC7B,SAAU,MAAM,WAAkC;AAAA,QAClD,UAAW,MAAM,YAAmC;AAAA,MACtD;AAAA,IACF;AAAA,IACA,YAAY;AACV,aAAO,CAAC;AAAA,IACV;AAAA,EACF;AACF;;;ACxDA,OAAO,kBAAkB;AAsBzB,IAAM,gCAA0C;AAAA,EAC9C,aAAa;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;A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