@storybook-astro/framework 0.1.0-beta.8 → 1.0.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.
Files changed (92) hide show
  1. package/README.md +38 -0
  2. package/dist/base-IRZo3zgK.d.ts +23 -0
  3. package/dist/chunk-4SWPVM6R.js +96 -0
  4. package/dist/chunk-4SWPVM6R.js.map +1 -0
  5. package/dist/chunk-5EF25G5S.js +69 -0
  6. package/dist/chunk-5EF25G5S.js.map +1 -0
  7. package/dist/chunk-7GHEQUPV.js +439 -0
  8. package/dist/chunk-7GHEQUPV.js.map +1 -0
  9. package/dist/chunk-C5OH4VBR.js +492 -0
  10. package/dist/chunk-C5OH4VBR.js.map +1 -0
  11. package/dist/chunk-DNGQBPT7.js +15 -0
  12. package/dist/chunk-DNGQBPT7.js.map +1 -0
  13. package/dist/chunk-E4LB75JN.js +89 -0
  14. package/dist/chunk-E4LB75JN.js.map +1 -0
  15. package/dist/chunk-PJEDXZVN.js +240 -0
  16. package/dist/chunk-PJEDXZVN.js.map +1 -0
  17. package/dist/chunk-UK43WNEA.js +657 -0
  18. package/dist/chunk-UK43WNEA.js.map +1 -0
  19. package/dist/dist-HJOEPVRQ.js +15574 -0
  20. package/dist/dist-HJOEPVRQ.js.map +1 -0
  21. package/dist/index.d.ts +42 -0
  22. package/dist/index.js +13 -64
  23. package/dist/index.js.map +1 -1
  24. package/dist/integrations/index.d.ts +138 -0
  25. package/dist/integrations/index.js +8 -196
  26. package/dist/integrations/index.js.map +1 -1
  27. package/dist/middleware.d.ts +26 -0
  28. package/dist/middleware.js +179 -0
  29. package/dist/middleware.js.map +1 -0
  30. package/dist/portable-stories-BvdaQigq.d.ts +83 -0
  31. package/dist/preset.d.ts +14 -0
  32. package/dist/preset.js +5 -1
  33. package/dist/testing.d.ts +27 -0
  34. package/dist/testing.js +324 -15539
  35. package/dist/testing.js.map +1 -1
  36. package/dist/types-CHTsRtA7.d.ts +42 -0
  37. package/dist/viteStorybookAstroMiddlewarePlugin-NP2E52IC.js +11 -0
  38. package/dist/viteStorybookAstroMiddlewarePlugin-NP2E52IC.js.map +1 -0
  39. package/dist/vitest/index.d.ts +19 -0
  40. package/dist/vitest/index.js +229 -0
  41. package/dist/vitest/index.js.map +1 -0
  42. package/package.json +31 -17
  43. package/src/importAstroConfig.ts +11 -0
  44. package/src/index.ts +20 -6
  45. package/src/integrations/alpine.ts +5 -2
  46. package/src/integrations/base.ts +2 -2
  47. package/src/integrations/moduleResolver.ts +43 -0
  48. package/src/integrations/preact.ts +5 -2
  49. package/src/integrations/react.ts +5 -2
  50. package/src/integrations/solid.ts +5 -2
  51. package/src/integrations/svelte.ts +5 -2
  52. package/src/integrations/vue.ts +5 -2
  53. package/src/lib/sanitization.test.ts +232 -0
  54. package/src/lib/sanitization.ts +338 -0
  55. package/src/lib/ssr-load-module-with-fs-fallback.ts +29 -0
  56. package/src/middleware.test.ts +48 -0
  57. package/src/middleware.ts +204 -96
  58. package/src/module-mocks.ts +16 -0
  59. package/src/msw-helpers.ts +1 -0
  60. package/src/msw.ts +58 -0
  61. package/src/preset.ts +38 -3
  62. package/src/rules-options.test.ts +71 -0
  63. package/src/rules-options.ts +87 -0
  64. package/src/rules.test.ts +183 -0
  65. package/src/rules.ts +314 -0
  66. package/src/testing/astro-runtime.ts +219 -0
  67. package/src/testing/component-utils.ts +32 -0
  68. package/src/testing/index.ts +2 -0
  69. package/src/testing/integration-config.ts +121 -0
  70. package/src/testing/project-root.ts +185 -0
  71. package/src/testing/renderer-daemon.ts +269 -0
  72. package/src/testing/story-composition.ts +33 -0
  73. package/src/testing/types.ts +14 -0
  74. package/src/testing/working-directory.ts +28 -0
  75. package/src/testing.ts +1 -254
  76. package/src/types.ts +16 -4
  77. package/src/virtual.d.ts +2 -1
  78. package/src/vite/createVirtualModulePlugin.test.ts +80 -0
  79. package/src/vite/createVirtualModulePlugin.ts +25 -0
  80. package/src/viteAstroContainerRenderersPlugin.ts +60 -26
  81. package/src/vitePluginAstro.ts +12 -5
  82. package/src/vitePluginAstroBuildPrerender.ts +665 -204
  83. package/src/vitePluginAstroRoutesFallback.ts +37 -0
  84. package/src/vitePluginAstroVueFallback.ts +47 -0
  85. package/src/viteStorybookAstroMiddlewarePlugin.ts +88 -12
  86. package/src/viteStorybookRendererFallbackPlugin.ts +13 -23
  87. package/src/vitest/config.ts +95 -0
  88. package/src/vitest/global-setup.ts +16 -0
  89. package/src/vitest/index.ts +2 -0
  90. package/src/vitest/vite-plugins.ts +187 -0
  91. package/dist/chunk-SAOPE6SA.js +0 -557
  92. package/dist/chunk-SAOPE6SA.js.map +0 -1
