@weasel-js/forge 1.11.1 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -0
- package/dist/{FrameController-Cj_i-Rdk.d.ts → FrameController-CdnaIo4C.d.ts} +1 -1
- package/dist/{chunk-7BQPHMA2.js → chunk-3BAM6M26.js} +2 -2
- package/dist/chunk-3BAM6M26.js.map +1 -0
- package/dist/{chunk-ZAWXMUGZ.js → chunk-5WS67HMU.js} +8 -3
- package/dist/chunk-5WS67HMU.js.map +1 -0
- package/dist/{chunk-BKPDKUDN.js → chunk-ATI7FYJ7.js} +8 -5
- package/dist/chunk-ATI7FYJ7.js.map +1 -0
- package/dist/chunk-ORMMZ5PV.js +59 -0
- package/dist/chunk-ORMMZ5PV.js.map +1 -0
- package/dist/{chunk-JTCUIJPZ.js → chunk-WMGEO5M6.js} +49 -7
- package/dist/chunk-WMGEO5M6.js.map +1 -0
- package/dist/chunk-YDLRSEUN.js +501 -0
- package/dist/chunk-YDLRSEUN.js.map +1 -0
- package/dist/{config-DN6IaNf6.d.ts → config-Mg05Ja9r.d.ts} +18 -1
- package/dist/frame/index.css +11 -0
- package/dist/frame/index.css.map +1 -1
- package/dist/frame/index.d.ts +62 -29
- package/dist/frame/index.js +134 -6
- package/dist/frame/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mountFrame-Ds3QLnBF.d.ts +35 -0
- package/dist/shell/index.css +116 -0
- package/dist/shell/index.css.map +1 -1
- package/dist/shell/index.d.ts +43 -7
- package/dist/shell/index.js +1570 -259
- package/dist/shell/index.js.map +1 -1
- package/dist/test/index.css +58 -0
- package/dist/test/index.css.map +1 -0
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.js +4 -4
- package/dist/vite/index.js +501 -106
- package/dist/vite/index.js.map +1 -1
- package/package.json +13 -8
- package/dist/chunk-5DXUNLV2.js +0 -6
- package/dist/chunk-5DXUNLV2.js.map +0 -1
- package/dist/chunk-7BQPHMA2.js.map +0 -1
- package/dist/chunk-BKPDKUDN.js.map +0 -1
- package/dist/chunk-FZNABWJC.js +0 -282
- package/dist/chunk-FZNABWJC.js.map +0 -1
- package/dist/chunk-JTCUIJPZ.js.map +0 -1
- package/dist/chunk-ZAWXMUGZ.js.map +0 -1
package/README.md
CHANGED
|
@@ -160,6 +160,96 @@ focused trial when it shows the routed story, else the first that does. An index
|
|
|
160
160
|
isolated story's frame and a story test show the story paused at its span's
|
|
161
161
|
start, with no transport.
|
|
162
162
|
|
|
163
|
+
## Loupe
|
|
164
|
+
|
|
165
|
+
A lens shows the patch of a story under its reticle, magnified, or rendered
|
|
166
|
+
under a different condition, or both. Lenses float over the whole workshop:
|
|
167
|
+
one stays where it was put while the panes under it scroll and zoom, and one
|
|
168
|
+
parked over a trial can aim at another. They last for the session and are not
|
|
169
|
+
saved with a trial. Drag a lens or its reticle to move it, drag its edge to
|
|
170
|
+
resize it, and press Delete to close a selected one; the lenses keep an undo
|
|
171
|
+
history of their own.
|
|
172
|
+
|
|
173
|
+
Every lens key is in the Loupe keymap. Alt+L opens it, a hint lists its keys
|
|
174
|
+
while it is open, and Escape closes it. Holding Alt+L keeps it open, so a Follow
|
|
175
|
+
lens can be pinned while the pointer is still on the story. Inside it, each key
|
|
176
|
+
acts on the selected lens, or on the last one added when none is selected:
|
|
177
|
+
|
|
178
|
+
| Key | Does | Key | Does |
|
|
179
|
+
|---|---|---|---|
|
|
180
|
+
| `l` | add a lens | `Shift+L` | close the lens |
|
|
181
|
+
| `p` | pin the reticle | `f` | make the reticle follow the pointer |
|
|
182
|
+
| `v` | Live source | `x` | Pixels source |
|
|
183
|
+
| `r` | Pixels at 1×, 2×, or both side by side | `=` / `-` | zoom in / out |
|
|
184
|
+
| `o` | compare with the opposite mode | `k` | choose a comparison |
|
|
185
|
+
| `Shift+O` | clear the comparison | `s` / `\` / `d` | Swap / Split / Difference |
|
|
186
|
+
| `t` | Token readout | `c` | Contrast readout |
|
|
187
|
+
| `g` | pixel grid | | |
|
|
188
|
+
|
|
189
|
+
Each binding's id is its action id (`loupe.add`, `loupe.view.split`, …), so a
|
|
190
|
+
binding override can rebind it. Alt+Slash opens a panel listing every key
|
|
191
|
+
binding the workshop registers, the lens keys included.
|
|
192
|
+
|
|
193
|
+
Token shows the color at the aim and the `--wzl-*` token chain behind it;
|
|
194
|
+
Contrast shows the WCAG ratio of the text there against its background, with
|
|
195
|
+
AA and AAA marks, read from computed styles on a Live lens and from the pixels
|
|
196
|
+
on a Pixels one; the pixel grid draws on a Pixels lens zoomed to 8× or more per
|
|
197
|
+
captured pixel (its zoom over the capture's DPR). On a Live lens with a
|
|
198
|
+
comparison, Token and Contrast read the compared copy. Token reads the DOM, so a
|
|
199
|
+
Pixels lens with a comparison has none to give, and neither reads inside an
|
|
200
|
+
isolated story's frame.
|
|
201
|
+
|
|
202
|
+
**Live** renders the story a second time inside the lens, with the
|
|
203
|
+
comparison's globals or args laid over the trial's. It is sharp at any factor
|
|
204
|
+
and follows the trial's state, but takes no clicks, and it is never the real
|
|
205
|
+
pixels. Being a second render, it shares the story's args and trial state but
|
|
206
|
+
not the story's own React state: a story whose pan and zoom a lens should
|
|
207
|
+
follow keeps them in an arg through `useArgs`, as CanvasStack's stories do.
|
|
208
|
+
**Pixels** asks the dev server
|
|
209
|
+
for a PNG of the story rendered in headless Chromium at a chosen DPR and enlarges
|
|
210
|
+
it nearest-neighbor, so a hairline half a pixel off looks as it does on screen.
|
|
211
|
+
A capture reproduces the story's args, globals, trial state, playhead, CSS
|
|
212
|
+
variable overrides, scroll position (an isolated story's excepted), the lab's
|
|
213
|
+
theme and the OS color scheme; it lags the live story
|
|
214
|
+
by one capture, and has no hover or focus in it. Difference always compares two
|
|
215
|
+
Pixels captures, whichever source the lens shows.
|
|
216
|
+
|
|
217
|
+
Playwright is an optional peer dependency. Without it, or without its Chromium
|
|
218
|
+
(`npx playwright install chromium`), a lens says why Pixels is unavailable and
|
|
219
|
+
offers Live only. The endpoint imports `@weasel-js/core/json`, which resolves to
|
|
220
|
+
core's built `dist`, so build core before starting the dev server in a fresh
|
|
221
|
+
checkout.
|
|
222
|
+
|
|
223
|
+
The endpoint is `<base>__forge/capture`, on the dev server only. A GET says
|
|
224
|
+
whether captures are available, without starting Chromium; a POST takes a JSON
|
|
225
|
+
payload and answers with the PNG. It is guarded against being used to load
|
|
226
|
+
anyone else's page:
|
|
227
|
+
|
|
228
|
+
- The capture page's URL is built from the socket the request arrived on,
|
|
229
|
+
never from its `Host` header.
|
|
230
|
+
- A POST must be `application/json`, and one whose `Origin` is not the dev
|
|
231
|
+
server's own is refused.
|
|
232
|
+
- A CSS variable override must be a custom property name with no `{`, `}` or
|
|
233
|
+
`;` in its value, and overrides are written through the CSSOM.
|
|
234
|
+
- A body past 16 MB is answered 413 and the connection closed.
|
|
235
|
+
- The capture browser blocks service workers, closes every WebSocket but the
|
|
236
|
+
dev server's own, and ignores certificate errors only for an https dev
|
|
237
|
+
server; a listed origin's requests are then fetched from Node, so its
|
|
238
|
+
certificate is still checked.
|
|
239
|
+
- The capture page can load nothing but the dev server's own origin and the
|
|
240
|
+
origins the shell config lists in `capture.allowOrigins`, such as a web-font
|
|
241
|
+
service's:
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
defineShellConfig({ capture: { allowOrigins: ['https://fonts.googleapis.com', 'https://fonts.gstatic.com'] } });
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Captures are cached in the dev-server process, at most 64 entries and 64 MB of
|
|
248
|
+
PNG bytes, least recently used out first. The cache is cleared on any client
|
|
249
|
+
module update and when the server closes. There is one Chromium, started on the
|
|
250
|
+
first capture that misses the cache and closed after 120 s idle or when the
|
|
251
|
+
server closes.
|
|
252
|
+
|
|
163
253
|
## Index pages
|
|
164
254
|
|
|
165
255
|
Every component — every story title — has an index page, opened by clicking
|
|
@@ -396,4 +396,4 @@ declare function startFrame({ story, channel, container, setup }: StartFrameOpti
|
|
|
396
396
|
/** Reports an import failure — there is no story to start. */
|
|
397
397
|
declare function reportImportFault(channel: Channel<ToFrame, FromFrame>, error: unknown): void;
|
|
398
398
|
|
|
399
|
-
export { type A11yFinding as A,
|
|
399
|
+
export { type A11yFinding as A, type SectionDescription as B, type Channel as C, type Decorator as D, type FrameSetup as F, type Globals as G, type IndexEntry as I, type Layout as L, type MetaSpec as M, type PlayContext as P, type StartFrameOptions as S, type ToFrame as T, type Viewport as V, type ConfigAnswers as a, type FaultPhase as b, type FromFrame as c, type StorySpec as d, type ClockState as e, type SpanOverride as f, type A11yNode as g, type A11yReport as h, type ComponentDeps as i, type ComponentHistory as j, type DepGraph as k, type GlobalsTarget as l, type IndexContext as m, type IndexRender as n, type IndexStoryProps as o, type LoadedStory as p, type StoryContext as q, reportImportFault as r, startFrame as s, type Span as t, type TimelineSpec as u, type CssVarReport as v, type A11yOutcome as w, type DescribedEntry as x, type DescribedShape as y, type SchemaDescription as z };
|
|
@@ -77,5 +77,5 @@ function withGlobals(schema, declarations) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export { FOLLOW_APP, GLOBALS_KEY, PLAYHEAD_KEY, effectiveGlobals, followApp, isForgePath, isGlobalsPath, labGlobals, labOptions, storyConfig, withGlobals };
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-3BAM6M26.js.map
|
|
81
|
+
//# sourceMappingURL=chunk-3BAM6M26.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shell/globals.ts"],"names":["from"],"mappings":";;;;AA2CO,IAAM,WAAA,GAAc;AAEpB,IAAM,UAAA,GAAa,KAAA;AAEnB,IAAM,UAAA,GAAa;AAE1B,IAAM,UAAA,GAAa,EAAE,KAAA,EAAO,UAAA,EAAY,OAAO,KAAA,EAAM;AAErD,IAAM,QAAA,GAAW,aAAA;AAEV,IA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asel-js/core';\nimport type { IconRef } from '@weasel-js/icons';\nimport type { LabMode } from '@weasel-js/labkit';\nimport { type ConfigSchema, f } from '@weasel-js/labkit/config';\nimport type { Globals } from '../protocol/messages';\n\n/** One global the workshop's toolbar sets for every story, and a trial may pin for its own. */\nexport interface GlobalDeclaration {\n label: string;\n options: readonly { value: string; label: string }[];\n default: string;\n /** Another global's key: the toolbar shows this one in a popover beside that one rather than in the bar itself. */\n under?: string;\n /** The glyph on the button opening the globals declared `under` this one. Default `core:tune`. */\n icon?: IconRef;\n /**\n * Whether the toolbar offers `value` given the lab's other values; every option shows when absent. `globals` is\n * resolved without any declaration's `shows`, so one `shows` cannot depend on another's outcome.\n */\n shows?: (value: string, globals: Globals) => boolean;\n /**\n * What this global reads from the lab's own chrome. Given, the lab's value may be `App` (`FOLLOW_APP`), offered\n * first, and while it is the global follows that chrome control, as the header's mode switch sets it. A trial's\n * pin follows the lab or names a value; it cannot follow the app on its own.\n */\n follows?: (chrome: LabChrome) => string;\n /**\n * The value opposite `value`, for the global a lens's opposite-mode comparison flips (`ShellConfig.loupe`'s\n * `modeGlobal`); undefined when it has none. `App` and `auto` are resolved to the mode they show before this is\n * asked. Absent, the lens swaps `light` and `dark`.\n */\n opposite?: (value: string, globals: Globals) => string | undefined;\n}\n\n/** The lab chrome's own settings a global can follow. */\nexport interface LabChrome {\n mode: LabMode;\n}\n\n/** The shell config's `globals`: each declaration by the key stories read it under. */\nexport type GlobalDeclarations = Readonly<Record<string, GlobalDeclaration>>;\n\n/** The config group every story schema gains, holding the trial's pins. A story never sees it. */\nexport const GLOBALS_KEY = '$globals';\n/** A pin's value when the trial follows the lab. */\nexport const FOLLOW_LAB = 'lab';\n/** A lab value, for a declaration that `follows` the app, meaning whatever the app's chrome is set to. */\nexport const FOLLOW_APP = 'app';\n\nconst APP_OPTION = { value: FOLLOW_APP, label: 'App' } as const;\n\nconst isRecord = isPlainObject;\n\nexport const isGlobalsPath = (path: string): boolean => path === GLOBALS_KEY || path.startsWith(`${GLOBALS_KEY}.`);\n\n/** The config key a timeline story's paused playhead is kept under, so labkit persists and snapshots it. */\nexport const PLAYHEAD_KEY = '$playhead';\n\n/** Config keys forge owns: a story neither sees nor writes them. */\nconst FORGE_KEYS: ReadonlySet<string> = new Set([GLOBALS_KEY, PLAYHEAD_KEY]);\n\n/** Whether a config path lies under a key forge owns. */\nexport const isForgePath = (path: string): boolean => FORGE_KEYS.has(path.split('.')[0]!);\n\n/** The options the toolbar offers for `declaration` at `globals`. */\nexport function shownOptions(declaration: GlobalDeclaration, globals: Globals): GlobalDeclaration['options'] {\n const { shows } = declaration;\n return shows ? declaration.options.filter((option) => shows(option.value, globals)) : declaration.options;\n}\n\n/** The options the lab's own control offers: `shownOptions`, after `App` where the declaration follows the app. */\nexport function labOptions(declaration: GlobalDeclaration, globals: Globals): GlobalDeclaration['options'] {\n const shown = shownOptions(declaration, globals);\n return declaration.follows ? [APP_OPTION, ...shown] : shown;\n}\n\n/** `values` with each `App` replaced by what its declaration reads from `chrome`; `values` itself when none is. */\nexport function followApp(declarations: GlobalDeclarations, values: Globals, chrome: LabChrome): Globals {\n const followed = Object.entries(declarations).flatMap(([key, { follows }]) =>\n follows && values[key] === FOLLOW_APP ? [[key, follows(chrome)] as const] : [],\n );\n return followed.length === 0 ? values : { ...values, ...Object.fromEntries(followed) };\n}\n\n/**\n * The lab's values from what was stored: declared keys only. A value no option offers falls back to the default, and\n * one its declaration's `shows` hides falls back to the shown option nearest it in `options`, the earlier on a tie.\n */\nexport function labGlobals(declarations: GlobalDeclarations, stored: unknown): Globals {\n const from = isRecord(stored) ? stored : {};\n const offered: Globals = Object.fromEntries(\n Object.entries(declarations).map(([key, declaration]) => {\n const value = from[key];\n const known =\n declaration.options.some((option) => option.value === value) || (declaration.follows && value === FOLLOW_APP);\n return [key, known ? value : declaration.default];\n }),\n );\n return Object.fromEntries(\n Object.entries(declarations).map(([key, declaration]) => {\n const shown = shownOptions(declaration, offered);\n const value = offered[key];\n if (value === FOLLOW_APP && declaration.follows) return [key, value];\n if (!declaration.shows || shown.length === 0 || shown.some((option) => option.value === value)) return [key, value];\n const at = (v: unknown) => declaration.options.findIndex((option) => option.value === v);\n const from = at(value);\n const nearest = shown.reduce((best, option) =>\n Math.abs(at(option.value) - from) < Math.abs(at(best.value) - from) ? option : best,\n );\n return [key, nearest.value];\n }),\n );\n}\n\n/** The lab's values, overridden by the pins in a trial's config that do not follow the lab. */\nexport function effectiveGlobals(lab: Globals, pins: unknown): Globals {\n if (!isRecord(pins)) return lab;\n const pinned = Object.entries(pins).filter(([key, value]) => key in lab && value !== FOLLOW_LAB);\n return pinned.length === 0 ? lab : { ...lab, ...Object.fromEntries(pinned) };\n}\n\n/**\n * The config a story receives: the trial's, without the keys forge owns. Returns `previous` when every other entry is\n * the same, so a change to a pin or the playhead alone is not a change to the story's config.\n */\nexport function storyConfig(config: unknown, previous?: unknown): unknown {\n if (!isRecord(config) || !Object.keys(config).some((key) => FORGE_KEYS.has(key))) return config;\n const rest = Object.fromEntries(Object.entries(config).filter(([key]) => !FORGE_KEYS.has(key)));\n if (isRecord(previous)) {\n const keys = Object.keys(rest);\n if (keys.length === Object.keys(previous).length && keys.every((key) => rest[key] === previous[key])) return previous;\n }\n return rest;\n}\n\n/** `schema` with a `$globals` group appended: one leaf per declaration, following the lab until pinned. */\nexport function withGlobals(schema: ConfigSchema<unknown>, declarations: GlobalDeclarations): ConfigSchema<unknown> {\n const entries = Object.entries(declarations);\n if (entries.length === 0) return schema;\n const leaves = Object.fromEntries(\n entries.map(([key, declaration]) => [\n key,\n f.enum(FOLLOW_LAB, [{ value: FOLLOW_LAB, label: 'Lab' }, ...declaration.options]).label(declaration.label),\n ]),\n );\n // An empty group name contributes rows without a heading of its own, under the section's.\n const group = f.group(leaves).label('').section('Globals', { layout: 'inline', pack: 'pairs', className: 'fg-globals-pins' });\n return f.schema({ ...schema.nodes, [GLOBALS_KEY]: group }) as ConfigSchema<unknown>;\n}\n"]}
|
|
@@ -17,6 +17,11 @@ function storyNameFromExport(exportName) {
|
|
|
17
17
|
// src/csf/propArgTypes.ts
|
|
18
18
|
var PROP_ARG_TYPES_EXPORT = "__forgeArgTypes";
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// src/frame/safeOverride.ts
|
|
21
|
+
function isSafeOverride(name, value) {
|
|
22
|
+
return /^--[\w-]+$/.test(name) && !/[{};]/.test(value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { PROP_ARG_TYPES_EXPORT, isSafeOverride, sanitize, storyId, storyNameFromExport };
|
|
26
|
+
//# sourceMappingURL=chunk-5WS67HMU.js.map
|
|
27
|
+
//# sourceMappingURL=chunk-5WS67HMU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/story/ids.ts","../src/csf/propArgTypes.ts","../src/frame/safeOverride.ts"],"names":[],"mappings":";AAIO,SAAS,SAAS,IAAA,EAAsB;AAC7C,EAAA,OAAO,KACJ,WAAA,EAAY,CACZ,OAAA,CAAQ,iDAAA,EAAmD,GAAG,CAAA,CAC9D,OAAA,CAAQ,KAAA,EAAO,GAAG,EAClB,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA,CACjB,OAAA,CAAQ,OAAO,EAAE,CAAA;AACtB;AAEA,SAAS,YAAA,CAAa,MAAc,IAAA,EAA+B;AACjE,EAAA,MAAM,SAAA,GAAY,SAAS,IAAI,CAAA;AAC/B,EAAA,IAAI,SAAA,KAAc,IAAI,MAAM,IAAI,MAAM,CAAA,QAAA,EAAW,IAAI,CAAA,EAAA,EAAK,IAAI,CAAA,uCAAA,CAAyC,CAAA;AACvG,EAAA,OAAO,SAAA;AACT;AAEO,SAAS,OAAA,CAAQ,OAAe,UAAA,EAA4B;AACjE,EAAA,OAAO,CAAA,EAAG,aAAa,KAAA,EAAO,MAAM,CAAC,CAAA,EAAA,EAAK,YAAA,CAAa,UAAA,EAAY,MAAM,CAAC,CAAA,CAAA;AAC5E;AAGO,SAAS,oBAAoB,UAAA,EAA4B;AAC9D,EAAA,OAAO,WACJ,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA,CACjB,QAAQ,IAAA,EAAM,GAAG,CAAA,CACjB,OAAA,CAAQ,OAAO,GAAG,CAAA,CAClB,QAAQ,wBAAA,EAA0B,CAAC,GAAG,CAAA,EAAW,CAAA,EAAW,CAAA,KAAc,CAAA,EAAG,CAAC,CAAA,CAAA,EAAI,CAAC,GAAG,CAAC,CAAA,CAAE,EACzF,OAAA,CAAQ,iBAAA,EAAmB,CAAC,CAAA,EAAG,GAAW,CAAA,KAAc,CAAA,EAAG,CAAC,CAAA,CAAA,EAAI,CAAC,EAAE,CAAA,CACnE,OAAA,CAAQ,kBAAA,EAAoB,CAAC,GAAG,CAAA,EAAW,CAAA,KAAc,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA,CAAE,CAAA,CACpE,OAAA,CAAQ,oBAAoB,CAAC,CAAA,EAAG,GAAW,CAAA,KAAc,CAAA,EAAG,CAAC,CAAA,CAAA,EAAI,CAAC,CAAA,CAAE,CAAA,CACpE,QAAQ,aAAA,EAAe,CAAC,GAAG,CAAA,EAAW,CAAA,KAAc,GAAG,CAAC,CAAA,EAAG,CAAA,CAAE,WAAA,EAAa,CAAA,CAAE,CAAA,CAC5E,QAAQ,KAAA,EAAO,GAAG,EAClB,IAAA,EAAK;AACV;;;ACnCO,IAAM,qBAAA,GAAwB;;;ACG9B,SAAS,cAAA,CAAe,MAAc,KAAA,EAAwB;AACnE,EAAA,OAAO,aAAa,IAAA,CAAK,IAAI,KAAK,CAAC,OAAA,CAAQ,KAAK,KAAK,CAAA;AACvD","file":"chunk-5WS67HMU.js","sourcesContent":["// sanitize, storyId and storyNameFromExport are ports of storybook/internal/csf (10.4.0)'s\n// sanitize, toId and storyNameFromExport; they must agree or links diverge.\n\n/** Lower-case; runs of the listed separators become one dash. Everything else, non-ASCII letters included, survives. */\nexport function sanitize(part: string): string {\n return part\n .toLowerCase()\n .replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\\-=?;:'\",.<>{}[\\]\\\\/]/gi, '-')\n .replace(/-+/g, '-')\n .replace(/^-+/, '')\n .replace(/-+$/, '');\n}\n\nfunction sanitizeSafe(part: string, kind: 'kind' | 'name'): string {\n const sanitized = sanitize(part);\n if (sanitized === '') throw new Error(`Invalid ${kind} '${part}', must include alphanumeric characters`);\n return sanitized;\n}\n\nexport function storyId(title: string, exportName: string): string {\n return `${sanitizeSafe(title, 'kind')}--${sanitizeSafe(exportName, 'name')}`;\n}\n\n/** `PrimaryButton` → `Primary Button`, `withIcon2` → `With Icon 2`. */\nexport function storyNameFromExport(exportName: string): string {\n return exportName\n .replace(/_/g, ' ')\n .replace(/-/g, ' ')\n .replace(/\\./g, ' ')\n .replace(/([^\\n])([A-Z])([a-z])/g, (_, a: string, b: string, c: string) => `${a} ${b}${c}`)\n .replace(/([a-z])([A-Z])/g, (_, a: string, b: string) => `${a} ${b}`)\n .replace(/([a-z])([0-9])/gi, (_, a: string, b: string) => `${a} ${b}`)\n .replace(/([0-9])([a-z])/gi, (_, a: string, b: string) => `${a} ${b}`)\n .replace(/(\\s|^)(\\w)/g, (_, a: string, b: string) => `${a}${b.toUpperCase()}`)\n .replace(/ +/g, ' ')\n .trim();\n}\n","/** The named export forge's vite plugin adds to a story module: argTypes read from the props of the meta's `component`. */\nexport const PROP_ARG_TYPES_EXPORT = '__forgeArgTypes';\n","/**\n * Whether a CSS variable override can be declared as given: a custom property name, and a value that cannot close\n * the declaration or the rule around it. A value that could would let whoever sets it write rules of their own.\n */\nexport function isSafeOverride(name: string, value: string): boolean {\n return /^--[\\w-]+$/.test(name) && !/[{};]/.test(value);\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useNearViewport, StoryHost } from './chunk-
|
|
2
|
-
import { sanitize } from './chunk-
|
|
1
|
+
import { useNearViewport, StoryHost } from './chunk-WMGEO5M6.js';
|
|
2
|
+
import { sanitize } from './chunk-5WS67HMU.js';
|
|
3
3
|
import { PROTOCOL_VERSION } from './chunk-GH5RE5X5.js';
|
|
4
4
|
import { createRoot } from 'react-dom/client';
|
|
5
5
|
import { IconRegistryProvider, isPlainObject } from '@weasel-js/core';
|
|
@@ -170,6 +170,9 @@ function librariesFrom(table = []) {
|
|
|
170
170
|
}
|
|
171
171
|
var TITLE_LIBRARIES = librariesFrom();
|
|
172
172
|
var LibrariesContext = createContext(TITLE_LIBRARIES);
|
|
173
|
+
|
|
174
|
+
// src/shell/labDensity.ts
|
|
175
|
+
var LAB_DENSITY = "roomy";
|
|
173
176
|
function LibraryBadge({ library, className }) {
|
|
174
177
|
const tone = useContext(LibrariesContext).toneOf(library);
|
|
175
178
|
return /* @__PURE__ */ jsx(Badge, { status: "muted", ...tone === void 0 ? {} : { tone }, variant: "subtle", size: "sm", ...className ? { className } : {}, children: library });
|
|
@@ -405,6 +408,6 @@ function IndexPage({ env, render }) {
|
|
|
405
408
|
return /* @__PURE__ */ jsx(IndexEnvContext.Provider, { value: env, children: render ? render(indexContext(env)) : /* @__PURE__ */ jsx(DefaultIndex, {}) });
|
|
406
409
|
}
|
|
407
410
|
|
|
408
|
-
export { IndexPage, LibrariesContext, LibraryBadge, TITLE_LIBRARIES, answerSchema, createKitRoot, describeSchema, indexEntries, indexId, isIndexId, librariesFrom, openChannel, schemaFromDescription };
|
|
409
|
-
//# sourceMappingURL=chunk-
|
|
410
|
-
//# sourceMappingURL=chunk-
|
|
411
|
+
export { IndexPage, LAB_DENSITY, LibrariesContext, LibraryBadge, TITLE_LIBRARIES, answerSchema, createKitRoot, describeSchema, indexEntries, indexId, isIndexId, librariesFrom, openChannel, schemaFromDescription };
|
|
412
|
+
//# sourceMappingURL=chunk-ATI7FYJ7.js.map
|
|
413
|
+
//# sourceMappingURL=chunk-ATI7FYJ7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/kitIcons.tsx","../src/protocol/schema.ts","../src/protocol/channel.ts","../src/story/indexPages.ts","../src/story/library.ts","../src/shell/labDensity.ts","../src/frame/index/LibraryBadge.tsx","../src/frame/index/variants.ts","../src/frame/index/IndexPage.tsx"],"names":["jsx","resolveConfigSchema","isEntryShown","isConfigBranch","createContext","useContext","Badge"],"mappings":";;;;;;;;;;;;;;AAQO,SAAS,aAAA,CAAc,SAAA,EAAoB,KAAA,GAA8B,EAAC,EAAqC;AACpH,EAAA,MAAM,IAAA,GAAO,WAAW,SAAS,CAAA;AACjC,EAAA,MAAM,KAAA,GAAQ,MAAM,MAAA,GAAS,CAAA,GAAI,CAAC,GAAG,QAAA,EAAU,GAAG,KAAK,CAAA,GAAI,QAAA;AAC3D,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,CAAC,IAAA,KAAoB,IAAA,CAAK,uBAAO,GAAA,CAAC,oBAAA,EAAA,EAAqB,KAAA,EAAe,QAAA,EAAA,IAAA,EAAK,CAAuB,CAAA;AAAA,IAC1G,OAAA,EAAS,MAAM,IAAA,CAAK,OAAA;AAAQ,GAC9B;AACF;AC0CA,IAAM,QAAA,GAAW,CAAC,EAAA,EAAY,GAAA,KAAyB,EAAA,KAAO,KAAK,GAAA,GAAM,CAAA,EAAG,EAAE,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA;AAErF,SAAS,cAAc,KAAA,EAAoC;AACzD,EAAA,MAAM,MAAsB,EAAC;AAC7B,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAChD,IAAA,MAAM,EAAE,OAAA,EAAS,MAAA,EAAO,GAAI,KAAA,CAAM,OAAA;AAClC,IAAA,MAAM,MAAA,GAAS;AAAA,MACb,WAAA,EAAa,EAAE,GAAG,KAAA,CAAM,WAAA,EAAY;AAAA,MACpC,GAAI,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,EAAE,GAAG,OAAA,EAAQ,EAAE;AAAA,MAC3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AAA,CAAI,WAAA,EAAY,CAAA,GAAO,IAAA;AAAA,sBAChFA,IAAC,YAAA,EAAA,EAAa,CAAA;AAAA,sBACdA,IAAC,iBAAA,EAAA,EAAkB;AAAA,KAAA,EACrB,CAAA;AAAA,IACC,IAAI,OAAA,CAAQ,GAAA,CAAI,CAAC,KAAA,qBAChBA,GAAAA,CAAC,YAAA,EAAA,EAA4B,KAAA,EAAc,QAAA,EAAU,aAAa,GAAA,CAAI,KAAA,CAAM,EAAE,CAAA,EAAA,EAA3D,KAAA,CAAM,EAAwD,CAClF;AAAA,GAAA,EACH,CAAA;AAEJ;AAGO,SAAS,aAAa,GAAA,EAA6B;AACxD,EAAA,OAAO;AAAA,IACL,OAAO,GAAA,CAAI,KAAA;AAAA,IACX,GAAI,IAAI,WAAA,KAAgB,MAAA,GAAY,EAAC,GAAI,EAAE,WAAA,EAAa,GAAA,CAAI,WAAA,EAAY;AAAA,IACxE,SAAS,GAAA,CAAI,OAAA;AAAA,IACb,SAAS,GAAA,CAAI,OAAA;AAAA,IACb,KAAA,EAAO,UAAA;AAAA,IACP,QAAA,EAAU,aAAA;AAAA,IACV,YAAA;AAAA,IACA,YAAA,EAAc,iBAAA;AAAA,IACd,OAAA,EAAS,YAAA;AAAA,IACT,OAAA,EAAS,IAAI,OAAA,IAAW,KAAA;AAAA,IACxB,MAAM,GAAA,CAAI;AAAA,GACZ;AACF;AAGO,SAAS,SAAA,CAAU,EAAE,GAAA,EAAK,MAAA,EAAO,EAAyE;AAC/G,EAAA,uBACEA,GAAAA,CAAC,eAAA,CAAgB,QAAA,EAAhB,EAAyB,OAAO,GAAA,EAAM,QAAA,EAAA,MAAA,GAAS,MAAA,CAAO,YAAA,CAAa,GAAG,CAAC,CAAA,mBAAIA,GAAAA,CAAC,gBAAa,CAAA,EAAG,CAAA;AAEjG","file":"chunk-ATI7FYJ7.js","sourcesContent":["import type { ReactNode } from 'react';\nimport { createRoot, type Root } from 'react-dom/client';\nimport { IconRegistryProvider } from '@weasel-js/core';\nimport type { IconTable } from '@weasel-js/icons';\nimport { kitIcons } from '@weasel-js/ui/kit-icons';\n\n/** A React root whose every render draws its icons from the kit's tables, plus `extra` (an app's own): the\n * workshop's, and each story frame's. */\nexport function createKitRoot(container: Element, extra: readonly IconTable[] = []): Pick<Root, 'render' | 'unmount'> {\n const root = createRoot(container);\n const icons = extra.length > 0 ? [...kitIcons, ...extra] : kitIcons;\n return {\n render: (node: ReactNode) => root.render(<IconRegistryProvider icons={icons}>{node}</IconRegistryProvider>),\n unmount: () => root.unmount(),\n };\n}\n","import {\n f,\n isConfigBranch,\n isEntryShown,\n resolveConfigSchema,\n schemaNodeAtPath,\n type Annotations,\n type BranchAnnotations,\n type ConfigBranch,\n type ConfigEntry,\n type ConfigNode,\n type ConfigSchema,\n type ConfigShape,\n type NodeOptions,\n} from '@weasel-js/labkit/config';\n\n/** The section a described entry sits in, as structured-clone data. */\nexport interface SectionDescription {\n label: string;\n collapsed?: boolean;\n}\n\n/** One key of a described shape: a leaf, or a branch holding more. */\nexport type DescribedEntry =\n | {\n branch: true;\n annotations: BranchAnnotations;\n section?: SectionDescription;\n conditional: boolean;\n children: DescribedShape;\n }\n | {\n branch: false;\n kind: string | null;\n default: unknown;\n annotations: Annotations;\n section?: SectionDescription;\n conditional: boolean;\n validated: boolean;\n /** The node draws its own row with `.render`, which stays in the frame. */\n customControl: boolean;\n };\n\n/** A config shape as structured-clone data: each key's entry, described. */\nexport type DescribedShape = { [key: string]: DescribedEntry };\n\n/** A story's `f.schema` as structured-clone data. */\nexport interface SchemaDescription {\n nodes: DescribedShape;\n}\n\n/** Answers the workshop has for the rebuilt schema's predicates. */\nexport interface SchemaAnswers {\n hidden(path: string, config: unknown): boolean;\n errors(path: string, config: unknown): string[];\n}\n\nconst joinPath = (at: string, key: string): string => (at === '' ? key : `${at}.${key}`);\n\nfunction describeShape(shape: ConfigShape): DescribedShape {\n const out: DescribedShape = {};\n for (const [key, entry] of Object.entries(shape)) {\n const { section, showIf } = entry.options;\n const common = {\n annotations: { ...entry.annotations },\n ...(section === undefined ? {} : { section: { ...section } }),\n conditional: showIf !== undefined,\n };\n out[key] = isConfigBranch(entry)\n ? { branch: true, ...common, children: describeShape(entry.children) }\n : {\n branch: false,\n kind: entry.kind,\n default: entry.default,\n ...common,\n validated: entry.options.validate !== undefined,\n customControl: entry.options.render !== undefined,\n };\n }\n return out;\n}\n\nexport function describeSchema(schema: ConfigSchema<unknown>): SchemaDescription {\n return { nodes: describeShape(schema.nodes) };\n}\n\nfunction rebuildShape(shape: DescribedShape, at: string, answers: SchemaAnswers): ConfigShape {\n const out: Record<string, ConfigEntry> = {};\n for (const [key, entry] of Object.entries(shape)) {\n const path = joinPath(at, key);\n const options: NodeOptions = {\n ...(entry.section === undefined ? {} : { section: entry.section }),\n ...(entry.conditional ? { showIf: (config) => !answers.hidden(path, config) } : {}),\n };\n if (entry.branch) {\n const branch: ConfigBranch = {\n children: rebuildShape(entry.children, path, answers),\n annotations: entry.annotations,\n options,\n };\n out[key] = branch;\n } else {\n const node: ConfigNode = {\n kind: entry.kind,\n default: entry.default,\n annotations: entry.annotations,\n options: entry.validated ? { ...options, validate: (_leaf, config) => answers.errors(path, config) } : options,\n };\n out[key] = node;\n }\n }\n return out;\n}\n\nexport function schemaFromDescription(\n description: SchemaDescription,\n answers: SchemaAnswers,\n): ConfigSchema<unknown> {\n return f.schema(rebuildShape(description.nodes, '', answers)) as ConfigSchema<unknown>;\n}\n\n/** Evaluate a schema's own predicates for one config — the frame's half of `answers`. */\nexport function answerSchema(\n schema: ConfigSchema<unknown>,\n config: unknown,\n): { hidden: string[]; errors: Record<string, string[]> } {\n const hidden: string[] = [];\n const errors: Record<string, string[]> = {};\n const record = config as Record<string, unknown>;\n const { group } = resolveConfigSchema(schema);\n\n const walk = (shape: ConfigShape, at: string): void => {\n for (const [key, entry] of Object.entries(shape)) {\n const path = joinPath(at, key);\n if (!isEntryShown(entry, record, group)) hidden.push(path);\n if (isConfigBranch(entry)) {\n walk(entry.children, path);\n continue;\n }\n const { validate } = entry.options;\n if (!validate) continue;\n const leaf = schemaNodeAtPath(group, path);\n if (!leaf || 'children' in leaf) continue;\n const found = validate(leaf, record);\n if (found.length > 0) errors[path] = found;\n }\n };\n walk(schema.nodes, '');\n return { hidden, errors };\n}\n","import { createEmitter } from '@weasel-js/registry';\nimport { type Envelope, PROTOCOL_VERSION } from './messages';\n\nexport interface PortLike {\n postMessage(message: unknown): void;\n addEventListener(type: 'message', fn: (event: MessageEvent) => void): void;\n removeEventListener(type: 'message', fn: (event: MessageEvent) => void): void;\n start?(): void;\n close(): void;\n}\n\n/** One end of a two-way message link: sends `Out`, hears `In`. */\nexport interface Channel<In, Out> {\n send(msg: Out): void;\n on(fn: (msg: In) => void): () => void;\n close(): void;\n}\n\nexport type Mismatch = { reason: 'not-an-envelope' } | { reason: 'version'; version: unknown };\n\nexport interface ChannelOptions {\n onMismatch?: (mismatch: Mismatch) => void;\n}\n\nexport function openChannel<In, Out>(port: PortLike, options: ChannelOptions = {}): Channel<In, Out> {\n const messages = createEmitter<[msg: In]>();\n const onMessage = (event: MessageEvent) => {\n const data: unknown = event.data;\n if (typeof data !== 'object' || data === null || !('msg' in data)) {\n options.onMismatch?.({ reason: 'not-an-envelope' });\n return;\n }\n const envelope = data as Partial<Envelope<In>>;\n if (envelope.v !== PROTOCOL_VERSION) {\n options.onMismatch?.({ reason: 'version', version: envelope.v });\n return;\n }\n messages.emit(envelope.msg as In);\n };\n port.addEventListener('message', onMessage);\n port.start?.();\n return {\n send: (msg) => port.postMessage({ v: PROTOCOL_VERSION, msg } satisfies Envelope<Out>),\n on: messages.subscribe,\n close: () => {\n port.removeEventListener('message', onMessage);\n port.close();\n },\n };\n}\n","import { sanitize } from './ids';\nimport type { IndexEntry } from './types';\n\nconst SUFFIX = ':index';\n\n/** The name an index page goes by in the sidebar and in its trial's title. */\nexport const INDEX_NAME = 'Index';\n\n/** The id of `title`'s index page. A colon never survives `sanitize`, so no story id can collide with it. */\nexport function indexId(title: string): string {\n return `${sanitize(title)}${SUFFIX}`;\n}\n\nexport function isIndexId(id: string): boolean {\n return id.endsWith(SUFFIX);\n}\n\n/**\n * One index-page entry per title in `stories`, in the order titles first appear. It routes and runs like a story:\n * its `file` is the title's first story file, its descriptions are the title's own, and its tags are those every story\n * of the title carries.\n */\nexport function indexEntries(stories: readonly IndexEntry[]): IndexEntry[] {\n const byTitle = new Map<string, IndexEntry>();\n for (const entry of stories) {\n const page = byTitle.get(entry.title);\n if (page) {\n if (page.tags) {\n const common = page.tags.filter((tag) => entry.tags?.includes(tag));\n if (common.length > 0) page.tags = common;\n else delete page.tags;\n }\n continue;\n }\n byTitle.set(entry.title, {\n id: indexId(entry.title),\n title: entry.title,\n name: INDEX_NAME,\n exportName: '',\n file: entry.file,\n ...(entry.componentDescription === undefined ? {} : { componentDescription: entry.componentDescription }),\n ...(entry.componentName === undefined ? {} : { componentName: entry.componentName }),\n ...(entry.tags === undefined ? {} : { tags: entry.tags }),\n });\n }\n return [...byTitle.values()];\n}\n","import type { StanceProps } from '@weasel-js/ui/stance';\nimport { createContext } from 'react';\n\n/** One library of a project: the story files under `path` carry `label`. */\nexport interface Library {\n /** A stretch of path every story file of the library has, with forward slashes: `/packages/ui/`. */\n path: string;\n label: string;\n /** The tone of the library's badge, as a `<Badge>` takes one. Default: the badge's own muted tone. */\n tone?: StanceProps['tone'];\n}\n\n/** A project's libraries, as the tree's package filter, the index page header, and Get Info ask about them. */\nexport interface Libraries {\n /** The label of the first library whose `path` the story's file holds, else its title's first segment. */\n of(entry: { file: string; title: string }): string;\n toneOf(label: string): StanceProps['tone'];\n}\n\nexport function librariesFrom(table: readonly Library[] = []): Libraries {\n return {\n of(entry) {\n const file = entry.file.replaceAll('\\\\', '/');\n return table.find((library) => file.includes(library.path))?.label ?? entry.title.split('/')[0] ?? entry.title;\n },\n toneOf: (label) => table.find((library) => library.label === label)?.tone,\n };\n}\n\n/** No table: every story's library is its title's first segment. */\nexport const TITLE_LIBRARIES = librariesFrom();\n\n/** The workshop's libraries, from `ShellConfig.libraries`. */\nexport const LibrariesContext = createContext<Libraries>(TITLE_LIBRARIES);\n","/** The density the workshop's lab is drawn at, and so the density a capture of a story in it takes. */\nexport const LAB_DENSITY = 'roomy';\n","// The component's own entry, not the barrel: the barrel would bring every weasel-ui component into each frame.\nimport { Badge } from '@weasel-js/ui/components/Badge';\nimport { useContext } from 'react';\nimport { LibrariesContext } from '../../story/library';\n\n/** A component's library, as a badge in the tone the project gave that library. */\nexport function LibraryBadge({ library, className }: { library: string; className?: string }) {\n const tone = useContext(LibrariesContext).toneOf(library);\n return (\n <Badge status=\"muted\" {...(tone === undefined ? {} : { tone })} variant=\"subtle\" size=\"sm\" {...(className ? { className } : {})}>\n {library}\n </Badge>\n );\n}\n","import { type ConfigSchema, type ConfigShape, isConfigBranch, isEntryShown, resolveConfigSchema, titleCase } from '@weasel-js/labkit/config';\nimport { isPlainObject } from '@weasel-js/core';\n\nexport interface VariantValue {\n value: unknown;\n label: string;\n}\n\n/** One control a story is shown varying along, with every other control at its default. */\nexport interface VariantRow {\n /** Dotted, as `setConfig` takes it. */\n path: string;\n label: string;\n values: VariantValue[];\n}\n\n/** Above this many choices a row stops being something to scan. */\nexport const MAX_ENUM_OPTIONS = 8;\nexport const MAX_ROWS = 6;\n\nconst labelOf = (key: string, name: string | undefined): string => name ?? titleCase(key);\n\n/**\n * The boolean and enum controls of `schema` a story can be shown varying along, in schema order: skipped are\n * controls that draw their own row, controls hidden at the defaults, and enums with more than\n * `MAX_ENUM_OPTIONS` choices. At most `MAX_ROWS`.\n */\nexport function variantRows(schema: ConfigSchema<unknown>): VariantRow[] {\n const defaults = schema.defaults() as Record<string, unknown>;\n const { group } = resolveConfigSchema(schema);\n const rows: VariantRow[] = [];\n const walk = (shape: ConfigShape, at: string): void => {\n for (const [key, entry] of Object.entries(shape)) {\n if (rows.length >= MAX_ROWS) return;\n const path = at === '' ? key : `${at}.${key}`;\n if (!isEntryShown(entry, defaults, group)) continue;\n if (isConfigBranch(entry)) {\n walk(entry.children, path);\n continue;\n }\n if (entry.annotations.hidden || entry.options.render) continue;\n const label = labelOf(key, entry.annotations.name);\n if (entry.kind === 'boolean') {\n rows.push({ path, label, values: [false, true].map((value) => ({ value, label: String(value) })) });\n } else if (entry.kind === 'enum') {\n const options = entry.annotations.options ?? [];\n if (options.length < 2 || options.length > MAX_ENUM_OPTIONS) continue;\n rows.push({ path, label, values: options.map((o) => ({ value: o.value, label: o.label })) });\n }\n }\n };\n walk(schema.nodes, '');\n return rows;\n}\n\n/** `over` merged into `base`: nested plain objects merge, anything else replaces. */\nexport function mergeConfig(base: unknown, over: unknown): unknown {\n if (!isPlainObject(base) || !isPlainObject(over)) return over === undefined ? base : over;\n const out: Record<string, unknown> = { ...base };\n for (const [key, value] of Object.entries(over)) out[key] = mergeConfig(base[key], value);\n return out;\n}\n\n/** `config` with `value` at dotted `path`, copying each object along the way. */\nexport function withValueAt(config: unknown, path: string, value: unknown): unknown {\n const [head, ...rest] = path.split('.');\n if (head === undefined) return value;\n const record = isPlainObject(config) ? config : {};\n return { ...record, [head]: rest.length === 0 ? value : withValueAt(record[head], rest.join('.'), value) };\n}\n","// The components' own entries, not the barrel: the barrel would bring every weasel-ui component into each frame.\nimport { Badge } from '@weasel-js/ui/components/Badge';\nimport { Button } from '@weasel-js/ui/components/Button';\nimport {\n createContext,\n type MouseEvent,\n type ReactNode,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { Globals } from '../../protocol/messages';\nimport { indexId } from '../../story/indexPages';\nimport type { ComponentDeps, Decorator, IndexContext, IndexStoryProps, LoadedStory, StoryContext } from '../../story/types';\nimport { StoryHost } from '../StoryHost';\nimport { useNearViewport } from '../useNearViewport';\nimport { mergeConfig, variantRows, withValueAt } from './variants';\nimport './index.css';\nimport { LibraryBadge } from './LibraryBadge';\nimport num from '@weasel-js/theme/numeric.module.css';\n\n/** What every cell on an index page shares with the frame that hosts it. */\nexport interface IndexEnv {\n title: string;\n /** The package the component ships in. */\n library?: string;\n description?: string;\n stories: readonly LoadedStory[];\n /** Per story id, the JSDoc above its export. */\n descriptions: Readonly<Record<string, string>>;\n /** A catalog or showcase rather than one component: every story of it is tagged `gallery`. */\n gallery?: boolean;\n /** The ids of the stories tagged `gallery`. */\n galleries?: readonly string[];\n /** The component's place in the component graph; absent until the graph arrives, and for a gallery. */\n dependencies?: ComponentDeps;\n globals: Globals;\n /** The frame config's, outermost. */\n decorators: readonly Decorator[];\n open: (id: string) => void;\n onError: (error: unknown) => void;\n}\n\nexport const IndexEnvContext = createContext<IndexEnv | null>(null);\n\nfunction useEnv(): IndexEnv {\n const env = useContext(IndexEnvContext);\n if (!env) throw new Error('An index page part rendered outside its index page');\n return env;\n}\n\n/** How far past the viewport a cell stays mounted. */\nconst NEAR_MARGIN = '100%';\n\n/**\n * One story at its defaults with `config` over them. It keeps its own config and state, so it stays interactive, and\n * it mounts only while near the viewport, so a page of canvas stories stays under the browser's WebGL context cap.\n */\nexport function IndexStory({ story, config: over, label }: IndexStoryProps) {\n const env = useEnv();\n const [config, setConfig] = useState(() => mergeConfig(story.config.defaults(), over));\n const [state, setState] = useState<unknown>(() => story.initialState?.(config) ?? null);\n const cell = useRef<HTMLElement>(null);\n // Starts unmounted, so a page of canvas stories never mounts every cell at once.\n const near = useNearViewport(cell, NEAR_MARGIN, false);\n // Held while unmounted, so scrolling past a cell does not move everything after it.\n const [height, setHeight] = useState<number | null>(null);\n useEffect(() => {\n const el = cell.current;\n if (!near || !el || typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(() => setHeight(el.getBoundingClientRect().height));\n observer.observe(el);\n return () => observer.disconnect();\n }, [near]);\n const ctx: StoryContext = {\n config,\n setConfig: (path, value) => setConfig((prev: unknown) => withValueAt(prev, path, value)),\n state,\n setState: (next) =>\n setState((prev: unknown) => (typeof next === 'function' ? (next as (p: unknown) => unknown)(prev) : next)),\n globals: env.globals,\n title: story.title,\n name: story.name,\n };\n return (\n <figure\n ref={cell}\n className={`fg-index-cell fg-index-cell--${story.layout}`}\n style={!near && height !== null ? { minHeight: height } : undefined}\n >\n <div className=\"fg-index-cell__stage\">\n {near ? (\n <StoryHost story={story} ctx={ctx} decorators={env.decorators} resetKey={0} onError={env.onError} />\n ) : null}\n </div>\n {label === undefined ? null : <figcaption className=\"fg-index-cell__label\">{label}</figcaption>}\n </figure>\n );\n}\n\n/** `story` once per value of each boolean and enum control, every other control at its default. */\nexport function IndexVariants({ story }: { story: LoadedStory }) {\n const rows = useMemo(() => variantRows(story.config), [story]);\n const defaults = useMemo(() => story.config.defaults(), [story]);\n if (rows.length === 0) return null;\n return (\n <div className=\"fg-index-variants\">\n {rows.map((row) => (\n <section key={row.path} className=\"fg-index-variants__row\" aria-label={row.label}>\n <h4 className=\"fg-index-variants__label\">{row.label}</h4>\n <div className=\"fg-index-variants__cells\">\n {row.values.map((v) => (\n <IndexStory\n key={String(v.value)}\n story={story}\n config={withValueAt(defaults, row.path, v.value) as Record<string, unknown>}\n label={v.label}\n />\n ))}\n </div>\n </section>\n ))}\n </div>\n );\n}\n\nfunction GalleryBadge() {\n return (\n <Badge status=\"accent\" variant=\"subtle\" size=\"sm\">\n Gallery\n </Badge>\n );\n}\n\nfunction DependencyList({ label, titles, empty }: { label: string; titles: readonly string[]; empty: string }) {\n const env = useEnv();\n const labelId = useId();\n const follow = (event: MouseEvent, id: string) => {\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n event.preventDefault();\n env.open(id);\n };\n return (\n <div className=\"fg-index-deps__row\">\n <dt id={labelId} className=\"fg-index-deps__label\">\n {label}\n </dt>\n <dd className=\"fg-index-deps__value\">\n {titles.length === 0 ? (\n <span className=\"fg-index-deps__empty\">{empty}</span>\n ) : (\n <ul className=\"fg-index-deps__list\" aria-labelledby={labelId}>\n {titles.map((title) => {\n const cut = title.lastIndexOf('/') + 1;\n const id = indexId(title);\n return (\n <li key={title}>\n <a className=\"fg-index-deps__link\" href={`#/${encodeURIComponent(id)}`} onClick={(event) => follow(event, id)}>\n <span className=\"fg-index-deps__prefix\">{title.slice(0, cut)}</span>\n {title.slice(cut)}\n </a>\n </li>\n );\n })}\n </ul>\n )}\n </dd>\n </div>\n );\n}\n\n/** The listed components this one uses and those that use it, read from source. Nothing for a gallery. */\nexport function IndexDependencies() {\n const { gallery, dependencies } = useEnv();\n if (gallery || !dependencies) return null;\n if (dependencies.source === null) {\n return (\n <p className=\"fg-index-deps__none\">\n forge found no source file for this component, so it lists none of its dependencies. It looks for the\n import the meta’s <code>component</code> names, or else the one the title’s last segment names.\n </p>\n );\n }\n return (\n <dl className=\"fg-index-deps\" aria-label=\"Dependencies\">\n <DependencyList label=\"Uses\" titles={dependencies.uses} empty=\"No listed component.\" />\n <DependencyList label=\"Used by\" titles={dependencies.usedBy} empty=\"No listed component uses it.\" />\n </dl>\n );\n}\n\nconst DAY = new Intl.DateTimeFormat(undefined, { dateStyle: 'medium' });\n\nfunction HistoryDate({ label, iso, version }: { label: string; iso: string; version: string | null }) {\n return (\n <div className=\"fg-index-history__item\">\n <dt className=\"fg-index-history__label\">{label}</dt>\n <dd className={`fg-index-history__value ${num.numeric}`}>\n <time dateTime={iso}>{DAY.format(new Date(iso))}</time> ({version ?? 'unreleased'})\n </dd>\n </div>\n );\n}\n\n/** When the component's source file was created and last changed, each with the release that shipped it, read from\n * git. Nothing for a gallery, or for a source file git has never committed. */\nexport function IndexHistory() {\n const { gallery, dependencies } = useEnv();\n const history = gallery ? undefined : dependencies?.history;\n if (!history) return null;\n return (\n <dl className=\"fg-index-history\" aria-label=\"History\">\n <HistoryDate label=\"Created\" iso={history.created} version={history.introduced} />\n <HistoryDate label=\"Modified\" iso={history.modified} version={history.modifiedIn} />\n </dl>\n );\n}\n\nfunction StorySection({ story, variants }: { story: LoadedStory; variants: boolean }) {\n const env = useEnv();\n const headingId = useId();\n const description = env.descriptions[story.id];\n const gallery = !env.gallery && env.galleries?.includes(story.id);\n return (\n <section className=\"fg-index-story\" aria-labelledby={headingId}>\n <header className=\"fg-index-story__head\">\n <h2 id={headingId} className=\"fg-index-story__name\">\n {story.name}\n </h2>\n {gallery ? <GalleryBadge /> : null}\n <Button variant=\"secondary\" size=\"sm\" onClick={() => env.open(story.id)}>\n Open\n </Button>\n </header>\n {description ? <p className=\"fg-index-story__description\">{description}</p> : null}\n <IndexStory story={story} />\n {variants ? <IndexVariants story={story} /> : null}\n </section>\n );\n}\n\n/** Which of `stories` show their variants: the first of each set of controls. Stories of one CSF file share their\n * meta's controls, and the same rows under every story would only repeat. */\nfunction firstOfEachControlSet(stories: readonly LoadedStory[]): Set<string> {\n const seen = new Set<string>();\n const shown = new Set<string>();\n for (const story of stories) {\n const key = JSON.stringify(variantRows(story.config));\n if (seen.has(key)) continue;\n seen.add(key);\n shown.add(story.id);\n }\n return shown;\n}\n\n/** The generated page: the component's title and description, then each story, with the variants of the first of\n * each set of controls. */\nexport function DefaultIndex() {\n const env = useEnv();\n const withVariants = useMemo(() => firstOfEachControlSet(env.stories), [env.stories]);\n const segments = env.title.split('/');\n const name = segments.pop();\n const { library } = env;\n if (library !== undefined && segments[0] === library) segments.shift();\n return (\n <article className=\"fg-index\">\n <header className=\"fg-index__head\">\n {segments.length > 0 || library !== undefined ? (\n <p className=\"fg-index__path\">\n {library !== undefined ? <LibraryBadge library={library} className=\"fg-index__library\" /> : null}\n {segments.join(' / ')}\n </p>\n ) : null}\n <div className=\"fg-index__title-row\">\n <h1 className=\"fg-index__title\">{name}</h1>\n {env.gallery ? <GalleryBadge /> : null}\n </div>\n {env.description ? <p className=\"fg-index__description\">{env.description}</p> : null}\n <IndexHistory />\n <IndexDependencies />\n </header>\n {env.stories.map((story) => (\n <StorySection key={story.id} story={story} variants={withVariants.has(story.id)} />\n ))}\n </article>\n );\n}\n\n/** What a component's own index page is handed. */\nexport function indexContext(env: IndexEnv): IndexContext {\n return {\n title: env.title,\n ...(env.description === undefined ? {} : { description: env.description }),\n stories: env.stories,\n globals: env.globals,\n Story: IndexStory,\n Variants: IndexVariants,\n DefaultIndex,\n Dependencies: IndexDependencies,\n History: IndexHistory,\n gallery: env.gallery ?? false,\n open: env.open,\n };\n}\n\n/** The page itself: the component's own, or the generated one. */\nexport function IndexPage({ env, render }: { env: IndexEnv; render: ((ctx: IndexContext) => ReactNode) | null }) {\n return (\n <IndexEnvContext.Provider value={env}>{render ? render(indexContext(env)) : <DefaultIndex />}</IndexEnvContext.Provider>\n );\n}\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { isSafeOverride } from './chunk-5WS67HMU.js';
|
|
2
|
+
|
|
3
|
+
// src/title.ts
|
|
4
|
+
var DEFAULT_TITLE = "weaselforge";
|
|
5
|
+
|
|
6
|
+
// src/vite/capture/payload.ts
|
|
7
|
+
var messageOf = (err) => err instanceof Error ? err.message : String(err);
|
|
8
|
+
var CAPTURE_PATH = "__forge/capture";
|
|
9
|
+
var CAPTURE_PAGES = { shell: "__forge/capture.html", frame: "__forge/capture-frame.html" };
|
|
10
|
+
var MIN_DPR = 1;
|
|
11
|
+
var MAX_DPR = 3;
|
|
12
|
+
var LAYOUTS = ["centered", "padded", "fullscreen"];
|
|
13
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14
|
+
var finite = (n) => typeof n === "number" && Number.isFinite(n);
|
|
15
|
+
var positive = (n) => finite(n) && n > 0;
|
|
16
|
+
function parsePayload(body) {
|
|
17
|
+
if (!isRecord(body)) return { error: "a capture payload is an object" };
|
|
18
|
+
const { story, isolate, config, state, globals, overrides, playhead, box, layout, dpr, scroll, lab, colorScheme } = body;
|
|
19
|
+
if (typeof story !== "string" || story === "") return { error: "story must be an index id" };
|
|
20
|
+
if (typeof isolate !== "boolean") return { error: "isolate must be a boolean" };
|
|
21
|
+
if (!isRecord(globals)) return { error: "globals must be an object" };
|
|
22
|
+
if (!isRecord(overrides) || !Object.values(overrides).every((v) => typeof v === "string")) {
|
|
23
|
+
return { error: "overrides must map property names to strings" };
|
|
24
|
+
}
|
|
25
|
+
const unsafe = Object.entries(overrides).find(([name, value]) => !isSafeOverride(name, value));
|
|
26
|
+
if (unsafe) return { error: `overrides must name custom properties, with no { } or ; in a value: ${unsafe[0]}` };
|
|
27
|
+
if (playhead !== null && !(typeof playhead === "number" && Number.isFinite(playhead))) {
|
|
28
|
+
return { error: "playhead must be a number or null" };
|
|
29
|
+
}
|
|
30
|
+
if (!isRecord(box) || !positive(box.width) || !positive(box.height)) {
|
|
31
|
+
return { error: "box must have a positive width and height" };
|
|
32
|
+
}
|
|
33
|
+
if (typeof layout !== "string" || !LAYOUTS.includes(layout)) return { error: `layout must be one of ${LAYOUTS.join(", ")}` };
|
|
34
|
+
if (typeof dpr !== "number" || !(dpr >= MIN_DPR && dpr <= MAX_DPR)) return { error: `dpr must be in [${MIN_DPR}, ${MAX_DPR}]` };
|
|
35
|
+
if (!isRecord(scroll) || !finite(scroll.left) || !finite(scroll.top)) return { error: "scroll must hold a finite left and top" };
|
|
36
|
+
if (!isRecord(lab) || !isRecord(lab.globals) || lab.mode !== "light" && lab.mode !== "dark") {
|
|
37
|
+
return { error: "lab must hold globals and a mode of light or dark" };
|
|
38
|
+
}
|
|
39
|
+
if (colorScheme !== "light" && colorScheme !== "dark") return { error: "colorScheme must be light or dark" };
|
|
40
|
+
return {
|
|
41
|
+
story,
|
|
42
|
+
isolate,
|
|
43
|
+
config,
|
|
44
|
+
state,
|
|
45
|
+
globals,
|
|
46
|
+
overrides,
|
|
47
|
+
playhead,
|
|
48
|
+
box: { width: box.width, height: box.height },
|
|
49
|
+
layout,
|
|
50
|
+
dpr,
|
|
51
|
+
scroll: { left: scroll.left, top: scroll.top },
|
|
52
|
+
lab: { globals: lab.globals, mode: lab.mode },
|
|
53
|
+
colorScheme
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { CAPTURE_PAGES, CAPTURE_PATH, DEFAULT_TITLE, MAX_DPR, M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AAA,CAAA,EAAG;AAC3H,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,IAAY,EAAE,OAAO,OAAA,IAAW,GAAA,IAAO,OAAA,CAAA,EAAU,OAAO,EAAE,KAAA,EAAO,CAAA,gBAAA,EAAmB,OAAO,CAAA,EAAA,EAAK,OAAO,CAAA,CAAA,CAAA,EAAI;AAC9H,EAAA,IAAI,CAAC,QAAA,CAAS,MAAM,CAAA,IAAK,CAAC,OAAO,MAAA,CAAO,IAAI,CAAA,IAAK,CAAC,OAAO,MAAA,CAAO,GAAG,GAAG,OAAO,EAAE,OAAO,wCAAA,EAAyC;AAC/H,EAAA,IAAI,CAAC,QAAA,CAAS,GAAG,CAAA,IAAK,CAAC,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,IAAM,GAAA,CAAI,IAAA,KAAS,OAAA,IAAW,GAAA,CAAI,SAAS,MAAA,EAAS;AAC7F,IAAA,OAAO,EAAE,OAAO,mDAAA,EAAoD;AAAA,EACtE;AACA,EAAA,IAAI,gBAAgB,OAAA,IAAW,WAAA,KAAgB,QAAQ,OAAO,EAAE,OAAO,mCAAA,EAAoC;AAC3G,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAK,EAAE,KAAA,EAAO,IAAI,KAAA,EAAO,MAAA,EAAQ,IAAI,MAAA,EAAO;AAAA,IAC5C,MAAA;AAAA,IACA,GAAA;AAAA,IACA,QAAQ,EAAE,IAAA,EAAM,OAAO,IAAA,EAAM,GAAA,EAAK,OAAO,GAAA,EAAI;AAAA,IAC7C,KAAK,EAAE,OAAA,EAAS,IAAI,OAAA,EAAS,IAAA,EAAM,IAAI,IAAA,EAAK;AAAA,IAC5C;AAAA,GACF;AACF","file":"chunk-ORMMZ5PV.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","import { isSafeOverride } from '../../frame/safeOverride.ts';\nimport type { Globals, Layout } from '../../protocol/messages.ts';\n\n/** Everything the screen renders a story from, as the capture endpoint takes it. */\nexport interface CapturePayload {\n /** The story's index id. */\n story: string;\n /** Picks the document: an isolated story renders under frame styles, any other under shell styles. */\n isolate: boolean;\n /** The story's config, with forge's `$` keys stripped and a comparison's args laid over. */\n config: unknown;\n /** Must survive JSON. */\n state: unknown;\n globals: Globals;\n /** CSS variable overrides, by property name. */\n overrides: Readonly<Record<string, string>>;\n /** Null for a story with no timeline, and for an isolated story. */\n playhead: number | null;\n /** The host's size in CSS pixels. */\n box: { width: number; height: number };\n layout: Layout;\n /** Device pixel ratio, in [1, 3]. */\n dpr: number;\n /** Where the story's scroller stands in its host, in CSS pixels, so the capture shows the patch the screen does. */\n scroll: { left: number; top: number };\n /** The workshop lab's theme as the screen shows it: the lab's globals, which the shell config's `labTheme` reads,\n * and its resolved color mode. An isolated story's document has no lab, and ignores it. */\n lab: { globals: Globals; mode: 'light' | 'dark' };\n /** The OS color scheme the screen sees, which the capture page emulates: a story or a lab in `auto` mode follows\n * `prefers-color-scheme`, and headless Chromium would otherwise answer light. */\n colorScheme: 'light' | 'dark';\n}\n\n/** What a capture failure says: an error's message, or anything else as a string. */\nexport const messageOf = (err: unknown): string => (err instanceof Error ? err.message : String(err));\n\n/** Where the endpoint answers, under the dev server's base. */\nexport const CAPTURE_PATH = '__forge/capture';\n\n/** The pages a capture renders on, under the dev server's base: one per document a story can render in. */\nexport const CAPTURE_PAGES = { shell: '__forge/capture.html', frame: '__forge/capture-frame.html' };\n\nexport const MIN_DPR = 1;\nexport const MAX_DPR = 3;\n\nconst LAYOUTS: readonly string[] = ['centered', 'padded', 'fullscreen'] satisfies readonly Layout[];\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst finite = (n: unknown): n is number => typeof n === 'number' && Number.isFinite(n);\nconst positive = (n: unknown): n is number => finite(n) && n > 0;\n\n/** Reads a request body as a payload, or names the first field it rejects. */\nexport function parsePayload(body: unknown): CapturePayload | { error: string } {\n if (!isRecord(body)) return { error: 'a capture payload is an object' };\n const { story, isolate, config, state, globals, overrides, playhead, box, layout, dpr, scroll, lab, colorScheme } = body;\n if (typeof story !== 'string' || story === '') return { error: 'story must be an index id' };\n if (typeof isolate !== 'boolean') return { error: 'isolate must be a boolean' };\n if (!isRecord(globals)) return { error: 'globals must be an object' };\n if (!isRecord(overrides) || !Object.values(overrides).every((v) => typeof v === 'string')) {\n return { error: 'overrides must map property names to strings' };\n }\n const unsafe = Object.entries(overrides as Record<string, string>).find(([name, value]) => !isSafeOverride(name, value));\n if (unsafe) return { error: `overrides must name custom properties, with no { } or ; in a value: ${unsafe[0]}` };\n if (playhead !== null && !(typeof playhead === 'number' && Number.isFinite(playhead))) {\n return { error: 'playhead must be a number or null' };\n }\n if (!isRecord(box) || !positive(box.width) || !positive(box.height)) {\n return { error: 'box must have a positive width and height' };\n }\n if (typeof layout !== 'string' || !LAYOUTS.includes(layout)) return { error: `layout must be one of ${LAYOUTS.join(', ')}` };\n if (typeof dpr !== 'number' || !(dpr >= MIN_DPR && dpr <= MAX_DPR)) return { error: `dpr must be in [${MIN_DPR}, ${MAX_DPR}]` };\n if (!isRecord(scroll) || !finite(scroll.left) || !finite(scroll.top)) return { error: 'scroll must hold a finite left and top' };\n if (!isRecord(lab) || !isRecord(lab.globals) || (lab.mode !== 'light' && lab.mode !== 'dark')) {\n return { error: 'lab must hold globals and a mode of light or dark' };\n }\n if (colorScheme !== 'light' && colorScheme !== 'dark') return { error: 'colorScheme must be light or dark' };\n return {\n story,\n isolate,\n config,\n state,\n globals,\n overrides: overrides as Record<string, string>,\n playhead,\n box: { width: box.width, height: box.height },\n layout: layout as Layout,\n dpr,\n scroll: { left: scroll.left, top: scroll.top },\n lab: { globals: lab.globals, mode: lab.mode },\n colorScheme,\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isNative, ClockContext } from './chunk-L5XM5VKB.js';
|
|
2
|
-
import { storyNameFromExport, storyId, PROP_ARG_TYPES_EXPORT } from './chunk-
|
|
2
|
+
import { isSafeOverride, storyNameFromExport, storyId, PROP_ARG_TYPES_EXPORT } from './chunk-5WS67HMU.js';
|
|
3
3
|
import { portSafePart, appliedLocal, withUnsent, coverOf, ArgsContext } from './chunk-KEQBGDUZ.js';
|
|
4
4
|
import { useVisibleRaf, useLatest, isPlainObject } from '@weasel-js/core';
|
|
5
|
-
import { createContext, useSyncExternalStore, useRef, useEffect, useState, Component, useContext, createElement } from 'react';
|
|
5
|
+
import { createContext, useSyncExternalStore, useRef, useEffect, useState, Component, useLayoutEffect, useContext, createElement } from 'react';
|
|
6
6
|
import { createEmitter } from '@weasel-js/registry';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
8
8
|
import { f } from '@weasel-js/labkit/config';
|
|
@@ -278,9 +278,17 @@ function createOverrides(doc, scope = ":root") {
|
|
|
278
278
|
}
|
|
279
279
|
doc.head.append(style);
|
|
280
280
|
};
|
|
281
|
+
const selector = `:is(${scope}):not(#fg-overrides)`;
|
|
281
282
|
const write = () => {
|
|
282
|
-
|
|
283
|
-
|
|
283
|
+
style.textContent = values.size > 0 ? `${selector} {}` : "";
|
|
284
|
+
const rule = style.sheet?.cssRules[0];
|
|
285
|
+
if (!rule) return;
|
|
286
|
+
for (const [name, value] of values) if (isSafeOverride(name, value)) rule.style.setProperty(name, value);
|
|
287
|
+
const decls = [...values.keys()].flatMap((name) => {
|
|
288
|
+
const value = rule.style.getPropertyValue(name).trim();
|
|
289
|
+
return value && isSafeOverride(name, value) ? [` ${name}: ${value};`] : [];
|
|
290
|
+
});
|
|
291
|
+
style.textContent = decls.length > 0 ? `${selector} {
|
|
284
292
|
${decls.join("\n")}
|
|
285
293
|
}
|
|
286
294
|
` : "";
|
|
@@ -822,7 +830,41 @@ function useNearViewport(ref, margin, initial = true) {
|
|
|
822
830
|
}, [ref, margin]);
|
|
823
831
|
return near;
|
|
824
832
|
}
|
|
833
|
+
var scopeOf = (id) => `[data-fg-host="${id}"]`;
|
|
834
|
+
function useHostConditions(host, opts) {
|
|
835
|
+
const { hostId, globals, overrides: persisted, setup } = opts;
|
|
836
|
+
const latest = useLatest({ setup });
|
|
837
|
+
const overridesRef = useRef(null);
|
|
838
|
+
useLayoutEffect(() => {
|
|
839
|
+
if (!host) return;
|
|
840
|
+
const scope = scopeOf(hostId);
|
|
841
|
+
const { cssVarsScope } = latest.current.setup;
|
|
842
|
+
overridesRef.current = createOverrides(
|
|
843
|
+
host.ownerDocument,
|
|
844
|
+
cssVarsScope ? `${scope}, ${scope} :is(${cssVarsScope})` : scope
|
|
845
|
+
);
|
|
846
|
+
return () => {
|
|
847
|
+
overridesRef.current?.dispose();
|
|
848
|
+
overridesRef.current = null;
|
|
849
|
+
};
|
|
850
|
+
}, [host, hostId, latest]);
|
|
851
|
+
const applied = useRef({});
|
|
852
|
+
useLayoutEffect(() => {
|
|
853
|
+
const overrides = overridesRef.current;
|
|
854
|
+
if (!overrides) return;
|
|
855
|
+
for (const name of Object.keys(applied.current)) if (!(name in persisted)) overrides.set(name, null);
|
|
856
|
+
for (const [name, value] of Object.entries(persisted)) overrides.set(name, value);
|
|
857
|
+
applied.current = { ...persisted };
|
|
858
|
+
}, [host, hostId, persisted]);
|
|
859
|
+
useLayoutEffect(() => {
|
|
860
|
+
if (!host) return;
|
|
861
|
+
const target = createGlobalsTarget(host, scopeOf(hostId));
|
|
862
|
+
latest.current.setup.applyGlobals?.(globals, target);
|
|
863
|
+
return () => target.dispose();
|
|
864
|
+
}, [host, hostId, globals, latest]);
|
|
865
|
+
return overridesRef;
|
|
866
|
+
}
|
|
825
867
|
|
|
826
|
-
export { IN_VIEW_MARGIN, StoryHost, auditElement, createA11yHighlighter, createGlobalsTarget, createOverrides, indexRenderOf, loadStories, resolveCssVar, runAxe, scanCssVars, useClockLoop, useNearViewport, useStoryClock };
|
|
827
|
-
//# sourceMappingURL=chunk-
|
|
828
|
-
//# sourceMappingURL=chunk-
|
|
868
|
+
export { IN_VIEW_MARGIN, StoryHost, auditElement, createA11yHighlighter, createGlobalsTarget, createOverrides, cssRulesOf, indexRenderOf, loadStories, resolveCssVar, runAxe, scanCssVars, useClockLoop, useHostConditions, useNearViewport, useStoryClock, varRefs };
|
|
869
|
+
//# sourceMappingURL=chunk-WMGEO5M6.js.map
|
|
870
|
+
//# sourceMappingURL=chunk-WMGEO5M6.js.map
|