@weasel-js/forge 1.11.0 → 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 +92 -1
- package/dist/{FrameController-BRhShqut.d.ts → FrameController-CdnaIo4C.d.ts} +18 -10
- 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-R5F44ECM.js → chunk-ATI7FYJ7.js} +18 -14
- package/dist/chunk-ATI7FYJ7.js.map +1 -0
- package/dist/{chunk-2OJAV522.js → chunk-GH5RE5X5.js} +2 -2
- package/dist/chunk-GH5RE5X5.js.map +1 -0
- package/dist/{chunk-SQ4KCIEH.js → chunk-KEQBGDUZ.js} +3 -3
- package/dist/{chunk-SQ4KCIEH.js.map → chunk-KEQBGDUZ.js.map} +1 -1
- package/dist/{chunk-DPTECNYC.js → chunk-LTTEILXY.js} +3 -3
- package/dist/{chunk-DPTECNYC.js.map → chunk-LTTEILXY.js.map} +1 -1
- package/dist/chunk-ORMMZ5PV.js +59 -0
- package/dist/chunk-ORMMZ5PV.js.map +1 -0
- package/dist/{chunk-NVNTQ4AT.js → chunk-WMGEO5M6.js} +133 -9
- 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-BwScQukB.d.ts → config-Mg05Ja9r.d.ts} +20 -3
- package/dist/csf/preview-api.js +2 -2
- package/dist/frame/index.css +12 -0
- package/dist/frame/index.css.map +1 -1
- package/dist/frame/index.d.ts +62 -29
- package/dist/frame/index.js +142 -15
- package/dist/frame/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/mountFrame-Ds3QLnBF.d.ts +35 -0
- package/dist/shell/index.css +131 -6
- package/dist/shell/index.css.map +1 -1
- package/dist/shell/index.d.ts +44 -16
- package/dist/shell/index.js +1663 -280
- 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 +2 -4
- package/dist/test/index.js +11 -13
- package/dist/test/index.js.map +1 -1
- package/dist/vite/index.js +515 -111
- package/dist/vite/index.js.map +1 -1
- package/package.json +13 -8
- package/dist/chunk-2OJAV522.js.map +0 -1
- 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-J3GYSNCK.js +0 -285
- package/dist/chunk-J3GYSNCK.js.map +0 -1
- package/dist/chunk-NVNTQ4AT.js.map +0 -1
- package/dist/chunk-R5F44ECM.js.map +0 -1
- package/dist/chunk-ZAWXMUGZ.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { LabMode, LabContribution, LabPage } from '@weasel-js/labkit';
|
|
2
2
|
import { Theme } from '@weasel-js/theme';
|
|
3
3
|
import { ControlRenderer } from '@weasel-js/labkit/config';
|
|
4
|
-
import { G as Globals, F as FrameSetup } from './FrameController-
|
|
4
|
+
import { G as Globals, F as FrameSetup } from './FrameController-CdnaIo4C.js';
|
|
5
5
|
import { IconRef } from '@weasel-js/icons';
|
|
6
|
-
import { StanceProps } from '@weasel-js/ui';
|
|
6
|
+
import { StanceProps } from '@weasel-js/ui/stance';
|
|
7
7
|
|
|
8
8
|
/** One global the workshop's toolbar sets for every story, and a trial may pin for its own. */
|
|
9
9
|
interface GlobalDeclaration {
|
|
@@ -28,6 +28,12 @@ interface GlobalDeclaration {
|
|
|
28
28
|
* pin follows the lab or names a value; it cannot follow the app on its own.
|
|
29
29
|
*/
|
|
30
30
|
follows?: (chrome: LabChrome) => string;
|
|
31
|
+
/**
|
|
32
|
+
* The value opposite `value`, for the global a lens's opposite-mode comparison flips (`ShellConfig.loupe`'s
|
|
33
|
+
* `modeGlobal`); undefined when it has none. `App` and `auto` are resolved to the mode they show before this is
|
|
34
|
+
* asked. Absent, the lens swaps `light` and `dark`.
|
|
35
|
+
*/
|
|
36
|
+
opposite?: (value: string, globals: Globals) => string | undefined;
|
|
31
37
|
}
|
|
32
38
|
/** The lab chrome's own settings a global can follow. */
|
|
33
39
|
interface LabChrome {
|
|
@@ -62,7 +68,7 @@ interface ShellConfig {
|
|
|
62
68
|
* it from this module's source, so write it as a string or a `const` of this file; a computed one titles the
|
|
63
69
|
* page only once the workshop has loaded. */
|
|
64
70
|
title?: string;
|
|
65
|
-
/** Whether the lab offers the CSS Vars panel. Default true. */
|
|
71
|
+
/** Whether the lab offers the CSS Vars panel and its header toggle. Default true; the panel starts hidden. */
|
|
66
72
|
cssVars?: boolean;
|
|
67
73
|
labChrome?: readonly LabContribution[];
|
|
68
74
|
controls?: Record<string, ControlRenderer>;
|
|
@@ -78,6 +84,17 @@ interface ShellConfig {
|
|
|
78
84
|
pages?: readonly LabPage[];
|
|
79
85
|
/** Which of `pages` the workshop is, when the URL alone cannot say, as across dev servers on different ports. */
|
|
80
86
|
path?: string;
|
|
87
|
+
/** What a Pixels capture may load besides the dev server's own pages, such as the origins of a web-font service
|
|
88
|
+
* the stories' fonts come from. Every other request a capture makes is refused. The dev server reads the list
|
|
89
|
+
* from this module's source, as it does `title`, so write each origin as a string. */
|
|
90
|
+
capture?: {
|
|
91
|
+
allowOrigins?: readonly string[];
|
|
92
|
+
};
|
|
93
|
+
/** The workshop's lenses. `modeGlobal` names the global holding the color mode, which a lens's opposite-mode
|
|
94
|
+
* comparison flips through its declaration's `opposite`. Default `mode`. */
|
|
95
|
+
loupe?: {
|
|
96
|
+
modeGlobal?: string;
|
|
97
|
+
};
|
|
81
98
|
}
|
|
82
99
|
/** A frame config module's default export. The workshop page imports it as well as every frame document, so CSS it imports reaches both; the plugin's `frameStyles` is for CSS meant for frames alone. */
|
|
83
100
|
declare function defineFrameConfig(config: FrameSetup): FrameSetup;
|
package/dist/csf/preview-api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArgsContext, coverOf, isPortSafe } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
import { ArgsContext, coverOf, isPortSafe } from '../chunk-KEQBGDUZ.js';
|
|
2
|
+
import '../chunk-GH5RE5X5.js';
|
|
3
3
|
import { useContext } from 'react';
|
|
4
4
|
|
|
5
5
|
var sendable = (value) => {
|
package/dist/frame/index.css
CHANGED
|
@@ -16,6 +16,7 @@ body {
|
|
|
16
16
|
padding: var(--wzl-space-8);
|
|
17
17
|
}
|
|
18
18
|
.fg-frame--fullscreen {
|
|
19
|
+
height: 100vh;
|
|
19
20
|
padding: 0;
|
|
20
21
|
}
|
|
21
22
|
.fg-frame__fault {
|
|
@@ -212,4 +213,15 @@ body {
|
|
|
212
213
|
margin: var(--wzl-space-8) 0 0;
|
|
213
214
|
font-size: var(--wzl-font-size-sm);
|
|
214
215
|
}
|
|
216
|
+
|
|
217
|
+
/* src/frame/capture/capture.css */
|
|
218
|
+
.fg-story[data-fg-capture] {
|
|
219
|
+
position: relative;
|
|
220
|
+
box-sizing: border-box;
|
|
221
|
+
width: var(--fg-capture-w);
|
|
222
|
+
height: var(--fg-capture-h);
|
|
223
|
+
overflow: hidden;
|
|
224
|
+
contain: paint;
|
|
225
|
+
container-type: size;
|
|
226
|
+
}
|
|
215
227
|
/*# sourceMappingURL=index.css.map */
|
package/dist/frame/index.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/frame/frame.css","../../src/frame/index/index.css"],"sourcesContent":["html,\nbody {\n margin: 0;\n}\n\n.fg-frame {\n box-sizing: border-box;\n}\n\n.fg-frame--centered {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n}\n\n.fg-frame--padded {\n padding: var(--wzl-space-8);\n}\n\n.fg-frame--fullscreen {\n padding: 0;\n}\n\n.fg-frame__fault {\n margin: 0;\n padding: var(--wzl-space-8);\n white-space: pre-wrap;\n border: 1px solid #f2b8b5;\n border-radius: 4px;\n background: #fdecea;\n color: #8c1d18;\n font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n",".fg-index {\n box-sizing: border-box;\n max-width: 1200px;\n margin: 0 auto;\n padding: var(--wzl-space-lg);\n font-family: var(--wzl-font-ui);\n font-size: var(--wzl-font-size);\n color: var(--wzl-fg);\n}\n\n.fg-index__head {\n margin-bottom: calc(var(--wzl-space-lg) * 2);\n}\n\n.fg-index__path {\n margin: 0 0 var(--wzl-space-2);\n font-size: var(--wzl-font-size-lg);\n color: var(--wzl-fg-muted);\n}\n\n.fg-index__title {\n margin: 0;\n font-family: var(--wzl-panel-title-font);\n font-size: calc(var(--wzl-font-size-xl) * 1.6);\n font-weight: var(--wzl-font-weight-medium);\n letter-spacing: var(--wzl-panel-title-tracking);\n text-transform: var(--wzl-panel-title-case);\n}\n\n.fg-index__description,\n.fg-index-story__description {\n max-width: 72ch;\n margin: var(--wzl-space-4) 0 0;\n font-family: var(--wzl-font-body);\n line-height: 1.5;\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-story {\n padding-top: calc(var(--wzl-space-lg) * 1.5);\n margin-top: calc(var(--wzl-space-lg) * 1.5);\n border-top: var(--wzl-border-w) solid var(--wzl-border);\n}\n\n.fg-index-story__head {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-6);\n}\n\n.fg-index-story__name {\n margin: 0;\n font-family: var(--wzl-panel-title-font);\n font-size: var(--wzl-font-size-xl);\n font-weight: var(--wzl-panel-title-weight);\n letter-spacing: var(--wzl-panel-title-tracking);\n text-transform: var(--wzl-panel-title-case);\n color: var(--wzl-panel-title-color);\n}\n\n.fg-index-cell {\n margin: var(--wzl-space-8) 0 0;\n width: fit-content;\n /* A fluid specimen (a slider, a tiled workspace) has no width of its own,\n so hugging it alone collapses the cell to its padding. */\n min-width: min(100%, 20rem);\n max-width: 100%;\n}\n\n.fg-index-cell__stage {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 96px;\n padding: var(--wzl-space-2);\n border: var(--wzl-border-w) solid var(--wzl-border);\n border-radius: var(--wzl-radius-md);\n background: var(--wzl-surface);\n overflow: auto;\n}\n\n/* A padded story sits top-left as it would on a page: the column's width, and\n none of the minimum height that gives a centered one presence. */\n.fg-index-cell--padded {\n width: auto;\n}\n\n.fg-index-cell--padded > .fg-index-cell__stage {\n display: block;\n min-height: 0;\n}\n\n.fg-index-cell--fullscreen {\n width: auto;\n}\n\n.fg-index-cell--fullscreen > .fg-index-cell__stage {\n display: block;\n height: 360px;\n padding: 0;\n}\n\n.fg-index-cell__label {\n margin-top: var(--wzl-space-3);\n font-family: var(--wzl-font-mono);\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-variants__row {\n margin-top: calc(var(--wzl-space-lg) * 1.25);\n}\n\n/* Set as the kit's panel titles are, at the small size. */\n.fg-index-variants__label {\n margin: 0;\n font-family: var(--wzl-panel-title-font);\n font-size: var(--wzl-font-size-sm);\n font-weight: var(--wzl-panel-title-weight);\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-variants__cells {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: var(--wzl-space-6);\n}\n\n.fg-index-variants__cells > .fg-index-cell {\n margin-top: var(--wzl-space-4);\n}\n\n.fg-index__library {\n margin-inline-end: var(--wzl-space-4);\n vertical-align: middle;\n}\n\n.fg-index__title-row {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-6);\n}\n\n.fg-index-history {\n display: flex;\n flex-wrap: wrap;\n gap: var(--wzl-space-2) var(--wzl-space-8);\n margin: var(--wzl-space-8) 0 0;\n font-size: var(--wzl-font-size-sm);\n}\n\n.fg-index-history__item {\n display: flex;\n gap: var(--wzl-space-3);\n}\n\n.fg-index-history__label {\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-history__value {\n margin: 0;\n}\n\n.fg-index-deps {\n display: grid;\n grid-template-columns: max-content 1fr;\n gap: var(--wzl-space-3) var(--wzl-space-8);\n margin: var(--wzl-space-8) 0 0;\n font-size: var(--wzl-font-size-sm);\n}\n\n.fg-index-deps__row {\n display: contents;\n}\n\n.fg-index-deps__label {\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-deps__value {\n margin: 0;\n}\n\n.fg-index-deps__list {\n display: flex;\n flex-wrap: wrap;\n gap: var(--wzl-space-2) var(--wzl-space-6);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.fg-index-deps__link {\n color: var(--wzl-accent-fg);\n text-decoration: none;\n}\n\n.fg-index-deps__link:hover {\n text-decoration: underline;\n}\n\n.fg-index-deps__prefix,\n.fg-index-deps__empty,\n.fg-index-deps__none {\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-deps__none {\n max-width: 72ch;\n margin: var(--wzl-space-8) 0 0;\n font-size: var(--wzl-font-size-sm);\n}\n"],"mappings":";AAAA;AACA;AACE,UAAQ;AACV;AAEA,CAAC;AACC,cAAY;AACd;AAEA,CAAC;AACC,WAAS;AACT,eAAa;AACb,mBAAiB;AACjB,cAAY;AACd;AAEA,CAAC;AACC,WAAS,IAAI;AACf;AAEA,CAAC;AACC,WAAS;AACX;AAEA,CAAC;AACC,UAAQ;AACR,WAAS,IAAI;AACb,eAAa;AACb,UAAQ,IAAI,MAAM;AAClB,iBAAe;AACf,cAAY;AACZ,SAAO;AACP;AAAA,IAAM,IAAI,CAAC,IAAI,YAAY;AAAA,IAAE,cAAc;AAAA,IAAE,KAAK;AAAA,IAAE;AACtD;;;
|
|
1
|
+
{"version":3,"sources":["../../src/frame/frame.css","../../src/frame/index/index.css","../../src/frame/capture/capture.css"],"sourcesContent":["html,\nbody {\n margin: 0;\n}\n\n.fg-frame {\n box-sizing: border-box;\n}\n\n.fg-frame--centered {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n}\n\n.fg-frame--padded {\n padding: var(--wzl-space-8);\n}\n\n.fg-frame--fullscreen {\n height: 100vh;\n padding: 0;\n}\n\n.fg-frame__fault {\n margin: 0;\n padding: var(--wzl-space-8);\n white-space: pre-wrap;\n border: 1px solid #f2b8b5;\n border-radius: 4px;\n background: #fdecea;\n color: #8c1d18;\n font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n",".fg-index {\n box-sizing: border-box;\n max-width: 1200px;\n margin: 0 auto;\n padding: var(--wzl-space-lg);\n font-family: var(--wzl-font-ui);\n font-size: var(--wzl-font-size);\n color: var(--wzl-fg);\n}\n\n.fg-index__head {\n margin-bottom: calc(var(--wzl-space-lg) * 2);\n}\n\n.fg-index__path {\n margin: 0 0 var(--wzl-space-2);\n font-size: var(--wzl-font-size-lg);\n color: var(--wzl-fg-muted);\n}\n\n.fg-index__title {\n margin: 0;\n font-family: var(--wzl-panel-title-font);\n font-size: calc(var(--wzl-font-size-xl) * 1.6);\n font-weight: var(--wzl-font-weight-medium);\n letter-spacing: var(--wzl-panel-title-tracking);\n text-transform: var(--wzl-panel-title-case);\n}\n\n.fg-index__description,\n.fg-index-story__description {\n max-width: 72ch;\n margin: var(--wzl-space-4) 0 0;\n font-family: var(--wzl-font-body);\n line-height: 1.5;\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-story {\n padding-top: calc(var(--wzl-space-lg) * 1.5);\n margin-top: calc(var(--wzl-space-lg) * 1.5);\n border-top: var(--wzl-border-w) solid var(--wzl-border);\n}\n\n.fg-index-story__head {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-6);\n}\n\n.fg-index-story__name {\n margin: 0;\n font-family: var(--wzl-panel-title-font);\n font-size: var(--wzl-font-size-xl);\n font-weight: var(--wzl-panel-title-weight);\n letter-spacing: var(--wzl-panel-title-tracking);\n text-transform: var(--wzl-panel-title-case);\n color: var(--wzl-panel-title-color);\n}\n\n.fg-index-cell {\n margin: var(--wzl-space-8) 0 0;\n width: fit-content;\n /* A fluid specimen (a slider, a tiled workspace) has no width of its own,\n so hugging it alone collapses the cell to its padding. */\n min-width: min(100%, 20rem);\n max-width: 100%;\n}\n\n.fg-index-cell__stage {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 96px;\n padding: var(--wzl-space-2);\n border: var(--wzl-border-w) solid var(--wzl-border);\n border-radius: var(--wzl-radius-md);\n background: var(--wzl-surface);\n overflow: auto;\n}\n\n/* A padded story sits top-left as it would on a page: the column's width, and\n none of the minimum height that gives a centered one presence. */\n.fg-index-cell--padded {\n width: auto;\n}\n\n.fg-index-cell--padded > .fg-index-cell__stage {\n display: block;\n min-height: 0;\n}\n\n.fg-index-cell--fullscreen {\n width: auto;\n}\n\n.fg-index-cell--fullscreen > .fg-index-cell__stage {\n display: block;\n height: 360px;\n padding: 0;\n}\n\n.fg-index-cell__label {\n margin-top: var(--wzl-space-3);\n font-family: var(--wzl-font-mono);\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-variants__row {\n margin-top: calc(var(--wzl-space-lg) * 1.25);\n}\n\n/* Set as the kit's panel titles are, at the small size. */\n.fg-index-variants__label {\n margin: 0;\n font-family: var(--wzl-panel-title-font);\n font-size: var(--wzl-font-size-sm);\n font-weight: var(--wzl-panel-title-weight);\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-variants__cells {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: var(--wzl-space-6);\n}\n\n.fg-index-variants__cells > .fg-index-cell {\n margin-top: var(--wzl-space-4);\n}\n\n.fg-index__library {\n margin-inline-end: var(--wzl-space-4);\n vertical-align: middle;\n}\n\n.fg-index__title-row {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-6);\n}\n\n.fg-index-history {\n display: flex;\n flex-wrap: wrap;\n gap: var(--wzl-space-2) var(--wzl-space-8);\n margin: var(--wzl-space-8) 0 0;\n font-size: var(--wzl-font-size-sm);\n}\n\n.fg-index-history__item {\n display: flex;\n gap: var(--wzl-space-3);\n}\n\n.fg-index-history__label {\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-history__value {\n margin: 0;\n}\n\n.fg-index-deps {\n display: grid;\n grid-template-columns: max-content 1fr;\n gap: var(--wzl-space-3) var(--wzl-space-8);\n margin: var(--wzl-space-8) 0 0;\n font-size: var(--wzl-font-size-sm);\n}\n\n.fg-index-deps__row {\n display: contents;\n}\n\n.fg-index-deps__label {\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-deps__value {\n margin: 0;\n}\n\n.fg-index-deps__list {\n display: flex;\n flex-wrap: wrap;\n gap: var(--wzl-space-2) var(--wzl-space-6);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.fg-index-deps__link {\n color: var(--wzl-accent-fg);\n text-decoration: none;\n}\n\n.fg-index-deps__link:hover {\n text-decoration: underline;\n}\n\n.fg-index-deps__prefix,\n.fg-index-deps__empty,\n.fg-index-deps__none {\n color: var(--wzl-fg-muted);\n}\n\n.fg-index-deps__none {\n max-width: 72ch;\n margin: var(--wzl-space-8) 0 0;\n font-size: var(--wzl-font-size-sm);\n}\n","/* The capture box is the host's size exactly, whatever else styles a `.fg-story`. An isolated story's frame wrapper\n measures `100vh` against the page, which the capture sizes to the box. */\n.fg-story[data-fg-capture] {\n position: relative;\n box-sizing: border-box;\n width: var(--fg-capture-w);\n height: var(--fg-capture-h);\n overflow: hidden;\n contain: paint;\n container-type: size;\n}\n"],"mappings":";AAAA;AACA;AACE,UAAQ;AACV;AAEA,CAAC;AACC,cAAY;AACd;AAEA,CAAC;AACC,WAAS;AACT,eAAa;AACb,mBAAiB;AACjB,cAAY;AACd;AAEA,CAAC;AACC,WAAS,IAAI;AACf;AAEA,CAAC;AACC,UAAQ;AACR,WAAS;AACX;AAEA,CAAC;AACC,UAAQ;AACR,WAAS,IAAI;AACb,eAAa;AACb,UAAQ,IAAI,MAAM;AAClB,iBAAe;AACf,cA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;AACR,WAAS;AACT,cAAY;AACd;AAEA,CAAC;AACC,SAAO,IAAI;AACX,mBAAiB;AACnB;AAEA,CALC,mBAKmB;AAClB,mBAAiB;AACnB;AAEA,CAAC;AACD,CAAC;AACD,CAAC;AACC,SAAO,IAAI;AACb;AAEA,CAJC;AAKC,aAAW;AACX,UAAQ,IAAI,eAAe,EAAE;AAC7B,aAAW,IAAI;AACjB;;;ACrNA,CAAC,QAAQ,CAAC;AACR,YAAU;AACV,cAAY;AACZ,SAAO,IAAI;AACX,UAAQ,IAAI;AACZ,YAAU;AACV,WAAS;AACT,kBAAgB;AAClB;","names":[]}
|
package/dist/frame/index.d.ts
CHANGED
|
@@ -1,39 +1,72 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { G as Globals, L as Layout, I as IndexEntry, F as FrameSetup } from '../FrameController-CdnaIo4C.js';
|
|
2
|
+
export { C as Channel, a as ConfigAnswers, b as FaultPhase, c as FromFrame, S as StartFrameOptions, T as ToFrame, r as reportImportFault, s as startFrame } from '../FrameController-CdnaIo4C.js';
|
|
3
|
+
import { F as FrameImporters } from '../mountFrame-Ds3QLnBF.js';
|
|
4
|
+
export { a as FrameIndexEntry, M as MountFrameOptions, m as mountFrame } from '../mountFrame-Ds3QLnBF.js';
|
|
5
|
+
import { Theme } from '@weasel-js/theme';
|
|
3
6
|
import '@weasel-js/icons';
|
|
4
7
|
import '@weasel-js/labkit/config';
|
|
5
8
|
import 'react';
|
|
6
9
|
|
|
7
|
-
/**
|
|
8
|
-
interface
|
|
9
|
-
|
|
10
|
+
/** Everything the screen renders a story from, as the capture endpoint takes it. */
|
|
11
|
+
interface CapturePayload {
|
|
12
|
+
/** The story's index id. */
|
|
13
|
+
story: string;
|
|
14
|
+
/** Picks the document: an isolated story renders under frame styles, any other under shell styles. */
|
|
15
|
+
isolate: boolean;
|
|
16
|
+
/** The story's config, with forge's `$` keys stripped and a comparison's args laid over. */
|
|
17
|
+
config: unknown;
|
|
18
|
+
/** Must survive JSON. */
|
|
19
|
+
state: unknown;
|
|
20
|
+
globals: Globals;
|
|
21
|
+
/** CSS variable overrides, by property name. */
|
|
22
|
+
overrides: Readonly<Record<string, string>>;
|
|
23
|
+
/** Null for a story with no timeline, and for an isolated story. */
|
|
24
|
+
playhead: number | null;
|
|
25
|
+
/** The host's size in CSS pixels. */
|
|
26
|
+
box: {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
layout: Layout;
|
|
31
|
+
/** Device pixel ratio, in [1, 3]. */
|
|
32
|
+
dpr: number;
|
|
33
|
+
/** Where the story's scroller stands in its host, in CSS pixels, so the capture shows the patch the screen does. */
|
|
34
|
+
scroll: {
|
|
35
|
+
left: number;
|
|
36
|
+
top: number;
|
|
37
|
+
};
|
|
38
|
+
/** The workshop lab's theme as the screen shows it: the lab's globals, which the shell config's `labTheme` reads,
|
|
39
|
+
* and its resolved color mode. An isolated story's document has no lab, and ignores it. */
|
|
40
|
+
lab: {
|
|
41
|
+
globals: Globals;
|
|
42
|
+
mode: 'light' | 'dark';
|
|
43
|
+
};
|
|
44
|
+
/** The OS color scheme the screen sees, which the capture page emulates: a story or a lab in `auto` mode follows
|
|
45
|
+
* `prefers-color-scheme`, and headless Chromium would otherwise answer light. */
|
|
46
|
+
colorScheme: 'light' | 'dark';
|
|
10
47
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
title: string;
|
|
16
|
-
file: string;
|
|
17
|
-
exportName: string;
|
|
18
|
-
/** The JSDoc above the story's export, which its index page shows. */
|
|
19
|
-
description?: string;
|
|
20
|
-
/** The JSDoc above the file's meta, which heads the index page. */
|
|
21
|
-
componentDescription?: string;
|
|
22
|
-
/** The meta's `tags`. */
|
|
23
|
-
tags?: readonly string[];
|
|
24
|
-
}
|
|
25
|
-
/** Inputs to `mountFrame`. `load` replaces the default module loader, `loadStories`. */
|
|
26
|
-
interface MountFrameOptions {
|
|
27
|
-
index: readonly FrameIndexEntry[];
|
|
48
|
+
|
|
49
|
+
/** Inputs to `mountCapture`, as a capture page's entry module passes them. */
|
|
50
|
+
interface MountCaptureOptions {
|
|
51
|
+
index: readonly IndexEntry[];
|
|
28
52
|
importers: FrameImporters;
|
|
29
|
-
setup
|
|
30
|
-
|
|
53
|
+
setup: FrameSetup;
|
|
54
|
+
/** The shell config's `labTheme`; only the shell's capture page has one. */
|
|
55
|
+
labTheme?: ((globals: Globals) => Theme) | undefined;
|
|
56
|
+
}
|
|
57
|
+
declare global {
|
|
58
|
+
interface Window {
|
|
59
|
+
/** Set by `mountCapture`: renders one payload and resolves once it has painted. */
|
|
60
|
+
__forgeCapture?: {
|
|
61
|
+
render(payload: CapturePayload): Promise<void>;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
31
64
|
}
|
|
32
|
-
|
|
33
65
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
66
|
+
* A capture page's entry: exposes `window.__forgeCapture.render(payload)`, which loads the payload's story, renders
|
|
67
|
+
* it afresh into `#root`, and resolves once it has painted. Rejects for a story the index does not hold, and with
|
|
68
|
+
* whatever throws outside the story's own error boundary.
|
|
36
69
|
*/
|
|
37
|
-
declare function
|
|
70
|
+
declare function mountCapture({ index, importers, setup, labTheme }: MountCaptureOptions): void;
|
|
38
71
|
|
|
39
|
-
export {
|
|
72
|
+
export { FrameImporters, FrameSetup, type MountCaptureOptions, mountCapture };
|
package/dist/frame/index.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { describeSchema, createKitRoot, openChannel, isIndexId, TITLE_LIBRARIES, indexId, answerSchema, IndexPage } from '../chunk-
|
|
1
|
+
import { describeSchema, createKitRoot, openChannel, isIndexId, TITLE_LIBRARIES, indexId, LAB_DENSITY, answerSchema, IndexPage } from '../chunk-ATI7FYJ7.js';
|
|
2
2
|
import { isGallery } from '../chunk-WEQSLPKT.js';
|
|
3
|
-
import { createOverrides, createGlobalsTarget, loadStories, indexRenderOf, scanCssVars, runAxe, StoryHost, resolveCssVar } from '../chunk-
|
|
4
|
-
import '../chunk-L5XM5VKB.js';
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import { FRAME_HELLO, stableStringify, PORT_HANDOFF } from '../chunk-
|
|
3
|
+
import { createOverrides, createGlobalsTarget, createA11yHighlighter, loadStories, indexRenderOf, scanCssVars, auditElement, runAxe, useHostConditions, useStoryClock, StoryHost, resolveCssVar } from '../chunk-WMGEO5M6.js';
|
|
4
|
+
import { ClockContext } from '../chunk-L5XM5VKB.js';
|
|
5
|
+
import '../chunk-5WS67HMU.js';
|
|
6
|
+
import '../chunk-KEQBGDUZ.js';
|
|
7
|
+
import { FRAME_HELLO, stableStringify, PORT_HANDOFF } from '../chunk-GH5RE5X5.js';
|
|
8
8
|
import { flushSync } from 'react-dom';
|
|
9
9
|
import { jsx } from 'react/jsx-runtime';
|
|
10
10
|
import { f } from '@weasel-js/labkit/config';
|
|
11
|
-
import { Component } from 'react';
|
|
11
|
+
import { Component, useState, useMemo, useLayoutEffect, useRef, useEffect } from 'react';
|
|
12
|
+
import { useLatest, useVisibleRaf } from '@weasel-js/core';
|
|
13
|
+
import { interstellarTheme, LabRoot } from '@weasel-js/labkit';
|
|
14
|
+
import { ThemeProvider } from '@weasel-js/theme/react';
|
|
15
|
+
import { OverlayPortalProvider } from '@weasel-js/ui/portal-host';
|
|
12
16
|
|
|
13
17
|
var VARS_SETTLE_MS = 100;
|
|
14
18
|
function fault(phase, error, seq) {
|
|
@@ -38,6 +42,7 @@ function startFrame({ story, channel, container, setup = {} }) {
|
|
|
38
42
|
let seq = 0;
|
|
39
43
|
const overrides = createOverrides(document, setup.cssVarsScope);
|
|
40
44
|
const globalsTarget = createGlobalsTarget(document.documentElement, ":root");
|
|
45
|
+
const highlighter = createA11yHighlighter(document);
|
|
41
46
|
let lastVars = null;
|
|
42
47
|
let reported = null;
|
|
43
48
|
const publishVars = (vars) => {
|
|
@@ -109,13 +114,7 @@ function startFrame({ story, channel, container, setup = {} }) {
|
|
|
109
114
|
const afterPaint = () => requestAnimationFrame(() => send({ type: "rendered" }));
|
|
110
115
|
void fonts.ready.then(afterPaint, afterPaint);
|
|
111
116
|
};
|
|
112
|
-
const audit = async (id) => {
|
|
113
|
-
try {
|
|
114
|
-
send({ type: "a11y", id, ok: true, report: await runAxe(wrapper) });
|
|
115
|
-
} catch (error) {
|
|
116
|
-
send({ type: "a11y", id, ok: false, message: error instanceof Error ? error.message : String(error) });
|
|
117
|
-
}
|
|
118
|
-
};
|
|
117
|
+
const audit = async (id) => send({ type: "a11y", id, ...await auditElement(wrapper) });
|
|
119
118
|
const off = channel.on((msg) => {
|
|
120
119
|
switch (msg.type) {
|
|
121
120
|
case "init":
|
|
@@ -159,6 +158,9 @@ function startFrame({ story, channel, container, setup = {} }) {
|
|
|
159
158
|
case "a11y.run":
|
|
160
159
|
void audit(msg.id);
|
|
161
160
|
break;
|
|
161
|
+
case "a11y.highlight":
|
|
162
|
+
highlighter.show(msg.targets);
|
|
163
|
+
break;
|
|
162
164
|
}
|
|
163
165
|
});
|
|
164
166
|
return () => {
|
|
@@ -167,6 +169,7 @@ function startFrame({ story, channel, container, setup = {} }) {
|
|
|
167
169
|
clearTimeout(settleTimer);
|
|
168
170
|
overrides.dispose();
|
|
169
171
|
globalsTarget.dispose();
|
|
172
|
+
highlighter.dispose();
|
|
170
173
|
root.unmount();
|
|
171
174
|
wrapper.remove();
|
|
172
175
|
};
|
|
@@ -335,7 +338,131 @@ async function mountFrame(options) {
|
|
|
335
338
|
reportImportFault(channel, error);
|
|
336
339
|
}
|
|
337
340
|
}
|
|
341
|
+
var HOST_ID = "capture";
|
|
342
|
+
var NO_WRITE = () => {
|
|
343
|
+
};
|
|
344
|
+
var boxStyle = ({ width, height }) => ({ ["--fg-capture-w"]: `${width}px`, ["--fg-capture-h"]: `${height}px` });
|
|
345
|
+
function scrollTo(host, { left, top }) {
|
|
346
|
+
const scroller = host?.querySelector(":scope > .fg-story__scroll");
|
|
347
|
+
if (!scroller) return;
|
|
348
|
+
scroller.scrollLeft = left;
|
|
349
|
+
scroller.scrollTop = top;
|
|
350
|
+
}
|
|
351
|
+
function CaptureView({ story, payload, setup, labTheme, onRendered }) {
|
|
352
|
+
const [host, setHost] = useState(null);
|
|
353
|
+
useHostConditions(host, { hostId: HOST_ID, globals: payload.globals, overrides: payload.overrides, setup });
|
|
354
|
+
const spec = useMemo(() => story.timeline?.(payload.config) ?? null, [story, payload.config]);
|
|
355
|
+
const clock = useStoryClock(spec, () => payload.playhead);
|
|
356
|
+
const state = useMemo(
|
|
357
|
+
() => payload.state === null && story.initialState ? story.initialState(payload.config) : payload.state,
|
|
358
|
+
[payload.state, payload.config, story]
|
|
359
|
+
);
|
|
360
|
+
const ctx = {
|
|
361
|
+
config: payload.config,
|
|
362
|
+
setConfig: NO_WRITE,
|
|
363
|
+
state,
|
|
364
|
+
setState: NO_WRITE,
|
|
365
|
+
globals: payload.globals,
|
|
366
|
+
title: story.title,
|
|
367
|
+
name: story.name
|
|
368
|
+
};
|
|
369
|
+
const latest = useLatest({ onRendered, host, scroll: payload.scroll });
|
|
370
|
+
useLayoutEffect(() => scrollTo(host, payload.scroll), [host, payload.scroll]);
|
|
371
|
+
const ticks = useRef(0);
|
|
372
|
+
const raf = useVisibleRaf(
|
|
373
|
+
(_now, loop) => {
|
|
374
|
+
ticks.current += 1;
|
|
375
|
+
scrollTo(latest.current.host, latest.current.scroll);
|
|
376
|
+
if (ticks.current < 2) loop.request();
|
|
377
|
+
else latest.current.onRendered();
|
|
378
|
+
},
|
|
379
|
+
{ dangerouslyRunWhenHidden: true }
|
|
380
|
+
);
|
|
381
|
+
useEffect(() => {
|
|
382
|
+
if (!host) return;
|
|
383
|
+
let canceled = false;
|
|
384
|
+
const start = () => {
|
|
385
|
+
if (!canceled) raf.request();
|
|
386
|
+
};
|
|
387
|
+
const { fonts } = host.ownerDocument;
|
|
388
|
+
if (fonts) void fonts.ready.then(start, start);
|
|
389
|
+
else start();
|
|
390
|
+
return () => {
|
|
391
|
+
canceled = true;
|
|
392
|
+
raf.cancel();
|
|
393
|
+
};
|
|
394
|
+
}, [host, raf]);
|
|
395
|
+
const content = host ? /* @__PURE__ */ jsx(ClockContext.Provider, { value: clock, children: /* @__PURE__ */ jsx(StoryHost, { story, ctx, decorators: setup.decorators ?? [], resetKey: 0, onError: NO_WRITE }) }) : null;
|
|
396
|
+
const box = /* @__PURE__ */ jsx(
|
|
397
|
+
"div",
|
|
398
|
+
{
|
|
399
|
+
ref: setHost,
|
|
400
|
+
className: "fg-story",
|
|
401
|
+
"data-fg-host": HOST_ID,
|
|
402
|
+
"data-fg-capture": "",
|
|
403
|
+
"data-fg-layout": payload.layout,
|
|
404
|
+
style: boxStyle(payload.box),
|
|
405
|
+
children: payload.isolate ? /* @__PURE__ */ jsx("div", { className: `fg-frame fg-frame--${payload.layout}`, children: content }) : /* @__PURE__ */ jsx("div", { className: "fg-story__scroll", children: host ? /* @__PURE__ */ jsx(OverlayPortalProvider, { container: host, contained: true, children: content }) : null })
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
if (payload.isolate) return box;
|
|
409
|
+
return /* @__PURE__ */ jsx(
|
|
410
|
+
ThemeProvider,
|
|
411
|
+
{
|
|
412
|
+
theme: labTheme?.(payload.lab.globals) ?? interstellarTheme,
|
|
413
|
+
selection: { mode: payload.lab.mode, density: LAB_DENSITY },
|
|
414
|
+
children: /* @__PURE__ */ jsx(LabRoot, { children: box })
|
|
415
|
+
}
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
var CaptureBoundary = class extends Component {
|
|
419
|
+
state = { failed: false };
|
|
420
|
+
static getDerivedStateFromError() {
|
|
421
|
+
return { failed: true };
|
|
422
|
+
}
|
|
423
|
+
componentDidCatch(error) {
|
|
424
|
+
this.props.onError(error);
|
|
425
|
+
}
|
|
426
|
+
render() {
|
|
427
|
+
return this.state.failed ? null : this.props.children;
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
function mountCapture({ index, importers, setup, labTheme }) {
|
|
431
|
+
const container = document.getElementById("root") ?? document.body;
|
|
432
|
+
const root = createKitRoot(container, setup.icons);
|
|
433
|
+
const prepared = /* @__PURE__ */ new Map();
|
|
434
|
+
let renders = 0;
|
|
435
|
+
const storyOf = (id) => {
|
|
436
|
+
let loading = prepared.get(id);
|
|
437
|
+
if (!loading) {
|
|
438
|
+
loading = (async () => {
|
|
439
|
+
const entry = index.find((e) => e.id === id);
|
|
440
|
+
if (!entry) throw new Error(`No story with id "${id}"`);
|
|
441
|
+
const importer = importers[entry.file];
|
|
442
|
+
if (!importer) throw new Error(`No importer for ${entry.file}`);
|
|
443
|
+
const story = loadStories(await importer(), entry.title, setup.parameters).find((s) => s.exportName === entry.exportName);
|
|
444
|
+
if (!story) throw new Error(`${entry.file} has no story export "${entry.exportName}"`);
|
|
445
|
+
await setup.prepare?.(story);
|
|
446
|
+
return story;
|
|
447
|
+
})();
|
|
448
|
+
prepared.set(id, loading);
|
|
449
|
+
loading.catch(() => prepared.delete(id));
|
|
450
|
+
}
|
|
451
|
+
return loading;
|
|
452
|
+
};
|
|
453
|
+
window.__forgeCapture = {
|
|
454
|
+
async render(payload) {
|
|
455
|
+
const story = await storyOf(payload.story);
|
|
456
|
+
renders += 1;
|
|
457
|
+
await new Promise((resolve, reject) => {
|
|
458
|
+
root.render(
|
|
459
|
+
/* @__PURE__ */ jsx(CaptureBoundary, { onError: reject, children: /* @__PURE__ */ jsx(CaptureView, { story, payload, setup, labTheme, onRendered: resolve }) }, renders)
|
|
460
|
+
);
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
}
|
|
338
465
|
|
|
339
|
-
export { mountFrame, reportImportFault, startFrame };
|
|
466
|
+
export { mountCapture, mountFrame, reportImportFault, startFrame };
|
|
340
467
|
//# sourceMappingURL=index.js.map
|
|
341
468
|
//# sourceMappingURL=index.js.map
|
package/dist/frame/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/frame/FrameController.tsx","../../src/frame/index/startIndex.tsx","../../src/frame/mountFrame.tsx"],"names":["jsx","flushSync","id","stories","story"],"mappings":";;;;;;;;;;;;AAkDA,IAAM,cAAA,GAAiB,GAAA;AAEvB,SAAS,KAAA,CAAM,KAAA,EAAmB,KAAA,EAAgB,GAAA,EAAyB;AACzE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,KAAA;AAAA,IACA,SAAS,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AAAA,IAC9D,GAAI,KAAA,YAAiB,KAAA,IAAS,KAAA,CAAM,KAAA,GAAQ,EAAE,KAAA,EAAO,KAAA,CAAM,KAAA,EAAM,GAAI,EAAC;AAAA,IACtE,GAAI,GAAA,KAAQ,MAAA,GAAY,EAAC,GAAI,EAAE,GAAA;AAAI,GACrC;AACF;AAGO,SAAS,UAAA,CAAW,EAAE,KAAA,EAAO,OAAA,EAAS,WAAW,KAAA,GAAQ,IAAG,EAAkC;AACnG,EAAA,MAAM,EAAE,MAAK,GAAI,OAAA;AACjB,EAAA,IAAA,CAAK,EAAE,IAAA,EAAM,OAAA,EAAS,MAAA,EAAQ,eAAe,KAAA,CAAM,MAAM,CAAA,EAAG,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAQ,QAAA,EAAU,KAAA,CAAM,UAAU,CAAA;AAE5G,EAAA,MAAM,OAAA,GAAU,QAAA,CAAS,aAAA,CAAc,KAAK,CAAA;AAC5C,EAAA,OAAA,CAAQ,SAAA,GAAY,CAAA,mBAAA,EAAsB,KAAA,CAAM,MAAM,CAAA,CAAA;AACtD,EAAA,SAAA,CAAU,OAAO,OAAO,CAAA;AACxB,EAAA,MAAM,IAAA,GAAO,aAAA,CAAc,OAAA,EAAS,KAAA,CAAM,KAAK,CAAA;AAC/C,EAAA,MAAM,UAAA,GAAa,KAAA,C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,MAAA;AAAA,IACF;AACA,IAAA,MAAM,KAAA,GAAQ,QAAQ,KAAA,CAAM,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,EAAE,CAAA;AACnD,IAAA,IAAI,CAAC,KAAA,EAAO,MAAM,IAAI,KAAA,CAAM,CAAA,kBAAA,EAAqB,EAAE,CAAA,CAAA,CAAG,CAAA;AACtD,IAAA,MAAM,GAAA,GAAM,MAAM,QAAA,CAAS,KAAA,CAAM,IAAI,CAAA;AACrC,IAAA,MAAM,OAAA,GAAA,CAAW,QAAQ,IAAA,IAAQ,WAAA,EAAa,KAAK,KAAA,CAAM,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAO,UAAU,CAAA;AACzF,IAAA,MAAM,KAAA,GAAQ,QAAQ,IAAA,CAAK,CAAC,MAAM,CAAA,CAAE,UAAA,KAAe,MAAM,UAAU,CAAA;AACnE,IAAA,IAAI,CAAC,KAAA,EAAO,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,KAAA,CAAM,IAAI,CAAA,sBAAA,EAAyB,KAAA,CAAM,UAAU,CAAA,CAAA,CAAG,CAAA;AACrF,IAAA,MAAM,OAAA,CAAQ,KAAA,EAAO,OAAA,GAAU,KAAK,CAAA;AACpC,IAAA,UAAA,CAAW,EAAE,KAAA,EAAO,OAAA,EAAS,WAAW,KAAA,EAAO,OAAA,CAAQ,OAAO,CAAA;AAAA,EAChE,SAAS,KAAA,EAAO;AACd,IAAA,iBAAA,CAAkB,SAAS,KAAK,CAAA;AAAA,EAClC;AACF","file":"index.js","sourcesContent":["import { flushSync } from 'react-dom';\nimport type { IconTable } from '@weasel-js/icons';\nimport { createKitRoot } from '../kitIcons';\nimport type { Channel } from '../protocol/channel';\nimport {\n type CssVarReport,\n type FaultPhase,\n type FromFrame,\n type Globals,\n stableStringify,\n type ToFrame,\n} from '../protocol/messages';\nimport { answerSchema, describeSchema } from '../protocol/schema';\nimport type { Decorator, LoadedStory, StoryContext } from '../story/types';\nimport { runAxe } from './a11y';\nimport { createOverrides, resolveCssVar, scanCssVars } from './cssVars';\nimport { createGlobalsTarget, type GlobalsTarget } from './globalsTarget';\nimport { StoryHost } from './StoryHost';\n\n/** The frame config: what `defineFrameConfig` returns and the `frameConfig` module default-exports. */\nexport interface FrameSetup {\n /** Wraps every story, outermost; receives the globals. From the frame config (`frameConfig`). */\n decorators?: Decorator[];\n /** Applies globals to a target: theme mode, fonts. The target is a frame document's root, or one story's host in\n * the workshop document, so a rule the setup writes goes through `target.style` under `target.scope`. */\n applyGlobals?: (globals: Globals, target: GlobalsTarget) => void;\n /**\n * The elements a CSS variable override is declared on; `:root` by default. An override has to be declared on\n * whichever element declares the token itself — a theme wrapper, say — or that element's own value wins.\n */\n cssVarsScope?: string;\n /** Project-wide CSF parameters, Storybook's preview `parameters`: under each meta's and story's. */\n parameters?: Record<string, unknown>;\n /**\n * Awaited once a story is loaded and before it first renders — the place to import what only some stories\n * need, so the rest never load it.\n */\n prepare?: (story: LoadedStory) => void | Promise<void>;\n /** Icon tables registered beside the kit's in every frame: an app's own, for its stories' glyphs. */\n icons?: readonly IconTable[];\n}\n\n/** Inputs to `startFrame`: the story, the channel to the shell, and the element to render into. */\nexport interface StartFrameOptions {\n story: LoadedStory;\n channel: Channel<ToFrame, FromFrame>;\n container: HTMLElement;\n setup?: FrameSetup;\n}\n\nconst VARS_SETTLE_MS = 100;\n\nfunction fault(phase: FaultPhase, error: unknown, seq?: number): FromFrame {\n return {\n type: 'fault',\n phase,\n message: error instanceof Error ? error.message : String(error),\n ...(error instanceof Error && error.stack ? { stack: error.stack } : {}),\n ...(seq === undefined ? {} : { seq }),\n };\n}\n\n/** Sends `ready`, then renders the story on `init` and keeps it in step. Returns a stop function. */\nexport function startFrame({ story, channel, container, setup = {} }: StartFrameOptions): () => void {\n const { send } = channel;\n send({ type: 'ready', schema: describeSchema(story.config), layout: story.layout, viewport: story.viewport });\n\n const wrapper = document.createElement('div');\n wrapper.className = `fg-frame fg-frame--${story.layout}`;\n container.append(wrapper);\n const root = createKitRoot(wrapper, setup.icons);\n const decorators = setup.decorators ?? [];\n\n let initialized = false;\n let rendered = false;\n let config: unknown;\n let state: unknown = null;\n let globals: Globals = {};\n let answeredKey: string | null = null;\n let resetKey = 0;\n let seq = 0;\n\n const overrides = createOverrides(document, setup.cssVarsScope);\n const globalsTarget = createGlobalsTarget(document.documentElement, ':root');\n let lastVars: CssVarReport[] | null = null;\n let reported: string | null = null;\n const publishVars = (vars: CssVarReport[]) => {\n lastVars = vars;\n const key = JSON.stringify(vars);\n if (key === reported) return;\n reported = key;\n send({ type: 'vars', vars });\n };\n const reportVars = () => publishVars(scanCssVars(document, overrides.has));\n const ownMutation = (record: MutationRecord) =>\n overrides.owns(record.target) ||\n (record.type === 'childList' &&\n [...record.addedNodes, ...record.removedNodes].length > 0 &&\n [...record.addedNodes, ...record.removedNodes].every(overrides.owns));\n let settleTimer: ReturnType<typeof setTimeout> | undefined;\n const mutations =\n typeof MutationObserver === 'undefined'\n ? null\n : new MutationObserver((records) => {\n if (records.every(ownMutation)) return;\n clearTimeout(settleTimer);\n settleTimer = setTimeout(reportVars, VARS_SETTLE_MS);\n });\n // Every attribute, not just style and class: a stylesheet can select on any of them, `[data-wzl-mode]` included.\n mutations?.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });\n\n const setConfig = (path: string, value: unknown) => send({ type: 'setConfig', path, value });\n const setState = (next: unknown) => {\n state = typeof next === 'function' ? (next as (prev: unknown) => unknown)(state) : next;\n send({ type: 'setState', state });\n render();\n };\n\n const render = () => {\n const ctx: StoryContext = { config, setConfig, state, setState, globals, title: story.title, name: story.name };\n const at = seq;\n root.render(\n <StoryHost\n story={story}\n ctx={ctx}\n decorators={decorators}\n resetKey={resetKey}\n onError={(error) => send(fault('render', error, at))}\n />,\n );\n const key = stableStringify(config);\n if (key !== answeredKey) {\n answeredKey = key;\n send({ type: 'answers', answers: { configKey: key, ...answerSchema(story.config, config) } });\n }\n };\n\n // Input from the trial commits synchronously, so `rendered` and the vars report describe the story it produced. A\n // throw while applying it faults like a render would; otherwise the trial would wait on a frame that never answers.\n const input = (apply: () => void) => {\n seq += 1;\n try {\n apply();\n if (!initialized) return;\n resetKey += 1;\n flushSync(render);\n } catch (error) {\n send(fault('render', error, seq));\n return;\n }\n if (!rendered) {\n rendered = true;\n announceRendered();\n }\n reportVars();\n };\n\n /**\n * The shell unhides the frame on `rendered` and fades it in, so a webfont\n * swapping in after that message reads as the story gliding. Waiting for the\n * fonts and then one painted frame means the story the shell reveals is the\n * settled one.\n *\n * `document.fonts` is absent in jsdom, so the message stays synchronous\n * there; the deferral is only exercised in a browser.\n */\n const announceRendered = () => {\n const { fonts } = document;\n if (!fonts) {\n send({ type: 'rendered' });\n return;\n }\n const afterPaint = () => requestAnimationFrame(() => send({ type: 'rendered' }));\n void fonts.ready.then(afterPaint, afterPaint);\n };\n\n const audit = async (id: string) => {\n try {\n send({ type: 'a11y', id, ok: true, report: await runAxe(wrapper) });\n } catch (error) {\n send({ type: 'a11y', id, ok: false, message: error instanceof Error ? error.message : String(error) });\n }\n };\n\n const off = channel.on((msg) => {\n switch (msg.type) {\n case 'init':\n input(() => {\n initialized = true;\n config = msg.config;\n globals = msg.globals;\n state = msg.state;\n if (state === null && story.initialState) {\n state = story.initialState(config);\n send({ type: 'setState', state });\n }\n setup.applyGlobals?.(globals, globalsTarget);\n });\n break;\n case 'config':\n input(() => {\n config = msg.config;\n });\n break;\n case 'state':\n input(() => {\n state = msg.state;\n });\n break;\n case 'globals':\n input(() => {\n globals = msg.globals;\n setup.applyGlobals?.(globals, globalsTarget);\n });\n break;\n case 'vars.set': {\n overrides.set(msg.name, msg.value);\n const at = lastVars?.findIndex((v) => v.name === msg.name) ?? -1;\n if (!lastVars || at < 0) break;\n const vars = lastVars.slice();\n vars[at] = { ...vars[at]!, value: resolveCssVar(document, msg.name), overridden: overrides.has(msg.name) };\n publishVars(vars);\n break;\n }\n case 'a11y.run':\n void audit(msg.id);\n break;\n }\n });\n\n return () => {\n off();\n mutations?.disconnect();\n clearTimeout(settleTimer);\n overrides.dispose();\n globalsTarget.dispose();\n root.unmount();\n wrapper.remove();\n };\n}\n\n/** Reports an import failure — there is no story to start. */\nexport function reportImportFault(channel: Channel<ToFrame, FromFrame>, error: unknown): void {\n channel.send(fault('import', error));\n}\n","import { f } from '@weasel-js/labkit/config';\nimport { Component, type ReactNode } from 'react';\nimport { flushSync } from 'react-dom';\nimport { createKitRoot } from '../../kitIcons';\nimport type { Channel } from '../../protocol/channel';\nimport type { FromFrame, Globals, ToFrame } from '../../protocol/messages';\nimport { describeSchema } from '../../protocol/schema';\nimport type { IndexRender, LoadedStory } from '../../story/types';\nimport { runAxe } from '../a11y';\nimport type { FrameSetup } from '../FrameController';\nimport { createGlobalsTarget } from '../globalsTarget';\nimport { type IndexEnv, IndexPage } from './IndexPage';\n\nexport interface StartIndexOptions {\n title: string;\n /** The package the component ships in. */\n library?: string;\n description?: string;\n /** Whether the component is a gallery. */\n gallery?: boolean;\n /** The ids of the stories tagged `gallery`. */\n galleries?: readonly string[];\n /** In file order. */\n stories: readonly LoadedStory[];\n descriptions: Readonly<Record<string, string>>;\n /** The component's own page; null for the generated one. */\n render: IndexRender | null;\n channel: Channel<ToFrame, FromFrame>;\n container: HTMLElement;\n setup?: FrameSetup;\n}\n\nconst message = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\n/** Faults the frame when the page itself throws. A single story's throw stays in its own cell. */\nclass PageBoundary extends Component<{ onError: (error: unknown) => void; children: ReactNode }, { failed: unknown }> {\n override state = { failed: null as unknown };\n\n static getDerivedStateFromError(error: unknown) {\n return { failed: error ?? new Error('Index page failed') };\n }\n\n override componentDidCatch(error: unknown): void {\n this.props.onError(error);\n }\n\n override render(): ReactNode {\n return this.state.failed ? null : this.props.children;\n }\n}\n\n/**\n * Sends `ready` for a page with no controls, then renders the component's index on `init` and follows the lab's\n * globals. Returns a stop function.\n */\nexport function startIndex(options: StartIndexOptions): () => void {\n const { channel, container, setup = {} } = options;\n const { send } = channel;\n send({ type: 'ready', schema: describeSchema(f.schema({})), layout: 'fullscreen', viewport: null });\n\n const wrapper = document.createElement('div');\n wrapper.className = 'fg-frame fg-frame--fullscreen';\n container.append(wrapper);\n const root = createKitRoot(wrapper, setup.icons);\n const globalsTarget = createGlobalsTarget(document.documentElement, ':root');\n let globals: Globals | null = null;\n let announced = false;\n\n const render = (): void => {\n if (!globals) return;\n const env: IndexEnv = {\n title: options.title,\n ...(options.library === undefined ? {} : { library: options.library }),\n ...(options.description === undefined ? {} : { description: options.description }),\n stories: options.stories,\n descriptions: options.descriptions,\n gallery: options.gallery ?? false,\n galleries: options.galleries ?? [],\n globals,\n decorators: setup.decorators ?? [],\n open: (id) => send({ type: 'open', id }),\n // A story that throws shows its error in its own cell; the rest of the page is still worth reading.\n onError: (error) => console.error(error),\n };\n root.render(\n <PageBoundary onError={(error) => send({ type: 'fault', phase: 'render', message: message(error) })}>\n <IndexPage env={env} render={options.render} />\n </PageBoundary>,\n );\n };\n\n const announce = (): void => {\n if (announced) return;\n announced = true;\n const { fonts } = document;\n if (!fonts) {\n send({ type: 'rendered' });\n return;\n }\n const afterPaint = () => requestAnimationFrame(() => send({ type: 'rendered' }));\n void fonts.ready.then(afterPaint, afterPaint);\n };\n\n const off = channel.on((msg) => {\n switch (msg.type) {\n case 'init':\n case 'globals':\n globals = msg.globals;\n setup.applyGlobals?.(globals, globalsTarget);\n flushSync(render);\n announce();\n break;\n case 'a11y.run':\n runAxe(wrapper).then(\n (report) => send({ type: 'a11y', id: msg.id, ok: true, report }),\n (error: unknown) => send({ type: 'a11y', id: msg.id, ok: false, message: message(error) }),\n );\n break;\n default:\n break;\n }\n });\n\n return () => {\n off();\n globalsTarget.dispose();\n root.unmount();\n wrapper.remove();\n };\n}\n","import { openChannel } from '../protocol/channel';\nimport { FRAME_HELLO, type FromFrame, PORT_HANDOFF, type ToFrame } from '../protocol/messages';\nimport { indexId, isIndexId } from '../story/indexPages';\nimport { TITLE_LIBRARIES } from '../story/library';\nimport { isGallery } from '../story/tags';\nimport { indexRenderOf, loadStories } from '../story/load';\nimport type { LoadedStory } from '../story/types';\nimport { type FrameSetup, reportImportFault, startFrame } from './FrameController';\nimport { startIndex } from './index/startIndex';\n\n/** Story modules by file path, each loaded on first use. */\nexport interface FrameImporters {\n [file: string]: () => Promise<Record<string, unknown>>;\n}\n\n/** One story as a frame document needs to find it, before its module is loaded. */\nexport interface FrameIndexEntry {\n id: string;\n /** The story's title as indexed, which titles the file's stories when its meta names none. */\n title: string;\n file: string;\n exportName: string;\n /** The JSDoc above the story's export, which its index page shows. */\n description?: string;\n /** The JSDoc above the file's meta, which heads the index page. */\n componentDescription?: string;\n /** The meta's `tags`. */\n tags?: readonly string[];\n}\n\n/** Inputs to `mountFrame`. `load` replaces the default module loader, `loadStories`. */\nexport interface MountFrameOptions {\n index: readonly FrameIndexEntry[];\n importers: FrameImporters;\n setup?: FrameSetup;\n load?: (mod: Record<string, unknown>, title: string, parameters?: Record<string, unknown>) => LoadedStory[];\n}\n\nexport { indexRenderOf, loadStories } from '../story/load';\n\nfunction waitForHandoff():Promise<{ port: MessagePort; id: string | null }> {\n return new Promise((resolve) => {\n const onMessage = (event: MessageEvent) => {\n const data = event.data as { type?: unknown; id?: unknown } | null;\n const port = event.ports[0];\n if (event.origin !== location.origin || event.source !== window.parent) return;\n if (typeof data !== 'object' || data === null || data.type !== PORT_HANDOFF || !port) return;\n window.removeEventListener('message', onMessage);\n resolve({ port, id: typeof data.id === 'string' ? data.id : null });\n };\n window.addEventListener('message', onMessage);\n });\n}\n\n/**\n * The frame document's entry: asks its parent for a port and shows what the handoff names, or, from a shell that\n * names nothing, what the hash does. The hash is read at once, so its module loads during the handshake.\n */\nexport async function mountFrame(options: MountFrameOptions): Promise<void> {\n const imports = new Map<string, Promise<Record<string, unknown>>>();\n const importOf = (file: string): Promise<Record<string, unknown>> => {\n let loading = imports.get(file);\n if (!loading) {\n const importer = options.importers[file];\n if (!importer) throw new Error(`No importer for ${file}`);\n loading = importer();\n imports.set(file, loading);\n }\n return loading;\n };\n /** The entries `id` shows: one story, or every story of the component an index id names. */\n const entriesOf = (id: string): FrameIndexEntry[] =>\n isIndexId(id)\n ? options.index.filter((e) => indexId(e.title) === id)\n : options.index.filter((e) => e.id === id);\n const early = location.hash.slice(1) || null;\n // Only starts the fetch; whoever awaits the import later sees its outcome.\n for (const file of new Set(early === null ? [] : entriesOf(early).map((e) => e.file))) {\n if (options.importers[file]) importOf(file).catch(() => {});\n }\n\n const handoff = waitForHandoff();\n window.parent.postMessage({ type: FRAME_HELLO }, location.origin);\n const { port, id: handed } = await handoff;\n const channel = openChannel<ToFrame, FromFrame>(port);\n const id = handed ?? early ?? '';\n const container = document.getElementById('root') ?? document.body;\n try {\n if (isIndexId(id)) {\n const entries = entriesOf(id);\n const title = entries[0]?.title;\n if (title === undefined) throw new Error(`No component with index \"${id}\"`);\n const files = [...new Set(entries.map((e) => e.file))];\n const mods = await Promise.all(files.map(importOf));\n const loaded = files.map((file, i) => ({\n file,\n stories: (options.load ?? loadStories)(mods[i] ?? {}, title, options.setup?.parameters),\n }));\n const stories = entries.flatMap(\n (e) => loaded.find((l) => l.file === e.file)?.stories.find((s) => s.exportName === e.exportName) ?? [],\n );\n for (const story of stories) await options.setup?.prepare?.(story);\n startIndex({\n title,\n ...(entries[0]?.componentDescription === undefined ? {} : { description: entries[0].componentDescription }),\n // The project's library table is the shell config's, which a frame document does not load.\n library: TITLE_LIBRARIES.of({ file: entries[0]?.file ?? '', title }),\n gallery: entries.every(isGallery),\n galleries: entries.filter(isGallery).map((e) => e.id),\n stories,\n descriptions: Object.fromEntries(entries.flatMap((e) => (e.description ? [[e.id, e.description]] : []))),\n render: mods.map(indexRenderOf).find((render) => render !== null) ?? null,\n channel,\n container,\n ...(options.setup ? { setup: options.setup } : {}),\n });\n return;\n }\n const entry = options.index.find((e) => e.id === id);\n if (!entry) throw new Error(`No story with id \"${id}\"`);\n const mod = await importOf(entry.file);\n const stories = (options.load ?? loadStories)(mod, entry.title, options.setup?.parameters);\n const story = stories.find((s) => s.exportName === entry.exportName);\n if (!story) throw new Error(`${entry.file} has no story export \"${entry.exportName}\"`);\n await options.setup?.prepare?.(story);\n startFrame({ story, channel, container, setup: options.setup });\n } catch (error) {\n reportImportFault(channel, error);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/frame/FrameController.tsx","../../src/frame/index/startIndex.tsx","../../src/frame/mountFrame.tsx","../../src/frame/capture/CaptureView.tsx","../../src/frame/capture/mountCapture.tsx"],"names":["jsx","flushSync","id","stories","story","Component"],"mappings":";;;;;;;;;;;;;;;;AAmDA,IAAM,cAAA,GAAiB,GAAA;AAEvB,SAAS,KAAA,CAAM,KAAA,EAAmB,KAAA,EAAgB,GAAA,EAAyB;AACzE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,KAAA;AAAA,IACA,SAAS,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AAAA,IAC9D,GAAI,KAAA,YAAiB,KAAA,IAAS,KAAA,CAAM,KAAA,GAAQ,EAAE,KAAA,EAAO,KAAA,CAAM,KAAA,EAAM,GAAI,EAAC;AAAA,IACtE,GAAI,GAAA,KAAQ,MAAA,GAAY,EAAC,GAAI,EAAE,GAAA;AAAI,GACrC;AACF;AAGO,SAAS,UAAA,CAAW,EAAE,KAAA,EAAO,OAAA,EAAS,WAAW,KAAA,GAAQ,IAAG,EAAkC;AACnG,EAAA,MAAM,EAAE,MAAK,GAAI,OAAA;AACjB,EAAA,IAAA,CAAK,EAAE,IAAA,EAAM,OAAA,EAAS,MAAA,EAAQ,eAAe,KAAA,CAAM,MAAM,CAAA,EAAG,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAQ,QAAA,EAAU,KAAA,CAAM,UAAU,CAAA;AAE5G,EAAA,MAAM,OAAA,GAAU,QAAA,CAAS,aAAA,CAAc,KAAK,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AK,CAAA;AACzC,MAAA,OAAA,IAAW,CAAA;AACX,MAAA,MAAM,IAAI,OAAA,CAAc,CAAC,OAAA,EAAS,MAAA,KAAW;AAE3C,QAAA,IAAA,CAAK,MAAA;AAAA,0BACHL,GAAAA,CAAC,eAAA,EAAA,EAA8B,OAAA,EAAS,QACtC,QAAA,kBAAAA,GAAAA,CAAC,WAAA,EAAA,EAAY,KAAA,EAAc,SAAkB,KAAA,EAAc,QAAA,EAAoB,UAAA,EAAY,OAAA,EAAS,KADhF,OAEtB;AAAA,SACF;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import { flushSync } from 'react-dom';\nimport type { IconTable } from '@weasel-js/icons';\nimport { createKitRoot } from '../kitIcons';\nimport type { Channel } from '../protocol/channel';\nimport {\n type CssVarReport,\n type FaultPhase,\n type FromFrame,\n type Globals,\n stableStringify,\n type ToFrame,\n} from '../protocol/messages';\nimport { answerSchema, describeSchema } from '../protocol/schema';\nimport type { Decorator, LoadedStory, StoryContext } from '../story/types';\nimport { auditElement } from './a11y';\nimport { createA11yHighlighter } from './a11yHighlight';\nimport { createOverrides, resolveCssVar, scanCssVars } from './cssVars';\nimport { createGlobalsTarget, type GlobalsTarget } from './globalsTarget';\nimport { StoryHost } from './StoryHost';\n\n/** The frame config: what `defineFrameConfig` returns and the `frameConfig` module default-exports. */\nexport interface FrameSetup {\n /** Wraps every story, outermost; receives the globals. From the frame config (`frameConfig`). */\n decorators?: Decorator[];\n /** Applies globals to a target: theme mode, fonts. The target is a frame document's root, or one story's host in\n * the workshop document, so a rule the setup writes goes through `target.style` under `target.scope`. */\n applyGlobals?: (globals: Globals, target: GlobalsTarget) => void;\n /**\n * The elements a CSS variable override is declared on; `:root` by default. An override has to be declared on\n * whichever element declares the token itself — a theme wrapper, say — or that element's own value wins.\n */\n cssVarsScope?: string;\n /** Project-wide CSF parameters, Storybook's preview `parameters`: under each meta's and story's. */\n parameters?: Record<string, unknown>;\n /**\n * Awaited once a story is loaded and before it first renders — the place to import what only some stories\n * need, so the rest never load it.\n */\n prepare?: (story: LoadedStory) => void | Promise<void>;\n /** Icon tables registered beside the kit's in every frame: an app's own, for its stories' glyphs. */\n icons?: readonly IconTable[];\n}\n\n/** Inputs to `startFrame`: the story, the channel to the shell, and the element to render into. */\nexport interface StartFrameOptions {\n story: LoadedStory;\n channel: Channel<ToFrame, FromFrame>;\n container: HTMLElement;\n setup?: FrameSetup;\n}\n\nconst VARS_SETTLE_MS = 100;\n\nfunction fault(phase: FaultPhase, error: unknown, seq?: number): FromFrame {\n return {\n type: 'fault',\n phase,\n message: error instanceof Error ? error.message : String(error),\n ...(error instanceof Error && error.stack ? { stack: error.stack } : {}),\n ...(seq === undefined ? {} : { seq }),\n };\n}\n\n/** Sends `ready`, then renders the story on `init` and keeps it in step. Returns a stop function. */\nexport function startFrame({ story, channel, container, setup = {} }: StartFrameOptions): () => void {\n const { send } = channel;\n send({ type: 'ready', schema: describeSchema(story.config), layout: story.layout, viewport: story.viewport });\n\n const wrapper = document.createElement('div');\n wrapper.className = `fg-frame fg-frame--${story.layout}`;\n container.append(wrapper);\n const root = createKitRoot(wrapper, setup.icons);\n const decorators = setup.decorators ?? [];\n\n let initialized = false;\n let rendered = false;\n let config: unknown;\n let state: unknown = null;\n let globals: Globals = {};\n let answeredKey: string | null = null;\n let resetKey = 0;\n let seq = 0;\n\n const overrides = createOverrides(document, setup.cssVarsScope);\n const globalsTarget = createGlobalsTarget(document.documentElement, ':root');\n const highlighter = createA11yHighlighter(document);\n let lastVars: CssVarReport[] | null = null;\n let reported: string | null = null;\n const publishVars = (vars: CssVarReport[]) => {\n lastVars = vars;\n const key = JSON.stringify(vars);\n if (key === reported) return;\n reported = key;\n send({ type: 'vars', vars });\n };\n const reportVars = () => publishVars(scanCssVars(document, overrides.has));\n const ownMutation = (record: MutationRecord) =>\n overrides.owns(record.target) ||\n (record.type === 'childList' &&\n [...record.addedNodes, ...record.removedNodes].length > 0 &&\n [...record.addedNodes, ...record.removedNodes].every(overrides.owns));\n let settleTimer: ReturnType<typeof setTimeout> | undefined;\n const mutations =\n typeof MutationObserver === 'undefined'\n ? null\n : new MutationObserver((records) => {\n if (records.every(ownMutation)) return;\n clearTimeout(settleTimer);\n settleTimer = setTimeout(reportVars, VARS_SETTLE_MS);\n });\n // Every attribute, not just style and class: a stylesheet can select on any of them, `[data-wzl-mode]` included.\n mutations?.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });\n\n const setConfig = (path: string, value: unknown) => send({ type: 'setConfig', path, value });\n const setState = (next: unknown) => {\n state = typeof next === 'function' ? (next as (prev: unknown) => unknown)(state) : next;\n send({ type: 'setState', state });\n render();\n };\n\n const render = () => {\n const ctx: StoryContext = { config, setConfig, state, setState, globals, title: story.title, name: story.name };\n const at = seq;\n root.render(\n <StoryHost\n story={story}\n ctx={ctx}\n decorators={decorators}\n resetKey={resetKey}\n onError={(error) => send(fault('render', error, at))}\n />,\n );\n const key = stableStringify(config);\n if (key !== answeredKey) {\n answeredKey = key;\n send({ type: 'answers', answers: { configKey: key, ...answerSchema(story.config, config) } });\n }\n };\n\n // Input from the trial commits synchronously, so `rendered` and the vars report describe the story it produced. A\n // throw while applying it faults like a render would; otherwise the trial would wait on a frame that never answers.\n const input = (apply: () => void) => {\n seq += 1;\n try {\n apply();\n if (!initialized) return;\n resetKey += 1;\n flushSync(render);\n } catch (error) {\n send(fault('render', error, seq));\n return;\n }\n if (!rendered) {\n rendered = true;\n announceRendered();\n }\n reportVars();\n };\n\n /**\n * The shell unhides the frame on `rendered` and fades it in, so a webfont\n * swapping in after that message reads as the story gliding. Waiting for the\n * fonts and then one painted frame means the story the shell reveals is the\n * settled one.\n *\n * `document.fonts` is absent in jsdom, so the message stays synchronous\n * there; the deferral is only exercised in a browser.\n */\n const announceRendered = () => {\n const { fonts } = document;\n if (!fonts) {\n send({ type: 'rendered' });\n return;\n }\n const afterPaint = () => requestAnimationFrame(() => send({ type: 'rendered' }));\n void fonts.ready.then(afterPaint, afterPaint);\n };\n\n const audit = async (id: string) => send({ type: 'a11y', id, ...(await auditElement(wrapper)) });\n\n const off = channel.on((msg) => {\n switch (msg.type) {\n case 'init':\n input(() => {\n initialized = true;\n config = msg.config;\n globals = msg.globals;\n state = msg.state;\n if (state === null && story.initialState) {\n state = story.initialState(config);\n send({ type: 'setState', state });\n }\n setup.applyGlobals?.(globals, globalsTarget);\n });\n break;\n case 'config':\n input(() => {\n config = msg.config;\n });\n break;\n case 'state':\n input(() => {\n state = msg.state;\n });\n break;\n case 'globals':\n input(() => {\n globals = msg.globals;\n setup.applyGlobals?.(globals, globalsTarget);\n });\n break;\n case 'vars.set': {\n overrides.set(msg.name, msg.value);\n const at = lastVars?.findIndex((v) => v.name === msg.name) ?? -1;\n if (!lastVars || at < 0) break;\n const vars = lastVars.slice();\n vars[at] = { ...vars[at]!, value: resolveCssVar(document, msg.name), overridden: overrides.has(msg.name) };\n publishVars(vars);\n break;\n }\n case 'a11y.run':\n void audit(msg.id);\n break;\n case 'a11y.highlight':\n highlighter.show(msg.targets);\n break;\n }\n });\n\n return () => {\n off();\n mutations?.disconnect();\n clearTimeout(settleTimer);\n overrides.dispose();\n globalsTarget.dispose();\n highlighter.dispose();\n root.unmount();\n wrapper.remove();\n };\n}\n\n/** Reports an import failure — there is no story to start. */\nexport function reportImportFault(channel: Channel<ToFrame, FromFrame>, error: unknown): void {\n channel.send(fault('import', error));\n}\n","import { f } from '@weasel-js/labkit/config';\nimport { Component, type ReactNode } from 'react';\nimport { flushSync } from 'react-dom';\nimport { createKitRoot } from '../../kitIcons';\nimport type { Channel } from '../../protocol/channel';\nimport type { FromFrame, Globals, ToFrame } from '../../protocol/messages';\nimport { describeSchema } from '../../protocol/schema';\nimport type { IndexRender, LoadedStory } from '../../story/types';\nimport { runAxe } from '../a11y';\nimport type { FrameSetup } from '../FrameController';\nimport { createGlobalsTarget } from '../globalsTarget';\nimport { type IndexEnv, IndexPage } from './IndexPage';\n\nexport interface StartIndexOptions {\n title: string;\n /** The package the component ships in. */\n library?: string;\n description?: string;\n /** Whether the component is a gallery. */\n gallery?: boolean;\n /** The ids of the stories tagged `gallery`. */\n galleries?: readonly string[];\n /** In file order. */\n stories: readonly LoadedStory[];\n descriptions: Readonly<Record<string, string>>;\n /** The component's own page; null for the generated one. */\n render: IndexRender | null;\n channel: Channel<ToFrame, FromFrame>;\n container: HTMLElement;\n setup?: FrameSetup;\n}\n\nconst message = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\n/** Faults the frame when the page itself throws. A single story's throw stays in its own cell. */\nclass PageBoundary extends Component<{ onError: (error: unknown) => void; children: ReactNode }, { failed: unknown }> {\n override state = { failed: null as unknown };\n\n static getDerivedStateFromError(error: unknown) {\n return { failed: error ?? new Error('Index page failed') };\n }\n\n override componentDidCatch(error: unknown): void {\n this.props.onError(error);\n }\n\n override render(): ReactNode {\n return this.state.failed ? null : this.props.children;\n }\n}\n\n/**\n * Sends `ready` for a page with no controls, then renders the component's index on `init` and follows the lab's\n * globals. Returns a stop function.\n */\nexport function startIndex(options: StartIndexOptions): () => void {\n const { channel, container, setup = {} } = options;\n const { send } = channel;\n send({ type: 'ready', schema: describeSchema(f.schema({})), layout: 'fullscreen', viewport: null });\n\n const wrapper = document.createElement('div');\n wrapper.className = 'fg-frame fg-frame--fullscreen';\n container.append(wrapper);\n const root = createKitRoot(wrapper, setup.icons);\n const globalsTarget = createGlobalsTarget(document.documentElement, ':root');\n let globals: Globals | null = null;\n let announced = false;\n\n const render = (): void => {\n if (!globals) return;\n const env: IndexEnv = {\n title: options.title,\n ...(options.library === undefined ? {} : { library: options.library }),\n ...(options.description === undefined ? {} : { description: options.description }),\n stories: options.stories,\n descriptions: options.descriptions,\n gallery: options.gallery ?? false,\n galleries: options.galleries ?? [],\n globals,\n decorators: setup.decorators ?? [],\n open: (id) => send({ type: 'open', id }),\n // A story that throws shows its error in its own cell; the rest of the page is still worth reading.\n onError: (error) => console.error(error),\n };\n root.render(\n <PageBoundary onError={(error) => send({ type: 'fault', phase: 'render', message: message(error) })}>\n <IndexPage env={env} render={options.render} />\n </PageBoundary>,\n );\n };\n\n const announce = (): void => {\n if (announced) return;\n announced = true;\n const { fonts } = document;\n if (!fonts) {\n send({ type: 'rendered' });\n return;\n }\n const afterPaint = () => requestAnimationFrame(() => send({ type: 'rendered' }));\n void fonts.ready.then(afterPaint, afterPaint);\n };\n\n const off = channel.on((msg) => {\n switch (msg.type) {\n case 'init':\n case 'globals':\n globals = msg.globals;\n setup.applyGlobals?.(globals, globalsTarget);\n flushSync(render);\n announce();\n break;\n case 'a11y.run':\n runAxe(wrapper).then(\n (report) => send({ type: 'a11y', id: msg.id, ok: true, report }),\n (error: unknown) => send({ type: 'a11y', id: msg.id, ok: false, message: message(error) }),\n );\n break;\n default:\n break;\n }\n });\n\n return () => {\n off();\n globalsTarget.dispose();\n root.unmount();\n wrapper.remove();\n };\n}\n","import { openChannel } from '../protocol/channel';\nimport { FRAME_HELLO, type FromFrame, PORT_HANDOFF, type ToFrame } from '../protocol/messages';\nimport { indexId, isIndexId } from '../story/indexPages';\nimport { TITLE_LIBRARIES } from '../story/library';\nimport { isGallery } from '../story/tags';\nimport { indexRenderOf, loadStories } from '../story/load';\nimport type { LoadedStory } from '../story/types';\nimport { type FrameSetup, reportImportFault, startFrame } from './FrameController';\nimport { startIndex } from './index/startIndex';\n\n/** Story modules by file path, each loaded on first use. */\nexport interface FrameImporters {\n [file: string]: () => Promise<Record<string, unknown>>;\n}\n\n/** One story as a frame document needs to find it, before its module is loaded. */\nexport interface FrameIndexEntry {\n id: string;\n /** The story's title as indexed, which titles the file's stories when its meta names none. */\n title: string;\n file: string;\n exportName: string;\n /** The JSDoc above the story's export, which its index page shows. */\n description?: string;\n /** The JSDoc above the file's meta, which heads the index page. */\n componentDescription?: string;\n /** The meta's `tags`. */\n tags?: readonly string[];\n}\n\n/** Inputs to `mountFrame`. `load` replaces the default module loader, `loadStories`. */\nexport interface MountFrameOptions {\n index: readonly FrameIndexEntry[];\n importers: FrameImporters;\n setup?: FrameSetup;\n load?: (mod: Record<string, unknown>, title: string, parameters?: Record<string, unknown>) => LoadedStory[];\n}\n\nexport { indexRenderOf, loadStories } from '../story/load';\n\nfunction waitForHandoff():Promise<{ port: MessagePort; id: string | null }> {\n return new Promise((resolve) => {\n const onMessage = (event: MessageEvent) => {\n const data = event.data as { type?: unknown; id?: unknown } | null;\n const port = event.ports[0];\n if (event.origin !== location.origin || event.source !== window.parent) return;\n if (typeof data !== 'object' || data === null || data.type !== PORT_HANDOFF || !port) return;\n window.removeEventListener('message', onMessage);\n resolve({ port, id: typeof data.id === 'string' ? data.id : null });\n };\n window.addEventListener('message', onMessage);\n });\n}\n\n/**\n * The frame document's entry: asks its parent for a port and shows what the handoff names, or, from a shell that\n * names nothing, what the hash does. The hash is read at once, so its module loads during the handshake.\n */\nexport async function mountFrame(options: MountFrameOptions): Promise<void> {\n const imports = new Map<string, Promise<Record<string, unknown>>>();\n const importOf = (file: string): Promise<Record<string, unknown>> => {\n let loading = imports.get(file);\n if (!loading) {\n const importer = options.importers[file];\n if (!importer) throw new Error(`No importer for ${file}`);\n loading = importer();\n imports.set(file, loading);\n }\n return loading;\n };\n /** The entries `id` shows: one story, or every story of the component an index id names. */\n const entriesOf = (id: string): FrameIndexEntry[] =>\n isIndexId(id)\n ? options.index.filter((e) => indexId(e.title) === id)\n : options.index.filter((e) => e.id === id);\n const early = location.hash.slice(1) || null;\n // Only starts the fetch; whoever awaits the import later sees its outcome.\n for (const file of new Set(early === null ? [] : entriesOf(early).map((e) => e.file))) {\n if (options.importers[file]) importOf(file).catch(() => {});\n }\n\n const handoff = waitForHandoff();\n window.parent.postMessage({ type: FRAME_HELLO }, location.origin);\n const { port, id: handed } = await handoff;\n const channel = openChannel<ToFrame, FromFrame>(port);\n const id = handed ?? early ?? '';\n const container = document.getElementById('root') ?? document.body;\n try {\n if (isIndexId(id)) {\n const entries = entriesOf(id);\n const title = entries[0]?.title;\n if (title === undefined) throw new Error(`No component with index \"${id}\"`);\n const files = [...new Set(entries.map((e) => e.file))];\n const mods = await Promise.all(files.map(importOf));\n const loaded = files.map((file, i) => ({\n file,\n stories: (options.load ?? loadStories)(mods[i] ?? {}, title, options.setup?.parameters),\n }));\n const stories = entries.flatMap(\n (e) => loaded.find((l) => l.file === e.file)?.stories.find((s) => s.exportName === e.exportName) ?? [],\n );\n for (const story of stories) await options.setup?.prepare?.(story);\n startIndex({\n title,\n ...(entries[0]?.componentDescription === undefined ? {} : { description: entries[0].componentDescription }),\n // The project's library table is the shell config's, which a frame document does not load.\n library: TITLE_LIBRARIES.of({ file: entries[0]?.file ?? '', title }),\n gallery: entries.every(isGallery),\n galleries: entries.filter(isGallery).map((e) => e.id),\n stories,\n descriptions: Object.fromEntries(entries.flatMap((e) => (e.description ? [[e.id, e.description]] : []))),\n render: mods.map(indexRenderOf).find((render) => render !== null) ?? null,\n channel,\n container,\n ...(options.setup ? { setup: options.setup } : {}),\n });\n return;\n }\n const entry = options.index.find((e) => e.id === id);\n if (!entry) throw new Error(`No story with id \"${id}\"`);\n const mod = await importOf(entry.file);\n const stories = (options.load ?? loadStories)(mod, entry.title, options.setup?.parameters);\n const story = stories.find((s) => s.exportName === entry.exportName);\n if (!story) throw new Error(`${entry.file} has no story export \"${entry.exportName}\"`);\n await options.setup?.prepare?.(story);\n startFrame({ story, channel, container, setup: options.setup });\n } catch (error) {\n reportImportFault(channel, error);\n }\n}\n","import './capture.css';\nimport { useLatest, useVisibleRaf } from '@weasel-js/core';\nimport { interstellarTheme, LabRoot } from '@weasel-js/labkit';\nimport type { Theme } from '@weasel-js/theme';\nimport { ThemeProvider } from '@weasel-js/theme/react';\nimport { OverlayPortalProvider } from '@weasel-js/ui/portal-host';\nimport { type CSSProperties, type ReactNode, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { useHostConditions } from '../../shell/hostConditions';\nimport { LAB_DENSITY } from '../../shell/labDensity';\nimport type { Globals } from '../../protocol/messages';\nimport type { LoadedStory, StoryContext } from '../../story/types';\nimport { ClockContext } from '../../timeline/context';\nimport { useStoryClock } from '../../timeline/StoryClock';\nimport type { CapturePayload } from '../../vite/capture/payload';\nimport type { FrameSetup } from '../FrameController';\nimport { StoryHost } from '../StoryHost';\n\n/** Props for `CaptureView`. */\nexport interface CaptureViewProps {\n story: LoadedStory;\n payload: CapturePayload;\n setup: FrameSetup;\n /** The shell config's `labTheme`, which the workshop's lab is themed by. */\n labTheme?: ((globals: Globals) => Theme) | undefined;\n /** Called once the story has painted with its fonts, so a screenshot taken then shows it settled. */\n onRendered: () => void;\n}\n\nconst HOST_ID = 'capture';\nconst NO_WRITE = () => {};\n\n/** Sizes the box through custom properties, which capture.css reads. */\nconst boxStyle = ({ width, height }: CapturePayload['box']): CSSProperties =>\n ({ ['--fg-capture-w' as string]: `${width}px`, ['--fg-capture-h' as string]: `${height}px` }) as CSSProperties;\n\n/** Scrolls the story's scroller to where the screen's stood; a story still growing is scrolled again before the shot. */\nfunction scrollTo(host: HTMLElement | null, { left, top }: CapturePayload['scroll']) {\n const scroller = host?.querySelector<HTMLElement>(':scope > .fg-story__scroll');\n if (!scroller) return;\n scroller.scrollLeft = left;\n scroller.scrollTop = top;\n}\n\n/**\n * One story rendered from a capture payload, still: its clock stands at the payload's playhead and nothing plays\n * it, and nothing it writes to its config or state goes anywhere. A story that would be in the workshop document\n * sits under a lab root themed as the lab is, as it does there; an isolated one sits in the frame document's own\n * wrapper.\n */\nexport function CaptureView({ story, payload, setup, labTheme, onRendered }: CaptureViewProps) {\n const [host, setHost] = useState<HTMLDivElement | null>(null);\n useHostConditions(host, { hostId: HOST_ID, globals: payload.globals, overrides: payload.overrides, setup });\n\n const spec = useMemo(() => story.timeline?.(payload.config) ?? null, [story, payload.config]);\n const clock = useStoryClock(spec, () => payload.playhead);\n\n const state = useMemo(\n () => (payload.state === null && story.initialState ? story.initialState(payload.config) : payload.state),\n [payload.state, payload.config, story],\n );\n const ctx: StoryContext = {\n config: payload.config,\n setConfig: NO_WRITE,\n state,\n setState: NO_WRITE,\n globals: payload.globals,\n title: story.title,\n name: story.name,\n };\n\n const latest = useLatest({ onRendered, host, scroll: payload.scroll });\n useLayoutEffect(() => scrollTo(host, payload.scroll), [host, payload.scroll]);\n const ticks = useRef(0);\n // A capture page is never looked at, and a headless page can count as hidden.\n const raf = useVisibleRaf(\n (_now, loop) => {\n ticks.current += 1;\n scrollTo(latest.current.host, latest.current.scroll);\n if (ticks.current < 2) loop.request();\n else latest.current.onRendered();\n },\n { dangerouslyRunWhenHidden: true },\n );\n useEffect(() => {\n if (!host) return;\n let canceled = false;\n const start = () => {\n if (!canceled) raf.request();\n };\n const { fonts } = host.ownerDocument;\n if (fonts) void fonts.ready.then(start, start);\n else start();\n return () => {\n canceled = true;\n raf.cancel();\n };\n }, [host, raf]);\n\n const content: ReactNode = host ? (\n <ClockContext.Provider value={clock}>\n <StoryHost story={story} ctx={ctx} decorators={setup.decorators ?? []} resetKey={0} onError={NO_WRITE} />\n </ClockContext.Provider>\n ) : null;\n\n const box = (\n <div\n ref={setHost}\n className=\"fg-story\"\n data-fg-host={HOST_ID}\n data-fg-capture=\"\"\n data-fg-layout={payload.layout}\n style={boxStyle(payload.box)}\n >\n {payload.isolate ? (\n <div className={`fg-frame fg-frame--${payload.layout}`}>{content}</div>\n ) : (\n <div className=\"fg-story__scroll\">\n {host ? (\n <OverlayPortalProvider container={host} contained>\n {content}\n </OverlayPortalProvider>\n ) : null}\n </div>\n )}\n </div>\n );\n if (payload.isolate) return box;\n return (\n <ThemeProvider\n theme={labTheme?.(payload.lab.globals) ?? interstellarTheme}\n selection={{ mode: payload.lab.mode, density: LAB_DENSITY }}\n >\n <LabRoot>{box}</LabRoot>\n </ThemeProvider>\n );\n}\n","import type { Theme } from '@weasel-js/theme';\nimport { Component, type ReactNode } from 'react';\nimport { createKitRoot } from '../../kitIcons';\nimport type { Globals } from '../../protocol/messages';\nimport { loadStories } from '../../story/load';\nimport type { IndexEntry, LoadedStory } from '../../story/types';\nimport type { CapturePayload } from '../../vite/capture/payload';\nimport type { FrameSetup } from '../FrameController';\nimport type { FrameImporters } from '../mountFrame';\nimport { CaptureView } from './CaptureView';\n\n/** Inputs to `mountCapture`, as a capture page's entry module passes them. */\nexport interface MountCaptureOptions {\n index: readonly IndexEntry[];\n importers: FrameImporters;\n setup: FrameSetup;\n /** The shell config's `labTheme`; only the shell's capture page has one. */\n labTheme?: ((globals: Globals) => Theme) | undefined;\n}\n\ndeclare global {\n interface Window {\n /** Set by `mountCapture`: renders one payload and resolves once it has painted. */\n __forgeCapture?: { render(payload: CapturePayload): Promise<void> };\n }\n}\n\n/** Catches what throws outside the story's own boundary, which would otherwise unmount the root and leave the\n * render waiting forever. */\nclass CaptureBoundary extends Component<{ onError: (error: unknown) => void; children: ReactNode }, { failed: boolean }> {\n override state = { failed: false };\n\n static getDerivedStateFromError(): { failed: boolean } {\n return { failed: true };\n }\n\n override componentDidCatch(error: unknown): void {\n this.props.onError(error);\n }\n\n override render(): ReactNode {\n return this.state.failed ? null : this.props.children;\n }\n}\n\n/**\n * A capture page's entry: exposes `window.__forgeCapture.render(payload)`, which loads the payload's story, renders\n * it afresh into `#root`, and resolves once it has painted. Rejects for a story the index does not hold, and with\n * whatever throws outside the story's own error boundary.\n */\nexport function mountCapture({ index, importers, setup, labTheme }: MountCaptureOptions): void {\n const container = document.getElementById('root') ?? document.body;\n const root = createKitRoot(container, setup.icons);\n const prepared = new Map<string, Promise<LoadedStory>>();\n let renders = 0;\n\n const storyOf = (id: string): Promise<LoadedStory> => {\n let loading = prepared.get(id);\n if (!loading) {\n loading = (async () => {\n const entry = index.find((e) => e.id === id);\n if (!entry) throw new Error(`No story with id \"${id}\"`);\n const importer = importers[entry.file];\n if (!importer) throw new Error(`No importer for ${entry.file}`);\n const story = loadStories(await importer(), entry.title, setup.parameters).find((s) => s.exportName === entry.exportName);\n if (!story) throw new Error(`${entry.file} has no story export \"${entry.exportName}\"`);\n await setup.prepare?.(story);\n return story;\n })();\n prepared.set(id, loading);\n loading.catch(() => prepared.delete(id));\n }\n return loading;\n };\n\n window.__forgeCapture = {\n async render(payload) {\n const story = await storyOf(payload.story);\n renders += 1;\n await new Promise<void>((resolve, reject) => {\n // Keyed per render, so a payload never inherits the last one's clock or state.\n root.render(\n <CaptureBoundary key={renders} onError={reject}>\n <CaptureView story={story} payload={payload} setup={setup} labTheme={labTheme} onRendered={resolve} />\n </CaptureBoundary>,\n );\n });\n },\n };\n}\n"]}
|