@storybook-astro/framework 1.3.0-canary.2 → 1.3.0-canary.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,267 +1,59 @@
1
1
  import {
2
- createInlineStoryModuleMock,
3
- createPathStoryModuleMock,
2
+ selectStoryRules,
3
+ withStoryRuleCleanups
4
+ } from "./chunk-ZIDMHD4S.js";
5
+ import {
4
6
  withStoryModuleMocks
5
7
  } from "./chunk-B5HHF6FC.js";
6
8
 
7
- // src/rules.ts
8
- import { dirname, isAbsolute, resolve } from "path";
9
- function defineStoryRules(config) {
10
- return config;
11
- }
12
- async function selectStoryRules(input) {
13
- const config = normalizeRulesConfig(input.configModule);
14
- const story = normalizeStory(input.story);
15
- const selection = createEmptySelection();
16
- for (const rule of config.rules) {
17
- if (!isStoryRuleMatch(rule.match, story)) {
18
- continue;
19
- }
20
- const uses = Array.isArray(rule.use) ? rule.use : [rule.use];
21
- for (const use of uses) {
22
- const pendingModuleMocks = [];
23
- if (typeof use !== "function") {
24
- throw new Error('Each story rule "use" entry must be a function.');
25
- }
26
- const cleanup = await use({
27
- story,
28
- mock: ((specifier, replacementOrFactory) => {
29
- const normalizedSpecifier = normalizeMockSpecifier(specifier);
30
- if (typeof replacementOrFactory === "function") {
31
- pendingModuleMocks.push(
32
- Promise.resolve(replacementOrFactory()).then((exportsObject) => {
33
- selection.moduleMocks.set(
34
- normalizedSpecifier,
35
- createInlineStoryModuleMock(normalizeMockFactoryResult(exportsObject))
36
- );
37
- return void 0;
38
- })
39
- );
40
- return;
41
- }
42
- const normalizedReplacement = normalizeMockReplacement(
43
- replacementOrFactory,
44
- input.configFilePath
45
- );
46
- selection.moduleMocks.set(normalizedSpecifier, createPathStoryModuleMock(normalizedReplacement));
47
- })
48
- });
49
- if (pendingModuleMocks.length > 0) {
50
- await Promise.all(pendingModuleMocks);
51
- }
52
- if (cleanup !== void 0) {
53
- if (typeof cleanup !== "function") {
54
- throw new Error('Story rule "use" must return either nothing or a cleanup function.');
55
- }
56
- selection.cleanups.push(cleanup);
57
- }
58
- }
59
- }
60
- return selection;
61
- }
62
- async function withStoryRuleCleanups(cleanups, callback) {
63
- let result;
64
- let callbackError;
65
- try {
66
- result = await callback();
67
- } catch (error) {
68
- callbackError = error;
69
- }
70
- try {
71
- await runStoryRuleCleanups(cleanups);
72
- } catch (cleanupError) {
73
- if (callbackError) {
74
- throw new AggregateError(
75
- [callbackError, cleanupError],
76
- "Story rule execution and cleanup both failed."
77
- );
78
- }
79
- throw cleanupError;
80
- }
81
- if (callbackError) {
82
- throw callbackError;
83
- }
84
- return result;
85
- }
86
- async function runStoryRuleCleanups(cleanups) {
87
- const errors = [];
88
- for (let index = cleanups.length - 1; index >= 0; index -= 1) {
89
- try {
90
- await cleanups[index]();
91
- } catch (error) {
92
- errors.push(error);
93
- }
94
- }
95
- if (errors.length === 1) {
96
- throw errors[0];
97
- }
98
- if (errors.length > 1) {
99
- throw new AggregateError(errors, "Story rule cleanup failed.");
100
- }
101
- }
102
- function normalizeRulesConfig(configModule) {
103
- const configExport = getRulesConfigExport(configModule);
104
- if (configExport === void 0 || configExport === null) {
105
- return {
106
- rules: []
107
- };
108
- }
109
- if (!isRecord(configExport)) {
110
- throw new Error(
111
- 'Story rules config must export an object with a "rules" array via a default export or named export.'
112
- );
113
- }
114
- const rules = configExport.rules;
115
- if (rules === void 0) {
116
- return {
117
- rules: []
118
- };
119
- }
120
- if (!Array.isArray(rules)) {
121
- throw new Error('Story rules config "rules" must be an array.');
122
- }
123
- return {
124
- rules
125
- };
126
- }
127
- function getRulesConfigExport(configModule) {
128
- if (!isRecord(configModule)) {
129
- return configModule;
130
- }
131
- if ("default" in configModule && configModule.default !== void 0) {
132
- return configModule.default;
133
- }
134
- if ("rules" in configModule) {
135
- return {
136
- rules: configModule.rules
137
- };
138
- }
139
- return void 0;
140
- }
141
- function normalizeStory(story) {
142
- const id = normalizeStoryId(story?.id);
143
- const title = normalizeOptionalString(story?.title);
144
- const name = normalizeOptionalString(story?.name);
145
- const keys = Array.from(resolveStoryKeys({ id, title, name }));
146
- return {
147
- id,
148
- title,
149
- name,
150
- keys
151
- };
152
- }
153
- function resolveStoryKeys(story) {
154
- const keys = /* @__PURE__ */ new Set();
155
- keys.add("");
156
- const storyId = story.id;
157
- const idPath = storyId ? storyId.replaceAll("--", "/") : "";
158
- if (storyId) {
159
- keys.add(storyId);
160
- keys.add(`/story/${storyId}`);
161
- }
162
- if (idPath) {
163
- keys.add(idPath);
164
- keys.add(`/story/${idPath}`);
165
- }
166
- const titlePath = story.title ? story.title.split("/").map((segment) => slugify(segment)).filter(Boolean).join("/") : "";
167
- const storyNamePath = story.name ? slugify(story.name) : "";
168
- if (titlePath && storyNamePath) {
169
- const composedPath = `${titlePath}/${storyNamePath}`;
170
- keys.add(composedPath);
171
- keys.add(`/story/${composedPath}`);
172
- }
173
- return keys;
174
- }
175
- function isStoryRuleMatch(match, story) {
176
- const patterns = Array.isArray(match) ? match : [match];
177
- return patterns.some((pattern) => {
178
- if (typeof pattern !== "string") {
179
- throw new Error('Story rule "match" must be a string or an array of strings.');
180
- }
181
- const normalizedPattern = pattern.trim();
182
- if (!normalizedPattern) {
183
- throw new Error('Story rule "match" cannot be empty.');
184
- }
185
- return story.keys.some((key) => isWildcardMatch(normalizedPattern, key));
186
- });
187
- }
188
- function isWildcardMatch(pattern, candidate) {
189
- const escapedPattern = escapeRegExp(pattern).replaceAll("*", ".*");
190
- const regex = new RegExp(`^${escapedPattern}$`);
191
- return regex.test(candidate);
192
- }
193
- function normalizeStoryId(id) {
194
- const value = normalizeOptionalString(id) ?? "";
195
- if (!value) {
196
- return "";
197
- }
198
- return value.startsWith("/story/") ? value.slice("/story/".length) : value;
199
- }
200
- function normalizeOptionalString(value) {
201
- if (typeof value !== "string") {
202
- return void 0;
203
- }
204
- const normalizedValue = value.trim();
205
- return normalizedValue || void 0;
206
- }
207
- function normalizeMockSpecifier(value) {
208
- if (typeof value !== "string") {
209
- throw new Error("Story rule mock specifier must be a string.");
210
- }
211
- const normalizedValue = value.trim();
212
- if (!normalizedValue) {
213
- throw new Error("Story rule mock specifier cannot be empty.");
214
- }
215
- return normalizedValue;
216
- }
217
- function normalizeMockReplacement(value, configFilePath) {
218
- if (typeof value !== "string") {
219
- throw new Error("Story rule mock replacement must be a string.");
220
- }
221
- const normalizedValue = value.trim();
222
- if (!normalizedValue) {
223
- throw new Error("Story rule mock replacement cannot be empty.");
224
- }
225
- if (isAbsolute(normalizedValue)) {
226
- return toPosixPath(normalizedValue);
9
+ // src/astroImageService.ts
10
+ function ensureAstroPassthroughImageService() {
11
+ if (!globalThis.astroAsset) {
12
+ globalThis.astroAsset = {};
227
13
  }
228
- if (normalizedValue.startsWith(".")) {
229
- if (!configFilePath) {
230
- throw new Error(
231
- "Story rule mock replacement uses a relative path, but rules config path is unavailable."
232
- );
14
+ globalThis.astroAsset.imageService = {
15
+ propertiesToHash: ["src"],
16
+ validateOptions(options) {
17
+ return options;
18
+ },
19
+ getURL(options) {
20
+ const src = options.src;
21
+ if (src != null && typeof src === "object" && "src" in src && typeof src.src === "string") {
22
+ return src.src;
23
+ }
24
+ return typeof src === "string" ? src : "";
25
+ },
26
+ getHTMLAttributes(options) {
27
+ const {
28
+ src,
29
+ width,
30
+ height,
31
+ format,
32
+ quality,
33
+ densities,
34
+ widths,
35
+ formats,
36
+ layout,
37
+ priority,
38
+ fit,
39
+ position,
40
+ background,
41
+ ...attrs
42
+ } = options;
43
+ const srcObject = src != null && typeof src === "object" ? src : null;
44
+ return {
45
+ ...attrs,
46
+ width: width ?? srcObject?.width,
47
+ height: height ?? srcObject?.height,
48
+ loading: attrs.loading ?? "lazy",
49
+ decoding: attrs.decoding ?? "async"
50
+ };
51
+ },
52
+ getSrcSet() {
53
+ return [];
233
54
  }
234
- return toPosixPath(resolve(dirname(configFilePath), normalizedValue));
235
- }
236
- return normalizedValue;
237
- }
238
- function normalizeMockFactoryResult(value) {
239
- if (!isRecord(value)) {
240
- throw new Error("Story rule mock factory must return an object of module exports.");
241
- }
242
- return value;
243
- }
244
- function slugify(input) {
245
- return input.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
246
- }
247
- function createEmptySelection() {
248
- return {
249
- moduleMocks: /* @__PURE__ */ new Map(),
250
- cleanups: []
251
55
  };
252
56
  }
253
- function toPosixPath(input) {
254
- return input.replaceAll("\\", "/");
255
- }
256
- function escapeRegExp(input) {
257
- return input.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
258
- }
259
- function isRecord(value) {
260
- if (typeof value !== "object" || value === null) {
261
- return false;
262
- }
263
- return !Array.isArray(value);
264
- }
265
57
 
266
58
  // src/lib/sanitization.ts
267
59
  import sanitizeHtml from "sanitize-html";
@@ -400,21 +192,21 @@ function mergeSanitizeHtmlOptions(userOptions) {
400
192
  ...DEFAULT_SANITIZE_HTML_OPTIONS,
401
193
  ...userOptions
402
194
  };
403
- if (isRecord2(DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes) && isRecord2(userOptions?.allowedAttributes)) {
195
+ if (isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes) && isRecord(userOptions?.allowedAttributes)) {
404
196
  merged.allowedAttributes = {
405
197
  ...DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes,
406
198
  ...userOptions.allowedAttributes
407
199
  };
408
200
  }
409
- if (isRecord2(userOptions?.allowedClasses)) {
201
+ if (isRecord(userOptions?.allowedClasses)) {
410
202
  merged.allowedClasses = {
411
- ...isRecord2(DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses) ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses : {},
203
+ ...isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses) ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses : {},
412
204
  ...userOptions.allowedClasses
413
205
  };
414
206
  }
415
- if (isRecord2(userOptions?.allowedStyles)) {
207
+ if (isRecord(userOptions?.allowedStyles)) {
416
208
  merged.allowedStyles = {
417
- ...isRecord2(DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles) ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles : {},
209
+ ...isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles) ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles : {},
418
210
  ...userOptions.allowedStyles
419
211
  };
420
212
  }
@@ -460,7 +252,7 @@ function sanitizeValue(value, currentPath, patterns, options) {
460
252
  return sanitizeValue(item, nextPath, patterns, options);
461
253
  });
462
254
  }
463
- if (isRecord2(value)) {
255
+ if (isRecord(value)) {
464
256
  const sanitized = {};
465
257
  Object.entries(value).forEach(([key, nestedValue]) => {
466
258
  const nextPath = `${currentPath}.${key}`;
@@ -497,7 +289,7 @@ function serializeValue(value, path, state) {
497
289
  );
498
290
  return `[${serializedItems.join(", ")}]`;
499
291
  }
500
- if (isRecord2(value)) {
292
+ if (isRecord(value)) {
501
293
  if (state.seen.has(value)) {
502
294
  throw new Error(`${path} contains a circular reference.`);
503
295
  }
@@ -530,7 +322,7 @@ function assertNoFunctionsRecursive(value, path, state) {
530
322
  });
531
323
  return;
532
324
  }
533
- if (isRecord2(value)) {
325
+ if (isRecord(value)) {
534
326
  if (state.seen.has(value)) {
535
327
  return;
536
328
  }
@@ -566,7 +358,7 @@ function matchSegments(pathSegments, patternSegments) {
566
358
  }
567
359
  return false;
568
360
  }
569
- function isRecord2(value) {
361
+ function isRecord(value) {
570
362
  if (typeof value !== "object" || value === null) {
571
363
  return false;
572
364
  }
@@ -597,12 +389,12 @@ function reviveValue(value) {
597
389
  if (Array.isArray(value)) {
598
390
  return value.map(reviveValue);
599
391
  }
600
- if (isRecord3(value)) {
392
+ if (isRecord2(value)) {
601
393
  return reviveDateStrings(value);
602
394
  }
603
395
  return value;
604
396
  }
605
- function isRecord3(value) {
397
+ function isRecord2(value) {
606
398
  return typeof value === "object" && value !== null && !Array.isArray(value);
607
399
  }
608
400
 
@@ -729,7 +521,7 @@ async function processImageMetadata(args) {
729
521
  if (isImageMetadata(item)) {
730
522
  return item;
731
523
  }
732
- if (isRecord4(item)) {
524
+ if (isRecord3(item)) {
733
525
  return processImageMetadata(item);
734
526
  }
735
527
  return item;
@@ -737,7 +529,7 @@ async function processImageMetadata(args) {
737
529
  );
738
530
  continue;
739
531
  }
740
- if (isRecord4(value)) {
532
+ if (isRecord3(value)) {
741
533
  processed[key] = await processImageMetadata(value);
742
534
  continue;
743
535
  }
@@ -746,66 +538,16 @@ async function processImageMetadata(args) {
746
538
  return processed;
747
539
  }
748
540
  function isImageMetadata(value) {
749
- return isRecord4(value) && typeof value.src === "string" && ("width" in value || "height" in value || "format" in value);
541
+ return isRecord3(value) && typeof value.src === "string" && ("width" in value || "height" in value || "format" in value);
750
542
  }
751
- function isRecord4(value) {
543
+ function isRecord3(value) {
752
544
  return typeof value === "object" && value !== null;
753
545
  }
754
546
 
755
- // src/astroImageService.ts
756
- function ensureAstroPassthroughImageService() {
757
- if (!globalThis.astroAsset) {
758
- globalThis.astroAsset = {};
759
- }
760
- globalThis.astroAsset.imageService = {
761
- propertiesToHash: ["src"],
762
- validateOptions(options) {
763
- return options;
764
- },
765
- getURL(options) {
766
- const src = options.src;
767
- if (src != null && typeof src === "object" && "src" in src && typeof src.src === "string") {
768
- return src.src;
769
- }
770
- return typeof src === "string" ? src : "";
771
- },
772
- getHTMLAttributes(options) {
773
- const {
774
- src,
775
- width,
776
- height,
777
- format,
778
- quality,
779
- densities,
780
- widths,
781
- formats,
782
- layout,
783
- priority,
784
- fit,
785
- position,
786
- background,
787
- ...attrs
788
- } = options;
789
- const srcObject = src != null && typeof src === "object" ? src : null;
790
- return {
791
- ...attrs,
792
- width: width ?? srcObject?.width,
793
- height: height ?? srcObject?.height,
794
- loading: attrs.loading ?? "lazy",
795
- decoding: attrs.decoding ?? "async"
796
- };
797
- },
798
- getSrcSet() {
799
- return [];
800
- }
801
- };
802
- }
803
-
804
547
  export {
805
- defineStoryRules,
548
+ ensureAstroPassthroughImageService,
806
549
  resolveSanitizationOptions,
807
550
  serializeSanitizationOptions,
808
- createAstroRenderHandler,
809
- ensureAstroPassthroughImageService
551
+ createAstroRenderHandler
810
552
  };
811
- //# sourceMappingURL=chunk-B454DGX6.js.map
553
+ //# sourceMappingURL=chunk-N3WTUD2A.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/astroImageService.ts","../src/lib/sanitization.ts","../src/lib/revive-dates.ts","../src/storyRulesRuntime.ts","../src/astroRenderHandler.ts"],"sourcesContent":["export function ensureAstroPassthroughImageService() {\n if (!globalThis.astroAsset) {\n (globalThis as Record<string, unknown>).astroAsset = {};\n }\n\n (globalThis.astroAsset as Record<string, unknown>).imageService = {\n propertiesToHash: ['src'],\n validateOptions(options: Record<string, unknown>) {\n return options;\n },\n getURL(options: { src: unknown }) {\n const src = options.src;\n\n if (\n src != null &&\n typeof src === 'object' &&\n 'src' in src &&\n typeof (src as Record<string, unknown>).src === 'string'\n ) {\n return (src as Record<string, unknown>).src as string;\n }\n\n return typeof src === 'string' ? src : '';\n },\n getHTMLAttributes(options: Record<string, unknown>) {\n const {\n src,\n width,\n height,\n format,\n quality,\n densities,\n widths,\n formats,\n layout,\n priority,\n fit,\n position,\n background,\n ...attrs\n } = options;\n const srcObject =\n src != null && typeof src === 'object' ? (src as Record<string, unknown>) : null;\n\n return {\n ...attrs,\n width: width ?? srcObject?.width,\n height: height ?? srcObject?.height,\n loading: (attrs.loading as string | undefined) ?? 'lazy',\n decoding: (attrs.decoding as string | undefined) ?? 'async'\n };\n },\n getSrcSet() {\n return [];\n }\n };\n}\n","import sanitizeHtml from 'sanitize-html';\nimport type { IOptions } from 'sanitize-html';\n\ntype SanitizationPayload = {\n args: Record<string, unknown>;\n slots: Record<string, unknown>;\n};\n\nexport type SanitizationOptions = {\n enabled?: boolean;\n args?: string[];\n slots?: string[];\n sanitizeHtml?: IOptions;\n};\n\nexport type ResolvedSanitizationOptions = {\n enabled: boolean;\n args: string[];\n slots: string[];\n sanitizeHtml: IOptions;\n};\n\nconst DEFAULT_SANITIZE_HTML_OPTIONS: IOptions = {\n allowedTags: [\n 'a',\n 'abbr',\n 'b',\n 'blockquote',\n 'br',\n 'caption',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'dd',\n 'details',\n 'dfn',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'figure',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'i',\n 'img',\n 'kbd',\n 'li',\n 'mark',\n 'ol',\n 'p',\n 'pre',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'u',\n 'ul',\n 'var',\n 'wbr'\n ],\n allowedAttributes: {\n '*': [\n 'aria-describedby',\n 'aria-hidden',\n 'aria-label',\n 'aria-labelledby',\n 'class',\n 'id',\n 'lang',\n 'role',\n 'title'\n ],\n a: ['href', 'name', 'target', 'rel'],\n img: ['src', 'srcset', 'alt', 'title', 'width', 'height', 'loading', 'decoding'],\n td: ['colspan', 'rowspan'],\n th: ['colspan', 'rowspan', 'scope'],\n time: ['datetime']\n },\n allowedSchemes: ['http', 'https', 'mailto', 'tel', 'data'],\n allowedSchemesByTag: {\n a: ['http', 'https', 'mailto', 'tel'],\n img: ['http', 'https', 'data']\n },\n allowedSchemesAppliedToAttributes: ['href', 'src', 'cite', 'srcset'],\n allowProtocolRelative: false,\n disallowedTagsMode: 'discard',\n enforceHtmlBoundary: true,\n parseStyleAttributes: false\n};\n\nexport function resolveSanitizationOptions(options?: SanitizationOptions): ResolvedSanitizationOptions {\n if (!options) {\n return {\n enabled: true,\n args: [],\n slots: ['**'],\n sanitizeHtml: mergeSanitizeHtmlOptions()\n };\n }\n\n const enabled = options.enabled ?? true;\n const args = normalizePathList(options.args, 'framework.options.sanitization.args');\n const slots =\n options.slots === undefined\n ? ['**']\n : normalizePathList(options.slots, 'framework.options.sanitization.slots');\n\n return {\n enabled,\n args,\n slots,\n sanitizeHtml: mergeSanitizeHtmlOptions(options.sanitizeHtml)\n };\n}\n\nexport function sanitizeRenderPayload(\n payload: SanitizationPayload,\n options: ResolvedSanitizationOptions\n): SanitizationPayload {\n if (!options.enabled) {\n return payload;\n }\n\n const sanitizedArgs =\n options.args.length > 0\n ? sanitizeRecord(payload.args, options.args, options.sanitizeHtml)\n : payload.args;\n\n const sanitizedSlots =\n options.slots.length > 0\n ? sanitizeRecord(payload.slots, options.slots, options.sanitizeHtml)\n : payload.slots;\n\n return {\n args: sanitizedArgs,\n slots: sanitizedSlots\n };\n}\n\nexport function serializeSanitizationOptions(options?: SanitizationOptions): string {\n if (!options) {\n return 'undefined';\n }\n\n assertNoFunctions(options.sanitizeHtml, 'framework.options.sanitization.sanitizeHtml');\n\n const state = {\n seen: new WeakSet<object>()\n };\n\n return serializeValue(options, 'framework.options.sanitization', state);\n}\n\nfunction mergeSanitizeHtmlOptions(userOptions?: IOptions): IOptions {\n const merged: IOptions = {\n ...DEFAULT_SANITIZE_HTML_OPTIONS,\n ...userOptions\n };\n\n if (\n isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes) &&\n isRecord(userOptions?.allowedAttributes)\n ) {\n merged.allowedAttributes = {\n ...DEFAULT_SANITIZE_HTML_OPTIONS.allowedAttributes,\n ...userOptions.allowedAttributes\n };\n }\n\n if (isRecord(userOptions?.allowedClasses)) {\n merged.allowedClasses = {\n ...(isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses)\n ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedClasses\n : {}),\n ...userOptions.allowedClasses\n };\n }\n\n if (isRecord(userOptions?.allowedStyles)) {\n merged.allowedStyles = {\n ...(isRecord(DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles)\n ? DEFAULT_SANITIZE_HTML_OPTIONS.allowedStyles\n : {}),\n ...userOptions.allowedStyles\n };\n }\n\n return merged;\n}\n\nfunction normalizePathList(value: unknown, path: string): string[] {\n if (value === undefined) {\n return [];\n }\n\n if (!Array.isArray(value)) {\n throw new Error(`${path} must be an array of dot-path patterns.`);\n }\n\n const unique = new Set<string>();\n\n value.forEach((entry, index) => {\n if (typeof entry !== 'string') {\n throw new Error(`${path}[${index}] must be a string.`);\n }\n\n const normalized = entry.trim();\n\n if (!normalized) {\n throw new Error(`${path}[${index}] cannot be an empty string.`);\n }\n\n unique.add(normalized);\n });\n\n return Array.from(unique);\n}\n\nfunction sanitizeRecord(\n record: Record<string, unknown>,\n patterns: string[],\n options: IOptions\n): Record<string, unknown> {\n const sanitized: Record<string, unknown> = {};\n\n Object.entries(record).forEach(([key, value]) => {\n sanitized[key] = sanitizeValue(value, key, patterns, options);\n });\n\n return sanitized;\n}\n\nfunction sanitizeValue(\n value: unknown,\n currentPath: string,\n patterns: string[],\n options: IOptions\n): unknown {\n if (typeof value === 'string') {\n if (shouldSanitizePath(currentPath, patterns)) {\n return sanitizeHtml(value, options);\n }\n\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item, index) => {\n const nextPath = `${currentPath}.${index}`;\n\n return sanitizeValue(item, nextPath, patterns, options);\n });\n }\n\n if (isRecord(value)) {\n const sanitized: Record<string, unknown> = {};\n\n Object.entries(value).forEach(([key, nestedValue]) => {\n const nextPath = `${currentPath}.${key}`;\n\n sanitized[key] = sanitizeValue(nestedValue, nextPath, patterns, options);\n });\n\n return sanitized;\n }\n\n return value;\n}\n\nfunction shouldSanitizePath(path: string, patterns: string[]): boolean {\n return patterns.some((pattern) => matchesPathPattern(path, pattern));\n}\n\nfunction matchesPathPattern(path: string, pattern: string): boolean {\n const pathSegments = path.split('.');\n const patternSegments = pattern.split('.');\n\n return matchSegments(pathSegments, patternSegments);\n}\n\nfunction serializeValue(value: unknown, path: string, state: { seen: WeakSet<object> }): string {\n if (value === null) {\n return 'null';\n }\n\n if (value === undefined) {\n return 'undefined';\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return JSON.stringify(value);\n }\n\n if (value instanceof RegExp) {\n return value.toString();\n }\n\n if (Array.isArray(value)) {\n const serializedItems = value.map((item, index) =>\n serializeValue(item, `${path}[${index}]`, state)\n );\n\n return `[${serializedItems.join(', ')}]`;\n }\n\n if (isRecord(value)) {\n if (state.seen.has(value)) {\n throw new Error(`${path} contains a circular reference.`);\n }\n\n state.seen.add(value);\n\n const serializedEntries = Object.entries(value)\n .filter(([, nestedValue]) => nestedValue !== undefined)\n .map(([key, nestedValue]) => {\n const serializedNestedValue = serializeValue(nestedValue, `${path}.${key}`, state);\n\n return `${JSON.stringify(key)}: ${serializedNestedValue}`;\n });\n\n return `{ ${serializedEntries.join(', ')} }`;\n }\n\n throw new Error(\n `${path} contains an unsupported value of type ${typeof value}. ` +\n 'Only plain objects, arrays, primitives, and regular expressions are supported.'\n );\n}\n\nfunction assertNoFunctions(value: unknown, path: string): void {\n const state = {\n seen: new WeakSet<object>()\n };\n\n assertNoFunctionsRecursive(value, path, state);\n}\n\nfunction assertNoFunctionsRecursive(\n value: unknown,\n path: string,\n state: { seen: WeakSet<object> }\n): void {\n if (typeof value === 'function') {\n throw new Error(\n `${path} cannot contain functions. ` +\n 'Function-valued sanitization hooks are not supported in framework options.'\n );\n }\n\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n assertNoFunctionsRecursive(item, `${path}[${index}]`, state);\n });\n\n return;\n }\n\n if (isRecord(value)) {\n if (state.seen.has(value)) {\n return;\n }\n\n state.seen.add(value);\n\n Object.entries(value).forEach(([key, nestedValue]) => {\n assertNoFunctionsRecursive(nestedValue, `${path}.${key}`, state);\n });\n }\n}\n\nfunction matchSegments(pathSegments: string[], patternSegments: string[]): boolean {\n if (patternSegments.length === 0) {\n return pathSegments.length === 0;\n }\n\n const [patternHead, ...patternTail] = patternSegments;\n\n if (patternHead === '**') {\n if (patternTail.length === 0) {\n return true;\n }\n\n for (let index = 0; index <= pathSegments.length; index += 1) {\n const remainingPath = pathSegments.slice(index);\n\n if (matchSegments(remainingPath, patternTail)) {\n return true;\n }\n }\n\n return false;\n }\n\n if (pathSegments.length === 0) {\n return false;\n }\n\n const [pathHead, ...pathTail] = pathSegments;\n\n if (patternHead === '*' || patternHead === pathHead) {\n return matchSegments(pathTail, patternTail);\n }\n\n return false;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n\n if (Array.isArray(value) || value instanceof RegExp) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n\n return prototype === Object.prototype || prototype === null;\n}\n","/**\n * Revives Date objects that were lost during JSON serialization.\n *\n * When story args travel over Vite HMR (dev) or HTTP (server mode), Date\n * values are serialized by JSON.stringify into ISO 8601 strings like\n * \"2025-04-12T00:00:00.000Z\". This function walks the args tree and\n * converts those strings back into Date objects so Astro components\n * receive the types they expect.\n *\n * Only the exact format produced by Date.toJSON() is matched\n * (YYYY-MM-DDTHH:mm:ss.sssZ) to minimize false positives.\n */\n\n// Matches the exact output of Date.toJSON() / JSON.stringify(date).\nconst ISO_DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$/;\n\nexport function reviveDateStrings(args: Record<string, unknown>): Record<string, unknown> {\n const revived: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(args)) {\n revived[key] = reviveValue(value);\n }\n\n return revived;\n}\n\nfunction reviveValue(value: unknown): unknown {\n if (typeof value === 'string' && ISO_DATE_PATTERN.test(value)) {\n const date = new Date(value);\n\n if (!Number.isNaN(date.getTime())) {\n return date;\n }\n\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map(reviveValue);\n }\n\n if (isRecord(value)) {\n return reviveDateStrings(value);\n }\n\n return value;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n","import { withStoryModuleMocks } from './module-mocks.ts';\nimport { selectStoryRules, withStoryRuleCleanups, type StoryRuleSelection } from './rules.ts';\nimport type { RenderStoryInput } from './types.ts';\n\nexport type ResolveRulesConfigModule = () => unknown | Promise<unknown>;\n\ntype RunWithStoryRulesOptions = {\n story?: RenderStoryInput;\n rulesConfigFilePath?: string;\n resolveRulesConfigModule?: ResolveRulesConfigModule;\n invalidateModuleGraph?: () => void;\n};\n\nexport async function runWithStoryRules<T>(\n options: RunWithStoryRulesOptions,\n callback: (selection: StoryRuleSelection) => Promise<T>\n): Promise<T> {\n const rulesConfigModule = options.resolveRulesConfigModule\n ? await options.resolveRulesConfigModule()\n : undefined;\n const selectedRules = await selectStoryRules({\n configModule: rulesConfigModule,\n configFilePath: options.rulesConfigFilePath,\n story: options.story\n });\n\n if (selectedRules.moduleMocks.size > 0) {\n options.invalidateModuleGraph?.();\n }\n\n return withStoryRuleCleanups(selectedRules.cleanups, async () => {\n return withStoryModuleMocks(selectedRules.moduleMocks, async () => callback(selectedRules));\n });\n}\n","import type { experimental_AstroContainer as AstroContainer } from 'astro/container';\nimport type { SanitizationOptions } from './lib/sanitization.ts';\nimport { resolveSanitizationOptions, sanitizeRenderPayload } from './lib/sanitization.ts';\nimport { reviveDateStrings } from './lib/revive-dates.ts';\nimport { runWithStoryRules, type ResolveRulesConfigModule } from './storyRulesRuntime.ts';\nimport type { RenderStoryInput } from './types.ts';\n\ntype AstroCreateResult = {\n createAstro?: (...args: unknown[]) => unknown;\n};\n\ntype AstroComponentFactory = ((\n result: AstroCreateResult,\n props: unknown,\n slots: unknown\n) => unknown) & {\n isAstroComponentFactory?: boolean;\n moduleId?: string;\n propagation?: unknown;\n};\n\nexport type HandlerProps = {\n component: string;\n args?: Record<string, unknown>;\n slots?: Record<string, unknown>;\n story?: RenderStoryInput;\n};\n\ntype CreateAstroRenderHandlerOptions = {\n container: Awaited<ReturnType<typeof AstroContainer.create>>;\n sanitization?: SanitizationOptions;\n rulesConfigFilePath?: string;\n resolveRulesConfigModule?: ResolveRulesConfigModule;\n loadModule: (id: string) => Promise<{ default: unknown }>;\n invalidateModuleGraph?: () => void;\n};\n\nexport function createAstroRenderHandler(options: CreateAstroRenderHandlerOptions) {\n const sanitizationOptions = resolveSanitizationOptions(options.sanitization);\n const componentCache = new Map<string, Promise<AstroComponentFactory>>();\n let renderQueue = Promise.resolve<void>(undefined);\n\n async function loadPatchedComponent(componentId: string, useCache = true) {\n if (!useCache) {\n const { default: component } = await options.loadModule(componentId);\n\n return patchCreateAstroCompat(component);\n }\n\n if (!componentCache.has(componentId)) {\n componentCache.set(\n componentId,\n (async () => {\n const { default: component } = await options.loadModule(componentId);\n\n return patchCreateAstroCompat(component);\n })()\n );\n }\n\n const cachedComponent = componentCache.get(componentId);\n\n if (!cachedComponent) {\n throw new Error(`Failed to load Astro component: ${componentId}`);\n }\n\n try {\n return await cachedComponent;\n } catch (error) {\n componentCache.delete(componentId);\n throw error;\n }\n }\n\n return async function handler(data: HandlerProps) {\n const executeRender = async () => {\n return runWithStoryRules(\n {\n story: data.story,\n rulesConfigFilePath: options.rulesConfigFilePath,\n resolveRulesConfigModule: options.resolveRulesConfigModule,\n invalidateModuleGraph: options.invalidateModuleGraph\n },\n async (selectedRules) => {\n const patchedComponent = await loadPatchedComponent(\n data.component,\n selectedRules.moduleMocks.size === 0\n );\n const processedArgs = await processImageMetadata(data.args ?? {});\n const revivedArgs = reviveDateStrings(processedArgs);\n const sanitizedPayload = sanitizeRenderPayload(\n {\n args: revivedArgs,\n slots: data.slots ?? {}\n },\n sanitizationOptions\n );\n\n return options.container.renderToString(\n patchedComponent as Parameters<typeof options.container.renderToString>[0],\n {\n props: sanitizedPayload.args,\n slots: sanitizedPayload.slots\n }\n );\n }\n );\n };\n\n const resultPromise = renderQueue.then(executeRender, executeRender);\n\n renderQueue = resultPromise.then(\n () => undefined,\n () => undefined\n );\n\n return resultPromise;\n };\n}\n\nexport function patchCreateAstroCompat(component: unknown): AstroComponentFactory {\n if (typeof component !== 'function') {\n throw new Error('Expected Astro component factory to be a function.');\n }\n\n const originalComponent = component as AstroComponentFactory;\n const wrapped = ((result: AstroCreateResult, props: unknown, slots: unknown) => {\n if (result && typeof result.createAstro === 'function') {\n const originalCreateAstro = result.createAstro;\n const runtimeExpectsAstroGlobal = originalCreateAstro.length >= 3;\n\n result.createAstro = (...args: unknown[]) => {\n if (args.length === 3 && !runtimeExpectsAstroGlobal) {\n return originalCreateAstro(args[1], args[2]);\n }\n\n return originalCreateAstro(...args);\n };\n }\n\n return originalComponent(result, props, slots);\n }) as AstroComponentFactory;\n\n wrapped.isAstroComponentFactory = originalComponent.isAstroComponentFactory;\n wrapped.moduleId = originalComponent.moduleId;\n wrapped.propagation = originalComponent.propagation;\n\n return wrapped;\n}\n\nasync function processImageMetadata(\n args: Record<string, unknown>\n): Promise<Record<string, unknown>> {\n const processed: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(args)) {\n if (isImageMetadata(value)) {\n // Keep ImageMetadata as an object so Astro's image pipeline still\n // recognizes it as an imported image and skips local path validation.\n processed[key] = value;\n\n continue;\n }\n\n if (Array.isArray(value)) {\n processed[key] = await Promise.all(\n value.map(async (item) => {\n if (isImageMetadata(item)) {\n return item;\n }\n\n if (isRecord(item)) {\n return processImageMetadata(item);\n }\n\n return item;\n })\n );\n\n continue;\n }\n\n if (isRecord(value)) {\n processed[key] = await processImageMetadata(value);\n\n continue;\n }\n\n processed[key] = value;\n }\n\n return processed;\n}\n\nfunction isImageMetadata(value: unknown): value is Record<string, unknown> {\n return (\n isRecord(value) &&\n typeof value.src === 'string' &&\n ('width' in value || 'height' in value || 'format' in value)\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n"],"mappings":";;;;;;;;;AAAO,SAAS,qCAAqC;AACnD,MAAI,CAAC,WAAW,YAAY;AAC1B,IAAC,WAAuC,aAAa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