@storybook-astro/framework 0.1.0-beta.9 → 1.0.1
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/README.md +38 -0
- package/dist/base-IRZo3zgK.d.ts +23 -0
- package/dist/chunk-4SWPVM6R.js +96 -0
- package/dist/chunk-4SWPVM6R.js.map +1 -0
- package/dist/chunk-5EF25G5S.js +69 -0
- package/dist/chunk-5EF25G5S.js.map +1 -0
- package/dist/chunk-7GHEQUPV.js +439 -0
- package/dist/chunk-7GHEQUPV.js.map +1 -0
- package/dist/chunk-C5OH4VBR.js +492 -0
- package/dist/chunk-C5OH4VBR.js.map +1 -0
- package/dist/chunk-DNGQBPT7.js +15 -0
- package/dist/chunk-DNGQBPT7.js.map +1 -0
- package/dist/chunk-E4LB75JN.js +89 -0
- package/dist/chunk-E4LB75JN.js.map +1 -0
- package/dist/chunk-KSDXET2L.js +660 -0
- package/dist/chunk-KSDXET2L.js.map +1 -0
- package/dist/chunk-PJEDXZVN.js +240 -0
- package/dist/chunk-PJEDXZVN.js.map +1 -0
- package/dist/dist-HJOEPVRQ.js +15574 -0
- package/dist/dist-HJOEPVRQ.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +13 -64
- package/dist/index.js.map +1 -1
- package/dist/integrations/index.d.ts +138 -0
- package/dist/integrations/index.js +8 -196
- package/dist/integrations/index.js.map +1 -1
- package/dist/middleware.d.ts +26 -0
- package/dist/middleware.js +179 -0
- package/dist/middleware.js.map +1 -0
- package/dist/portable-stories-BvdaQigq.d.ts +83 -0
- package/dist/preset.d.ts +14 -0
- package/dist/preset.js +5 -1
- package/dist/testing.d.ts +27 -0
- package/dist/testing.js +324 -15539
- package/dist/testing.js.map +1 -1
- package/dist/types-CHTsRtA7.d.ts +42 -0
- package/dist/viteStorybookAstroMiddlewarePlugin-NP2E52IC.js +11 -0
- package/dist/viteStorybookAstroMiddlewarePlugin-NP2E52IC.js.map +1 -0
- package/dist/vitest/index.d.ts +19 -0
- package/dist/vitest/index.js +229 -0
- package/dist/vitest/index.js.map +1 -0
- package/package.json +31 -17
- package/src/importAstroConfig.ts +11 -0
- package/src/index.ts +20 -6
- package/src/integrations/alpine.ts +5 -2
- package/src/integrations/base.ts +2 -2
- package/src/integrations/moduleResolver.ts +43 -0
- package/src/integrations/preact.ts +5 -2
- package/src/integrations/react.ts +5 -2
- package/src/integrations/solid.ts +5 -2
- package/src/integrations/svelte.ts +5 -2
- package/src/integrations/vue.ts +5 -2
- package/src/lib/sanitization.test.ts +232 -0
- package/src/lib/sanitization.ts +338 -0
- package/src/lib/ssr-load-module-with-fs-fallback.ts +29 -0
- package/src/middleware.test.ts +48 -0
- package/src/middleware.ts +204 -96
- package/src/module-mocks.ts +16 -0
- package/src/msw-helpers.ts +1 -0
- package/src/msw.ts +58 -0
- package/src/preset.ts +47 -3
- package/src/rules-options.test.ts +71 -0
- package/src/rules-options.ts +87 -0
- package/src/rules.test.ts +183 -0
- package/src/rules.ts +314 -0
- package/src/testing/astro-runtime.ts +219 -0
- package/src/testing/component-utils.ts +32 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/integration-config.ts +121 -0
- package/src/testing/project-root.ts +185 -0
- package/src/testing/renderer-daemon.ts +269 -0
- package/src/testing/story-composition.ts +33 -0
- package/src/testing/types.ts +14 -0
- package/src/testing/working-directory.ts +28 -0
- package/src/testing.ts +1 -254
- package/src/types.ts +16 -4
- package/src/virtual.d.ts +2 -1
- package/src/vite/createVirtualModulePlugin.test.ts +80 -0
- package/src/vite/createVirtualModulePlugin.ts +25 -0
- package/src/viteAstroContainerRenderersPlugin.ts +60 -26
- package/src/vitePluginAstro.ts +12 -5
- package/src/vitePluginAstroBuildPrerender.ts +665 -204
- package/src/vitePluginAstroRoutesFallback.ts +37 -0
- package/src/vitePluginAstroVueFallback.ts +47 -0
- package/src/viteStorybookAstroMiddlewarePlugin.ts +88 -12
- package/src/viteStorybookRendererFallbackPlugin.ts +13 -23
- package/src/vitest/config.ts +95 -0
- package/src/vitest/global-setup.ts +16 -0
- package/src/vitest/index.ts +2 -0
- package/src/vitest/vite-plugins.ts +187 -0
- package/dist/chunk-KTGNRGDJ.js +0 -561
- package/dist/chunk-KTGNRGDJ.js.map +0 -1
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import {
|
|
2
|
+
importAstroConfig
|
|
3
|
+
} from "./chunk-DNGQBPT7.js";
|
|
4
|
+
|
|
5
|
+
// src/viteStorybookAstroMiddlewarePlugin.ts
|
|
6
|
+
import { createRequire } from "module";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
import { createServer } from "vite";
|
|
9
|
+
|
|
10
|
+
// src/vite/createVirtualModulePlugin.ts
|
|
11
|
+
function createVirtualModulePlugin(options) {
|
|
12
|
+
const resolvedVirtualModuleId = `\0${options.virtualModuleId}`;
|
|
13
|
+
return {
|
|
14
|
+
name: options.pluginName,
|
|
15
|
+
resolveId(id) {
|
|
16
|
+
if (id === options.virtualModuleId) {
|
|
17
|
+
return resolvedVirtualModuleId;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
async load(id) {
|
|
21
|
+
if (id === resolvedVirtualModuleId) {
|
|
22
|
+
return options.load(id);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/viteAstroContainerRenderersPlugin.ts
|
|
29
|
+
function viteAstroContainerRenderersPlugin(integrations, options = {}) {
|
|
30
|
+
const safeIntegrations = integrations ?? [];
|
|
31
|
+
const mode = options.mode ?? "development";
|
|
32
|
+
const staticModuleMap = options.staticModuleMap ?? {};
|
|
33
|
+
return createVirtualModulePlugin({
|
|
34
|
+
pluginName: "storybook-astro:container-renderers",
|
|
35
|
+
virtualModuleId: "virtual:astro-container-renderers",
|
|
36
|
+
load() {
|
|
37
|
+
const importStatements = buildImportStatements(safeIntegrations);
|
|
38
|
+
const clientResolvers = mode === "development" ? safeIntegrations.filter((integration) => typeof integration.resolveClient === "function").map(
|
|
39
|
+
(integration) => integration.resolveClient.toString().replace(/^resolveClient/, "function")
|
|
40
|
+
).join(",\n") : "";
|
|
41
|
+
return `
|
|
42
|
+
${importStatements}
|
|
43
|
+
|
|
44
|
+
export function addRenderers(container) {
|
|
45
|
+
${safeIntegrations.map((integration) => buildServerRenderer(integration) + "\n" + buildClientRenderer(integration)).join("\n")}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const staticClientModules = ${JSON.stringify(staticModuleMap, null, 2)};
|
|
49
|
+
|
|
50
|
+
const clientModulesResolvers = [
|
|
51
|
+
${clientResolvers}
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
export function resolveClientModules(specifier) {
|
|
55
|
+
if (Object.hasOwn(staticClientModules, specifier)) {
|
|
56
|
+
return staticClientModules[specifier];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const normalizedSpecifier = specifier.replace(/\\\\/g, '/').replace(/\\?.*$/, '');
|
|
60
|
+
|
|
61
|
+
if (Object.hasOwn(staticClientModules, normalizedSpecifier)) {
|
|
62
|
+
return staticClientModules[normalizedSpecifier];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
for (const resolver of clientModulesResolvers) {
|
|
66
|
+
const resolution = resolver(specifier);
|
|
67
|
+
|
|
68
|
+
if (resolution) {
|
|
69
|
+
return resolution;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function buildImportStatements(integrations) {
|
|
78
|
+
return integrations.filter((integration) => integration.renderer.server).map(
|
|
79
|
+
(integration) => `import ${integration.name}Renderer from '${integration.renderer.server?.entrypoint}';`
|
|
80
|
+
).join("\n");
|
|
81
|
+
}
|
|
82
|
+
function buildServerRenderer(integration) {
|
|
83
|
+
const serverRenderer = integration.renderer.server;
|
|
84
|
+
if (!serverRenderer) {
|
|
85
|
+
return "";
|
|
86
|
+
}
|
|
87
|
+
if (integration.name === "solid") {
|
|
88
|
+
return `
|
|
89
|
+
container.addServerRenderer({
|
|
90
|
+
name: '${serverRenderer.name}',
|
|
91
|
+
renderer: {
|
|
92
|
+
...${integration.name}Renderer,
|
|
93
|
+
name: '${serverRenderer.name}'
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
return `
|
|
99
|
+
container.addServerRenderer({
|
|
100
|
+
name: '${serverRenderer.name}',
|
|
101
|
+
renderer: ${integration.name}Renderer
|
|
102
|
+
});
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
function buildClientRenderer(integration) {
|
|
106
|
+
const clientRenderer = integration.renderer.client;
|
|
107
|
+
if (clientRenderer) {
|
|
108
|
+
return `
|
|
109
|
+
container.addClientRenderer({
|
|
110
|
+
name: '${clientRenderer.name}',
|
|
111
|
+
entrypoint: '${clientRenderer.entrypoint}'
|
|
112
|
+
});
|
|
113
|
+
`;
|
|
114
|
+
}
|
|
115
|
+
return "";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// src/vitePluginAstroFontsFallback.ts
|
|
119
|
+
var FONTS_RUNTIME_STUB = `
|
|
120
|
+
export const fontData = {};
|
|
121
|
+
export function createGetFontData(fontsMod) {
|
|
122
|
+
return fontsMod?.fontDataByCssVariable ?? {};
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
var FONTS_INTERNAL_STUB = `
|
|
126
|
+
export const componentDataByCssVariable = new Map();
|
|
127
|
+
export const fontDataByCssVariable = {};
|
|
128
|
+
`;
|
|
129
|
+
function vitePluginAstroFontsFallback() {
|
|
130
|
+
const VIRTUAL_ID = "virtual:astro:assets/fonts/internal";
|
|
131
|
+
const RUNTIME_VIRTUAL_ID = "virtual:astro:assets/fonts/runtime";
|
|
132
|
+
const RESOLVED_VIRTUAL_ID = "\0" + VIRTUAL_ID;
|
|
133
|
+
const RESOLVED_RUNTIME_VIRTUAL_ID = "\0" + RUNTIME_VIRTUAL_ID;
|
|
134
|
+
const RESOLVED_FONTS_RUNTIME_ID = "\0storybook:astro-fonts-runtime";
|
|
135
|
+
return {
|
|
136
|
+
name: "storybook-astro-fonts-fallback",
|
|
137
|
+
// Must run before vite:resolve to intercept virtual modules
|
|
138
|
+
// before Vite tries to resolve them as Node package imports
|
|
139
|
+
enforce: "pre",
|
|
140
|
+
resolveId(id) {
|
|
141
|
+
if (id === VIRTUAL_ID) {
|
|
142
|
+
return RESOLVED_VIRTUAL_ID;
|
|
143
|
+
}
|
|
144
|
+
if (id === RUNTIME_VIRTUAL_ID) {
|
|
145
|
+
return RESOLVED_RUNTIME_VIRTUAL_ID;
|
|
146
|
+
}
|
|
147
|
+
if (id === "astro/assets/fonts/runtime" || id === "astro/assets/fonts/runtime.js") {
|
|
148
|
+
return RESOLVED_FONTS_RUNTIME_ID;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
load(id) {
|
|
152
|
+
if (id === RESOLVED_VIRTUAL_ID) {
|
|
153
|
+
return { code: FONTS_INTERNAL_STUB };
|
|
154
|
+
}
|
|
155
|
+
if (id === RESOLVED_RUNTIME_VIRTUAL_ID || id === RESOLVED_FONTS_RUNTIME_ID) {
|
|
156
|
+
return { code: FONTS_RUNTIME_STUB };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// src/vitePluginAstroVueFallback.ts
|
|
163
|
+
var VUE_APP_STUB = `
|
|
164
|
+
export const setup = () => {};
|
|
165
|
+
`;
|
|
166
|
+
var VIRTUAL_IDS = ["virtual:astro:vue-app", "virtual:@astrojs/vue/app"];
|
|
167
|
+
function vitePluginAstroVueFallback() {
|
|
168
|
+
const resolvedIds = new Map(VIRTUAL_IDS.map((id) => [id, "\0" + id]));
|
|
169
|
+
const resolvedIdSet = new Set(resolvedIds.values());
|
|
170
|
+
return {
|
|
171
|
+
name: "storybook-astro-vue-fallback",
|
|
172
|
+
// Must run before vite:resolve to intercept virtual modules
|
|
173
|
+
// before Vite tries to resolve them as Node package imports
|
|
174
|
+
enforce: "pre",
|
|
175
|
+
resolveId(id) {
|
|
176
|
+
const resolved = resolvedIds.get(id);
|
|
177
|
+
if (resolved) {
|
|
178
|
+
return resolved;
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
load(id) {
|
|
182
|
+
if (resolvedIdSet.has(id)) {
|
|
183
|
+
return { code: VUE_APP_STUB };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// src/vitePluginAstroRoutesFallback.ts
|
|
190
|
+
var ROUTES_STUB = `
|
|
191
|
+
export const routes = [];
|
|
192
|
+
`;
|
|
193
|
+
function vitePluginAstroRoutesFallback() {
|
|
194
|
+
const VIRTUAL_ID = "virtual:astro:routes";
|
|
195
|
+
const RESOLVED_VIRTUAL_ID = "\0" + VIRTUAL_ID;
|
|
196
|
+
return {
|
|
197
|
+
name: "storybook-astro-routes-fallback",
|
|
198
|
+
// Must run before vite:resolve to intercept virtual modules
|
|
199
|
+
// before Vite tries to resolve them as Node package imports
|
|
200
|
+
enforce: "pre",
|
|
201
|
+
resolveId(id) {
|
|
202
|
+
if (id === VIRTUAL_ID) {
|
|
203
|
+
return RESOLVED_VIRTUAL_ID;
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
load(id) {
|
|
207
|
+
if (id === RESOLVED_VIRTUAL_ID) {
|
|
208
|
+
return { code: ROUTES_STUB };
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/lib/ssr-load-module-with-fs-fallback.ts
|
|
215
|
+
async function ssrLoadModuleWithFsFallback(viteServer, id, options) {
|
|
216
|
+
const ids = [id];
|
|
217
|
+
if (id.startsWith("/") && !id.startsWith("/@fs/")) {
|
|
218
|
+
ids.push(`/@fs${id}`);
|
|
219
|
+
}
|
|
220
|
+
let lastError;
|
|
221
|
+
for (const candidate of ids) {
|
|
222
|
+
try {
|
|
223
|
+
return await viteServer.ssrLoadModule(candidate, options);
|
|
224
|
+
} catch (error) {
|
|
225
|
+
lastError = error;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
throw lastError;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// src/rules-options.ts
|
|
232
|
+
import { existsSync, statSync } from "fs";
|
|
233
|
+
import { extname, resolve } from "path";
|
|
234
|
+
function resolveRulesConfigFilePath(options, resolveFrom = process.cwd()) {
|
|
235
|
+
if (options === void 0) {
|
|
236
|
+
return void 0;
|
|
237
|
+
}
|
|
238
|
+
const configFile = normalizeConfigFileOption(options);
|
|
239
|
+
const resolvedConfigFilePath = resolve(resolveFrom, configFile);
|
|
240
|
+
const normalizedConfigFilePath = resolveConfigFilePath(resolvedConfigFilePath);
|
|
241
|
+
if (!normalizedConfigFilePath) {
|
|
242
|
+
throw new Error(
|
|
243
|
+
`framework.options.storyRules config file was not found: ${resolvedConfigFilePath}. Provide an existing path in framework.options.storyRules.`
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
return normalizedConfigFilePath;
|
|
247
|
+
}
|
|
248
|
+
function normalizeConfigFileOption(options) {
|
|
249
|
+
const configFile = typeof options === "string" ? options : typeof options === "object" && options !== null ? options.configFile : void 0;
|
|
250
|
+
if (typeof configFile !== "string") {
|
|
251
|
+
throw new Error(
|
|
252
|
+
"framework.options.storyRules must be either a string path or an object with a string configFile."
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
const normalizedConfigFile = configFile.trim();
|
|
256
|
+
if (!normalizedConfigFile) {
|
|
257
|
+
throw new Error("framework.options.storyRules config file path cannot be empty.");
|
|
258
|
+
}
|
|
259
|
+
return normalizedConfigFile;
|
|
260
|
+
}
|
|
261
|
+
function resolveConfigFilePath(filePath) {
|
|
262
|
+
if (existsSync(filePath)) {
|
|
263
|
+
const fileStats = statSync(filePath);
|
|
264
|
+
if (fileStats.isFile()) {
|
|
265
|
+
return filePath;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (extname(filePath)) {
|
|
269
|
+
return void 0;
|
|
270
|
+
}
|
|
271
|
+
const extensions = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
|
|
272
|
+
for (const extension of extensions) {
|
|
273
|
+
const candidateFilePath = `${filePath}${extension}`;
|
|
274
|
+
if (existsSync(candidateFilePath)) {
|
|
275
|
+
return candidateFilePath;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
for (const extension of extensions) {
|
|
279
|
+
const candidateFilePath = resolve(filePath, `index${extension}`);
|
|
280
|
+
if (existsSync(candidateFilePath)) {
|
|
281
|
+
return candidateFilePath;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return void 0;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// src/viteStorybookAstroMiddlewarePlugin.ts
|
|
288
|
+
async function vitePluginStorybookAstroMiddleware(options) {
|
|
289
|
+
let viteServer = null;
|
|
290
|
+
const resolveFrom = options.resolveFrom ?? process.cwd();
|
|
291
|
+
const vitePlugin = {
|
|
292
|
+
name: "storybook-astro-middleware-plugin",
|
|
293
|
+
async configureServer(server) {
|
|
294
|
+
viteServer = await createViteServer(options.integrations, resolveFrom);
|
|
295
|
+
const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, resolveFrom);
|
|
296
|
+
const filePath = fileURLToPath(new URL("./middleware", import.meta.url));
|
|
297
|
+
const middleware = await viteServer.ssrLoadModule(filePath, {
|
|
298
|
+
fixStacktrace: true
|
|
299
|
+
});
|
|
300
|
+
const createHandler = () => middleware.handlerFactory(options.integrations ?? [], {
|
|
301
|
+
mode: "development",
|
|
302
|
+
sanitization: options.sanitization,
|
|
303
|
+
rulesConfigFilePath: storyRulesConfigFilePath,
|
|
304
|
+
resolveRulesConfigModule: () => loadRulesConfigModule(viteServer, storyRulesConfigFilePath),
|
|
305
|
+
loadModule: (id) => ssrLoadModuleWithFsFallback(viteServer, id, {
|
|
306
|
+
fixStacktrace: true
|
|
307
|
+
})
|
|
308
|
+
});
|
|
309
|
+
let handlerPromise = createHandler();
|
|
310
|
+
const resetHandler = () => {
|
|
311
|
+
handlerPromise = createHandler();
|
|
312
|
+
};
|
|
313
|
+
server.watcher.on("add", resetHandler);
|
|
314
|
+
server.watcher.on("change", resetHandler);
|
|
315
|
+
server.watcher.on("unlink", resetHandler);
|
|
316
|
+
server.ws.on("astro:render:request", async (data) => {
|
|
317
|
+
try {
|
|
318
|
+
const handler = await handlerPromise;
|
|
319
|
+
const html = await handler(data);
|
|
320
|
+
server.ws.send("astro:render:response", {
|
|
321
|
+
html,
|
|
322
|
+
id: data.id
|
|
323
|
+
});
|
|
324
|
+
} catch (err) {
|
|
325
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
326
|
+
const errorStack = err instanceof Error ? err.stack : "";
|
|
327
|
+
console.error("[storybook-astro] Render error:", errorMessage);
|
|
328
|
+
if (errorStack) {
|
|
329
|
+
console.error(errorStack);
|
|
330
|
+
}
|
|
331
|
+
server.ws.send("astro:render:response", {
|
|
332
|
+
id: data.id,
|
|
333
|
+
html: '<div style="background: #d73838; padding: 12px; color: #f0f0f0; font-family: monospace; border-radius: 4px"><strong>Error rendering Astro component</strong><br/><pre style="white-space: pre-wrap; margin-top: 8px; font-size: 12px">' + errorMessage.replace(/</g, "<").replace(/>/g, ">") + "</pre></div>"
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
const assetServingPlugin = {
|
|
340
|
+
name: "storybook-astro-assets",
|
|
341
|
+
configureServer(server) {
|
|
342
|
+
server.middlewares.use("/_image", (req, res, next) => {
|
|
343
|
+
if (!viteServer) {
|
|
344
|
+
next();
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
viteServer.middlewares.handle(req, res, (err) => {
|
|
348
|
+
if (err) {
|
|
349
|
+
console.error("Asset serving error:", err);
|
|
350
|
+
next();
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
return {
|
|
357
|
+
vitePlugin,
|
|
358
|
+
viteConfig: {
|
|
359
|
+
plugins: [
|
|
360
|
+
assetServingPlugin
|
|
361
|
+
].filter(Boolean)
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
async function createViteServer(integrations, resolveFrom = process.cwd()) {
|
|
366
|
+
const { getViteConfig } = await importAstroConfig(resolveFrom);
|
|
367
|
+
const safeIntegrations = integrations ?? [];
|
|
368
|
+
const projectAstroResolutionPlugin = createProjectAstroResolutionPlugin(resolveFrom);
|
|
369
|
+
const config = await getViteConfig(
|
|
370
|
+
{ root: resolveFrom },
|
|
371
|
+
{
|
|
372
|
+
configFile: false,
|
|
373
|
+
integrations: await Promise.all(
|
|
374
|
+
safeIntegrations.map((integration) => integration.loadIntegration(resolveFrom))
|
|
375
|
+
)
|
|
376
|
+
}
|
|
377
|
+
)({ mode: "development", command: "serve" });
|
|
378
|
+
const viteServer = await createServer({
|
|
379
|
+
configFile: false,
|
|
380
|
+
...config,
|
|
381
|
+
plugins: [
|
|
382
|
+
projectAstroResolutionPlugin,
|
|
383
|
+
// Fallbacks must come first to intercept before Astro's plugins
|
|
384
|
+
vitePluginAstroFontsFallback(),
|
|
385
|
+
vitePluginAstroVueFallback(),
|
|
386
|
+
vitePluginAstroRoutesFallback(),
|
|
387
|
+
...config.plugins?.filter(Boolean) ?? [],
|
|
388
|
+
viteAstroContainerRenderersPlugin(safeIntegrations)
|
|
389
|
+
]
|
|
390
|
+
});
|
|
391
|
+
await viteServer.pluginContainer.buildStart({});
|
|
392
|
+
return viteServer;
|
|
393
|
+
}
|
|
394
|
+
function createProjectAstroResolutionPlugin(resolveFrom) {
|
|
395
|
+
const require2 = createRequire(import.meta.url);
|
|
396
|
+
return {
|
|
397
|
+
name: "storybook-astro:resolve-project-astro",
|
|
398
|
+
enforce: "pre",
|
|
399
|
+
resolveId(id) {
|
|
400
|
+
if (id !== "astro" && !id.startsWith("astro/")) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
try {
|
|
404
|
+
return require2.resolve(id, {
|
|
405
|
+
paths: [resolveFrom]
|
|
406
|
+
});
|
|
407
|
+
} catch {
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
async function loadRulesConfigModule(viteServer, configFilePath) {
|
|
414
|
+
if (!configFilePath) {
|
|
415
|
+
return void 0;
|
|
416
|
+
}
|
|
417
|
+
try {
|
|
418
|
+
return await ssrLoadModuleWithFsFallback(viteServer, configFilePath, {
|
|
419
|
+
fixStacktrace: true
|
|
420
|
+
});
|
|
421
|
+
} catch (error) {
|
|
422
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
423
|
+
throw new Error(
|
|
424
|
+
`Unable to load framework.options.storyRules config module at ${configFilePath}: ${reason}`
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export {
|
|
430
|
+
createVirtualModulePlugin,
|
|
431
|
+
vitePluginAstroFontsFallback,
|
|
432
|
+
vitePluginAstroVueFallback,
|
|
433
|
+
vitePluginAstroRoutesFallback,
|
|
434
|
+
ssrLoadModuleWithFsFallback,
|
|
435
|
+
resolveRulesConfigFilePath,
|
|
436
|
+
vitePluginStorybookAstroMiddleware,
|
|
437
|
+
createViteServer
|
|
438
|
+
};
|
|
439
|
+
//# sourceMappingURL=chunk-7GHEQUPV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/viteStorybookAstroMiddlewarePlugin.ts","../src/vite/createVirtualModulePlugin.ts","../src/viteAstroContainerRenderersPlugin.ts","../src/vitePluginAstroFontsFallback.ts","../src/vitePluginAstroVueFallback.ts","../src/vitePluginAstroRoutesFallback.ts","../src/lib/ssr-load-module-with-fs-fallback.ts","../src/rules-options.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { fileURLToPath } from 'node:url';\nimport { createServer, type PluginOption, type ViteDevServer } from 'vite';\nimport type { RenderRequestMessage, RenderResponseMessage } from '@storybook-astro/renderer/types';\nimport type { FrameworkOptions } from './types.ts';\nimport type { Integration } from './integrations/index.ts';\nimport { importAstroConfig } from './importAstroConfig.ts';\nimport { viteAstroContainerRenderersPlugin } from './viteAstroContainerRenderersPlugin.ts';\nimport { vitePluginAstroFontsFallback } from './vitePluginAstroFontsFallback.ts';\nimport { vitePluginAstroVueFallback } from './vitePluginAstroVueFallback.ts';\nimport { vitePluginAstroRoutesFallback } from './vitePluginAstroRoutesFallback.ts';\nimport { ssrLoadModuleWithFsFallback } from './lib/ssr-load-module-with-fs-fallback.ts';\nimport { resolveRulesConfigFilePath } from './rules-options.ts';\n\nexport async function vitePluginStorybookAstroMiddleware(options: FrameworkOptions) {\n // The internal Vite server is created lazily inside configureServer (dev-only).\n // During builds, configureServer never fires, so no server is created.\n let viteServer: ViteDevServer | null = null;\n\n const resolveFrom = options.resolveFrom ?? process.cwd();\n\n const vitePlugin = {\n name: 'storybook-astro-middleware-plugin',\n async configureServer(server) {\n viteServer = await createViteServer(options.integrations, resolveFrom);\n const storyRulesConfigFilePath = resolveRulesConfigFilePath(options.storyRules, resolveFrom);\n\n const filePath = fileURLToPath(new URL('./middleware', import.meta.url));\n const middleware = await viteServer.ssrLoadModule(filePath, {\n fixStacktrace: true\n });\n\n const createHandler = () => middleware.handlerFactory(options.integrations ?? [], {\n mode: 'development',\n sanitization: options.sanitization,\n rulesConfigFilePath: storyRulesConfigFilePath,\n resolveRulesConfigModule: () =>\n loadRulesConfigModule(viteServer!, storyRulesConfigFilePath),\n loadModule: (id: string) =>\n ssrLoadModuleWithFsFallback(viteServer!, id, {\n fixStacktrace: true\n })\n });\n\n let handlerPromise = createHandler();\n\n const resetHandler = () => {\n handlerPromise = createHandler();\n };\n\n server.watcher.on('add', resetHandler);\n server.watcher.on('change', resetHandler);\n server.watcher.on('unlink', resetHandler);\n\n server.ws.on('astro:render:request', async (data: RenderRequestMessage['data']) => {\n try {\n const handler = await handlerPromise;\n const html = await handler(data);\n\n server.ws.send('astro:render:response', {\n html,\n id: data.id\n } satisfies RenderResponseMessage['data']);\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n const errorStack = err instanceof Error ? err.stack : '';\n\n console.error('[storybook-astro] Render error:', errorMessage);\n if (errorStack) {console.error(errorStack);}\n server.ws.send('astro:render:response', {\n id: data.id,\n html:\n '<div style=\"background: #d73838; padding: 12px; color: #f0f0f0; font-family: monospace; border-radius: 4px\">' +\n '<strong>Error rendering Astro component</strong><br/>' +\n '<pre style=\"white-space: pre-wrap; margin-top: 8px; font-size: 12px\">' +\n errorMessage.replace(/</g, '<').replace(/>/g, '>') +\n '</pre></div>'\n } satisfies RenderResponseMessage['data']);\n }\n });\n }\n } satisfies PluginOption;\n\n // Create asset serving plugin (only active in dev when viteServer exists)\n const assetServingPlugin = {\n name: 'storybook-astro-assets',\n configureServer(server) {\n server.middlewares.use('/_image', (req, res, next) => {\n if (!viteServer) {\n next();\n\n return;\n }\n // Forward the request to the Astro vite server\n viteServer.middlewares.handle(req, res, (err) => {\n if (err) {\n console.error('Asset serving error:', err);\n next();\n }\n });\n });\n }\n };\n\n // The extracted CSS plugins from Astro's internal Vite server cause Vue SFC\n // <style> blocks to be double-processed (once by these plugins, once by\n // Storybook's built-in CSS plugins), resulting in PostCSS errors.\n //\n // Solution: Don't extract Astro's CSS plugins. Storybook's built-in CSS\n // plugins handle both Vue styles AND Astro style sub-modules (which are\n // standard CSS imports like `Component.astro?astro&type=style&index=0&lang.css`).\n //\n // The Astro internal server's CSS plugins are only needed for SSR rendering\n // within that server - they don't need to be shared with Storybook's server.\n return {\n vitePlugin,\n viteConfig: {\n plugins: [\n assetServingPlugin\n ].filter(Boolean)\n }\n };\n}\n\nexport async function createViteServer(integrations: Integration[], resolveFrom = process.cwd()) {\n const { getViteConfig } = await importAstroConfig(resolveFrom);\n const safeIntegrations = integrations ?? [];\n const projectAstroResolutionPlugin = createProjectAstroResolutionPlugin(resolveFrom);\n\n const config = await getViteConfig(\n { root: resolveFrom },\n {\n configFile: false,\n integrations: await Promise.all(\n safeIntegrations.map((integration) => integration.loadIntegration(resolveFrom))\n )\n }\n )({ mode: 'development', command: 'serve' });\n\n const viteServer = await createServer({\n configFile: false,\n ...config,\n plugins: [\n projectAstroResolutionPlugin,\n // Fallbacks must come first to intercept before Astro's plugins\n vitePluginAstroFontsFallback(),\n vitePluginAstroVueFallback(),\n vitePluginAstroRoutesFallback(),\n ...(config.plugins?.filter(Boolean) ?? []),\n viteAstroContainerRenderersPlugin(safeIntegrations)\n ]\n });\n\n // Initialize the server's plugin container to ensure all plugins are ready.\n // Without this, some plugins (like vite:css) may have uninitialized state\n // when ssrLoadModule is called.\n await viteServer.pluginContainer.buildStart({});\n\n return viteServer;\n}\n\nfunction createProjectAstroResolutionPlugin(resolveFrom: string): PluginOption {\n const require = createRequire(import.meta.url);\n\n return {\n name: 'storybook-astro:resolve-project-astro',\n enforce: 'pre',\n resolveId(id: string) {\n if (id !== 'astro' && !id.startsWith('astro/')) {\n return null;\n }\n\n try {\n return require.resolve(id, {\n paths: [resolveFrom]\n });\n } catch {\n return null;\n }\n }\n } satisfies PluginOption;\n}\n\nasync function loadRulesConfigModule(viteServer: ViteDevServer, configFilePath?: string) {\n if (!configFilePath) {\n return undefined;\n }\n\n try {\n return await ssrLoadModuleWithFsFallback(viteServer, configFilePath, {\n fixStacktrace: true\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n\n throw new Error(\n `Unable to load framework.options.storyRules config module at ${configFilePath}: ${reason}`\n );\n }\n}\n","import type { PluginOption } from 'vite';\n\ntype CreateVirtualModulePluginOptions = {\n pluginName: string;\n virtualModuleId: string;\n load: (id: string) => string | Promise<string> | undefined;\n};\n\nexport function createVirtualModulePlugin(options: CreateVirtualModulePluginOptions): PluginOption {\n const resolvedVirtualModuleId = `\\0${options.virtualModuleId}`;\n\n return {\n name: options.pluginName,\n resolveId(id) {\n if (id === options.virtualModuleId) {\n return resolvedVirtualModuleId;\n }\n },\n async load(id) {\n if (id === resolvedVirtualModuleId) {\n return options.load(id);\n }\n }\n } satisfies PluginOption;\n}\n","import type { Integration } from './integrations/index.ts';\nimport { createVirtualModulePlugin } from './vite/createVirtualModulePlugin.ts';\n\ntype PluginOptions = {\n mode?: 'development' | 'production';\n staticModuleMap?: Record<string, string>;\n};\n\nexport function viteAstroContainerRenderersPlugin(\n integrations: Integration[],\n options: PluginOptions = {}\n) {\n const safeIntegrations = integrations ?? [];\n const mode = options.mode ?? 'development';\n const staticModuleMap = options.staticModuleMap ?? {};\n\n return createVirtualModulePlugin({\n pluginName: 'storybook-astro:container-renderers',\n virtualModuleId: 'virtual:astro-container-renderers',\n load() {\n const importStatements = buildImportStatements(safeIntegrations);\n const clientResolvers =\n mode === 'development'\n ? safeIntegrations\n .filter((integration) => typeof integration.resolveClient === 'function')\n .map((integration) =>\n integration.resolveClient.toString().replace(/^resolveClient/, 'function')\n )\n .join(',\\n')\n : '';\n\n return `\n ${importStatements}\n\n export function addRenderers(container) {\n ${safeIntegrations.map((integration) => buildServerRenderer(integration) + '\\n' + buildClientRenderer(integration)).join('\\n')}\n }\n\n const staticClientModules = ${JSON.stringify(staticModuleMap, null, 2)};\n\n const clientModulesResolvers = [\n ${clientResolvers}\n ];\n\n export function resolveClientModules(specifier) {\n if (Object.hasOwn(staticClientModules, specifier)) {\n return staticClientModules[specifier];\n }\n\n const normalizedSpecifier = specifier.replace(/\\\\\\\\/g, '/').replace(/\\\\?.*$/, '');\n\n if (Object.hasOwn(staticClientModules, normalizedSpecifier)) {\n return staticClientModules[normalizedSpecifier];\n }\n\n for (const resolver of clientModulesResolvers) {\n const resolution = resolver(specifier);\n\n if (resolution) {\n return resolution;\n }\n }\n }\n `;\n }\n });\n}\n\nfunction buildImportStatements(integrations: Integration[]) {\n return integrations\n .filter((integration) => integration.renderer.server)\n .map(\n (integration) =>\n `import ${integration.name}Renderer from '${integration.renderer.server?.entrypoint}';`\n )\n .join('\\n');\n}\n\nfunction buildServerRenderer(integration: Integration) {\n const serverRenderer = integration.renderer.server;\n\n if (!serverRenderer) {\n return '';\n }\n\n if (integration.name === 'solid') {\n return `\n container.addServerRenderer({\n name: '${serverRenderer.name}',\n renderer: {\n ...${integration.name}Renderer,\n name: '${serverRenderer.name}'\n }\n });\n `;\n }\n\n return `\n container.addServerRenderer({\n name: '${serverRenderer.name}',\n renderer: ${integration.name}Renderer\n });\n `;\n}\n\nfunction buildClientRenderer(integration: Integration) {\n const clientRenderer = integration.renderer.client;\n\n if (clientRenderer) {\n return `\n container.addClientRenderer({\n name: '${clientRenderer.name}',\n entrypoint: '${clientRenderer.entrypoint}'\n });\n `;\n }\n\n return '';\n}\n","import type { Plugin } from 'vite';\n\nconst FONTS_RUNTIME_STUB = `\nexport const fontData = {};\nexport function createGetFontData(fontsMod) {\n return fontsMod?.fontDataByCssVariable ?? {};\n}\n`;\n\nconst FONTS_INTERNAL_STUB = `\nexport const componentDataByCssVariable = new Map();\nexport const fontDataByCssVariable = {};\n`;\n\n/**\n * Provides fallback resolution for Astro's font-related virtual modules\n * and package import paths in Storybook's SSR Vite server.\n *\n * In Astro 6, the `astro:assets` virtual module depends on font-related\n * modules through virtual modules and a bare `astro/assets/fonts/runtime`\n * import. In the Storybook SSR context:\n *\n * 1. The fonts plugin's filter-based `resolveId` may not trigger for\n * the virtual module IDs.\n * 2. A Vite transform rewrites the `astro:assets` module to import\n * `createGetFontData` from `astro/assets/fonts/runtime` (without\n * `.js`), which fails against Astro's package.json exports map.\n * 3. The `createGetFontData` function is injected by a runtime Vite\n * transform that doesn't run in our SSR context.\n *\n * This plugin stubs all three font module paths with no-op exports,\n * since Storybook doesn't need Astro's font system.\n */\nexport function vitePluginAstroFontsFallback(): Plugin {\n const VIRTUAL_ID = 'virtual:astro:assets/fonts/internal';\n const RUNTIME_VIRTUAL_ID = 'virtual:astro:assets/fonts/runtime';\n const RESOLVED_VIRTUAL_ID = '\\0' + VIRTUAL_ID;\n const RESOLVED_RUNTIME_VIRTUAL_ID = '\\0' + RUNTIME_VIRTUAL_ID;\n const RESOLVED_FONTS_RUNTIME_ID = '\\0storybook:astro-fonts-runtime';\n\n return {\n name: 'storybook-astro-fonts-fallback',\n // Must run before vite:resolve to intercept virtual modules\n // before Vite tries to resolve them as Node package imports\n enforce: 'pre',\n\n resolveId(id) {\n if (id === VIRTUAL_ID) {\n return RESOLVED_VIRTUAL_ID;\n }\n if (id === RUNTIME_VIRTUAL_ID) {\n return RESOLVED_RUNTIME_VIRTUAL_ID;\n }\n // Intercept the bare package import (without .js) and the .js variant\n if (id === 'astro/assets/fonts/runtime' || id === 'astro/assets/fonts/runtime.js') {\n return RESOLVED_FONTS_RUNTIME_ID;\n }\n },\n\n load(id) {\n if (id === RESOLVED_VIRTUAL_ID) {\n return { code: FONTS_INTERNAL_STUB };\n }\n if (id === RESOLVED_RUNTIME_VIRTUAL_ID || id === RESOLVED_FONTS_RUNTIME_ID) {\n return { code: FONTS_RUNTIME_STUB };\n }\n }\n };\n}\n","import type { Plugin } from 'vite';\n\nconst VUE_APP_STUB = `\nexport const setup = () => {};\n`;\n\n// Different versions of @astrojs/vue use different virtual module names\nconst VIRTUAL_IDS = ['virtual:astro:vue-app', 'virtual:@astrojs/vue/app'];\n\n/**\n * Provides fallback resolution for @astrojs/vue's virtual module\n * in Storybook's SSR Vite server.\n *\n * @astrojs/vue's server.js imports a virtual module to get a setup function\n * for configuring the Vue app instance. The virtual module name varies by version:\n * - v6.0.0-beta.1: \"virtual:astro:vue-app\"\n * - Later versions: \"virtual:@astrojs/vue/app\"\n *\n * The Vite plugin that normally creates this virtual module may not run in\n * Storybook's SSR context, so this plugin stubs it with a no-op setup function\n * (the default behavior when no appEntrypoint is configured).\n */\nexport function vitePluginAstroVueFallback(): Plugin {\n const resolvedIds = new Map(VIRTUAL_IDS.map((id) => [id, '\\0' + id]));\n const resolvedIdSet = new Set(resolvedIds.values());\n\n return {\n name: 'storybook-astro-vue-fallback',\n // Must run before vite:resolve to intercept virtual modules\n // before Vite tries to resolve them as Node package imports\n enforce: 'pre',\n\n resolveId(id) {\n const resolved = resolvedIds.get(id);\n\n if (resolved) {\n return resolved;\n }\n },\n\n load(id) {\n if (resolvedIdSet.has(id)) {\n return { code: VUE_APP_STUB };\n }\n }\n };\n}\n","import type { Plugin } from 'vite';\n\nconst ROUTES_STUB = `\nexport const routes = [];\n`;\n\n/**\n * Provides fallback resolution for Astro's routes virtual module\n * in Storybook's SSR Vite server.\n *\n * In Astro 6, the manifest and app entrypoints import from \"virtual:astro:routes\"\n * to get route data. In Storybook's context, there are no routes, so this plugin\n * stubs the virtual module with an empty routes array.\n */\nexport function vitePluginAstroRoutesFallback(): Plugin {\n const VIRTUAL_ID = 'virtual:astro:routes';\n const RESOLVED_VIRTUAL_ID = '\\0' + VIRTUAL_ID;\n\n return {\n name: 'storybook-astro-routes-fallback',\n // Must run before vite:resolve to intercept virtual modules\n // before Vite tries to resolve them as Node package imports\n enforce: 'pre',\n\n resolveId(id) {\n if (id === VIRTUAL_ID) {\n return RESOLVED_VIRTUAL_ID;\n }\n },\n\n load(id) {\n if (id === RESOLVED_VIRTUAL_ID) {\n return { code: ROUTES_STUB };\n }\n }\n };\n}\n","import type { ViteDevServer } from 'vite';\n\ntype SsrLoadModuleOptions = {\n fixStacktrace?: boolean;\n};\n\nexport async function ssrLoadModuleWithFsFallback<TModule = unknown>(\n viteServer: Pick<ViteDevServer, 'ssrLoadModule'>,\n id: string,\n options?: SsrLoadModuleOptions\n) {\n const ids = [id];\n\n if (id.startsWith('/') && !id.startsWith('/@fs/')) {\n ids.push(`/@fs${id}`);\n }\n\n let lastError: unknown;\n\n for (const candidate of ids) {\n try {\n return await viteServer.ssrLoadModule(candidate, options) as TModule;\n } catch (error) {\n lastError = error;\n }\n }\n\n throw lastError;\n}\n","import { existsSync, statSync } from 'node:fs';\nimport { extname, resolve } from 'node:path';\n\nexport type StoryRulesOptions =\n | string\n | {\n configFile: string;\n };\n\nexport function resolveRulesConfigFilePath(\n options?: StoryRulesOptions,\n resolveFrom = process.cwd()\n): string | undefined {\n if (options === undefined) {\n return undefined;\n }\n\n const configFile = normalizeConfigFileOption(options);\n const resolvedConfigFilePath = resolve(resolveFrom, configFile);\n const normalizedConfigFilePath = resolveConfigFilePath(resolvedConfigFilePath);\n\n if (!normalizedConfigFilePath) {\n throw new Error(\n `framework.options.storyRules config file was not found: ${resolvedConfigFilePath}. ` +\n 'Provide an existing path in framework.options.storyRules.'\n );\n }\n\n return normalizedConfigFilePath;\n}\n\nfunction normalizeConfigFileOption(options: StoryRulesOptions): string {\n const configFile =\n typeof options === 'string'\n ? options\n : typeof options === 'object' && options !== null\n ? options.configFile\n : undefined;\n\n if (typeof configFile !== 'string') {\n throw new Error(\n 'framework.options.storyRules must be either a string path or an object with a string configFile.'\n );\n }\n\n const normalizedConfigFile = configFile.trim();\n\n if (!normalizedConfigFile) {\n throw new Error('framework.options.storyRules config file path cannot be empty.');\n }\n\n return normalizedConfigFile;\n}\n\nfunction resolveConfigFilePath(filePath: string): string | undefined {\n if (existsSync(filePath)) {\n const fileStats = statSync(filePath);\n\n if (fileStats.isFile()) {\n return filePath;\n }\n }\n\n if (extname(filePath)) {\n return undefined;\n }\n\n const extensions = ['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'];\n\n for (const extension of extensions) {\n const candidateFilePath = `${filePath}${extension}`;\n\n if (existsSync(candidateFilePath)) {\n return candidateFilePath;\n }\n }\n\n for (const extension of extensions) {\n const candidateFilePath = resolve(filePath, `index${extension}`);\n\n if (existsSync(candidateFilePath)) {\n return candidateFilePath;\n }\n }\n\n return undefined;\n}\n"],"mappings":";;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,oBAA2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