@@ -0,0 +1,42 @@
1
+ import { CompatibleString, Options } from 'storybook/internal/types';
2
+ import { InlineConfig } from 'vite';
3
+ import { I as Integration } from './base-IRZo3zgK.js';
4
+ import { IOptions } from 'sanitize-html';
5
+
6
+ type SanitizationOptions = {
7
+ enabled?: boolean;
8
+ args?: string[];
9
+ slots?: string[];
10
+ sanitizeHtml?: IOptions;
11
+ };
12
+
13
+ type StoryRulesOptions = string | {
14
+ configFile: string;
15
+ };
16
+
17
+ type FrameworkName = CompatibleString<'@storybook-astro/framework'>;
18
+
19
+ type RenderStoryInput = {
20
+ id: string;
21
+ title?: string;
22
+ name?: string;
23
+ };
24
+ type FrameworkOptions = {
25
+ integrations?: Integration[];
26
+ sanitization?: SanitizationOptions;
27
+ storyRules?: StoryRulesOptions;
28
+ resolveFrom?: string;
29
+ };
30
+ type StorybookConfigFramework = {
31
+ framework: {
32
+ name: FrameworkName;
33
+ options?: FrameworkOptions;
34
+ };
35
+ };
36
+ type StorybookConfig = StorybookConfigFramework;
37
+ type ViteFinal = (config: InlineConfig, options: Options) => InlineConfig | Promise<InlineConfig>;
38
+ type StorybookConfigVite = {
39
+ viteFinal?: ViteFinal;
40
+ };
41
+
42
+ export type { FrameworkOptions as F, RenderStoryInput as R, SanitizationOptions as S, StoryRulesOptions as a, StorybookConfig as b, StorybookConfigVite as c };
@@ -0,0 +1,11 @@
1
+ import {
2
+ createViteServer,
3
+ vitePluginStorybookAstroMiddleware
4
+ } from "./chunk-7GHEQUPV.js";
5
+ import "./chunk-DNGQBPT7.js";
6
+ import "./chunk-G3PMV62Z.js";
7
+ export {
8
+ createViteServer,
9
+ vitePluginStorybookAstroMiddleware
10
+ };
11
+ //# sourceMappingURL=viteStorybookAstroMiddlewarePlugin-NP2E52IC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,19 @@
1
+ import { InlineConfig, PluginOption, Plugin } from 'vite';
2
+ import { I as Integration } from '../base-IRZo3zgK.js';
3
+ import { AstroIntegration } from 'astro';
4
+
5
+ type TestingDefineConfig = Omit<InlineConfig, 'plugins' | 'test'> & {
6
+ integrations?: Integration[];
7
+ plugins?: PluginOption[];
8
+ astroConfigFile?: false | string;
9
+ test?: any;
10
+ };
11
+ declare function defineConfig(options: TestingDefineConfig): ({ mode: viteMode, command }: {
12
+ mode: string;
13
+ command: "build" | "serve";
14
+ }) => Promise<any>;
15
+
16
+ declare function vitestPatchForSolidJs(): AstroIntegration;
17
+ declare function cjsInteropPlugin(): Plugin;
18
+
19
+ export { type TestingDefineConfig, cjsInteropPlugin, defineConfig, vitestPatchForSolidJs };
@@ -0,0 +1,229 @@
1
+ import {
2
+ vitePluginAstroComponentMarker
3
+ } from "../chunk-E4LB75JN.js";
4
+ import {
5
+ registerTestingIntegrationsForRoot
6
+ } from "../chunk-4SWPVM6R.js";
7
+ import "../chunk-PJEDXZVN.js";
8
+ import {
9
+ importAstroConfig
10
+ } from "../chunk-DNGQBPT7.js";
11
+ import "../chunk-G3PMV62Z.js";
12
+
13
+ // ../../../node_modules/vitest/dist/config.js
14
+ import { mergeConfig } from "vite";
15
+ import "os";
16
+ function defineConfig(config) {
17
+ return config;
18
+ }
19
+
20
+ // src/vitest/config.ts
21
+ import { fileURLToPath } from "url";
22
+
23
+ // src/vitest/vite-plugins.ts
24
+ import { existsSync, readFileSync } from "fs";
25
+ import { dirname, join } from "path";
26
+ function findPackageDir(pkgName) {
27
+ let dir = process.cwd();
28
+ while (true) {
29
+ const candidate = join(dir, "node_modules", pkgName);
30
+ if (existsSync(join(candidate, "package.json"))) {
31
+ return candidate;
32
+ }
33
+ const parent = dirname(dir);
34
+ if (parent === dir) {
35
+ break;
36
+ }
37
+ dir = parent;
38
+ }
39
+ return null;
40
+ }
41
+ function vitestPatchForSolidJs() {
42
+ return {
43
+ name: "fix-solid",
44
+ hooks: {
45
+ "astro:config:done": ({ config }) => {
46
+ const solidPlugin = config.vite.plugins?.find(
47
+ (plugin) => plugin && "name" in plugin && plugin.name === "solid"
48
+ );
49
+ if (!solidPlugin) {
50
+ return;
51
+ }
52
+ const originalConfigEnvironment = solidPlugin.configEnvironment;
53
+ if (typeof originalConfigEnvironment !== "function") {
54
+ return;
55
+ }
56
+ solidPlugin.configEnvironment = async (name, resolvedConfig, opts) => {
57
+ await originalConfigEnvironment(name, resolvedConfig, opts);
58
+ const config2 = resolvedConfig;
59
+ config2.resolve ??= {};
60
+ const alias = config2.resolve.alias;
61
+ const replacement = "solid-js/web/dist/web.js";
62
+ if (Array.isArray(alias)) {
63
+ const hasAlias = alias.some((entry) => {
64
+ if (!entry || typeof entry !== "object" || !("find" in entry)) {
65
+ return false;
66
+ }
67
+ return entry.find === "solid-js/web" || String(entry.find) === "/^solid-js\\/web$/";
68
+ });
69
+ if (!hasAlias) {
70
+ alias.unshift({ find: /^solid-js\/web$/, replacement });
71
+ }
72
+ return;
73
+ }
74
+ config2.resolve.alias = {
75
+ ...alias ?? {},
76
+ "solid-js/web": replacement
77
+ };
78
+ };
79
+ }
80
+ }
81
+ };
82
+ }
83
+ function cjsInteropPlugin() {
84
+ return {
85
+ name: "cjs-esm-interop",
86
+ enforce: "pre",
87
+ resolveId(id) {
88
+ if (id.startsWith(".") || id.startsWith("/") || id.startsWith("\0") || id.includes("node_modules")) {
89
+ return;
90
+ }
91
+ const parts = id.split("/");
92
+ const pkgName = id.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
93
+ const subpath = parts.slice(pkgName.split("/").length).join("/");
94
+ if (subpath && !["server-renderer", "server", "client"].includes(subpath)) {
95
+ return;
96
+ }
97
+ try {
98
+ const nmDir = findPackageDir(pkgName);
99
+ if (!nmDir) {
100
+ return;
101
+ }
102
+ const pkgJsonPath = join(nmDir, "package.json");
103
+ if (!existsSync(pkgJsonPath)) {
104
+ return;
105
+ }
106
+ const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
107
+ const exportKey = subpath ? `./${subpath}` : ".";
108
+ const exportEntry = pkgJson.exports?.[exportKey];
109
+ if (exportEntry) {
110
+ const importEntry = exportEntry.import;
111
+ if (importEntry) {
112
+ const esmPath = typeof importEntry === "string" ? importEntry : importEntry.default || importEntry.node;
113
+ if (esmPath) {
114
+ const resolved = join(nmDir, esmPath);
115
+ if (existsSync(resolved)) {
116
+ return resolved;
117
+ }
118
+ }
119
+ }
120
+ }
121
+ if (!subpath && pkgJson.module) {
122
+ const resolved = join(nmDir, pkgJson.module);
123
+ if (existsSync(resolved)) {
124
+ return resolved;
125
+ }
126
+ }
127
+ } catch {
128
+ }
129
+ },
130
+ transform(code, id) {
131
+ if (!id.includes("node_modules")) {
132
+ return;
133
+ }
134
+ if (id.startsWith("\0")) {
135
+ return;
136
+ }
137
+ if (/\bexport\s+(default|const|let|var|function|class|\{|\*)/.test(code)) {
138
+ return;
139
+ }
140
+ if (!code.includes("module.exports") && !code.includes("exports.")) {
141
+ return;
142
+ }
143
+ const dirPath = id.substring(0, id.lastIndexOf("/"));
144
+ const fileName = id;
145
+ return {
146
+ code: [
147
+ 'import { createRequire as __createRequire } from "module";',
148
+ `var __require = __createRequire("file://${dirPath}/");`,
149
+ "var module = { exports: {} };",
150
+ "var exports = module.exports;",
151
+ "function require(id) { return __require(id); }",
152
+ `var __dirname = ${JSON.stringify(dirPath)};`,
153
+ `var __filename = ${JSON.stringify(fileName)};`,
154
+ code,
155
+ "export default module.exports;"
156
+ ].join("\n"),
157
+ map: null
158
+ };
159
+ }
160
+ };
161
+ }
162
+
163
+ // src/vitest/config.ts
164
+ function normalizeGlobalSetup(globalSetup, value) {
165
+ if (!globalSetup) {
166
+ return [value];
167
+ }
168
+ if (Array.isArray(globalSetup)) {
169
+ if (globalSetup.includes(value)) {
170
+ return globalSetup;
171
+ }
172
+ return [...globalSetup, value];
173
+ }
174
+ if (globalSetup === value) {
175
+ return [globalSetup];
176
+ }
177
+ return [globalSetup, value];
178
+ }
179
+ function defineConfig2(options) {
180
+ const {
181
+ integrations = [],
182
+ plugins = [],
183
+ root = process.cwd(),
184
+ mode = "test",
185
+ astroConfigFile = false,
186
+ ...rest
187
+ } = options;
188
+ registerTestingIntegrationsForRoot(root, integrations);
189
+ const globalSetupFilePath = fileURLToPath(new URL("./global-setup.ts", import.meta.url));
190
+ const testConfig = {
191
+ ...rest.test,
192
+ globalSetup: normalizeGlobalSetup(rest.test?.globalSetup, globalSetupFilePath)
193
+ };
194
+ const vitestConfig = defineConfig({
195
+ ...rest,
196
+ root,
197
+ mode,
198
+ test: testConfig,
199
+ plugins: [
200
+ cjsInteropPlugin(),
201
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
202
+ vitePluginAstroComponentMarker(),
203
+ ...plugins
204
+ ]
205
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
206
+ });
207
+ const astroConfigFactoryPromise = Promise.all([
208
+ importAstroConfig(root),
209
+ Promise.all(integrations.map((integration) => integration.loadIntegration(root)))
210
+ ]).then(
211
+ ([astroConfigModule, resolvedIntegrations]) => (
212
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
213
+ astroConfigModule.getViteConfig(vitestConfig, {
214
+ configFile: astroConfigFile,
215
+ integrations: [...resolvedIntegrations, vitestPatchForSolidJs()]
216
+ })
217
+ )
218
+ );
219
+ return async ({ mode: viteMode, command }) => {
220
+ const astroConfigFactory = await astroConfigFactoryPromise;
221
+ return astroConfigFactory({ mode: viteMode, command });
222
+ };
223
+ }
224
+ export {
225
+ cjsInteropPlugin,
226
+ defineConfig2 as defineConfig,
227
+ vitestPatchForSolidJs
228
+ };
229
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../node_modules/vitest/dist/config.js","../../src/vitest/config.ts","../../src/vitest/vite-plugins.ts"],"sourcesContent":["export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.BOqNVLsY.js';\nexport { mergeConfig } from 'vite';\nexport { d as defaultBrowserPort } from './chunks/constants.D_Q9UYh-.js';\nimport 'node:os';\nimport './chunks/env.D4Lgay0q.js';\nimport 'std-env';\n\nfunction defineConfig(config) {\n\treturn config;\n}\nfunction defineProject(config) {\n\treturn config;\n}\n\nexport { defineConfig, defineProject };\n","import { defineConfig as defineVitestConfig } from 'vitest/config';\nimport { fileURLToPath } from 'node:url';\nimport type { InlineConfig, PluginOption } from 'vite';\nimport type { Integration } from '../integrations/base.ts';\nimport { importAstroConfig } from '../importAstroConfig.ts';\nimport { vitePluginAstroComponentMarker } from '../vitePluginAstroComponentMarker.ts';\nimport { registerTestingIntegrationsForRoot } from '../testing/integration-config.ts';\nimport { cjsInteropPlugin, vitestPatchForSolidJs } from './vite-plugins.ts';\n\n// Type definition omits 'test' to allow Vitest-specific config options\n// Vite 8 type definitions conflict with Vitest config when used in monorepo\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Vitest config requires any type for test option\nexport type TestingDefineConfig = Omit<InlineConfig, 'plugins' | 'test'> & {\n integrations?: Integration[];\n plugins?: PluginOption[];\n astroConfigFile?: false | string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n test?: any;\n};\n\nfunction normalizeGlobalSetup(globalSetup: string | string[] | undefined, value: string) {\n // Inject our setup without clobbering any user-provided global setup hooks.\n if (!globalSetup) {\n return [value];\n }\n\n if (Array.isArray(globalSetup)) {\n if (globalSetup.includes(value)) {\n return globalSetup;\n }\n\n return [...globalSetup, value];\n }\n\n if (globalSetup === value) {\n return [globalSetup];\n }\n\n return [globalSetup, value];\n}\n\nexport function defineConfig(options: TestingDefineConfig) {\n const {\n integrations = [],\n plugins = [],\n root = process.cwd(),\n mode = 'test',\n astroConfigFile = false,\n ...rest\n } = options;\n\n registerTestingIntegrationsForRoot(root, integrations);\n\n const globalSetupFilePath = fileURLToPath(new URL('./global-setup.ts', import.meta.url));\n const testConfig = {\n ...rest.test,\n globalSetup: normalizeGlobalSetup(rest.test?.globalSetup, globalSetupFilePath)\n };\n\n // Cast to any to work around Vite 8 type conflicts in monorepo environments\n // where multiple Vite versions exist in node_modules\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Type conflict with Vite 8 in monorepo\n const vitestConfig = defineVitestConfig({\n ...rest,\n root,\n mode,\n test: testConfig,\n plugins: [\n cjsInteropPlugin(),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n vitePluginAstroComponentMarker() as any,\n ...plugins\n ]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any);\n\n const astroConfigFactoryPromise = Promise\n .all([\n importAstroConfig(root),\n Promise.all(integrations.map((integration) => integration.loadIntegration(root)))\n ])\n .then(([astroConfigModule, resolvedIntegrations]) =>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n astroConfigModule.getViteConfig(vitestConfig as any, {\n configFile: astroConfigFile,\n integrations: [...resolvedIntegrations, vitestPatchForSolidJs()]\n })\n );\n\n return async ({ mode: viteMode, command }: { mode: string; command: 'build' | 'serve' }) => {\n const astroConfigFactory = await astroConfigFactoryPromise;\n\n return astroConfigFactory({ mode: viteMode, command });\n };\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type { AstroIntegration } from 'astro';\nimport type { Plugin } from 'vite';\n\ntype ResolveConfig = { resolve?: { alias?: Record<string, string> | Array<{ find: string | RegExp; replacement: string }> } };\n\nfunction findPackageDir(pkgName: string): string | null {\n let dir = process.cwd();\n\n while (true) {\n const candidate = join(dir, 'node_modules', pkgName);\n\n if (existsSync(join(candidate, 'package.json'))) {\n return candidate;\n }\n\n const parent = dirname(dir);\n\n if (parent === dir) {\n break;\n }\n\n dir = parent;\n }\n\n return null;\n}\n\nexport function vitestPatchForSolidJs(): AstroIntegration {\n return {\n name: 'fix-solid',\n hooks: {\n 'astro:config:done': ({ config }) => {\n const solidPlugin = config.vite.plugins?.find(\n (plugin) => plugin && 'name' in plugin && plugin.name === 'solid'\n ) as Plugin | undefined;\n\n if (!solidPlugin) {\n return;\n }\n\n const originalConfigEnvironment = solidPlugin.configEnvironment;\n\n if (typeof originalConfigEnvironment !== 'function') {\n return;\n }\n\n // Use bracket notation to avoid type assignment issues\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (solidPlugin as any).configEnvironment = async (name: unknown, resolvedConfig: unknown, opts: unknown): Promise<void> => {\n await (originalConfigEnvironment as (name: unknown, config: unknown, opts: unknown) => Promise<void>)(name, resolvedConfig, opts);\n\n const config = resolvedConfig as ResolveConfig;\n\n config.resolve ??= {};\n const alias = config.resolve.alias;\n const replacement = 'solid-js/web/dist/web.js';\n\n if (Array.isArray(alias)) {\n const hasAlias = alias.some((entry) => {\n if (!entry || typeof entry !== 'object' || !('find' in entry)) {\n return false;\n }\n\n return entry.find === 'solid-js/web' || String(entry.find) === '/^solid-js\\\\/web$/';\n });\n\n if (!hasAlias) {\n alias.unshift({ find: /^solid-js\\/web$/, replacement });\n }\n\n return;\n }\n\n config.resolve!.alias = {\n ...(alias ?? {}),\n 'solid-js/web': replacement\n };\n };\n }\n }\n };\n}\n\nexport function cjsInteropPlugin(): Plugin {\n return {\n name: 'cjs-esm-interop',\n enforce: 'pre',\n resolveId(id) {\n if (id.startsWith('.') || id.startsWith('/') || id.startsWith('\\0') || id.includes('node_modules')) {\n return;\n }\n\n const parts = id.split('/');\n const pkgName = id.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];\n const subpath = parts.slice(pkgName.split('/').length).join('/');\n\n if (subpath && !['server-renderer', 'server', 'client'].includes(subpath)) {\n return;\n }\n\n try {\n const nmDir = findPackageDir(pkgName);\n\n if (!nmDir) {\n return;\n }\n\n const pkgJsonPath = join(nmDir, 'package.json');\n\n if (!existsSync(pkgJsonPath)) {\n return;\n }\n\n const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));\n\n const exportKey = subpath ? `./${subpath}` : '.';\n const exportEntry = pkgJson.exports?.[exportKey];\n\n if (exportEntry) {\n const importEntry = exportEntry.import;\n\n if (importEntry) {\n const esmPath =\n typeof importEntry === 'string'\n ? importEntry\n : importEntry.default || importEntry.node;\n\n if (esmPath) {\n const resolved = join(nmDir, esmPath);\n\n if (existsSync(resolved)) {\n return resolved;\n }\n }\n }\n }\n\n if (!subpath && pkgJson.module) {\n const resolved = join(nmDir, pkgJson.module);\n\n if (existsSync(resolved)) {\n return resolved;\n }\n }\n } catch {\n // Ignore resolution errors\n }\n },\n transform(code, id) {\n if (!id.includes('node_modules')) {\n return;\n }\n\n if (id.startsWith('\\0')) {\n return;\n }\n\n if (/\\bexport\\s+(default|const|let|var|function|class|\\{|\\*)/.test(code)) {\n return;\n }\n\n if (!code.includes('module.exports') && !code.includes('exports.')) {\n return;\n }\n\n const dirPath = id.substring(0, id.lastIndexOf('/'));\n const fileName = id;\n\n return {\n code: [\n 'import { createRequire as __createRequire } from \"module\";',\n `var __require = __createRequire(\"file://${dirPath}/\");`,\n 'var module = { exports: {} };',\n 'var exports = module.exports;',\n 'function require(id) { return __require(id); }',\n `var __dirname = ${JSON.stringify(dirPath)};`,\n `var __filename = ${JSON.stringify(fileName)};`,\n code,\n 'export default module.exports;'\n ].join('\\n'),\n map: null\n };\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;AACA,SAAS,mBAAmB;AAE5B,OAAO;AAIP,SAAS,aAAa,QAAQ;AAC7B,SAAO;AACR;;;ACRA,SAAS,qBAAqB;;;ACD9B,SAAS,YAAY,oBAAoB;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ACzD,QAAM;AAAA,IACJ,eAAe,CAAC;AAAA,IAChB,UAAU,CAAC;AAAA,IACX,OAAO,QAAQ,IAAI;AAAA,IACnB,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB,GAAG;AAAA,EACL,IAAI;AAEJ,qCAAmC,MAAM,YAAY;AAErD,QAAM,sBAAsB,cAAc,IAAI,IAAI,qBAAqB,YAAY,GAAG,CAAC;AACvF,QAAM,aAAa;AAAA,IACjB,GAAG,KAAK;AAAA,IACR,aAAa,qBAAqB,KAAK,MAAM,aAAa,mBAAmB;AAAA,EAC/E;AAKA,QAAM,eAAe,aAAmB;AAAA,IACtC,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,SAAS;AAAA,MACP,iBAAiB;AAAA;AAAA,MAEjB,+BAA+B;AAAA,MAC/B,GAAG;AAAA,IACL;AAAA;AAAA,EAEF,CAAQ;AAER,QAAM,4BAA4B,QAC/B,IAAI;AAAA,IACH,kBAAkB,IAAI;AAAA,IACtB,QAAQ,IAAI,aAAa,IAAI,CAAC,gBAAgB,YAAY,gBAAgB,IAAI,CAAC,CAAC;AAAA,EAClF,CAAC,EACA;AAAA,IAAK,CAAC,CAAC,mBAAmB,oBAAoB;AAAA;AAAA,MAE7C,kBAAkB,cAAc,cAAqB;AAAA,QACnD,YAAY;AAAA,QACZ,cAAc,CAAC,GAAG,sBAAsB,sBAAsB,CAAC;AAAA,MACjE,CAAC;AAAA;AAAA,EACH;AAEF,SAAO,OAAO,EAAE,MAAM,UAAU,QAAQ,MAAoD;AAC1F,UAAM,qBAAqB,MAAM;AAEjC,WAAO,mBAAmB,EAAE,MAAM,UAAU,QAAQ,CAAC;AAAA,EACvD;AACF;","names":["config","defineConfig"]}
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@storybook-astro/framework",
3
- "version": "0.1.0-beta.8",
4
- "description": "Community-supported Storybook framework for Astro 6 components",
3
+ "version": "1.0.0",
4
+ "description": "Community-supported Storybook framework for Astro 5 & 6 components",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/lukemcd/storybook-astro.git",
9
+ "url": "git+https://github.com/storybook-astro/storybook-astro.git",
10
10
  "directory": "packages/@storybook-astro/framework"
