@weasel-js/forge 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -0
- package/dist/{FrameController-RdGggdGA.d.ts → FrameController-BH8xJHZ8.d.ts} +36 -1
- package/dist/{chunk-NYBMOSSR.js → chunk-5N4YP5HS.js} +166 -10
- package/dist/chunk-5N4YP5HS.js.map +1 -0
- package/dist/chunk-CJX3W5HY.js +151 -0
- package/dist/chunk-CJX3W5HY.js.map +1 -0
- package/dist/{chunk-SEK6EKHO.js → chunk-GHTVXHNJ.js} +72 -10
- package/dist/chunk-GHTVXHNJ.js.map +1 -0
- package/dist/{chunk-KIFCYY4F.js → chunk-JQD3MVUQ.js} +4 -4
- package/dist/{chunk-KIFCYY4F.js.map → chunk-JQD3MVUQ.js.map} +1 -1
- package/dist/chunk-KJGXJD3U.js +15 -0
- package/dist/chunk-KJGXJD3U.js.map +1 -0
- package/dist/chunk-L5XM5VKB.js +47 -0
- package/dist/chunk-L5XM5VKB.js.map +1 -0
- package/dist/{chunk-YKN3IAEX.js → chunk-MGQWCPYE.js} +4 -24
- package/dist/chunk-MGQWCPYE.js.map +1 -0
- package/dist/{chunk-JNJGIUYU.js → chunk-NI5FYQHW.js} +8 -5
- package/dist/chunk-NI5FYQHW.js.map +1 -0
- package/dist/{config-BJIgUhiI.d.ts → config-DoLWwEb2.d.ts} +5 -1
- package/dist/csf/preview-api.js +2 -1
- package/dist/csf/preview-api.js.map +1 -1
- package/dist/frame/index.css +1 -0
- package/dist/frame/index.css.map +1 -1
- package/dist/frame/index.d.ts +2 -2
- package/dist/frame/index.js +5 -4
- package/dist/frame/index.js.map +1 -1
- package/dist/index.d.ts +79 -4
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/shell/index.css +14 -0
- package/dist/shell/index.css.map +1 -1
- package/dist/shell/index.d.ts +2 -2
- package/dist/shell/index.js +225 -56
- package/dist/shell/index.js.map +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.js +6 -5
- package/dist/test/index.js.map +1 -1
- package/dist/vite/index.js +160 -16
- package/dist/vite/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-JNJGIUYU.js.map +0 -1
- package/dist/chunk-NYBMOSSR.js.map +0 -1
- package/dist/chunk-SEK6EKHO.js.map +0 -1
- package/dist/chunk-Y3WZ2EWR.js +0 -15
- package/dist/chunk-Y3WZ2EWR.js.map +0 -1
- package/dist/chunk-YKN3IAEX.js.map +0 -1
package/README.md
CHANGED
|
@@ -50,6 +50,8 @@ The vite plugin takes two optional config modules:
|
|
|
50
50
|
`style(css)` for a rule that should reach that story alone.
|
|
51
51
|
- `shellConfig` default-exports `defineShellConfig({...})`: lab chrome, control
|
|
52
52
|
renderers, and global declarations. Only the workshop page imports it.
|
|
53
|
+
`title` names the workshop in its header and as the document title
|
|
54
|
+
(default `weaselforge`), and `cssVars: false` leaves out the CSS Vars panel.
|
|
53
55
|
|
|
54
56
|
```ts
|
|
55
57
|
forge({ stories: ['src/**/*.stories.tsx'], frameConfig: 'forge.frame.tsx', shellConfig: 'forge.shell.tsx' });
|
|
@@ -61,6 +63,82 @@ trial's config and state kept; the page itself stays.
|
|
|
61
63
|
Clicking a story in the tree, or reaching one by its URL, shows it in the
|
|
62
64
|
focused trial; Shift-click opens another trial beside it.
|
|
63
65
|
|
|
66
|
+
## Knobs in the URL
|
|
67
|
+
|
|
68
|
+
A story's URL carries its knobs — its args, the trial's controls — after the
|
|
69
|
+
story id, in the hash:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
/#/ui-button--primary?label=Save&look.px=8&disabled=true
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Opening that URL shows the story with those values; every knob it leaves out
|
|
76
|
+
is at its default. Changing a control rewrites the URL in place, without a
|
|
77
|
+
history entry, and a value back at its default leaves the URL. Moving to
|
|
78
|
+
another story starts with no knobs. Typing new knobs into the URL of the open
|
|
79
|
+
story applies them.
|
|
80
|
+
|
|
81
|
+
A knob inside a group is named by its dotted path (`look.px`). Each value is
|
|
82
|
+
read as its control's type, or its default's when the control declares none:
|
|
83
|
+
a number, `true`/`false` (`1`/`0`, or a bare `?disabled`, also work), one of an
|
|
84
|
+
enum's options, a string, or JSON for a list or object. A value that does not
|
|
85
|
+
read as its type, or names no knob, is ignored. `t` is reserved for the
|
|
86
|
+
workshop and is never a knob.
|
|
87
|
+
|
|
88
|
+
The functions behind this are exported from `@weasel-js/forge`, for a host
|
|
89
|
+
building links: `storyHref('ui-button--primary', { label: 'Save', 'look.px': 8 })`
|
|
90
|
+
returns `#/ui-button--primary?label=Save&look.px=8`, and `parseRoute`,
|
|
91
|
+
`paramsToKnobs` and `knobsToParams` read and write the same form against a
|
|
92
|
+
story's schema.
|
|
93
|
+
|
|
94
|
+
## Timelines
|
|
95
|
+
|
|
96
|
+
A story that declares a timeline gets a playhead, and its trial gets a
|
|
97
|
+
transport in the status bar: a scrub bar, play and pause, loop, and rate. Times
|
|
98
|
+
are in ms, as `@weasel-js/ui`'s timeline components take them.
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { story, usePlayhead } from '@weasel-js/forge';
|
|
102
|
+
|
|
103
|
+
function Ball() {
|
|
104
|
+
const t = usePlayhead(); // ms
|
|
105
|
+
return <circle cx={t / 10} cy={10} r={8} />;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const Swing = story({
|
|
109
|
+
timeline: { duration: 4000, start: -500, loop: true, rate: 1 },
|
|
110
|
+
render: () => <svg><Ball /></svg>,
|
|
111
|
+
});
|
|
112
|
+
// CSF: parameters: { forge: { timeline: { duration: 4000 } } }
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The span runs from `start` (default 0; below zero is a lead-in) for `duration`.
|
|
116
|
+
`loop` defaults to true and `rate` to 1. A meta's `timeline` covers every story
|
|
117
|
+
in its file. A function in place of the object is handed the trial's config, or
|
|
118
|
+
a CSF story's args, so the span can follow a control:
|
|
119
|
+
`timeline: (config) => ({ duration: config.seconds * 1000 })`.
|
|
120
|
+
|
|
121
|
+
`usePlayhead()` returns the time, and re-renders only the component that calls
|
|
122
|
+
it. `useTimeline()` returns the whole clock — `time`, `playing`, `span`, `loop`,
|
|
123
|
+
`rate` — with `play`, `pause`, `seek`, `setLoop`, `setRate`, and `setSpan` for a
|
|
124
|
+
span the story learns only once it runs (null goes back to the declared one).
|
|
125
|
+
Either throws in a story that declares no timeline.
|
|
126
|
+
|
|
127
|
+
The clock belongs to the trial, so two trials of one story play independently.
|
|
128
|
+
It runs only while the story's box is on screen and the page is visible. Its
|
|
129
|
+
paused time is kept with the trial, so a reload or a loaded snapshot brings the
|
|
130
|
+
story back there; it is written when the clock stops or moves while stopped,
|
|
131
|
+
never on a playing frame.
|
|
132
|
+
|
|
133
|
+
While the clock is paused off its span's start, the URL holds the playhead in
|
|
134
|
+
seconds, so a paused frame works as a link: `#/<story>?t=1.5`. Opening that URL
|
|
135
|
+
starts the story paused at 1.5s, over any kept time, and a hash change that
|
|
136
|
+
brings a different `t` seeks there and pauses. Playing drops `t` rather than
|
|
137
|
+
rewriting it every frame. Only one trial holds the URL, as for knobs: the
|
|
138
|
+
focused trial when it shows the routed story, else the first that does. An index page, an
|
|
139
|
+
isolated story's frame and a story test show the story paused at its span's
|
|
140
|
+
start, with no transport.
|
|
141
|
+
|
|
64
142
|
## Index pages
|
|
65
143
|
|
|
66
144
|
Every component — every story title — has an index page, opened by clicking
|
|
@@ -186,6 +186,34 @@ type FromFrame = {
|
|
|
186
186
|
seq?: number;
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
+
/** What a story declares to get a playhead. Times are in ms, as `@weasel-js/ui`'s timeline components take them. */
|
|
190
|
+
interface TimelineSpec {
|
|
191
|
+
/** How long the span runs. */
|
|
192
|
+
duration: number;
|
|
193
|
+
/** Where the span begins; below zero gives a lead-in before the story's zero. A fresh trial opens here. Default 0. */
|
|
194
|
+
start?: number;
|
|
195
|
+
/** Whether playing past the end wraps back to `start`. Default true. */
|
|
196
|
+
loop?: boolean;
|
|
197
|
+
/** Playback speed multiplier. Default 1. */
|
|
198
|
+
rate?: number;
|
|
199
|
+
}
|
|
200
|
+
/** The span a playhead may stand in, in ms. */
|
|
201
|
+
interface Span {
|
|
202
|
+
start: number;
|
|
203
|
+
end: number;
|
|
204
|
+
}
|
|
205
|
+
/** Everything a clock holds. */
|
|
206
|
+
interface ClockState {
|
|
207
|
+
/** The playhead, in ms, always inside `span`. */
|
|
208
|
+
time: number;
|
|
209
|
+
playing: boolean;
|
|
210
|
+
loop: boolean;
|
|
211
|
+
rate: number;
|
|
212
|
+
span: Span;
|
|
213
|
+
}
|
|
214
|
+
/** A span replacing the declared one at runtime, as `StoryTimeline.setSpan` takes it. */
|
|
215
|
+
type SpanOverride = Pick<TimelineSpec, 'duration' | 'start'>;
|
|
216
|
+
|
|
189
217
|
/** What a story's `render` and its decorators receive: the trial's config and state, the globals in force, and the
|
|
190
218
|
* story's own title and name. */
|
|
191
219
|
interface StoryContext<C = unknown, S = unknown> {
|
|
@@ -217,6 +245,8 @@ interface MetaSpec {
|
|
|
217
245
|
/** As CSF's meta `tags`; `'gallery'` marks a catalog or showcase rather than one component. Read from the source,
|
|
218
246
|
* so each must be a string literal. */
|
|
219
247
|
tags?: readonly string[];
|
|
248
|
+
/** Gives every story in the file a playhead and a transport, unless the story declares its own. */
|
|
249
|
+
timeline?: TimelineSpec | ((config: Record<string, unknown>) => TimelineSpec);
|
|
220
250
|
}
|
|
221
251
|
/** What an index page is given: its component's stories, and the parts the generated page is built from. */
|
|
222
252
|
interface IndexContext {
|
|
@@ -265,6 +295,9 @@ interface StorySpec<C = Record<string, never>, S = undefined> {
|
|
|
265
295
|
play?: (ctx: PlayContext<C>) => void | Promise<void>;
|
|
266
296
|
/** Added to the meta's `tags`; `'!tag'` drops one. Read from the source, so each must be a string literal. */
|
|
267
297
|
tags?: readonly string[];
|
|
298
|
+
/** Gives the story a playhead, which it reads with `usePlayhead` or `useTimeline`, and its trial a transport. A
|
|
299
|
+
* function is handed the trial's config, for a span that follows a control. */
|
|
300
|
+
timeline?: TimelineSpec | ((config: C) => TimelineSpec);
|
|
268
301
|
}
|
|
269
302
|
/** One story, normalized — what both the native and CSF loaders produce. */
|
|
270
303
|
interface LoadedStory {
|
|
@@ -281,6 +314,8 @@ interface LoadedStory {
|
|
|
281
314
|
viewport: Viewport | null;
|
|
282
315
|
isolate: string | null;
|
|
283
316
|
play: ((ctx: PlayContext) => void | Promise<void>) | null;
|
|
317
|
+
/** The timeline the story declares, for a config; null when it declares none. */
|
|
318
|
+
timeline: ((config: unknown) => TimelineSpec) | null;
|
|
284
319
|
}
|
|
285
320
|
/** One story as the index knows it, before its module is loaded. */
|
|
286
321
|
interface IndexEntry {
|
|
@@ -356,4 +391,4 @@ declare function startFrame({ story, channel, container, setup }: StartFrameOpti
|
|
|
356
391
|
/** Reports an import failure — there is no story to start. */
|
|
357
392
|
declare function reportImportFault(channel: Channel<ToFrame, FromFrame>, error: unknown): void;
|
|
358
393
|
|
|
359
|
-
export { type A11yFinding as A, type
|
|
394
|
+
export { type A11yFinding as A, 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 DepGraph as e, type GlobalsTarget as f, type IndexRender as g, type IndexStoryProps as h, type StoryContext as i, type IndexEntry as j, type Layout as k, type FromFrame as l, type ToFrame as m, type CssVarReport as n, type CapturedPicture as o, type StartFrameOptions as p, reportImportFault as r, startFrame as s };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { isNative } from './chunk-
|
|
1
|
+
import { isNative, ClockContext } from './chunk-L5XM5VKB.js';
|
|
2
2
|
import { storyNameFromExport, storyId } from './chunk-HRGPFQBW.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { portSafePart, appliedLocal, withUnsent, coverOf, ArgsContext } from './chunk-MGQWCPYE.js';
|
|
4
|
+
import { isPlainObject } from './chunk-KJGXJD3U.js';
|
|
5
|
+
import { useVisibleRaf, useLatest } from '@weasel-js/core';
|
|
6
|
+
import { createContext, useSyncExternalStore, useRef, useEffect, useState, Component, useContext, createElement } from 'react';
|
|
5
7
|
import { jsx } from 'react/jsx-runtime';
|
|
6
8
|
import { f } from '@weasel-js/labkit/config';
|
|
7
9
|
|
|
@@ -192,6 +194,149 @@ function createGlobalsTarget(root, scope) {
|
|
|
192
194
|
}
|
|
193
195
|
};
|
|
194
196
|
}
|
|
197
|
+
var NEVER = () => () => {
|
|
198
|
+
};
|
|
199
|
+
var notPlaying = () => false;
|
|
200
|
+
function useClockLoop(clock, target) {
|
|
201
|
+
const playing = useSyncExternalStore(clock?.subscribe ?? NEVER, clock ? () => clock.get().playing : notPlaying);
|
|
202
|
+
const last = useRef(null);
|
|
203
|
+
const raf = useVisibleRaf(
|
|
204
|
+
(now) => {
|
|
205
|
+
if (!clock) return;
|
|
206
|
+
const prev = last.current;
|
|
207
|
+
last.current = now;
|
|
208
|
+
if (prev !== null) clock.tick(now - prev);
|
|
209
|
+
if (clock.get().playing) raf.request();
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
...target ? { target } : {},
|
|
213
|
+
onResume: () => {
|
|
214
|
+
last.current = null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
useEffect(() => {
|
|
219
|
+
if (!playing) return;
|
|
220
|
+
last.current = null;
|
|
221
|
+
raf.request();
|
|
222
|
+
return () => raf.cancel();
|
|
223
|
+
}, [playing, raf]);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/timeline/clock.ts
|
|
227
|
+
function spanOf(spec) {
|
|
228
|
+
const start = Number.isFinite(spec.start) ? spec.start : 0;
|
|
229
|
+
const duration = Number.isFinite(spec.duration) && spec.duration > 0 ? spec.duration : 0;
|
|
230
|
+
return { start, end: start + duration };
|
|
231
|
+
}
|
|
232
|
+
function clampTime(span, t) {
|
|
233
|
+
if (Number.isNaN(t)) return span.start;
|
|
234
|
+
return Math.min(span.end, Math.max(span.start, t));
|
|
235
|
+
}
|
|
236
|
+
function advance(state, elapsed) {
|
|
237
|
+
if (!state.playing) return state;
|
|
238
|
+
const { start, end } = state.span;
|
|
239
|
+
const length = end - start;
|
|
240
|
+
if (length <= 0) return { ...state, time: start, playing: false };
|
|
241
|
+
const next = state.time + elapsed * state.rate;
|
|
242
|
+
if (next <= end) return { ...state, time: next };
|
|
243
|
+
if (!state.loop) return { ...state, time: end, playing: false };
|
|
244
|
+
return { ...state, time: start + (next - start) % length };
|
|
245
|
+
}
|
|
246
|
+
var validRate = (rate) => typeof rate === "number" && Number.isFinite(rate) && rate > 0;
|
|
247
|
+
var placed = (span, requested) => requested === null ? span.start : clampTime(span, requested);
|
|
248
|
+
function createClock(spec, initial) {
|
|
249
|
+
let declared = spanOf(spec);
|
|
250
|
+
let override = null;
|
|
251
|
+
let requested = { time: initial ?? null };
|
|
252
|
+
let state = {
|
|
253
|
+
time: placed(declared, requested.time),
|
|
254
|
+
playing: false,
|
|
255
|
+
loop: spec.loop ?? true,
|
|
256
|
+
rate: validRate(spec.rate) ? spec.rate : 1,
|
|
257
|
+
span: declared
|
|
258
|
+
};
|
|
259
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
260
|
+
const pendingIn = (at) => requested && requested.time !== null && requested.time !== at.time ? requested.time : null;
|
|
261
|
+
let pending = pendingIn(state);
|
|
262
|
+
const set = (next) => {
|
|
263
|
+
const nextPending = pendingIn(next);
|
|
264
|
+
if (nextPending === pending && next.time === state.time && next.playing === state.playing && next.loop === state.loop && next.rate === state.rate && next.span.start === state.span.start && next.span.end === state.span.end)
|
|
265
|
+
return;
|
|
266
|
+
state = next;
|
|
267
|
+
pending = nextPending;
|
|
268
|
+
for (const listener of [...listeners]) listener();
|
|
269
|
+
};
|
|
270
|
+
const moved = (next) => {
|
|
271
|
+
requested = null;
|
|
272
|
+
set(next);
|
|
273
|
+
};
|
|
274
|
+
const respan = () => {
|
|
275
|
+
const span = override ?? declared;
|
|
276
|
+
set({ ...state, span, time: requested ? placed(span, requested.time) : clampTime(span, state.time) });
|
|
277
|
+
};
|
|
278
|
+
return {
|
|
279
|
+
get: () => state,
|
|
280
|
+
subscribe(listener) {
|
|
281
|
+
listeners.add(listener);
|
|
282
|
+
return () => listeners.delete(listener);
|
|
283
|
+
},
|
|
284
|
+
play() {
|
|
285
|
+
if (state.playing) return;
|
|
286
|
+
moved({ ...state, playing: true, time: state.time >= state.span.end ? state.span.start : state.time });
|
|
287
|
+
},
|
|
288
|
+
pause: () => set({ ...state, playing: false }),
|
|
289
|
+
seek: (time) => moved({ ...state, time: clampTime(state.span, time) }),
|
|
290
|
+
request(time) {
|
|
291
|
+
requested = { time: Number.isNaN(time) ? null : time };
|
|
292
|
+
set({ ...state, playing: false, time: placed(state.span, requested.time) });
|
|
293
|
+
},
|
|
294
|
+
pending: () => pending,
|
|
295
|
+
setLoop: (loop) => set({ ...state, loop }),
|
|
296
|
+
setRate(rate) {
|
|
297
|
+
if (validRate(rate)) set({ ...state, rate });
|
|
298
|
+
},
|
|
299
|
+
setSpan(span) {
|
|
300
|
+
override = span ? spanOf(span) : null;
|
|
301
|
+
respan();
|
|
302
|
+
},
|
|
303
|
+
declare(next) {
|
|
304
|
+
declared = spanOf(next);
|
|
305
|
+
respan();
|
|
306
|
+
},
|
|
307
|
+
tick(elapsed) {
|
|
308
|
+
if (state.playing) moved(advance(state, elapsed));
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function useStoryClock(spec, initial) {
|
|
313
|
+
const [clock, setClock] = useState(() => spec ? createClock(spec, initial()) : null);
|
|
314
|
+
let current = clock;
|
|
315
|
+
if (spec && !clock) {
|
|
316
|
+
current = createClock(spec, initial());
|
|
317
|
+
setClock(current);
|
|
318
|
+
} else if (!spec && clock) {
|
|
319
|
+
current = null;
|
|
320
|
+
setClock(null);
|
|
321
|
+
}
|
|
322
|
+
const latest = useLatest(spec);
|
|
323
|
+
const spanKey = spec ? `${spec.start ?? 0}:${spec.duration}` : null;
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
if (current && latest.current) current.declare(latest.current);
|
|
326
|
+
}, [current, spanKey, latest]);
|
|
327
|
+
return current;
|
|
328
|
+
}
|
|
329
|
+
var NO_INITIAL = () => null;
|
|
330
|
+
function OwnClock({ spec, children }) {
|
|
331
|
+
const clock = useStoryClock(spec, NO_INITIAL);
|
|
332
|
+
useClockLoop(clock);
|
|
333
|
+
return /* @__PURE__ */ jsx(ClockContext.Provider, { value: clock, children });
|
|
334
|
+
}
|
|
335
|
+
function WithStoryClock({ story, config, children }) {
|
|
336
|
+
const outer = useContext(ClockContext);
|
|
337
|
+
if (outer || !story.timeline) return children;
|
|
338
|
+
return /* @__PURE__ */ jsx(OwnClock, { spec: story.timeline(config), children });
|
|
339
|
+
}
|
|
195
340
|
function RenderStory({ story, ctx }) {
|
|
196
341
|
return story.render(ctx);
|
|
197
342
|
}
|
|
@@ -220,7 +365,7 @@ var StoryHost = class extends Component {
|
|
|
220
365
|
return /* @__PURE__ */ jsx("pre", { className: "fg-frame__fault", children: error instanceof Error ? error.message : String(error) });
|
|
221
366
|
}
|
|
222
367
|
const { story, ctx, decorators } = this.props;
|
|
223
|
-
return /* @__PURE__ */ jsx(Decorated, { story, ctx, decorators });
|
|
368
|
+
return /* @__PURE__ */ jsx(WithStoryClock, { story, config: ctx.config, children: /* @__PURE__ */ jsx(Decorated, { story, ctx, decorators }) });
|
|
224
369
|
}
|
|
225
370
|
};
|
|
226
371
|
function controlOf(argType) {
|
|
@@ -323,6 +468,14 @@ function argsToSchema(args, argTypes, matchers = {}) {
|
|
|
323
468
|
return f.schema(nodes);
|
|
324
469
|
}
|
|
325
470
|
|
|
471
|
+
// src/timeline/declare.ts
|
|
472
|
+
var isSpec = (value) => !!value && typeof value === "object" && typeof value.duration === "number";
|
|
473
|
+
function timelineOf(value, adapt = (config) => config) {
|
|
474
|
+
if (isSpec(value)) return () => value;
|
|
475
|
+
if (typeof value === "function") return (config) => value(adapt(config));
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
|
|
326
479
|
// src/csf/loadCsfModule.tsx
|
|
327
480
|
var LAYOUTS = ["centered", "padded", "fullscreen"];
|
|
328
481
|
var asArray = (value) => value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
@@ -437,7 +590,8 @@ function loadCsfModule(mod, autoTitle, projectParameters = {}) {
|
|
|
437
590
|
scoped(ctx, (context) => decorator(Story, context))
|
|
438
591
|
);
|
|
439
592
|
const layout = parameters.layout;
|
|
440
|
-
const
|
|
593
|
+
const forgeParams = parameters.forge;
|
|
594
|
+
const isolate = forgeParams?.isolate;
|
|
441
595
|
const play = spec.play ?? meta.play;
|
|
442
596
|
stories.push({
|
|
443
597
|
id,
|
|
@@ -454,7 +608,8 @@ function loadCsfModule(mod, autoTitle, projectParameters = {}) {
|
|
|
454
608
|
layout: layout && LAYOUTS.includes(layout) ? layout : "padded",
|
|
455
609
|
viewport: resolveViewport(parameters, storyGlobals),
|
|
456
610
|
isolate: typeof isolate === "string" ? isolate : null,
|
|
457
|
-
play: play ? ({ canvasElement, config: config2, globals }) => play({ ...csfContext(config2, globals), canvasElement, step: async (_label, fn) => fn() }) : null
|
|
611
|
+
play: play ? ({ canvasElement, config: config2, globals }) => play({ ...csfContext(config2, globals), canvasElement, step: async (_label, fn) => fn() }) : null,
|
|
612
|
+
timeline: timelineOf(forgeParams?.timeline, (config2) => csfContext(config2, {}).args)
|
|
458
613
|
});
|
|
459
614
|
}
|
|
460
615
|
return stories;
|
|
@@ -478,7 +633,8 @@ function loadNativeModule(mod, autoTitle) {
|
|
|
478
633
|
layout: spec.layout ?? metaSpec.layout ?? "centered",
|
|
479
634
|
viewport: spec.viewport ?? null,
|
|
480
635
|
isolate: spec.isolate ?? metaSpec.isolate ?? null,
|
|
481
|
-
play: spec.play ?? null
|
|
636
|
+
play: spec.play ?? null,
|
|
637
|
+
timeline: timelineOf(spec.timeline ?? metaSpec.timeline)
|
|
482
638
|
});
|
|
483
639
|
}
|
|
484
640
|
return stories;
|
|
@@ -494,6 +650,6 @@ function indexRenderOf(mod) {
|
|
|
494
650
|
return typeof render === "function" ? render : null;
|
|
495
651
|
}
|
|
496
652
|
|
|
497
|
-
export { StoryHost, captureElement, createGlobalsTarget, createOverrides, indexRenderOf, loadStories, resolveCssVar, runAxe, scanCssVars };
|
|
498
|
-
//# sourceMappingURL=chunk-
|
|
499
|
-
//# sourceMappingURL=chunk-
|
|
653
|
+
export { StoryHost, captureElement, createGlobalsTarget, createOverrides, indexRenderOf, loadStories, resolveCssVar, runAxe, scanCssVars, useClockLoop, useStoryClock };
|
|
654
|
+
//# sourceMappingURL=chunk-5N4YP5HS.js.map
|
|
655
|
+
//# sourceMappingURL=chunk-5N4YP5HS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/frame/a11y.ts","../src/frame/cssVars.ts","../src/frame/capture.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"],"names":["useEffect","jsx","value","useContext","useState","config","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,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AAA;AAAA,MAC3B,OAAA,EAAS,IAAA,CAAK,OAAA,IAAW,QAAA,CAAS,OAAA,IAAW,IAAA;AAAA,MAC7C,IAAA,EAAM,KAAK,IAAA,IAAQ,IAAA;AAAA,MACnB,QAAA,EAAU,UAAA,CAAW,IAAA,CAAK,QAAA,IAAY,SAAS,QAAQ;AAAA,KACxD,CAAA;AAAA,EACH;AACA,EAAA,OAAO,OAAA;AACT;;;ACvBO,SAAS,WAAA,CACd,GAAA,EACA,SAAA,EACA,UAAA,EACe;AACf,EAAA,OAAO,QAAA,CAAS,GAAA,CAAI,OAAA,EAAS,MAAM,CAAA,GAC/B,gBAAA,CAAiB,GAAA,EAAK,SAAS,CAAA,GAC/B,aAAA,CAAc,GAAA,EAAK,SAAA,EAAW,UAAU,CAAA;AAC9C;AAGO,SAAS,cAAc,GAAA,EAAkD;AAC9E,EAAA,MAAM,OAAO,GAAA,CAAI,OAAA;AACjB,EAAA,MAAM,MAAA,GAAS,SAAS,IAAA,EAAM,MAAM,IAAI,IAAA,EAAM,KAAA,GAAQ,IAAA,EAAM,UAAA,EAAY,KAAA,EAAO,KAAA;AAC/E,EAAA,OAAO,OAAO,MAAA,KAAW,UAAA,GAAc,MAAA,GAAyB,IAAA;AAClE","file":"chunk-5N4YP5HS.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/** 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/** Runs axe over `element` and reduces its answer to what crosses the frame's channel. */\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 result = await axe.run(element, rules ? { rules } : undefined);\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`, the document's by default, or else\n * 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 return [...names]\n .sort()\n .map((name) => ({ name, value: values.get(name) ?? '', overridden: overridden(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 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","/** 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) => {\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","/** 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 listeners = new Set<() => void>();\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 for (const listener of [...listeners]) listener();\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(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\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 } 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?:\n | string\n | false\n | {\n type?: string;\n min?: number;\n max?: number;\n step?: number;\n /** forge's own: an icon (weasel-ui `IconName`) 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\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 { icons } = control;\n const node = f.enum(\n def<string>(),\n icons ? options.map((value) => ({ value, label: value, ...(icons[value] ? { icon: icons[value] } : {}) })) : options,\n );\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 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 './isPlainObject';\nimport { withUnsent } from './portSafe';\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. `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 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/** 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 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`. `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\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"]}
|