@weasel-js/forge 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/{FrameController-Ba3LaWfq.d.ts → FrameController-eZM3hlcE.d.ts} +74 -1
  2. package/dist/{chunk-O5OQZQRZ.js → chunk-2JDYOBWM.js} +5 -5
  3. package/dist/chunk-2JDYOBWM.js.map +1 -0
  4. package/dist/{chunk-KKF7ZX5E.js → chunk-5YHEO26U.js} +133 -23
  5. package/dist/chunk-5YHEO26U.js.map +1 -0
  6. package/dist/{chunk-UZCXH724.js → chunk-6SRQIHJQ.js} +3 -8
  7. package/dist/chunk-6SRQIHJQ.js.map +1 -0
  8. package/dist/{chunk-IOBG7GZQ.js → chunk-FTFR2YPM.js} +2 -2
  9. package/dist/chunk-FTFR2YPM.js.map +1 -0
  10. package/dist/chunk-TLO6UHF2.js +103 -0
  11. package/dist/chunk-TLO6UHF2.js.map +1 -0
  12. package/dist/{config-DdumOfyd.d.ts → config-CSVP6duU.d.ts} +6 -2
  13. package/dist/csf/preview-api.js +2 -2
  14. package/dist/frame/index.d.ts +5 -4
  15. package/dist/frame/index.js +5 -5
  16. package/dist/index.d.ts +97 -5
  17. package/dist/index.js.map +1 -1
  18. package/dist/shell/index.css +209 -12
  19. package/dist/shell/index.css.map +1 -1
  20. package/dist/shell/index.d.ts +62 -4
  21. package/dist/shell/index.js +712 -182
  22. package/dist/shell/index.js.map +1 -1
  23. package/dist/test/index.d.ts +2 -2
  24. package/dist/test/index.js +7 -7
  25. package/dist/test/index.js.map +1 -1
  26. package/dist/test/play.d.ts +25 -0
  27. package/dist/test/play.js +14 -0
  28. package/dist/test/play.js.map +1 -0
  29. package/dist/vite/index.js +72 -20
  30. package/dist/vite/index.js.map +1 -1
  31. package/package.json +14 -5
  32. package/dist/chunk-IOBG7GZQ.js.map +0 -1
  33. package/dist/chunk-KKF7ZX5E.js.map +0 -1
  34. package/dist/chunk-KKVTFMWV.js +0 -59
  35. package/dist/chunk-KKVTFMWV.js.map +0 -1
  36. package/dist/chunk-O5OQZQRZ.js.map +0 -1
  37. package/dist/chunk-UZCXH724.js.map +0 -1
@@ -57,6 +57,39 @@ interface ConfigAnswers {
57
57
  hidden: string[];
58
58
  errors: Record<string, string[]>;
59
59
  }