11
11
  },
12
12
  "homepage": "https://storybook-astro.org",
13
13
  "bugs": {
14
- "url": "https://github.com/lukemcd/storybook-astro/issues"
14
+ "url": "https://github.com/storybook-astro/storybook-astro/issues"
15
15
  },
16
16
  "engines": {
17
17
  "node": ">=20.16.0 || >=22.19.0 || >=24.0.0"
@@ -36,6 +36,10 @@
36
36
  "types": "./src/testing.ts",
37
37
  "import": "./dist/testing.js"
38
38
  },
39
+ "./vitest": {
40
+ "types": "./src/vitest/index.ts",
41
+ "import": "./dist/vitest/index.js"
42
+ },
39
43
  "./preset": {
40
44
  "types": "./preset.ts",
41
45
  "import": "./dist/preset.js"
@@ -57,6 +61,10 @@
57
61
  "types": "./src/testing.ts",
58
62
  "import": "./dist/testing.js"
59
63
  },
64
+ "./vitest": {
65
+ "types": "./src/vitest/index.ts",
66
+ "import": "./dist/vitest/index.js"
67
+ },
60
68
  "./preset": {
61
69
  "types": "./preset.ts",
62
70
  "import": "./dist/preset.js"
@@ -76,19 +84,23 @@
76
84
  "@storybook/vue3": "^10.0.0",
77
85
  "@sveltejs/vite-plugin-svelte": "^5.0.3 || ^6.0.0",
78
86
  "@types/node": "^20.19.0",
79
- "@vitejs/plugin-react": "^5.0.0",
87
+ "@types/sanitize-html": "^2.16.0",
88
+ "@vitejs/plugin-react": "^5.1.4",
89
+ "@vitest/coverage-v8": "4.0.18",
80
90
  "alpinejs": "^3.14.9",
81
- "astro": "^5.6.1 || ^6.0.0-beta.0",
91
+ "astro": "^5.6.1 || ^6.0.0",
82
92
  "storybook-solidjs": "^1.0.0-beta.7",
83
- "vite-plugin-solid": "^2.11.10"
93
+ "tsup": "^8.5.1",
94
+ "vite-plugin-solid": "^2.11.10",
95
+ "vitest": "^4.0.18"
84
96
  },
