@weasel-js/forge 1.11.1 → 1.13.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +110 -5
  2. package/dist/{FrameController-Cj_i-Rdk.d.ts → FrameController-Tv3jrHyT.d.ts} +3 -3
  3. package/dist/{chunk-JTCUIJPZ.js → chunk-35DOPXHZ.js} +119 -10
  4. package/dist/chunk-35DOPXHZ.js.map +1 -0
  5. package/dist/{chunk-7BQPHMA2.js → chunk-3BAM6M26.js} +2 -2
  6. package/dist/chunk-3BAM6M26.js.map +1 -0
  7. package/dist/{chunk-ZAWXMUGZ.js → chunk-5WS67HMU.js} +8 -3
  8. package/dist/chunk-5WS67HMU.js.map +1 -0
  9. package/dist/{chunk-BKPDKUDN.js → chunk-BUXUWAI4.js} +45 -60
  10. package/dist/chunk-BUXUWAI4.js.map +1 -0
  11. package/dist/chunk-ORMMZ5PV.js +59 -0
  12. package/dist/chunk-ORMMZ5PV.js.map +1 -0
  13. package/dist/chunk-RKQ277P5.js +501 -0
  14. package/dist/chunk-RKQ277P5.js.map +1 -0
  15. package/dist/chunk-STF6NQ5N.js +60 -0
  16. package/dist/chunk-STF6NQ5N.js.map +1 -0
  17. package/dist/chunk-VUPN73JP.js +16 -0
  18. package/dist/chunk-VUPN73JP.js.map +1 -0
  19. package/dist/{config-DN6IaNf6.d.ts → config-Bd6FVlh7.d.ts} +22 -5
  20. package/dist/frame/index.css +37 -0
  21. package/dist/frame/index.css.map +1 -1
  22. package/dist/frame/index.d.ts +62 -29
  23. package/dist/frame/index.js +138 -8
  24. package/dist/frame/index.js.map +1 -1
  25. package/dist/index.d.ts +28 -5
  26. package/dist/index.js +2 -2
  27. package/dist/index.js.map +1 -1
  28. package/dist/mountFrame-FdJDb3TB.d.ts +35 -0
  29. package/dist/shell/index.css +147 -2
  30. package/dist/shell/index.css.map +1 -1
  31. package/dist/shell/index.d.ts +44 -8
  32. package/dist/shell/index.js +1614 -277
  33. package/dist/shell/index.js.map +1 -1
  34. package/dist/test/index.css +58 -0
  35. package/dist/test/index.css.map +1 -0
  36. package/dist/test/index.d.ts +1 -1
  37. package/dist/test/index.js +4 -4
  38. package/dist/vite/index.js +571 -121
  39. package/dist/vite/index.js.map +1 -1
  40. package/package.json +13 -8
  41. package/dist/chunk-5DXUNLV2.js +0 -6
  42. package/dist/chunk-5DXUNLV2.js.map +0 -1
  43. package/dist/chunk-7BQPHMA2.js.map +0 -1
  44. package/dist/chunk-BKPDKUDN.js.map +0 -1
  45. package/dist/chunk-FZNABWJC.js +0 -282
  46. package/dist/chunk-FZNABWJC.js.map +0 -1
  47. package/dist/chunk-JTCUIJPZ.js.map +0 -1
  48. package/dist/chunk-WEQSLPKT.js +0 -9
  49. package/dist/chunk-WEQSLPKT.js.map +0 -1
  50. package/dist/chunk-ZAWXMUGZ.js.map +0 -1
package/README.md CHANGED
@@ -65,7 +65,7 @@ The vite plugin takes two optional config modules:
65
65
  (default `weaselforge`). The CSS Vars panel stays hidden until its header toggle
66
66
  is pressed, and the lab remembers the choice; `cssVars: false` leaves out both.
67
67
  `libraries` names the project's libraries, each a stretch of file path, a
68
- label and an optional badge tone: `{ path: '/packages/ui/', label: 'ui' }`.
68
+ label and an optional badge tint: `{ path: '/packages/ui/', label: 'ui' }`.
69
69
  The tree's package filter, index pages, and Get Info show the label; a
70
70
  story under none of them takes its title's first segment.
71
71
 
@@ -160,6 +160,96 @@ focused trial when it shows the routed story, else the first that does. An index
160
160
  isolated story's frame and a story test show the story paused at its span's
161
161
  start, with no transport.
162
162
 
163
+ ## Loupe
164
+
165
+ A lens shows the patch of a story under its reticle, magnified, or rendered
166
+ under a different condition, or both. Lenses float over the whole workshop:
167
+ one stays where it was put while the panes under it scroll and zoom, and one
168
+ parked over a trial can aim at another. They last for the session and are not
169
+ saved with a trial. Drag a lens or its reticle to move it, drag its edge to
170
+ resize it, and press Delete to close a selected one; the lenses keep an undo
171
+ history of their own.
172
+
173
+ Every lens key is in the Loupe keymap. Alt+L opens it, a hint lists its keys
174
+ while it is open, and Escape closes it. Holding Alt+L keeps it open, so a Follow
175
+ lens can be pinned while the pointer is still on the story. Inside it, each key
176
+ acts on the selected lens, or on the last one added when none is selected:
177
+
178
+ | Key | Does | Key | Does |
179
+ |---|---|---|---|
180
+ | `l` | add a lens | `Shift+L` | close the lens |
181
+ | `p` | pin the reticle | `f` | make the reticle follow the pointer |
182
+ | `v` | Live source | `x` | Pixels source |
183
+ | `r` | Pixels at 1×, 2×, or both side by side | `=` / `-` | zoom in / out |
184
+ | `o` | compare with the opposite mode | `k` | choose a comparison |
185
+ | `Shift+O` | clear the comparison | `s` / `\` / `d` | Swap / Split / Difference |
186
+ | `t` | Token readout | `c` | Contrast readout |
187
+ | `g` | pixel grid | | |
188
+
189
+ Each binding's id is its action id (`loupe.add`, `loupe.view.split`, …), so a
190
+ binding override can rebind it. Alt+Slash opens a panel listing every key
191
+ binding the workshop registers, the lens keys included.
192
+
193
+ Token shows the color at the aim and the `--wzl-*` token chain behind it;
194
+ Contrast shows the WCAG ratio of the text there against its background, with
195
+ AA and AAA marks, read from computed styles on a Live lens and from the pixels
196
+ on a Pixels one; the pixel grid draws on a Pixels lens zoomed to 8× or more per
197
+ captured pixel (its zoom over the capture's DPR). On a Live lens with a
198
+ comparison, Token and Contrast read the compared copy. Token reads the DOM, so a
199
+ Pixels lens with a comparison has none to give, and neither reads inside an
200
+ isolated story's frame.
201
+
202
+ **Live** renders the story a second time inside the lens, with the
203
+ comparison's globals or args laid over the trial's. It is sharp at any factor
204
+ and follows the trial's state, but takes no clicks, and it is never the real
205
+ pixels. Being a second render, it shares the story's args and trial state but
206
+ not the story's own React state: a story whose pan and zoom a lens should
207
+ follow keeps them in an arg through `useArgs`, as CanvasStack's stories do.
208
+ **Pixels** asks the dev server
209
+ for a PNG of the story rendered in headless Chromium at a chosen DPR and enlarges
210
+ it nearest-neighbor, so a hairline half a pixel off looks as it does on screen.
211
+ A capture reproduces the story's args, globals, trial state, playhead, CSS
212
+ variable overrides, scroll position (an isolated story's excepted), the lab's
213
+ theme and the OS color scheme; it lags the live story
214
+ by one capture, and has no hover or focus in it. Difference always compares two
215
+ Pixels captures, whichever source the lens shows.
216
+
217
+ Playwright is an optional peer dependency. Without it, or without its Chromium
218
+ (`npx playwright install chromium`), a lens says why Pixels is unavailable and
219
+ offers Live only. The endpoint imports `@weasel-js/core/json`, which resolves to
220
+ core's built `dist`, so build core before starting the dev server in a fresh
221
+ checkout.
222
+
223
+ The endpoint is `<base>__forge/capture`, on the dev server only. A GET says
224
+ whether captures are available, without starting Chromium; a POST takes a JSON
225
+ payload and answers with the PNG. It is guarded against being used to load
226
+ anyone else's page:
227
+
228
+ - The capture page's URL is built from the socket the request arrived on,
229
+ never from its `Host` header.
230
+ - A POST must be `application/json`, and one whose `Origin` is not the dev
231
+ server's own is refused.
232
+ - A CSS variable override must be a custom property name with no `{`, `}` or
233
+ `;` in its value, and overrides are written through the CSSOM.
234
+ - A body past 16 MB is answered 413 and the connection closed.
235
+ - The capture browser blocks service workers, closes every WebSocket but the
236
+ dev server's own, and ignores certificate errors only for an https dev
237
+ server; a listed origin's requests are then fetched from Node, so its
238
+ certificate is still checked.
239
+ - The capture page can load nothing but the dev server's own origin and the
240
+ origins the shell config lists in `capture.allowOrigins`, such as a web-font
241
+ service's:
242
+
243
+ ```ts
244
+ defineShellConfig({ capture: { allowOrigins: ['https://fonts.googleapis.com', 'https://fonts.gstatic.com'] } });
245
+ ```
246
+
247
+ Captures are cached in the dev-server process, at most 64 entries and 64 MB of
248
+ PNG bytes, least recently used out first. The cache is cleared on any client
249
+ module update and when the server closes. There is one Chromium, started on the
250
+ first capture that misses the cache and closed after 120 s idle or when the
251
+ server closes.
252
+
163
253
  ## Index pages
164
254
 
165
255
  Every component — every story title — has an index page, opened by clicking
@@ -221,10 +311,25 @@ const meta: Meta = { title: 'ui/Icons/Gallery', tags: ['gallery'] };
221
311
  export const AllPermutations: Story = { tags: ['gallery'], render: … };
222
312
  ```
