@weasel-js/forge 1.9.3 → 1.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/dist/{FrameController-CpcY0DNB.d.ts → FrameController-BQjKhdwk.d.ts} +2 -36
- package/dist/chunk-5DXUNLV2.js +6 -0
- package/dist/chunk-5DXUNLV2.js.map +1 -0
- package/dist/{chunk-MGQWCPYE.js → chunk-5KI5YSQ5.js} +4 -5
- package/dist/chunk-5KI5YSQ5.js.map +1 -0
- package/dist/{chunk-Q2EZXJFE.js → chunk-B3PPHJTS.js} +59 -45
- package/dist/chunk-B3PPHJTS.js.map +1 -0
- package/dist/{chunk-CJX3W5HY.js → chunk-FRUA5WJF.js} +4 -3
- package/dist/chunk-FRUA5WJF.js.map +1 -0
- package/dist/{chunk-GZPQMGXJ.js → chunk-JHL4ERDA.js} +4 -3
- package/dist/chunk-JHL4ERDA.js.map +1 -0
- package/dist/{chunk-JVRHBI3V.js → chunk-MQSFPRF6.js} +20 -44
- package/dist/chunk-MQSFPRF6.js.map +1 -0
- package/dist/chunk-TXLWQFF6.js +10 -0
- package/dist/chunk-TXLWQFF6.js.map +1 -0
- package/dist/{chunk-BGOHALHO.js → chunk-ZZCCIXEJ.js} +11 -90
- package/dist/chunk-ZZCCIXEJ.js.map +1 -0
- package/dist/{config-BfsYw5lg.d.ts → config-Dfu-NKxd.d.ts} +27 -4
- package/dist/csf/preview-api.js +2 -2
- package/dist/frame/index.d.ts +2 -2
- package/dist/frame/index.js +6 -40
- package/dist/frame/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/shell/index.css +61 -61
- package/dist/shell/index.css.map +1 -1
- package/dist/shell/index.d.ts +5 -13
- package/dist/shell/index.js +345 -332
- package/dist/shell/index.js.map +1 -1
- package/dist/test/index.d.ts +4 -2
- package/dist/test/index.js +7 -7
- package/dist/test/index.js.map +1 -1
- package/dist/test/play.d.ts +3 -3
- package/dist/test/play.js.map +1 -1
- package/dist/vite/index.d.ts +3 -1
- package/dist/vite/index.js +365 -101
- package/dist/vite/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-BGOHALHO.js.map +0 -1
- package/dist/chunk-CJX3W5HY.js.map +0 -1
- package/dist/chunk-GZPQMGXJ.js.map +0 -1
- package/dist/chunk-JVRHBI3V.js.map +0 -1
- package/dist/chunk-KJGXJD3U.js +0 -15
- package/dist/chunk-KJGXJD3U.js.map +0 -1
- package/dist/chunk-MGQWCPYE.js.map +0 -1
- package/dist/chunk-Q2EZXJFE.js.map +0 -1
package/README.md
CHANGED
|
@@ -7,6 +7,19 @@ component can be compared side by side.
|
|
|
7
7
|
|
|
8
8
|
Direction: `docs/superpowers/specs/2026-09-13-forge-design.md`.
|
|
9
9
|
|
|
10
|
+
## What the index reads
|
|
11
|
+
|
|
12
|
+
The story list is read from each file's source without running it, and a
|
|
13
|
+
loaded story takes its title from that list. So a meta's `title` has to be
|
|
14
|
+
readable there: a string, a template with no expression, or a `const` of the
|
|
15
|
+
same file holding one. Any other title, such as an imported constant, is
|
|
16
|
+
passed over for the title the file's path gives it. In a file whose meta is
|
|
17
|
+
forge's `meta`, a story is an export that calls `story`, directly or through
|
|
18
|
+
a function that returns the call, and an import or a re-export is followed to
|
|
19
|
+
its declaration to see whether it is one. Anything else the file exports, such
|
|
20
|
+
as `export const rows = makeRows()` or a constant from another module, is not
|
|
21
|
+
listed.
|
|
22
|
+
|
|
10
23
|
## Where a story renders
|
|
11
24
|
|
|
12
25
|
A story renders inside a host element in the workshop document. The host
|
|
@@ -52,11 +65,20 @@ The vite plugin takes two optional config modules:
|
|
|
52
65
|
renderers, and global declarations. Only the workshop page imports it.
|
|
53
66
|
`title` names the workshop in its header and as the document title
|
|
54
67
|
(default `weaselforge`), and `cssVars: false` leaves out the CSS Vars panel.
|
|
68
|
+
`libraries` names the project's libraries, each a stretch of file path, a
|
|
69
|
+
label and an optional badge tone: `{ path: '/packages/ui/', label: 'ui' }`.
|
|
70
|
+
The tree's package filter, index pages, and Get Info show the label; a
|
|
71
|
+
story under none of them takes its title's first segment.
|
|
55
72
|
|
|
56
73
|
```ts
|
|
57
74
|
forge({ stories: ['src/**/*.stories.tsx'], frameConfig: 'forge.frame.tsx', shellConfig: 'forge.shell.tsx' });
|
|
58
75
|
```
|
|
59
76
|
|
|
77
|
+
The workshop page imports the frame config too, so a stylesheet it imports
|
|
78
|
+
styles the workshop as well. CSS meant for frame documents alone, such as a
|
|
79
|
+
page background on `html, body`, goes in `frameStyles`, a list of stylesheet
|
|
80
|
+
paths that only the frame document loads.
|
|
81
|
+
|
|
60
82
|
Editing a story file reloads that story in every trial showing it, with the
|
|
61
83
|
trial's config and state kept; the page itself stays.
|
|
62
84
|
|
|
@@ -42,7 +42,7 @@ interface Viewport {
|
|
|
42
42
|
width: number;
|
|
43
43
|
height: number;
|
|
44
44
|
}
|
|
45
|
-
type FaultPhase = 'import' | 'render' | '
|
|
45
|
+
type FaultPhase = 'import' | 'render' | 'protocol';
|
|
46
46
|
/** One custom property as the frame found it. */
|
|
47
47
|
interface CssVarReport {
|
|
48
48
|
name: string;
|
|
@@ -81,15 +81,6 @@ interface A11yReport {
|
|
|
81
81
|
passes: number;
|
|
82
82
|
inapplicable: number;
|
|
83
83
|
}
|
|
84
|
-
/** A picture of the story the frame can put in a message: labkit's `CaptureSource` without the canvas,
|
|
85
|
-
* which no structured clone carries. */
|
|
86
|
-
type CapturedPicture = {
|
|
87
|
-
kind: 'svg';
|
|
88
|
-
markup: string;
|
|
89
|
-
} | {
|
|
90
|
-
kind: 'image';
|
|
91
|
-
src: string;
|
|
92
|
-
};
|
|
93
84
|
type ToFrame = {
|
|
94
85
|
type: 'init';
|
|
95
86
|
config: unknown;
|
|
@@ -108,18 +99,11 @@ type ToFrame = {
|
|
|
108
99
|
type: 'vars.set';
|
|
109
100
|
name: string;
|
|
110
101
|
value: string | null;
|
|
111
|
-
} | {
|
|
112
|
-
type: 'play';
|
|
113
102
|
}
|
|
114
103
|
/** Run axe over the story's own subtree. Answered by `a11y` carrying the same `id`. */
|
|
115
104
|
| {
|
|
116
105
|
type: 'a11y.run';
|
|
117
106
|
id: string;
|
|
118
|
-
}
|
|
119
|
-
/** Serialize the story's own subtree as a picture. Answered by `capture` carrying the same `id`. */
|
|
120
|
-
| {
|
|
121
|
-
type: 'capture.run';
|
|
122
|
-
id: string;
|
|
123
107
|
};
|
|
124
108
|
type FromFrame = {
|
|
125
109
|
type: 'ready';
|
|
@@ -140,10 +124,6 @@ type FromFrame = {
|
|
|
140
124
|
} | {
|
|
141
125
|
type: 'setState';
|
|
142
126
|
state: unknown;
|
|
143
|
-
} | {
|
|
144
|
-
type: 'size';
|
|
145
|
-
width: number;
|
|
146
|
-
height: number;
|
|
147
127
|
} | {
|
|
148
128
|
type: 'vars';
|
|
149
129
|
vars: CssVarReport[];
|
|
@@ -152,10 +132,6 @@ type FromFrame = {
|
|
|
152
132
|
| {
|
|
153
133
|
type: 'open';
|
|
154
134
|
id: string;
|
|
155
|
-
} | {
|
|
156
|
-
type: 'played';
|
|
157
|
-
ok: boolean;
|
|
158
|
-
message?: string;
|
|
159
135
|
} | {
|
|
160
136
|
type: 'a11y';
|
|
161
137
|
id: string;
|
|
@@ -166,16 +142,6 @@ type FromFrame = {
|
|
|
166
142
|
id: string;
|
|
167
143
|
ok: false;
|
|
168
144
|
message: string;
|
|
169
|
-
} | {
|
|
170
|
-
type: 'capture';
|
|
171
|
-
id: string;
|
|
172
|
-
ok: true;
|
|
173
|
-
picture: CapturedPicture;
|
|
174
|
-
} | {
|
|
175
|
-
type: 'capture';
|
|
176
|
-
id: string;
|
|
177
|
-
ok: false;
|
|
178
|
-
message: string;
|
|
179
145
|
}
|
|
180
146
|
/** `seq`, on a render fault only: how many `init`/`config`/`state`/`globals` messages the frame had received. */
|
|
181
147
|
| {
|
|
@@ -393,4 +359,4 @@ declare function startFrame({ story, channel, container, setup }: StartFrameOpti
|
|
|
393
359
|
/** Reports an import failure — there is no story to start. */
|
|
394
360
|
declare function reportImportFault(channel: Channel<ToFrame, FromFrame>, error: unknown): void;
|
|
395
361
|
|
|
396
|
-
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
|
|
362
|
+
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 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 StartFrameOptions as o, reportImportFault as r, startFrame as s };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/title.ts"],"names":[],"mappings":";AACO,IAAM,aAAA,GAAgB","file":"chunk-5DXUNLV2.js","sourcesContent":["/** The workshop's name when the shell config gives none: in its header, and as the document title. */\nexport const DEFAULT_TITLE = 'weaselforge';\n"]}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { stableStringify
|
|
1
|
+
import { stableStringify } from './chunk-TXLWQFF6.js';
|
|
2
2
|
import { createContext } from 'react';
|
|
3
|
+
import { isPlainObject } from '@weasel-js/core';
|
|
3
4
|
|
|
4
5
|
var coverOf = (value) => stableStringify(value) ?? " undefined";
|
|
5
6
|
var appliedLocal = (local, config) => Object.fromEntries(
|
|
6
7
|
Object.entries(local).filter(([key, entry]) => coverOf(config[key]) === entry.over).map(([key, entry]) => [key, entry.value])
|
|
7
8
|
);
|
|
8
9
|
var ArgsContext = createContext(null);
|
|
9
|
-
|
|
10
|
-
// src/csf/portSafe.ts
|
|
11
10
|
var g = globalThis;
|
|
12
11
|
var CLONED_WHOLE = new Set(
|
|
13
12
|
[
|
|
@@ -94,5 +93,5 @@ function withUnsent(sent, original) {
|
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
export { ArgsContext, appliedLocal, coverOf, isPortSafe, portSafePart, withUnsent };
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
98
|
-
//# sourceMappingURL=chunk-
|
|
96
|
+
//# sourceMappingURL=chunk-5KI5YSQ5.js.map
|
|
97
|
+
//# sourceMappingURL=chunk-5KI5YSQ5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/csf/argsContext.ts","../src/csf/portSafe.ts"],"names":[],"mappings":";;;;AAcO,IAAM,OAAA,GAAU,CAAC,KAAA,KAA2B,eAAA,CAAgB,KAAK,CAAA,IAAK;AAGtE,IAAM,YAAA,GAAe,CAAC,KAAA,EAAkB,MAAA,KAC7C,MAAA,CAAO,WAAA;AAAA,EACL,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,CACjB,MAAA,CAAO,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM,OAAA,CAAQ,MAAA,CAAO,GAAG,CAAC,CAAA,KAAM,KAAA,CAAM,IAAI,CAAA,CAC5D,GAAA,CAAI,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM,CAAC,GAAA,EAAK,KAAA,CAAM,KAAK,CAAC;AAC7C;AAeK,IAAM,WAAA,GAAyC,cAAgC,IAAI;ACnC1F,IAAM,CAAA,GAAI,UAAA;AACV,IAAM,eAAe,IAAI,GAAA;AAAA,EACvB;AAAA,IACE,MAAA;AAAA,IACA,QAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,mBAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAAA,IACA,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pD,IAAA,IAAI,GAAA,IAAO,MAAM,GAAA,CAAI,GAAG,IAAI,UAAA,CAAW,IAAA,CAAK,GAAG,CAAA,EAAG,MAAM,CAAA;AAAA,SAAA,IAC/C,aAAa,MAAM,CAAA,KAAM,IAAA,EAAM,GAAA,CAAI,GAAG,CAAA,GAAI,MAAA;AAAA,EACrD;AACA,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,MAAM,CAAA,IAAK,OAAO,OAAA,CAAQ,IAAI,CAAA,EAAG,IAAI,EAAE,GAAA,IAAO,QAAA,CAAA,EAAW,GAAA,CAAI,GAAG,CAAA,GAAI,MAAA;AACrF,EAAA,OAAO,GAAA;AACT","file":"chunk-5KI5YSQ5.js","sourcesContent":["import { type Context, createContext, type Dispatch, type SetStateAction } from 'react';\nimport { stableStringify } from '../protocol/messages';\n\ntype Args = Record<string, unknown>;\n\n/** A frame-local arg, and the config value it was set over: it applies only while config still holds that. */\nexport interface LocalArg {\n value: unknown;\n over: string;\n}\n\nexport type LocalArgs = Record<string, LocalArg>;\n\n/** A config value in the form `LocalArg.over` records. */\nexport const coverOf = (value: unknown): string => stableStringify(value) ?? ' undefined';\n\n/** The frame-local values that still apply over `config`. */\nexport const appliedLocal = (local: LocalArgs, config: Args): Args =>\n Object.fromEntries(\n Object.entries(local)\n .filter(([key, entry]) => coverOf(config[key]) === entry.over)\n .map(([key, entry]) => [key, entry.value]),\n );\n\nexport interface ArgsScope {\n /** The args the story renders with: its own, then config, then the frame-local ones that still apply. */\n args: Args;\n /** The trial's config as it stands. An `undefined` key means the story's own arg. */\n config: Args;\n defaults: Args;\n /** The story's own args, before config and the frame-local ones. */\n original: Args;\n setConfig: (path: string, value: unknown) => void;\n /** Args a MessagePort would not deliver intact, kept in the frame because config crosses one. */\n setLocal: Dispatch<SetStateAction<LocalArgs>>;\n}\n\nexport const ArgsContext: Context<ArgsScope | null> = createContext<ArgsScope | null>(null);\n","import { isPlainObject } from '@weasel-js/core';\n\nconst g = globalThis as Record<string, unknown>;\nconst CLONED_WHOLE = new Set<unknown>(\n [\n 'Date',\n 'RegExp',\n 'ArrayBuffer',\n 'DataView',\n 'Int8Array',\n 'Uint8Array',\n 'Uint8ClampedArray',\n 'Int16Array',\n 'Uint16Array',\n 'Int32Array',\n 'Uint32Array',\n 'Float16Array',\n 'Float32Array',\n 'Float64Array',\n 'BigInt64Array',\n 'BigUint64Array',\n ]\n .map((name) => (g[name] as { prototype?: object } | undefined)?.prototype)\n .filter(Boolean),\n);\n\n/** Own keys a clone keeps: enumerable string keys, plus an array's `length`. */\nconst hasOnlyClonedKeys = (v: object): boolean =>\n Reflect.ownKeys(v).every(\n (key) =>\n typeof key === 'string' &&\n (Object.prototype.propertyIsEnumerable.call(v, key) || (Array.isArray(v) && key === 'length')),\n );\n\n/**\n * Whether a MessagePort delivers `value` as the same thing it was. `structuredClone` succeeding is\n * not enough: it copies a class instance's fields onto a plain object and drops its methods.\n */\nexport function isPortSafe(value: unknown): boolean {\n const seen = new Set<object>();\n const safe = (v: unknown): boolean => {\n if (v === null) return true;\n if (typeof v !== 'object') return typeof v !== 'function' && typeof v !== 'symbol';\n if (seen.has(v)) return true;\n seen.add(v);\n const proto = Object.getPrototypeOf(v);\n if (CLONED_WHOLE.has(proto)) return true;\n if (proto === Map.prototype)\n return hasOnlyClonedKeys(v) && [...(v as Map<unknown, unknown>)].every(([key, member]) => safe(key) && safe(member));\n if (proto === Set.prototype) return hasOnlyClonedKeys(v) && [...(v as Set<unknown>)].every(safe);\n if (proto !== Array.prototype && proto !== Object.prototype && proto !== null) return false;\n return hasOnlyClonedKeys(v) && Object.values(v).every(safe);\n };\n try {\n return safe(value);\n } catch {\n return false;\n }\n}\n\n/** A plain object or array whose members can be split: React elements are plain objects, but whole. */\nconst splittable = (v: unknown): v is Record<string, unknown> | unknown[] =>\n (Array.isArray(v) ? Object.getPrototypeOf(v) === Array.prototype : isPlainObject(v) && !('$$typeof' in v)) &&\n hasOnlyClonedKeys(v as object);\n\n/**\n * The part of `value` a port delivers intact, or null when none of it can cross. A plain object\n * keeps its port-safe fields; an array holds null where a member has no part.\n */\nexport function portSafePart(value: unknown): { value: unknown } | null {\n const walking = new Set<object>();\n const part = (v: unknown): { value: unknown } | null => {\n if (isPortSafe(v)) return { value: v };\n if (!splittable(v) || walking.has(v)) return null;\n walking.add(v);\n try {\n if (Array.isArray(v)) return { value: v.map((member) => part(member)?.value ?? null) };\n const out: Record<string, unknown> = {};\n for (const [key, member] of Object.entries(v)) {\n const kept = part(member);\n if (kept) out[key] = kept.value;\n }\n return { value: out };\n } finally {\n walking.delete(v);\n }\n };\n try {\n return part(value);\n } catch {\n return null;\n }\n}\n\n/** `sent`, a value that crossed the port as `portSafePart(original)` or an edit of it, with what the part left behind put back. */\nexport function withUnsent(sent: unknown, original: unknown): unknown {\n if (isPortSafe(original)) return sent;\n if (sent === null && portSafePart(original) === null) return original;\n if (Array.isArray(original) && Array.isArray(sent))\n return sent.map((member, i) => (i < original.length ? withUnsent(member, original[i]) : member));\n if (!splittable(original) || Array.isArray(original) || !isPlainObject(sent)) return sent;\n const out: Record<string, unknown> = {};\n for (const [key, member] of Object.entries(original)) {\n if (key in sent) out[key] = withUnsent(sent[key], member);\n else if (portSafePart(member) === null) out[key] = member;\n }\n for (const [key, member] of Object.entries(sent)) if (!(key in original)) out[key] = member;\n return out;\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { isNative, ClockContext } from './chunk-L5XM5VKB.js';
|
|
2
2
|
import { storyNameFromExport, storyId } from './chunk-HRGPFQBW.js';
|
|
3
|
-
import { portSafePart, appliedLocal, withUnsent, coverOf, ArgsContext } from './chunk-
|
|
4
|
-
import { isPlainObject } from '
|
|
5
|
-
import { useVisibleRaf, useLatest } from '@weasel-js/core';
|
|
3
|
+
import { portSafePart, appliedLocal, withUnsent, coverOf, ArgsContext } from './chunk-5KI5YSQ5.js';
|
|
4
|
+
import { useVisibleRaf, useLatest, isPlainObject } from '@weasel-js/core';
|
|
6
5
|
import { createContext, useSyncExternalStore, useRef, useEffect, useState, Component, useContext, createElement } from 'react';
|
|
7
6
|
import { jsx } from 'react/jsx-runtime';
|
|
8
7
|
import { f } from '@weasel-js/labkit/config';
|
|
@@ -40,10 +39,14 @@ var PAGE_RULES = [
|
|
|
40
39
|
"page-has-heading-one",
|
|
41
40
|
"region"
|
|
42
41
|
];
|
|
42
|
+
var last = Promise.resolve();
|
|
43
43
|
async function runAxe(element, { page = true } = {}) {
|
|
44
44
|
const axe = await loadAxe();
|
|
45
45
|
const rules = page ? void 0 : Object.fromEntries(PAGE_RULES.map((id) => [id, { enabled: false }]));
|
|
46
|
-
const
|
|
46
|
+
const run = () => axe.run(element, rules ? { rules } : void 0);
|
|
47
|
+
const running = last.then(run, run);
|
|
48
|
+
last = running;
|
|
49
|
+
const result = await running;
|
|
47
50
|
return {
|
|
48
51
|
violations: result.violations.map(finding),
|
|
49
52
|
incomplete: result.incomplete.map(finding),
|
|
@@ -142,37 +145,6 @@ ${decls.join("\n")}
|
|
|
142
145
|
};
|
|
143
146
|
}
|
|
144
147
|
|
|
145
|
-
// src/frame/capture.ts
|
|
146
|
-
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
147
|
-
function documentCss(doc) {
|
|
148
|
-
const out = [];
|
|
149
|
-
for (const sheet of Array.from(doc.styleSheets)) {
|
|
150
|
-
try {
|
|
151
|
-
for (const rule of Array.from(sheet.cssRules)) out.push(rule.cssText);
|
|
152
|
-
} catch {
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return out.join("\n");
|
|
156
|
-
}
|
|
157
|
-
function captureElement(element) {
|
|
158
|
-
const doc = element.ownerDocument;
|
|
159
|
-
const rect = element.getBoundingClientRect();
|
|
160
|
-
const w = Math.max(1, Math.ceil(rect.width));
|
|
161
|
-
const h = Math.max(1, Math.ceil(rect.height));
|
|
162
|
-
const root = doc.createElement("div");
|
|
163
|
-
root.setAttribute("data-fg-capture", "");
|
|
164
|
-
const tokens = scanCssVars(doc).filter((v) => v.value).map((v) => `${v.name}: ${v.value};`).join("");
|
|
165
|
-
const style = doc.createElement("style");
|
|
166
|
-
style.textContent = `${documentCss(doc)}
|
|
167
|
-
[data-fg-capture]{${tokens}}`;
|
|
168
|
-
root.append(style, element.cloneNode(true));
|
|
169
|
-
const inner = new XMLSerializer().serializeToString(root);
|
|
170
|
-
return {
|
|
171
|
-
kind: "svg",
|
|
172
|
-
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>`
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
148
|
// src/frame/globalsTarget.ts
|
|
177
149
|
function createGlobalsTarget(root, scope) {
|
|
178
150
|
const doc = root.ownerDocument;
|
|
@@ -199,25 +171,25 @@ var NEVER = () => () => {
|
|
|
199
171
|
var notPlaying = () => false;
|
|
200
172
|
function useClockLoop(clock, target) {
|
|
201
173
|
const playing = useSyncExternalStore(clock?.subscribe ?? NEVER, clock ? () => clock.get().playing : notPlaying);
|
|
202
|
-
const
|
|
174
|
+
const last2 = useRef(null);
|
|
203
175
|
const raf = useVisibleRaf(
|
|
204
176
|
(now) => {
|
|
205
177
|
if (!clock) return;
|
|
206
|
-
const prev =
|
|
207
|
-
|
|
178
|
+
const prev = last2.current;
|
|
179
|
+
last2.current = now;
|
|
208
180
|
if (prev !== null) clock.tick(now - prev);
|
|
209
181
|
if (clock.get().playing) raf.request();
|
|
210
182
|
},
|
|
211
183
|
{
|
|
212
184
|
...target ? { target } : {},
|
|
213
185
|
onResume: () => {
|
|
214
|
-
|
|
186
|
+
last2.current = null;
|
|
215
187
|
}
|
|
216
188
|
}
|
|
217
189
|
);
|
|
218
190
|
useEffect(() => {
|
|
219
191
|
if (!playing) return;
|
|
220
|
-
|
|
192
|
+
last2.current = null;
|
|
221
193
|
raf.request();
|
|
222
194
|
return () => raf.cancel();
|
|
223
195
|
}, [playing, raf]);
|
|
@@ -532,9 +504,8 @@ function Scoped({
|
|
|
532
504
|
createElement(ArgsContext.Provider, { value: scope }, createElement(Call, { fn: () => fn(context) }))
|
|
533
505
|
);
|
|
534
506
|
}
|
|
535
|
-
function loadCsfModule(mod,
|
|
507
|
+
function loadCsfModule(mod, title, projectParameters = {}) {
|
|
536
508
|
const meta = isPlainObject(mod.default) ? mod.default : {};
|
|
537
|
-
const title = meta.title ?? autoTitle;
|
|
538
509
|
const stories = [];
|
|
539
510
|
for (const [exportName, value] of Object.entries(mod)) {
|
|
540
511
|
if (exportName === "default" || exportName === "__namedExportsOrder" || exportName === "__esModule") continue;
|
|
@@ -648,7 +619,50 @@ function indexRenderOf(mod) {
|
|
|
648
619
|
const render = isNative(meta, "meta") ? meta?.index : meta?.parameters?.forge?.index;
|
|
649
620
|
return typeof render === "function" ? render : null;
|
|
650
621
|
}
|
|
622
|
+
var IN_VIEW_MARGIN = "50%";
|
|
623
|
+
function useNearViewport(ref, margin, initial = true) {
|
|
624
|
+
const [near, setNear] = useState(() => initial || typeof IntersectionObserver === "undefined");
|
|
625
|
+
useEffect(() => {
|
|
626
|
+
const el = ref.current;
|
|
627
|
+
if (!el || typeof IntersectionObserver === "undefined") return;
|
|
628
|
+
const recheck = () => {
|
|
629
|
+
observer.unobserve(el);
|
|
630
|
+
observer.observe(el);
|
|
631
|
+
};
|
|
632
|
+
let watching = false;
|
|
633
|
+
const watch = (on) => {
|
|
634
|
+
if (on === watching) return;
|
|
635
|
+
watching = on;
|
|
636
|
+
if (on) {
|
|
637
|
+
document.addEventListener("scroll", recheck, { capture: true, passive: true });
|
|
638
|
+
window.addEventListener("resize", recheck);
|
|
639
|
+
} else {
|
|
640
|
+
document.removeEventListener("scroll", recheck, { capture: true });
|
|
641
|
+
window.removeEventListener("resize", recheck);
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
const observer = new IntersectionObserver(
|
|
645
|
+
(entries) => {
|
|
646
|
+
const last2 = entries.at(-1);
|
|
647
|
+
if (!last2) return;
|
|
648
|
+
const root = last2.rootBounds;
|
|
649
|
+
const box = last2.boundingClientRect;
|
|
650
|
+
setNear(
|
|
651
|
+
root ? box.bottom >= root.top && box.top <= root.bottom && box.right >= root.left && box.left <= root.right : last2.isIntersecting
|
|
652
|
+
);
|
|
653
|
+
watch(Boolean(root) && !last2.isIntersecting);
|
|
654
|
+
},
|
|
655
|
+
{ root: document, rootMargin: margin }
|
|
656
|
+
);
|
|
657
|
+
observer.observe(el);
|
|
658
|
+
return () => {
|
|
659
|
+
observer.disconnect();
|
|
660
|
+
watch(false);
|
|
661
|
+
};
|
|
662
|
+
}, [ref, margin]);
|
|
663
|
+
return near;
|
|
664
|
+
}
|
|
651
665
|
|
|
652
|
-
export {
|
|
653
|
-
//# sourceMappingURL=chunk-
|
|
654
|
-
//# sourceMappingURL=chunk-
|
|
666
|
+
export { IN_VIEW_MARGIN, StoryHost, createGlobalsTarget, createOverrides, indexRenderOf, loadStories, resolveCssVar, runAxe, scanCssVars, useClockLoop, useNearViewport, useStoryClock };
|
|
667
|
+
//# sourceMappingURL=chunk-B3PPHJTS.js.map
|
|
668
|
+
//# sourceMappingURL=chunk-B3PPHJTS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/frame/a11y.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"],"names":["last","useEffect","jsx","value","isPlainObject","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,GA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iB,UAAU,OAAO,CAAA;AAAA,MAC3C,CAAA,MAAO;AACL,QAAA,QAAA,CAAS,oBAAoB,QAAA,EAAU,OAAA,EAAS,EAAE,OAAA,EAAS,MAAM,CAAA;AACjE,QAAA,MAAA,CAAO,mBAAA,CAAoB,UAAU,OAAO,CAAA;AAAA,MAC9C;AAAA,IACF,CAAA;AACA,IAAA,MAAM,WAAW,IAAI,oBAAA;AAAA,MACnB,CAAC,OAAA,KAAY;AACX,QAAA,MAAMD,KAAAA,GAAO,OAAA,CAAQ,EAAA,CAAG,EAAE,CAAA;AAC1B,QAAA,IAAI,CAACA,KAAAA,EAAM;AACX,QAAA,MAAM,OAAOA,KAAAA,CAAK,UAAA;AAClB,QAAA,MAAM,MAAMA,KAAAA,CAAK,kBAAA;AACjB,QAAA,OAAA;AAAA,UACE,OACI,GAAA,CAAI,MAAA,IAAU,IAAA,CAAK,GAAA,IAAO,IAAI,GAAA,IAAO,IAAA,CAAK,MAAA,IAAU,GAAA,CAAI,SAAS,IAAA,CAAK,IAAA,IAAQ,IAAI,IAAA,IAAQ,IAAA,CAAK,QAC/FA,KAAAA,CAAK;AAAA,SACX;AAEA,QAAA,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,IAAK,CAACA,MAAK,cAAc,CAAA;AAAA,MAC7C,CAAA;AAAA,MACA,EAAE,IAAA,EAAM,QAAA,EAAU,UAAA,EAAY,MAAA;AAAO,KACvC;AACA,IAAA,QAAA,CAAS,QAAQ,EAAE,CAAA;AACnB,IAAA,OAAO,MAAM;AACX,MAAA,QAAA,CAAS,UAAA,EAAW;AACpB,MAAA,KAAA,CAAM,KAAK,CAAA;AAAA,IACb,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,GAAA,EAAK,MAAM,CAAC,CAAA;AAChB,EAAA,OAAO,IAAA;AACT","file":"chunk-B3PPHJTS.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// 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","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","/** 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 '@weasel-js/core';\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 '@weasel-js/core';\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. `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\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/**\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"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stableStringify } from './chunk-TXLWQFF6.js';
|
|
2
2
|
import { valueAtPath, isConfigBranch } from '@weasel-js/labkit/config';
|
|
3
|
+
import { isPlainObject } from '@weasel-js/core';
|
|
3
4
|
|
|
4
5
|
var PLAYHEAD_PARAM = "t";
|
|
5
6
|
var RESERVED_PARAMS = /* @__PURE__ */ new Set([PLAYHEAD_PARAM]);
|
|
@@ -147,5 +148,5 @@ function storyHref(story, knobs = {}, params = {}) {
|
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
export { PLAYHEAD_PARAM, RESERVED_PARAMS, decodeKnob, encodeKnob, formatRoute, knobParams, knobPaths, knobsToParams, paramsToKnobs, parseRoute, reservedParams, sameKnob, storyHref };
|
|
150
|
-
//# sourceMappingURL=chunk-
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
151
|
+
//# sourceMappingURL=chunk-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AI,OAAA,KAAY,MAAA,EAAW,MAAA,CAAO,IAAI,CAAA,GAAI,OAAA;AAAA,EAC5C;AACA,EAAA,OAAO,MAAA;AACT;AAMO,SAAS,aAAA,CACd,QACA,MAAA,EACyB;AACzB,EAAA,MAAM,QAAiC,EAAC;AACxC,EAAA,KAAA,MAAW,EAAE,IAAA,EAAM,IAAA,EAAK,IAAK,SAAA,CAAU,MAAM,CAAA,EAAG;AAC9C,IAAA,MAAM,GAAA,GAAM,OAAO,IAAI,CAAA;AACvB,IAAA,IAAI,GAAA,KAAQ,MAAA,IAAa,CAAC,WAAA,CAAY,IAAI,CAAA,EAAG;AAC7C,IAAA,MAAM,OAAA,GAAU,UAAA,CAAW,GAAA,EAAK,IAAI,CAAA;AACpC,IAAA,IAAI,OAAA,EAAS,KAAA,CAAM,IAAI,CAAA,GAAI,OAAA,CAAQ,KAAA;AAAA,EACrC;AACA,EAAA,OAAO,KAAA;AACT;AAMO,SAAS,UACd,KAAA,EACA,KAAA,GAA2C,EAAC,EAC5C,MAAA,GAA2C,EAAC,EACpC;AACR,EAAA,MAAM,UAAkC,EAAC;AACzC,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AACjD,IAAA,MAAM,GAAA,GAAM,WAAW,KAAK,CAAA;AAC5B,IAAA,IAAI,QAAQ,MAAA,IAAa,WAAA,CAAY,IAAI,CAAA,EAAG,OAAA,CAAQ,IAAI,CAAA,GAAI,GAAA;AAAA,EAC9D;AACA,EAAA,OAAO,WAAA,CAAY,EAAE,KAAA,EAAO,MAAA,EAAQ,EAAE,GAAG,OAAA,EAAS,GAAG,cAAA,CAAe,MAAM,CAAA,EAAE,EAAG,CAAA;AACjF","file":"chunk-FRUA5WJF.js","sourcesContent":["import { type ConfigSchema, type ConfigShape, isConfigBranch, valueAtPath } from '@weasel-js/labkit/config';\nimport { isPlainObject } from '@weasel-js/core';\nimport { stableStringify } from '../protocol/messages';\n\n/**\n * Forge's URL, as pure functions: `#/<story id>?<params>`. The story and its params share the hash, so the page's\n * own query string stays the host's. A param is a knob — a story arg, addressed by its dotted config path\n * (`look.px`) — unless its name is reserved for the workshop itself.\n */\n\n/** The param a paused playhead is held in, in seconds. */\nexport const PLAYHEAD_PARAM = 't';\n\n/** Param names that are never knobs. */\nexport const RESERVED_PARAMS: ReadonlySet<string> = new Set([PLAYHEAD_PARAM]);\n\n/** Config keys forge keeps for itself, such as the `$globals` pins, start with this and never reach the URL. */\nconst INTERNAL_PREFIX = '$';\n\n/** What a forge hash holds: the story it names, and every param after it, knobs and reserved alike, in order. */\nexport interface ForgeRoute {\n story: string | null;\n params: Readonly<Record<string, string>>;\n}\n\n/** Reads a hash (`location.hash`, with or without its `#`). Anything not in the `#/<id>` form names no story. */\nexport function parseRoute(hash: string): ForgeRoute {\n const body = hash.startsWith('#') ? hash.slice(1) : hash;\n if (!body.startsWith('/')) return { story: null, params: {} };\n const at = body.indexOf('?');\n const path = at === -1 ? body.slice(1) : body.slice(1, at);\n let story: string | null;\n try {\n story = decodeURIComponent(path) || null;\n } catch {\n story = null;\n }\n const params: Record<string, string> = {};\n if (at !== -1) for (const [key, value] of new URLSearchParams(body.slice(at + 1))) params[key] = value;\n return { story, params };\n}\n\n/** The hash for `route`, with its leading `#`. The inverse of `parseRoute`. */\nexport function formatRoute(route: ForgeRoute): string {\n const query = new URLSearchParams(Object.entries(route.params)).toString();\n return `#/${encodeURIComponent(route.story ?? '')}${query ? `?${query}` : ''}`;\n}\n\n/** Whether a param name can be a knob: not reserved and not one of forge's own config keys. */\nexport function isKnobParam(name: string): boolean {\n return name !== '' && !RESERVED_PARAMS.has(name) && !name.startsWith(INTERNAL_PREFIX);\n}\n\n/** The params that are knobs, with the reserved ones left out. */\nexport function knobParams(params: Readonly<Record<string, string>>): Record<string, string> {\n return Object.fromEntries(Object.entries(params).filter(([name]) => isKnobParam(name)));\n}\n\n/** The params that are not knobs. Kept as they are when the knobs are rewritten. */\nexport function reservedParams(params: Readonly<Record<string, string>>): Record<string, string> {\n return Object.fromEntries(Object.entries(params).filter(([name]) => !isKnobParam(name)));\n}\n\n/** What a knob's value is decoded against: its schema leaf's declared kind, its default, and its choices. */\nexport interface KnobLeaf {\n kind: string | null;\n default: unknown;\n annotations?: { options?: readonly { value: string }[] };\n}\n\ntype Codec = 'number' | 'boolean' | 'string' | 'enum' | 'json';\n\n/** How a leaf's value travels: by its declared kind first, then by the type of its default. */\nfunction codecOf(leaf: KnobLeaf): Codec | null {\n switch (leaf.kind) {\n case 'number':\n case 'boolean':\n case 'string':\n case 'enum':\n return leaf.kind;\n case 'color':\n return 'string';\n case 'list':\n case 'json':\n return 'json';\n }\n const d = leaf.default;\n if (typeof d === 'number' || typeof d === 'boolean' || typeof d === 'string') return typeof d as Codec;\n return Array.isArray(d) || isPlainObject(d) ? 'json' : null;\n}\n\n/** A value as one param. Undefined for a value no param can carry, such as a function. */\nexport function encodeKnob(value: unknown): string | undefined {\n switch (typeof value) {\n case 'string':\n return value;\n case 'number':\n case 'boolean':\n return String(value);\n case 'object':\n return value !== null && (Array.isArray(value) || isPlainObject(value)) ? JSON.stringify(value) : undefined;\n default:\n return undefined;\n }\n}\n\n/** Whether `value` is something a leaf of codec `codec` could hold, so a well-formed param of the wrong type is refused. */\nfunction fits(codec: Codec, value: unknown, leaf: KnobLeaf): boolean {\n if (codec !== 'json') return true;\n const d = leaf.default;\n if (Array.isArray(d)) {\n if (!Array.isArray(value)) return false;\n return leaf.kind !== 'list' || value.every((item) => typeof item === 'string');\n }\n if (isPlainObject(d)) return isPlainObject(value);\n return true;\n}\n\n/**\n * One param read as `leaf`'s type: `{ value }`, or undefined for a param that does not parse as one — a number that\n * is not a number, an option the enum does not list, malformed JSON. A bare boolean param (`?dark`) reads as true.\n */\nexport function decodeKnob(raw: string, leaf: KnobLeaf): { value: unknown } | undefined {\n const codec = codecOf(leaf);\n switch (codec) {\n case 'number': {\n const n = raw.trim() === '' ? Number.NaN : Number(raw);\n return Number.isNaN(n) ? undefined : { value: n };\n }\n case 'boolean':\n if (raw === '' || raw === 'true' || raw === '1') return { value: true };\n if (raw === 'false' || raw === '0') return { value: false };\n return undefined;\n case 'string':\n return { value: raw };\n case 'enum': {\n const options = leaf.annotations?.options;\n return !options || options.some((o) => o.value === raw) ? { value: raw } : undefined;\n }\n case 'json': {\n try {\n const value: unknown = JSON.parse(raw);\n return fits(codec, value, leaf) ? { value } : undefined;\n } catch {\n return undefined;\n }\n }\n default:\n return undefined;\n }\n}\n\n/** One leaf a URL can address: its dotted path, and what its value decodes against. */\nexport interface KnobPath {\n path: string;\n leaf: KnobLeaf;\n}\n\n/** Every leaf of `schema` a param can carry, in schema order, with branches flattened into dotted paths. */\nexport function knobPaths(schema: Pick<ConfigSchema<unknown>, 'nodes'>): KnobPath[] {\n const out: KnobPath[] = [];\n const walk = (shape: ConfigShape, at: string): void => {\n for (const [key, entry] of Object.entries(shape)) {\n if (key.startsWith(INTERNAL_PREFIX) || key.includes('.')) continue;\n const path = at === '' ? key : `${at}.${key}`;\n if (isConfigBranch(entry)) walk(entry.children, path);\n else if (codecOf(entry) !== null) out.push({ path, leaf: entry });\n }\n };\n walk(schema.nodes, '');\n return out;\n}\n\n/** Whether two knob values are the same value, compared as data. */\nexport function sameKnob(a: unknown, b: unknown): boolean {\n return Object.is(a, b) || stableStringify(a) === stableStringify(b);\n}\n\n/**\n * The knob params for `config`: one per leaf whose value differs from its default, keyed by dotted path, in schema\n * order. A leaf absent from `config` is at its default.\n */\nexport function knobsToParams(schema: Pick<ConfigSchema<unknown>, 'nodes'>, config: unknown): Record<string, string> {\n const params: Record<string, string> = {};\n for (const { path, leaf } of knobPaths(schema)) {\n const value = valueAtPath(config, path);\n if (value === undefined || sameKnob(value, leaf.default)) continue;\n const encoded = encodeKnob(value);\n if (encoded !== undefined) params[path] = encoded;\n }\n return params;\n}\n\n/**\n * The knob values `params` sets, by dotted path, each coerced to its leaf's type. A param naming no leaf, a reserved\n * param, and one that does not parse as its leaf's type are left out rather than failing the rest.\n */\nexport function paramsToKnobs(\n schema: Pick<ConfigSchema<unknown>, 'nodes'>,\n params: Readonly<Record<string, string>>,\n): Record<string, unknown> {\n const knobs: Record<string, unknown> = {};\n for (const { path, leaf } of knobPaths(schema)) {\n const raw = params[path];\n if (raw === undefined || !isKnobParam(path)) continue;\n const decoded = decodeKnob(raw, leaf);\n if (decoded) knobs[path] = decoded.value;\n }\n return knobs;\n}\n\n/**\n * A link to a story at a given state, for a host that has no schema to hand: each knob is a dotted path and a value,\n * encoded by its own type. `params` adds workshop params, such as `t`.\n */\nexport function storyHref(\n story: string,\n knobs: Readonly<Record<string, unknown>> = {},\n params: Readonly<Record<string, string>> = {},\n): string {\n const encoded: Record<string, string> = {};\n for (const [path, value] of Object.entries(knobs)) {\n const raw = encodeKnob(value);\n if (raw !== undefined && isKnobParam(path)) encoded[path] = raw;\n }\n return formatRoute({ story, params: { ...encoded, ...reservedParams(params) } });\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPlainObject } from '@weasel-js/core';
|
|
1
2
|
import { f } from '@weasel-js/labkit/config';
|
|
2
3
|
|
|
3
4
|
// src/shell/globals.ts
|
|
@@ -5,7 +6,7 @@ var GLOBALS_KEY = "$globals";
|
|
|
5
6
|
var FOLLOW_LAB = "lab";
|
|
6
7
|
var FOLLOW_APP = "app";
|
|
7
8
|
var APP_OPTION = { value: FOLLOW_APP, label: "App" };
|
|
8
|
-
var isRecord =
|
|
9
|
+
var isRecord = isPlainObject;
|
|
9
10
|
var isGlobalsPath = (path) => path === GLOBALS_KEY || path.startsWith(`${GLOBALS_KEY}.`);
|
|
10
11
|
var PLAYHEAD_KEY = "$playhead";
|
|
11
12
|
var FORGE_KEYS = /* @__PURE__ */ new Set([GLOBALS_KEY, PLAYHEAD_KEY]);
|
|
@@ -76,5 +77,5 @@ function withGlobals(schema, declarations) {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
export { FOLLOW_APP, GLOBALS_KEY, PLAYHEAD_KEY, effectiveGlobals, followApp, isForgePath, isGlobalsPath, labGlobals, labOptions, storyConfig, withGlobals };
|
|
79
|
-
//# sourceMappingURL=chunk-
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-JHL4ERDA.js.map
|
|
81
|
+
//# sourceMappingURL=chunk-JHL4ERDA.js.map
|