85
97
  "peerDependencies": {
86
- "@astrojs/alpinejs": "^0.4.5 || ^0.5.0-beta.0",
87
- "@astrojs/preact": "^4.0.8 || ^5.0.0-beta.0",
88
- "@astrojs/react": "^4.2.3 || ^5.0.0-beta.0",
89
- "@astrojs/solid-js": "^5.0.7 || ^6.0.0-beta.0",
90
- "@astrojs/svelte": "^7.0.9 || ^8.0.0-beta.0",
91
- "@astrojs/vue": "^5.0.9 || ^6.0.0-beta.0",
98
+ "@astrojs/alpinejs": "^0.4.5 || ^0.5.0",
99
+ "@astrojs/preact": "^4.0.8 || ^5.0.0",
100
+ "@astrojs/react": "^4.2.3 || ^5.0.0",
101
+ "@astrojs/solid-js": "^5.0.7 || ^6.0.0",
102
+ "@astrojs/svelte": "^7.0.9 || ^8.0.0",
103
+ "@astrojs/vue": "^5.0.9 || ^6.0.0",
92
104
  "@preact/preset-vite": "^2.10.1",
93
105
  "@storybook/preact": "^10.0.0",
94
106
  "@storybook/react": "^10.0.0",
@@ -97,10 +109,10 @@
97
109
  "@vitejs/plugin-react": "^5.0.0",
98
110
  "@vitejs/plugin-vue": "^5.2.3",
99
111
  "@vitejs/plugin-vue-jsx": "^4.1.2",
100
- "astro": "^5.5.3 || ^6.0.0-beta.0",
112
+ "astro": "^5.5.3 || ^6.0.0",
101
113
  "storybook": "^10.0.0",
102
114
  "storybook-solidjs": "^1.0.0-beta.7",
103
- "vite": "^6.2.5 || ^7.0.0"
115
+ "vite": "^6.2.5 || ^7.0.0 || ^8.0.0"
104
116
  },