223
313
 
224
- A gallery row carries a grid mark in the sidebar and a Gallery badge on its
225
- index page. A component every one of whose stories is a gallery is left out of
226
- the dependency lists entirely, so a catalog that imports everything does not
227
- appear as a user of everything.
314
+ Galleries list in the sidebar's Gallery view rather than under Components or
315
+ Tree, and carry a Gallery badge on their index page. A component every one of
316
+ whose stories is a gallery is left out of the dependency lists entirely, so a
317
+ catalog that imports everything does not appear as a user of everything.
318
+
319
+ ## Labs
320
+
321
+ A story file that is a whole screen for exercising a component, rather than a
322
+ specimen of it, tags its meta `lab`, the same way. A full-screen layout is not
323
+ the signal: a sidebar's specimen fills the frame too.
324
+
325
+ ```ts
326
+ const meta: Meta = { title: 'ui/Bar on an arc', tags: ['lab'] };
327
+ ```
328
+
329
+ On an index page a lab story keeps its title link and description but embeds
330
+ no example and no variants, so a lab with many controls does not fill the page
331
+ with copies of itself. Its rows in the sidebar, and its index page entries,
332
+ carry a Lab badge, so a reader knows opening one opens a screen.
228
333
 
229
334
  ## Story tests
230
335
 