60
+ /** One element axe faulted on, inside the frame's own document. */
61
+ interface A11yNode {
62
+ /** The CSS selectors, outermost first, that reach the element in the frame. */
63
+ target: readonly string[];
64
+ html: string;
65
+ failureSummary?: string;
66
+ }
67
+ /** One axe rule's outcome on the story, with the elements it names. */
68
+ interface A11yFinding {
69
+ id: string;
70
+ impact: 'minor' | 'moderate' | 'serious' | 'critical' | null;
71
+ help: string;
72
+ helpUrl: string;
73
+ description: string;
74
+ nodes: readonly A11yNode[];
75
+ }
76
+ /** What axe found on one story: the rules it failed, and the ones it could not decide. */
77
+ interface A11yReport {
78
+ violations: readonly A11yFinding[];
79
+ incomplete: readonly A11yFinding[];
80
+ /** Rules that passed, and rules no element on the page could be judged by. */
81
+ passes: number;
82
+ inapplicable: number;
83
+ }
84
+ /** A picture of the story the frame can put in a message: labkit's `CaptureSource` without the canvas,
85
+ * which no structured clone carries. */
86
+ type CapturedPicture = {
87
+ kind: 'svg';
88
+ markup: string;
89
+ } | {
90
+ kind: 'image';
91
+ src: string;
92
+ };
60
93
  type ToFrame = {
61
94
  type: 'init';
62
95
  config: unknown;
@@ -77,12 +110,26 @@ type ToFrame = {
77
110
  value: string | null;
78
111
  } | {
79
112
  type: 'play';
113
+ }
114
+ /** Run axe over the story's own subtree. Answered by `a11y` carrying the same `id`. */
115
+ | {
116
+ type: 'a11y.run';
117
+ id: string;
118
+ }
119
+ /** Serialize the story's own subtree as a picture. Answered by `capture` carrying the same `id`. */
120
+ | {
121
+ type: 'capture.run';
122
+ id: string;
80
123
  };
81
124
  type FromFrame = {
82
125
  type: 'ready';
83
126
  schema: SchemaDescription;
84
127
  layout: Layout;
85
128
  viewport: Viewport | null;
129
+ }
130
+ /** Sent once, when the story's first render after `init` has committed. */
131
+ | {
132
+ type: 'rendered';
86
133
  } | {
87
134
  type: 'answers';
88
135
  answers: ConfigAnswers;
@@ -104,6 +151,26 @@ type FromFrame = {
104
151
  type: 'played';
105
152
  ok: boolean;
106
153
  message?: string;
154
+ } | {
155
+ type: 'a11y';
156
+ id: string;
157
+ ok: true;
158
+ report: A11yReport;
159
+ } | {
160
+ type: 'a11y';
161
+ id: string;
162
+ ok: false;
163
+ message: string;
164
+ } | {
165
+ type: 'capture';
166
+ id: string;
167
+ ok: true;
168
+ picture: CapturedPicture;
169
+ } | {
170
+ type: 'capture';
171
+ id: string;
172
+ ok: false;
173
+ message: string;
107
174
  }
108
175
  /** `seq`, on a render fault only: how many `init`/`config`/`state`/`globals` messages the frame had received. */
109
176
  | {
@@ -167,6 +234,12 @@ interface IndexEntry {
167
234
  exportName: string;
168
235
  /** Absolute path of the story file. */
169
236
  file: string;
237
+ /** The JSDoc written above this story's export, if any. */
238
+ description?: string;
239
+ /** The JSDoc written above the file's meta, if any. */
240
+ componentDescription?: string;
241
+ /** The identifier the meta's `component` names, if it names one. */
242
+ componentName?: string;
170
243
  }
171
244
 
172
245
  interface FrameSetup {
@@ -193,4 +266,4 @@ declare function startFrame({ story, channel, container, setup }: StartFrameOpti
193
266
  /** Reports an import failure — there is no story to start. */
194
267
  declare function reportImportFault(channel: Channel<ToFrame, FromFrame>, error: unknown): void;
195
268
 
196
- export { type Decorator as D, type FrameSetup as F, type IndexEntry as I, type LoadedStory as L, type MetaSpec as M, type PlayContext as P, type StorySpec as S, type StoryContext as a, type StartFrameOptions as b, type FromFrame as c, reportImportFault as r, startFrame as s };
269
+ export { type A11yFinding as A, type CssVarReport as C, type Decorator as D, type FrameSetup as F, type Globals as G, type IndexEntry as I, type LoadedStory as L, type MetaSpec as M, type PlayContext as P, type StorySpec as S, type ToFrame as T, type Viewport as V, type A11yNode as a, type A11yReport as b, type StoryContext as c, type StartFrameOptions as d, type FromFrame as e, type CapturedPicture as f, reportImportFault as r, startFrame as s };
@@ -1,4 +1,4 @@
1
- import { PROTOCOL_VERSION } from './chunk-IOBG7GZQ.js';
1
+ import { PROTOCOL_VERSION } from './chunk-FTFR2YPM.js';
2
2
  import { f, isConfigBranch, resolveConfigSchema, schemaNodeAtPath } from '@weasel-js/labkit/config';
3
3
 
4
4
  var joinPath = (at, key) => at === "" ? key : `${at}.${key}`;
@@ -45,7 +45,7 @@ function rebuildShape(shape, at, answers) {
45
45
  kind: entry.kind,
46
46
  default: entry.default,
47
47
  annotations: entry.annotations,
48
- options: entry.validated ? { ...options, validate: () => answers.errors(path) } : options
48
+ options: entry.validated ? { ...options, validate: (_leaf, config) => answers.errors(path, config) } : options
49
49
  };
50
50
  out[key] = node;
51
51
  }
@@ -73,7 +73,7 @@ function answerSchema(schema, config) {
73
73
  group ??= resolveConfigSchema(schema).group;
74
74
  const leaf = schemaNodeAtPath(group, path);
75
75
  if (!leaf || "children" in leaf) continue;
76
- const found = validate(leaf);
76
+ const found = validate(leaf, record);
77
77
  if (found.length > 0) errors[path] = found;
78
78
  }
79
79
  };
@@ -114,5 +114,5 @@ function openChannel(port, options = {}) {
114
114
  }
115
115
 
116
116
  export { answerSchema, describeSchema, openChannel, schemaFromDescription };
117
- //# sourceMappingURL=chunk-O5OQZQRZ.js.map
118
- //# sourceMappingURL=chunk-O5OQZQRZ.js.map
117
+ //# sourceMappingURL=chunk-2JDYOBWM.js.map
118
+ //# sourceMappingURL=chunk-2JDYOBWM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/protocol/schema.ts","../src/protocol/channel.ts"],"names":[],"mappings":";;;AAqDA,IAAM,QAAA,GAAW,CAAC,EAAA,EAAY,GAAA,KAAyB,EAAA,KAAO,KAAK,GAAA,GAAM,CAAA,EAAG,EAAE,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA;AAErF,SAAS,cAAc,KAAA,EAAoC;AACzD,EAAA,MAAM,MAAsB,E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n f,\n isConfigBranch,\n resolveConfigSchema,\n schemaNodeAtPath,\n type Annotations,\n type BranchAnnotations,\n type ConfigBranch,\n type ConfigEntry,\n type ConfigNode,\n type ConfigSchema,\n type ConfigShape,\n type NodeOptions,\n} from '@weasel-js/labkit/config';\n\nexport interface SectionDescription {\n label: string;\n collapsed?: boolean;\n}\n\nexport type DescribedEntry =\n | {\n branch: true;\n annotations: BranchAnnotations;\n section?: SectionDescription;\n conditional: boolean;\n children: DescribedShape;\n }\n | {\n branch: false;\n kind: string | null;\n default: unknown;\n annotations: Annotations;\n section?: SectionDescription;\n conditional: boolean;\n validated: boolean;\n /** The node draws its own row with `.render`, which stays in the frame. */\n customControl: boolean;\n };\n\nexport type DescribedShape = { [key: string]: DescribedEntry };\n\n/** A story's `f.schema` as structured-clone data. */\nexport interface SchemaDescription {\n nodes: DescribedShape;\n}\n\n/** Answers the workshop has for the rebuilt schema's predicates. */\nexport interface SchemaAnswers {\n hidden(path: string, config: unknown): boolean;\n errors(path: string, config: unknown): string[];\n}\n\nconst joinPath = (at: string, key: string): string => (at === '' ? key : `${at}.${key}`);\n\nfunction describeShape(shape: ConfigShape): DescribedShape {\n const out: DescribedShape = {};\n for (const [key, entry] of Object.entries(shape)) {\n const { section, showIf } = entry.options;\n const common = {\n annotations: { ...entry.annotations },\n ...(section === undefined ? {} : { section: { ...section } }),\n conditional: showIf !== undefined,\n };\n out[key] = isConfigBranch(entry)\n ? { branch: true, ...common, children: describeShape(entry.children) }\n : {\n branch: false,\n kind: entry.kind,\n default: entry.default,\n ...common,\n validated: entry.options.validate !== undefined,\n customControl: entry.options.render !== undefined,\n };\n }\n return out;\n}\n\nexport function describeSchema(schema: ConfigSchema<unknown>): SchemaDescription {\n return { nodes: describeShape(schema.nodes) };\n}\n\nfunction rebuildShape(shape: DescribedShape, at: string, answers: SchemaAnswers): ConfigShape {\n const out: Record<string, ConfigEntry> = {};\n for (const [key, entry] of Object.entries(shape)) {\n const path = joinPath(at, key);\n const options: NodeOptions = {\n ...(entry.section === undefined ? {} : { section: entry.section }),\n ...(entry.conditional ? { showIf: (config) => !answers.hidden(path, config) } : {}),\n };\n if (entry.branch) {\n const branch: ConfigBranch = {\n children: rebuildShape(entry.children, path, answers),\n annotations: entry.annotations,\n options,\n };\n out[key] = branch;\n } else {\n const node: ConfigNode = {\n kind: entry.kind,\n default: entry.default,\n annotations: entry.annotations,\n options: entry.validated ? { ...options, validate: (_leaf, config) => answers.errors(path, config) } : options,\n };\n out[key] = node;\n }\n }\n return out;\n}\n\nexport function schemaFromDescription(\n description: SchemaDescription,\n answers: SchemaAnswers,\n): ConfigSchema<unknown> {\n return f.schema(rebuildShape(description.nodes, '', answers)) as ConfigSchema<unknown>;\n}\n\n/** Evaluate a schema's own predicates for one config — the frame's half of `answers`. */\nexport function answerSchema(\n schema: ConfigSchema<unknown>,\n config: unknown,\n): { hidden: string[]; errors: Record<string, string[]> } {\n const hidden: string[] = [];\n const errors: Record<string, string[]> = {};\n const record = config as Record<string, unknown>;\n let group: ReturnType<typeof resolveConfigSchema>['group'] | undefined;\n\n const walk = (shape: ConfigShape, at: string): void => {\n for (const [key, entry] of Object.entries(shape)) {\n const path = joinPath(at, key);\n if (entry.options.showIf && !entry.options.showIf(record)) hidden.push(path);\n if (isConfigBranch(entry)) {\n walk(entry.children, path);\n continue;\n }\n const { validate } = entry.options;\n if (!validate) continue;\n group ??= resolveConfigSchema(schema).group;\n const leaf = schemaNodeAtPath(group, path);\n if (!leaf || 'children' in leaf) continue;\n const found = validate(leaf, record);\n if (found.length > 0) errors[path] = found;\n }\n };\n walk(schema.nodes, '');\n return { hidden, errors };\n}\n","import { type Envelope, PROTOCOL_VERSION } from './messages';\n\nexport interface PortLike {\n postMessage(message: unknown): void;\n addEventListener(type: 'message', fn: (event: MessageEvent) => void): void;\n removeEventListener(type: 'message', fn: (event: MessageEvent) => void): void;\n start?(): void;\n close(): void;\n}\n\nexport interface Channel<In, Out> {\n send(msg: Out): void;\n on(fn: (msg: In) => void): () => void;\n close(): void;\n}\n\nexport type Mismatch = { reason: 'not-an-envelope' } | { reason: 'version'; version: unknown };\n\nexport interface ChannelOptions {\n onMismatch?: (mismatch: Mismatch) => void;\n}\n\nexport function openChannel<In, Out>(port: PortLike, options: ChannelOptions = {}): Channel<In, Out> {\n const listeners = new Set<(msg: In) => void>();\n const onMessage = (event: MessageEvent) => {\n const data: unknown = event.data;\n if (typeof data !== 'object' || data === null || !('msg' in data)) {\n options.onMismatch?.({ reason: 'not-an-envelope' });\n return;\n }\n const envelope = data as Partial<Envelope<In>>;\n if (envelope.v !== PROTOCOL_VERSION) {\n options.onMismatch?.({ reason: 'version', version: envelope.v });\n return;\n }\n for (const fn of listeners) fn(envelope.msg as In);\n };\n port.addEventListener('message', onMessage);\n port.start?.();\n return {\n send: (msg) => port.postMessage({ v: PROTOCOL_VERSION, msg } satisfies Envelope<Out>),\n on: (fn) => {\n listeners.add(fn);\n return () => listeners.delete(fn);\n },\n close: () => {\n port.removeEventListener('message', onMessage);\n listeners.clear();\n port.close();\n },\n };\n}\n"]}
@@ -1,14 +1,48 @@
1
1
  import { isNative } from './chunk-2GXKNXTJ.js';
2
- import { titleFromFile, storyNameFromExport, storyId } from './chunk-UZCXH724.js';
3
- import { describeSchema, openChannel, answerSchema } from './chunk-O5OQZQRZ.js';
4
- import { isPortSafe, appliedLocal, coverOf, ArgsContext } from './chunk-KKVTFMWV.js';
5
- import { stableStringify, PORT_HANDOFF } from './chunk-IOBG7GZQ.js';
2
+ import { storyNameFromExport, storyId } from './chunk-6SRQIHJQ.js';
3
+ import { describeSchema, openChannel, answerSchema } from './chunk-2JDYOBWM.js';
4
+ import { portSafePart, appliedLocal, withUnsent, coverOf, ArgsContext } from './chunk-TLO6UHF2.js';
5
+ import { stableStringify, PORT_HANDOFF } from './chunk-FTFR2YPM.js';
6
6
  import { flushSync } from 'react-dom';
7
7
  import { createRoot } from 'react-dom/client';
8
8
  import { createContext, createElement, Component, useContext, useState, useEffect } from 'react';
9
9
  import { jsx } from 'react/jsx-runtime';
10
10
  import { f } from '@weasel-js/labkit/config';
11
11
 
12
+ // src/frame/a11y.ts
13
+ var IMPACTS = /* @__PURE__ */ new Set(["minor", "moderate", "serious", "critical"]);
14
+ function finding(from) {
15
+ const impact = from.impact ?? "";
16
+ return {
17
+ id: from.id,
18
+ impact: IMPACTS.has(impact) ? impact : null,
19
+ help: from.help,
20
+ helpUrl: from.helpUrl,
21
+ description: from.description,
22
+ nodes: from.nodes.map((node) => ({
23
+ // An axe target entry is a selector, or an array of them for an element inside a shadow root.
24
+ target: node.target.map((part) => Array.isArray(part) ? part.join(" ") : String(part)),
25
+ html: node.html,
26
+ ...node.failureSummary === void 0 ? {} : { failureSummary: node.failureSummary }
27
+ }))
28
+ };
29
+ }
30
+ var loading = null;
31
+ function loadAxe() {
32
+ loading ??= import('axe-core').then((mod) => mod.default ?? mod);
33
+ return loading;
34
+ }
35
+ async function runAxe(element) {
36
+ const axe = await loadAxe();
37
+ const result = await axe.run(element);
38
+ return {
39
+ violations: result.violations.map(finding),
40
+ incomplete: result.incomplete.map(finding),
41
+ passes: result.passes.length,
42
+ inapplicable: result.inapplicable.length
43
+ };
44
+ }
45
+
12
46
  // src/frame/cssVars.ts
13
47
  var VAR_REF = /var\(\s*(--[\w-]+)/g;
14
48
  function collect(text, names) {
@@ -97,6 +131,37 @@ ${decls.join("\n")}
97
131
  }
98
132
  };
99
133
  }
134
+
135
+ // src/frame/capture.ts
136
+ var SVG_NS = "http://www.w3.org/2000/svg";
137
+ function documentCss(doc) {
138
+ const out = [];
139
+ for (const sheet of Array.from(doc.styleSheets)) {
140
+ try {
141
+ for (const rule of Array.from(sheet.cssRules)) out.push(rule.cssText);
142
+ } catch {
143
+ }
144
+ }
145
+ return out.join("\n");
146
+ }
147
+ function captureElement(element) {
148
+ const doc = element.ownerDocument;
149
+ const rect = element.getBoundingClientRect();
150
+ const w = Math.max(1, Math.ceil(rect.width));
151
+ const h = Math.max(1, Math.ceil(rect.height));
152
+ const root = doc.createElement("div");
153
+ root.setAttribute("data-fg-capture", "");
154
+ const tokens = scanCssVars(doc).filter((v) => v.value).map((v) => `${v.name}: ${v.value};`).join("");
155
+ const style = doc.createElement("style");
156
+ style.textContent = `${documentCss(doc)}
157
+ [data-fg-capture]{${tokens}}`;
158
+ root.append(style, element.cloneNode(true));
159
+ const inner = new XMLSerializer().serializeToString(root);
160
+ return {
161
+ kind: "svg",
162
+ markup: `<svg xmlns="${SVG_NS}" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}"><foreignObject x="0" y="0" width="${w}" height="${h}">${inner}</foreignObject></svg>`
163
+ };
164
+ }
100
165
  function RenderStory({ story, ctx }) {
101
166
  return story.render(ctx);
102
167
  }
@@ -147,6 +212,7 @@ function startFrame({ story, channel, container, setup = {} }) {
147
212
  const root = createRoot(wrapper);
148
213
  const decorators = setup.decorators ?? [];
149
214
  let initialized = false;
215
+ let rendered = false;
150
216
  let config;
151
217
  let state = null;
152
218
  let globals = {};
@@ -171,13 +237,7 @@ function startFrame({ story, channel, container, setup = {} }) {
171
237
  clearTimeout(settleTimer);
172
238
  settleTimer = setTimeout(reportVars, VARS_SETTLE_MS);
173
239
  });
174
- mutations?.observe(document.documentElement, {
175
- subtree: true,
176
- childList: true,
177
- characterData: true,
178
- attributes: true,
179
- attributeFilter: ["style", "class"]
180
- });
240
+ mutations?.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });
181
241
  const setConfig = (path, value) => send({ type: "setConfig", path, value });