105
117
  "peerDependenciesMeta": {
106
118
  "@astrojs/alpinejs": {
@@ -147,7 +159,9 @@
147
159
  }
148
160
  },
149
161
  "dependencies": {
150
- "@storybook-astro/renderer": "0.1.0-beta.8",
151
- "vite": "^6.2.5 || ^7.0.0"
162
+ "@storybook-astro/renderer": "1.0.0",
163
+ "msw": "^2.12.10",
164
+ "sanitize-html": "^2.17.0",
165
+ "vite": "^6.2.5 || ^7.0.0 || ^8.0.0"
152
166
  }
153
167
  }
@@ -0,0 +1,11 @@
1
+ import { createRequire } from 'node:module';
2
+ import { pathToFileURL } from 'node:url';
3
+
4
+ export async function importAstroConfig(resolveFrom: string) {
5
+ const require = createRequire(import.meta.url);
6
+ const astroConfigEntrypoint = require.resolve('astro/config', {
7
+ paths: [resolveFrom]
8
+ });
9
+
10
+ return import(pathToFileURL(astroConfigEntrypoint).href);
11
+ }
package/src/index.ts CHANGED
@@ -3,19 +3,33 @@ export type {
3
3
  Args,
4
4
  ArgTypes,
5
5
  Parameters,
6
- StrictArgs,
6
+ ProjectAnnotations,
7
+ StrictArgs
7
8
  } from 'storybook/internal/types';
