@weasel-js/forge 1.13.0-rc.0 → 1.14.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 +1 -1
- package/dist/{FrameController-Tv3jrHyT.d.ts → FrameController-BM6xuEfY.d.ts} +18 -10
- package/dist/{chunk-KEQBGDUZ.js → chunk-B26DWEYT.js} +3 -3
- package/dist/{chunk-KEQBGDUZ.js.map → chunk-B26DWEYT.js.map} +1 -1
- package/dist/{chunk-3BAM6M26.js → chunk-FPF2JSWB.js} +3 -3
- package/dist/chunk-FPF2JSWB.js.map +1 -0
- package/dist/{chunk-ORMMZ5PV.js → chunk-MRYXJTDO.js} +7 -3
- package/dist/chunk-MRYXJTDO.js.map +1 -0
- package/dist/{chunk-35DOPXHZ.js → chunk-PGLOYXDP.js} +193 -190
- package/dist/chunk-PGLOYXDP.js.map +1 -0
- package/dist/{chunk-BUXUWAI4.js → chunk-PPB7VP6R.js} +62 -8
- package/dist/chunk-PPB7VP6R.js.map +1 -0
- package/dist/{chunk-STF6NQ5N.js → chunk-RVJHUY7W.js} +2 -2
- package/dist/chunk-RVJHUY7W.js.map +1 -0
- package/dist/{chunk-LTTEILXY.js → chunk-SFKDHXVE.js} +26 -4
- package/dist/chunk-SFKDHXVE.js.map +1 -0
- package/dist/chunk-STK2AZH2.js +11 -0
- package/dist/chunk-STK2AZH2.js.map +1 -0
- package/dist/chunk-TT4ZOYB6.js +143 -0
- package/dist/chunk-TT4ZOYB6.js.map +1 -0
- package/dist/{chunk-RKQ277P5.js → chunk-UDEUT7AG.js} +125 -80
- package/dist/chunk-UDEUT7AG.js.map +1 -0
- package/dist/{config-Bd6FVlh7.d.ts → config-DOjWyIui.d.ts} +3 -21
- package/dist/csf/preview-api.js +2 -2
- package/dist/frame/index.css +0 -2
- package/dist/frame/index.css.map +1 -1
- package/dist/frame/index.d.ts +14 -8
- package/dist/frame/index.js +114 -79
- package/dist/frame/index.js.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.js +4 -4
- package/dist/library-CdTj-hFp.d.ts +21 -0
- package/dist/{mountFrame-FdJDb3TB.d.ts → mountFrame-CRPAjg1M.d.ts} +1 -1
- package/dist/shell/index.css +166 -150
- package/dist/shell/index.css.map +1 -1
- package/dist/shell/index.d.ts +24 -5
- package/dist/shell/index.js +594 -402
- package/dist/shell/index.js.map +1 -1
- package/dist/test/index.css +2 -3
- package/dist/test/index.css.map +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.js +8 -10
- package/dist/test/index.js.map +1 -1
- package/dist/vite/index.js +127 -32
- package/dist/vite/index.js.map +1 -1
- package/package.json +11 -9
- package/dist/chunk-35DOPXHZ.js.map +0 -1
- package/dist/chunk-3BAM6M26.js.map +0 -1
- package/dist/chunk-BUXUWAI4.js.map +0 -1
- package/dist/chunk-GH5RE5X5.js +0 -10
- package/dist/chunk-GH5RE5X5.js.map +0 -1
- package/dist/chunk-L5XM5VKB.js +0 -47
- package/dist/chunk-L5XM5VKB.js.map +0 -1
- package/dist/chunk-LTTEILXY.js.map +0 -1
- package/dist/chunk-ORMMZ5PV.js.map +0 -1
- package/dist/chunk-RKQ277P5.js.map +0 -1
- package/dist/chunk-STF6NQ5N.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shell/trialFrames.ts","../src/shell/StoryGlobalsContext.ts","../src/shell/inViewMargin.ts","../src/shell/cssVars/overrides.ts","../src/shell/StoryScroller.tsx","../src/shell/storyHosts.ts","../src/shell/storyShow.ts","../src/shell/TrialHost.tsx","../src/shell/StoryBody.tsx","../src/shell/loupe/conditions.ts","../src/shell/loupe/liveLenses.ts","../src/shell/loupe/trialAt.ts","../src/shell/loupe/LiveCopies.tsx","../src/shell/StoryTrial.tsx"],"names":["createContext","useContext","useLayoutEffect","useState","useCallback","jsx","useEffect","StoryBody","NONE","useMemo","useSyncExternalStore","useLatest","useRef","TrialIdContext","jsxs","Fragment"],"mappings":";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EAAW,GAAG,IAAA,EAAM,SAAkB,CAAA,EACzC,CAAA;AAGF,EAAA,uBACES,IAAAA,CAAAC,QAAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAAV,GAAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QACC,QAAQ,KAAA,CAAM,MAAA;AAAA,QACd,KAAA;AAAA,QACA,QAAQ,GAAA,CAAI,MAAA;AAAA,QACZ,OAAA,EAAS,IAAA;AAAA,QACR,GAAI,UAAA,GAAa,EAAE,UAAA,KAAe,EAAC;AAAA,QAEnC,QAAA,EAAA;AAAA;AAAA,KACH;AAAA,oBACAA,IAAC,UAAA,EAAA,EAAW,OAAA,EAAkB,QAAQ,KAAA,CAAM,MAAA,EAAQ,OAAc,WAAA,EAAa,GAAA,CAAI,QAChF,QAAA,EAAA,CAAC,OAAA,EAAS,yBAASA,GAAAA,CAAC,aAAU,IAAA,EAAY,KAAA,EAAc,OAAA,EAAkB,IAAA,EAAY,CAAA,EACzF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-UDEUT7AG.js","sourcesContent":["import { createEmitter } from '@weasel-js/registry';\nimport { createContext, useCallback, useContext, useSyncExternalStore } from 'react';\nimport type { A11yOutcome, CssVarReport, ToFrame } from '../protocol/messages';\n\nexport type { A11yOutcome };\n\n/** The half of a trial's frame that answers a request: each call is one round trip over the frame's channel. */\nexport interface TrialFrameCalls {\n send: (msg: ToFrame) => void;\n audit: () => Promise<A11yOutcome>;\n}\n\n/** What trial chrome can reach of the frame its trial shows. */\nexport interface TrialFrame {\n /** Null while no frame is connected. */\n send: ((msg: ToFrame) => void) | null;\n /** The frame's latest `vars` report. */\n vars: readonly CssVarReport[];\n /** Runs axe over the story and records the answer as `a11y`. Null while no frame is connected. */\n audit: (() => Promise<A11yOutcome>) | null;\n /** What the last audit found; null until one has run against the connected frame. */\n a11y: A11yOutcome | null;\n}\n\n/** Each trial's frame, keyed by trial id: `FrameView` connects and reports, trial chrome reads. */\nexport interface TrialFrames {\n /** Returns a disconnect that does nothing once a newer connection replaced this one. */\n connect(trialId: string, calls: TrialFrameCalls): () => void;\n report(trialId: string, vars: readonly CssVarReport[]): void;\n reportA11y(trialId: string, outcome: A11yOutcome): void;\n get(trialId: string): TrialFrame;\n subscribe(listener: () => void): () => void;\n}\n\nconst NO_FRAME: TrialFrame = { send: null, vars: [], audit: null, a11y: null };\n\nexport function createTrialFrames(): TrialFrames {\n const frames = new Map<string, TrialFrame>();\n const changes = createEmitter();\n const changed = changes.emit;\n const patch = (trialId: string, next: Partial<TrialFrame>) => {\n const frame = frames.get(trialId);\n if (!frame) return;\n frames.set(trialId, { ...frame, ...next });\n changed();\n };\n return {\n connect(trialId, calls) {\n frames.set(trialId, { send: calls.send, vars: [], audit: calls.audit, a11y: null });\n changed();\n return () => {\n if (frames.get(trialId)?.send !== calls.send) return;\n frames.delete(trialId);\n changed();\n };\n },\n report: (trialId, vars) => patch(trialId, { vars }),\n reportA11y: (trialId, a11y) => patch(trialId, { a11y }),\n get: (trialId) => frames.get(trialId) ?? NO_FRAME,\n subscribe: changes.subscribe,\n };\n}\n\n/** The workshop's `TrialFrames`; `null` outside a `Workshop`. */\nexport const TrialFramesContext = createContext<TrialFrames | null>(null);\n\n/** The frame of the trial `trialId` names, re-read when it connects or reports. */\nexport function useTrialFrame(trialId: string): TrialFrame {\n const frames = useContext(TrialFramesContext);\n const subscribe = useCallback((listener: () => void) => frames?.subscribe(listener) ?? (() => {}), [frames]);\n const read = () => frames?.get(trialId) ?? NO_FRAME;\n return useSyncExternalStore(subscribe, read, read);\n}\n","import { createContext } from 'react';\nimport type { Globals } from '../protocol/messages';\n\n/** The lab's global values, which a trial's pins override. A change reaches open frames without replacing instruments. */\nexport const StoryGlobalsContext = createContext<Globals>({});\n","/** How far past the viewport a trial's story stays mounted, so a small scroll back does not reload it. */\nexport const IN_VIEW_MARGIN = '50%';\n","import { usePersistedState } from '@weasel-js/labkit';\n\nexport type CssOverrides = Readonly<Record<string, string>>;\n\nconst NONE: CssOverrides = {};\n\n/** The CSS variable overrides of the trial this is rendered inside, persisted with it. */\nexport function useCssOverrides() {\n return usePersistedState<CssOverrides>('fg-css-overrides', NONE, { scope: 'trial' });\n}\n","import { useTrialTitle } from '@weasel-js/labkit';\nimport { type ReactNode, useLayoutEffect, useState } from 'react';\n\nconst overflows = (el: HTMLElement) => el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth;\n\n/** Whether `el` currently has more content than it shows, rechecked as it or any child resizes. */\nfunction useOverflowing(el: HTMLElement | null): boolean {\n const [overflowing, setOverflowing] = useState(false);\n useLayoutEffect(() => {\n if (!el || typeof ResizeObserver === 'undefined') return;\n const check = () => setOverflowing(overflows(el));\n const sizes = new ResizeObserver(check);\n const watch = () => {\n sizes.disconnect();\n sizes.observe(el);\n for (const child of el.children) sizes.observe(child, { box: 'border-box' });\n };\n const children = new MutationObserver(() => {\n watch();\n check();\n });\n children.observe(el, { childList: true });\n watch();\n check();\n return () => {\n children.disconnect();\n sizes.disconnect();\n };\n }, [el]);\n return overflowing;\n}\n\n/**\n * The story's own box. While its story overflows it is a tab stop, so a keyboard can scroll it, and a region named\n * for the trial, as WCAG asks of a focusable scroller.\n */\nexport function StoryScroller({ children }: { children: ReactNode }) {\n const [el, setEl] = useState<HTMLDivElement | null>(null);\n const overflowing = useOverflowing(el);\n const title = useTrialTitle();\n return (\n <div\n ref={setEl}\n className=\"fg-story__scroll\"\n {...(overflowing ? { tabIndex: 0, role: 'region', 'aria-label': title ?? 'Story' } : {})}\n >\n {children}\n </div>\n );\n}\n","import { createContext, type RefObject, useContext, useLayoutEffect } from 'react';\n\n/** Each trial's story host, keyed by trial id: `TrialHost` attaches its element, an annotation target reads it. */\nexport interface StoryHosts {\n /** One ref per trial, the same object every time, holding its host while one is attached. */\n ref(trialId: string): RefObject<HTMLElement | null>;\n /**\n * Returns the detach, which leaves a later attach for the same trial standing. `show` renders the host's content\n * while it is out of view, resolving once that has painted, with the release.\n */\n attach(trialId: string, host: HTMLElement, show?: () => Promise<() => void>): () => void;\n /** Renders trial `trialId`'s story wherever it is, until the release it resolves with is called. */\n show(trialId: string): Promise<() => void>;\n}\n\nexport function createStoryHosts(): StoryHosts {\n const refs = new Map<string, RefObject<HTMLElement | null>>();\n const shows = new Map<string, { host: HTMLElement; show: () => Promise<() => void> }>();\n const ref = (trialId: string) => {\n let held = refs.get(trialId);\n if (!held) {\n held = { current: null };\n refs.set(trialId, held);\n }\n return held;\n };\n return {\n ref,\n attach(trialId, host, show) {\n const held = ref(trialId);\n held.current = host;\n if (show) shows.set(trialId, { host, show });\n return () => {\n if (held.current === host) held.current = null;\n if (shows.get(trialId)?.host === host) shows.delete(trialId);\n };\n },\n show(trialId) {\n return shows.get(trialId)?.show() ?? Promise.resolve(() => {});\n },\n };\n}\n\n/** The workshop's `StoryHosts`; `null` outside a `Workshop`. */\nexport const StoryHostsContext = createContext<StoryHosts | null>(null);\n\n/** Attaches `host` as the story host of trial `trialId` while both are given. */\nexport function useStoryHost(\n trialId: string | null | undefined,\n host: HTMLElement | null,\n show?: () => Promise<() => void>,\n): void {\n const hosts = useContext(StoryHostsContext);\n useLayoutEffect(\n () => (host && hosts && trialId ? hosts.attach(trialId, host, show) : undefined),\n [host, hosts, trialId, show],\n );\n}\n","import { useCallback, useEffect, useState } from 'react';\n\n/** Calls `done` once `host`'s fonts are ready and a frame has painted after; returns the cancel. */\nexport function afterPaint(host: HTMLElement, done: () => void): () => void {\n let canceled = false;\n const finish = () => {\n if (!canceled) done();\n };\n const { fonts } = host.ownerDocument;\n if (!fonts) finish();\n else {\n const frame = () => requestAnimationFrame(finish);\n void fonts.ready.then(frame, frame);\n }\n return () => {\n canceled = true;\n };\n}\n\n/**\n * Whether a story host renders its content: while it is near the viewport, or while a caller of `show` holds it.\n * `show` resolves once the content has painted, with the release.\n */\nexport function useStoryShow(\n host: HTMLElement | null,\n inView: boolean,\n): { live: boolean; show: () => Promise<() => void> } {\n const [held, setHeld] = useState(0);\n const [waiters] = useState<(() => void)[]>(() => []);\n const live = inView || held > 0;\n\n const show = useCallback(\n () =>\n new Promise<() => void>((resolve) => {\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n setHeld((n) => n - 1);\n };\n waiters.push(() => resolve(release));\n setHeld((n) => n + 1);\n }),\n [waiters],\n );\n\n useEffect(() => {\n if (!host || !live || waiters.length === 0) return;\n const waiting = waiters.splice(0);\n let settled = false;\n const cancel = afterPaint(host, () => {\n settled = true;\n for (const resolve of waiting) resolve();\n });\n return () => {\n cancel();\n if (!settled) waiters.unshift(...waiting);\n };\n }, [host, live, held, waiters]);\n\n // A caller still waiting when the host goes finds it gone rather than hanging.\n useEffect(\n () => () => {\n for (const resolve of waiters.splice(0)) resolve();\n },\n [waiters],\n );\n\n return { live, show };\n}\n","import { useLatest } from '@weasel-js/core';\nimport { LabBoundary, TrialIdContext } from '@weasel-js/labkit';\nimport { OverlayPortalProvider } from '@weasel-js/ui/portal-host';\nimport {\n type ReactNode,\n type RefObject,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { auditElement } from '../frame/a11y';\nimport { createA11yHighlighter } from '../frame/a11yHighlight';\nimport { scanCssVars } from '../frame/cssVars';\nimport type { FrameSetup } from '../frame/FrameController';\nimport { useNearViewport } from '@weasel-js/react';\nimport { IN_VIEW_MARGIN } from './inViewMargin';\nimport type { CssVarReport, Globals, Layout, ToFrame } from '../protocol/messages';\nimport { useCssOverrides } from './cssVars/overrides';\nimport { effectiveGlobals, GLOBALS_KEY } from './globals';\nimport { useHostConditions } from './hostConditions';\nimport { StoryGlobalsContext } from './StoryGlobalsContext';\nimport { StoryScroller } from './StoryScroller';\nimport { useStoryHost } from './storyHosts';\nimport { afterPaint, useStoryShow } from './storyShow';\nimport { TrialFramesContext } from './trialFrames';\n\n/** Props for `TrialHost`. */\nexport interface TrialHostProps {\n layout: Layout;\n setup: FrameSetup;\n /** The trial's config, read for its `$globals` pins. */\n config: unknown;\n /** Rendered once the host element exists, with the globals in force on it. */\n children: (globals: Globals) => ReactNode;\n /** Receives the host element, for a caller with no trial to reach it through. */\n hostRef?: RefObject<HTMLElement | null>;\n /** Called once the children's first commit has painted. */\n onRendered?: () => void;\n /**\n * Makes this host a second copy of the trial's story: it takes `id` as its host id and `globals` in place of the\n * computed ones, carries `data-fg-copy`, and stays out of the frame registry, the a11y highlighter and `onRendered`.\n */\n copy?: { id: string; globals: Globals };\n}\n\nconst VARS_SETTLE_MS = 100;\n\n/**\n * The workshop is itself a lab; below the boundary a story sees no lab, trial or theme above it, as in a document of\n * its own. Overlays portal to the host, outside the scroller, so they stay put as it scrolls, and a modal takes the\n * host for its viewport.\n */\nfunction StoryContent({ host, children }: { host: HTMLElement; children: ReactNode }) {\n return (\n <LabBoundary>\n <OverlayPortalProvider container={host} contained>{children}</OverlayPortalProvider>\n </LabBoundary>\n );\n}\n\n/**\n * One story's box in the workshop document: what a frame document was, as an element. It applies the globals to\n * itself, keeps its CSS variable overrides on itself, contains fixed-position descendants and portals, reports its\n * vars and audits to the trial's frame registry, and unmounts its content while out of view unless something holds it shown.\n */\nexport function TrialHost({ layout, setup, config, children, hostRef, onRendered, copy }: TrialHostProps) {\n const trialId = useContext(TrialIdContext);\n const frames = useContext(TrialFramesContext);\n const labGlobals = useContext(StoryGlobalsContext);\n const pins = (config as Record<string, unknown> | null | undefined)?.[GLOBALS_KEY];\n const computed = useMemo(() => effectiveGlobals(labGlobals, pins), [labGlobals, pins]);\n const globals = copy?.globals ?? computed;\n const [persisted] = useCssOverrides();\n const reactId = useId();\n const hostId = copy?.id ?? trialId ?? reactId;\n const [host, setHost] = useState<HTMLDivElement | null>(null);\n const elementRef = useRef<HTMLDivElement | null>(null);\n const inView = useNearViewport(elementRef, IN_VIEW_MARGIN);\n const { live, show } = useStoryShow(host, inView);\n const [pending, setPending] = useState(true);\n // Settles at the first render below, which an audit waits for: until then the host holds no story to judge.\n const [rendered] = useState(() => {\n let resolve!: () => void;\n const promise = new Promise<void>((r) => { resolve = r; });\n return { promise, resolve };\n });\n const latest = useLatest({ onRendered: copy ? undefined : onRendered });\n\n const overridesRef = useHostConditions(host, { hostId, globals, overrides: persisted, setup });\n\n // The registry connection: the host's vars and audits, reported to the trial. A copy has none.\n useLayoutEffect(() => {\n const overrides = overridesRef.current;\n if (!host || !overrides || copy) return;\n const doc = host.ownerDocument;\n let lastVars: CssVarReport[] | null = null;\n let reported: string | null = null;\n const publish = (vars: CssVarReport[]) => {\n lastVars = vars;\n const key = JSON.stringify(vars);\n if (key === reported) return;\n reported = key;\n if (trialId) frames?.report(trialId, vars);\n };\n const scan = () => publish(scanCssVars(doc, overrides.has, host));\n let settleTimer: ReturnType<typeof setTimeout> | undefined;\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 const mutations =\n typeof MutationObserver === 'undefined'\n ? null\n : new MutationObserver((records) => {\n if (records.every(ownMutation)) return;\n clearTimeout(settleTimer);\n settleTimer = setTimeout(scan, VARS_SETTLE_MS);\n });\n mutations?.observe(host, { subtree: true, childList: true, characterData: true, attributes: true });\n\n const highlighter = createA11yHighlighter(doc);\n const send = (msg: ToFrame) => {\n if (msg.type === 'a11y.highlight') highlighter.show(msg.targets);\n if (msg.type !== 'vars.set') return;\n overrides.set(msg.name, msg.value);\n if (lastVars?.some((v) => v.name === msg.name)) scan();\n };\n const audit = async () => {\n await rendered.promise;\n const outcome = await auditElement(host, { page: false });\n if (trialId) frames?.reportA11y(trialId, outcome);\n return outcome;\n };\n const disconnect = frames && trialId ? frames.connect(trialId, { send, audit }) : () => {};\n\n return () => {\n disconnect();\n highlighter.dispose();\n mutations?.disconnect();\n clearTimeout(settleTimer);\n };\n }, [host, hostId, trialId, frames, copy, overridesRef, rendered]);\n\n useStoryHost(trialId, copy ? null : host, show);\n // The host is hidden until its first commit has painted with its fonts, so a new trial never shows a jump.\n const announced = useRef(false);\n useEffect(() => {\n if (!host || !live || announced.current) return;\n return afterPaint(host, () => {\n announced.current = true;\n rendered.resolve();\n setPending(false);\n latest.current.onRendered?.();\n });\n }, [host, live, latest, rendered]);\n\n return (\n <div\n ref={(el) => {\n elementRef.current = el;\n if (hostRef) hostRef.current = el;\n setHost(el);\n }}\n className=\"fg-story\"\n data-fg-host={hostId}\n data-fg-copy={copy ? '' : undefined}\n data-fg-layout={layout}\n data-pending={pending || undefined}\n >\n <StoryScroller>{host && live ? <StoryContent host={host}>{children(globals)}</StoryContent> : null}</StoryScroller>\n </div>\n );\n}\n","import { memo } from 'react';\nimport { StoryHost } from '../frame/StoryHost';\nimport type { Globals } from '../protocol/messages';\nimport type { Decorator, LoadedStory, StoryContext } from '../story/types';\n\nexport interface StoryBodyProps {\n story: LoadedStory;\n config: StoryContext['config'];\n setConfig: StoryContext['setConfig'];\n state: unknown;\n setState: StoryContext['setState'];\n globals: Globals;\n decorators: readonly Decorator[];\n resetKey: number;\n onError: (error: unknown) => void;\n}\n\n/** Calls `render` only when its inputs change, as Storybook does: the lab re-renders a trial for its own reasons, and a\n * story declaring a component inside `render` remounts it on every extra call. */\nexport const StoryBody = memo(function StoryBody({ story, config, setConfig, state, setState, globals, decorators, resetKey, onError }: StoryBodyProps) {\n const storyCtx: StoryContext = { config, setConfig, state, setState, globals, title: story.title, name: story.name };\n return <StoryHost story={story} ctx={storyCtx} decorators={decorators} resetKey={resetKey} onError={onError} />;\n});\n","import type { LabMode } from '@weasel-js/labkit';\nimport { withValueAtPath } from '@weasel-js/labkit/config';\nimport type { Globals } from '../../protocol/messages';\nimport { effectiveGlobals, FOLLOW_APP, GLOBALS_KEY, type GlobalDeclarations } from '../globals';\n\n/** What a lens compares the story against: the opposite color mode, or globals, args and a DPR of its own. */\nexport type ForgeComparison =\n | { kind: 'opposite-mode' }\n | {\n kind: 'custom';\n globals?: Readonly<Record<string, string>>;\n args?: Readonly<Record<string, unknown>>;\n dpr?: number;\n };\n\n/** The conditions a compared render runs under. `dpr` is null where the comparison leaves it alone. */\nexport interface ResolvedConditions {\n globals: Globals;\n args: Readonly<Record<string, unknown>>;\n dpr: number | null;\n}\n\n/** What resolving a comparison reads besides the comparison and the globals it starts from. */\nexport interface ResolveContext {\n declarations: GlobalDeclarations;\n modeGlobal: string;\n prefersDark: boolean;\n labMode: LabMode;\n}\n\nconst NO_ARGS: Readonly<Record<string, unknown>> = {};\n\n/** `value` with `App` read from the lab's own mode and `auto` from the OS, as the story would be shown. */\nfunction shownMode(value: string, ctx: ResolveContext): string {\n const followed = value === FOLLOW_APP ? ctx.labMode : value;\n return followed === 'auto' ? (ctx.prefersDark ? 'dark' : 'light') : followed;\n}\n\nconst SWAP: Readonly<Record<string, string>> = { light: 'dark', dark: 'light' };\n\n/**\n * The mode opposite the one `base` shows, from its declaration's `opposite` or else a swap of light and dark; `to`\n * is undefined where it has none.\n */\nexport function oppositeMode(base: Globals, ctx: ResolveContext): { from: string; to: string | undefined } {\n const from = shownMode(String(base[ctx.modeGlobal] ?? ''), ctx);\n const own = ctx.declarations[ctx.modeGlobal]?.opposite;\n return { from, to: own ? own(from, base) : SWAP[from] };\n}\n\n/**\n * The conditions `c` asks for, starting from `base` — the globals the story renders under before the comparison,\n * pins included. Resolved when a lens renders rather than when the comparison is chosen, so opposite mode keeps\n * showing the opposite after the lab's mode changes; a mode with no opposite leaves the story as it is.\n */\nexport function resolveComparison(c: ForgeComparison | null, base: Globals, ctx: ResolveContext): ResolvedConditions {\n if (c === null) return { globals: base, args: NO_ARGS, dpr: null };\n if (c.kind === 'opposite-mode') {\n const { to } = oppositeMode(base, ctx);\n return { globals: to === undefined ? base : { ...base, [ctx.modeGlobal]: to }, args: NO_ARGS, dpr: null };\n }\n return {\n globals: c.globals ? { ...base, ...c.globals } : base,\n args: c.args ?? NO_ARGS,\n dpr: c.dpr ?? null,\n };\n}\n\n/** A global's value as the toolbar names it: \"Theme: Ocean\". */\nfunction globalLabel(key: string, value: string, declarations: GlobalDeclarations): string {\n const declaration = declarations[key];\n if (!declaration) return `${key}: ${value}`;\n const option = declaration.options.find((o) => o.value === value);\n return `${declaration.label}: ${option?.label ?? value}`;\n}\n\n/** What a lens's comparison is named against: the globals it resolves over, and whether the lens shows Pixels. */\nexport interface DescribeAgainst {\n base: Globals;\n ctx: ResolveContext;\n /** False on a lens that shows no Pixels, where a DPR comparison changes nothing. */\n pixels?: boolean;\n}\n\n/**\n * How a lens names `c`: \"Opposite mode\", \"Theme: Ocean\", \"Arg size = 3\", \"DPR 2×\". Given what the lens renders\n * against, opposite mode says so when there is no opposite to show, and a DPR says it applies to Pixels only on a\n * lens that shows none.\n */\nexport function describeComparison(c: ForgeComparison, declarations: GlobalDeclarations, against?: DescribeAgainst): string {\n if (c.kind === 'opposite-mode') {\n const flip = against ? oppositeMode(against.base, against.ctx) : null;\n return flip && flip.to === undefined ? `Opposite mode: no opposite for '${flip.from}'` : 'Opposite mode';\n }\n const globals = Object.entries(c.globals ?? {}).map(([key, value]) => globalLabel(key, value, declarations));\n const args = Object.entries(c.args ?? {}).map(([path, value]) => `Arg ${path} = ${String(value)}`);\n const dpr = c.dpr ? [`DPR ${c.dpr}×${against?.pixels === false ? ' (Pixels only)' : ''}`] : [];\n return [...globals, ...args, ...dpr].join(', ') || 'As it is';\n}\n\n/**\n * How a lens over a trial names `c`: against that trial's own globals, pins included, as the lens renders it, and\n * whether the lens shows Pixels.\n */\nexport function describeLens(c: ForgeComparison, lab: LabConditions, trialConfig: unknown, pixels: boolean): string {\n const pins = (trialConfig as Record<string, unknown> | null | undefined)?.[GLOBALS_KEY];\n const base = effectiveGlobals(lab.labValues, pins);\n return describeComparison(c, lab.declarations, { base, ctx: resolveContextOf(lab), pixels });\n}\n\n/** `config` with each of `args` written at its path. */\nexport const withArgs = (config: unknown, args: Readonly<Record<string, unknown>>): unknown =>\n Object.entries(args).reduce((c, [path, value]) => withValueAtPath(c, path, value), config);\n\n/** The lab as a lens reads it when it renders: its globals, its mode, and the declarations behind them. */\nexport interface LabConditions {\n labValues: Globals;\n mode: LabMode;\n declarations: GlobalDeclarations;\n modeGlobal: string;\n}\n\n/** What resolving a comparison against `lab` reads, the OS color scheme included. */\nexport function resolveContextOf(lab: LabConditions): ResolveContext {\n const prefersDark = globalThis.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false;\n return { declarations: lab.declarations, modeGlobal: lab.modeGlobal, prefersDark, labMode: lab.mode };\n}\n","import { createContext } from 'react';\nimport type { ForgeComparison, ResolveContext } from './conditions';\nimport type { TrialHit } from './trialAt';\n\n/** One Live lens cell's ask of the trial under its reticle: render a copy into `slot`, magnified about `hit.local`. */\nexport interface LiveRequest {\n /** The lens's id; a cell showing a comparison adds `~compared`, so a Split lens's two cells are two requests. */\n lensId: string;\n slot: HTMLElement;\n hit: TrialHit;\n factor: number;\n /** The slot's size, in CSS px. */\n size: { width: number; height: number };\n /** What the copy compares against, resolved over the trial's own globals, pins included; null shows the story\n * as it is. */\n compare: ForgeComparison | null;\n ctx: ResolveContext;\n /** Config values written over the trial's at their paths. */\n args: Readonly<Record<string, unknown>>;\n}\n\n/** The Live requests standing, by lens, read by each trial for the copies it owes. */\nexport interface LiveLenses {\n /** `null` withdraws the lens's request. */\n set(lensId: string, request: LiveRequest | null): void;\n /** The same array until a request changes. */\n forTrial(trialId: string): readonly LiveRequest[];\n subscribe(listener: () => void): () => void;\n}\n\nconst NONE: readonly LiveRequest[] = [];\n\nexport function createLiveLenses(): LiveLenses {\n const requests = new Map<string, LiveRequest>();\n const listeners = new Set<() => void>();\n let byTrial = new Map<string, readonly LiveRequest[]>();\n return {\n set(lensId, request) {\n if (request === null) {\n if (!requests.delete(lensId)) return;\n } else requests.set(lensId, request);\n byTrial = new Map();\n for (const listener of [...listeners]) listener();\n },\n forTrial(trialId) {\n let found = byTrial.get(trialId);\n if (!found) {\n const mine = [...requests.values()].filter((r) => r.hit.trialId === trialId);\n found = mine.length === 0 ? NONE : mine;\n byTrial.set(trialId, found);\n }\n return found;\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\n/** The workshop's Live requests; null outside a workshop, where no trial renders copies. */\nexport const LiveLensesContext = createContext<LiveLenses | null>(null);\n","import type { LoupePoint } from '@weasel-js/labkit/loupe';\n\n/** The trial under a client point: its host, and the point in the host's own px. */\nexport interface TrialHit {\n trialId: string;\n host: HTMLElement;\n /** In the host's own px: the client offset from its corner, undone by any zoom on the pane holding it. */\n local: LoupePoint;\n /** Client px per host px. */\n scale: number;\n}\n\n/** The element an in-document story scrolls in, inside its host; null for a host with none, as a frame's. */\nexport const scrollerOf = (host: HTMLElement | null): HTMLElement | null =>\n host?.querySelector<HTMLElement>(':scope > .fg-story__scroll') ?? null;\n\nconst stackAt = (client: LoupePoint, doc: Document): readonly Element[] =>\n doc.elementsFromPoint?.(client.x, client.y) ?? [];\n\n/**\n * The topmost story host under `client`, an in-document story's or an isolated one's frame host, skipping a lens's\n * copies, which only ever show some host beneath them.\n */\nexport function trialAt(client: LoupePoint, doc: Document = document): TrialHit | null {\n for (const el of stackAt(client, doc)) {\n const host = el.closest<HTMLElement>('[data-fg-host]');\n if (!host || host.hasAttribute('data-fg-copy')) continue;\n const rect = host.getBoundingClientRect();\n const scale = host.offsetWidth > 0 ? rect.width / host.offsetWidth : 1;\n return {\n trialId: host.dataset.fgHost ?? '',\n host,\n local: { x: (client.x - rect.left) / scale, y: (client.y - rect.top) / scale },\n scale,\n };\n }\n return null;\n}\n","import './loupe.css';\nimport {\n type CSSProperties,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useSyncExternalStore,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport type { FrameSetup } from '../../frame/FrameController';\nimport type { Globals, Layout } from '../../protocol/messages';\nimport type { ClockHandle } from '@weasel-js/clock';\nimport { ClockContext } from '../../timeline/context';\nimport { effectiveGlobals, GLOBALS_KEY } from '../globals';\nimport { StoryBody, type StoryBodyProps } from '../StoryBody';\nimport { StoryGlobalsContext } from '../StoryGlobalsContext';\nimport { TrialHost } from '../TrialHost';\nimport { resolveComparison, withArgs } from './conditions';\nimport { type LiveLenses, LiveLensesContext, type LiveRequest } from './liveLenses';\nimport { scrollerOf } from './trialAt';\n\n/** Props for `LiveCopies`: what a trial renders its own content with, which every copy of it shares. */\nexport interface LiveCopiesProps {\n trialId: string | null;\n layout: Layout;\n setup: FrameSetup;\n /** The trial's whole config, read for its `$globals` pins. */\n trialConfig: unknown;\n /** One copy's content, under the copy's globals and with the lens's args to write over the trial's config. */\n children: (globals: Globals, args: Readonly<Record<string, unknown>>) => ReactNode;\n}\n\n/** Props for `StoryCopy`. */\nexport interface StoryCopyProps {\n /** The story's own body props; a copy replaces `config`, `setConfig` and `globals`. */\n body: Omit<StoryBodyProps, 'globals'>;\n /** The trial's clock; a copy reads it and never drives it. */\n clock: ClockHandle | null;\n globals: Globals;\n args: Readonly<Record<string, unknown>>;\n}\n\n/** A story trial's copy: its body under the copy's globals, with the lens's args written over its config. */\nexport function StoryCopy({ body, clock, globals, args }: StoryCopyProps) {\n const { config, setConfig } = useCopyConfig(body.config, body.setConfig, args);\n return (\n <ClockContext.Provider value={clock}>\n <StoryBody {...body} config={config} setConfig={setConfig} globals={globals} />\n </ClockContext.Provider>\n );\n}\n\n/** Whether a write to `path` would land on, inside or over the arg at `arg`. */\nconst covers = (arg: string, path: string) =>\n path === arg || path.startsWith(`${arg}.`) || arg.startsWith(`${path}.`);\n\nconst px = (n: number) => `${n}px`;\n\n/** Where the copy sits in its slot: the host's own size, scaled by the factor about the hit point, which lands on the\n * slot's center. Set as custom properties, which the stylesheet reads. */\nfunction placement(request: LiveRequest): CSSProperties {\n const { hit, factor, size } = request;\n return {\n ['--fg-lens-copy-w' as string]: px(hit.host.offsetWidth),\n ['--fg-lens-copy-h' as string]: px(hit.host.offsetHeight),\n ['--fg-lens-copy-x' as string]: px(size.width / 2 - hit.local.x * factor),\n ['--fg-lens-copy-y' as string]: px(size.height / 2 - hit.local.y * factor),\n ['--fg-lens-copy-f' as string]: String(factor),\n } as CSSProperties;\n}\n\n\n/** Runs `sync` after every commit of the copy's content, which mounts a render after the copy's host does. */\nfunction AfterCommit({ sync }: { sync: () => void }) {\n useLayoutEffect(sync);\n return null;\n}\n\n/** The globals a lens's copy renders under: the comparison resolved over the trial's own, pins included. */\nfunction useCopyGlobals(request: LiveRequest, trialConfig: unknown): Globals {\n const labGlobals = useContext(StoryGlobalsContext);\n const pins = (trialConfig as Record<string, unknown> | null | undefined)?.[GLOBALS_KEY];\n const own = useMemo(() => effectiveGlobals(labGlobals, pins), [labGlobals, pins]);\n const { compare, ctx } = request;\n return useMemo<Globals>(() => resolveComparison(compare, own, ctx).globals, [own, compare, ctx]);\n}\n\n/**\n * A copy's config and its writer: the trial's config with each of `args` written at its path, and a `setConfig`\n * that drops a write to any of them, since the comparison owns those, and passes every other write to the trial.\n */\nexport function useCopyConfig(\n trialConfig: unknown,\n trialSetConfig: (path: string, value: unknown) => void,\n args: Readonly<Record<string, unknown>>,\n): { config: unknown; setConfig: (path: string, value: unknown) => void } {\n const config = useMemo(() => withArgs(trialConfig, args), [args, trialConfig]);\n // Keyed by the paths alone, so a comparison re-resolved to the same args keeps the story's `setConfig` stable.\n const argPaths = Object.keys(args).join('\\n');\n const setConfig = useCallback(\n (path: string, value: unknown) => {\n const owned = argPaths === '' ? [] : argPaths.split('\\n');\n if (!owned.some((arg) => covers(arg, path))) trialSetConfig(path, value);\n },\n [argPaths, trialSetConfig],\n );\n return { config, setConfig };\n}\n\n/** Portals a copy into its lens's slot, placed and scaled about the reticle's point. */\nfunction LensPortal({ request, children }: { request: LiveRequest; children: ReactNode }) {\n return createPortal(\n <div className=\"fg-lens-copy\" style={placement(request)}>\n {children}\n </div>,\n request.slot,\n );\n}\n\nconst copyId = (trialId: string, request: LiveRequest) => `${trialId}~lens-${request.lensId}`;\n\n/** The Live requests standing over `trialId`, re-read as they change. */\nfunction useRequests(lenses: LiveLenses, trialId: string): readonly LiveRequest[] {\n const forTrial = useCallback(() => lenses.forTrial(trialId), [lenses, trialId]);\n return useSyncExternalStore(lenses.subscribe, forTrial);\n}\n\nfunction LensCopy({ request, trialId, layout, setup, trialConfig, children }: LiveCopiesProps & { request: LiveRequest; trialId: string }) {\n const globals = useCopyGlobals(request, trialConfig);\n const id = copyId(trialId, request);\n const copy = useMemo(() => ({ id, globals }), [id, globals]);\n\n const main = request.hit.host;\n const { slot } = request;\n // Found from the slot, not through the copy's host ref, which a re-render of the host detaches until after its\n // content's layout effects have run.\n const sync = useCallback(() => {\n const from = scrollerOf(main);\n const to = scrollerOf(slot.querySelector<HTMLElement>(':scope > .fg-lens-copy > [data-fg-copy]'));\n if (!from || !to) return;\n to.scrollTop = from.scrollTop;\n to.scrollLeft = from.scrollLeft;\n }, [main, slot]);\n useEffect(() => {\n const from = scrollerOf(main);\n from?.addEventListener('scroll', sync, { passive: true });\n return () => from?.removeEventListener('scroll', sync);\n }, [main, sync]);\n\n return (\n <LensPortal request={request}>\n {/* Remounted on a new factor: no observer sees a transform change, and a canvas inside sizes its backing\n store for the magnification it mounted under. */}\n <TrialHost key={request.factor} layout={layout} setup={setup} config={trialConfig} copy={copy}>\n {(g) => (\n <>\n {children(g, request.args)}\n <AfterCommit sync={sync} />\n </>\n )}\n </TrialHost>\n </LensPortal>\n );\n}\n\nfunction Copies({ lenses, trialId, ...props }: LiveCopiesProps & { lenses: LiveLenses; trialId: string }) {\n const requests = useRequests(lenses, trialId);\n return requests.map((request) => (\n <LensCopy key={request.lensId} request={request} trialId={trialId} {...props} />\n ));\n}\n\n/**\n * The trial's copies for the Live lenses over it: each a second render of its content, portaled into its lens, under\n * the lens's globals and args, following its scroll.\n */\nexport function LiveCopies(props: LiveCopiesProps) {\n const lenses = useContext(LiveLensesContext);\n const { trialId } = props;\n return lenses && trialId ? <Copies {...props} lenses={lenses} trialId={trialId} /> : null;\n}\n\n/**\n * What a lens's copy of an isolated story renders: its host id, the globals and args it renders under, the trial's\n * host, whose scroll it follows, and the factor the lens shows it at.\n */\nexport interface LensFrameCopy {\n id: string;\n main: HTMLElement;\n globals: Globals;\n args: Readonly<Record<string, unknown>>;\n factor: number;\n}\n\n/** Props for `LiveFrameCopies`. */\nexport interface LiveFrameCopiesProps {\n trialId: string | null;\n /** The trial's whole config, read for its `$globals` pins. */\n trialConfig: unknown;\n /** The trial's frame view in copy mode. */\n children: (copy: LensFrameCopy) => ReactNode;\n}\n\nfunction FrameLensCopy({ request, trialId, trialConfig, children }: Omit<LiveFrameCopiesProps, 'trialId'> & { request: LiveRequest; trialId: string }) {\n const globals = useCopyGlobals(request, trialConfig);\n const id = copyId(trialId, request);\n const { args, factor } = request;\n const main = request.hit.host;\n const copy = useMemo(() => ({ id, main, globals, args, factor }), [id, main, globals, args, factor]);\n return <LensPortal request={request}>{children(copy)}</LensPortal>;\n}\n\nfunction FrameCopies({ lenses, trialId, ...props }: Omit<LiveFrameCopiesProps, 'trialId'> & { lenses: LiveLenses; trialId: string }) {\n const requests = useRequests(lenses, trialId);\n return requests.map((request) => <FrameLensCopy key={request.lensId} request={request} trialId={trialId} {...props} />);\n}\n\n/**\n * The copies an isolated trial owes the Live lenses over it: each a frame of its own, portaled into its lens, under\n * the lens's globals and args, following its scroll. The trial's frame view renders itself as each copy, through\n * `children`.\n */\nexport function LiveFrameCopies(props: LiveFrameCopiesProps) {\n const lenses = useContext(LiveLensesContext);\n const { trialId } = props;\n return lenses && trialId ? <FrameCopies {...props} lenses={lenses} trialId={trialId} /> : null;\n}\n","import { type RenderContext, TrialIdContext, useTrialClockHandle } from '@weasel-js/labkit';\nimport { useLatest } from '@weasel-js/core';\nimport { type RefObject, useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport type { FrameSetup } from '../frame/FrameController';\nimport type { Globals } from '../protocol/messages';\nimport type { Decorator, LoadedStory } from '../story/types';\nimport { ClockContext } from '../timeline/context';\nimport { isForgePath, storyConfig } from './globals';\nimport { LiveCopies, StoryCopy } from './loupe/LiveCopies';\nimport { StoryBody } from './StoryBody';\nimport { TrialHost } from './TrialHost';\n\n/** Props for `StoryTrial`. */\nexport interface StoryTrialProps {\n story: LoadedStory;\n setup: FrameSetup;\n /** The trial's config and state; the story reads and writes them through its `StoryContext`. */\n ctx: Pick<RenderContext<unknown, unknown>, 'config' | 'state' | 'setConfig' | 'setState'>;\n hostRef?: RefObject<HTMLElement | null>;\n onRendered?: () => void;\n /** A render throw, after the boundary has shown it. */\n onError?: (error: unknown) => void;\n}\n\nconst NO_DECORATORS: readonly Decorator[] = [];\n\n/** A story rendered in the workshop document, inside a `TrialHost`, from the trial's own config and state. */\nexport function StoryTrial({ story, setup, ctx, hostRef, onRendered, onError }: StoryTrialProps) {\n const latestRef = useLatest(ctx);\n // Kept across a write to a key forge owns, so moving the playhead or a pin does not re-render the story.\n const [heldConfig, setHeldConfig] = useState(() => storyConfig(ctx.config));\n const config = storyConfig(ctx.config, heldConfig);\n if (config !== heldConfig) setHeldConfig(config);\n\n // A trial opened on the provisional instrument starts at `null`; the story's own initial state fills it once.\n const seeded = useRef(false);\n useEffect(() => {\n if (seeded.current || ctx.state !== null || !story.initialState) return;\n seeded.current = true;\n ctx.setState(story.initialState(config));\n }, [ctx, story, config]);\n\n // Each new input retries a render the boundary caught, as the frame did on each message.\n // State, not a ref: a render React throws away takes its bump with it.\n const [input, setInput] = useState({ config, state: ctx.state, key: 0 });\n let resetKey = input.key;\n if (input.config !== config || input.state !== ctx.state) {\n resetKey = input.key + 1;\n setInput({ config, state: ctx.state, key: resetKey });\n }\n\n // Stable, as the frame's were: a story may list them as effect dependencies.\n // The pins belong to the trial; a story cannot see them, so it cannot set them either.\n const setConfig = useCallback((path: string, value: unknown) => {\n if (!isForgePath(path)) latestRef.current.setConfig(path, value);\n }, [latestRef]);\n const setState = useCallback((next: unknown) => latestRef.current.setState(next), [latestRef]);\n\n // The story's clock is the one labkit made for its trial from the timeline the instrument declares.\n const trialId = useContext(TrialIdContext);\n const ownHost = useRef<HTMLElement | null>(null);\n const host = hostRef ?? ownHost;\n const spec = story.timeline?.(config) ?? null;\n const trialClock = useTrialClockHandle();\n const clock = spec ? trialClock : null;\n\n const decorators = setup.decorators ?? NO_DECORATORS;\n const latestError = useLatest(onError);\n const reportError = useCallback((error: unknown) => latestError.current?.(error), [latestError]);\n const body = {\n story,\n config,\n setConfig,\n state: ctx.state,\n setState,\n decorators,\n resetKey,\n onError: reportError,\n };\n const render = (globals: Globals) => (\n <ClockContext.Provider value={clock}>\n <StoryBody {...body} globals={globals} />\n </ClockContext.Provider>\n );\n\n return (\n <>\n <TrialHost\n layout={story.layout}\n setup={setup}\n config={ctx.config}\n hostRef={host}\n {...(onRendered ? { onRendered } : {})}\n >\n {render}\n </TrialHost>\n <LiveCopies trialId={trialId} layout={story.layout} setup={setup} trialConfig={ctx.config}>\n {(globals, args) => <StoryCopy body={body} clock={clock} globals={globals} args={args} />}\n </LiveCopies>\n </>\n );\n}\n"]}
|
|
@@ -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-BM6xuEfY.js';
|
|
5
5
|
import { IconRef } from '@weasel-js/icons';
|
|
6
|
-
import {
|
|
6
|
+
import { L as Library } from './library-CdTj-hFp.js';
|
|
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 {
|
|
@@ -44,24 +44,6 @@ type GlobalDeclarations = Readonly<Record<string, GlobalDeclaration>>;
|
|
|
44
44
|
/** A lab value, for a declaration that `follows` the app, meaning whatever the app's chrome is set to. */
|
|
45
45
|
declare const FOLLOW_APP = "app";
|
|
46
46
|
|
|
47
|
-
/** One library of a project: the story files under `path` carry `label`. */
|
|
48
|
-
interface Library {
|
|
49
|
-
/** A stretch of path every story file of the library has, with forward slashes: `/packages/ui/`. */
|
|
50
|
-
path: string;
|
|
51
|
-
label: string;
|
|
52
|
-
/** The tint of the library's badge, as a `<Badge>` takes one. Default: the badge's own low emphasis. */
|
|
53
|
-
tint?: AppearanceProps['tint'];
|
|
54
|
-
}
|
|
55
|
-
/** A project's libraries, as the tree's package filter, the index page header, and Get Info ask about them. */
|
|
56
|
-
interface Libraries {
|
|
57
|
-
/** The label of the first library whose `path` the story's file holds, else its title's first segment. */
|
|
58
|
-
of(entry: {
|
|
59
|
-
file: string;
|
|
60
|
-
title: string;
|
|
61
|
-
}): string;
|
|
62
|
-
tintOf(label: string): AppearanceProps['tint'];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
47
|
/** A shell config module: what the workshop adds to the lab. Only the workshop page imports it. */
|
|
66
48
|
interface ShellConfig {
|
|
67
49
|
/** The workshop's name, in its header and as the document title. Default `weaselforge`. The served page reads
|
|
@@ -101,4 +83,4 @@ declare function defineFrameConfig(config: FrameSetup): FrameSetup;
|
|
|
101
83
|
/** A shell config module's default export. */
|
|
102
84
|
declare function defineShellConfig(config: ShellConfig): ShellConfig;
|
|
103
85
|
|
|
104
|
-
export { FOLLOW_APP as F, type GlobalDeclaration as G, type LabChrome as L, type ShellConfig as S, type GlobalDeclarations as a,
|
|
86
|
+
export { FOLLOW_APP as F, type GlobalDeclaration as G, type LabChrome as L, type ShellConfig as S, type GlobalDeclarations as a, defineShellConfig as b, defineFrameConfig as d };
|
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-B26DWEYT.js';
|
|
2
|
+
import '../chunk-STK2AZH2.js';
|
|
3
3
|
import { useContext } from 'react';
|
|
4
4
|
|
|
5
5
|
var sendable = (value) => {
|
package/dist/frame/index.css
CHANGED
package/dist/frame/index.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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/* Text and example share a row while both fit, and the example wraps under the text rather than squeezing it. */\n.fg-index-story__main {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: var(--wzl-space-8) calc(var(--wzl-space-lg) * 1.5);\n}\n\n.fg-index-story__text {\n flex: 1 1 20rem;\n min-width: 0;\n}\n\n.fg-index-story__main > .fg-index-cell {\n flex: 0 1 auto;\n margin: 0;\n}\n\n.fg-index-story__main > .fg-index-cell--padded,\n.fg-index-story__main > .fg-index-cell--fullscreen {\n flex: 2 1 28rem;\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-story__link {\n color: inherit;\n text-decoration: none;\n}\n\n.fg-index-story__link:hover {\n color: var(--wzl-accent-fg);\n text-decoration: underline;\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
|
|
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/* Text and example share a row while both fit, and the example wraps under the text rather than squeezing it. */\n.fg-index-story__main {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: var(--wzl-space-8) calc(var(--wzl-space-lg) * 1.5);\n}\n\n.fg-index-story__text {\n flex: 1 1 20rem;\n min-width: 0;\n}\n\n.fg-index-story__main > .fg-index-cell {\n flex: 0 1 auto;\n margin: 0;\n}\n\n.fg-index-story__main > .fg-index-cell--padded,\n.fg-index-story__main > .fg-index-cell--fullscreen {\n flex: 2 1 28rem;\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-story__link {\n color: inherit;\n text-decoration: none;\n}\n\n.fg-index-story__link:hover {\n color: var(--wzl-accent-fg);\n text-decoration: underline;\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 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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,IAAI;AACvB,kBAAgB;AAClB;AAEA,CAAC;AACC,WAAS;AACT,eAAa;AACb,OAAK,IAAI;AACX;AAEA,CAAC;AACC,WAAS;AACT,aAAW;AACX,OAAK,IAAI,eAAe,IAAI;AAC5B,UAAQ,IAAI,eAAe,EAAE;AAC7B,aAAW,IAAI;AACjB;AAEA,CAAC;AACC,WAAS;AACT,OAAK,IAAI;AACX;AAEA,CAAC;AACC,SAAO,IAAI;AACb;AAEA,CAAC;AACC,UAAQ;AACV;AAEA,CAAC;AACC,WAAS;AACT,yBAAuB,YAAY;AACnC,OAAK,IAAI,eAAe,IAAI;AAC5B,UAAQ,IAAI,eAAe,EAAE;AAC7B,aAAW,IAAI;AACjB;AAEA,CAAC;AACC,WAAS;AACX;AAEA,CAAC;AACC,SAAO,IAAI;AACb;AAEA,CAAC;AACC,UAAQ;AACV;AAEA,CAAC;AACC,WAAS;AACT,aAAW;AACX,OAAK,IAAI,eAAe,IAAI;AAC5B,UAAQ;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;;;ACpPA,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,11 +1,13 @@
|
|
|
1
|
-
import { G as Globals, L as Layout, I as IndexEntry, F as FrameSetup } from '../FrameController-
|
|
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-
|
|
3
|
-
import { F as FrameImporters } from '../mountFrame-
|
|
4
|
-
export { a as FrameIndexEntry, M as MountFrameOptions, m as mountFrame } from '../mountFrame-
|
|
1
|
+
import { G as Globals, L as Layout, I as IndexEntry, F as FrameSetup, D as DepGraph } from '../FrameController-BM6xuEfY.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-BM6xuEfY.js';
|
|
3
|
+
import { F as FrameImporters } from '../mountFrame-CRPAjg1M.js';
|
|
4
|
+
export { a as FrameIndexEntry, M as MountFrameOptions, m as mountFrame } from '../mountFrame-CRPAjg1M.js';
|
|
5
5
|
import { Theme } from '@weasel-js/theme';
|
|
6
|
+
import { L as Library } from '../library-CdTj-hFp.js';
|
|
6
7
|
import '@weasel-js/icons';
|
|
7
8
|
import '@weasel-js/labkit/config';
|
|
8
9
|
import 'react';
|
|
10
|
+
import '@weasel-js/ui/appearance';
|
|
9
11
|
|
|
10
12
|
/** Everything the screen renders a story from, as the capture endpoint takes it. */
|
|
11
13
|
interface CapturePayload {
|
|
@@ -53,6 +55,10 @@ interface MountCaptureOptions {
|
|
|
53
55
|
setup: FrameSetup;
|
|
54
56
|
/** The shell config's `labTheme`; only the shell's capture page has one. */
|
|
55
57
|
labTheme?: ((globals: Globals) => Theme) | undefined;
|
|
58
|
+
/** The shell config's `libraries`, which an index page's header names and tints. */
|
|
59
|
+
libraries?: readonly Library[] | undefined;
|
|
60
|
+
/** The component graph an index page reads its dependencies and history from, asked for at its first capture. */
|
|
61
|
+
dependencies?: (() => Promise<DepGraph>) | undefined;
|
|
56
62
|
}
|
|
57
63
|
declare global {
|
|
58
64
|
interface Window {
|
|
@@ -63,10 +69,10 @@ declare global {
|
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
66
|
-
* A capture page's entry: exposes `window.__forgeCapture.render(payload)`, which loads the payload's story,
|
|
67
|
-
* it afresh into `#root`, and resolves once it has painted. Rejects for
|
|
68
|
-
* whatever throws outside the story's own error boundary.
|
|
72
|
+
* A capture page's entry: exposes `window.__forgeCapture.render(payload)`, which loads the payload's story, or the
|
|
73
|
+
* index page its index id names, renders it afresh into `#root`, and resolves once it has painted. Rejects for an id
|
|
74
|
+
* the index does not hold, and with whatever throws outside the story's own error boundary.
|
|
69
75
|
*/
|
|
70
|
-
declare function mountCapture(
|
|
76
|
+
declare function mountCapture(options: MountCaptureOptions): void;
|
|
71
77
|
|
|
72
78
|
export { FrameImporters, FrameSetup, type MountCaptureOptions, mountCapture };
|
package/dist/frame/index.js
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
|
-
import { describeSchema, createKitRoot, openChannel,
|
|
2
|
-
import { isIndexId, indexId } from '../chunk-
|
|
3
|
-
import
|
|
4
|
-
import { createOverrides, createGlobalsTarget, createA11yHighlighter, loadStories,
|
|
5
|
-
import { ClockContext } from '../chunk-
|
|
1
|
+
import { describeSchema, createKitRoot, openChannel, loadIndexBundle, librariesFrom, LibrariesContext, IndexPage, indexEnvOf, LAB_DENSITY, answerSchema } from '../chunk-PPB7VP6R.js';
|
|
2
|
+
import { isIndexId, indexId } from '../chunk-RVJHUY7W.js';
|
|
3
|
+
import '../chunk-VUPN73JP.js';
|
|
4
|
+
import { createOverrides, createGlobalsTarget, createA11yHighlighter, loadStories, scanCssVars, auditElement, runAxe, useHostConditions, StoryHost, useOwnClock, resolveCssVar } from '../chunk-PGLOYXDP.js';
|
|
5
|
+
import { ClockContext } from '../chunk-TT4ZOYB6.js';
|
|
6
6
|
import '../chunk-5WS67HMU.js';
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import { FRAME_HELLO, stableStringify, PORT_HANDOFF } from '../chunk-
|
|
7
|
+
import '../chunk-B26DWEYT.js';
|
|
8
|
+
import { FRAME_HELLO, stableStringify, PORT_HANDOFF } from '../chunk-STK2AZH2.js';
|
|
9
9
|
import { flushSync } from 'react-dom';
|
|
10
10
|
import { jsx } from 'react/jsx-runtime';
|
|
11
11
|
import { f } from '@weasel-js/labkit/config';
|
|
12
|
-
import { Component, useState,
|
|
12
|
+
import { Component, useState, useLayoutEffect, useRef, useEffect, useMemo } from 'react';
|
|
13
13
|
import { useLatest, useVisibleRaf } from '@weasel-js/core';
|
|
14
14
|
import { interstellarTheme, LabRoot } from '@weasel-js/labkit';
|
|
15
15
|
import { ThemeProvider } from '@weasel-js/theme/react';
|
|
16
16
|
import { OverlayPortalProvider } from '@weasel-js/ui/portal-host';
|
|
17
|
+
import { holdAt } from '@weasel-js/clock';
|
|
17
18
|
|
|
19
|
+
// src/frame/documentScroll.ts
|
|
20
|
+
function followDocumentScroll(doc, send) {
|
|
21
|
+
const scroller = doc.scrollingElement ?? doc.documentElement;
|
|
22
|
+
const view = doc.defaultView;
|
|
23
|
+
let reported = null;
|
|
24
|
+
const report = () => {
|
|
25
|
+
const left = scroller.scrollLeft;
|
|
26
|
+
const top = scroller.scrollTop;
|
|
27
|
+
const key = `${left} ${top}`;
|
|
28
|
+
if (key === reported) return;
|
|
29
|
+
reported = key;
|
|
30
|
+
send({ type: "scroll", left, top });
|
|
31
|
+
};
|
|
32
|
+
report();
|
|
33
|
+
view?.addEventListener("scroll", report, { passive: true });
|
|
34
|
+
return {
|
|
35
|
+
apply({ left, top }) {
|
|
36
|
+
scroller.scrollLeft = left;
|
|
37
|
+
scroller.scrollTop = top;
|
|
38
|
+
},
|
|
39
|
+
dispose: () => view?.removeEventListener("scroll", report)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
18
42
|
var VARS_SETTLE_MS = 100;
|
|
19
43
|
function fault(phase, error, seq) {
|
|
20
44
|
return {
|
|
@@ -25,6 +49,15 @@ function fault(phase, error, seq) {
|
|
|
25
49
|
...seq === void 0 ? {} : { seq }
|
|
26
50
|
};
|
|
27
51
|
}
|
|
52
|
+
function announceRendered(send) {
|
|
53
|
+
const { fonts } = document;
|
|
54
|
+
if (!fonts) {
|
|
55
|
+
send({ type: "rendered" });
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const afterPaint = () => requestAnimationFrame(() => send({ type: "rendered" }));
|
|
59
|
+
void fonts.ready.then(afterPaint, afterPaint);
|
|
60
|
+
}
|
|
28
61
|
function startFrame({ story, channel, container, setup = {} }) {
|
|
29
62
|
const { send } = channel;
|
|
30
63
|
send({ type: "ready", schema: describeSchema(story.config), layout: story.layout, viewport: story.viewport });
|
|
@@ -102,19 +135,11 @@ function startFrame({ story, channel, container, setup = {} }) {
|
|
|
102
135
|
}
|
|
103
136
|
if (!rendered) {
|
|
104
137
|
rendered = true;
|
|
105
|
-
announceRendered();
|
|
138
|
+
announceRendered(send);
|
|
106
139
|
}
|
|
107
140
|
reportVars();
|
|
108
141
|
};
|
|
109
|
-
const
|
|
110
|
-
const { fonts } = document;
|
|
111
|
-
if (!fonts) {
|
|
112
|
-
send({ type: "rendered" });
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const afterPaint = () => requestAnimationFrame(() => send({ type: "rendered" }));
|
|
116
|
-
void fonts.ready.then(afterPaint, afterPaint);
|
|
117
|
-
};
|
|
142
|
+
const scroll = followDocumentScroll(document, send);
|
|
118
143
|
const audit = async (id) => send({ type: "a11y", id, ...await auditElement(wrapper) });
|
|
119
144
|
const off = channel.on((msg) => {
|
|
120
145
|
switch (msg.type) {
|
|
@@ -162,10 +187,14 @@ function startFrame({ story, channel, container, setup = {} }) {
|
|
|
162
187
|
case "a11y.highlight":
|
|
163
188
|
highlighter.show(msg.targets);
|
|
164
189
|
break;
|
|
190
|
+
case "scroll":
|
|
191
|
+
scroll.apply(msg);
|
|
192
|
+
break;
|
|
165
193
|
}
|
|
166
194
|
});
|
|
167
195
|
return () => {
|
|
168
196
|
off();
|
|
197
|
+
scroll.dispose();
|
|
169
198
|
mutations?.disconnect();
|
|
170
199
|
clearTimeout(settleTimer);
|
|
171
200
|
overrides.dispose();
|
|
@@ -204,23 +233,14 @@ function startIndex(options) {
|
|
|
204
233
|
let announced = false;
|
|
205
234
|
const render = () => {
|
|
206
235
|
if (!globals) return;
|
|
207
|
-
const env = {
|
|
208
|
-
|
|
209
|
-
...options.library === void 0 ? {} : { library: options.library },
|
|
210
|
-
...options.description === void 0 ? {} : { description: options.description },
|
|
211
|
-
stories: options.stories,
|
|
212
|
-
descriptions: options.descriptions,
|
|
213
|
-
gallery: options.gallery ?? false,
|
|
214
|
-
galleries: options.galleries ?? [],
|
|
215
|
-
labs: options.labs ?? [],
|
|
236
|
+
const env = indexEnvOf(options.bundle, {
|
|
237
|
+
graph: null,
|
|
216
238
|
globals,
|
|
217
239
|
decorators: setup.decorators ?? [],
|
|
218
|
-
open: (id) => send({ type: "open", id })
|
|
219
|
-
|
|
220
|
-
onError: (error) => console.error(error)
|
|
221
|
-
};
|
|
240
|
+
open: (id) => send({ type: "open", id })
|
|
241
|
+
});
|
|
222
242
|
root.render(
|
|
223
|
-
/* @__PURE__ */ jsx(PageBoundary, { onError: (error) => send({ type: "fault", phase: "render", message: message(error) }), children: /* @__PURE__ */ jsx(IndexPage, { env, render: options.render }) })
|
|
243
|
+
/* @__PURE__ */ jsx(PageBoundary, { onError: (error) => send({ type: "fault", phase: "render", message: message(error) }), children: /* @__PURE__ */ jsx(IndexPage, { env, render: options.bundle.render }) })
|
|
224
244
|
);
|
|
225
245
|
};
|
|
226
246
|
const announce = () => {
|
|
@@ -299,33 +319,10 @@ async function mountFrame(options) {
|
|
|
299
319
|
const container = document.getElementById("root") ?? document.body;
|
|
300
320
|
try {
|
|
301
321
|
if (isIndexId(id)) {
|
|
302
|
-
const
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
const mods = await Promise.all(files.map(importOf));
|
|
307
|
-
const loaded = files.map((file, i) => ({
|
|
308
|
-
file,
|
|
309
|
-
stories: (options.load ?? loadStories)(mods[i] ?? {}, title, options.setup?.parameters)
|
|
310
|
-
}));
|
|
311
|
-
const stories2 = entries.flatMap(
|
|
312
|
-
(e) => loaded.find((l) => l.file === e.file)?.stories.find((s) => s.exportName === e.exportName) ?? []
|
|
313
|
-
);
|
|
314
|
-
for (const story2 of stories2) await options.setup?.prepare?.(story2);
|
|
315
|
-
startIndex({
|
|
316
|
-
title,
|
|
317
|
-
...entries[0]?.componentDescription === void 0 ? {} : { description: entries[0].componentDescription },
|
|
318
|
-
// The project's library table is the shell config's, which a frame document does not load.
|
|
319
|
-
library: TITLE_LIBRARIES.of({ file: entries[0]?.file ?? "", title }),
|
|
320
|
-
gallery: entries.every(isGallery),
|
|
321
|
-
...taggedIds(entries),
|
|
322
|
-
stories: stories2,
|
|
323
|
-
descriptions: Object.fromEntries(entries.flatMap((e) => e.description ? [[e.id, e.description]] : [])),
|
|
324
|
-
render: mods.map(indexRenderOf).find((render) => render !== null) ?? null,
|
|
325
|
-
channel,
|
|
326
|
-
container,
|
|
327
|
-
...options.setup ? { setup: options.setup } : {}
|
|
328
|
-
});
|
|
322
|
+
const { load, setup } = options;
|
|
323
|
+
const source = { index: options.index, importOf, load, parameters: setup?.parameters, prepare: setup?.prepare };
|
|
324
|
+
const bundle = await loadIndexBundle(id, source);
|
|
325
|
+
startIndex({ bundle, channel, container, ...setup ? { setup } : {} });
|
|
329
326
|
return;
|
|
330
327
|
}
|
|
331
328
|
const entry = options.index.find((e) => e.id === id);
|
|
@@ -345,16 +342,16 @@ var NO_WRITE = () => {
|
|
|
345
342
|
};
|
|
346
343
|
var boxStyle = ({ width, height }) => ({ ["--fg-capture-w"]: `${width}px`, ["--fg-capture-h"]: `${height}px` });
|
|
347
344
|
function scrollTo(host, { left, top }) {
|
|
348
|
-
const scroller = host?.querySelector(":scope > .fg-story__scroll");
|
|
345
|
+
const scroller = host?.querySelector(":scope > .fg-story__scroll") ?? host;
|
|
349
346
|
if (!scroller) return;
|
|
350
347
|
scroller.scrollLeft = left;
|
|
351
348
|
scroller.scrollTop = top;
|
|
352
349
|
}
|
|
353
|
-
function
|
|
354
|
-
const [host, setHost] = useState(null);
|
|
355
|
-
useHostConditions(host, { hostId: HOST_ID, globals: payload.globals, overrides: payload.overrides, setup });
|
|
350
|
+
function CapturedStory({ story, payload, setup }) {
|
|
356
351
|
const spec = useMemo(() => story.timeline?.(payload.config) ?? null, [story, payload.config]);
|
|
357
|
-
const clock =
|
|
352
|
+
const clock = useOwnClock(spec);
|
|
353
|
+
const at = payload.playhead;
|
|
354
|
+
useLayoutEffect(() => clock ? holdAt(clock, at).release : void 0, [clock, at]);
|
|
358
355
|
const state = useMemo(
|
|
359
356
|
() => payload.state === null && story.initialState ? story.initialState(payload.config) : payload.state,
|
|
360
357
|
[payload.state, payload.config, story]
|
|
@@ -368,6 +365,11 @@ function CaptureView({ story, payload, setup, labTheme, onRendered }) {
|
|
|
368
365
|
title: story.title,
|
|
369
366
|
name: story.name
|
|
370
367
|
};
|
|
368
|
+
return /* @__PURE__ */ jsx(ClockContext.Provider, { value: clock, children: /* @__PURE__ */ jsx(StoryHost, { story, ctx, decorators: setup.decorators ?? [], resetKey: 0, onError: NO_WRITE }) });
|
|
369
|
+
}
|
|
370
|
+
function CaptureView({ subject, graph = null, payload, setup, labTheme, onRendered }) {
|
|
371
|
+
const [host, setHost] = useState(null);
|
|
372
|
+
useHostConditions(host, { hostId: HOST_ID, globals: payload.globals, overrides: payload.overrides, setup });
|
|
371
373
|
const latest = useLatest({ onRendered, host, scroll: payload.scroll });
|
|
372
374
|
useLayoutEffect(() => scrollTo(host, payload.scroll), [host, payload.scroll]);
|
|
373
375
|
const ticks = useRef(0);
|
|
@@ -394,7 +396,13 @@ function CaptureView({ story, payload, setup, labTheme, onRendered }) {
|
|
|
394
396
|
raf.cancel();
|
|
395
397
|
};
|
|
396
398
|
}, [host, raf]);
|
|
397
|
-
const content = host ?
|
|
399
|
+
const content = !host ? null : subject.kind === "story" ? /* @__PURE__ */ jsx(CapturedStory, { story: subject.story, payload, setup }) : /* @__PURE__ */ jsx(
|
|
400
|
+
IndexPage,
|
|
401
|
+
{
|
|
402
|
+
env: indexEnvOf(subject.bundle, { graph, globals: payload.globals, decorators: setup.decorators ?? [], open: NO_WRITE }),
|
|
403
|
+
render: subject.bundle.render
|
|
404
|
+
}
|
|
405
|
+
);
|
|
398
406
|
const box = /* @__PURE__ */ jsx(
|
|
399
407
|
"div",
|
|
400
408
|
{
|
|
@@ -429,36 +437,63 @@ var CaptureBoundary = class extends Component {
|
|
|
429
437
|
return this.state.failed ? null : this.props.children;
|
|
430
438
|
}
|
|
431
439
|
};
|
|
432
|
-
function mountCapture(
|
|
440
|
+
function mountCapture(options) {
|
|
441
|
+
const { index, importers, setup, labTheme } = options;
|
|
442
|
+
const libraries = librariesFrom(options.libraries);
|
|
433
443
|
const container = document.getElementById("root") ?? document.body;
|
|
434
444
|
const root = createKitRoot(container, setup.icons);
|
|
435
445
|
const prepared = /* @__PURE__ */ new Map();
|
|
446
|
+
let graph = null;
|
|
436
447
|
let renders = 0;
|
|
437
|
-
const
|
|
448
|
+
const importOf = (file) => {
|
|
449
|
+
const importer = importers[file];
|
|
450
|
+
return importer ? importer() : Promise.reject(new Error(`No importer for ${file}`));
|
|
451
|
+
};
|
|
452
|
+
const loadStory = async (id) => {
|
|
453
|
+
const entry = index.find((e) => e.id === id);
|
|
454
|
+
if (!entry) throw new Error(`No story with id "${id}"`);
|
|
455
|
+
const story = loadStories(await importOf(entry.file), entry.title, setup.parameters).find(
|
|
456
|
+
(s) => s.exportName === entry.exportName
|
|
457
|
+
);
|
|
458
|
+
if (!story) throw new Error(`${entry.file} has no story export "${entry.exportName}"`);
|
|
459
|
+
await setup.prepare?.(story);
|
|
460
|
+
return { kind: "story", story };
|
|
461
|
+
};
|
|
462
|
+
const loadIndex = async (id) => {
|
|
463
|
+
const source = { index, importOf, parameters: setup.parameters, prepare: setup.prepare, libraries };
|
|
464
|
+
return { kind: "index", bundle: await loadIndexBundle(id, source) };
|
|
465
|
+
};
|
|
466
|
+
const subjectOf = (id) => {
|
|
438
467
|
let loading = prepared.get(id);
|
|
439
468
|
if (!loading) {
|
|
440
|
-
loading = (
|
|
441
|
-
const entry = index.find((e) => e.id === id);
|
|
442
|
-
if (!entry) throw new Error(`No story with id "${id}"`);
|
|
443
|
-
const importer = importers[entry.file];
|
|
444
|
-
if (!importer) throw new Error(`No importer for ${entry.file}`);
|
|
445
|
-
const story = loadStories(await importer(), entry.title, setup.parameters).find((s) => s.exportName === entry.exportName);
|
|
446
|
-
if (!story) throw new Error(`${entry.file} has no story export "${entry.exportName}"`);
|
|
447
|
-
await setup.prepare?.(story);
|
|
448
|
-
return story;
|
|
449
|
-
})();
|
|
469
|
+
loading = isIndexId(id) ? loadIndex(id) : loadStory(id);
|
|
450
470
|
prepared.set(id, loading);
|
|
451
471
|
loading.catch(() => prepared.delete(id));
|
|
452
472
|
}
|
|
453
473
|
return loading;
|
|
454
474
|
};
|
|
475
|
+
const graphOf = () => {
|
|
476
|
+
graph ??= options.dependencies ? options.dependencies().catch(() => null) : Promise.resolve(null);
|
|
477
|
+
return graph;
|
|
478
|
+
};
|
|
455
479
|
window.__forgeCapture = {
|
|
456
480
|
async render(payload) {
|
|
457
|
-
const
|
|
481
|
+
const subject = await subjectOf(payload.story);
|
|
482
|
+
const deps = subject.kind === "index" ? await graphOf() : null;
|
|
458
483
|
renders += 1;
|
|
459
484
|
await new Promise((resolve, reject) => {
|
|
460
485
|
root.render(
|
|
461
|
-
/* @__PURE__ */ jsx(CaptureBoundary, { onError: reject, children: /* @__PURE__ */ jsx(
|
|
486
|
+
/* @__PURE__ */ jsx(CaptureBoundary, { onError: reject, children: /* @__PURE__ */ jsx(LibrariesContext.Provider, { value: libraries, children: /* @__PURE__ */ jsx(
|
|
487
|
+
CaptureView,
|
|
488
|
+
{
|
|
489
|
+
subject,
|
|
490
|
+
graph: deps,
|
|
491
|
+
payload,
|
|
492
|
+
setup,
|
|
493
|
+
labTheme,
|
|
494
|
+
onRendered: resolve
|
|
495
|
+
}
|
|
496
|
+
) }) }, renders)
|
|
462
497
|
);
|
|
463
498
|
});
|
|
464
499
|
}
|