@storybook-astro/framework 1.0.3 → 1.1.1-canary.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/dist/{chunk-5EF25G5S.js → chunk-KXAAX3GN.js} +1 -1
- package/dist/chunk-KXAAX3GN.js.map +1 -0
- package/dist/{chunk-C5OH4VBR.js → chunk-OUEDTRBO.js} +174 -47
- package/dist/chunk-OUEDTRBO.js.map +1 -0
- package/dist/chunk-PBISP7PA.js +1137 -0
- package/dist/chunk-PBISP7PA.js.map +1 -0
- 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/index.d.ts +33 -13
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/middleware.js +29 -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/{portable-stories-BvdaQigq.d.ts → portable-stories-DXT_GOf6.d.ts} +3 -3
- package/dist/preset.d.ts +1 -1
- package/dist/preset.js +3 -3
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +13 -65
- package/dist/testing.js.map +1 -1
- package/dist/types-C-jan6Px.d.ts +67 -0
- 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.d.ts +19 -1
- package/dist/vitest/index.js +21 -3
- package/dist/vitest/index.js.map +1 -1
- package/package.json +11 -3
- package/src/index.ts +33 -3
- package/src/lib/passthrough-image-service.ts +76 -0
- package/src/lib/sanitization.ts +104 -0
- package/src/middleware.ts +35 -44
- package/src/node/index.ts +7 -0
- package/src/portable-stories.test.ts +28 -0
- package/src/portable-stories.ts +12 -12
- package/src/preset.ts +86 -16
- 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 +34 -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 +191 -65
- package/src/vitePluginAstroBuildServer.ts +289 -0
- package/src/vitePluginAstroIntegrationOptsFallback.ts +25 -0
- package/src/vitePluginAstroToolbarFallback.ts +38 -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/src/vitest/index.ts +1 -0
- package/dist/chunk-5EF25G5S.js.map +0 -1
- package/dist/chunk-7GHEQUPV.js.map +0 -1
- package/dist/chunk-C5OH4VBR.js.map +0 -1
- package/dist/chunk-KSDXET2L.js +0 -660
- package/dist/chunk-KSDXET2L.js.map +0 -1
- package/dist/middleware.d.ts +0 -26
- package/dist/types-CHTsRtA7.d.ts +0 -42
- 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/portable-stories.ts"],"sourcesContent":["// @ts-ignore - Storybook internal modules have complex module resolution\nimport type {\n Args,\n ComponentAnnotations,\n NamedOrDefaultProjectAnnotations,\n NormalizedProjectAnnotations,\n ProjectAnnotations,\n StoryAnnotationsOrFn,\n WebRenderer,\n} from 'storybook/internal/types';\n// @ts-ignore - Storybook internal modules have complex module resolution\nimport {\n composeStory as originalComposeStory,\n composeStories as originalComposeStories,\n setProjectAnnotations as originalSetProjectAnnotations,\n} from 'storybook/internal/preview-api';\n\n// Define the AstroRenderer type to match other frameworks\nexport interface AstroRenderer extends WebRenderer {\n component: any;\n storyResult: any;\n}\n\n// Create a render function for testing that mimics Storybook's render behavior\nconst render = (args: Args, context?: any) => {\n const Component = context?.component;\n const renderer = context?.parameters?.renderer;\n const id = context?.id || 'test-story';\n \n // Renderers that are known to not work in the current integration\n const brokenRenderers: string[] = [];\n \n // Mimic the renderer detection logic from the main renderer\n if (renderer && brokenRenderers.includes(renderer)) {\n throw new Error(`Renderer '${renderer}' not found. Available renderers: react, vue, svelte, solid, preact`);\n }\n \n // For Astro components and working integrations, return a renderable object\n if (!Component) {\n throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);\n }\n \n // Astro components can be identified by isAstroComponentFactory\n if (typeof Component === 'function' && (Component as any).isAstroComponentFactory) {\n // This is an Astro component - return it for server-side rendering\n return Component;\n }\n \n // For framework components that have working integrations\n if (typeof Component === 'function') {\n if (renderer && !brokenRenderers.includes(renderer)) {\n // This would delegate to working framework renderer\n return Component;\n }\n \n // If no renderer specified for function component\n if (!renderer) {\n throw new Error(\n `Component appears to be a framework component but no renderer is specified. ` +\n `Add 'parameters: { renderer: \"framework-name\" }' to your story configuration.`\n );\n }\n }\n \n // Return a basic representation for testing\n return {\n component: Component,\n args: args,\n renderer: renderer || 'astro'\n };\n};\n\n/**\n * Function that sets the globalConfig of your storybook. The global config is the preview module of\n * your .storybook folder.\n *\n * It should be run a single time, so that your global config (e.g. decorators) is applied to your\n * stories when using `composeStories` or `composeStory`.\n *\n * Example:\n *\n * ```jsx\n * // setup-file.js\n * import { setProjectAnnotations } from '@storybook-astro/framework';\n * import projectAnnotations from './.storybook/preview';\n *\n * setProjectAnnotations(projectAnnotations);\n * ```\n *\n * @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')\n */\nexport function setProjectAnnotations<R extends AstroRenderer = AstroRenderer>(\n projectAnnotations:\n | NamedOrDefaultProjectAnnotations<R>\n | NamedOrDefaultProjectAnnotations<R>[]\n): NormalizedProjectAnnotations<R> {\n return originalSetProjectAnnotations<R>(projectAnnotations);\n}\n\n/**\n * Function that will receive a story along with meta (e.g. a default export from a .stories file)\n * and optionally projectAnnotations e.g. (import * as projectAnnotations from '../.storybook/preview')\n * and will return a composed component that has all args/parameters/decorators/etc combined and applied to it.\n *\n * It's very useful for reusing a story in scenarios outside of Storybook like unit testing.\n *\n * Example:\n * ```jsx\n * import { render } from '@testing-library/react';\n * import { composeStory } from '@storybook-astro/framework';\n * import meta, { Primary as PrimaryStory } from './Button.stories';\n *\n * const Primary = composeStory(PrimaryStory, meta);\n *\n * test('renders primary button', () => {\n * const { getByRole } = render(<Primary>Hello world</Primary>);\n * expect(getByRole('button')).toBeInTheDocument();\n * });\n * ```\n *\n * @param story - E.g. (import { Primary } from './Button.stories')\n * @param componentAnnotations - E.g. (import meta from './Button.stories')\n * @param projectAnnotations - E.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.\n * @param exportsName - In case your story does not contain a name and you want it to have a name.\n */\nexport function composeStory<TArgs extends Args = Args, R extends AstroRenderer = AstroRenderer>(\n story: StoryAnnotationsOrFn<R, TArgs>,\n componentAnnotations: ComponentAnnotations<R, TArgs>,\n projectAnnotations?: ProjectAnnotations<R>,\n exportsName?: string\n) {\n // Merge project annotations with Astro renderer\n const mergedProjectAnnotations: any = projectAnnotations ? {\n ...projectAnnotations,\n render: projectAnnotations.render || render\n } : {\n render\n };\n \n return originalComposeStory<AstroRenderer, TArgs>(\n story as any,\n componentAnnotations as any,\n mergedProjectAnnotations as any,\n exportsName as any\n );\n}\n\n/**\n * Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`)\n * and optionally a globalConfig (e.g. `import * from '../.storybook/preview`)\n * and will return an object containing all the stories passed, but now as a composed component that has all args/parameters/decorators/etc combined and applied to it.\n *\n * It's very useful for reusing stories in scenarios outside of Storybook like unit testing.\n *\n * Example:\n * ```jsx\n * import { render } from '@testing-library/react';\n * import { composeStories } from '@storybook-astro/framework';\n * import * as stories from './Button.stories';\n *\n * const { Primary, Secondary } = composeStories(stories);\n *\n * test('renders primary button', () => {\n * const { getByRole } = render(<Primary>Hello world</Primary>);\n * expect(getByRole('button')).toBeInTheDocument();\n * });\n * ```\n *\n * @param storiesImport - E.g. (import * as stories from './Button.stories')\n * @param projectAnnotations - E.g. (import * as globalConfig from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.\n */\nexport function composeStories<TModule extends Record<string, any>, R extends AstroRenderer = AstroRenderer>(\n storiesImport: TModule,\n projectAnnotations?: ProjectAnnotations<R>\n): { [K in keyof Omit<TModule, 'default'>]: any } {\n // Merge project annotations with Astro renderer\n const mergedProjectAnnotations: any = projectAnnotations ? {\n ...projectAnnotations,\n render: projectAnnotations.render || render\n } : {\n render\n };\n \n return originalComposeStories(storiesImport as any, mergedProjectAnnotations as any) as { [K in keyof Omit<TModule, 'default'>]: any };\n}\n"],"mappings":";AAWA;AAAA,EACE,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,yBAAyB;AAAA,OACpB;AASP,IAAM,SAAS,CAAC,MAAY,YAAkB;AAC5C,QAAM,YAAY,SAAS;AAC3B,QAAM,WAAW,SAAS,YAAY;AACtC,QAAM,KAAK,SAAS,MAAM;AAG1B,QAAM,kBAA4B,CAAC;AAGnC,MAAI,YAAY,gBAAgB,SAAS,QAAQ,GAAG;AAClD,UAAM,IAAI,MAAM,aAAa,QAAQ,qEAAqE;AAAA,EAC5G;AAGA,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,0BAA0B,EAAE,iEAAiE;AAAA,EAC/G;AAGA,MAAI,OAAO,cAAc,cAAe,UAAkB,yBAAyB;AAEjF,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,cAAc,YAAY;AACnC,QAAI,YAAY,CAAC,gBAAgB,SAAS,QAAQ,GAAG;AAEnD,aAAO;AAAA,IACT;AAGA,QAAI,CAAC,UAAU;AACb,YAAM,IAAI;AAAA,QACR;AAAA,MAEF;AAAA,IACF;AAAA,EACF;AAGA,SAAO;AAAA,IACL,WAAW;AAAA,IACX;AAAA,IACA,UAAU,YAAY;AAAA,EACxB;AACF;AAqBO,SAAS,sBACd,oBAGiC;AACjC,SAAO,8BAAiC,kBAAkB;AAC5D;AA4BO,SAAS,aACd,OACA,sBACA,oBACA,aACA;AAEA,QAAM,2BAAgC,qBAAqB;AAAA,IACzD,GAAG;AAAA,IACH,QAAQ,mBAAmB,UAAU;AAAA,EACvC,IAAI;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AA0BO,SAAS,eACd,eACA,oBACgD;AAEhD,QAAM,2BAAgC,qBAAqB;AAAA,IACzD,GAAG;AAAA,IACH,QAAQ,mBAAmB,UAAU;AAAA,EACvC,IAAI;AAAA,IACF;AAAA,EACF;AAEA,SAAO,uBAAuB,eAAsB,wBAA+B;AACrF;","names":[]}
|
|
@@ -16,24 +16,64 @@ async function selectStoryRules(input) {
|
|
|
16
16
|
if (typeof use !== "function") {
|
|
17
17
|
throw new Error('Each story rule "use" entry must be a function.');
|
|
18
18
|
}
|
|
19
|
-
await use({
|
|
20
|
-
mode: input.mode,
|
|
19
|
+
const cleanup = await use({
|
|
21
20
|
story,
|
|
22
|
-
msw: {
|
|
23
|
-
use: (...handlers) => {
|
|
24
|
-
selection.mswHandlers.push(...handlers);
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
21
|
mock: (specifier, replacement) => {
|
|
28
22
|
const normalizedSpecifier = normalizeMockSpecifier(specifier);
|
|
29
23
|
const normalizedReplacement = normalizeMockReplacement(replacement, input.configFilePath);
|
|
30
24
|
selection.moduleMocks.set(normalizedSpecifier, normalizedReplacement);
|
|
31
25
|
}
|
|
32
26
|
});
|
|
27
|
+
if (cleanup !== void 0) {
|
|
28
|
+
if (typeof cleanup !== "function") {
|
|
29
|
+
throw new Error('Story rule "use" must return either nothing or a cleanup function.');
|
|
30
|
+
}
|
|
31
|
+
selection.cleanups.push(cleanup);
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
return selection;
|
|
36
36
|
}
|
|
37
|
+
async function withStoryRuleCleanups(cleanups, callback) {
|
|
38
|
+
let result;
|
|
39
|
+
let callbackError;
|
|
40
|
+
try {
|
|
41
|
+
result = await callback();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
callbackError = error;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
await runStoryRuleCleanups(cleanups);
|
|
47
|
+
} catch (cleanupError) {
|
|
48
|
+
if (callbackError) {
|
|
49
|
+
throw new AggregateError(
|
|
50
|
+
[callbackError, cleanupError],
|
|
51
|
+
"Story rule execution and cleanup both failed."
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
throw cleanupError;
|
|
55
|
+
}
|
|
56
|
+
if (callbackError) {
|
|
57
|
+
throw callbackError;
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
async function runStoryRuleCleanups(cleanups) {
|
|
62
|
+
const errors = [];
|
|
63
|
+
for (let index = cleanups.length - 1; index >= 0; index -= 1) {
|
|
64
|
+
try {
|
|
65
|
+
await cleanups[index]();
|
|
66
|
+
} catch (error) {
|
|
67
|
+
errors.push(error);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (errors.length === 1) {
|
|
71
|
+
throw errors[0];
|
|
72
|
+
}
|
|
73
|
+
if (errors.length > 1) {
|
|
74
|
+
throw new AggregateError(errors, "Story rule cleanup failed.");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
37
77
|
function normalizeRulesConfig(configModule) {
|
|
38
78
|
const configExport = getRulesConfigExport(configModule);
|
|
39
79
|
if (configExport === void 0 || configExport === null) {
|
|
@@ -176,7 +216,7 @@ function slugify(input) {
|
|
|
176
216
|
function createEmptySelection() {
|
|
177
217
|
return {
|
|
178
218
|
moduleMocks: /* @__PURE__ */ new Map(),
|
|
179
|
-
|
|
219
|
+
cleanups: []
|
|
180
220
|
};
|
|
181
221
|
}
|
|
182
222
|
function toPosixPath(input) {
|
|
@@ -192,6 +232,55 @@ function isRecord(value) {
|
|
|
192
232
|
return !Array.isArray(value);
|
|
193
233
|
}
|
|
194
234
|
|
|
235
|
+
// src/lib/passthrough-image-service.ts
|
|
236
|
+
function installPassthroughImageService() {
|
|
237
|
+
if (!globalThis.astroAsset) {
|
|
238
|
+
globalThis.astroAsset = {};
|
|
239
|
+
}
|
|
240
|
+
globalThis.astroAsset.imageService = {
|
|
241
|
+
propertiesToHash: ["src"],
|
|
242
|
+
validateOptions(options) {
|
|
243
|
+
return options;
|
|
244
|
+
},
|
|
245
|
+
getURL(options) {
|
|
246
|
+
const src = options.src;
|
|
247
|
+
if (src != null && typeof src === "object" && "src" in src && typeof src.src === "string") {
|
|
248
|
+
return src.src;
|
|
249
|
+
}
|
|
250
|
+
return typeof src === "string" ? src : "";
|
|
251
|
+
},
|
|
252
|
+
getHTMLAttributes(options) {
|
|
253
|
+
const {
|
|
254
|
+
src,
|
|
255
|
+
width,
|
|
256
|
+
height,
|
|
257
|
+
format: _format,
|
|
258
|
+
quality: _quality,
|
|
259
|
+
densities: _densities,
|
|
260
|
+
widths: _widths,
|
|
261
|
+
formats: _formats,
|
|
262
|
+
layout: _layout,
|
|
263
|
+
priority: _priority,
|
|
264
|
+
fit: _fit,
|
|
265
|
+
position: _position,
|
|
266
|
+
background: _background,
|
|
267
|
+
...attrs
|
|
268
|
+
} = options;
|
|
269
|
+
const srcObj = src != null && typeof src === "object" ? src : null;
|
|
270
|
+
return {
|
|
271
|
+
...attrs,
|
|
272
|
+
width: width ?? srcObj?.width,
|
|
273
|
+
height: height ?? srcObj?.height,
|
|
274
|
+
loading: attrs.loading ?? "lazy",
|
|
275
|
+
decoding: attrs.decoding ?? "async"
|
|
276
|
+
};
|
|
277
|
+
},
|
|
278
|
+
getSrcSet() {
|
|
279
|
+
return [];
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
195
284
|
// src/lib/sanitization.ts
|
|
196
285
|
import sanitizeHtml from "sanitize-html";
|
|
197
286
|
var DEFAULT_SANITIZE_HTML_OPTIONS = {
|
|
@@ -314,6 +403,16 @@ function sanitizeRenderPayload(payload, options) {
|
|
|
314
403
|
slots: sanitizedSlots
|
|
315
404
|
};
|
|
316
405
|
}
|
|
406
|
+
function serializeSanitizationOptions(options) {
|
|
407
|
+
if (!options) {
|
|
408
|
+
return "undefined";
|
|
409
|
+
}
|
|
410
|
+
assertNoFunctions(options.sanitizeHtml, "framework.options.sanitization.sanitizeHtml");
|
|
411
|
+
const state = {
|
|
412
|
+
seen: /* @__PURE__ */ new WeakSet()
|
|
413
|
+
};
|
|
414
|
+
return serializeValue(options, "framework.options.sanitization", state);
|
|
415
|
+
}
|
|
317
416
|
function mergeSanitizeHtmlOptions(userOptions) {
|
|
318
417
|
const merged = {
|
|
319
418
|
...DEFAULT_SANITIZE_HTML_OPTIONS,
|
|
@@ -397,6 +496,68 @@ function matchesPathPattern(path, pattern) {
|
|
|
397
496
|
const patternSegments = pattern.split(".");
|
|
398
497
|
return matchSegments(pathSegments, patternSegments);
|
|
399
498
|
}
|
|
499
|
+
function serializeValue(value, path, state) {
|
|
500
|
+
if (value === null) {
|
|
501
|
+
return "null";
|
|
502
|
+
}
|
|
503
|
+
if (value === void 0) {
|
|
504
|
+
return "undefined";
|
|
505
|
+
}
|
|
506
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
507
|
+
return JSON.stringify(value);
|
|
508
|
+
}
|
|
509
|
+
if (value instanceof RegExp) {
|
|
510
|
+
return value.toString();
|
|
511
|
+
}
|
|
512
|
+
if (Array.isArray(value)) {
|
|
513
|
+
const serializedItems = value.map(
|
|
514
|
+
(item, index) => serializeValue(item, `${path}[${index}]`, state)
|
|
515
|
+
);
|
|
516
|
+
return `[${serializedItems.join(", ")}]`;
|
|
517
|
+
}
|
|
518
|
+
if (isRecord2(value)) {
|
|
519
|
+
if (state.seen.has(value)) {
|
|
520
|
+
throw new Error(`${path} contains a circular reference.`);
|
|
521
|
+
}
|
|
522
|
+
state.seen.add(value);
|
|
523
|
+
const serializedEntries = Object.entries(value).filter(([, nestedValue]) => nestedValue !== void 0).map(([key, nestedValue]) => {
|
|
524
|
+
const serializedNestedValue = serializeValue(nestedValue, `${path}.${key}`, state);
|
|
525
|
+
return `${JSON.stringify(key)}: ${serializedNestedValue}`;
|
|
526
|
+
});
|
|
527
|
+
return `{ ${serializedEntries.join(", ")} }`;
|
|
528
|
+
}
|
|
529
|
+
throw new Error(
|
|
530
|
+
`${path} contains an unsupported value of type ${typeof value}. Only plain objects, arrays, primitives, and regular expressions are supported.`
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
function assertNoFunctions(value, path) {
|
|
534
|
+
const state = {
|
|
535
|
+
seen: /* @__PURE__ */ new WeakSet()
|
|
536
|
+
};
|
|
537
|
+
assertNoFunctionsRecursive(value, path, state);
|
|
538
|
+
}
|
|
539
|
+
function assertNoFunctionsRecursive(value, path, state) {
|
|
540
|
+
if (typeof value === "function") {
|
|
541
|
+
throw new Error(
|
|
542
|
+
`${path} cannot contain functions. Function-valued sanitization hooks are not supported in framework options.`
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
if (Array.isArray(value)) {
|
|
546
|
+
value.forEach((item, index) => {
|
|
547
|
+
assertNoFunctionsRecursive(item, `${path}[${index}]`, state);
|
|
548
|
+
});
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
if (isRecord2(value)) {
|
|
552
|
+
if (state.seen.has(value)) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
state.seen.add(value);
|
|
556
|
+
Object.entries(value).forEach(([key, nestedValue]) => {
|
|
557
|
+
assertNoFunctionsRecursive(nestedValue, `${path}.${key}`, state);
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
}
|
|
400
561
|
function matchSegments(pathSegments, patternSegments) {
|
|
401
562
|
if (patternSegments.length === 0) {
|
|
402
563
|
return pathSegments.length === 0;
|
|
@@ -444,49 +605,15 @@ function resolveStoryModuleMock(specifier) {
|
|
|
444
605
|
return moduleMockStorage.getStore()?.get(specifier);
|
|
445
606
|
}
|
|
446
607
|
|
|
447
|
-
// src/msw.ts
|
|
448
|
-
import { setupServer } from "msw/node";
|
|
449
|
-
var defaultListenOptions = {
|
|
450
|
-
onUnhandledRequest: "bypass"
|
|
451
|
-
};
|
|
452
|
-
async function applyMswHandlers(handlers) {
|
|
453
|
-
const state = getMswState();
|
|
454
|
-
if (state.pendingUpdate) {
|
|
455
|
-
await state.pendingUpdate;
|
|
456
|
-
}
|
|
457
|
-
const updatePromise = syncMswHandlers(handlers, state);
|
|
458
|
-
state.pendingUpdate = updatePromise;
|
|
459
|
-
try {
|
|
460
|
-
await updatePromise;
|
|
461
|
-
} finally {
|
|
462
|
-
state.pendingUpdate = void 0;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
async function syncMswHandlers(handlers, state) {
|
|
466
|
-
if (!state.server) {
|
|
467
|
-
state.server = setupServer();
|
|
468
|
-
state.server.listen(defaultListenOptions);
|
|
469
|
-
}
|
|
470
|
-
state.server.resetHandlers(...handlers);
|
|
471
|
-
}
|
|
472
|
-
function getMswState() {
|
|
473
|
-
const globalState = globalThis;
|
|
474
|
-
if (!globalState.__storybookAstroMswState__) {
|
|
475
|
-
globalState.__storybookAstroMswState__ = {
|
|
476
|
-
server: void 0,
|
|
477
|
-
pendingUpdate: void 0
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
|
-
return globalState.__storybookAstroMswState__;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
608
|
export {
|
|
484
609
|
defineStoryRules,
|
|
485
610
|
selectStoryRules,
|
|
611
|
+
withStoryRuleCleanups,
|
|
612
|
+
installPassthroughImageService,
|
|
486
613
|
resolveSanitizationOptions,
|
|
487
614
|
sanitizeRenderPayload,
|
|
615
|
+
serializeSanitizationOptions,
|
|
488
616
|
withStoryModuleMocks,
|
|
489
|
-
resolveStoryModuleMock
|
|
490
|
-
applyMswHandlers
|
|
617
|
+
resolveStoryModuleMock
|
|
491
618
|
};
|
|
492
|
-
//# sourceMappingURL=chunk-
|
|
619
|
+
//# sourceMappingURL=chunk-OUEDTRBO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rules.ts","../src/lib/passthrough-image-service.ts","../src/lib/sanitization.ts","../src/module-mocks.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport type { RenderStoryInput } from './types.ts';\n\nexport type StoryRuleCleanup = () => void | Promise<void>;\ntype StoryRuleUseResult = void | StoryRuleCleanup | Promise<void | StoryRuleCleanup>;\n\nexport type StoryRuleUseContext = {\n story: StoryRuleStory;\n mock: (specifier: string, replacement: string) => void;\n};\n\nexport type StoryRuleUse = (context: StoryRuleUseContext) => StoryRuleUseResult;\n\nexport type StoryRule = {\n match: string | string[];\n use: StoryRuleUse | StoryRuleUse[];\n};\n\nexport type StoryRulesConfig = {\n rules: StoryRule[];\n};\n\nexport type StoryRuleStory = {\n id: string;\n title?: string;\n name?: string;\n keys: string[];\n};\n\nexport type StoryRuleSelectionInput = {\n configModule: unknown;\n configFilePath?: string;\n story?: RenderStoryInput;\n};\n\nexport type StoryRuleSelection = {\n moduleMocks: Map<string, string>;\n cleanups: StoryRuleCleanup[];\n};\n\ntype MutableStoryRuleSelection = {\n moduleMocks: Map<string, string>;\n cleanups: StoryRuleCleanup[];\n};\n\nexport function defineStoryRules(config: StoryRulesConfig): StoryRulesConfig {\n return config;\n}\n\nexport async function selectStoryRules(\n input: StoryRuleSelectionInput\n): Promise<StoryRuleSelection> {\n const config = normalizeRulesConfig(input.configModule);\n const story = normalizeStory(input.story);\n const selection = createEmptySelection();\n\n for (const rule of config.rules) {\n if (!isStoryRuleMatch(rule.match, story)) {\n continue;\n }\n\n const uses = Array.isArray(rule.use) ? rule.use : [rule.use];\n\n for (const use of uses) {\n if (typeof use !== 'function') {\n throw new Error('Each story rule \"use\" entry must be a function.');\n }\n\n const cleanup = await use({\n story,\n mock: (specifier, replacement) => {\n const normalizedSpecifier = normalizeMockSpecifier(specifier);\n const normalizedReplacement = normalizeMockReplacement(replacement, input.configFilePath);\n\n selection.moduleMocks.set(normalizedSpecifier, normalizedReplacement);\n }\n });\n\n if (cleanup !== undefined) {\n if (typeof cleanup !== 'function') {\n throw new Error('Story rule \"use\" must return either nothing or a cleanup function.');\n }\n\n selection.cleanups.push(cleanup);\n }\n }\n }\n\n return selection;\n}\n\nexport async function withStoryRuleCleanups<T>(\n cleanups: StoryRuleCleanup[],\n callback: () => Promise<T>\n): Promise<T> {\n let result: T | undefined;\n let callbackError: unknown;\n\n try {\n result = await callback();\n } catch (error) {\n callbackError = error;\n }\n\n try {\n await runStoryRuleCleanups(cleanups);\n } catch (cleanupError) {\n if (callbackError) {\n throw new AggregateError(\n [callbackError, cleanupError],\n 'Story rule execution and cleanup both failed.'\n );\n }\n\n throw cleanupError;\n }\n\n if (callbackError) {\n throw callbackError;\n }\n\n return result as T;\n}\n\nexport async function runStoryRuleCleanups(cleanups: StoryRuleCleanup[]): Promise<void> {\n const errors: unknown[] = [];\n\n for (let index = cleanups.length - 1; index >= 0; index -= 1) {\n try {\n await cleanups[index]();\n } catch (error) {\n errors.push(error);\n }\n }\n\n if (errors.length === 1) {\n throw errors[0];\n }\n\n if (errors.length > 1) {\n throw new AggregateError(errors, 'Story rule cleanup failed.');\n }\n}\n\nfunction normalizeRulesConfig(configModule: unknown): StoryRulesConfig {\n const configExport = getRulesConfigExport(configModule);\n\n if (configExport === undefined || configExport === null) {\n return {\n rules: []\n };\n }\n\n if (!isRecord(configExport)) {\n throw new Error(\n 'Story rules config must export an object with a \"rules\" array via a default export or named export.'\n );\n }\n\n const rules = configExport.rules;\n\n if (rules === undefined) {\n return {\n rules: []\n };\n }\n\n if (!Array.isArray(rules)) {\n throw new Error('Story rules config \"rules\" must be an array.');\n }\n\n return {\n rules: rules as StoryRule[]\n };\n}\n\nfunction getRulesConfigExport(configModule: unknown): unknown {\n if (!isRecord(configModule)) {\n return configModule;\n }\n\n if ('default' in configModule && configModule.default !== undefined) {\n return configModule.default;\n }\n\n if ('rules' in configModule) {\n return {\n rules: configModule.rules\n };\n }\n\n return undefined;\n}\n\nfunction normalizeStory(story?: RenderStoryInput): StoryRuleStory {\n const id = normalizeStoryId(story?.id);\n const title = normalizeOptionalString(story?.title);\n const name = normalizeOptionalString(story?.name);\n const keys = Array.from(resolveStoryKeys({ id, title, name }));\n\n return {\n id,\n title,\n name,\n keys\n };\n}\n\nfunction resolveStoryKeys(story: { id: string; title?: string; name?: string }) {\n const keys = new Set<string>();\n\n keys.add('');\n\n const storyId = story.id;\n const idPath = storyId ? storyId.replaceAll('--', '/') : '';\n\n if (storyId) {\n keys.add(storyId);\n keys.add(`/story/${storyId}`);\n }\n\n if (idPath) {\n keys.add(idPath);\n keys.add(`/story/${idPath}`);\n }\n\n const titlePath = story.title\n ? story.title\n .split('/')\n .map((segment) => slugify(segment))\n .filter(Boolean)\n .join('/')\n : '';\n\n const storyNamePath = story.name ? slugify(story.name) : '';\n\n if (titlePath && storyNamePath) {\n const composedPath = `${titlePath}/${storyNamePath}`;\n\n keys.add(composedPath);\n keys.add(`/story/${composedPath}`);\n }\n\n return keys;\n}\n\nfunction isStoryRuleMatch(match: string | string[], story: StoryRuleStory): boolean {\n const patterns = Array.isArray(match) ? match : [match];\n\n return patterns.some((pattern) => {\n if (typeof pattern !== 'string') {\n throw new Error('Story rule \"match\" must be a string or an array of strings.');\n }\n\n const normalizedPattern = pattern.trim();\n\n if (!normalizedPattern) {\n throw new Error('Story rule \"match\" cannot be empty.');\n }\n\n return story.keys.some((key) => isWildcardMatch(normalizedPattern, key));\n });\n}\n\nfunction isWildcardMatch(pattern: string, candidate: string): boolean {\n const escapedPattern = escapeRegExp(pattern).replaceAll('*', '.*');\n const regex = new RegExp(`^${escapedPattern}$`);\n\n return regex.test(candidate);\n}\n\nfunction normalizeStoryId(id?: string): string {\n const value = normalizeOptionalString(id) ?? '';\n\n if (!value) {\n return '';\n }\n\n return value.startsWith('/story/') ? value.slice('/story/'.length) : value;\n}\n\nfunction normalizeOptionalString(value: unknown): string | undefined {\n if (typeof value !== 'string') {\n return undefined;\n }\n\n const normalizedValue = value.trim();\n\n return normalizedValue || undefined;\n}\n\nfunction normalizeMockSpecifier(value: unknown): string {\n if (typeof value !== 'string') {\n throw new Error('Story rule mock specifier must be a string.');\n }\n\n const normalizedValue = value.trim();\n\n if (!normalizedValue) {\n throw new Error('Story rule mock specifier cannot be empty.');\n }\n\n return normalizedValue;\n}\n\nfunction normalizeMockReplacement(value: unknown, configFilePath?: string): string {\n if (typeof value !== 'string') {\n throw new Error('Story rule mock replacement must be a string.');\n }\n\n const normalizedValue = value.trim();\n\n if (!normalizedValue) {\n throw new Error('Story rule mock replacement cannot be empty.');\n }\n\n if (isAbsolute(normalizedValue)) {\n return toPosixPath(normalizedValue);\n }\n\n if (normalizedValue.startsWith('.')) {\n if (!configFilePath) {\n throw new Error(\n 'Story rule mock replacement uses a relative path, but rules config path is unavailable.'\n );\n }\n\n return toPosixPath(resolve(dirname(configFilePath), normalizedValue));\n }\n\n return normalizedValue;\n}\n\nfunction slugify(input: string): string {\n return input\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n\nfunction createEmptySelection(): MutableStoryRuleSelection {\n return {\n moduleMocks: new Map(),\n cleanups: []\n };\n}\n\nfunction toPosixPath(input: string): string {\n return input.replaceAll('\\\\', '/');\n}\n\nfunction escapeRegExp(input: string) {\n return input.replace(/[|\\\\{}()[\\]^$+?.]/g, '\\\\$&');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n return !Array.isArray(value);\n}\n","/**\n * Install a passthrough image service on `globalThis.astroAsset.imageService`.\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 — `getConfiguredImageService()` checks this global first and returns\n * it without going through the broken virtual module. Our service returns the\n * direct /@fs/... Vite URL from the ImageMetadata object, which Vite can serve\n * as a static asset in the browser; in static (build-time prerender) mode the\n * URL ends up being rewritten to a content-hashed Rollup asset.\n *\n * This must be called on the same Node process that hosts AstroContainer,\n * before `container.renderToString()` is invoked.\n */\nexport function installPassthroughImageService() {\n if (!globalThis.astroAsset) {\n (globalThis as Record<string, unknown>).astroAsset = {};\n }\n\n (globalThis.astroAsset as Record<string, unknown>).imageService = {\n propertiesToHash: ['src'],\n validateOptions(options: Record<string, unknown>) {\n return options;\n },\n getURL(options: { src: unknown }) {\n const src = options.src;\n\n if (\n src != null &&\n typeof src === 'object' &&\n 'src' in src &&\n typeof (src as Record<string, unknown>).src === 'string'\n ) {\n // 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 {\n src,\n width,\n height,\n format: _format,\n quality: _quality,\n densities: _densities,\n widths: _widths,\n formats: _formats,\n layout: _layout,\n priority: _priority,\n fit: _fit,\n position: _position,\n background: _background,\n ...attrs\n } = 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","import sanitizeHtml from 'sanitize-html';\nimport type { IOptions } from 'sanitize-html';\n\ntype SanitizationPayload = {\n args: Record<string, unknown>;\n slots: Record<string, unknown>;\n};\n\nexport type SanitizationOptions = {\n enabled?: boolean;\n args?: string[];\n slots?: string[];\n sanitizeHtml?: IOptions;\n};\n\nexport type ResolvedSanitizationOptions = {\n enabled: boolean;\n args: string[];\n slots: string[];\n sanitizeHtml: IOptions;\n};\n\nconst DEFAULT_SANITIZE_HTML_OPTIONS: IOptions = {\n allowedTags: [\n 'a',\n 'abbr',\n 'b',\n 'blockquote',\n 'br',\n 'caption',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'dd',\n 'details',\n 'dfn',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'figure',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'i',\n 'img',\n 'kbd',\n 'li',\n 'mark',\n 'ol',\n 'p',\n 'pre',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'u',\n 'ul',\n 'var',\n 'wbr'\n ],\n allowedAttributes: {\n '*': [\n 'aria-describedby',\n 'aria-hidden',\n 'aria-label',\n 'aria-labelledby',\n 'class',\n 'id',\n 'lang',\n 'role',\n 'title'\n ],\n a: ['href', 'name', 'target', 'rel'],\n img: ['src', 'srcset', 'alt', 'title', 'width', 'height', 'loading', 'decoding'],\n td: ['colspan', 'rowspan'],\n th: ['colspan', 'rowspan', 'scope'],\n time: ['datetime']\n },\n allowedSchemes: ['http', 'https', 'mailto', 'tel', 'data'],\n allowedSchemesByTag: {\n a: ['http', 'https', 'mailto', 'tel'],\n img: ['http', 'https', 'data']\n },\n allowedSchemesAppliedToAttributes: ['href', 'src', 'cite', 'srcset'],\n allowProtocolRelative: false,\n disallowedTagsMode: 'discard',\n enforceHtmlBoundary: true,\n parseStyleAttributes: false\n};\n\nexport function resolveSanitizationOptions(options?: SanitizationOptions): ResolvedSanitizationOptions {\n if (!options) {\n return {\n enabled: true,\n args: [],\n slots: ['**'],\n sanitizeHtml: mergeSanitizeHtmlOptions()\n };\n }\n\n const enabled = options.enabled ?? true;\n const args = normalizePathList(options.args, 'framework.options.sanitization.args');\n const slots =\n options.slots === undefined\n ? ['**']\n : normalizePathList(options.slots, 'framework.options.sanitization.slots');\n\n return {\n enabled,\n args,\n slots,\n sanitizeHtml: mergeSanitizeHtmlOptions(options.sanitizeHtml)\n };\n}\n\nexport function sanitizeRenderPayload(\n payload: SanitizationPayload,\n options: ResolvedSanitizationOptions\n): SanitizationPayload {\n if (!options.enabled) {\n return payload;\n }\n\n const sanitizedArgs =\n options.args.length > 0\n ? sanitizeRecord(payload.args, options.args, options.sanitizeHtml)\n : payload.args;\n\n const sanitizedSlots =\n options.slots.length > 0\n ? sanitizeRecord(payload.slots, options.slots, options.sanitizeHtml)\n : payload.slots;\n\n return {\n args: sanitizedArgs,\n slots: sanitizedSlots\n };\n}\n\nexport function serializeSanitizationOptions(options?: SanitizationOptions): string {\n if (!options) {\n return 'undefined';\n }\n\n assertNoFunctions(options.sanitizeHtml, 'framework.options.sanitization.sanitizeHtml');\n\n const state = {\n seen: new WeakSet<object>()\n };\n\n return serializeValue(options, 'framework.options.sanitization', state);\n}\n\nfunction mergeSanitizeHtmlOptions(userOptions?: IOptions): IOptions {\n const merged: IOptions = {\n ...DEFAULT_SANITIZE_HTML_OPTIONS,\n ...userOptions\n };\n\n if (\n isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes) &&\n isRecord(userOptions?.allowedAttributes)\n ) {\n merged.allowedAttributes = {\n ...DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes,\n ...userOptions.allowedAttributes\n };\n }\n\n if (isRecord(userOptions?.allowedClasses)) {\n merged.allowedClasses = {\n ...(isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses)\n ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses\n : {}),\n ...userOptions.allowedClasses\n };\n }\n\n if (isRecord(userOptions?.allowedStyles)) {\n merged.allowedStyles = {\n ...(isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles)\n ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles\n : {}),\n ...userOptions.allowedStyles\n };\n }\n\n return merged;\n}\n\nfunction normalizePathList(value: unknown, path: string): string[] {\n if (value === undefined) {\n return [];\n }\n\n if (!Array.isArray(value)) {\n throw new Error(`${path} must be an array of dot-path patterns.`);\n }\n\n const unique = new Set<string>();\n\n value.forEach((entry, index) => {\n if (typeof entry !== 'string') {\n throw new Error(`${path}[${index}] must be a string.`);\n }\n\n const normalized = entry.trim();\n\n if (!normalized) {\n throw new Error(`${path}[${index}] cannot be an empty string.`);\n }\n\n unique.add(normalized);\n });\n\n return Array.from(unique);\n}\n\nfunction sanitizeRecord(\n record: Record<string, unknown>,\n patterns: string[],\n options: IOptions\n): Record<string, unknown> {\n const sanitized: Record<string, unknown> = {};\n\n Object.entries(record).forEach(([key, value]) => {\n sanitized[key] = sanitizeValue(value, key, patterns, options);\n });\n\n return sanitized;\n}\n\nfunction sanitizeValue(\n value: unknown,\n currentPath: string,\n patterns: string[],\n options: IOptions\n): unknown {\n if (typeof value === 'string') {\n if (shouldSanitizePath(currentPath, patterns)) {\n return sanitizeHtml(value, options);\n }\n\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item, index) => {\n const nextPath = `${currentPath}.${index}`;\n\n return sanitizeValue(item, nextPath, patterns, options);\n });\n }\n\n if (isRecord(value)) {\n const sanitized: Record<string, unknown> = {};\n\n Object.entries(value).forEach(([key, nestedValue]) => {\n const nextPath = `${currentPath}.${key}`;\n\n sanitized[key] = sanitizeValue(nestedValue, nextPath, patterns, options);\n });\n\n return sanitized;\n }\n\n return value;\n}\n\nfunction shouldSanitizePath(path: string, patterns: string[]): boolean {\n return patterns.some((pattern) => matchesPathPattern(path, pattern));\n}\n\nfunction matchesPathPattern(path: string, pattern: string): boolean {\n const pathSegments = path.split('.');\n const patternSegments = pattern.split('.');\n\n return matchSegments(pathSegments, patternSegments);\n}\n\nfunction serializeValue(value: unknown, path: string, state: { seen: WeakSet<object> }): string {\n if (value === null) {\n return 'null';\n }\n\n if (value === undefined) {\n return 'undefined';\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return JSON.stringify(value);\n }\n\n if (value instanceof RegExp) {\n return value.toString();\n }\n\n if (Array.isArray(value)) {\n const serializedItems = value.map((item, index) =>\n serializeValue(item, `${path}[${index}]`, state)\n );\n\n return `[${serializedItems.join(', ')}]`;\n }\n\n if (isRecord(value)) {\n if (state.seen.has(value)) {\n throw new Error(`${path} contains a circular reference.`);\n }\n\n state.seen.add(value);\n\n const serializedEntries = Object.entries(value)\n .filter(([, nestedValue]) => nestedValue !== undefined)\n .map(([key, nestedValue]) => {\n const serializedNestedValue = serializeValue(nestedValue, `${path}.${key}`, state);\n\n return `${JSON.stringify(key)}: ${serializedNestedValue}`;\n });\n\n return `{ ${serializedEntries.join(', ')} }`;\n }\n\n throw new Error(\n `${path} contains an unsupported value of type ${typeof value}. ` +\n 'Only plain objects, arrays, primitives, and regular expressions are supported.'\n );\n}\n\nfunction assertNoFunctions(value: unknown, path: string): void {\n const state = {\n seen: new WeakSet<object>()\n };\n\n assertNoFunctionsRecursive(value, path, state);\n}\n\nfunction assertNoFunctionsRecursive(\n value: unknown,\n path: string,\n state: { seen: WeakSet<object> }\n): void {\n if (typeof value === 'function') {\n throw new Error(\n `${path} cannot contain functions. ` +\n 'Function-valued sanitization hooks are not supported in framework options.'\n );\n }\n\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n assertNoFunctionsRecursive(item, `${path}[${index}]`, state);\n });\n\n return;\n }\n\n if (isRecord(value)) {\n if (state.seen.has(value)) {\n return;\n }\n\n state.seen.add(value);\n\n Object.entries(value).forEach(([key, nestedValue]) => {\n assertNoFunctionsRecursive(nestedValue, `${path}.${key}`, state);\n });\n }\n}\n\nfunction matchSegments(pathSegments: string[], patternSegments: string[]): boolean {\n if (patternSegments.length === 0) {\n return pathSegments.length === 0;\n }\n\n const [patternHead, ...patternTail] = patternSegments;\n\n if (patternHead === '**') {\n if (patternTail.length === 0) {\n return true;\n }\n\n for (let index = 0; index <= pathSegments.length; index += 1) {\n const remainingPath = pathSegments.slice(index);\n\n if (matchSegments(remainingPath, patternTail)) {\n return true;\n }\n }\n\n return false;\n }\n\n if (pathSegments.length === 0) {\n return false;\n }\n\n const [pathHead, ...pathTail] = pathSegments;\n\n if (patternHead === '*' || patternHead === pathHead) {\n return matchSegments(pathTail, patternTail);\n }\n\n return false;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n if (Array.isArray(value) || value instanceof RegExp) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n\n return prototype === Object.prototype || prototype === null;\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\n\nexport type StoryModuleMocks = Map<string, string>;\n\nconst moduleMockStorage = new AsyncLocalStorage<StoryModuleMocks>();\n\nexport async function withStoryModuleMocks<T>(\n moduleMocks: StoryModuleMocks,\n callback: () => Promise<T>\n): Promise<T> {\n return moduleMockStorage.run(moduleMocks, callback);\n}\n\nexport function resolveStoryModuleMock(specifier: string): string | undefined {\n return moduleM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