@@ -227,8 +227,8 @@ interface MetaSpec {
227
227
  isolate?: string;
228
228
  /** The component's own index page, in place of the generated one. A CSF file sets `parameters.forge.index`. */
229
229
  index?: IndexRender;
230
- /** As CSF's meta `tags`; `'gallery'` marks a catalog or showcase rather than one component. Read from the source,
231
- * so each must be a string literal. */
230
+ /** As CSF's meta `tags`; `'gallery'` marks a catalog or showcase rather than one component, and `'lab'` a whole
231
+ * screen for exercising one rather than a specimen of it. Read from the source, so each must be a string literal. */
232
232
  tags?: readonly string[];
233
233
  /** Gives every story in the file a playhead and a transport, unless the story declares its own. */
234
234
  timeline?: TimelineSpec | ((config: Record<string, unknown>) => TimelineSpec);
@@ -396,4 +396,4 @@ declare function startFrame({ story, channel, container, setup }: StartFrameOpti
396
396
  /** Reports an import failure — there is no story to start. */
397
397
  declare function reportImportFault(channel: Channel<ToFrame, FromFrame>, error: unknown): void;
398
398
 
399
- export { type A11yFinding as A, startFrame as B, type ClockState as C, type Decorator as D, type FrameSetup as F, type Globals as G, type IndexContext as I, type LoadedStory as L, type MetaSpec as M, type PlayContext as P, type StorySpec as S, type TimelineSpec as T, type Viewport as V, type SpanOverride as a, type A11yNode as b, type A11yReport as c, type ComponentDeps as d, type ComponentHistory as e, type DepGraph as f, type GlobalsTarget as g, type IndexRender as h, type IndexStoryProps as i, type StoryContext as j, type Layout as k, type Span as l, type IndexEntry as m, type FromFrame as n, type ToFrame as o, type CssVarReport as p, type A11yOutcome as q, type DescribedEntry as r, type DescribedShape as s, type SchemaDescription as t, type SectionDescription as u, type Channel as v, type ConfigAnswers as w, type FaultPhase as x, type StartFrameOptions as y, reportImportFault as z };
399
+ export { type A11yFinding as A, type SectionDescription as B, type Channel as C, type Decorator as D, type FrameSetup as F, type Globals as G, type IndexEntry as I, type Layout as L, type MetaSpec as M, type PlayContext as P, type StartFrameOptions as S, type ToFrame as T, type Viewport as V, type ConfigAnswers as a, type FaultPhase as b, type FromFrame as c, type StorySpec as d, type ClockState as e, type SpanOverride as f, type A11yNode as g, type A11yReport as h, type ComponentDeps as i, type ComponentHistory as j, type DepGraph as k, type GlobalsTarget as l, type IndexContext as m, type IndexRender as n, type IndexStoryProps as o, type LoadedStory as p, type StoryContext as q, reportImportFault as r, startFrame as s, type Span as t, type TimelineSpec as u, type CssVarReport as v, type A11yOutcome as w, type DescribedEntry as x, type DescribedShape as y, type SchemaDescription as z };
@@ -1,11 +1,11 @@
1
1
  import { isNative, ClockContext } from './chunk-L5XM5VKB.js';
2
- import { storyNameFromExport, storyId, PROP_ARG_TYPES_EXPORT } from './chunk-ZAWXMUGZ.js';
2
+ import { isSafeOverride, storyNameFromExport, storyId, PROP_ARG_TYPES_EXPORT } from './chunk-5WS67HMU.js';
3
3
  import { portSafePart, appliedLocal, withUnsent, coverOf, ArgsContext } from './chunk-KEQBGDUZ.js';
4
4
  import { useVisibleRaf, useLatest, isPlainObject } from '@weasel-js/core';
5
- import { createContext, useSyncExternalStore, useRef, useEffect, useState, Component, useContext, createElement } from 'react';
5
+ import { createContext, useSyncExternalStore, useRef, useEffect, useState, Component, useLayoutEffect, useContext, createElement } from 'react';
6
6
  import { createEmitter } from '@weasel-js/registry';
7
7
  import { jsx } from 'react/jsx-runtime';
8
- import { f } from '@weasel-js/labkit/config';
8
+ import { f, UnionNode, ObjectNode } from '@weasel-js/labkit/config';
9
9
  import { iconFromData } from '@weasel-js/ui/components/Icon';
10
10
 
11
11
  // src/frame/a11y.ts
@@ -278,9 +278,17 @@ function createOverrides(doc, scope = ":root") {
278
278
  }
279
279
  doc.head.append(style);
280
280
  };
281
+ const selector = `:is(${scope}):not(#fg-overrides)`;
281
282
  const write = () => {
282
- const decls = [...values].map(([name, value]) => ` ${name}: ${value};`);
283
- style.textContent = decls.length > 0 ? `:is(${scope}):not(#fg-overrides) {
283
+ style.textContent = values.size > 0 ? `${selector} {}` : "";
284
+ const rule = style.sheet?.cssRules[0];
285
+ if (!rule) return;
286
+ for (const [name, value] of values) if (isSafeOverride(name, value)) rule.style.setProperty(name, value);
287
+ const decls = [...values.keys()].flatMap((name) => {
288
+ const value = rule.style.getPropertyValue(name).trim();
289
+ return value && isSafeOverride(name, value) ? [` ${name}: ${value};`] : [];
290
+ });
291
+ style.textContent = decls.length > 0 ? `${selector} {
284
292
  ${decls.join("\n")}
285
293
  }
286
294
  ` : "";
@@ -515,6 +523,73 @@ function inferred(value) {
515
523
  return Array.isArray(value) || isPlainObject(value) ? f.custom("json", value) : null;
516
524
  }
517
525
  }
526
+ function variantsOf(members) {
527
+ const objects = members.filter((m) => m.name === "object");
528
+ if (objects.length !== members.length || objects.length === 0) return null;
529
+ const pinned = (m, key) => {
530
+ const field = m.value[key];
531
+ return field?.name === "enum" && field.value.length === 1 ? field.value[0] : void 0;
532
+ };
533
+ const tag = Object.keys(objects[0].value).find((key) => objects.every((m) => pinned(m, key) !== void 0));
534
+ if (tag === void 0) return null;
535
+ const variants = /* @__PURE__ */ new Map();
536
+ for (const member of objects) {
537
+ const name = pinned(member, tag);
538
+ const held = variants.get(name)?.value ?? {};
539
+ const added = Object.entries(member.value).filter(([key]) => !(key in held));
540
+ variants.set(name, { name: "object", value: { ...held, ...Object.fromEntries(added) } });
541
+ }
542
+ return { tag, variants };
543
+ }
544
+ function fieldsOf(shape, value, omit) {
545
+ const held = isPlainObject(value) ? value : {};
546
+ const fields = {};
547
+ for (const [key, field] of Object.entries(shape.value)) {
548
+ if (key === omit) continue;
549
+ const leaf = shaped(field, held[key]);
550
+ if (leaf) fields[key] = leaf;
551
+ }
552
+ return Object.keys(fields).length > 0 ? fields : null;
553
+ }
554
+ function shaped(shape, value) {
555
+ switch (shape.name) {
556
+ case "boolean":
557
+ return f.boolean(value);
558
+ case "string":
559
+ return f.string(value);
560
+ case "number":
561
+ return f.number(value);
562
+ case "enum":
563
+ return shape.value.length > 0 ? f.enum(value, shape.value) : null;
564
+ case "array": {
565
+ const item = shaped(shape.value, void 0);
566
+ return item ? f.list(Array.isArray(value) ? value : [], item) : null;
567
+ }
568
+ case "object": {
569
+ const fields = fieldsOf(shape, value);
570
+ if (!fields) return null;
571
+ const node = f.object(fields);
572
+ return new ObjectNode(isPlainObject(value) ? value : node.default, node.annotations, node.options);
573
+ }
574
+ case "union": {
575
+ const union = variantsOf(shape.value);
576
+ if (!union) return null;
577
+ const { tag, variants } = union;
578
+ const held = isPlainObject(value) ? value[tag] : void 0;
579
+ const nodes = Object.fromEntries(
580
+ [...variants].map(([name, member]) => [name, f.object(fieldsOf(member, held === name ? value : void 0, tag) ?? {})])
581
+ );
582
+ const node = f.union(tag, nodes);
583
+ const start = typeof held === "string" && variants.has(held) ? value : node.default;
584
+ return new UnionNode(start, node.annotations, node.options);
585
+ }
586
+ default:
587
+ return null;
588
+ }
589
+ }
590
+ function structured(argType, value) {
591
+ return (argType.type ? shaped(argType.type, value) : null) ?? inferred(value);
592
+ }
518
593
  function bounded(node, control) {
519
594
  let out = node;
520
595
  if (control.min !== void 0 && control.max !== void 0) out = out.range(control.min, control.max);
@@ -543,7 +618,7 @@ function controlled(control, argType, has, value) {
543
618
  case "radio":
544
619
  case "inline-radio":
545
620
  case void 0: {
546
- if (!options) return control.type === void 0 && has ? inferred(value) : null;
621
+ if (!options) return control.type === void 0 && has ? structured(argType, value) : null;
547
622
  const { icons } = control;
548
623
  const node = f.enum(
549
624
  def(),
@@ -555,7 +630,7 @@ function controlled(control, argType, has, value) {
555
630
  return control.type === "radio" || control.type === "inline-radio" ? node.radio() : node;
556
631
  }
557
632
  case "object":
558
- return has ? f.custom("json", value) : null;
633
+ return has ? (argType.type ? shaped(argType.type, value) : null) ?? f.custom("json", value) : null;
559
634
  default:
560
635
  return has ? inferred(value) : null;
561
636
  }
@@ -822,7 +897,41 @@ function useNearViewport(ref, margin, initial = true) {
822
897
  }, [ref, margin]);
823
898
  return near;
824
899
  }
900
+ var scopeOf = (id) => `[data-fg-host="${id}"]`;
901
+ function useHostConditions(host, opts) {
902
+ const { hostId, globals, overrides: persisted, setup } = opts;
903
+ const latest = useLatest({ setup });
904
+ const overridesRef = useRef(null);
905
+ useLayoutEffect(() => {
906
+ if (!host) return;
907
+ const scope = scopeOf(hostId);
908
+ const { cssVarsScope } = latest.current.setup;
909
+ overridesRef.current = createOverrides(
910
+ host.ownerDocument,
911
+ cssVarsScope ? `${scope}, ${scope} :is(${cssVarsScope})` : scope
912
+ );
913
+ return () => {
914
+ overridesRef.current?.dispose();
915
+ overridesRef.current = null;
916
+ };
917
+ }, [host, hostId, latest]);
918
+ const applied = useRef({});
919
+ useLayoutEffect(() => {
920
+ const overrides = overridesRef.current;
921
+ if (!overrides) return;
922
+ for (const name of Object.keys(applied.current)) if (!(name in persisted)) overrides.set(name, null);
923
+ for (const [name, value] of Object.entries(persisted)) overrides.set(name, value);
924
+ applied.current = { ...persisted };
925
+ }, [host, hostId, persisted]);
926
+ useLayoutEffect(() => {
927
+ if (!host) return;
928
+ const target = createGlobalsTarget(host, scopeOf(hostId));
929
+ latest.current.setup.applyGlobals?.(globals, target);
930
+ return () => target.dispose();
931
+ }, [host, hostId, globals, latest]);
932
+ return overridesRef;
933
+ }
825
934
 
826
- export { IN_VIEW_MARGIN, StoryHost, auditElement, createA11yHighlighter, createGlobalsTarget, createOverrides, indexRenderOf, loadStories, resolveCssVar, runAxe, scanCssVars, useClockLoop, useNearViewport, useStoryClock };
827
- //# sourceMappingURL=chunk-JTCUIJPZ.js.map
828
- //# sourceMappingURL=chunk-JTCUIJPZ.js.map
935
+ export { IN_VIEW_MARGIN, StoryHost, auditElement, createA11yHighlighter, createGlobalsTarget, createOverrides, cssRulesOf, indexRenderOf, loadStories, resolveCssVar, runAxe, scanCssVars, useClockLoop, useHostConditions, useNearViewport, useStoryClock, varRefs };
936
+ //# sourceMappingURL=chunk-35DOPXHZ.js.map
937
+ //# sourceMappingURL=chunk-35DOPXHZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/frame/a11y.ts","../src/frame/a11yHighlight.ts","../src/frame/cssVarUse.ts","../src/frame/cssVars.ts","../src/frame/globalsTarget.ts","../src/timeline/useClockLoop.ts","../src/timeline/clock.ts","../src/timeline/StoryClock.tsx","../src/frame/StoryHost.tsx","../src/csf/argsToSchema.ts","../src/timeline/declare.ts","../src/csf/loadCsfModule.tsx","../src/story/native.ts","../src/story/load.ts","../src/frame/useNearViewport.ts","../src/shell/hostConditions.ts"],"names":["last","raf","useEffect","jsx","value","isPlainObject","useContext","useState","config","f","useLatest","useRef"],"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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,MAAA,CAAO,OAAA,CAAQ,KAAA,CAAM,YAAA,GAAe,OAAA,EAAS,MAAM,CAAA;AACnD,IAAA,OAAO,MAAM,OAAO,OAAA,EAAQ;AAAA,EAC9B,GAAG,CAAC,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAS,MAAM,CAAC,CAAA;AAElC,EAAA,OAAO,YAAA;AACT","file":"chunk-35DOPXHZ.js","sourcesContent":["import type { A11yFinding, A11yOutcome, 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/** Rules that judge the page rather than the element audited; off when the element is one story on a page of many. */\nexport const PAGE_RULES: readonly string[] = [\n 'bypass',\n 'document-title',\n 'html-has-lang',\n 'html-lang-valid',\n 'html-xml-lang-mismatch',\n 'landmark-one-main',\n 'page-has-heading-one',\n 'region',\n];\n\nexport interface RunAxeOptions {\n /** Whether `element` stands for the whole page. False leaves `PAGE_RULES` out. Default true. */\n page?: boolean;\n}\n\n// axe refuses a run while another is under way in the same document, and the workshop page holds every story.\nlet last: Promise<unknown> = Promise.resolve();\n\n/** Runs axe over `element` and reduces its answer to what crosses the frame's channel. A run waits for the one before it. */\nexport async function runAxe(element: Element, { page = true }: RunAxeOptions = {}): Promise<A11yReport> {\n const axe = await loadAxe();\n const rules = page ? undefined : Object.fromEntries(PAGE_RULES.map((id) => [id, { enabled: false }]));\n const run = () => axe.run(element, rules ? { rules } : undefined);\n const running = last.then(run, run);\n last = running;\n const result = await running;\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\n/** `runAxe`, with a failure to run reported as an outcome rather than thrown. */\nexport async function auditElement(element: Element, options?: RunAxeOptions): Promise<A11yOutcome> {\n try {\n return { ok: true, report: await runAxe(element, options) };\n } catch (error) {\n return { ok: false, message: error instanceof Error ? error.message : String(error) };\n }\n}\n","/** Outlines over the elements an axe finding names, drawn in the document that holds them. */\nexport interface A11yHighlighter {\n /** Outlines every element `targets` reaches, replacing what was shown; an empty list clears. */\n show(targets: readonly (readonly string[])[]): void;\n dispose(): void;\n}\n\nconst CSS = `[data-fg-a11y-highlight] {\n position: fixed;\n z-index: var(--wzl-z-drag, 10000);\n box-sizing: border-box;\n pointer-events: none;\n border: 2px solid var(--wzl-danger, #e5484d);\n border-radius: 2px;\n background: color-mix(in srgb, var(--wzl-danger, #e5484d) 15%, transparent);\n}\n`;\n\n/** The element an axe target reaches: each entry after the first steps into the frame or shadow root before it. */\nexport function resolveTarget(doc: Document, target: readonly string[]): Element | null {\n let scope: Document | ShadowRoot = doc;\n let found: Element | null = null;\n for (const selector of target) {\n try {\n found = scope.querySelector(selector);\n } catch {\n return null;\n }\n if (!found) return null;\n const inner: Document | ShadowRoot | null | undefined =\n found.shadowRoot ?? (found as HTMLIFrameElement).contentDocument;\n if (inner) scope = inner;\n }\n return found;\n}\n\nexport function createA11yHighlighter(doc: Document): A11yHighlighter {\n let style: HTMLStyleElement | null = null;\n let boxes: { el: Element; box: HTMLElement }[] = [];\n const view = doc.defaultView;\n\n const place = () => {\n for (const { el, box } of boxes) {\n const rect = el.getBoundingClientRect();\n box.style.left = `${rect.left}px`;\n box.style.top = `${rect.top}px`;\n box.style.width = `${rect.width}px`;\n box.style.height = `${rect.height}px`;\n }\n };\n\n const clear = () => {\n for (const { box } of boxes) box.remove();\n boxes = [];\n view?.removeEventListener('scroll', place, true);\n view?.removeEventListener('resize', place);\n };\n\n return {\n show(targets) {\n clear();\n const elements = targets.map((target) => resolveTarget(doc, target)).filter((el) => el !== null);\n if (elements.length === 0) return;\n if (!style) {\n style = doc.createElement('style');\n style.setAttribute('data-fg-a11y-highlight-style', '');\n style.textContent = CSS;\n doc.head.append(style);\n }\n boxes = elements.map((el) => {\n const box = doc.createElement('div');\n box.setAttribute('data-fg-a11y-highlight', '');\n box.setAttribute('aria-hidden', 'true');\n doc.body.append(box);\n return { el, box };\n });\n place();\n view?.addEventListener('scroll', place, true);\n view?.addEventListener('resize', place);\n },\n dispose() {\n clear();\n style?.remove();\n style = null;\n },\n };\n}\n","const VAR_REF = /var\\(\\s*(--[\\w-]+)/g;\nconst CUSTOM_DECL = /(?:^|[;{\\s])(--[\\w-]+)\\s*:\\s*([^;]*)/g;\n// A selector naming a pseudo-element, or a state the pointer or focus has to be in, matches no element at rest.\nconst RESTLESS = /::?(?:before|after|first-line|first-letter|marker|placeholder|selection|backdrop|file-selector-button)\\b|::[\\w-]+(?:\\([^)]*\\))?|:(?:hover|active|focus-visible|focus-within|focus|visited|target)\\b/g;\nconst STYLE_RULE = 1;\n\n/** Every custom property `text` reads with `var()`. */\nexport function varRefs(text: string, into: Set<string> = new Set()): Set<string> {\n if (!text.includes('var(')) return into;\n for (const [, name] of text.matchAll(VAR_REF)) into.add(name!);\n return into;\n}\n\n/** Where a selector lands relative to the story: on it or inside it, or on an ancestor whose declarations it inherits. */\ninterface Reach {\n readonly within: boolean;\n readonly above: boolean;\n}\n\nfunction reach(selector: string, root: Element): Reach {\n const resting = selector.replace(RESTLESS, '').trim() || '*';\n try {\n return { within: root.matches(resting) || root.querySelector(resting) !== null, above: root.parentElement?.closest(resting) != null };\n } catch {\n // A selector the engine can't query is kept rather than lost.\n return { within: true, above: true };\n }\n}\n\n/** A declaration block split into what it defines and the custom properties its other declarations read. */\nfunction readBlock(block: string, defs: Map<string, Set<string>>, seeds: Set<string> | null): void {\n for (const [, name, value] of block.matchAll(CUSTOM_DECL)) {\n const refs = defs.get(name!) ?? new Set<string>();\n varRefs(value!, refs);\n defs.set(name!, refs);\n }\n if (seeds) varRefs(block.replace(CUSTOM_DECL, ''), seeds);\n}\n\nfunction blockOf(rule: CSSRule): string {\n const text = rule.cssText;\n const open = text.indexOf('{');\n return open < 0 ? '' : text.slice(open + 1, text.lastIndexOf('}'));\n}\n\nfunction walk(rules: CSSRuleList, root: Element, defs: Map<string, Set<string>>, seeds: Set<string>, parent?: Reach): void {\n for (const rule of Array.from(rules)) {\n const imported = (rule as CSSRule & { styleSheet?: CSSStyleSheet | null }).styleSheet;\n if (imported) {\n const inner = cssRulesOf(imported);\n if (inner) walk(inner, root, defs, seeds);\n continue;\n }\n const children = (rule as CSSRule & { cssRules?: CSSRuleList }).cssRules;\n if (rule.type !== STYLE_RULE) {\n // @media, @supports, @layer and @container hold rules; a keyframe or a font face reaches no element.\n if (children) walk(children, root, defs, seeds, parent);\n continue;\n }\n // A nested rule's selector is relative to its parent's, so it inherits the parent's reach.\n const at = parent ?? reach((rule as CSSStyleRule).selectorText, root);\n if (at.within || at.above) readBlock(blockOf(rule), defs, at.within ? seeds : null);\n }\n}\n\nexport function cssRulesOf(sheet: CSSStyleSheet): CSSRuleList | null {\n try {\n return sheet.cssRules;\n } catch {\n // A cross-origin sheet refuses to be read.\n return null;\n }\n}\n\n/**\n * The custom properties the story under `root` uses: those read by a declaration of a rule matching an element in\n * it, or by its inline styles, and every property one of those reads in turn through a definition that reaches it.\n * A definition on an ancestor reaches it by inheritance; an ancestor's other declarations do not count as use.\n */\nexport function usedCssVars(doc: Document, root: Element): Set<string> {\n const defs = new Map<string, Set<string>>();\n const seeds = new Set<string>();\n for (const sheet of Array.from(doc.styleSheets)) {\n const rules = cssRulesOf(sheet);\n if (rules) walk(rules, root, defs, seeds);\n }\n for (const el of Array.from(doc.querySelectorAll('[style]'))) {\n const within = root.contains(el);\n if (within || el.contains(root)) readBlock(el.getAttribute('style') ?? '', defs, within ? seeds : null);\n }\n\n const used = new Set<string>();\n const queue = [...seeds];\n while (queue.length > 0) {\n const name = queue.pop()!;\n if (used.has(name)) continue;\n used.add(name);\n for (const ref of defs.get(name) ?? []) queue.push(ref);\n }\n return used;\n}\n","import type { CssVarReport } from '../protocol/messages';\nimport { usedCssVars, varRefs } from './cssVarUse';\nimport { isSafeOverride } from './safeOverride';\n\nconst collect = (text: string, names: Set<string>) => void varRefs(text, names);\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 — each marked with whether the story under `root` uses it.\n * Values resolve on `root`, the document's by default, or else on the first element under it that declares one.\n */\nexport function scanCssVars(\n doc: Document,\n overridden: (name: string) => boolean = () => false,\n root: Element = doc.documentElement,\n): 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, root);\n const used = usedCssVars(doc, root);\n return [...names]\n .sort()\n .map((name) => ({ name, value: values.get(name) ?? '', overridden: overridden(name), used: used.has(name) }));\n}\n\nfunction resolveValues(doc: Document, names: Iterable<string>, root: Element): Map<string, string> {\n const view = doc.defaultView;\n const values = new Map<string, string>();\n if (!view) return values;\n const own = view.getComputedStyle(root);\n const missing: string[] = [];\n for (const name of names) {\n const value = own.getPropertyValue(name).trim();\n if (value) values.set(name, value);\n else missing.push(name);\n }\n const under = root === doc.documentElement ? (doc.body ?? root) : root;\n for (const el of missing.length > 0 ? Array.from(under.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, root: Element = doc.documentElement): string {\n return resolveValues(doc, [name], root).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 selector = `:is(${scope}):not(#fg-overrides)`;\n /** Each declaration goes through the rule's own CSSOM, which drops what the browser would not take as one value,\n * and the text is written back from what it kept; an override that could close the rule is never offered. */\n const write = () => {\n style.textContent = values.size > 0 ? `${selector} {}` : '';\n const rule = style.sheet?.cssRules[0] as CSSStyleRule | undefined;\n if (!rule) return;\n for (const [name, value] of values) if (isSafeOverride(name, value)) rule.style.setProperty(name, value);\n const decls = [...values.keys()].flatMap((name) => {\n const value = rule.style.getPropertyValue(name).trim();\n return value && isSafeOverride(name, value) ? [` ${name}: ${value};`] : [];\n });\n style.textContent = decls.length > 0 ? `${selector} {\\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","/** What a setup's `applyGlobals` is handed: the element the globals apply to, and a way to style it alone. */\nexport interface GlobalsTarget {\n /** A frame document's root, or one story's host in the workshop document. */\n root: HTMLElement;\n /** A selector matching `root` and nothing else, so a rule written under it reaches only this target. */\n scope: string;\n /** Replaces the CSS forge keeps for this target. */\n style: (css: string) => void;\n}\n\n/** A target over `root`, owning one `<style>` in the document's head; `dispose` removes it. */\nexport function createGlobalsTarget(root: HTMLElement, scope: string): GlobalsTarget & { dispose: () => void } {\n const doc = root.ownerDocument;\n let style: HTMLStyleElement | null = null;\n return {\n root,\n scope,\n style(css) {\n if (!style) {\n style = doc.createElement('style');\n style.setAttribute('data-fg-globals', scope);\n doc.head.append(style);\n }\n style.textContent = css;\n },\n dispose() {\n style?.remove();\n style = null;\n },\n };\n}\n","import { useVisibleRaf, type VisibleRafTarget } from '@weasel-js/core';\nimport { useEffect, useRef, useSyncExternalStore } from 'react';\nimport type { Clock } from './clock';\n\nconst NEVER = () => () => {};\nconst notPlaying = () => false;\n\n/** Drives `clock` from frames while it plays. Frames stop while the page or `target` is out of sight, and the time\n * spent there is dropped rather than arriving as one long frame. */\nexport function useClockLoop(clock: Clock | null, target?: VisibleRafTarget): void {\n const playing = useSyncExternalStore(clock?.subscribe ?? NEVER, clock ? () => clock.get().playing : notPlaying);\n const last = useRef<number | null>(null);\n const raf = useVisibleRaf(\n (now, raf) => {\n if (!clock) return;\n const prev = last.current;\n last.current = now;\n if (prev !== null) clock.tick(now - prev);\n if (clock.get().playing) raf.request();\n },\n {\n ...(target ? { target } : {}),\n onResume: () => {\n last.current = null;\n },\n },\n );\n useEffect(() => {\n if (!playing) return;\n last.current = null;\n raf.request();\n return () => raf.cancel();\n }, [playing, raf]);\n}\n","import { createEmitter } from '@weasel-js/registry';\n\n/** What a story declares to get a playhead. Times are in ms, as `@weasel-js/ui`'s timeline components take them. */\nexport interface TimelineSpec {\n /** How long the span runs. */\n duration: number;\n /** Where the span begins; below zero gives a lead-in before the story's zero. A fresh trial opens here. Default 0. */\n start?: number;\n /** Whether playing past the end wraps back to `start`. Default true. */\n loop?: boolean;\n /** Playback speed multiplier. Default 1. */\n rate?: number;\n}\n\n/** The span a playhead may stand in, in ms. */\nexport interface Span {\n start: number;\n end: number;\n}\n\n/** Everything a clock holds. */\nexport interface ClockState {\n /** The playhead, in ms, always inside `span`. */\n time: number;\n playing: boolean;\n loop: boolean;\n rate: number;\n span: Span;\n}\n\n/** A span replacing the declared one at runtime, as `StoryTimeline.setSpan` takes it. */\nexport type SpanOverride = Pick<TimelineSpec, 'duration' | 'start'>;\n\nexport function spanOf(spec: SpanOverride): Span {\n const start = Number.isFinite(spec.start) ? (spec.start as number) : 0;\n const duration = Number.isFinite(spec.duration) && spec.duration > 0 ? spec.duration : 0;\n return { start, end: start + duration };\n}\n\nexport function clampTime(span: Span, t: number): number {\n if (Number.isNaN(t)) return span.start;\n return Math.min(span.end, Math.max(span.start, t));\n}\n\n/** `state` after `elapsed` ms of wall time. Past the end it wraps when looping, and otherwise stops there, paused. */\nexport function advance(state: ClockState, elapsed: number): ClockState {\n if (!state.playing) return state;\n const { start, end } = state.span;\n const length = end - start;\n if (length <= 0) return { ...state, time: start, playing: false };\n const next = state.time + elapsed * state.rate;\n if (next <= end) return { ...state, time: next };\n if (!state.loop) return { ...state, time: end, playing: false };\n return { ...state, time: start + ((next - start) % length) };\n}\n\nconst validRate = (rate: number | undefined): rate is number => typeof rate === 'number' && Number.isFinite(rate) && rate > 0;\n\n/** A story's clock: its state as an external store, and the moves the transport and the story make on it. */\nexport interface Clock {\n get(): ClockState;\n subscribe(listener: () => void): () => void;\n play(): void;\n pause(): void;\n seek(time: number): void;\n /**\n * Pauses at `time`, asked for from outside the story — a URL, a persisted value — and keeps asking: every span\n * change clamps it afresh, so a span that only arrives later can still hold it, until play, a seek or another\n * request moves the playhead. Null asks for the span's start, wherever it ends up.\n */\n request(time: number | null): void;\n /** The requested time while the span cannot hold it yet, or null. Whatever echoes the playhead outward waits on it. */\n pending(): number | null;\n setLoop(loop: boolean): void;\n setRate(rate: number): void;\n /** Replaces the declared span until called with null. */\n setSpan(span: SpanOverride | null): void;\n /** The story's declaration changed, as after an edit or a new config. Only its span is taken up. */\n declare(spec: TimelineSpec): void;\n /** Advances a playing clock by `elapsed` ms of wall time. */\n tick(elapsed: number): void;\n}\n\n/** Where a request puts the playhead in `span`; null asks for its start. */\nconst placed = (span: Span, requested: number | null): number =>\n requested === null ? span.start : clampTime(span, requested);\n\n/** A clock for `spec`, paused at a request for `initial`, which is the span start when none is given. */\nexport function createClock(spec: TimelineSpec, initial?: number | null): Clock {\n let declared = spanOf(spec);\n let override: Span | null = null;\n // Until something moves the playhead it stands where it was asked to, re-placed in every new span, so a span set\n // after mount still opens at the start — or at a URL's time beyond the span declared before it.\n let requested: { time: number | null } | null = { time: initial ?? null };\n let state: ClockState = {\n time: placed(declared, requested.time),\n playing: false,\n loop: spec.loop ?? true,\n rate: validRate(spec.rate) ? spec.rate : 1,\n span: declared,\n };\n const changed = createEmitter();\n const pendingIn = (at: ClockState): number | null =>\n requested && requested.time !== null && requested.time !== at.time ? requested.time : null;\n // What echoes the playhead outward waits on a pending request, so its coming and going notifies as a move does.\n let pending = pendingIn(state);\n\n const set = (next: ClockState): void => {\n const nextPending = pendingIn(next);\n if (\n nextPending === pending &&\n next.time === state.time &&\n next.playing === state.playing &&\n next.loop === state.loop &&\n next.rate === state.rate &&\n next.span.start === state.span.start &&\n next.span.end === state.span.end\n )\n return;\n state = next;\n pending = nextPending;\n changed.emit();\n };\n const moved = (next: ClockState): void => {\n requested = null;\n set(next);\n };\n const respan = (): void => {\n const span = override ?? declared;\n set({ ...state, span, time: requested ? placed(span, requested.time) : clampTime(span, state.time) });\n };\n\n return {\n get: () => state,\n subscribe: changed.subscribe,\n play() {\n if (state.playing) return;\n // Playing from the end starts over, as a player's play button does.\n moved({ ...state, playing: true, time: state.time >= state.span.end ? state.span.start : state.time });\n },\n pause: () => set({ ...state, playing: false }),\n seek: (time) => moved({ ...state, time: clampTime(state.span, time) }),\n request(time) {\n requested = { time: Number.isNaN(time) ? null : time };\n set({ ...state, playing: false, time: placed(state.span, requested.time) });\n },\n pending: () => pending,\n setLoop: (loop) => set({ ...state, loop }),\n setRate(rate) {\n if (validRate(rate)) set({ ...state, rate });\n },\n setSpan(span) {\n override = span ? spanOf(span) : null;\n respan();\n },\n declare(next) {\n declared = spanOf(next);\n respan();\n },\n tick(elapsed) {\n if (state.playing) moved(advance(state, elapsed));\n },\n };\n}\n","import { useLatest } from '@weasel-js/core';\nimport { type ReactNode, useContext, useEffect, useState } from 'react';\nimport type { LoadedStory } from '../story/types';\nimport { type Clock, createClock, type TimelineSpec } from './clock';\nimport { ClockContext } from './context';\nimport { useClockLoop } from './useClockLoop';\n\n/**\n * A clock for a story declaring `spec`, kept across renders and redeclared when the span it declares changes. It is\n * made when a declaration appears and dropped when it goes, as an edit can do either. `initial` is read only when\n * the clock is made.\n */\nexport function useStoryClock(spec: TimelineSpec | null, initial: () => number | null): Clock | null {\n const [clock, setClock] = useState(() => (spec ? createClock(spec, initial()) : null));\n let current = clock;\n if (spec && !clock) {\n current = createClock(spec, initial());\n setClock(current);\n } else if (!spec && clock) {\n current = null;\n setClock(null);\n }\n const latest = useLatest(spec);\n const spanKey = spec ? `${spec.start ?? 0}:${spec.duration}` : null;\n useEffect(() => {\n if (current && latest.current) current.declare(latest.current);\n }, [current, spanKey, latest]);\n return current;\n}\n\nconst NO_INITIAL = () => null;\n\nfunction OwnClock({ spec, children }: { spec: TimelineSpec; children: ReactNode }) {\n const clock = useStoryClock(spec, NO_INITIAL);\n useClockLoop(clock);\n return <ClockContext.Provider value={clock}>{children}</ClockContext.Provider>;\n}\n\n/**\n * Gives a story declaring a timeline a clock of its own where nothing above supplies one — an index page, a frame, a\n * story test. It stands paused at the span's start, with no transport, until the story moves it.\n */\nexport function WithStoryClock({ story, config, children }: { story: LoadedStory; config: unknown; children: ReactNode }) {\n const outer = useContext(ClockContext);\n if (outer || !story.timeline) return children;\n return <OwnClock spec={story.timeline(config)}>{children}</OwnClock>;\n}\n","import { Component, type ReactNode } from 'react';\nimport type { Decorator, LoadedStory, StoryContext } from '../story/types';\nimport { WithStoryClock } from '../timeline/StoryClock';\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 (\n <WithStoryClock story={story} config={ctx.config}>\n <Decorated story={story} ctx={ctx} decorators={decorators} />\n </WithStoryClock>\n );\n }\n}\n","import { type ConfigNode, type ConfigSchema, type ConfigShape, f, ObjectNode, UnionNode } from '@weasel-js/labkit/config';\nimport { isPlainObject } from '@weasel-js/core';\nimport { iconFromData } from '@weasel-js/ui/components/Icon';\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/**\n * Storybook's `SBType`, as far as forge reads it: the shape of an arg's value. A control is built from the parts of\n * an array, an object or a union, and a union of objects that each pin one field to a string is edited as a choice\n * of that string, with the chosen object's own fields under it.\n */\nexport type ArgShape =\n | { name: 'boolean' | 'string' | 'number' }\n | { name: 'enum'; value: readonly string[] }\n | { name: 'array'; value: ArgShape }\n | { name: 'object'; value: Readonly<Record<string, ArgShape>> }\n | { name: 'union'; value: readonly ArgShape[] };\n\n/** A CSF `argTypes` entry, as far as forge reads it. */\nexport interface ArgType {\n name?: string;\n description?: string;\n type?: ArgShape;\n control?:\n | string\n | false\n | {\n type?: string;\n min?: number;\n max?: number;\n step?: number;\n /** forge's own: a qualified icon ref (`ui:variantSolid`) per option, drawn in place of its label. */\n icons?: Readonly<Record<string, string>>;\n };\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 icons?: Readonly<Record<string, string>>;\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, icons: control?.icons };\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\ntype ObjectShape = Extract<ArgShape, { name: 'object' }>;\n\n/**\n * A union's members by the string each pins one field to, with that field: the first field every member pins.\n * Members pinning the same string are one variant, holding the fields of each.\n */\nfunction variantsOf(members: readonly ArgShape[]): { tag: string; variants: Map<string, ObjectShape> } | null {\n const objects = members.filter((m): m is ObjectShape => m.name === 'object');\n if (objects.length !== members.length || objects.length === 0) return null;\n const pinned = (m: ObjectShape, key: string) => {\n const field = m.value[key];\n return field?.name === 'enum' && field.value.length === 1 ? field.value[0] : undefined;\n };\n const tag = Object.keys(objects[0]!.value).find((key) => objects.every((m) => pinned(m, key) !== undefined));\n if (tag === undefined) return null;\n const variants = new Map<string, ObjectShape>();\n for (const member of objects) {\n const name = pinned(member, tag)!;\n const held = variants.get(name)?.value ?? {};\n const added = Object.entries(member.value).filter(([key]) => !(key in held));\n variants.set(name, { name: 'object', value: { ...held, ...Object.fromEntries(added) } });\n }\n return { tag, variants };\n}\n\nfunction fieldsOf(shape: ObjectShape, value: unknown, omit?: string): Record<string, Leaf> | null {\n const held = isPlainObject(value) ? value : {};\n const fields: Record<string, Leaf> = {};\n for (const [key, field] of Object.entries(shape.value)) {\n if (key === omit) continue;\n const leaf = shaped(field, held[key]);\n if (leaf) fields[key] = leaf;\n }\n return Object.keys(fields).length > 0 ? fields : null;\n}\n\n/** A leaf editing a value of `shape`, starting at `value`; null for a shape no control can edit. */\nfunction shaped(shape: ArgShape, value: unknown): Leaf | null {\n switch (shape.name) {\n case 'boolean':\n return f.boolean(value as boolean);\n case 'string':\n return f.string(value as string);\n case 'number':\n return f.number(value as number);\n case 'enum':\n return shape.value.length > 0 ? f.enum(value as string, shape.value) : null;\n case 'array': {\n const item = shaped(shape.value, undefined);\n return item ? (f.list(Array.isArray(value) ? value : [], item) as unknown as Leaf) : null;\n }\n case 'object': {\n const fields = fieldsOf(shape, value);\n if (!fields) return null;\n const node = f.object(fields);\n return new ObjectNode(isPlainObject(value) ? value : node.default, node.annotations, node.options) as unknown as Leaf;\n }\n case 'union': {\n const union = variantsOf(shape.value);\n if (!union) return null;\n const { tag, variants } = union;\n const held = isPlainObject(value) ? value[tag] : undefined;\n const nodes = Object.fromEntries(\n [...variants].map(([name, member]) => [name, f.object(fieldsOf(member, held === name ? value : undefined, tag) ?? {})]),\n );\n const node = f.union(tag, nodes);\n const start = typeof held === 'string' && variants.has(held) ? value : node.default;\n return new UnionNode(start, node.annotations, node.options) as unknown as Leaf;\n }\n default:\n return null;\n }\n}\n\n/** A leaf for an object-valued arg: from its argType's shape where one is given and editable, else a JSON leaf. */\nfunction structured(argType: ArgType, value: unknown): Leaf | null {\n return (argType.type ? shaped(argType.type, value) : null) ?? inferred(value);\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 ? structured(argType, value) : null;\n const { icons } = control;\n const node = f.enum(\n def<string>(),\n icons ? options.map((value) => {\n const ref = iconFromData(icons[value]);\n return { value, label: value, ...(ref ? { icon: ref } : {}) };\n }) : options,\n );\n return control.type === 'radio' || control.type === 'inline-radio' ? node.radio() : node;\n }\n case 'object':\n return has ? (argType.type ? shaped(argType.type, value) : null) ?? 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 type { TimelineSpec } from './clock';\n\nconst isSpec = (value: unknown): value is TimelineSpec =>\n !!value && typeof value === 'object' && typeof (value as { duration?: unknown }).duration === 'number';\n\n/** A declared timeline as a function of config: a spec stands for itself at every config, a function is called with\n * the config. Anything else declares none. `adapt` turns the trial's config into what the function is handed. */\nexport function timelineOf(\n value: unknown,\n adapt: (config: unknown) => unknown = (config) => config,\n): ((config: unknown) => TimelineSpec) | null {\n if (isSpec(value)) return () => value;\n if (typeof value === 'function') return (config) => (value as (input: unknown) => TimelineSpec)(adapt(config));\n return null;\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 '@weasel-js/core';\nimport { withUnsent } from './portSafe';\nimport { PROP_ARG_TYPES_EXPORT } from './propArgTypes';\nimport { timelineOf } from '../timeline/declare';\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. `title` is the index entry's, which wins over the meta's own: the\n * index reads the meta without running it and falls back to the auto title for one it cannot read, so taking the\n * meta's here would give one story two ids. `parameters` are the project's, under the meta's and each story's.\n */\nexport function loadCsfModule(\n mod: Record<string, unknown>,\n title: string,\n projectParameters: Record<string, unknown> = {},\n): LoadedStory[] {\n const meta = (isPlainObject(mod.default) ? mod.default : {}) as Annotations;\n const stories: LoadedStory[] = [];\n const propArgTypes = isPlainObject(mod[PROP_ARG_TYPES_EXPORT]) ? (mod[PROP_ARG_TYPES_EXPORT] as Record<string, ArgType>) : undefined;\n\n for (const [exportName, value] of Object.entries(mod)) {\n if (exportName === PROP_ARG_TYPES_EXPORT) continue;\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 render = spec.render ?? meta.render;\n // A render that takes no args draws the same thing whatever a prop's control says.\n const fromProps = render === undefined || render.length > 0 ? propArgTypes : undefined;\n const config = argsToSchema(\n args,\n combineParameters(fromProps, 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 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 forgeParams = parameters.forge as { isolate?: unknown; timeline?: unknown } | undefined;\n const isolate = forgeParams?.isolate;\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 isolate: typeof isolate === 'string' ? isolate : null,\n play: play\n ? ({ canvasElement, config, globals }: PlayContext) =>\n play({ ...csfContext(config, globals), canvasElement, step: async (_label, fn) => fn() })\n : null,\n timeline: timelineOf(forgeParams?.timeline, (config) => csfContext(config, {}).args),\n });\n }\n return stories;\n}\n","import { f } from '@weasel-js/labkit/config';\nimport { isNative } from './define';\nimport { storyId, storyNameFromExport } from './ids';\nimport { timelineOf } from '../timeline/declare';\nimport type { LoadedStory, MetaSpec, StorySpec } from './types';\n\n/**\n * Normalizes a module written with `meta` and `story`; exports that are not stories are skipped. `title` is the index\n * entry's, which wins over the meta's own: the index reads the meta without running it and can miss it, so taking\n * the meta's here would give one story two titles.\n */\nexport function loadNativeModule(mod: Record<string, unknown>, title: string): LoadedStory[] {\n const metaSpec: MetaSpec = isNative(mod.default, 'meta') ? (mod.default as MetaSpec) : {};\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 isolate: spec.isolate ?? metaSpec.isolate ?? null,\n play: spec.play ?? null,\n timeline: timelineOf(spec.timeline ?? metaSpec.timeline),\n });\n }\n return stories;\n}\n","import { loadCsfModule } from '../csf/loadCsfModule';\nimport { isNative } from './define';\nimport { loadNativeModule } from './native';\nimport type { IndexRender, LoadedStory } from './types';\n\n/**\n * A story module's stories: a module whose default export is a forge `meta` is native, anything else is CSF under\n * `parameters`. `title` is the module's index entry title, which every story takes as given.\n */\nexport function loadStories(\n mod: Record<string, unknown>,\n title: string,\n parameters?: Record<string, unknown>,\n): LoadedStory[] {\n return isNative(mod.default, 'meta')\n ? loadNativeModule(mod, title)\n : loadCsfModule(mod, title, parameters);\n}\n\n/** A module's own index page: a native meta's `index`, or a CSF meta's `parameters.forge.index`. */\nexport function indexRenderOf(mod: Record<string, unknown>): IndexRender | null {\n const meta = mod.default as { index?: unknown; parameters?: { forge?: { index?: unknown } } } | undefined;\n const render = isNative(meta, 'meta') ? meta?.index : meta?.parameters?.forge?.index;\n return typeof render === 'function' ? (render as IndexRender) : null;\n}\n","import { type RefObject, useEffect, useState } from 'react';\n\n/** How far past the viewport a trial's story stays mounted, so a small scroll back does not reload it. */\nexport const IN_VIEW_MARGIN = '50%';\n\n/**\n * Whether `ref`'s element lies within `margin` of its document's viewport; true where the browser cannot say.\n * Decided by where the element is, not by whether any of it shows: `isIntersecting` is false too for an element an\n * `overflow` ancestor clips away, as a narrow lab tile does to its content while the tiling changes. `initial` is\n * the answer before the browser has given one: false for content too costly to mount everywhere at once.\n */\nexport function useNearViewport(ref: RefObject<Element | null>, margin: string, initial = true): boolean {\n const [near, setNear] = useState(() => initial || typeof IntersectionObserver === 'undefined');\n useEffect(() => {\n const el = ref.current;\n if (!el || typeof IntersectionObserver === 'undefined') return;\n // A fresh observe always reports, wherever the element is.\n const recheck = () => {\n observer.unobserve(el);\n observer.observe(el);\n };\n let watching = false;\n const watch = (on: boolean) => {\n if (on === watching) return;\n watching = on;\n if (on) {\n document.addEventListener('scroll', recheck, { capture: true, passive: true });\n window.addEventListener('resize', recheck);\n } else {\n document.removeEventListener('scroll', recheck, { capture: true });\n window.removeEventListener('resize', recheck);\n }\n };\n const observer = new IntersectionObserver(\n (entries) => {\n const last = entries.at(-1);\n if (!last) return;\n const root = last.rootBounds;\n const box = last.boundingClientRect;\n setNear(\n root\n ? box.bottom >= root.top && box.top <= root.bottom && box.right >= root.left && box.left <= root.right\n : last.isIntersecting,\n );\n // While nothing of it intersects, a clip can hide every move from the observer, so ask again on each scroll.\n watch(Boolean(root) && !last.isIntersecting);\n },\n { root: document, rootMargin: margin },\n );\n observer.observe(el);\n return () => {\n observer.disconnect();\n watch(false);\n };\n }, [ref, margin]);\n return near;\n}\n","import { useLatest } from '@weasel-js/core';\nimport { type RefObject, useLayoutEffect, useRef } from 'react';\nimport { createOverrides, type Overrides } from '../frame/cssVars';\nimport type { FrameSetup } from '../frame/FrameController';\nimport { createGlobalsTarget } from '../frame/globalsTarget';\nimport type { Globals } from '../protocol/messages';\nimport type { CssOverrides } from './cssVars/overrides';\n\n/** A selector matching only the element carrying `id`. */\nexport const scopeOf = (id: string) => `[data-fg-host=\"${id}\"]`;\n\n/**\n * The conditions a host element lives under: its globals target, and its CSS variable overrides rule with the\n * trial's persisted overrides put back and kept in step. Everything is scoped to `hostId`; no registry connection.\n * The returned ref holds the overrides while `host` is set.\n */\nexport function useHostConditions(\n host: HTMLElement | null,\n opts: { hostId: string; globals: Globals; overrides: CssOverrides; setup: FrameSetup },\n): RefObject<Overrides | null> {\n const { hostId, globals, overrides: persisted, setup } = opts;\n const latest = useLatest({ setup });\n const overridesRef = useRef<Overrides | null>(null);\n\n useLayoutEffect(() => {\n if (!host) return;\n const scope = scopeOf(hostId);\n const { cssVarsScope } = latest.current.setup;\n overridesRef.current = createOverrides(\n host.ownerDocument,\n cssVarsScope ? `${scope}, ${scope} :is(${cssVarsScope})` : scope,\n );\n return () => {\n overridesRef.current?.dispose();\n overridesRef.current = null;\n };\n }, [host, hostId, latest]);\n\n const applied = useRef<Record<string, string>>({});\n useLayoutEffect(() => {\n const overrides = overridesRef.current;\n if (!overrides) return;\n for (const name of Object.keys(applied.current)) if (!(name in persisted)) overrides.set(name, null);\n for (const [name, value] of Object.entries(persisted)) overrides.set(name, value);\n applied.current = { ...persisted };\n }, [host, hostId, persisted]);\n\n useLayoutEffect(() => {\n if (!host) return;\n const target = createGlobalsTarget(host, scopeOf(hostId));\n latest.current.setup.applyGlobals?.(globals, target);\n return () => target.dispose();\n }, [host, hostId, globals, latest]);\n\n return overridesRef;\n}\n"]}
@@ -77,5 +77,5 @@ function withGlobals(schema, declarations) {
77
77
  }
78
78
 
79
79
  export { FOLLOW_APP, GLOBALS_KEY, PLAYHEAD_KEY, effectiveGlobals, followApp, isForgePath, isGlobalsPath, labGlobals, labOptions, storyConfig, withGlobals };
80
- //# sourceMappingURL=chunk-7BQPHMA2.js.map
81
- //# sourceMappingURL=chunk-7BQPHMA2.js.map
80
+ //# sourceMappingURL=chunk-3BAM6M26.js.map
81
+ //# sourceMappingURL=chunk-3BAM6M26.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shell/globals.ts"],"names":["from"],"mappings":";;;;AA2CO,IAAM,WAAA,GAAc;AAEpB,IAAM,UAAA,GAAa,KAAA;AAEnB,IAAM,UAAA,GAAa;AAE1B,IAAM,UAAA,GAAa,EAAE,KAAA,EAAO,UAAA,EAAY,OAAO,KAAA,EAAM;AAErD,IAAM,QAAA,GAAW,aAAA;AAEV,IAAM,aAAA,GAAgB,CAAC,IAAA,KAA0B,IAAA,KAAS,eAAe,IAAA,CAAK,UAAA,CAAW,CAAA,EAAG,WAAW,CAAA,CAAA,CAAG;AAG1G,IAAM,YAAA,GAAe;AAG5B,IAAM,6BAAkC,IAAI,GAAA,CAAI,CAAC,WAAA,EAAa,YAAY,CAAC,CAAA;AAGpE,IAAM,WAAA,GAAc,CAAC,IAAA,KAA0B,UAAA,CAAW,GAAA,CAAI,KAAK,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAE;AAGjF,SAAS,YAAA,CAAa,aAAgC,OAAA,EAAgD;AAC3G,EAAA,MAAM,EAAE,OAAM,GAAI,WAAA;AAClB,EAAA,OAAO,KAAA,GAAQ,WAAA,CAAY,OAAA,CAAQ,MAAA,CAAO,CAAC,MAAA,KAAW,KAAA,CAAM,MAAA,CAAO,KAAA,EAAO,OAAO,CAAC,CAAA,GAAI,WAAA,CAAY,OAAA;AACpG;AAGO,SAAS,UAAA,CAAW,aAAgC,OAAA,EAAgD;AACzG,EAAA,MAAM,KAAA,GAAQ,YAAA,CAAa,WAAA,EAAa,OAAO,CAAA;AAC/C,EAAA,OAAO,YAAY,OAAA,GAAU,CAAC,UAAA,EAAY,GAAG,KAAK,CAAA,GAAI,KAAA;AACxD;AAGO,SAAS,SAAA,CAAU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AAA,CAAE,KAAA,CAAM,YAAY,KAAK;AAAA,KAC1G;AAAA,GACH;AAEA,EAAA,MAAM,QAAQ,CAAA,CAAE,KAAA,CAAM,MAAM,CAAA,CAAE,MAAM,EAAE,CAAA,CAAE,OAAA,CAAQ,SAAA,EAAW,EAAE,MAAA,EAAQ,QAAA,EAAU,MAAM,OAAA,EAAS,SAAA,EAAW,mBAAmB,CAAA;AAC5H,EAAA,OAAO,CAAA,CAAE,MAAA,CAAO,EAAE,GAAG,MAAA,CAAO,OAAO,CAAC,WAAW,GAAG,KAAA,EAAO,CAAA;AAC3D","file":"chunk-3BAM6M26.js","sourcesContent":["import { isPlainObject } from '@weasel-js/core';\nimport type { IconRef } from '@weasel-js/icons';\nimport type { LabMode } from '@weasel-js/labkit';\nimport { type ConfigSchema, f } from '@weasel-js/labkit/config';\nimport type { Globals } from '../protocol/messages';\n\n/** One global the workshop's toolbar sets for every story, and a trial may pin for its own. */\nexport interface GlobalDeclaration {\n label: string;\n options: readonly { value: string; label: string }[];\n default: string;\n /** Another global's key: the toolbar shows this one in a popover beside that one rather than in the bar itself. */\n under?: string;\n /** The glyph on the button opening the globals declared `under` this one. Default `core:tune`. */\n icon?: IconRef;\n /**\n * Whether the toolbar offers `value` given the lab's other values; every option shows when absent. `globals` is\n * resolved without any declaration's `shows`, so one `shows` cannot depend on another's outcome.\n */\n shows?: (value: string, globals: Globals) => boolean;\n /**\n * What this global reads from the lab's own chrome. Given, the lab's value may be `App` (`FOLLOW_APP`), offered\n * first, and while it is the global follows that chrome control, as the header's mode switch sets it. A trial's\n * pin follows the lab or names a value; it cannot follow the app on its own.\n */\n follows?: (chrome: LabChrome) => string;\n /**\n * The value opposite `value`, for the global a lens's opposite-mode comparison flips (`ShellConfig.loupe`'s\n * `modeGlobal`); undefined when it has none. `App` and `auto` are resolved to the mode they show before this is\n * asked. Absent, the lens swaps `light` and `dark`.\n */\n opposite?: (value: string, globals: Globals) => string | undefined;\n}\n\n/** The lab chrome's own settings a global can follow. */\nexport interface LabChrome {\n mode: LabMode;\n}\n\n/** The shell config's `globals`: each declaration by the key stories read it under. */\nexport type GlobalDeclarations = Readonly<Record<string, GlobalDeclaration>>;\n\n/** The config group every story schema gains, holding the trial's pins. A story never sees it. */\nexport const GLOBALS_KEY = '$globals';\n/** A pin's value when the trial follows the lab. */\nexport const FOLLOW_LAB = 'lab';\n/** A lab value, for a declaration that `follows` the app, meaning whatever the app's chrome is set to. */\nexport const FOLLOW_APP = 'app';\n\nconst APP_OPTION = { value: FOLLOW_APP, label: 'App' } as const;\n\nconst isRecord = isPlainObject;\n\nexport const isGlobalsPath = (path: string): boolean => path === GLOBALS_KEY || path.startsWith(`${GLOBALS_KEY}.`);\n\n/** The config key a timeline story's paused playhead is kept under, so labkit persists and snapshots it. */\nexport const PLAYHEAD_KEY = '$playhead';\n\n/** Config keys forge owns: a story neither sees nor writes them. */\nconst FORGE_KEYS: ReadonlySet<string> = new Set([GLOBALS_KEY, PLAYHEAD_KEY]);\n\n/** Whether a config path lies under a key forge owns. */\nexport const isForgePath = (path: string): boolean => FORGE_KEYS.has(path.split('.')[0]!);\n\n/** The options the toolbar offers for `declaration` at `globals`. */\nexport function shownOptions(declaration: GlobalDeclaration, globals: Globals): GlobalDeclaration['options'] {\n const { shows } = declaration;\n return shows ? declaration.options.filter((option) => shows(option.value, globals)) : declaration.options;\n}\n\n/** The options the lab's own control offers: `shownOptions`, after `App` where the declaration follows the app. */\nexport function labOptions(declaration: GlobalDeclaration, globals: Globals): GlobalDeclaration['options'] {\n const shown = shownOptions(declaration, globals);\n return declaration.follows ? [APP_OPTION, ...shown] : shown;\n}\n\n/** `values` with each `App` replaced by what its declaration reads from `chrome`; `values` itself when none is. */\nexport function followApp(declarations: GlobalDeclarations, values: Globals, chrome: LabChrome): Globals {\n const followed = Object.entries(declarations).flatMap(([key, { follows }]) =>\n follows && values[key] === FOLLOW_APP ? [[key, follows(chrome)] as const] : [],\n );\n return followed.length === 0 ? values : { ...values, ...Object.fromEntries(followed) };\n}\n\n/**\n * The lab's values from what was stored: declared keys only. A value no option offers falls back to the default, and\n * one its declaration's `shows` hides falls back to the shown option nearest it in `options`, the earlier on a tie.\n */\nexport function labGlobals(declarations: GlobalDeclarations, stored: unknown): Globals {\n const from = isRecord(stored) ? stored : {};\n const offered: Globals = Object.fromEntries(\n Object.entries(declarations).map(([key, declaration]) => {\n const value = from[key];\n const known =\n declaration.options.some((option) => option.value === value) || (declaration.follows && value === FOLLOW_APP);\n return [key, known ? value : declaration.default];\n }),\n );\n return Object.fromEntries(\n Object.entries(declarations).map(([key, declaration]) => {\n const shown = shownOptions(declaration, offered);\n const value = offered[key];\n if (value === FOLLOW_APP && declaration.follows) return [key, value];\n if (!declaration.shows || shown.length === 0 || shown.some((option) => option.value === value)) return [key, value];\n const at = (v: unknown) => declaration.options.findIndex((option) => option.value === v);\n const from = at(value);\n const nearest = shown.reduce((best, option) =>\n Math.abs(at(option.value) - from) < Math.abs(at(best.value) - from) ? option : best,\n );\n return [key, nearest.value];\n }),\n );\n}\n\n/** The lab's values, overridden by the pins in a trial's config that do not follow the lab. */\nexport function effectiveGlobals(lab: Globals, pins: unknown): Globals {\n if (!isRecord(pins)) return lab;\n const pinned = Object.entries(pins).filter(([key, value]) => key in lab && value !== FOLLOW_LAB);\n return pinned.length === 0 ? lab : { ...lab, ...Object.fromEntries(pinned) };\n}\n\n/**\n * The config a story receives: the trial's, without the keys forge owns. Returns `previous` when every other entry is\n * the same, so a change to a pin or the playhead alone is not a change to the story's config.\n */\nexport function storyConfig(config: unknown, previous?: unknown): unknown {\n if (!isRecord(config) || !Object.keys(config).some((key) => FORGE_KEYS.has(key))) return config;\n const rest = Object.fromEntries(Object.entries(config).filter(([key]) => !FORGE_KEYS.has(key)));\n if (isRecord(previous)) {\n const keys = Object.keys(rest);\n if (keys.length === Object.keys(previous).length && keys.every((key) => rest[key] === previous[key])) return previous;\n }\n return rest;\n}\n\n/** `schema` with a `$globals` group appended: one leaf per declaration, following the lab until pinned. */\nexport function withGlobals(schema: ConfigSchema<unknown>, declarations: GlobalDeclarations): ConfigSchema<unknown> {\n const entries = Object.entries(declarations);\n if (entries.length === 0) return schema;\n const leaves = Object.fromEntries(\n entries.map(([key, declaration]) => [\n key,\n f.enum(FOLLOW_LAB, [{ value: FOLLOW_LAB, label: 'Lab' }, ...declaration.options]).label(declaration.label),\n ]),\n );\n // An empty group name contributes rows without a heading of its own, under the section's.\n const group = f.group(leaves).label('').section('Globals', { layout: 'inline', pack: 'pairs', className: 'fg-globals-pins' });\n return f.schema({ ...schema.nodes, [GLOBALS_KEY]: group }) as ConfigSchema<unknown>;\n}\n"]}