182
242
  const setState = (next) => {
183
243
  state = typeof next === "function" ? next(state) : next;
@@ -216,8 +276,21 @@ function startFrame({ story, channel, container, setup = {} }) {
216
276
  send(fault("render", error, seq));
217
277
  return;
218
278
  }
279
+ if (!rendered) {
280
+ rendered = true;
281
+ announceRendered();
282
+ }
219
283
  reportVars();
220
284
  };
285
+ const announceRendered = () => {
286
+ const { fonts } = document;
287
+ if (!fonts) {
288
+ send({ type: "rendered" });
289
+ return;
290
+ }
291
+ const afterPaint = () => requestAnimationFrame(() => send({ type: "rendered" }));
292
+ void fonts.ready.then(afterPaint, afterPaint);
293
+ };
221
294
  const play = async () => {
222
295
  try {
223
296
  await story.play?.({ canvasElement: wrapper, config, globals });
@@ -227,6 +300,20 @@ function startFrame({ story, channel, container, setup = {} }) {
227
300
  send(fault("play", error));
228
301
  }
229
302
  };
303
+ const audit = async (id) => {
304
+ try {
305
+ send({ type: "a11y", id, ok: true, report: await runAxe(wrapper) });
306
+ } catch (error) {
307
+ send({ type: "a11y", id, ok: false, message: error instanceof Error ? error.message : String(error) });
308
+ }
309
+ };
310
+ const picture = (id) => {
311
+ try {
312
+ send({ type: "capture", id, ok: true, picture: captureElement(wrapper) });
313
+ } catch (error) {
314
+ send({ type: "capture", id, ok: false, message: error instanceof Error ? error.message : String(error) });
315
+ }
316
+ };
230
317
  const off = channel.on((msg) => {
231
318
  switch (msg.type) {
232
319
  case "init":
@@ -270,6 +357,12 @@ function startFrame({ story, channel, container, setup = {} }) {
270
357
  case "play":
271
358
  void play();
272
359
  break;
360
+ case "a11y.run":
361
+ void audit(msg.id);
362
+ break;
363
+ case "capture.run":
364
+ picture(msg.id);
365
+ break;
273
366
  }
274
367
  });
275
368
  const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => {
@@ -355,6 +448,17 @@ function controlled(control, argType, has, value) {
355
448
  return has ? inferred(value) : null;
356
449
  }
357
450
  }
451
+ function conditionOf(condition) {
452
+ if (!("arg" in condition)) return null;
453
+ const { arg } = condition;
454
+ return (config) => {
455
+ const value = config[arg];
456
+ if (condition.exists !== void 0) return value !== void 0 === condition.exists;
457
+ if ("eq" in condition) return Object.is(value, condition.eq);
458
+ if ("neq" in condition) return !Object.is(value, condition.neq);
459
+ return Boolean(value) === (condition.truthy ?? true);
460
+ };
461
+ }
358
462
  function matched(key, value, argType, matchers) {
359
463
  if (typeof value !== "string" || argType?.control !== void 0 || stringOptions(argType ?? {})) return null;
360
464
  return matchers.color?.test(key) ? f.color(value) : null;
@@ -363,8 +467,9 @@ function argsToSchema(args, argTypes, matchers = {}) {
363
467
  const nodes = {};
364
468
  for (const key of /* @__PURE__ */ new Set([...Object.keys(args), ...Object.keys(argTypes)])) {
365
469
  const has = key in args;
366
- const value = args[key];
367
- if (has && !isPortSafe(value)) continue;
470
+ const part = has ? portSafePart(args[key]) : null;
471
+ if (has && !part) continue;
472
+ const value = part?.value;
368
473
  const argType = argTypes[key];
369
474
  const control = argType ? controlOf(argType) : false;
370
475
  let node = (has ? matched(key, value, argType, matchers) : null) ?? (control ? controlled(control, argType ?? {}, has, value) : has ? inferred(value) : null);
@@ -372,6 +477,8 @@ function argsToSchema(args, argTypes, matchers = {}) {
372
477
  if (argType && (argType.control === false || argType.table?.disable)) node = node.hidden();
373
478
  if (argType?.description) node = node.describe(argType.description);
374
479
  if (argType?.name) node = node.label(argType.name);
480
+ const shownWhen = argType?.if ? conditionOf(argType.if) : null;
481
+ if (shownWhen) node = node.showIf(shownWhen);
375
482
  nodes[key] = node;
376
483
  }
377
484
  return f.schema(nodes);
@@ -433,9 +540,9 @@ function Scoped({
433
540
  createElement(ArgsContext.Provider, { value: scope }, createElement(Call, { fn: () => fn(context) }))
434
541
  );
435
542
  }
436
- function loadCsfModule(mod, file, root, projectParameters = {}) {
543
+ function loadCsfModule(mod, autoTitle, projectParameters = {}) {
437
544
  const meta = isPlainObject(mod.default) ? mod.default : {};
438
- const title = meta.title ?? titleFromFile(file, root);
545
+ const title = meta.title ?? autoTitle;
439
546
  const stories = [];
440
547
  for (const [exportName, value] of Object.entries(mod)) {
441
548
  if (exportName === "default" || exportName === "__namedExportsOrder" || exportName === "__esModule") continue;
@@ -457,8 +564,11 @@ function loadCsfModule(mod, file, root, projectParameters = {}) {
457
564
  const storyGlobals = { ...meta.globals, ...spec.globals };
458
565
  const component = meta.component;
459
566
  const renderFn = spec.render ?? meta.render ?? (component ? (a) => createElement(component, a) : void 0);
567
+ const withArgs = (config2) => Object.fromEntries(
568
+ Object.entries(withoutUndefined(config2)).map(([key, value2]) => [key, key in args ? withUnsent(value2, args[key]) : value2])
569
+ );
460
570
  const csfContext = (config2, globals, local = {}) => ({
461
- args: withoutUndefined({ ...args, ...withoutUndefined(config2), ...appliedLocal(local, config2) }),
571
+ args: withoutUndefined({ ...args, ...withArgs(config2), ...appliedLocal(local, config2) }),
462
572
  globals,
463
573
  parameters,
464
574
  title,
@@ -508,9 +618,9 @@ function loadCsfModule(mod, file, root, projectParameters = {}) {
508
618
  }
509
619
  return stories;
510
620
  }
511
- function loadNativeModule(mod, file, root) {
621
+ function loadNativeModule(mod, autoTitle) {
512
622
  const metaSpec = isNative(mod.default, "meta") ? mod.default : {};
513
- const title = metaSpec.title ?? titleFromFile(file, root);
623
+ const title = metaSpec.title ?? autoTitle;
514
624
  const stories = [];
515
625
  for (const [exportName, value] of Object.entries(mod)) {
516
626
  if (exportName === "default" || !isNative(value, "story")) continue;
@@ -533,8 +643,8 @@ function loadNativeModule(mod, file, root) {
533
643
  }
534
644
 
535
645
  // src/frame/mountFrame.tsx
536
- function loadStories(mod, file, root, parameters) {
537
- return isNative(mod.default, "meta") ? loadNativeModule(mod, file, root) : loadCsfModule(mod, file, root, parameters);
646
+ function loadStories(mod, autoTitle, parameters) {
647
+ return isNative(mod.default, "meta") ? loadNativeModule(mod, autoTitle) : loadCsfModule(mod, autoTitle, parameters);
538
648
  }
539
649
  function waitForPort() {
540
650
  return new Promise((resolve) => {
@@ -558,7 +668,7 @@ async function mountFrame(options) {
558
668
  const importer = options.importers[entry.file];
559
669
  if (!importer) throw new Error(`No importer for ${entry.file}`);
560
670
  const mod = await importer();
561
- const stories = (options.load ?? loadStories)(mod, entry.file, options.root, options.setup?.parameters);
671
+ const stories = (options.load ?? loadStories)(mod, entry.title, options.setup?.parameters);
562
672
  const story = stories.find((s) => s.exportName === entry.exportName);
563
673
  if (!story) throw new Error(`${entry.file} has no story export "${entry.exportName}"`);
564
674
  startFrame({ story, channel, container: document.getElementById("root") ?? document.body, setup: options.setup });
@@ -568,5 +678,5 @@ async function mountFrame(options) {
568
678
  }
569
679
 
570
680
  export { loadStories, mountFrame, reportImportFault, startFrame };
571
- //# sourceMappingURL=chunk-KKF7ZX5E.js.map
572
- //# sourceMappingURL=chunk-KKF7ZX5E.js.map
681
+ //# sourceMappingURL=chunk-5YHEO26U.js.map
682
+ //# sourceMappingURL=chunk-5YHEO26U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/frame/a11y.ts","../src/frame/cssVars.ts","../src/frame/capture.ts","../src/frame/StoryHost.tsx","../src/frame/FrameController.tsx","../src/csf/isPlainObject.ts","../src/csf/argsToSchema.ts","../src/csf/loadCsfModule.tsx","../src/story/native.ts","../src/frame/mountFrame.tsx"],"names":["jsx","config","value","f"],"mappings":";;;;;;;;;;;;AAqBA,IAAM,OAAA,uBAAc,GAAA,CAAI,CAAC,SAAS,UAAA,EAAY,SAAA,EAAW,UAAU,CAAC,CAAA;AAEpE,SAAS,QAAQ,IAAA,EAA+B;AAC9C,EAAA,MAAM,MAAA,GAAS,KAAK,MAAA,IAAU,EAAA;AAC9B,EAAA,OAAO;AAAA,IACL,IAAI,IAAA,CAAK,EAAA;AAAA,IACT,MAAA,EAAQ,OAAA,CAAQ,GAAA,CAAI,MAAM,IAAK,MAAA,GAAmC,IAAA;AAAA,IAClE,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,SAAS,IAAA,CAAK,OAAA;AAAA,IACd,aAAa,IAAA,CAAK,WAAA;AAAA,IAClB,KAAA,EAAO,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,MAAU;AAAA;AAAA,MAE/B,QAAQ,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,CAAC,SAAU,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,GAAI,KAAK,IAAA,CAAK,GAAG,CAAA,GAAI,MAAA,CAAO,IAAI,CAAE,CAAA;AAAA,MACvF,MAAM,IAAA,CAAK,IAAA;AAAA,MACX,GAAI,KAAK,c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CAAM,CAAA,kBAAA,EAAqB,EAAE,CAAA,CAAA,CAAG,CAAA;AACtD,IAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,SAAA,CAAU,KAAA,CAAM,IAAI,CAAA;AAC7C,IAAA,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,CAAA,gBAAA,EAAmB,KAAA,CAAM,IAAI,CAAA,CAAE,CAAA;AAC9D,IAAA,MAAM,GAAA,GAAM,MAAM,QAAA,EAAS;AAC3B,IAAA,MAAM,OAAA,GAAA,CAAW,QAAQ,IAAA,IAAQ,WAAA,EAAa,KAAK,KAAA,CAAM,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAO,UAAU,CAAA;AACzF,IAAA,MAAM,KAAA,GAAQ,QAAQ,IAAA,CAAK,CAAC,MAAM,CAAA,CAAE,UAAA,KAAe,MAAM,UAAU,CAAA;AACnE,IAAA,IAAI,CAAC,KAAA,EAAO,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,KAAA,CAAM,IAAI,CAAA,sBAAA,EAAyB,KAAA,CAAM,UAAU,CAAA,CAAA,CAAG,CAAA;AACrF,IAAA,UAAA,CAAW,EAAE,KAAA,EAAO,OAAA,EAAS,SAAA,EAAW,QAAA,CAAS,cAAA,CAAe,MAAM,CAAA,IAAK,QAAA,CAAS,IAAA,EAAM,KAAA,EAAO,OAAA,CAAQ,OAAO,CAAA;AAAA,EAClH,SAAS,KAAA,EAAO;AACd,IAAA,iBAAA,CAAkB,SAAS,KAAK,CAAA;AAAA,EAClC;AACF","file":"chunk-5YHEO26U.js","sourcesContent":["import type { A11yFinding, A11yReport } from '../protocol/messages';\n\n/** The shape of `axe.run`'s answer this module reads. */\ninterface AxeResult {\n violations: readonly AxeFinding[];\n incomplete: readonly AxeFinding[];\n passes: readonly unknown[];\n inapplicable: readonly unknown[];\n}\ninterface AxeFinding {\n id: string;\n impact?: string | null;\n help: string;\n helpUrl: string;\n description: string;\n nodes: readonly { target: readonly unknown[]; html: string; failureSummary?: string }[];\n}\ninterface AxeModule {\n run(context: Element, options?: unknown): Promise<AxeResult>;\n}\n\nconst IMPACTS = new Set(['minor', 'moderate', 'serious', 'critical']);\n\nfunction finding(from: AxeFinding): A11yFinding {\n const impact = from.impact ?? '';\n return {\n id: from.id,\n impact: IMPACTS.has(impact) ? (impact as A11yFinding['impact']) : null,\n help: from.help,\n helpUrl: from.helpUrl,\n description: from.description,\n nodes: from.nodes.map((node) => ({\n // An axe target entry is a selector, or an array of them for an element inside a shadow root.\n target: node.target.map((part) => (Array.isArray(part) ? part.join(' ') : String(part))),\n html: node.html,\n ...(node.failureSummary === undefined ? {} : { failureSummary: node.failureSummary }),\n })),\n };\n}\n\nlet loading: Promise<AxeModule> | null = null;\n\n/** axe is ~500 KB, so a frame that is never audited never pays for it. */\nfunction loadAxe(): Promise<AxeModule> {\n loading ??= import('axe-core').then((mod) => (mod as unknown as { default?: AxeModule }).default ?? (mod as unknown as AxeModule));\n return loading;\n}\n\n/** Runs axe over `element` and reduces its answer to what crosses the frame's channel. */\nexport async function runAxe(element: Element): Promise<A11yReport> {\n const axe = await loadAxe();\n const result = await axe.run(element);\n return {\n violations: result.violations.map(finding),\n incomplete: result.incomplete.map(finding),\n passes: result.passes.length,\n inapplicable: result.inapplicable.length,\n };\n}\n","import type { CssVarReport } from '../protocol/messages';\n\nconst VAR_REF = /var\\(\\s*(--[\\w-]+)/g;\n\nfunction collect(text: string, names: Set<string>): void {\n if (!text.includes('var(')) return;\n for (const [, name] of text.matchAll(VAR_REF)) names.add(name!);\n}\n\n/** A grouping rule's text holds its children's; an `@import` holds only its URL, so its sheet is read too. */\nfunction walkRules(sheet: CSSStyleSheet, names: Set<string>): void {\n let rules: CSSRuleList;\n try {\n rules = sheet.cssRules;\n } catch {\n // A cross-origin sheet refuses to be read.\n return;\n }\n for (const rule of Array.from(rules)) {\n const imported = (rule as CSSRule & { styleSheet?: CSSStyleSheet | null }).styleSheet;\n if (imported) walkRules(imported, names);\n else collect(rule.cssText, names);\n }\n}\n\n/**\n * Every custom property the document references with `var()`, from inline styles and stylesheet rules — computed\n * styles have already substituted the reference away. Values resolve on `:root`, or else on the first element that\n * declares one.\n */\nexport function scanCssVars(doc: Document, overridden: (name: string) => boolean = () => false): CssVarReport[] {\n const names = new Set<string>();\n for (const el of Array.from(doc.querySelectorAll('[style]'))) collect(el.getAttribute('style') ?? '', names);\n for (const sheet of Array.from(doc.styleSheets)) walkRules(sheet, names);\n\n const values = resolveValues(doc, names);\n return [...names]\n .sort()\n .map((name) => ({ name, value: values.get(name) ?? '', overridden: overridden(name) }));\n}\n\nfunction resolveValues(doc: Document, names: Iterable<string>): Map<string, string> {\n const view = doc.defaultView;\n const values = new Map<string, string>();\n if (!view) return values;\n const root = view.getComputedStyle(doc.documentElement);\n const missing: string[] = [];\n for (const name of names) {\n const value = root.getPropertyValue(name).trim();\n if (value) values.set(name, value);\n else missing.push(name);\n }\n for (const el of missing.length > 0 ? Array.from((doc.body ?? doc.documentElement).querySelectorAll('*')) : []) {\n const style = view.getComputedStyle(el);\n for (let i = missing.length - 1; i >= 0; i--) {\n const value = style.getPropertyValue(missing[i]!).trim();\n if (!value) continue;\n values.set(missing[i]!, value);\n missing.splice(i, 1);\n }\n if (missing.length === 0) break;\n }\n return values;\n}\n\n/** One custom property's value, resolved the way `scanCssVars` resolves each. */\nexport function resolveCssVar(doc: Document, name: string): string {\n return resolveValues(doc, [name]).get(name) ?? '';\n}\n\nexport interface Overrides {\n set(name: string, value: string | null): void;\n has(name: string): boolean;\n /** Whether `node` is the override style element or inside it. */\n owns(node: Node): boolean;\n dispose(): void;\n}\n\n/**\n * Custom property overrides as one rule on `scope`, kept last in `<head>`. `:not(#fg-overrides)` adds an ID's weight\n * without `!important`, so the rule outranks a theme's attribute selectors; a stylesheet that lands after it sends\n * the element back to the end.\n */\nexport function createOverrides(doc: Document, scope = ':root'): Overrides {\n const values = new Map<string, string>();\n const style = doc.createElement('style');\n style.setAttribute('data-fg-overrides', '');\n\n // Another instance's style counts as last place too, or two instances would take turns moving forever.\n const keepLast = () => {\n if (style.parentNode === doc.head) {\n let next = style.nextElementSibling;\n while (next?.hasAttribute('data-fg-overrides')) next = next.nextElementSibling;\n if (next === null) return;\n }\n doc.head.append(style);\n };\n const write = () => {\n const decls = [...values].map(([name, value]) => ` ${name}: ${value};`);\n style.textContent = decls.length > 0 ? `:is(${scope}):not(#fg-overrides) {\\n${decls.join('\\n')}\\n}\\n` : '';\n };\n\n keepLast();\n const observer = typeof MutationObserver === 'undefined' ? null : new MutationObserver(keepLast);\n observer?.observe(doc.head, { childList: true });\n\n return {\n set(name, value) {\n if (value === null) values.delete(name);\n else values.set(name, value);\n write();\n },\n has: (name) => values.has(name),\n owns: (node) => style.contains(node),\n dispose() {\n observer?.disconnect();\n style.remove();\n },\n };\n}\n","import type { CapturedPicture } from '../protocol/messages';\nimport { scanCssVars } from './cssVars';\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\n/** Every rule the document can read. A cross-origin sheet refuses, and is skipped. */\nfunction documentCss(doc: Document): string {\n const out: string[] = [];\n for (const sheet of Array.from(doc.styleSheets)) {\n try {\n for (const rule of Array.from(sheet.cssRules)) out.push(rule.cssText);\n } catch {\n // A cross-origin sheet refuses to be read.\n }\n }\n return out.join('\\n');\n}\n\n/**\n * The story's own subtree as an SVG picture: the DOM inside a `<foreignObject>`, with the document's\n * stylesheets beside it.\n *\n * The capture root is a `<div>`, so nothing a rule hangs off `:root`, `html` or `body` reaches the story —\n * hence the custom properties restated on the root, which is what theme tokens travel by.\n */\nexport function captureElement(element: HTMLElement): Extract<CapturedPicture, { kind: 'svg' }> {\n const doc = element.ownerDocument;\n const rect = element.getBoundingClientRect();\n const w = Math.max(1, Math.ceil(rect.width));\n const h = Math.max(1, Math.ceil(rect.height));\n\n const root = doc.createElement('div');\n root.setAttribute('data-fg-capture', '');\n const tokens = scanCssVars(doc)\n .filter((v) => v.value)\n .map((v) => `${v.name}: ${v.value};`)\n .join('');\n const style = doc.createElement('style');\n style.textContent = `${documentCss(doc)}\\n[data-fg-capture]{${tokens}}`;\n root.append(style, element.cloneNode(true));\n\n // XML, not HTML: an `<svg>` base is re-parsed as XML, where `<br>` and friends have to be closed.\n const inner = new XMLSerializer().serializeToString(root);\n return {\n kind: 'svg',\n markup: `<svg xmlns=\"${SVG_NS}\" width=\"${w}\" height=\"${h}\" viewBox=\"0 0 ${w} ${h}\"><foreignObject x=\"0\" y=\"0\" width=\"${w}\" height=\"${h}\">${inner}</foreignObject></svg>`,\n };\n}\n","import { Component, type ReactNode } from 'react';\nimport type { Decorator, LoadedStory, StoryContext } from '../story/types';\n\nexport interface StoryHostProps {\n story: LoadedStory;\n ctx: StoryContext;\n /** Outermost decorators, from the frame setup. */\n decorators: readonly Decorator[];\n /** A change clears a caught error, so new input retries the render. */\n resetKey: number;\n onError: (error: unknown) => void;\n}\n\nfunction RenderStory({ story, ctx }: { story: LoadedStory; ctx: StoryContext }): ReactNode {\n return story.render(ctx);\n}\n\nfunction Decorated({ story, ctx, decorators }: Omit<StoryHostProps, 'resetKey' | 'onError'>): ReactNode {\n let inner: () => ReactNode = () => <RenderStory story={story} ctx={ctx} />;\n for (const decorate of [...story.decorators, ...decorators]) {\n const wrapped = inner;\n inner = () => decorate(wrapped, ctx);\n }\n return inner();\n}\n\ninterface BoundaryState {\n error: unknown;\n failed: boolean;\n resetKey: number;\n}\n\nexport class StoryHost extends Component<StoryHostProps, BoundaryState> {\n override state: BoundaryState = { error: null, failed: false, resetKey: this.props.resetKey };\n\n static getDerivedStateFromProps(props: StoryHostProps, state: BoundaryState): Partial<BoundaryState> | null {\n return props.resetKey === state.resetKey ? null : { error: null, failed: false, resetKey: props.resetKey };\n }\n\n static getDerivedStateFromError(error: unknown): Partial<BoundaryState> {\n return { error, failed: true };\n }\n\n override componentDidCatch(error: unknown): void {\n this.props.onError(error);\n }\n\n override render(): ReactNode {\n if (this.state.failed) {\n const { error } = this.state;\n return <pre className=\"fg-frame__fault\">{error instanceof Error ? error.message : String(error)}</pre>;\n }\n const { story, ctx, decorators } = this.props;\n return <Decorated story={story} ctx={ctx} decorators={decorators} />;\n }\n}\n","import { flushSync } from 'react-dom';\nimport { createRoot } from 'react-dom/client';\nimport type { Channel } from '../protocol/channel';\nimport {\n type CssVarReport,\n type FaultPhase,\n type FromFrame,\n type Globals,\n stableStringify,\n type ToFrame,\n} from '../protocol/messages';\nimport { answerSchema, describeSchema } from '../protocol/schema';\nimport type { Decorator, LoadedStory, StoryContext } from '../story/types';\nimport { runAxe } from './a11y';\nimport { captureElement } from './capture';\nimport { createOverrides, resolveCssVar, scanCssVars } from './cssVars';\nimport { StoryHost } from './StoryHost';\n\nexport interface FrameSetup {\n /** Wraps every story, outermost; receives the globals. From the frame config (`frameConfig`). */\n decorators?: Decorator[];\n /** Applies globals to the frame document — theme mode, fonts. */\n applyGlobals?: (globals: Globals, root: HTMLElement) => void;\n /**\n * The elements a CSS variable override is declared on; `:root` by default. An override has to be declared on\n * whichever element declares the token itself — a theme wrapper, say — or that element's own value wins.\n */\n cssVarsScope?: string;\n /** Project-wide CSF parameters, Storybook's preview `parameters`: under each meta's and story's. */\n parameters?: Record<string, unknown>;\n}\n\nexport interface StartFrameOptions {\n story: LoadedStory;\n channel: Channel<ToFrame, FromFrame>;\n container: HTMLElement;\n setup?: FrameSetup;\n}\n\nconst VARS_SETTLE_MS = 100;\n\nfunction fault(phase: FaultPhase, error: unknown, seq?: number): FromFrame {\n return {\n type: 'fault',\n phase,\n message: error instanceof Error ? error.message : String(error),\n ...(error instanceof Error && error.stack ? { stack: error.stack } : {}),\n ...(seq === undefined ? {} : { seq }),\n };\n}\n\n/** Sends `ready`, then renders the story on `init` and keeps it in step. Returns a stop function. */\nexport function startFrame({ story, channel, container, setup = {} }: StartFrameOptions): () => void {\n const { send } = channel;\n send({ type: 'ready', schema: describeSchema(story.config), layout: story.layout, viewport: story.viewport });\n\n const wrapper = document.createElement('div');\n wrapper.className = `fg-frame fg-frame--${story.layout}`;\n container.append(wrapper);\n const root = createRoot(wrapper);\n const decorators = setup.decorators ?? [];\n\n let initialized = false;\n let rendered = false;\n let config: unknown;\n let state: unknown = null;\n let globals: Globals = {};\n let answeredKey: string | null = null;\n let resetKey = 0;\n let seq = 0;\n\n const overrides = createOverrides(document, setup.cssVarsScope);\n let lastVars: CssVarReport[] | null = null;\n let reported: string | null = null;\n const publishVars = (vars: CssVarReport[]) => {\n lastVars = vars;\n const key = JSON.stringify(vars);\n if (key === reported) return;\n reported = key;\n send({ type: 'vars', vars });\n };\n const reportVars = () => publishVars(scanCssVars(document, overrides.has));\n const ownMutation = (record: MutationRecord) =>\n overrides.owns(record.target) ||\n (record.type === 'childList' &&\n [...record.addedNodes, ...record.removedNodes].length > 0 &&\n [...record.addedNodes, ...record.removedNodes].every(overrides.owns));\n let settleTimer: ReturnType<typeof setTimeout> | undefined;\n const mutations =\n typeof MutationObserver === 'undefined'\n ? null\n : new MutationObserver((records) => {\n if (records.every(ownMutation)) return;\n clearTimeout(settleTimer);\n settleTimer = setTimeout(reportVars, VARS_SETTLE_MS);\n });\n // Every attribute, not just style and class: a stylesheet can select on any of them, `[data-wzl-mode]` included.\n mutations?.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });\n\n const setConfig = (path: string, value: unknown) => send({ type: 'setConfig', path, value });\n const setState = (next: unknown) => {\n state = typeof next === 'function' ? (next as (prev: unknown) => unknown)(state) : next;\n send({ type: 'setState', state });\n render();\n };\n\n const render = () => {\n const ctx: StoryContext = { config, setConfig, state, setState, globals, title: story.title, name: story.name };\n const at = seq;\n root.render(\n <StoryHost\n story={story}\n ctx={ctx}\n decorators={decorators}\n resetKey={resetKey}\n onError={(error) => send(fault('render', error, at))}\n />,\n );\n const key = stableStringify(config);\n if (key !== answeredKey) {\n answeredKey = key;\n send({ type: 'answers', answers: { configKey: key, ...answerSchema(story.config, config) } });\n }\n };\n\n // Input from the trial commits synchronously, so a `play` that follows sees the rendered story. A throw while\n // applying it faults like a render would; otherwise the trial would wait on a frame that never answers.\n const input = (apply: () => void) => {\n seq += 1;\n try {\n apply();\n if (!initialized) return;\n resetKey += 1;\n flushSync(render);\n } catch (error) {\n send(fault('render', error, seq));\n return;\n }\n if (!rendered) {\n rendered = true;\n announceRendered();\n }\n reportVars();\n };\n\n /**\n * The shell unhides the frame on `rendered` and fades it in, so whatever\n * reflows after that message reads as a glide rather than a jump. A webfont\n * swapping in is the reflow that does it: a `layout: 'padded'` story is\n * top-anchored, so the line-height change walks the whole story upward.\n * Waiting for the fonts and then one painted frame means the story the\n * shell reveals is the settled one.\n *\n * `document.fonts` is absent in jsdom, where there is no paint to wait for\n * and no font to swap — the message stays synchronous there, which is also\n * what `FrameController.test.tsx` observes. The deferral itself is only\n * exercised in a browser.\n */\n const announceRendered = () => {\n const { fonts } = document;\n if (!fonts) {\n send({ type: 'rendered' });\n return;\n }\n const afterPaint = () => requestAnimationFrame(() => send({ type: 'rendered' }));\n void fonts.ready.then(afterPaint, afterPaint);\n };\n\n const play = async () => {\n try {\n await story.play?.({ canvasElement: wrapper, config, globals });\n send({ type: 'played', ok: true });\n } catch (error) {\n send({ type: 'played', ok: false, message: error instanceof Error ? error.message : String(error) });\n send(fault('play', error));\n }\n };\n\n const audit = async (id: string) => {\n try {\n send({ type: 'a11y', id, ok: true, report: await runAxe(wrapper) });\n } catch (error) {\n send({ type: 'a11y', id, ok: false, message: error instanceof Error ? error.message : String(error) });\n }\n };\n\n const picture = (id: string) => {\n try {\n send({ type: 'capture', id, ok: true, picture: captureElement(wrapper) });\n } catch (error) {\n send({ type: 'capture', id, ok: false, message: error instanceof Error ? error.message : String(error) });\n }\n };\n\n const off = channel.on((msg) => {\n switch (msg.type) {\n case 'init':\n input(() => {\n initialized = true;\n config = msg.config;\n globals = msg.globals;\n state = msg.state;\n if (state === null && story.initialState) {\n state = story.initialState(config);\n send({ type: 'setState', state });\n }\n setup.applyGlobals?.(globals, document.documentElement);\n });\n break;\n case 'config':\n input(() => {\n config = msg.config;\n });\n break;\n case 'state':\n input(() => {\n state = msg.state;\n });\n break;\n case 'globals':\n input(() => {\n globals = msg.globals;\n setup.applyGlobals?.(globals, document.documentElement);\n });\n break;\n case 'vars.set': {\n overrides.set(msg.name, msg.value);\n const at = lastVars?.findIndex((v) => v.name === msg.name) ?? -1;\n if (!lastVars || at < 0) break;\n const vars = lastVars.slice();\n vars[at] = { name: msg.name, value: resolveCssVar(document, msg.name), overridden: overrides.has(msg.name) };\n publishVars(vars);\n break;\n }\n case 'play':\n void play();\n break;\n case 'a11y.run':\n void audit(msg.id);\n break;\n case 'capture.run':\n picture(msg.id);\n break;\n }\n });\n\n const observer =\n typeof ResizeObserver === 'undefined'\n ? null\n : new ResizeObserver(() => {\n const { width, height } = wrapper.getBoundingClientRect();\n send({ type: 'size', width: Math.ceil(width), height: Math.ceil(height) });\n });\n observer?.observe(wrapper);\n\n return () => {\n off();\n observer?.disconnect();\n mutations?.disconnect();\n clearTimeout(settleTimer);\n overrides.dispose();\n root.unmount();\n wrapper.remove();\n };\n}\n\n/** Reports an import failure — there is no story to start. */\nexport function reportImportFault(channel: Channel<ToFrame, FromFrame>, error: unknown): void {\n channel.send(fault('import', error));\n}\n","export const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype;\n","import { type ConfigNode, type ConfigSchema, type ConfigShape, f } from '@weasel-js/labkit/config';\nimport { isPlainObject } from './isPlainObject';\nimport { portSafePart } from './portSafe';\n\n/** Storybook's conditional control: shown only while an arg, or a global, meets the test. */\nexport type ArgCondition = ({ arg: string } | { global: string }) & {\n truthy?: boolean;\n exists?: boolean;\n eq?: unknown;\n neq?: unknown;\n};\n\n/** A CSF `argTypes` entry, as far as forge reads it. */\nexport interface ArgType {\n name?: string;\n description?: string;\n control?: string | false | { type?: string; min?: number; max?: number; step?: number };\n options?: readonly unknown[];\n table?: { disable?: boolean };\n if?: ArgCondition;\n}\n\ninterface Leaf extends ConfigNode<unknown> {\n hidden(): Leaf;\n describe(description: string): Leaf;\n label(name: string): Leaf;\n showIf(predicate: (config: Record<string, unknown>) => boolean): Leaf;\n}\n\ninterface Control {\n type: string | undefined;\n min?: number;\n max?: number;\n step?: number;\n}\n\nfunction controlOf(argType: ArgType): Control | false {\n const { control } = argType;\n if (control === false) return false;\n if (typeof control === 'string') return { type: control };\n return { type: control?.type, min: control?.min, max: control?.max, step: control?.step };\n}\n\nfunction stringOptions(argType: ArgType): string[] | null {\n const opts = argType.options;\n return opts && opts.length > 0 && opts.every((o) => typeof o === 'string') ? (opts as string[]) : null;\n}\n\nfunction inferred(value: unknown): Leaf | null {\n switch (typeof value) {\n case 'number':\n return f.number(value);\n case 'boolean':\n return f.boolean(value);\n case 'string':\n return f.string(value);\n default:\n return Array.isArray(value) || isPlainObject(value) ? f.custom('json', value) : null;\n }\n}\n\nfunction bounded(node: ReturnType<typeof f.number>, control: Control) {\n let out = node;\n if (control.min !== undefined && control.max !== undefined) out = out.range(control.min, control.max);\n if (control.step !== undefined) out = out.step(control.step);\n return out;\n}\n\nfunction controlled(control: Control, argType: ArgType, has: boolean, value: unknown): Leaf | null {\n const options = stringOptions(argType);\n // Storybook passes an argTypes-only key as undefined, so the component's own default applies.\n const def = <T>() => (has ? value : undefined) as T;\n switch (control.type) {\n case 'number': {\n const node = bounded(f.number(def()), control);\n return control.min !== undefined && control.max !== undefined ? node.input() : node;\n }\n case 'range':\n case 'slider':\n return has ? bounded(f.number(def()), control).slider() : null;\n case 'boolean':\n return f.boolean(def());\n case 'switch':\n return f.boolean(def()).toggle();\n case 'text':\n case 'textarea':\n return f.string(def());\n case 'select':\n case 'radio':\n case 'inline-radio':\n case undefined: {\n if (!options) return control.type === undefined && has ? inferred(value) : null;\n const node = f.enum(def<string>(), options);\n return control.type === 'radio' || control.type === 'inline-radio' ? node.radio() : node;\n }\n case 'object':\n return has ? f.custom('json', value) : null;\n default:\n return has ? inferred(value) : null;\n }\n}\n\n/** The config predicate for an `if`; null for a condition on a global, which a story's config does not hold. */\nfunction conditionOf(condition: ArgCondition): ((config: Record<string, unknown>) => boolean) | null {\n if (!('arg' in condition)) return null;\n const { arg } = condition;\n return (config) => {\n const value = config[arg];\n if (condition.exists !== undefined) return (value !== undefined) === condition.exists;\n if ('eq' in condition) return Object.is(value, condition.eq);\n if ('neq' in condition) return !Object.is(value, condition.neq);\n return Boolean(value) === (condition.truthy ?? true);\n };\n}\n\n/** `parameters.controls.matchers`: arg names that pick a control when the arg's argType names none. */\nexport interface ControlMatchers {\n color?: RegExp;\n /** labkit has no date leaf, so a date match keeps the leaf its value infers. */\n date?: RegExp;\n}\n\n/** Storybook's rule: a string arg with no control or options whose name matches `color` gets a color picker. */\nfunction matched(key: string, value: unknown, argType: ArgType | undefined, matchers: ControlMatchers): Leaf | null {\n if (typeof value !== 'string' || argType?.control !== undefined || stringOptions(argType ?? {})) return null;\n return matchers.color?.test(key) ? f.color(value) : null;\n}\n\n/** A labkit schema for a CSF story's args, refined by its `argTypes`. */\nexport function argsToSchema(\n args: Readonly<Record<string, unknown>>,\n argTypes: Readonly<Record<string, ArgType | undefined>>,\n matchers: ControlMatchers = {},\n): ConfigSchema<unknown> {\n const nodes: Record<string, Leaf> = {};\n for (const key of new Set([...Object.keys(args), ...Object.keys(argTypes)])) {\n const has = key in args;\n // A control carries only what crosses the port; the frame puts the rest back from `args` (`withUnsent`).\n const part = has ? portSafePart(args[key]) : null;\n if (has && !part) continue;\n const value = part?.value;\n const argType = argTypes[key];\n const control = argType ? controlOf(argType) : false;\n\n let node: Leaf | null =\n (has ? matched(key, value, argType, matchers) : null) ??\n (control ? controlled(control, argType ?? {}, has, value) : has ? inferred(value) : null);\n if (!node) continue;\n if (argType && (argType.control === false || argType.table?.disable)) node = node.hidden();\n if (argType?.description) node = node.describe(argType.description);\n if (argType?.name) node = node.label(argType.name);\n const shownWhen = argType?.if ? conditionOf(argType.if) : null;\n if (shownWhen) node = node.showIf(shownWhen);\n nodes[key] = node;\n }\n return f.schema(nodes as ConfigShape);\n}\n","import {\n type ComponentType,\n createContext,\n createElement,\n type Dispatch,\n type ReactNode,\n type SetStateAction,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport type { Globals, Layout, Viewport } from '../protocol/messages';\nimport { storyId, storyNameFromExport } from '../story/ids';\nimport type { Decorator, LoadedStory, PlayContext, StoryContext } from '../story/types';\nimport { type ArgsScope, ArgsContext, appliedLocal, coverOf, type LocalArgs } from './argsContext';\nimport { type ArgType, argsToSchema, type ControlMatchers } from './argsToSchema';\nimport { isPlainObject } from './isPlainObject';\nimport { withUnsent } from './portSafe';\n\ntype Args = Record<string, unknown>;\ntype CsfContext = {\n args: Args;\n globals: Globals;\n parameters: Record<string, unknown>;\n title: string;\n name: string;\n id: string;\n viewMode: 'story';\n};\ntype CsfRender = (args: Args, context: CsfContext) => ReactNode;\ntype CsfDecorator = (Story: ComponentType, context: CsfContext) => ReactNode;\ntype CsfPlay = (context: CsfContext & { canvasElement: HTMLElement; step: CsfStep }) => void | Promise<void>;\ntype CsfStep = (label: string, fn: () => void | Promise<void>) => Promise<void>;\n\ninterface Annotations {\n title?: string;\n name?: string;\n storyName?: string;\n component?: ComponentType<Args>;\n args?: Args;\n argTypes?: Record<string, ArgType>;\n parameters?: Record<string, unknown>;\n globals?: Record<string, unknown>;\n decorators?: CsfDecorator | CsfDecorator[];\n render?: CsfRender;\n play?: CsfPlay;\n includeStories?: string[] | RegExp;\n excludeStories?: string[] | RegExp;\n}\n\nconst LAYOUTS: readonly Layout[] = ['centered', 'padded', 'fullscreen'];\n\nconst asArray = <T,>(value: T | T[] | undefined): T[] => (value === undefined ? [] : Array.isArray(value) ? value : [value]);\n\n/** Storybook's `deleteUndefined`, which its args store applies after every update. */\nconst withoutUndefined = (args: Args): Args =>\n Object.fromEntries(Object.entries(args).filter(([, value]) => value !== undefined));\n\n/** Storybook's `matches` from `isExportStory`. */\nconst matches = (key: string, filter: string[] | RegExp) =>\n Array.isArray(filter) ? filter.includes(key) : key.match(filter) !== null;\n\n/** Storybook's `combineParameters`: plain objects merge deeply, anything else is replaced. */\nfunction combineParameters(...sources: (Record<string, unknown> | undefined)[]): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const source of sources) {\n for (const [key, value] of Object.entries(source ?? {})) {\n if (value === undefined) continue;\n out[key] = isPlainObject(value) && isPlainObject(out[key]) ? combineParameters(out[key], value) : value;\n }\n }\n return out;\n}\n\nfunction resolveViewport(parameters: Record<string, unknown>, globals: Record<string, unknown>): Viewport | null {\n const selected = globals.viewport as { value?: string; isRotated?: boolean } | undefined;\n const options = (parameters.viewport as { options?: Record<string, { styles?: { width?: string; height?: string } }> } | undefined)\n ?.options;\n const styles = selected?.value ? options?.[selected.value]?.styles : undefined;\n const px = (v: string | undefined) => (v && /^\\d+(\\.\\d+)?px$/.test(v) ? Number.parseFloat(v) : Number.NaN);\n const width = px(styles?.width);\n const height = px(styles?.height);\n if (Number.isNaN(width) || Number.isNaN(height)) return null;\n return selected?.isRotated ? { width: height, height: width } : { width, height };\n}\n\nconst InnerStory = createContext<(() => ReactNode) | null>(null);\n\nfunction Story(): ReactNode {\n return useContext(InnerStory)?.() ?? null;\n}\n\nfunction Call({ fn }: { fn: () => ReactNode }): ReactNode {\n return fn();\n}\n\ninterface StoryLocals {\n story: string;\n local: LocalArgs;\n setLocal: Dispatch<SetStateAction<LocalArgs>>;\n}\n\nconst LocalArgsContext = createContext<StoryLocals | null>(null);\n\n/** The outermost scope of a story holds its frame-local args, so its decorators and render share them. */\nfunction Scoped({\n id,\n build,\n fn,\n}: {\n id: string;\n build: (local: StoryLocals) => [ArgsScope, CsfContext];\n fn: (context: CsfContext) => ReactNode;\n}): ReactNode {\n const outer = useContext(LocalArgsContext);\n const [local, setLocal] = useState<LocalArgs>({});\n const shared = outer?.story === id ? outer : { story: id, local, setLocal };\n const [scope, context] = build(shared);\n const { config } = scope;\n const prune = shared.setLocal;\n // An entry config has moved past must not come back if config later returns to the value it covered.\n useEffect(() => {\n prune((prev) => {\n const kept = Object.entries(prev).filter(([key, entry]) => coverOf(config[key]) === entry.over);\n return kept.length === Object.keys(prev).length ? prev : Object.fromEntries(kept);\n });\n }, [config, prune]);\n return createElement(\n LocalArgsContext.Provider,\n { value: shared },\n createElement(ArgsContext.Provider, { value: scope }, createElement(Call, { fn: () => fn(context) })),\n );\n}\n\n/**\n * Normalizes a Component Story Format module. `autoTitle` titles the stories when the meta names no title;\n * `parameters` are the project's, under the meta's and each story's.\n */\nexport function loadCsfModule(\n mod: Record<string, unknown>,\n autoTitle: string,\n projectParameters: Record<string, unknown> = {},\n): LoadedStory[] {\n const meta = (isPlainObject(mod.default) ? mod.default : {}) as Annotations;\n const title = meta.title ?? autoTitle;\n const stories: LoadedStory[] = [];\n\n for (const [exportName, value] of Object.entries(mod)) {\n if (exportName === 'default' || exportName === '__namedExportsOrder' || exportName === '__esModule') continue;\n if (meta.includeStories && !matches(exportName, meta.includeStories)) continue;\n if (meta.excludeStories && matches(exportName, meta.excludeStories)) continue;\n if (!value || (typeof value !== 'object' && typeof value !== 'function')) continue;\n\n // A CSF 2 function export hoists its annotations onto itself.\n const spec: Annotations = typeof value === 'function' ? { ...value, render: value as CsfRender } : (value as Annotations);\n const id = storyId(title, exportName);\n const name = spec.name || spec.storyName || storyNameFromExport(exportName);\n const args = { ...meta.args, ...spec.args };\n const parameters = combineParameters(projectParameters, meta.parameters, spec.parameters);\n const matchers = (parameters.controls as { matchers?: ControlMatchers } | undefined)?.matchers;\n const config = argsToSchema(\n args,\n combineParameters(meta.argTypes, spec.argTypes) as Record<string, ArgType>,\n isPlainObject(matchers) ? matchers : {},\n );\n const defaults = config.defaults() as Args;\n const storyGlobals = { ...meta.globals, ...spec.globals };\n const component = meta.component;\n const renderFn: CsfRender | undefined =\n spec.render ?? meta.render ?? (component ? (a) => createElement(component, a) : undefined);\n\n const withArgs = (config: Args): Args =>\n Object.fromEntries(\n Object.entries(withoutUndefined(config)).map(([key, value]) => [key, key in args ? withUnsent(value, args[key]) : value]),\n );\n const csfContext = (config: unknown, globals: Globals, local: LocalArgs = {}): CsfContext => ({\n args: withoutUndefined({ ...args, ...withArgs(config as Args), ...appliedLocal(local, config as Args) }),\n globals,\n parameters,\n title,\n name,\n id,\n viewMode: 'story',\n });\n const scoped = (ctx: StoryContext, fn: (context: CsfContext) => ReactNode): ReactNode =>\n createElement(Scoped, {\n id,\n build: ({ local, setLocal }: StoryLocals): [ArgsScope, CsfContext] => {\n const context = csfContext(ctx.config, ctx.globals, local);\n const scope: ArgsScope = {\n args: context.args,\n config: ctx.config as Args,\n defaults,\n original: args,\n setConfig: ctx.setConfig,\n setLocal,\n };\n return [scope, context];\n },\n fn,\n });\n\n const adapt =\n (decorator: CsfDecorator): Decorator =>\n (inner, ctx) =>\n createElement(\n InnerStory.Provider,\n { value: inner },\n scoped(ctx, (context) => decorator(Story, context)),\n );\n\n const layout = parameters.layout as Layout | undefined;\n const play = spec.play ?? meta.play;\n\n stories.push({\n id,\n title,\n name,\n exportName,\n config,\n initialState: null,\n render: (ctx) => {\n if (!renderFn) return null;\n return scoped(ctx, (context) => renderFn(context.args, context));\n },\n decorators: [...asArray(spec.decorators), ...asArray(meta.decorators)].map(adapt),\n layout: layout && LAYOUTS.includes(layout) ? layout : 'padded',\n viewport: resolveViewport(parameters, storyGlobals),\n play: play\n ? ({ canvasElement, config, globals }: PlayContext) =>\n play({ ...csfContext(config, globals), canvasElement, step: async (_label, fn) => fn() })\n : null,\n });\n }\n return stories;\n}\n","import { f } from '@weasel-js/labkit/config';\nimport { isNative } from './define';\nimport { storyId, storyNameFromExport } from './ids';\nimport type { LoadedStory, MetaSpec, StorySpec } from './types';\n\n/** Normalizes a module written with `meta` and `story`; exports that are not stories are skipped. */\n/** `autoTitle` titles the stories when the meta names no title. */\nexport function loadNativeModule(mod: Record<string, unknown>, autoTitle: string): LoadedStory[] {\n const metaSpec: MetaSpec = isNative(mod.default, 'meta') ? (mod.default as MetaSpec) : {};\n const title = metaSpec.title ?? autoTitle;\n const stories: LoadedStory[] = [];\n for (const [exportName, value] of Object.entries(mod)) {\n if (exportName === 'default' || !isNative(value, 'story')) continue;\n const spec = value as StorySpec<unknown, unknown>;\n stories.push({\n id: storyId(title, exportName),\n title,\n name: spec.name ?? storyNameFromExport(exportName),\n exportName,\n config: spec.config ?? f.schema({}),\n initialState: spec.state ?? null,\n render: spec.render,\n decorators: [...(spec.decorators ?? []), ...(metaSpec.decorators ?? [])],\n layout: spec.layout ?? metaSpec.layout ?? 'centered',\n viewport: spec.viewport ?? null,\n play: spec.play ?? null,\n });\n }\n return stories;\n}\n","import { loadCsfModule } from '../csf/loadCsfModule';\nimport { openChannel } from '../protocol/channel';\nimport { type FromFrame, PORT_HANDOFF, type ToFrame } from '../protocol/messages';\nimport { isNative } from '../story/define';\nimport { loadNativeModule } from '../story/native';\nimport type { LoadedStory } from '../story/types';\nimport { type FrameSetup, reportImportFault, startFrame } from './FrameController';\n\nexport interface FrameImporters {\n [file: string]: () => Promise<Record<string, unknown>>;\n}\n\nexport interface FrameIndexEntry {\n id: string;\n /** The story's title as indexed, which titles the file's stories when its meta names none. */\n title: string;\n file: string;\n exportName: string;\n}\n\nexport interface MountFrameOptions {\n index: readonly FrameIndexEntry[];\n importers: FrameImporters;\n setup?: FrameSetup;\n load?: (mod: Record<string, unknown>, autoTitle: string, parameters?: Record<string, unknown>) => LoadedStory[];\n}\n\n/**\n * The default `load`: a module whose default export is a forge `meta` is native, anything else is CSF under\n * `parameters`. `autoTitle` titles the stories when the meta names no title.\n */\nexport function loadStories(\n mod: Record<string, unknown>,\n autoTitle: string,\n parameters?: Record<string, unknown>,\n): LoadedStory[] {\n return isNative(mod.default, 'meta')\n ? loadNativeModule(mod, autoTitle)\n : loadCsfModule(mod, autoTitle, parameters);\n}\n\nfunction waitForPort(): Promise<MessagePort> {\n return new Promise((resolve) => {\n const onMessage = (event: MessageEvent) => {\n const data = event.data as { type?: unknown } | null;\n const port = event.ports[0];\n if (event.origin !== location.origin || event.source !== window.parent) return;\n if (typeof data !== 'object' || data === null || data.type !== PORT_HANDOFF || !port) return;\n window.removeEventListener('message', onMessage);\n resolve(port);\n };\n window.addEventListener('message', onMessage);\n });\n}\n\n/** The frame document's entry: takes the shell's port, loads the story named by the hash, and starts it. */\nexport async function mountFrame(options: MountFrameOptions): Promise<void> {\n const channel = openChannel<ToFrame, FromFrame>(await waitForPort());\n const id = location.hash.slice(1);\n try {\n const entry = options.index.find((e) => e.id === id);\n if (!entry) throw new Error(`No story with id \"${id}\"`);\n const importer = options.importers[entry.file];\n if (!importer) throw new Error(`No importer for ${entry.file}`);\n const mod = await importer();\n const stories = (options.load ?? loadStories)(mod, entry.title, options.setup?.parameters);\n const story = stories.find((s) => s.exportName === entry.exportName);\n if (!story) throw new Error(`${entry.file} has no story export \"${entry.exportName}\"`);\n startFrame({ story, channel, container: document.getElementById('root') ?? document.body, setup: options.setup });\n } catch (error) {\n reportImportFault(channel, error);\n }\n}\n"]}
@@ -13,12 +13,7 @@ function storyId(title, exportName) {
13
13
  function storyNameFromExport(exportName) {
14
14
  return exportName.replace(/_/g, " ").replace(/-/g, " ").replace(/\./g, " ").replace(/([^\n])([A-Z])([a-z])/g, (_, a, b, c) => `${a} ${b}${c}`).replace(/([a-z])([A-Z])/g, (_, a, b) => `${a} ${b}`).replace(/([a-z])([0-9])/gi, (_, a, b) => `${a} ${b}`).replace(/([0-9])([a-z])/gi, (_, a, b) => `${a} ${b}`).replace(/(\s|^)(\w)/g, (_, a, b) => `${a}${b.toUpperCase()}`).replace(/ +/g, " ").trim();
15
15
  }
16
- function titleFromFile(file, root) {
17
- const prefix = `${root.replace(/\/$/, "")}/`;
18
- const relative = file.startsWith(prefix) ? file.slice(prefix.length) : file;
19
- return relative.replace(/\.stories\.[jt]sx?$/, "");
20
- }
21
16
 
22
- export { storyId, storyNameFromExport, titleFromFile };
23
- //# sourceMappingURL=chunk-UZCXH724.js.map
24
- //# sourceMappingURL=chunk-UZCXH724.js.map
17
+ export { storyId, storyNameFromExport };
18
+ //# sour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AAA,CACnE,OAAA,CAAQ,kBAAA,EAAoB,CAAC,GAAG,CAAA,EAAW,CAAA,KAAc,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA,CAAE,CAAA,CACpE,OAAA,CAAQ,oBAAoB,CAAC,CAAA,EAAG,GAAW,CAAA,KAAc,CAAA,EAAG,CAAC,CAAA,CAAA,EAAI,CAAC,CAAA,CAAE,CAAA,CACpE,QAAQ,aAAA,EAAe,CAAC,GAAG,CAAA,EAAW,CAAA,KAAc,GAAG,CAAC,CAAA,EAAG,CAAA,CAAE,WAAA,EAAa,CAAA,CAAE,CAAA,CAC5E,QAAQ,KAAA,EAAO,GAAG,EAClB,IAAA,EAAK;AACV","file":"chunk-6SRQIHJQ.js","sourcesContent":["// sanitize, storyId and storyNameFromExport are ports of storybook/internal/csf (10.4.0)'s\n// sanitize, toId and storyNameFromExport; they must agree or links diverge.\n\n/** Lower-case; runs of the listed separators become one dash. Everything else, non-ASCII letters included, survives. */\nexport function sanitize(part: string): string {\n return part\n .toLowerCase()\n .replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\\-=?;:'\",.<>{}[\\]\\\\/]/gi, '-')\n .replace(/-+/g, '-')\n .replace(/^-+/, '')\n .replace(/-+$/, '');\n}\n\nfunction sanitizeSafe(part: string, kind: 'kind' | 'name'): string {\n const sanitized = sanitize(part);\n if (sanitized === '') throw new Error(`Invalid ${kind} '${part}', must include alphanumeric characters`);\n return sanitized;\n}\n\nexport function storyId(title: string, exportName: string): string {\n return `${sanitizeSafe(title, 'kind')}--${sanitizeSafe(exportName, 'name')}`;\n}\n\n/** `PrimaryButton` → `Primary Button`, `withIcon2` → `With Icon 2`. */\nexport function storyNameFromExport(exportName: string): string {\n return exportName\n .replace(/_/g, ' ')\n .replace(/-/g, ' ')\n .replace(/\\./g, ' ')\n .replace(/([^\\n])([A-Z])([a-z])/g, (_, a: string, b: string, c: string) => `${a} ${b}${c}`)\n .replace(/([a-z])([A-Z])/g, (_, a: string, b: string) => `${a} ${b}`)\n .replace(/([a-z])([0-9])/gi, (_, a: string, b: string) => `${a} ${b}`)\n .replace(/([0-9])([a-z])/gi, (_, a: string, b: string) => `${a} ${b}`)\n .replace(/(\\s|^)(\\w)/g, (_, a: string, b: string) => `${a}${b.toUpperCase()}`)\n .replace(/ +/g, ' ')\n .trim();\n}\n"]}
@@ -9,5 +9,5 @@ function stableStringify(value) {
9
9
  }
10
10
 
11
11
  export { PORT_HANDOFF, PROTOCOL_VERSION, stableStringify };
12
- //# sourceMappingURL=chunk-IOBG7GZQ.js.map
13
- //# sourceMappingURL=chunk-IOBG7GZQ.js.map
12
+ //# sourceMappingURL=chunk-FTFR2YPM.js.map
13
+ //# sourceMappingURL=chunk-FTFR2YPM.js.map