8
9
 
10
+ import type { ProjectAnnotations } from 'storybook/internal/types';
11
+ import type { AstroRenderer } from './portable-stories.ts';
12
+
13
+ /** Preview configuration type for `.storybook/preview.ts` in Astro projects. */
14
+ export type Preview = ProjectAnnotations<AstroRenderer>;
15
+
9
16
  // Export portable stories functionality
10
- export {
11
- composeStories,
12
- composeStory,
17
+ export {
18
+ composeStories,
19
+ composeStory,
13
20
  setProjectAnnotations,
14
21
  type AstroRenderer
15
22
  } from './portable-stories.ts';
16
23
 
17
24
  // Export framework types
18
- export type { FrameworkOptions, StorybookConfig } from './types.ts';
25
+ export type {
26
+ FrameworkOptions,
27
+ SanitizationOptions,
28
+ StoryRulesOptions,
29
+ StorybookConfig
30
+ } from './types.ts';
31
+ export type { StoryRule, StoryRulesConfig, StoryRuleUse, StoryRuleUseContext } from './rules.ts';
32
+ export { defineStoryRules } from './rules.ts';
19
33
 
20
34
  // Re-export preset functionality for framework usage
21
- export { core, viteFinal } from './preset.ts';
35
+ export { core, viteFinal } from './preset.ts';
@@ -1,4 +1,5 @@
1
1
  import type { Integration } from './base.ts';
2
+ import { importModule } from './moduleResolver.ts';
2
3
 
3
4
  export type Options = Record<string, unknown>;
4
5
 
@@ -17,8 +18,10 @@ export class AlpineIntegration implements Integration {
17
18
 
18
19
  resolveClient(_moduleName: string): undefined {}
19
20
 
20
- async loadIntegration() {
21
- const framework = await import('@astrojs/alpinejs');
21
+ async loadIntegration(resolveFrom = process.cwd()) {
22
+ const framework = await importModule<{
23
+ default: (options: Options) => Awaited<ReturnType<Integration['loadIntegration']>>;
24
+ }>('@astrojs/alpinejs', resolveFrom);
22
25
 
23
26
  return framework.default(this.options);
24
27
  }
@@ -19,5 +19,5 @@ export abstract class Integration {
19
19
  abstract readonly storybookEntryPreview?: string;
20
20
 
21
21
  abstract resolveClient(moduleName: string): string | undefined;
22
- abstract loadIntegration(): Promise<AstroIntegration>;
23
- }
22
+ abstract loadIntegration(resolveFrom?: string): Promise<AstroIntegration>;
23
+ }
@@ -0,0 +1,43 @@
1
+ import path from 'node:path';
2
+ import { createRequire } from 'node:module';
3
+ import { pathToFileURL } from 'node:url';
4
+
5
+ function toFileHref(filePath: string): string {
6
+ return pathToFileURL(filePath).href;
7
+ }
8
+
9
+ export function resolveFrom(moduleName: string, fromDirectory: string): string {
10
+ const fromFile = path.join(fromDirectory, '__storybook_astro_resolve__.js');
11
+
12
+ return createRequire(toFileHref(fromFile)).resolve(moduleName);
13
+ }
14
+
15
+ function resolveFromCandidates(moduleName: string, primaryDirectory: string): string {
16
+ const directories = [primaryDirectory, process.env.INIT_CWD].filter(
17
+ (value): value is string => Boolean(value)
18
+ );
19
+ const visited = new Set<string>();
20
+ let lastError: unknown;
21
+
22
+ for (const directory of directories) {
23
+ if (visited.has(directory)) {
24
+ continue;
25
+ }
26
+
27
+ visited.add(directory);
28
+
29
+ try {
30
+ return resolveFrom(moduleName, directory);
31
+ } catch (error) {
32
+ lastError = error;
33
+ }
34
+ }
35
+
36
+ throw lastError;
37
+ }
38
+
39
+ export async function importModule<T = unknown>(moduleName: string, resolveFrom = process.cwd()): Promise<T> {
40
+ const resolvedPath = resolveFromCandidates(moduleName, resolveFrom);
41
+
42
+ return import(toFileHref(resolvedPath)) as Promise<T>;
43
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Integration } from './base.ts';
2
2
  import type { PreactPluginOptions } from '@preact/preset-vite';
3
+ import { importModule } from './moduleResolver.ts';
3
4
 
4
5
  export type Options = Pick<PreactPluginOptions, 'include' | 'exclude'> & {
5
6
  compat?: boolean;
@@ -33,8 +34,10 @@ export class PreactIntegration implements Integration {
33
34
  }
34
35
  }
35
36
 
36
- async loadIntegration() {
37
- const framework = await import('@astrojs/preact');
37
+ async loadIntegration(resolveFrom = process.cwd()) {
38
+ const framework = await importModule<{
39
+ default: (options: Options) => Awaited<ReturnType<Integration['loadIntegration']>>;
40
+ }>('@astrojs/preact', resolveFrom);
38
41
 
39
42
  return framework.default(this.options);
40
43
  }
@@ -1,5 +1,6 @@
1
1
  import type { Integration } from './base.ts';
2
2
  import type { Options as ViteReactPluginOptions } from '@vitejs/plugin-react';
3
+ import { importModule } from './moduleResolver.ts';
3
4
 
4
5
  export type Options = Pick<ViteReactPluginOptions, 'include' | 'exclude'>;
5
6
 
@@ -30,8 +31,10 @@ export class ReactIntegration implements Integration {
30
31
  }
31
32
  }
32
33
 
33
- async loadIntegration() {
34
- const framework = await import('@astrojs/react');
34
+ async loadIntegration(resolveFrom = process.cwd()) {
35
+ const framework = await importModule<{
36
+ default: (options: Options) => Awaited<ReturnType<Integration['loadIntegration']>>;
37
+ }>('@astrojs/react', resolveFrom);
35
38
 
36
39
  return framework.default(this.options);
37
40
  }
@@ -1,5 +1,6 @@
1
1
  import type { Integration } from './base.ts';
2
2
  import type { Options as ViteSolidPluginOptions } from 'vite-plugin-solid';
3
+ import { importModule } from './moduleResolver.ts';
3
4
 
4
5
  export type Options = Pick<ViteSolidPluginOptions, 'include' | 'exclude'>;
5
6
 
@@ -29,8 +30,10 @@ export class SolidIntegration implements Integration {
29
30
  }
30
31
  }
31
32
 
32
- async loadIntegration() {
33
- const framework = await import('@astrojs/solid-js');
33
+ async loadIntegration(resolveFrom = process.cwd()) {
34
+ const framework = await importModule<{
35
+ default: (options: Options) => Awaited<ReturnType<Integration['loadIntegration']>>;
36
+ }>('@astrojs/solid-js', resolveFrom);
34
37
 
35
38
  return framework.default(this.options);
36
39
  }
@@ -1,5 +1,6 @@
1
1
  import type { Integration } from './base.ts';
2
2
  import type { Options as _foo, PluginOptions, SvelteConfig } from '@sveltejs/vite-plugin-svelte';
3
+ import { importModule } from './moduleResolver.ts';
3
4
 
4
5
  // Using Omit with empty string to preserve index signature
5
6
  // capabilities while maintaining the structure of the original types
@@ -35,8 +36,10 @@ export class SvelteIntegration implements Integration {
35
36
  }
36
37
  }
37
38
 
38
- async loadIntegration() {
39
- const framework = await import('@astrojs/svelte');
39
+ async loadIntegration(resolveFrom = process.cwd()) {
40
+ const framework = await importModule<{
41
+ default: (options: Options) => Awaited<ReturnType<Integration['loadIntegration']>>;
42
+ }>('@astrojs/svelte', resolveFrom);
40
43
 
41
44
  return framework.default(this.options);
42
45
  }