@storybook-astro/framework 1.0.2 → 1.1.0
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-7GHEQUPV.js → chunk-POHTFYST.js} +46 -8
- package/dist/chunk-POHTFYST.js.map +1 -0
- package/dist/chunk-T7NWIO5S.js +220 -0
- package/dist/chunk-T7NWIO5S.js.map +1 -0
- package/dist/{chunk-C5OH4VBR.js → chunk-V76WSNSP.js} +124 -47
- package/dist/chunk-V76WSNSP.js.map +1 -0
- package/dist/{chunk-KSDXET2L.js → chunk-VPJDFGB5.js} +444 -60
- package/dist/chunk-VPJDFGB5.js.map +1 -0
- package/dist/index.d.ts +19 -9
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/middleware.js +57 -39
- package/dist/middleware.js.map +1 -1
- package/dist/node/index.d.ts +10 -0
- package/dist/node/index.js +10 -0
- package/dist/node/index.js.map +1 -0
- package/dist/preset.d.ts +1 -1
- package/dist/preset.js +3 -3
- package/dist/testing.js +12 -64
- package/dist/testing.js.map +1 -1
- package/dist/{types-CHTsRtA7.d.ts → types-Cvor6Tyi.d.ts} +21 -5
- package/dist/{viteStorybookAstroMiddlewarePlugin-NP2E52IC.js → viteStorybookAstroMiddlewarePlugin-2EFKTECT.js} +2 -2
- package/dist/vitest/global-setup.js +42 -0
- package/dist/vitest/global-setup.js.map +1 -0
- package/dist/vitest/index.js +20 -3
- package/dist/vitest/index.js.map +1 -1
- package/package.json +13 -5
- package/src/index.ts +21 -1
- package/src/lib/sanitization.ts +104 -0
- package/src/middleware.ts +76 -44
- package/src/node/index.ts +7 -0
- package/src/preset.ts +75 -15
- package/src/renderer/renderer-dev.ts +82 -0
- package/src/renderer/renderer-server.test.ts +101 -0
- package/src/renderer/renderer-server.ts +135 -0
- package/src/renderer/renderer-static.ts +62 -0
- package/src/rules.test.ts +89 -18
- package/src/rules.ts +67 -18
- package/src/server/index.ts +111 -0
- package/src/testing/renderer-daemon.ts +10 -1
- package/src/types.ts +25 -5
- package/src/virtual.d.ts +37 -0
- package/src/vite/astroFilesVirtualModulePlugin.ts +36 -0
- package/src/vite/createVirtualModulePlugin.ts +3 -3
- package/src/vite/storybookAstroRulesConfigVirtualModulePlugin.ts +37 -0
- package/src/vite/storybookAstroSanitizationConfigVirtualModulePlugin.ts +21 -0
- package/src/vite/storybookAstroServerAuthConfigVirtualModulePlugin.test.ts +71 -0
- package/src/vite/storybookAstroServerAuthConfigVirtualModulePlugin.ts +42 -0
- package/src/vitePluginAstroBuildPrerender.ts +50 -51
- package/src/vitePluginAstroBuildServer.ts +289 -0
- package/src/vitePluginAstroIntegrationOptsFallback.ts +25 -0
- package/src/viteStorybookAstroMiddlewarePlugin.ts +40 -8
- package/src/viteStorybookAstroRendererPlugin.ts +45 -0
- package/src/vitest/config.ts +45 -4
- package/src/vitest/global-setup.ts +45 -0
- package/dist/chunk-7GHEQUPV.js.map +0 -1
- package/dist/chunk-C5OH4VBR.js.map +0 -1
- package/dist/chunk-KSDXET2L.js.map +0 -1
- package/dist/middleware.d.ts +0 -26
- package/src/msw-helpers.ts +0 -1
- package/src/msw.ts +0 -58
- /package/dist/{viteStorybookAstroMiddlewarePlugin-NP2E52IC.js.map → viteStorybookAstroMiddlewarePlugin-2EFKTECT.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/viteStorybookRendererFallbackPlugin.ts","../src/viteStorybookAstroRendererPlugin.ts","../src/vitePluginAstroBuildPrerender.ts","../src/vitePluginAstroBuildServer.ts","../src/vitePluginAstro.ts","../src/vite/astroFilesVirtualModulePlugin.ts","../src/vite/storybookAstroRulesConfigVirtualModulePlugin.ts","../src/vite/storybookAstroSanitizationConfigVirtualModulePlugin.ts","../src/vite/storybookAstroServerAuthConfigVirtualModulePlugin.ts","../src/preset.ts"],"sourcesContent":["import type { Integration } from './integrations/index.ts';\nimport { createVirtualModulePlugin } from './vite/createVirtualModulePlugin.ts';\n\nexport function viteStorybookRendererFallbackPlugin(integrations: Integration[]) {\n const safeIntegrations = integrations ?? [];\n\n return createVirtualModulePlugin({\n pluginName: 'storybook-renderer-fallback',\n virtualModuleId: 'virtual:storybook-renderer-fallback',\n load() {\n return safeIntegrations\n .filter((integration) => integration.storybookEntryPreview)\n .map(\n (integration) =>\n `export * as ${integration.name} from '${integration.storybookEntryPreview}';`\n )\n .join('\\n');\n }\n });\n}\n","import type { RenderMode, ServerBuildOptions } from './types.ts';\nimport { createVirtualModulePlugin } from './vite/createVirtualModulePlugin.ts';\n\nconst packageName = '@storybook-astro/framework';\n\nexport function viteStorybookAstroRendererPlugin(options: {\n mode: 'development' | 'production';\n renderMode?: RenderMode;\n server?: ServerBuildOptions;\n}) {\n const pluginName = 'storybook-astro:renderer-module';\n const virtualModuleId = 'virtual:storybook-astro-renderer';\n const isProduction = options.mode === 'production';\n const isStaticMode = options.renderMode === 'static';\n\n return createVirtualModulePlugin({\n pluginName,\n virtualModuleId,\n load() {\n if (!isProduction) {\n return `export * from '${packageName}/renderer/renderer-dev.ts';`;\n }\n\n if (isStaticMode) {\n return `export * from '${packageName}/renderer/renderer-static.ts';`;\n }\n\n return [\n `import { createServerRenderer } from '${packageName}/renderer/renderer-server.ts';`,\n `const renderer = createServerRenderer(${JSON.stringify(\n {\n serverUrl: options.server?.serverUrl,\n authToken: options.server?.authToken,\n authHeader: options.server?.authHeader\n },\n null,\n 2\n )});`,\n 'export const render = renderer.render;',\n 'export const init = renderer.init;',\n 'export const applyStyles = renderer.applyStyles;'\n ].join('\\n');\n }\n });\n}\n","import { createRequire } from 'node:module';\nimport type { Dirent } from 'node:fs';\nimport { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { experimental_AstroContainer as AstroContainer } from 'astro/container';\nimport { createServer, mergeConfig, type Plugin, type Rollup } from 'vite';\nimport { importAstroConfig } from './importAstroConfig.ts';\nimport type { Integration } from './integrations/index.ts';\nimport { ssrLoadModuleWithFsFallback } from './lib/ssr-load-module-with-fs-fallback.ts';\nimport { resolveSanitizationOptions, sanitizeRenderPayload } from './lib/sanitization.ts';\nimport { resolveStoryModuleMock, withStoryModuleMocks } from './module-mocks.ts';\nimport { resolveRulesConfigFilePath } from './rules-options.ts';\nimport { selectStoryRules, withStoryRuleCleanups } from './rules.ts';\nimport type { FrameworkOptions } from './types.ts';\nimport { vitePluginAstroFontsFallback } from './vitePluginAstroFontsFallback.ts';\nimport { vitePluginAstroIntegrationOptsFallback } from './vitePluginAstroIntegrationOptsFallback.ts';\nimport { vitePluginAstroRoutesFallback } from './vitePluginAstroRoutesFallback.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\n\nconst PRERENDERED_STORIES_FILE = 'astro-prerendered-stories.json';\n\ntype StoryIndex = {\n entries?: Record<\n string,\n {\n type?: string;\n id?: string;\n importPath?: string;\n exportName?: string;\n componentPath?: string;\n title?: string;\n name?: string;\n }\n >;\n};\n\ntype StoryEntry = {\n id: string;\n importPath: string;\n exportName: string;\n title?: string;\n name?: string;\n};\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 function vitePluginAstroBuildPrerender(options: FrameworkOptions): Plugin {\n const integrations = options.integrations ?? [];\n const resolveFrom = options.resolveFrom ?? process.cwd();\n const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, resolveFrom);\n const trackedSpecifiers = collectTrackedSpecifiers(integrations);\n const staticEntrypointRefs = new Map<string, string>();\n const componentEntrypointRefs = new Map<string, string>();\n let outDir = resolve(resolveFrom, 'storybook-static');\n\n return {\n name: 'storybook-astro:build-prerender',\n apply: 'build',\n enforce: 'post',\n\n configResolved(config) {\n outDir = resolve(resolveFrom, config.build.outDir ?? 'storybook-static');\n },\n\n resolveId(id: string) {\n if (id.startsWith('virtual:astro-static-module/')) {\n return `\\0${id}`;\n }\n\n if (id.startsWith('virtual:astro-component-module/')) {\n return `\\0${id}`;\n }\n },\n\n load(id: string) {\n if (id.startsWith('\\0virtual:astro-static-module/')) {\n const encodedSpecifier = id.replace('\\0virtual:astro-static-module/', '');\n const specifier = decodeURIComponent(encodedSpecifier);\n\n if (isClientEntrypoint(specifier)) {\n return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join('\\n');\n }\n\n return [`import '${specifier}';`, 'export default undefined;'].join('\\n');\n }\n\n if (id.startsWith('\\0virtual:astro-component-module/')) {\n const encodedSpecifier = id.replace('\\0virtual:astro-component-module/', '');\n const specifier = decodeURIComponent(encodedSpecifier);\n\n return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join('\\n');\n }\n },\n\n async buildStart(this: Rollup.PluginContext) {\n integrations.forEach((integration) => {\n const entrypoint = integration.renderer.client?.entrypoint;\n\n if (entrypoint) {\n this.addWatchFile(entrypoint);\n }\n });\n\n trackedSpecifiers.forEach((specifier) => {\n const fileReferenceId = this.emitFile({\n type: 'chunk',\n id: toStaticVirtualId(specifier)\n });\n\n staticEntrypointRefs.set(specifier, fileReferenceId);\n });\n\n const srcRoot = resolve(resolveFrom, 'src/components');\n const specifiers = await collectHydratableSourceModules(srcRoot);\n\n specifiers.forEach((specifier) => {\n const fileReferenceId = this.emitFile({\n type: 'chunk',\n id: toComponentVirtualId(specifier)\n });\n\n componentEntrypointRefs.set(specifier, fileReferenceId);\n });\n },\n\n async writeBundle(this: Rollup.PluginContext) {\n const staticModuleMap = buildStaticModuleMap(\n this,\n staticEntrypointRefs,\n componentEntrypointRefs\n );\n\n const stories = await collectAstroStories(outDir);\n\n if (stories.length === 0) {\n await writePrerenderedStoriesFile(outDir, {});\n\n return;\n }\n\n const prerenderedStories = await prerenderStories({\n stories,\n integrations,\n sanitization: options.sanitization,\n storyRulesConfigFilePath,\n staticModuleMap,\n trackedSpecifiers,\n resolveFrom\n });\n\n await writePrerenderedStoriesFile(outDir, prerenderedStories);\n }\n };\n}\n\nasync function writePrerenderedStoriesFile(outDir: string, payload: Record<string, string>) {\n await mkdir(outDir, { recursive: true });\n await writeFile(resolve(outDir, PRERENDERED_STORIES_FILE), JSON.stringify(payload), 'utf-8');\n}\n\nasync function prerenderStories(options: {\n stories: StoryEntry[];\n integrations: Integration[];\n sanitization?: FrameworkOptions['sanitization'];\n storyRulesConfigFilePath?: string;\n staticModuleMap: Record<string, string>;\n trackedSpecifiers: Set<string>;\n resolveFrom: string;\n}) {\n const sanitizationOptions = resolveSanitizationOptions(options.sanitization ?? undefined);\n const resolveClientModule = createClientModuleResolver(\n options.integrations,\n options.staticModuleMap\n );\n const viteServer = await createStorySsrServer(\n options.integrations,\n options.trackedSpecifiers,\n options.resolveFrom\n );\n const rulesConfigModule = await loadRulesConfigModule(viteServer, options.storyRulesConfigFilePath);\n\n try {\n const container = await AstroContainer.create({\n resolve: async (specifier) => {\n const mockedModule = resolveStoryModuleMock(specifier);\n\n if (mockedModule) {\n return mockedModule;\n }\n\n const resolution = resolveClientModule(specifier);\n\n if (resolution) {\n return resolution;\n }\n\n return specifier;\n }\n });\n\n await addContainerRenderers(container, options.integrations, resolveClientModule, viteServer);\n\n const output: Record<string, string> = {};\n\n for (const story of options.stories) {\n const selectedRules = await selectStoryRules({\n configModule: rulesConfigModule,\n configFilePath: options.storyRulesConfigFilePath,\n story: {\n id: story.id,\n title: story.title,\n name: story.name\n }\n });\n\n if (selectedRules.moduleMocks.size > 0) {\n viteServer.moduleGraph.invalidateAll();\n }\n\n const html = await withStoryRuleCleanups(selectedRules.cleanups, async () => {\n return withStoryModuleMocks(selectedRules.moduleMocks, async () => {\n const modulePath = resolveImportPath(story.importPath, options.resolveFrom);\n const storyModule = await viteServer.ssrLoadModule(modulePath);\n const meta = isRecord(storyModule.default) ? storyModule.default : {};\n const storyExport = isRecord(storyModule[story.exportName])\n ? storyModule[story.exportName]\n : {};\n\n if (typeof meta.component !== 'function') {\n throw new Error(\n `Unable to prerender story \"${story.id}\". Missing default export component in ${story.importPath}.`\n );\n }\n\n if (storyExport.component && storyExport.component !== meta.component) {\n return undefined;\n }\n\n const mergedArgs = mergeStoryArgs(toRecord(meta.args), toRecord(storyExport.args));\n const { args, slots } = separateSlots(mergedArgs);\n const processedArgs = await processImageMetadata(args);\n const sanitizedPayload = sanitizeRenderPayload(\n {\n args: processedArgs,\n slots\n },\n sanitizationOptions\n );\n\n return container.renderToString(\n patchCreateAstroCompat(meta.component) as Parameters<typeof container.renderToString>[0],\n {\n props: sanitizedPayload.args,\n slots: sanitizedPayload.slots\n }\n );\n });\n });\n\n if (html !== undefined) {\n output[story.id] = html;\n }\n }\n\n return output;\n } finally {\n await viteServer.close();\n }\n}\n\nasync function createStorySsrServer(\n integrations: Integration[],\n trackedSpecifiers: Set<string>,\n resolveFrom: string\n) {\n const { getViteConfig, passthroughImageService } = await importAstroConfig(resolveFrom);\n const astroConfig = await getViteConfig(\n { root: resolveFrom },\n {\n configFile: false,\n integrations: await Promise.all(\n integrations.map((integration) => integration.loadIntegration(resolveFrom))\n ),\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 )({\n mode: 'production',\n command: 'serve'\n });\n\n const config = mergeConfig(astroConfig, {\n appType: 'custom',\n server: {\n middlewareMode: true\n },\n plugins: [\n createProjectAstroResolutionPlugin(resolveFrom),\n vitePluginAstroFontsFallback(),\n vitePluginAstroIntegrationOptsFallback(),\n vitePluginAstroVueFallback(),\n vitePluginAstroRoutesFallback(),\n {\n name: 'storybook-astro:static-prerender-ssr-stubs',\n resolveId(id: string) {\n if (trackedSpecifiers.has(id)) {\n return `\\0storybook-astro-static-prerender-stub:${encodeURIComponent(id)}`;\n }\n },\n load(id: string) {\n if (id.startsWith('\\0storybook-astro-static-prerender-stub:')) {\n return 'export default undefined;';\n }\n }\n }\n ]\n });\n\n return createServer(config);\n}\n\nasync function loadRulesConfigModule(\n viteServer: Awaited<ReturnType<typeof createStorySsrServer>>,\n configFilePath?: string\n) {\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\nasync function addContainerRenderers(\n container: Awaited<ReturnType<typeof AstroContainer.create>>,\n integrations: Integration[],\n resolveClientModule: (specifier: string) => string | undefined,\n viteServer: Awaited<ReturnType<typeof createStorySsrServer>>\n) {\n for (const integration of integrations) {\n const serverRenderer = integration.renderer.server;\n\n if (serverRenderer) {\n const serverRendererModule = await viteServer.ssrLoadModule(serverRenderer.entrypoint);\n const renderer = serverRendererModule.default ?? serverRendererModule;\n\n if (integration.name === 'solid' && isRecord(renderer)) {\n container.addServerRenderer({\n name: serverRenderer.name,\n renderer: {\n ...renderer,\n name: serverRenderer.name\n } as Parameters<typeof container.addServerRenderer>[0]['renderer']\n });\n } else {\n container.addServerRenderer({\n name: serverRenderer.name,\n renderer\n });\n }\n }\n\n const clientRenderer = integration.renderer.client;\n\n if (clientRenderer) {\n const resolvedEntrypoint =\n resolveClientModule(clientRenderer.entrypoint) ?? clientRenderer.entrypoint;\n\n container.addClientRenderer({\n name: clientRenderer.name,\n entrypoint: resolvedEntrypoint\n });\n }\n }\n}\n\nfunction createClientModuleResolver(\n integrations: Integration[],\n staticModuleMap: Record<string, string>\n) {\n return function resolveClientModule(specifier: string) {\n if (Object.hasOwn(staticModuleMap, specifier)) {\n return staticModuleMap[specifier];\n }\n\n const normalizedSpecifier = specifier.replace(/\\\\/g, '/').replace(/\\?.*$/, '');\n\n if (Object.hasOwn(staticModuleMap, normalizedSpecifier)) {\n return staticModuleMap[normalizedSpecifier];\n }\n\n for (const integration of integrations) {\n const resolution = integration.resolveClient(specifier);\n\n if (resolution) {\n return resolution;\n }\n }\n };\n}\n\nasync function collectAstroStories(outDir: string): Promise<StoryEntry[]> {\n const indexFile = resolve(outDir, 'index.json');\n const indexRaw = await readFile(indexFile, 'utf-8');\n const indexJson = JSON.parse(indexRaw) as StoryIndex;\n\n return Object.values(indexJson.entries ?? {})\n .filter((entry) => entry.type === 'story' && entry.componentPath?.endsWith('.astro'))\n .map((entry) => {\n if (!entry.id || !entry.importPath || !entry.exportName) {\n throw new Error(`Encountered an invalid Storybook index entry in ${indexFile}.`);\n }\n\n return {\n id: entry.id,\n importPath: entry.importPath,\n exportName: entry.exportName,\n title: entry.title,\n name: entry.name\n };\n });\n}\n\nfunction mergeStoryArgs(\n metaArgs: Record<string, unknown> | undefined,\n storyArgs: Record<string, unknown> | undefined\n) {\n return {\n ...(metaArgs ?? {}),\n ...(storyArgs ?? {})\n };\n}\n\nfunction separateSlots(inputArgs: Record<string, unknown>) {\n const args = { ...inputArgs };\n const slotsCandidate = args.slots;\n\n delete args.slots;\n\n if (!isRecord(slotsCandidate)) {\n return {\n args,\n slots: {}\n };\n }\n\n return {\n args,\n slots: slotsCandidate as Record<string, string>\n };\n}\n\nfunction resolveImportPath(importPath: string, resolveFrom: string) {\n if (importPath.startsWith('./')) {\n return resolve(resolveFrom, importPath.slice(2));\n }\n\n return resolve(resolveFrom, importPath);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction toRecord(value: unknown): Record<string, unknown> | undefined {\n if (!isRecord(value)) {\n return undefined;\n }\n\n return value;\n}\n\nfunction collectTrackedSpecifiers(integrations: Integration[]) {\n const specifiers = new Set<string>(['astro:scripts/page.js', 'astro:scripts/before-hydration.js']);\n\n integrations.forEach((integration) => {\n const entrypoint = integration.renderer.client?.entrypoint;\n\n if (entrypoint) {\n specifiers.add(entrypoint);\n }\n });\n\n return specifiers;\n}\n\nfunction buildStaticModuleMap(\n pluginContext: Rollup.PluginContext,\n staticEntrypointRefs: Map<string, string>,\n componentEntrypointRefs: Map<string, string>\n) {\n const map: Record<string, string> = {};\n\n staticEntrypointRefs.forEach((fileReferenceId, specifier) => {\n const fileName = pluginContext.getFileName(fileReferenceId);\n\n if (fileName) {\n map[specifier] = toPublicPath(fileName);\n }\n });\n\n componentEntrypointRefs.forEach((fileReferenceId, specifier) => {\n const fileName = pluginContext.getFileName(fileReferenceId);\n\n if (fileName) {\n map[specifier] = toPublicPath(fileName);\n }\n });\n\n return map;\n}\n\nfunction toStaticVirtualId(specifier: string) {\n return `virtual:astro-static-module/${encodeURIComponent(specifier)}`;\n}\n\nfunction toComponentVirtualId(specifier: string) {\n return `virtual:astro-component-module/${encodeURIComponent(specifier)}`;\n}\n\nfunction isClientEntrypoint(specifier: string) {\n return specifier.startsWith('@astrojs/') && specifier.endsWith('/client.js');\n}\n\nfunction toPublicPath(fileName: string) {\n return `./${fileName}`;\n}\n\nasync function collectHydratableSourceModules(srcRoot: string): Promise<string[]> {\n const modules: string[] = [];\n\n async function walk(directory: string) {\n let entries: Dirent[];\n\n try {\n entries = await readdir(directory, { withFileTypes: true });\n } catch {\n return;\n }\n\n await Promise.all(\n entries.map(async (entry) => {\n const absolutePath = resolve(directory, entry.name);\n\n if (entry.isDirectory()) {\n await walk(absolutePath);\n\n return;\n }\n\n if (!entry.isFile()) {\n return;\n }\n\n const normalizedPath = absolutePath.replace(/\\\\/g, '/');\n\n if (!isHydratableSourceFile(normalizedPath)) {\n return;\n }\n\n if (isNonHydratableSourceFile(normalizedPath)) {\n return;\n }\n\n modules.push(normalizedPath);\n })\n );\n }\n\n await walk(srcRoot);\n\n return modules;\n}\n\nfunction isHydratableSourceFile(input: string) {\n return /\\.(jsx|tsx|vue|svelte|js|ts)$/.test(input);\n}\n\nfunction isNonHydratableSourceFile(input: string) {\n return /\\.stories\\.[jt]sx?$|\\.stories\\.vue$|\\.stories\\.svelte$|\\.(spec|test)\\.[jt]sx?$/.test(\n input\n );\n}\n\nfunction 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 a plain object — Astro's image service checks\n // isESMImportedImage (typeof src === 'object') and skips the /@fs/ string\n // validation that throws LocalImageUsedWrongly. Converting to a URL string\n // causes that error when the string starts with /@fs/.\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\n\nfunction createProjectAstroResolutionPlugin(resolveFrom: string): Plugin {\n const require = createRequire(import.meta.url);\n\n return {\n name: 'storybook-astro:resolve-project-astro-prerender',\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 };\n}\n","import type { Dirent } from 'node:fs';\nimport { readdir } from 'node:fs/promises';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { build, type Rollup } from 'vite';\nimport type { FrameworkOptions } from './types.ts';\nimport { mergeWithAstroConfig } from './vitePluginAstro.ts';\nimport { viteAstroContainerRenderersPlugin } from './viteAstroContainerRenderersPlugin.ts';\nimport { astroFilesVirtualModulePlugin } from './vite/astroFilesVirtualModulePlugin.ts';\nimport { storybookAstroStoryRulesConfigVirtualModulePlugin } from './vite/storybookAstroRulesConfigVirtualModulePlugin.ts';\nimport { storybookAstroSanitizationConfigVirtualModulePlugin } from './vite/storybookAstroSanitizationConfigVirtualModulePlugin.ts';\nimport { storybookAstroServerAuthConfigVirtualModulePlugin } from './vite/storybookAstroServerAuthConfigVirtualModulePlugin.ts';\n\nconst moduleRoot = resolve(dirname(fileURLToPath(import.meta.url)), '.');\n// packageRoot works regardless of whether this file is running from src/ or dist/\nconst packageRoot = resolve(moduleRoot, '..');\n\nexport function vitePluginAstroBuildServer(options: FrameworkOptions) {\n const integrations = options.integrations ?? [];\n const resolveFrom = options.resolveFrom ?? process.cwd();\n const storiesMap = new Map<string, Set<string>>();\n const trackedSpecifiers = collectTrackedSpecifiers(integrations);\n const staticEntrypointRefs = new Map<string, string>();\n const componentEntrypointRefs = new Map<string, string>();\n let storybookStaticOutDir = resolve(resolveFrom, 'storybook-static');\n\n return {\n name: 'storybook-astro:build-server',\n apply: 'build',\n enforce: 'post',\n\n configResolved(config: { build: { outDir?: string } }) {\n storybookStaticOutDir = resolve(resolveFrom, config.build.outDir ?? 'storybook-static');\n },\n\n resolveId(id: string, importer?: string) {\n if (id.endsWith('.astro') && importer) {\n const absoluteAstroPath = resolve(dirname(importer), id);\n\n if (!storiesMap.has(absoluteAstroPath)) {\n storiesMap.set(absoluteAstroPath, new Set());\n }\n\n storiesMap.get(absoluteAstroPath)?.add(importer);\n }\n\n if (id.startsWith('virtual:astro-static-module/')) {\n return `\\0${id}`;\n }\n\n if (id.startsWith('virtual:astro-component-module/')) {\n return `\\0${id}`;\n }\n },\n\n load(id: string) {\n if (id.startsWith('\\0virtual:astro-static-module/')) {\n const encodedSpecifier = id.replace('\\0virtual:astro-static-module/', '');\n const specifier = decodeURIComponent(encodedSpecifier);\n\n if (isClientEntrypoint(specifier)) {\n return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join('\\n');\n }\n\n return [`import '${specifier}';`, 'export default undefined;'].join('\\n');\n }\n\n if (id.startsWith('\\0virtual:astro-component-module/')) {\n const encodedSpecifier = id.replace('\\0virtual:astro-component-module/', '');\n const specifier = decodeURIComponent(encodedSpecifier);\n\n return [`export { default } from '${specifier}';`, `export * from '${specifier}';`].join('\\n');\n }\n },\n\n async buildStart(this: Rollup.PluginContext) {\n integrations.forEach((integration) => {\n const entrypoint = integration.renderer.client?.entrypoint;\n\n if (entrypoint) {\n this.addWatchFile(entrypoint);\n }\n });\n\n trackedSpecifiers.forEach((specifier) => {\n const fileReferenceId = this.emitFile({\n type: 'chunk',\n id: toStaticVirtualId(specifier)\n });\n\n staticEntrypointRefs.set(specifier, fileReferenceId);\n });\n\n const srcRoot = resolve(resolveFrom, 'src/components');\n const specifiers = await collectHydratableSourceModules(srcRoot);\n\n specifiers.forEach((specifier) => {\n const fileReferenceId = this.emitFile({\n type: 'chunk',\n id: toComponentVirtualId(specifier)\n });\n\n componentEntrypointRefs.set(specifier, fileReferenceId);\n });\n },\n\n async writeBundle(this: Rollup.PluginContext) {\n const astroComponents = Array.from(storiesMap.keys());\n const staticModuleMap = buildStaticModuleMap(\n this,\n staticEntrypointRefs,\n componentEntrypointRefs\n );\n const serverOutDir = resolve(dirname(storybookStaticOutDir), 'storybook-server');\n\n await buildAstroServer({\n astroComponents,\n integrations,\n sanitization: options.sanitization,\n storyRules: options.storyRules,\n server: options.server,\n outDir: serverOutDir,\n staticModuleMap,\n resolveFrom\n });\n }\n };\n}\n\nasync function buildAstroServer(options: {\n astroComponents: string[];\n integrations: FrameworkOptions['integrations'];\n sanitization?: FrameworkOptions['sanitization'];\n storyRules?: FrameworkOptions['storyRules'];\n server?: FrameworkOptions['server'];\n outDir: string;\n staticModuleMap: Record<string, string>;\n resolveFrom: string;\n}) {\n const buildConfig = {\n root: resolve(packageRoot, 'src/server'),\n ssr: {\n noExternal: /(@astrojs\\/.+|react|react-dom)/\n },\n build: {\n ssr: true,\n outDir: options.outDir,\n emptyOutDir: true,\n sourcemap: true,\n manifest: false,\n rollupOptions: {\n input: resolve(packageRoot, 'src/server/index.ts'),\n treeshake: true\n }\n },\n plugins: [\n astroFilesVirtualModulePlugin(options.astroComponents),\n storybookAstroSanitizationConfigVirtualModulePlugin(options.sanitization),\n storybookAstroStoryRulesConfigVirtualModulePlugin(options.storyRules, options.resolveFrom),\n storybookAstroServerAuthConfigVirtualModulePlugin(options.server),\n viteAstroContainerRenderersPlugin(options.integrations, {\n mode: 'production',\n staticModuleMap: options.staticModuleMap\n })\n ]\n };\n\n const finalConfig = await mergeWithAstroConfig(\n buildConfig,\n options.integrations,\n options.resolveFrom,\n 'production',\n 'build'\n );\n\n await build(finalConfig);\n}\n\nfunction collectTrackedSpecifiers(integrations: FrameworkOptions['integrations']) {\n const specifiers = new Set<string>(['astro:scripts/page.js', 'astro:scripts/before-hydration.js']);\n\n integrations.forEach((integration) => {\n const entrypoint = integration.renderer.client?.entrypoint;\n\n if (entrypoint) {\n specifiers.add(entrypoint);\n }\n });\n\n return specifiers;\n}\n\nfunction buildStaticModuleMap(\n pluginContext: Rollup.PluginContext,\n staticEntrypointRefs: Map<string, string>,\n componentEntrypointRefs: Map<string, string>\n) {\n const map: Record<string, string> = {};\n\n staticEntrypointRefs.forEach((fileReferenceId, specifier) => {\n const fileName = pluginContext.getFileName(fileReferenceId);\n\n if (fileName) {\n map[specifier] = toPublicPath(fileName);\n }\n });\n\n componentEntrypointRefs.forEach((fileReferenceId, specifier) => {\n const fileName = pluginContext.getFileName(fileReferenceId);\n\n if (fileName) {\n map[specifier] = toPublicPath(fileName);\n }\n });\n\n return map;\n}\n\nfunction toStaticVirtualId(specifier: string) {\n return `virtual:astro-static-module/${encodeURIComponent(specifier)}`;\n}\n\nfunction toComponentVirtualId(specifier: string) {\n return `virtual:astro-component-module/${encodeURIComponent(specifier)}`;\n}\n\nfunction isClientEntrypoint(specifier: string) {\n return specifier.startsWith('@astrojs/') && specifier.endsWith('/client.js');\n}\n\nfunction toPublicPath(fileName: string) {\n return `./${fileName}`;\n}\n\nasync function collectHydratableSourceModules(srcRoot: string): Promise<string[]> {\n const modules: string[] = [];\n\n async function walk(directory: string) {\n let entries: Dirent[];\n\n try {\n entries = await readdir(directory, { withFileTypes: true });\n } catch {\n return;\n }\n\n await Promise.all(\n entries.map(async (entry) => {\n const absolutePath = resolve(directory, entry.name);\n\n if (entry.isDirectory()) {\n await walk(absolutePath);\n\n return;\n }\n\n if (!entry.isFile()) {\n return;\n }\n\n const normalizedPath = absolutePath.replace(/\\\\/g, '/');\n\n if (!isHydratableSourceFile(normalizedPath)) {\n return;\n }\n\n if (isNonHydratableSourceFile(normalizedPath)) {\n return;\n }\n\n modules.push(normalizedPath);\n })\n );\n }\n\n await walk(srcRoot);\n\n return modules;\n}\n\nfunction isHydratableSourceFile(input: string) {\n return /\\.(jsx|tsx|vue|svelte|js|ts)$/.test(input);\n}\n\nfunction isNonHydratableSourceFile(input: string) {\n return /\\.stories\\.[jt]sx?$|\\.stories\\.vue$|\\.stories\\.svelte$|\\.(spec|test)\\.[jt]sx?$/.test(\n input\n );\n}\n","import { mergeConfig, type InlineConfig } from 'vite';\nimport type { Integration } from './integrations/index.ts';\nimport { importAstroConfig } from './importAstroConfig.ts';\n\nconst ASTRO_PLUGINS_THAT_ARE_SUPPOSEDLY_NOT_NEEDED_IN_STORYBOOK = [\n '@astro/plugin-actions',\n '@astrojs/vite-plugin-astro-ssr-manifest',\n 'astro-content-virtual-mod-plugin',\n 'astro:actions',\n 'astro:build:normal',\n 'astro:container',\n 'astro:content-asset-propagation',\n 'astro:content-imports',\n 'astro:content-listen',\n 'astro:dev-toolbar',\n 'astro:head-metadata',\n 'astro:html',\n 'astro:i18n',\n 'astro:integration-container',\n 'astro:jsx',\n 'astro:markdown',\n 'astro:postprocess',\n 'astro:prefetch',\n 'astro:scanner',\n 'astro:scripts:page-ssr',\n 'astro:server',\n 'astro:vite-plugin-env',\n 'astro:vite-plugin-file-url'\n];\n\nexport async function mergeWithAstroConfig(\n config: InlineConfig,\n integrations: Integration[] = [],\n resolveFrom = process.cwd(),\n mode = 'development',\n command: 'build' | 'serve' = 'serve'\n) {\n const { getViteConfig } = await importAstroConfig(resolveFrom);\n const safeIntegrations = integrations ?? [];\n\n const astroConfig = await getViteConfig(\n {},\n {\n configFile: false,\n integrations: await Promise.all(\n safeIntegrations.map((integration) => integration.loadIntegration(resolveFrom))\n )\n }\n )({\n mode,\n command\n });\n\n const filteredPlugins = astroConfig\n .plugins!.flat()\n .filter(\n (plugin) =>\n plugin &&\n 'name' in plugin &&\n !ASTRO_PLUGINS_THAT_ARE_SUPPOSEDLY_NOT_NEEDED_IN_STORYBOOK.includes(plugin.name)\n );\n\n return mergeConfig(config, {\n ...astroConfig,\n plugins: filteredPlugins\n });\n}\n","import type { Plugin } from 'vite';\nimport { createVirtualModulePlugin } from './createVirtualModulePlugin.ts';\n\ntype ImportRecord = {\n id: string;\n file: string;\n importStatement: string;\n};\n\nexport function astroFilesVirtualModulePlugin(astroComponents: string[]): Plugin {\n return createVirtualModulePlugin({\n pluginName: 'storybook-astro:virtual-astro-files',\n virtualModuleId: 'virtual:astro-files',\n load() {\n const imports = astroComponents.reduce<ImportRecord[]>((records, file, index) => {\n const moduleId = `_astroFile${index}`;\n\n return [\n ...records,\n {\n id: moduleId,\n file,\n importStatement: `import ${moduleId} from '${file}';`\n }\n ];\n }, []);\n\n return [\n imports.map(({ importStatement }) => importStatement).join('\\n'),\n 'export default {',\n imports.map(({ file, id }) => `'${file}': ${id}`).join(',\\n'),\n '};'\n ].join('\\n');\n }\n });\n}\n","import type { Plugin } from 'vite';\nimport type { StoryRulesOptions } from '../rules-options.ts';\nimport { resolveRulesConfigFilePath } from '../rules-options.ts';\nimport { createVirtualModulePlugin } from './createVirtualModulePlugin.ts';\n\nexport const STORYBOOK_ASTRO_STORY_RULES_CONFIG_VIRTUAL_MODULE_ID =\n 'virtual:storybook-astro-story-rules-config';\n\nexport function storybookAstroStoryRulesConfigVirtualModulePlugin(\n options?: StoryRulesOptions,\n resolveFrom = process.cwd()\n): Plugin {\n return createVirtualModulePlugin({\n pluginName: 'storybook-astro:virtual-story-rules-config',\n virtualModuleId: STORYBOOK_ASTRO_STORY_RULES_CONFIG_VIRTUAL_MODULE_ID,\n load() {\n const configFilePath = resolveRulesConfigFilePath(options, resolveFrom);\n\n if (!configFilePath) {\n return [\n 'const storybookAstroStoryRulesConfig = { rules: [] };',\n 'export default storybookAstroStoryRulesConfig;',\n 'export const storybookAstroStoryRulesConfigFilePath = undefined;'\n ].join('\\n');\n }\n\n const importPath = JSON.stringify(configFilePath.replace(/\\\\/g, '/'));\n const configPath = JSON.stringify(configFilePath.replace(/\\\\/g, '/'));\n\n return [\n `import * as storybookAstroStoryRulesConfigModule from ${importPath};`,\n 'export default storybookAstroStoryRulesConfigModule;',\n `export const storybookAstroStoryRulesConfigFilePath = ${configPath};`\n ].join('\\n');\n }\n });\n}\n","import type { Plugin } from 'vite';\nimport type { SanitizationOptions } from '../lib/sanitization.ts';\nimport { serializeSanitizationOptions } from '../lib/sanitization.ts';\nimport { createVirtualModulePlugin } from './createVirtualModulePlugin.ts';\n\nexport const STORYBOOK_ASTRO_SANITIZATION_CONFIG_VIRTUAL_MODULE_ID =\n 'virtual:storybook-astro-sanitization-config';\n\nexport function storybookAstroSanitizationConfigVirtualModulePlugin(\n options?: SanitizationOptions\n): Plugin {\n return createVirtualModulePlugin({\n pluginName: 'storybook-astro:virtual-sanitization-config',\n virtualModuleId: STORYBOOK_ASTRO_SANITIZATION_CONFIG_VIRTUAL_MODULE_ID,\n load() {\n const serializedConfig = serializeSanitizationOptions(options);\n\n return `export default ${serializedConfig};`;\n }\n });\n}\n","import type { Plugin } from 'vite';\nimport type { ServerBuildOptions } from '../types.ts';\nimport { createVirtualModulePlugin } from './createVirtualModulePlugin.ts';\n\nexport const STORYBOOK_ASTRO_SERVER_AUTH_CONFIG_VIRTUAL_MODULE_ID =\n 'virtual:storybook-astro-server-auth-config';\n\nexport function storybookAstroServerAuthConfigVirtualModulePlugin(\n options?: ServerBuildOptions\n): Plugin {\n const authToken = normalizeOptionalString(options?.authToken);\n const authHeader = normalizeAuthHeader(options?.authHeader);\n\n return createVirtualModulePlugin({\n pluginName: 'storybook-astro:virtual-server-auth-config',\n virtualModuleId: STORYBOOK_ASTRO_SERVER_AUTH_CONFIG_VIRTUAL_MODULE_ID,\n load() {\n return [\n `export const storybookAstroServerAuthToken = ${\n authToken ? JSON.stringify(authToken) : 'undefined'\n };`,\n `export const storybookAstroServerAuthHeader = ${JSON.stringify(authHeader)};`\n ].join('\\n');\n }\n });\n}\n\nfunction normalizeOptionalString(value: string | undefined) {\n if (!value) {\n return undefined;\n }\n\n const normalizedValue = value.trim();\n\n return normalizedValue || undefined;\n}\n\nfunction normalizeAuthHeader(value: string | undefined) {\n const normalizedValue = normalizeOptionalString(value);\n\n return (normalizedValue ?? 'authorization').toLowerCase();\n}\n","import type { StorybookConfigVite, FrameworkOptions } from './types.ts';\nimport { vitePluginStorybookAstroMiddleware } from './viteStorybookAstroMiddlewarePlugin.ts';\nimport { viteStorybookRendererFallbackPlugin } from './viteStorybookRendererFallbackPlugin.ts';\nimport { viteStorybookAstroRendererPlugin } from './viteStorybookAstroRendererPlugin.ts';\nimport { vitePluginAstroComponentMarker } from './vitePluginAstroComponentMarker.ts';\nimport { vitePluginAstroBuildPrerender } from './vitePluginAstroBuildPrerender.ts';\nimport { vitePluginAstroBuildServer } from './vitePluginAstroBuildServer.ts';\nimport { vitePluginAstroIntegrationOptsFallback } from './vitePluginAstroIntegrationOptsFallback.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\nimport { resolveSanitizationOptions } from './lib/sanitization.ts';\nimport { mergeWithAstroConfig } from './vitePluginAstro.ts';\n\nexport const core = {\n builder: '@storybook/builder-vite',\n renderer: '@storybook-astro/renderer'\n};\n\nexport const viteFinal: StorybookConfigVite['viteFinal'] = async (config, { configType, presets }) => {\n const options = await presets.apply<FrameworkOptions>('frameworkOptions');\n\n if (!config.plugins) {\n config.plugins = [];\n }\n\n const integrations = options.integrations ?? [];\n const resolveFrom = options.resolveFrom ?? process.cwd();\n const renderMode = options.renderMode ?? 'server';\n const mode = configType === 'DEVELOPMENT' ? 'development' : 'production';\n const command = configType === 'DEVELOPMENT' ? 'serve' : 'build';\n\n resolveSanitizationOptions(options.sanitization);\n\n config.envPrefix = mergeEnvPrefixes(config.envPrefix, 'STORYBOOK_');\n\n const { vitePlugin: storybookAstroMiddlewarePlugin, viteConfig } =\n await vitePluginStorybookAstroMiddleware(options);\n\n config.plugins.push(\n viteStorybookRendererFallbackPlugin(integrations),\n viteStorybookAstroRendererPlugin({\n mode,\n renderMode,\n server: options.server\n }),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n vitePluginAstroComponentMarker() as any,\n vitePluginAstroIntegrationOptsFallback(),\n vitePluginAstroVueFallback(),\n );\n\n if (configType === 'DEVELOPMENT') {\n config.plugins.push(storybookAstroMiddlewarePlugin, ...viteConfig.plugins);\n } else if (renderMode === 'static') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config.plugins.push(vitePluginAstroBuildPrerender(options) as any);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config.plugins.push(vitePluginAstroBuildServer(options) as any);\n }\n\n if (configType !== 'DEVELOPMENT') {\n config.build = {\n ...(config.build ?? {}),\n manifest: true\n };\n\n config.build.rollupOptions = {\n ...(config.build.rollupOptions ?? {}),\n preserveEntrySignatures: 'strict'\n };\n }\n\n // Add React/ReactDOM aliases for storybook-solidjs compatibility\n if (!config.resolve) {\n config.resolve = {};\n }\n if (!config.resolve.alias) {\n config.resolve.alias = {};\n }\n \n // Ensure React is available for storybook-solidjs\n const aliases = config.resolve.alias as Record<string, string>;\n\n if (!aliases['react']) {\n aliases['react'] = 'react';\n }\n if (!aliases['react-dom']) {\n aliases['react-dom'] = 'react-dom';\n }\n\n const finalConfig = await mergeWithAstroConfig(config, integrations, resolveFrom, mode, command);\n\n // Exclude Astro integration packages from dependency optimization because\n // they import virtual modules that esbuild cannot resolve.\n if (!finalConfig.optimizeDeps) {\n finalConfig.optimizeDeps = {};\n }\n if (!finalConfig.optimizeDeps.exclude) {\n finalConfig.optimizeDeps.exclude = [];\n }\n for (const pkg of ['@astrojs/vue', '@astrojs/react', '@astrojs/preact']) {\n if (!finalConfig.optimizeDeps.exclude.includes(pkg)) {\n finalConfig.optimizeDeps.exclude.push(pkg);\n }\n }\n // Exclude the renderer from Vite's esbuild pre-bundler so that\n // import.meta.hot is preserved in the preview iframe. When installed\n // via npm (not workspace:*), Vite would otherwise pre-bundle the\n // renderer with esbuild, which strips import.meta.hot and causes the\n // renderer to fall back to fetching astro-prerendered-stories.json\n // (a 404 in dev mode) rather than using the Vite HMR channel.\n if (!finalConfig.optimizeDeps.exclude.includes('@storybook-astro/renderer')) {\n finalConfig.optimizeDeps.exclude.push('@storybook-astro/renderer');\n }\n // Mark integration virtual modules as external so the dep bundler doesn't\n // try to resolve them (they are Vite virtual modules with no real package).\n // Set both esbuildOptions (Vite ≤7) and rolldownOptions (Vite 8+, Rolldown)\n // so the correct key is populated regardless of Vite version.\n const integrationVirtualModules = [\n 'virtual:@astrojs/vue/app',\n 'virtual:astro:vue-app',\n 'astro:react:opts',\n 'astro:preact:opts'\n ];\n\n // Vite ≤7 (esbuild-based optimizer)\n if (!finalConfig.optimizeDeps.esbuildOptions) {\n finalConfig.optimizeDeps.esbuildOptions = {};\n }\n if (!finalConfig.optimizeDeps.esbuildOptions.external) {\n finalConfig.optimizeDeps.esbuildOptions.external = [];\n }\n for (const mod of integrationVirtualModules) {\n if (!finalConfig.optimizeDeps.esbuildOptions.external.includes(mod)) {\n finalConfig.optimizeDeps.esbuildOptions.external.push(mod);\n }\n }\n\n // Vite 8+ (Rolldown-based optimizer) — same semantics, different key\n // Use a loose cast because rolldownOptions is absent from Vite <8 types.\n const optimizeDepsMut = finalConfig.optimizeDeps as Record<string, unknown>;\n const rolldownOpts = (optimizeDepsMut.rolldownOptions ?? {}) as { external?: string[] };\n\n rolldownOpts.external = Array.from(\n new Set([...(rolldownOpts.external ?? []), ...integrationVirtualModules])\n );\n optimizeDepsMut.rolldownOptions = rolldownOpts;\n\n return finalConfig;\n};\n\nfunction mergeEnvPrefixes(\n existing: string | string[] | undefined,\n additionalPrefix: string\n): string[] {\n const prefixes = Array.isArray(existing) ? existing : existing ? [existing] : [];\n\n return Array.from(new Set([...prefixes, additionalPrefix]));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,oCAAoC,cAA6B;AAC/E,QAAM,mBAAmB,gBAAgB,CAAC;AAE1C,SAAO,0BAA0B;AAAA,IAC/B,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,OAAO;AACL,aAAO,iBACJ,OAAO,CAAC,gBAAgB,YAAY,qBAAqB,EACzD;AAAA,QACC,CAAC,gBACC,eAAe,YAAY,IAAI,UAAU,YAAY,qBAAqB;AAAA,MAC9E,EACC,KAAK,IAAI;AAAA,IACd;AAAA,EACF,CAAC;AACH;;;AChBA,IAAM,cAAc;AAEb,SAAS,iCAAiC,SAI9C;AACD,QAAM,aAAa;AACnB,QAAM,kBAAkB;AACxB,QAAM,eAAe,QAAQ,SAAS;AACtC,QAAM,eAAe,QAAQ,eAAe;AAE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BACU;AACV,QAAM,WAAW,MAAM,QAAQ,QAAQ,IAAI,WAAW,WAAW,CAAC,QAAQ,IAAI,CAAC;AAE/E,SAAO,MAAM,KAAK,oBAAI,IAAI,CAAC,GAAG,UAAU,gBAAgB,CAAC,CAAC;AAC5D;","names":["require","readdir","resolve","mergeConfig","mergeConfig","resolve","collectTrackedSpecifiers","isClientEntrypoint","toStaticVirtualId","collectHydratableSourceModules","toComponentVirtualId","buildStaticModuleMap","toPublicPath","readdir","isHydratableSourceFile","isNonHydratableSourceFile"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { ProjectAnnotations } from 'storybook/internal/types';
|
|
2
2
|
export { ArgTypes, Args, Parameters, ProjectAnnotations, StrictArgs } from 'storybook/internal/types';
|
|
3
|
+
import { PreviewAddon, Preview as Preview$1, InferTypes } from 'storybook/internal/csf';
|
|
3
4
|
import { A as AstroRenderer } from './portable-stories-BvdaQigq.js';
|
|
4
5
|
export { c as composeStories, a as composeStory, s as setProjectAnnotations } from './portable-stories-BvdaQigq.js';
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
import { R as RenderStoryInput } from './types-Cvor6Tyi.js';
|
|
7
|
+
export { F as FrameworkOptions, a as RenderMode, S as SanitizationOptions, b as ServerBuildOptions, c as StoryRulesOptions, d as StorybookConfig } from './types-Cvor6Tyi.js';
|
|
7
8
|
export { core, viteFinal } from './preset.js';
|
|
8
9
|
import 'vite';
|
|
9
10
|
import './base-IRZo3zgK.js';
|
|
10
11
|
import 'astro';
|
|
11
12
|
import 'sanitize-html';
|
|
12
13
|
|
|
13
|
-
type
|
|
14
|
-
type StoryRuleUseResult = void | Promise<void>;
|
|
14
|
+
type StoryRuleCleanup = () => void | Promise<void>;
|
|
15
|
+
type StoryRuleUseResult = void | StoryRuleCleanup | Promise<void | StoryRuleCleanup>;
|
|
15
16
|
type StoryRuleUseContext = {
|
|
16
|
-
mode: StoryMode;
|
|
17
17
|
story: StoryRuleStory;
|
|
18
|
-
msw: {
|
|
19
|
-
use: (...handlers: RequestHandler[]) => void;
|
|
20
|
-
};
|
|
21
18
|
mock: (specifier: string, replacement: string) => void;
|
|
22
19
|
};
|
|
23
20
|
type StoryRuleUse = (context: StoryRuleUseContext) => StoryRuleUseResult;
|
|
@@ -34,9 +31,22 @@ type StoryRuleStory = {
|
|
|
34
31
|
name?: string;
|
|
35
32
|
keys: string[];
|
|
36
33
|
};
|
|
34
|
+
type StoryRuleSelectionInput = {
|
|
35
|
+
configModule: unknown;
|
|
36
|
+
configFilePath?: string;
|
|
37
|
+
story?: RenderStoryInput;
|
|
38
|
+
};
|
|
39
|
+
type StoryRuleSelection = {
|
|
40
|
+
moduleMocks: Map<string, string>;
|
|
41
|
+
cleanups: StoryRuleCleanup[];
|
|
42
|
+
};
|
|
37
43
|
declare function defineStoryRules(config: StoryRulesConfig): StoryRulesConfig;
|
|
38
44
|
|
|
39
45
|
/** Preview configuration type for `.storybook/preview.ts` in Astro projects. */
|
|
40
46
|
type Preview = ProjectAnnotations<AstroRenderer>;
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
declare function definePreview<Addons extends PreviewAddon<never>[] = []>(input: ProjectAnnotations<AstroRenderer> & {
|
|
49
|
+
addons?: Addons;
|
|
50
|
+
}): Preview$1<AstroRenderer & InferTypes<Addons>>;
|
|
51
|
+
|
|
52
|
+
export { AstroRenderer, type Preview, RenderStoryInput, type StoryRule, type StoryRuleCleanup, type StoryRuleSelection, type StoryRuleSelectionInput, type StoryRuleStory, type StoryRuleUse, type StoryRuleUseContext, type StoryRulesConfig, definePreview, defineStoryRules };
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
core,
|
|
3
3
|
viteFinal
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VPJDFGB5.js";
|
|
5
5
|
import {
|
|
6
6
|
defineStoryRules
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-V76WSNSP.js";
|
|
8
8
|
import {
|
|
9
9
|
composeStories,
|
|
10
10
|
composeStory,
|
|
11
11
|
setProjectAnnotations
|
|
12
12
|
} from "./chunk-5EF25G5S.js";
|
|
13
|
+
import "./chunk-POHTFYST.js";
|
|
13
14
|
import "./chunk-E4LB75JN.js";
|
|
14
|
-
import "./chunk-7GHEQUPV.js";
|
|
15
15
|
import "./chunk-DNGQBPT7.js";
|
|
16
16
|
import "./chunk-G3PMV62Z.js";
|
|
17
|
+
|
|
18
|
+
// src/index.ts
|
|
19
|
+
import { definePreview as definePreviewBase } from "storybook/internal/csf";
|
|
20
|
+
function definePreview(input) {
|
|
21
|
+
return definePreviewBase(input);
|
|
22
|
+
}
|
|
17
23
|
export {
|
|
18
24
|
composeStories,
|
|
19
25
|
composeStory,
|
|
20
26
|
core,
|
|
27
|
+
definePreview,
|
|
21
28
|
defineStoryRules,
|
|
22
29
|
setProjectAnnotations,
|
|
23
30
|
viteFinal
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Re-export types from storybook internal\nexport type {\n Args,\n ArgTypes,\n Parameters,\n ProjectAnnotations,\n StrictArgs\n} from 'storybook/internal/types';\n\nimport { definePreview as definePreviewBase, type PreviewAddon, type InferTypes, type Preview as CsfPreview } from 'storybook/internal/csf';\nimport type { ProjectAnnotations } from 'storybook/internal/types';\nimport type { AstroRenderer } from './portable-stories.ts';\n\n/** Preview configuration type for `.storybook/preview.ts` in Astro projects. */\nexport type Preview = ProjectAnnotations<AstroRenderer>;\n\n// Export portable stories functionality\nexport {\n composeStories,\n composeStory,\n setProjectAnnotations,\n type AstroRenderer\n} from './portable-stories.ts';\n\n// Export framework types\nexport type {\n FrameworkOptions,\n RenderMode,\n RenderStoryInput,\n ServerBuildOptions,\n SanitizationOptions,\n StoryRulesOptions,\n StorybookConfig\n} from './types.ts';\nexport type {\n StoryRuleCleanup,\n StoryRule,\n StoryRulesConfig,\n StoryRuleSelection,\n StoryRuleSelectionInput,\n StoryRuleStory,\n StoryRuleUse,\n StoryRuleUseContext\n} from './rules.ts';\nexport { defineStoryRules } from './rules.ts';\n\n// Re-export preset functionality for framework usage\nexport { core, viteFinal } from './preset.ts';\n\n// Preview configuration helper\nexport function definePreview<Addons extends PreviewAddon<never>[] = []>(\n input: ProjectAnnotations<AstroRenderer> & { addons?: Addons }\n): CsfPreview<AstroRenderer & InferTypes<Addons>> {\n return definePreviewBase<AstroRenderer, Addons>(input);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AASA,SAAS,iBAAiB,yBAAyF;AAyC5G,SAAS,cACd,OACgD;AAChD,SAAO,kBAAyC,KAAK;AACvD;","names":[]}
|
package/dist/middleware.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
applyMswHandlers,
|
|
3
2
|
resolveSanitizationOptions,
|
|
4
3
|
resolveStoryModuleMock,
|
|
5
4
|
sanitizeRenderPayload,
|
|
6
5
|
selectStoryRules,
|
|
7
|
-
withStoryModuleMocks
|
|
8
|
-
|
|
6
|
+
withStoryModuleMocks,
|
|
7
|
+
withStoryRuleCleanups
|
|
8
|
+
} from "./chunk-V76WSNSP.js";
|
|
9
9
|
import "./chunk-G3PMV62Z.js";
|
|
10
10
|
|
|
11
11
|
// src/middleware.ts
|
|
@@ -13,7 +13,36 @@ import { pathToFileURL } from "url";
|
|
|
13
13
|
import { experimental_AstroContainer as AstroContainer } from "astro/container";
|
|
14
14
|
import { addRenderers, resolveClientModules } from "virtual:astro-container-renderers";
|
|
15
15
|
async function handlerFactory(_integrations, options) {
|
|
16
|
-
|
|
16
|
+
if (!globalThis.astroAsset) {
|
|
17
|
+
globalThis.astroAsset = {};
|
|
18
|
+
}
|
|
19
|
+
globalThis.astroAsset.imageService = {
|
|
20
|
+
propertiesToHash: ["src"],
|
|
21
|
+
validateOptions(options2) {
|
|
22
|
+
return options2;
|
|
23
|
+
},
|
|
24
|
+
getURL(options2) {
|
|
25
|
+
const src = options2.src;
|
|
26
|
+
if (src != null && typeof src === "object" && "src" in src && typeof src.src === "string") {
|
|
27
|
+
return src.src;
|
|
28
|
+
}
|
|
29
|
+
return typeof src === "string" ? src : "";
|
|
30
|
+
},
|
|
31
|
+
getHTMLAttributes(options2) {
|
|
32
|
+
const { src, width, height, format, quality, densities, widths, formats, layout, priority, fit, position, background, ...attrs } = options2;
|
|
33
|
+
const srcObj = src != null && typeof src === "object" ? src : null;
|
|
34
|
+
return {
|
|
35
|
+
...attrs,
|
|
36
|
+
width: width ?? srcObj?.width,
|
|
37
|
+
height: height ?? srcObj?.height,
|
|
38
|
+
loading: attrs.loading ?? "lazy",
|
|
39
|
+
decoding: attrs.decoding ?? "async"
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
getSrcSet() {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
};
|
|
17
46
|
const container = await AstroContainer.create({
|
|
18
47
|
// Somewhat hacky way to force client-side Storybook's Vite to resolve modules properly
|
|
19
48
|
resolve: async (specifier) => {
|
|
@@ -70,30 +99,30 @@ async function handlerFactory(_integrations, options) {
|
|
|
70
99
|
const selectedRules = await selectStoryRules({
|
|
71
100
|
configModule: rulesConfigModule,
|
|
72
101
|
configFilePath: options?.rulesConfigFilePath,
|
|
73
|
-
mode,
|
|
74
102
|
story: data.story
|
|
75
103
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
104
|
+
return withStoryRuleCleanups(selectedRules.cleanups, async () => {
|
|
105
|
+
return withStoryModuleMocks(selectedRules.moduleMocks, async () => {
|
|
106
|
+
const patchedComponent = await loadPatchedComponent(
|
|
107
|
+
data.component,
|
|
108
|
+
selectedRules.moduleMocks.size === 0
|
|
109
|
+
);
|
|
110
|
+
const processedArgs = await processImageMetadata(data.args ?? {});
|
|
111
|
+
const sanitizedPayload = sanitizeRenderPayload(
|
|
112
|
+
{
|
|
113
|
+
args: processedArgs,
|
|
114
|
+
slots: data.slots ?? {}
|
|
115
|
+
},
|
|
116
|
+
sanitizationOptions
|
|
117
|
+
);
|
|
118
|
+
return container.renderToString(
|
|
119
|
+
patchedComponent,
|
|
120
|
+
{
|
|
121
|
+
props: sanitizedPayload.args,
|
|
122
|
+
slots: sanitizedPayload.slots
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
});
|
|
97
126
|
});
|
|
98
127
|
};
|
|
99
128
|
const resultPromise = renderQueue.then(executeRender, executeRender);
|
|
@@ -131,14 +160,14 @@ async function processImageMetadata(args) {
|
|
|
131
160
|
const processed = {};
|
|
132
161
|
for (const [key, value] of Object.entries(args)) {
|
|
133
162
|
if (isImageMetadata(value)) {
|
|
134
|
-
processed[key] =
|
|
163
|
+
processed[key] = value;
|
|
135
164
|
continue;
|
|
136
165
|
}
|
|
137
166
|
if (Array.isArray(value)) {
|
|
138
167
|
processed[key] = await Promise.all(
|
|
139
168
|
value.map(async (item) => {
|
|
140
169
|
if (isImageMetadata(item)) {
|
|
141
|
-
return
|
|
170
|
+
return item;
|
|
142
171
|
}
|
|
143
172
|
if (isRecord(item)) {
|
|
144
173
|
return processImageMetadata(item);
|
|
@@ -159,17 +188,6 @@ async function processImageMetadata(args) {
|
|
|
159
188
|
function isImageMetadata(value) {
|
|
160
189
|
return isRecord(value) && typeof value.src === "string" && ("width" in value || "height" in value || "format" in value);
|
|
161
190
|
}
|
|
162
|
-
function convertImageMetadataToUrl(imageMetadata) {
|
|
163
|
-
const src = imageMetadata.src;
|
|
164
|
-
const fsPath = imageMetadata.fsPath;
|
|
165
|
-
if (typeof src === "string") {
|
|
166
|
-
return src;
|
|
167
|
-
}
|
|
168
|
-
if (typeof fsPath === "string") {
|
|
169
|
-
return fsPath;
|
|
170
|
-
}
|
|
171
|
-
return String(imageMetadata);
|
|
172
|
-
}
|
|
173
191
|
function isRecord(value) {
|
|
174
192
|
return typeof value === "object" && value !== null;
|
|
175
193
|
}
|
package/dist/middleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/middleware.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url';\nimport { experimental_AstroContainer as AstroContainer } from 'astro/container';\nimport type { Integration } from './integrations/index.ts';\nimport type { SanitizationOptions } from './lib/sanitization.ts';\nimport { resolveSanitizationOptions, sanitizeRenderPayload } from './lib/sanitization.ts';\nimport { resolveStoryModuleMock, withStoryModuleMocks } from './module-mocks.ts';\nimport { applyMswHandlers } from './msw.ts';\nimport { selectStoryRules } from './rules.ts';\nimport type { RenderStoryInput } from './types.ts';\nimport { addRenderers, resolveClientModules } from 'virtual:astro-container-renderers';\n\ntype ResolveRulesConfigModule = () => unknown | Promise<unknown>;\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 HandlerFactoryOptions = {\n mode?: 'development' | 'production';\n sanitization?: SanitizationOptions;\n rulesConfigFilePath?: string;\n resolveRulesConfigModule?: ResolveRulesConfigModule;\n loadModule?: (id: string) => Promise<{ default: unknown }>;\n};\n\nexport async function handlerFactory(_integrations: Integration[], options?: HandlerFactoryOptions) {\n const mode = options?.mode ?? 'development';\n const container = await AstroContainer.create({\n // Somewhat hacky way to force client-side Storybook's Vite to resolve modules properly\n resolve: async (specifier) => {\n const mockedModule = resolveStoryModuleMock(specifier);\n\n if (mockedModule) {\n return mockedModule;\n }\n\n if (specifier.startsWith('astro:scripts')) {\n return `/@id/${specifier}`;\n }\n\n const resolution = resolveClientModules(specifier);\n\n if (resolution) {\n return resolution;\n }\n\n return specifier;\n }\n });\n\n addRenderers(container);\n const sanitizationOptions = resolveSanitizationOptions(options?.sanitization);\n const loadModule =\n options?.loadModule ??\n ((id: string) => {\n const normalizedId = /^[a-zA-Z]:[/\\\\]/.test(id) ? pathToFileURL(id).href : id;\n\n return import(/* @vite-ignore */ normalizedId);\n });\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 loadModule(componentId);\n\n return patchCreateAstroCompat(component);\n }\n\n if (!componentCache.has(componentId)) {\n componentCache.set(componentId, (async () => {\n const { default: component } = await loadModule(componentId);\n\n return patchCreateAstroCompat(component);\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 // Drop failed entries so transient/module errors can recover on the next request.\n componentCache.delete(componentId);\n throw error;\n }\n }\n\n return async function handler(data: HandlerProps) {\n const executeRender = async () => {\n const rulesConfigModule = options?.resolveRulesConfigModule\n ? await options.resolveRulesConfigModule()\n : undefined;\n\n const selectedRules = await selectStoryRules({\n configModule: rulesConfigModule,\n configFilePath: options?.rulesConfigFilePath,\n mode,\n story: data.story\n });\n\n await applyMswHandlers(selectedRules.mswHandlers);\n\n return withStoryModuleMocks(selectedRules.moduleMocks, async () => {\n const patchedComponent = await loadPatchedComponent(\n data.component,\n selectedRules.moduleMocks.size === 0\n );\n const processedArgs = await processImageMetadata(data.args ?? {});\n const sanitizedPayload = sanitizeRenderPayload(\n {\n args: processedArgs,\n slots: data.slots ?? {}\n },\n sanitizationOptions\n );\n\n return container.renderToString(\n patchedComponent as Parameters<typeof container.renderToString>[0],\n {\n props: sanitizedPayload.args,\n slots: sanitizedPayload.slots\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\nfunction 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 processed[key] = convertImageMetadataToUrl(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 convertImageMetadataToUrl(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 convertImageMetadataToUrl(imageMetadata: Record<string, unknown>): string {\n const src = imageMetadata.src;\n const fsPath = imageMetadata.fsPath;\n\n if (typeof src === 'string') {\n return src;\n }\n\n if (typeof fsPath === 'string') {\n return fsPath;\n }\n\n return String(imageMetadata);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,+BAA+B,sBAAsB;AAQ9D,SAAS,cAAc,4BAA4B;AAiCnD,eAAsB,eAAe,eAA8B,SAAiC;AAClG,QAAM,OAAO,SAAS,QAAQ;AAC9B,QAAM,YAAY,MAAM,eAAe,OAAO;AAAA;AAAA,IAE5C,SAAS,OAAO,cAAc;AAC5B,YAAM,eAAe,uBAAuB,SAAS;AAErD,UAAI,cAAc;AAChB,eAAO;AAAA,MACT;AAEA,UAAI,UAAU,WAAW,eAAe,GAAG;AACzC,eAAO,QAAQ,SAAS;AAAA,MAC1B;AAEA,YAAM,aAAa,qBAAqB,SAAS;AAEjD,UAAI,YAAY;AACd,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AAED,eAAa,SAAS;AACtB,QAAM,sBAAsB,2BAA2B,SAAS,YAAY;AAC5E,QAAM,aACJ,SAAS,eACR,CAAC,OAAe;AACf,UAAM,eAAe,kBAAkB,KAAK,EAAE,IAAI,cAAc,EAAE,EAAE,OAAO;AAE3E,WAAO;AAAA;AAAA,MAA0B;AAAA;AAAA,EACnC;AACF,QAAM,iBAAiB,oBAAI,IAA4C;AACvE,MAAI,cAAc,QAAQ,QAAc,MAAS;AAEjD,iBAAe,qBAAqB,aAAqB,WAAW,MAAM;AACxE,QAAI,CAAC,UAAU;AACb,YAAM,EAAE,SAAS,UAAU,IAAI,MAAM,WAAW,WAAW;AAE3D,aAAO,uBAAuB,SAAS;AAAA,IACzC;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AS,KAAK,GAAG;AACnB,gBAAU,GAAG,IAAI,MAAM,qBAAqB,KAAK;AAEjD;AAAA,IACF;AAEA,cAAU,GAAG,IAAI;AAAA,EACnB;AAEA,SAAO;AACT;AAEA,SAAS,gBAAgB,OAAkD;AACzE,SACE,SAAS,KAAK,KACd,OAAO,MAAM,QAAQ,aACpB,WAAW,SAAS,YAAY,SAAS,YAAY;AAE1D;AAEA,SAAS,0BAA0B,eAAgD;AACjF,QAAM,MAAM,cAAc;AAC1B,QAAM,SAAS,cAAc;AAE7B,MAAI,OAAO,QAAQ,UAAU;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,aAAa;AAC7B;AAEA,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU;AAChD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/middleware.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url';\nimport { experimental_AstroContainer as AstroContainer } from 'astro/container';\nimport type { Integration } from './integrations/index.ts';\nimport type { SanitizationOptions } from './lib/sanitization.ts';\nimport { resolveSanitizationOptions, sanitizeRenderPayload } from './lib/sanitization.ts';\nimport { resolveStoryModuleMock, withStoryModuleMocks } from './module-mocks.ts';\nimport { selectStoryRules, withStoryRuleCleanups } from './rules.ts';\nimport type { RenderStoryInput } from './types.ts';\nimport { addRenderers, resolveClientModules } from 'virtual:astro-container-renderers';\n\ntype ResolveRulesConfigModule = () => unknown | Promise<unknown>;\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 HandlerFactoryOptions = {\n sanitization?: SanitizationOptions;\n rulesConfigFilePath?: string;\n resolveRulesConfigModule?: ResolveRulesConfigModule;\n loadModule?: (id: string) => Promise<{ default: unknown }>;\n};\n\nexport async function handlerFactory(_integrations: Integration[], options?: HandlerFactoryOptions) {\n // Inject a passthrough image service before any component renders.\n //\n // AstroContainer has no image service configuration API, and the default\n // getConfiguredImageService() tries to dynamically import \"virtual:image-service\"\n // which fails in astro6/Vite 7's module runner. Even when it succeeds (astro5),\n // the noop service still routes through /_image?href=... URLs that the Storybook\n // dev server cannot serve.\n //\n // Pre-populating globalThis.astroAsset.imageService bypasses the dynamic import\n // entirely. Our service returns the direct /@fs/... Vite URL from the ImageMetadata\n // object, which Vite can serve as a static asset in the browser.\n if (!globalThis.astroAsset) {\n (globalThis as Record<string, unknown>).astroAsset = {};\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 (src != null && typeof src === 'object' && 'src' in src && typeof (src as Record<string, unknown>).src === 'string') {\n // ImageMetadata object — return the /@fs/... Vite URL directly\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 { src, width, height, format, quality, densities, widths, formats, layout, priority, fit, position, background, ...attrs } = options;\n const srcObj = src != null && typeof src === 'object' ? src as Record<string, unknown> : null;\n\n return {\n ...attrs,\n width: width ?? srcObj?.width,\n height: height ?? srcObj?.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 const container = await AstroContainer.create({\n // Somewhat hacky way to force client-side Storybook's Vite to resolve modules properly\n resolve: async (specifier) => {\n const mockedModule = resolveStoryModuleMock(specifier);\n\n if (mockedModule) {\n return mockedModule;\n }\n\n if (specifier.startsWith('astro:scripts')) {\n return `/@id/${specifier}`;\n }\n\n const resolution = resolveClientModules(specifier);\n\n if (resolution) {\n return resolution;\n }\n\n return specifier;\n }\n });\n\n addRenderers(container);\n const sanitizationOptions = resolveSanitizationOptions(options?.sanitization);\n const loadModule =\n options?.loadModule ??\n ((id: string) => {\n const normalizedId = /^[a-zA-Z]:[/\\\\]/.test(id) ? pathToFileURL(id).href : id;\n\n return import(/* @vite-ignore */ normalizedId);\n });\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 loadModule(componentId);\n\n return patchCreateAstroCompat(component);\n }\n\n if (!componentCache.has(componentId)) {\n componentCache.set(componentId, (async () => {\n const { default: component } = await loadModule(componentId);\n\n return patchCreateAstroCompat(component);\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 // Drop failed entries so transient/module errors can recover on the next request.\n componentCache.delete(componentId);\n throw error;\n }\n }\n\n return async function handler(data: HandlerProps) {\n const executeRender = async () => {\n const rulesConfigModule = options?.resolveRulesConfigModule\n ? await options.resolveRulesConfigModule()\n : undefined;\n\n const selectedRules = await selectStoryRules({\n configModule: rulesConfigModule,\n configFilePath: options?.rulesConfigFilePath,\n story: data.story\n });\n\n return withStoryRuleCleanups(selectedRules.cleanups, async () => {\n return withStoryModuleMocks(selectedRules.moduleMocks, async () => {\n const patchedComponent = await loadPatchedComponent(\n data.component,\n selectedRules.moduleMocks.size === 0\n );\n const processedArgs = await processImageMetadata(data.args ?? {});\n const sanitizedPayload = sanitizeRenderPayload(\n {\n args: processedArgs,\n slots: data.slots ?? {}\n },\n sanitizationOptions\n );\n\n return container.renderToString(\n patchedComponent as Parameters<typeof 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\nfunction 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 a plain object — Astro's image service checks\n // isESMImportedImage (typeof src === 'object') and skips the /@fs/ string\n // validation that throws LocalImageUsedWrongly. Converting to a URL string\n // causes that error when the string starts with /@fs/.\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\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,+BAA+B,sBAAsB;AAO9D,SAAS,cAAc,4BAA4B;AAgCnD,eAAsB,eAAe,eAA8B,SAAiC;AAYlG,MAAI,CAAC,WAAW,YAAY;AAC1B,IAAC,WAAuC,aAAa,CAAC;AAAA,EACxD;AACA,EAAC,WAAW,WAAuC,eAAe;AAAA,IAChE,kBAAkB,CAAC,KAAK;AAAA,IACxB,gBAAgBA,UAAkC;AAChD,aAAOA;AAAA,IACT;AAAA,IACA,OAAOA,UAA2B;AAChC,YAAM,MAAMA,SAAQ;AAEpB,UAAI,OAAO,QAAQ,OAAO,QAAQ,YAAY,SAAS,OAAO,OAAQ,IAAgC,QAAQ,UAAU;AAEtH,eAAQ,IAAgC;AAAA,MAC1C;AAEA,aAAO,OAAO,QAAQ,WAAW,MAAM;AAAA,IACzC;AAAA,IACA,kBAAkBA,UAAkC;AAClD,YAAM,EAAE,KAAK,OAAO,QAAQ,QAAQ,SAAS,WAAW,QAAQ,SAAS,QAAQ,UAAU,KAAK,UAAU,YAAY,GAAG,MAAM,IAAIA;AACnI,YAAM,SAAS,OAAO,QAAQ,OAAO,QAAQ,WAAW,MAAiC;AAEzF,aAAO;AAAA,QACL,GAAG;AAAA,QACH,OAAO,SAAS,QAAQ;AAAA,QACxB,QAAQ,UAAU,QAAQ;AAAA,QAC1B,SAAU,MAAM,WAAkC;AAAA,QAClD,UAAW,MAAM,YAAmC;AAAA,MACtD;AAAA,IACF;AAAA,IACA,YAAY;AACV,aAAO,CAAC;AAAA,IACV;AAAA,EACF;AAEA,QAAM,YAAY,MAAM,eAAe,OAAO;AAAA;AAAA,IAE5C,SAAS,OAAO,cAAc;AAC5B,YAAM,eAAe,uBAAuB,SAAS;AAErD,UAAI,cAAc;AAChB,eAAO;AAAA,MACT;AAEA,UAAI,UAAU,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AAEA,UAAQ,0BAA0B,kBAAkB;AACpD,UAAQ,WAAW,kBAAkB;AACrC,UAAQ,cAAc,kBAAkB;AAExC,SAAO;AACT;AAEA,eAAe,qBACb,MACkC;AAClC,QAAM,YAAqC,CAAC;AAE5C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC/C,QAAI,gBAAgB,KAAK,GAAG;AAK1B,gBAAU,GAAG,IAAI;AAEjB;AAAA,IACF;AAEA,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,gBAAU,GAAG,IAAI,MAAM,QAAQ;AAAA,QAC7B,MAAM,IAAI,OAAO,SAAS;AACxB,cAAI,gBAAgB,IAAI,GAAG;AACzB,mBAAO;AAAA,UACT;AAEA,cAAI,SAAS,IAAI,GAAG;AAClB,mBAAO,qBAAqB,IAAI;AAAA,UAClC;AAEA,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAEA;AAAA,IACF;AAEA,QAAI,SAAS,KAAK,GAAG;AACnB,gBAAU,GAAG,IAAI,MAAM,qBAAqB,KAAK;AAEjD;AAAA,IACF;AAEA,cAAU,GAAG,IAAI;AAAA,EACnB;AAEA,SAAO;AACT;AAEA,SAAS,gBAAgB,OAAkD;AACzE,SACE,SAAS,KAAK,KACd,OAAO,MAAM,QAAQ,aACpB,WAAW,SAAS,YAAY,SAAS,YAAY;AAE1D;AAGA,SAAS,SAAS,OAAkD;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU;AAChD;","names":["options"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { d as StorybookConfig } from '../types-Cvor6Tyi.js';
|
|
2
|
+
import 'storybook/internal/types';
|
|
3
|
+
import 'vite';
|
|
4
|
+
import '../base-IRZo3zgK.js';
|
|
5
|
+
import 'astro';
|
|
6
|
+
import 'sanitize-html';
|
|
7
|
+
|
|
8
|
+
declare function defineMain(config: StorybookConfig): StorybookConfig;
|
|
9
|
+
|
|
10
|
+
export { StorybookConfig, defineMain };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/index.ts"],"sourcesContent":["import type { StorybookConfig } from '../types.ts';\n\nexport function defineMain(config: StorybookConfig): StorybookConfig {\n return config;\n}\n\nexport type { StorybookConfig };\n"],"mappings":";;;AAEO,SAAS,WAAW,QAA0C;AACnE,SAAO;AACT;","names":[]}
|
package/dist/preset.d.ts
CHANGED
package/dist/preset.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
core,
|
|
3
3
|
viteFinal
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-VPJDFGB5.js";
|
|
5
|
+
import "./chunk-V76WSNSP.js";
|
|
6
|
+
import "./chunk-POHTFYST.js";
|
|
6
7
|
import "./chunk-E4LB75JN.js";
|
|
7
|
-
import "./chunk-7GHEQUPV.js";
|
|
8
8
|
import "./chunk-DNGQBPT7.js";
|
|
9
9
|
import "./chunk-G3PMV62Z.js";
|
|
10
10
|
export {
|
package/dist/testing.js
CHANGED
|
@@ -4,13 +4,17 @@ import {
|
|
|
4
4
|
setProjectAnnotations
|
|
5
5
|
} from "./chunk-5EF25G5S.js";
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
renderViaTestingRendererDaemon,
|
|
8
|
+
runWithWorkingDirectory
|
|
9
|
+
} from "./chunk-T7NWIO5S.js";
|
|
10
10
|
import {
|
|
11
11
|
ssrLoadModuleWithFsFallback
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-POHTFYST.js";
|
|
13
|
+
import {
|
|
14
|
+
resolveTestingIntegrationsForRoot
|
|
15
|
+
} from "./chunk-4SWPVM6R.js";
|
|
13
16
|
import "./chunk-DNGQBPT7.js";
|
|
17
|
+
import "./chunk-PJEDXZVN.js";
|
|
14
18
|
import "./chunk-G3PMV62Z.js";
|
|
15
19
|
|
|
16
20
|
// src/testing/story-composition.ts
|
|
@@ -29,7 +33,7 @@ var composeStory2 = composeStory;
|
|
|
29
33
|
var setProjectAnnotations2 = setProjectAnnotations;
|
|
30
34
|
|
|
31
35
|
// src/testing/astro-runtime.ts
|
|
32
|
-
import { fileURLToPath as
|
|
36
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
33
37
|
|
|
34
38
|
// src/testing/project-root.ts
|
|
35
39
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -188,62 +192,6 @@ async function resolveTestingProjectRoot(component) {
|
|
|
188
192
|
return process.cwd();
|
|
189
193
|
}
|
|
190
194
|
|
|
191
|
-
// src/testing/working-directory.ts
|
|
192
|
-
var workingDirectoryLock = Promise.resolve();
|
|
193
|
-
async function runWithWorkingDirectory(dir, fn) {
|
|
194
|
-
const previousLock = workingDirectoryLock;
|
|
195
|
-
let releaseLock;
|
|
196
|
-
workingDirectoryLock = new Promise((resolve2) => {
|
|
197
|
-
releaseLock = resolve2;
|
|
198
|
-
});
|
|
199
|
-
await previousLock;
|
|
200
|
-
const previousCwd = process.cwd();
|
|
201
|
-
try {
|
|
202
|
-
if (previousCwd !== dir) {
|
|
203
|
-
process.chdir(dir);
|
|
204
|
-
}
|
|
205
|
-
return await fn();
|
|
206
|
-
} finally {
|
|
207
|
-
if (process.cwd() !== previousCwd) {
|
|
208
|
-
process.chdir(previousCwd);
|
|
209
|
-
}
|
|
210
|
-
releaseLock();
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// src/testing/renderer-daemon.ts
|
|
215
|
-
import { createServer as createHttpServer } from "http";
|
|
216
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
217
|
-
var TESTING_RENDERER_DAEMON_URL_ENV = "STORYBOOK_ASTRO_TESTING_RENDERER_DAEMON_URL";
|
|
218
|
-
function getTestingRendererDaemonUrl() {
|
|
219
|
-
const value = process.env[TESTING_RENDERER_DAEMON_URL_ENV];
|
|
220
|
-
if (!value || value.length === 0) {
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
return value;
|
|
224
|
-
}
|
|
225
|
-
async function renderViaTestingRendererDaemon(payload) {
|
|
226
|
-
const daemonUrl = getTestingRendererDaemonUrl();
|
|
227
|
-
if (!daemonUrl) {
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
const response = await fetch(daemonUrl, {
|
|
231
|
-
method: "POST",
|
|
232
|
-
headers: {
|
|
233
|
-
"content-type": "application/json"
|
|
234
|
-
},
|
|
235
|
-
body: JSON.stringify(payload)
|
|
236
|
-
});
|
|
237
|
-
const parsed = await response.json();
|
|
238
|
-
if (!response.ok) {
|
|
239
|
-
throw new Error(parsed.error ?? `Renderer daemon returned ${response.status}.`);
|
|
240
|
-
}
|
|
241
|
-
if (typeof parsed.html !== "string") {
|
|
242
|
-
throw new Error("Renderer daemon returned an invalid payload.");
|
|
243
|
-
}
|
|
244
|
-
return parsed.html;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
195
|
// src/testing/astro-runtime.ts
|
|
248
196
|
var astroContainerPromise = null;
|
|
249
197
|
var astroSsrViteServerPromises = /* @__PURE__ */ new Map();
|
|
@@ -264,11 +212,11 @@ async function getAstroContainer() {
|
|
|
264
212
|
}
|
|
265
213
|
async function getAstroSsrViteServer(resolveFrom) {
|
|
266
214
|
if (!astroSsrViteServerPromises.has(resolveFrom)) {
|
|
267
|
-
const { createViteServer
|
|
215
|
+
const { createViteServer } = await import("./viteStorybookAstroMiddlewarePlugin-2EFKTECT.js");
|
|
268
216
|
const integrations = getTestingIntegrations(resolveFrom);
|
|
269
217
|
astroSsrViteServerPromises.set(
|
|
270
218
|
resolveFrom,
|
|
271
|
-
runWithWorkingDirectory(resolveFrom, () =>
|
|
219
|
+
runWithWorkingDirectory(resolveFrom, () => createViteServer(integrations, resolveFrom))
|
|
272
220
|
);
|
|
273
221
|
}
|
|
274
222
|
return astroSsrViteServerPromises.get(resolveFrom);
|
|
@@ -278,7 +226,7 @@ async function getAstroSsrHandler(resolveFrom) {
|
|
|
278
226
|
astroSsrHandlerPromises.set(resolveFrom, (async () => {
|
|
279
227
|
const integrations = getTestingIntegrations(resolveFrom);
|
|
280
228
|
const viteServer = await getAstroSsrViteServer(resolveFrom);
|
|
281
|
-
const middlewareModulePath =
|
|
229
|
+
const middlewareModulePath = fileURLToPath2(new URL("../middleware", import.meta.url));
|
|
282
230
|
const middleware = await runWithWorkingDirectory(
|
|
283
231
|
resolveFrom,
|
|
284
232
|
() => viteServer.ssrLoadModule(middlewareModulePath, {
|