@bgub/fig-dom 0.1.0 → 0.1.2

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.
@@ -1,21 +1,25 @@
1
1
  import { ViewTransitionSurface } from "@bgub/fig";
2
2
  import "@bgub/fig-reconciler/view-transitions";
3
3
  //#region src/view-transition-pseudos.d.ts
4
+ /** Describes view transition pseudo element. */
4
5
  interface ViewTransitionPseudoElement {
5
6
  readonly selector: string;
6
7
  animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions): Animation;
7
8
  getAnimations(): Animation[];
8
9
  getComputedStyle(): CSSStyleDeclaration;
9
10
  }
11
+ /** Describes view transition pseudo elements. */
10
12
  interface ViewTransitionPseudoElements {
11
13
  readonly group: ViewTransitionPseudoElement;
12
14
  readonly imagePair: ViewTransitionPseudoElement;
13
15
  readonly new: ViewTransitionPseudoElement | null;
14
16
  readonly old: ViewTransitionPseudoElement | null;
15
17
  }
18
+ /** Gets view transition pseudo elements. */
16
19
  declare function getViewTransitionPseudoElements(surface: ViewTransitionSurface): ViewTransitionPseudoElements;
17
20
  //#endregion
18
21
  //#region src/view-transitions.d.ts
22
+ /** Enables view transitions. */
19
23
  declare function enableViewTransitions(): void;
20
24
  //#endregion
21
25
  export { type ViewTransitionPseudoElement, type ViewTransitionPseudoElements, enableViewTransitions, getViewTransitionPseudoElements };
@@ -1 +1 @@
1
- {"version":3,"file":"view-transitions.js","names":[],"sources":["../src/view-transition-pseudos.ts","../src/view-transition.ts","../src/view-transitions.ts"],"sourcesContent":["import type { ViewTransitionSurface } from \"@bgub/fig\";\nimport type { ViewTransitionSurfaceSnapshots } from \"@bgub/fig-reconciler/view-transitions\";\n\nexport interface ViewTransitionPseudoElement {\n readonly selector: string;\n animate(\n keyframes: Keyframe[] | PropertyIndexedKeyframes | null,\n options?: number | KeyframeAnimationOptions,\n ): Animation;\n getAnimations(): Animation[];\n getComputedStyle(): CSSStyleDeclaration;\n}\n\nexport interface ViewTransitionPseudoElements {\n readonly group: ViewTransitionPseudoElement;\n readonly imagePair: ViewTransitionPseudoElement;\n readonly new: ViewTransitionPseudoElement | null;\n readonly old: ViewTransitionPseudoElement | null;\n}\n\nconst domSurfaces = new WeakMap<\n ViewTransitionSurface,\n { owner: Document; snapshots: ViewTransitionSurfaceSnapshots }\n>();\n\nexport function createDOMViewTransitionSurface(\n element: Element,\n name: string,\n snapshots: ViewTransitionSurfaceSnapshots,\n): ViewTransitionSurface {\n const surface: ViewTransitionSurface = { name };\n domSurfaces.set(surface, { owner: element.ownerDocument, snapshots });\n return surface;\n}\n\nexport function getViewTransitionPseudoElements(\n surface: ViewTransitionSurface,\n): ViewTransitionPseudoElements {\n const resolved = domSurfaces.get(surface);\n if (resolved === undefined) {\n throw new Error(\n \"The view-transition surface was not created by Fig DOM. Read pseudo \" +\n \"elements from a surface passed to <ViewTransition onTransition>.\",\n );\n }\n\n const name = escapeViewTransitionName(surface.name);\n const pseudo = (kind: string): ViewTransitionPseudoElement =>\n createPseudoElement(\n resolved.owner.documentElement,\n `::view-transition-${kind}(${name})`,\n );\n return {\n group: pseudo(\"group\"),\n imagePair: pseudo(\"image-pair\"),\n new: resolved.snapshots.new ? pseudo(\"new\") : null,\n old: resolved.snapshots.old ? pseudo(\"old\") : null,\n };\n}\n\nfunction createPseudoElement(\n element: HTMLElement,\n selector: string,\n): ViewTransitionPseudoElement {\n return {\n selector,\n animate(keyframes, options): Animation {\n const resolvedOptions: KeyframeAnimationOptions =\n typeof options === \"number\"\n ? { duration: options, pseudoElement: selector }\n : { ...options, pseudoElement: selector };\n return element.animate(keyframes, resolvedOptions);\n },\n getAnimations(): Animation[] {\n return element.getAnimations({ subtree: true }).filter((animation) => {\n const effect = animation.effect;\n return (\n effect !== null &&\n \"target\" in effect &&\n effect.target === element &&\n \"pseudoElement\" in effect &&\n effect.pseudoElement === selector\n );\n });\n },\n getComputedStyle(): CSSStyleDeclaration {\n return (\n element.ownerDocument.defaultView?.getComputedStyle(\n element,\n selector,\n ) ?? getComputedStyle(element, selector)\n );\n },\n };\n}\n\nexport function escapeViewTransitionName(name: string): string {\n return globalThis.CSS?.escape?.(name) ?? name;\n}\n","import type { Props } from \"@bgub/fig\";\nimport {\n VIEW_TRANSITION_PENDING_PROPERTY,\n VIEW_TRANSITION_TIMEOUT_MS,\n} from \"@bgub/fig/internal\";\nimport type {\n ViewTransitionCommitOptions,\n ViewTransitionCommitResult,\n ViewTransitionHostConfig,\n ViewTransitionMutationResult,\n ViewTransitionSurfaceMeasurement,\n} from \"@bgub/fig-reconciler/view-transitions\";\nimport type { Container } from \"./events.ts\";\nimport {\n createDOMViewTransitionSurface,\n escapeViewTransitionName,\n} from \"./view-transition-pseudos.ts\";\n\ninterface RunningViewTransition {\n finished?: Promise<unknown>;\n ready?: Promise<unknown>;\n skipTransition?(): void;\n}\n\ninterface CancellableAnimation {\n cancel(): void;\n}\n\ntype ViewTransitionDocument = Document & {\n [VIEW_TRANSITION_PENDING_PROPERTY]?: RunningViewTransition | null;\n};\n\nconst interruptedTransitions = new WeakSet<object>();\n\nfunction commitViewTransition(\n container: Container,\n options: ViewTransitionCommitOptions,\n prepareSnapshot: () => void,\n mutate: () => ViewTransitionMutationResult,\n onReady: (active: boolean) => void,\n onFinished: () => void,\n): ViewTransitionCommitResult {\n const owner = ownerDocument(container);\n const start = owner.startViewTransition?.bind(owner);\n if (start === undefined) return false;\n\n let didMutate = false;\n let chained = false;\n let failedBeforeMutate = false;\n let restoreRootName: (() => void) | null = null;\n let mutationResult: ViewTransitionMutationResult | null = null;\n const notifyReady = once(onReady);\n const notifyFinished = once(onFinished);\n const finishUnanimated = (): void => {\n restoreRootName?.();\n notifyReady(false);\n notifyFinished();\n };\n\n const run = (): void => {\n prepareSnapshot();\n try {\n const update = () => {\n didMutate = true;\n mutationResult = mutate();\n // Before the new capture: when measurement shows every change is\n // contained in a named boundary, drop the root's own snapshot so the\n // page-wide overlay does not swallow pointer events for the\n // animation's duration.\n if (mutationResult.cancelRootSnapshot) {\n restoreRootName = cancelRootViewTransitionName(owner);\n }\n };\n const transition = start(\n options.types.length === 0\n ? update\n : { types: [...options.types], update },\n );\n if (transition !== undefined) {\n registerPendingTransition(owner, transition);\n hideCanceledSnapshots(owner, transition, () => mutationResult);\n }\n // Root-name restore waits for the transition to fully settle: putting\n // `view-transition-name: root` back on the live <html> while the\n // transition still runs can re-associate the live root with its\n // (force-hidden) captured group, which paints the page blank for the\n // rest of the animation.\n const settleAfterTransition = transitionSettled(transition);\n if (settleAfterTransition === undefined) {\n finishUnanimated();\n } else {\n if (transition?.ready === undefined) {\n onSettled(settleAfterTransition, () => notifyReady(false));\n } else {\n transition.ready.then(\n () => notifyReady(true),\n () => notifyReady(false),\n );\n }\n const finish = (): void => {\n restoreRootName?.();\n notifyFinished();\n };\n onSettled(settleAfterTransition, finish);\n }\n } catch (error) {\n if (!didMutate) {\n // A chained run has no caller to report a fallback to and the\n // reconciler stays frozen until mutate runs: commit unanimated.\n // A synchronous run reports `false` so the caller falls back.\n if (chained) {\n didMutate = true;\n try {\n mutate();\n } finally {\n finishUnanimated();\n }\n } else {\n failedBeforeMutate = true;\n finishUnanimated();\n }\n return;\n }\n finishUnanimated();\n if (!chained) throw error;\n // Chained commit errors were already routed by the reconciler's\n // deferred-commit handling; a residual throw here is a transition\n // failure that must not vanish into the pending promise.\n setTimeout(() => {\n throw error;\n });\n }\n };\n\n // Coordinate per document: the default serializes animations, while an\n // explicit interruption skips the active one but still waits for its\n // restoration before capturing the next old state. The reconciler normally\n // parks eligible commits upstream (render-during-wait via the adapter's\n // suspend hook), so for fig-dom this chain is a fallback for renderers that\n // wire commit without suspend — chaining freezes the root until the previous\n // animation settles or times out; parking keeps rendering live.\n if (coordinateActiveViewTransition(owner, options.interrupt, run)) {\n chained = true;\n return \"deferred\";\n }\n\n run();\n if (failedBeforeMutate) return false;\n return didMutate ? \"committed\" : \"deferred\";\n}\n\n// Remove the root element from the new capture, remembering how to restore\n// the author's inline style afterwards.\nfunction cancelRootViewTransitionName(\n owner: ViewTransitionDocument,\n): () => void {\n const element = owner.documentElement;\n const style = element.style;\n const previous = style.viewTransitionName ?? \"\";\n style.viewTransitionName = \"none\";\n\n return () => {\n style.viewTransitionName = previous;\n if (element.getAttribute(\"style\") === \"\") element.removeAttribute(\"style\");\n };\n}\n\n// Old snapshots were captured before the update callback ran and cannot be\n// un-captured; once the pseudo tree exists (ready), hide the groups of\n// measurement-canceled boundaries — and the root group plus the\n// ::view-transition overlay when the whole-page snapshot was dropped — with\n// filling zero-duration animations so untouched regions stay interactive\n// while the remaining groups animate. Mirrors React's\n// cancelViewTransitionName / cancelRootViewTransitionName.\nfunction hideCanceledSnapshots(\n owner: ViewTransitionDocument,\n transition: RunningViewTransition,\n getResult: () => ViewTransitionMutationResult | null,\n): void {\n // The filled zero-duration animations outlive their pseudo tree: without\n // an explicit cancel once the transition settles they would apply to the\n // next transition's pseudo tree and hide its groups.\n const hideAnimations: CancellableAnimation[] = [];\n const cancelHideAnimations = (): void => {\n for (const animation of hideAnimations) {\n try {\n animation.cancel();\n } catch {\n // Cancelling a finished pseudo animation is best-effort.\n }\n }\n hideAnimations.length = 0;\n };\n\n const hide = (): void => {\n const result = getResult();\n if (result === null) return;\n if (result.canceledNames.length === 0 && !result.cancelRootSnapshot) {\n return;\n }\n\n const element = owner.documentElement;\n if (typeof element.animate !== \"function\") return;\n\n const track = (animation: unknown): void => {\n if (\n typeof (animation as CancellableAnimation | null)?.cancel === \"function\"\n ) {\n hideAnimations.push(animation as CancellableAnimation);\n }\n };\n\n const hideGroup = (name: string): void => {\n track(\n element.animate(\n { opacity: [0, 0], pointerEvents: [\"none\", \"none\"] },\n {\n duration: 0,\n fill: \"forwards\",\n pseudoElement: `::view-transition-group(${name})`,\n },\n ),\n );\n };\n\n try {\n for (const name of result.canceledNames) {\n hideGroup(escapeViewTransitionName(name));\n }\n if (result.cancelRootSnapshot) {\n hideGroup(\"root\");\n track(\n element.animate(\n { height: [0, 0], width: [0, 0] },\n {\n duration: 0,\n fill: \"forwards\",\n pseudoElement: \"::view-transition\",\n },\n ),\n );\n }\n } catch {\n // Pseudo-element animation is best-effort: without it the canceled\n // snapshots fall back to the browser's default cross-fade.\n }\n };\n\n const ready = transition.ready ?? transition.finished;\n if (ready === undefined) hide();\n else ready.then(hide, () => undefined);\n\n const settled = transitionSettled(transition);\n onSettled(settled, cancelHideAnimations);\n}\n\nfunction registerPendingTransition(\n owner: ViewTransitionDocument,\n transition: RunningViewTransition,\n): void {\n owner[VIEW_TRANSITION_PENDING_PROPERTY] = transition;\n const release = (): void => {\n if (owner[VIEW_TRANSITION_PENDING_PROPERTY] === transition) {\n owner[VIEW_TRANSITION_PENDING_PROPERTY] = null;\n }\n };\n onSettled(transitionSettled(transition), release);\n}\n\n// React caps suspended commits at 60 seconds. Besides preventing a broken or\n// infinite animation from parking work forever, releasing the document mutex\n// lets the resumed commit start a new transition, which ends the stale one.\nfunction coordinateActiveViewTransition(\n owner: ViewTransitionDocument,\n interrupt: boolean,\n onFinished: () => void,\n): boolean {\n const pending = owner[VIEW_TRANSITION_PENDING_PROPERTY];\n if (pending == null) return false;\n const settled = transitionSettled(pending);\n if (settled === undefined) return false;\n\n let waiting = true;\n function finish(): void {\n if (!waiting) return;\n waiting = false;\n clearTimeout(timeout);\n if (owner[VIEW_TRANSITION_PENDING_PROPERTY] === pending) {\n owner[VIEW_TRANSITION_PENDING_PROPERTY] = null;\n }\n onFinished();\n }\n\n const timeout = setTimeout(finish, VIEW_TRANSITION_TIMEOUT_MS);\n onSettled(settled, finish);\n if (\n interrupt &&\n pending.skipTransition !== undefined &&\n !interruptedTransitions.has(pending)\n ) {\n interruptedTransitions.add(pending);\n try {\n pending.skipTransition();\n } catch {\n interruptedTransitions.delete(pending);\n // A failed interruption falls back to waiting for normal settlement.\n }\n }\n return true;\n}\n\nfunction onSettled(\n promise: Promise<unknown> | undefined,\n callback: () => void,\n): void {\n if (promise === undefined) callback();\n else promise.then(callback, callback);\n}\n\nfunction once<Args extends unknown[]>(\n callback: (...args: Args) => void,\n): (...args: Args) => void {\n let called = false;\n return (...args) => {\n if (called) return;\n called = true;\n callback(...args);\n };\n}\n\nfunction transitionSettled(\n transition: RunningViewTransition | undefined,\n): Promise<unknown> | undefined {\n return transition?.finished ?? transition?.ready;\n}\n\nfunction measureViewTransitionSurface(\n element: Element,\n): ViewTransitionSurfaceMeasurement | null {\n if (typeof element.getBoundingClientRect !== \"function\") return null;\n\n const rect = element.getBoundingClientRect();\n const view = element.ownerDocument?.defaultView ?? null;\n const inViewport =\n view === null\n ? true\n : rect.bottom >= 0 &&\n rect.right >= 0 &&\n rect.top <= view.innerHeight &&\n rect.left <= view.innerWidth;\n let absolutelyPositioned = false;\n try {\n absolutelyPositioned =\n view?.getComputedStyle(element).position === \"absolute\";\n } catch {\n // Detached elements or minimal test environments: assume static\n // positioning, the conservative choice (resizes keep the root snapshot).\n }\n\n return {\n absolutelyPositioned,\n height: rect.height,\n inViewport,\n width: rect.width,\n x: rect.left,\n y: rect.top,\n };\n}\n\nfunction applyViewTransitionName(\n element: Element,\n name: string,\n className: string | null,\n): void {\n const style = (element as HTMLElement).style;\n\n style.viewTransitionName = escapeViewTransitionName(name);\n if (className !== null) style.viewTransitionClass = className;\n}\n\nfunction restoreViewTransitionName(element: Element, props: Props): void {\n const style = (element as HTMLElement).style;\n const styleProp = props.style;\n const name =\n styleProp?.viewTransitionName ?? styleProp?.[\"view-transition-name\"];\n const className =\n styleProp?.viewTransitionClass ?? styleProp?.[\"view-transition-class\"];\n\n style.viewTransitionName = styleValue(name);\n style.viewTransitionClass = styleValue(className);\n}\n\nfunction ownerDocument(container: Container): ViewTransitionDocument {\n return (container.ownerDocument ?? document) as ViewTransitionDocument;\n}\n\nfunction styleValue(value: unknown): string {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return String(value).trim();\n }\n\n return \"\";\n}\n\nexport const viewTransitionHostConfig: ViewTransitionHostConfig<\n Container,\n Element\n> = {\n commit: commitViewTransition,\n apply: applyViewTransitionName,\n restore: restoreViewTransitionName,\n measure: measureViewTransitionSurface,\n createSurface: createDOMViewTransitionSurface,\n // Park eligible commits behind the shared per-document mutex while\n // rendering continues, then re-schedule once the transition settles.\n suspend(container, options, onFinished) {\n return coordinateActiveViewTransition(\n ownerDocument(container),\n options.interrupt,\n onFinished,\n );\n },\n};\n","import { createViewTransitionCommitCoordinator } from \"@bgub/fig-reconciler/view-transitions\";\nimport { domRenderer } from \"./renderer.ts\";\nimport { viewTransitionHostConfig } from \"./view-transition.ts\";\n\nexport {\n getViewTransitionPseudoElements,\n type ViewTransitionPseudoElement,\n type ViewTransitionPseudoElements,\n} from \"./view-transition-pseudos.ts\";\n\nconst coordinator = createViewTransitionCommitCoordinator(\n viewTransitionHostConfig,\n);\n\nexport function enableViewTransitions(): void {\n domRenderer.installCommitCoordinator(coordinator);\n}\n"],"mappings":"+OAoBA,MAAM,EAAc,IAAI,QAKxB,SAAgB,EACd,EACA,EACA,EACuB,CACvB,IAAM,EAAiC,CAAE,MAAK,EAE9C,OADA,EAAY,IAAI,EAAS,CAAE,MAAO,EAAQ,cAAe,WAAU,CAAC,EAC7D,CACT,CAEA,SAAgB,EACd,EAC8B,CAC9B,IAAM,EAAW,EAAY,IAAI,CAAO,EACxC,GAAI,IAAa,IAAA,GACf,MAAU,MACR,sIAEF,EAGF,IAAM,EAAO,EAAyB,EAAQ,IAAI,EAC5C,EAAU,GACd,EACE,EAAS,MAAM,gBACf,qBAAqB,EAAK,GAAG,EAAK,EACpC,EACF,MAAO,CACL,MAAO,EAAO,OAAO,EACrB,UAAW,EAAO,YAAY,EAC9B,IAAK,EAAS,UAAU,IAAM,EAAO,KAAK,EAAI,KAC9C,IAAK,EAAS,UAAU,IAAM,EAAO,KAAK,EAAI,IAChD,CACF,CAEA,SAAS,EACP,EACA,EAC6B,CAC7B,MAAO,CACL,WACA,QAAQ,EAAW,EAAoB,CACrC,IAAM,EACJ,OAAO,GAAY,SAC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rB,EACT,CCxYA,MAAM,EAAc,EAClB,CD6YA,OAAQ,EACR,MAAO,EACP,QAAS,EACT,QAAS,EACT,cAAe,EAGf,QAAQ,EAAW,EAAS,EAAY,CACtC,OAAO,EACL,EAAc,CAAS,EACvB,EAAQ,UACR,CACF,CACF,CC1ZA,CACF,EAEA,SAAgB,GAA8B,CAC5C,EAAY,yBAAyB,CAAW,CAClD"}
1
+ {"version":3,"file":"view-transitions.js","names":[],"sources":["../src/view-transition-pseudos.ts","../src/view-transition.ts","../src/view-transitions.ts"],"sourcesContent":["import type { ViewTransitionSurface } from \"@bgub/fig\";\nimport type { ViewTransitionSurfaceSnapshots } from \"@bgub/fig-reconciler/view-transitions\";\n\n/** Describes view transition pseudo element. */\nexport interface ViewTransitionPseudoElement {\n readonly selector: string;\n animate(\n keyframes: Keyframe[] | PropertyIndexedKeyframes | null,\n options?: number | KeyframeAnimationOptions,\n ): Animation;\n getAnimations(): Animation[];\n getComputedStyle(): CSSStyleDeclaration;\n}\n\n/** Describes view transition pseudo elements. */\nexport interface ViewTransitionPseudoElements {\n readonly group: ViewTransitionPseudoElement;\n readonly imagePair: ViewTransitionPseudoElement;\n readonly new: ViewTransitionPseudoElement | null;\n readonly old: ViewTransitionPseudoElement | null;\n}\n\nconst domSurfaces = new WeakMap<\n ViewTransitionSurface,\n { owner: Document; snapshots: ViewTransitionSurfaceSnapshots }\n>();\n\nexport function createDOMViewTransitionSurface(\n element: Element,\n name: string,\n snapshots: ViewTransitionSurfaceSnapshots,\n): ViewTransitionSurface {\n const surface: ViewTransitionSurface = { name };\n domSurfaces.set(surface, { owner: element.ownerDocument, snapshots });\n return surface;\n}\n\n/** Gets view transition pseudo elements. */\nexport function getViewTransitionPseudoElements(\n surface: ViewTransitionSurface,\n): ViewTransitionPseudoElements {\n const resolved = domSurfaces.get(surface);\n if (resolved === undefined) {\n throw new Error(\n \"The view-transition surface was not created by Fig DOM. Read pseudo \" +\n \"elements from a surface passed to <ViewTransition onTransition>.\",\n );\n }\n\n const name = escapeViewTransitionName(surface.name);\n const pseudo = (kind: string): ViewTransitionPseudoElement =>\n createPseudoElement(\n resolved.owner.documentElement,\n `::view-transition-${kind}(${name})`,\n );\n return {\n group: pseudo(\"group\"),\n imagePair: pseudo(\"image-pair\"),\n new: resolved.snapshots.new ? pseudo(\"new\") : null,\n old: resolved.snapshots.old ? pseudo(\"old\") : null,\n };\n}\n\nfunction createPseudoElement(\n element: HTMLElement,\n selector: string,\n): ViewTransitionPseudoElement {\n return {\n selector,\n animate(keyframes, options): Animation {\n const resolvedOptions: KeyframeAnimationOptions =\n typeof options === \"number\"\n ? { duration: options, pseudoElement: selector }\n : { ...options, pseudoElement: selector };\n return element.animate(keyframes, resolvedOptions);\n },\n getAnimations(): Animation[] {\n return element.getAnimations({ subtree: true }).filter((animation) => {\n const effect = animation.effect;\n return (\n effect !== null &&\n \"target\" in effect &&\n effect.target === element &&\n \"pseudoElement\" in effect &&\n effect.pseudoElement === selector\n );\n });\n },\n getComputedStyle(): CSSStyleDeclaration {\n return (\n element.ownerDocument.defaultView?.getComputedStyle(\n element,\n selector,\n ) ?? getComputedStyle(element, selector)\n );\n },\n };\n}\n\nexport function escapeViewTransitionName(name: string): string {\n return globalThis.CSS?.escape?.(name) ?? name;\n}\n","import type { Props } from \"@bgub/fig\";\nimport {\n VIEW_TRANSITION_PENDING_PROPERTY,\n VIEW_TRANSITION_TIMEOUT_MS,\n} from \"@bgub/fig/internal\";\nimport type {\n ViewTransitionCommitOptions,\n ViewTransitionCommitResult,\n ViewTransitionHostConfig,\n ViewTransitionMutationResult,\n ViewTransitionSurfaceMeasurement,\n} from \"@bgub/fig-reconciler/view-transitions\";\nimport type { Container } from \"./events.ts\";\nimport {\n createDOMViewTransitionSurface,\n escapeViewTransitionName,\n} from \"./view-transition-pseudos.ts\";\n\ninterface RunningViewTransition {\n finished?: Promise<unknown>;\n ready?: Promise<unknown>;\n skipTransition?(): void;\n}\n\ninterface CancellableAnimation {\n cancel(): void;\n}\n\ntype ViewTransitionDocument = Document & {\n [VIEW_TRANSITION_PENDING_PROPERTY]?: RunningViewTransition | null;\n};\n\nconst interruptedTransitions = new WeakSet<object>();\n\nfunction commitViewTransition(\n container: Container,\n options: ViewTransitionCommitOptions,\n prepareSnapshot: () => void,\n mutate: () => ViewTransitionMutationResult,\n onReady: (active: boolean) => void,\n onFinished: () => void,\n): ViewTransitionCommitResult {\n const owner = ownerDocument(container);\n const start = owner.startViewTransition?.bind(owner);\n if (start === undefined) return false;\n\n let didMutate = false;\n let chained = false;\n let failedBeforeMutate = false;\n let restoreRootName: (() => void) | null = null;\n let mutationResult: ViewTransitionMutationResult | null = null;\n const notifyReady = once(onReady);\n const notifyFinished = once(onFinished);\n const finishUnanimated = (): void => {\n restoreRootName?.();\n notifyReady(false);\n notifyFinished();\n };\n\n const run = (): void => {\n prepareSnapshot();\n try {\n const update = () => {\n didMutate = true;\n mutationResult = mutate();\n // Before the new capture: when measurement shows every change is\n // contained in a named boundary, drop the root's own snapshot so the\n // page-wide overlay does not swallow pointer events for the\n // animation's duration.\n if (mutationResult.cancelRootSnapshot) {\n restoreRootName = cancelRootViewTransitionName(owner);\n }\n };\n const transition = start(\n options.types.length === 0\n ? update\n : { types: [...options.types], update },\n );\n if (transition !== undefined) {\n registerPendingTransition(owner, transition);\n hideCanceledSnapshots(owner, transition, () => mutationResult);\n }\n // Root-name restore waits for the transition to fully settle: putting\n // `view-transition-name: root` back on the live <html> while the\n // transition still runs can re-associate the live root with its\n // (force-hidden) captured group, which paints the page blank for the\n // rest of the animation.\n const settleAfterTransition = transitionSettled(transition);\n if (settleAfterTransition === undefined) {\n finishUnanimated();\n } else {\n if (transition?.ready === undefined) {\n onSettled(settleAfterTransition, () => notifyReady(false));\n } else {\n transition.ready.then(\n () => notifyReady(true),\n () => notifyReady(false),\n );\n }\n const finish = (): void => {\n restoreRootName?.();\n notifyFinished();\n };\n onSettled(settleAfterTransition, finish);\n }\n } catch (error) {\n if (!didMutate) {\n // A chained run has no caller to report a fallback to and the\n // reconciler stays frozen until mutate runs: commit unanimated.\n // A synchronous run reports `false` so the caller falls back.\n if (chained) {\n didMutate = true;\n try {\n mutate();\n } finally {\n finishUnanimated();\n }\n } else {\n failedBeforeMutate = true;\n finishUnanimated();\n }\n return;\n }\n finishUnanimated();\n if (!chained) throw error;\n // Chained commit errors were already routed by the reconciler's\n // deferred-commit handling; a residual throw here is a transition\n // failure that must not vanish into the pending promise.\n setTimeout(() => {\n throw error;\n });\n }\n };\n\n // Coordinate per document: the default serializes animations, while an\n // explicit interruption skips the active one but still waits for its\n // restoration before capturing the next old state. The reconciler normally\n // parks eligible commits upstream (render-during-wait via the adapter's\n // suspend hook), so for fig-dom this chain is a fallback for renderers that\n // wire commit without suspend — chaining freezes the root until the previous\n // animation settles or times out; parking keeps rendering live.\n if (coordinateActiveViewTransition(owner, options.interrupt, run)) {\n chained = true;\n return \"deferred\";\n }\n\n run();\n if (failedBeforeMutate) return false;\n return didMutate ? \"committed\" : \"deferred\";\n}\n\n// Remove the root element from the new capture, remembering how to restore\n// the author's inline style afterwards.\nfunction cancelRootViewTransitionName(\n owner: ViewTransitionDocument,\n): () => void {\n const element = owner.documentElement;\n const style = element.style;\n const previous = style.viewTransitionName ?? \"\";\n style.viewTransitionName = \"none\";\n\n return () => {\n style.viewTransitionName = previous;\n if (element.getAttribute(\"style\") === \"\") element.removeAttribute(\"style\");\n };\n}\n\n// Old snapshots were captured before the update callback ran and cannot be\n// un-captured; once the pseudo tree exists (ready), hide the groups of\n// measurement-canceled boundaries — and the root group plus the\n// ::view-transition overlay when the whole-page snapshot was dropped — with\n// filling zero-duration animations so untouched regions stay interactive\n// while the remaining groups animate. Mirrors React's\n// cancelViewTransitionName / cancelRootViewTransitionName.\nfunction hideCanceledSnapshots(\n owner: ViewTransitionDocument,\n transition: RunningViewTransition,\n getResult: () => ViewTransitionMutationResult | null,\n): void {\n // The filled zero-duration animations outlive their pseudo tree: without\n // an explicit cancel once the transition settles they would apply to the\n // next transition's pseudo tree and hide its groups.\n const hideAnimations: CancellableAnimation[] = [];\n const cancelHideAnimations = (): void => {\n for (const animation of hideAnimations) {\n try {\n animation.cancel();\n } catch {\n // Cancelling a finished pseudo animation is best-effort.\n }\n }\n hideAnimations.length = 0;\n };\n\n const hide = (): void => {\n const result = getResult();\n if (result === null) return;\n if (result.canceledNames.length === 0 && !result.cancelRootSnapshot) {\n return;\n }\n\n const element = owner.documentElement;\n if (typeof element.animate !== \"function\") return;\n\n const track = (animation: unknown): void => {\n if (\n typeof (animation as CancellableAnimation | null)?.cancel === \"function\"\n ) {\n hideAnimations.push(animation as CancellableAnimation);\n }\n };\n\n const hideGroup = (name: string): void => {\n track(\n element.animate(\n { opacity: [0, 0], pointerEvents: [\"none\", \"none\"] },\n {\n duration: 0,\n fill: \"forwards\",\n pseudoElement: `::view-transition-group(${name})`,\n },\n ),\n );\n };\n\n try {\n for (const name of result.canceledNames) {\n hideGroup(escapeViewTransitionName(name));\n }\n if (result.cancelRootSnapshot) {\n hideGroup(\"root\");\n track(\n element.animate(\n { height: [0, 0], width: [0, 0] },\n {\n duration: 0,\n fill: \"forwards\",\n pseudoElement: \"::view-transition\",\n },\n ),\n );\n }\n } catch {\n // Pseudo-element animation is best-effort: without it the canceled\n // snapshots fall back to the browser's default cross-fade.\n }\n };\n\n const ready = transition.ready ?? transition.finished;\n if (ready === undefined) hide();\n else ready.then(hide, () => undefined);\n\n const settled = transitionSettled(transition);\n onSettled(settled, cancelHideAnimations);\n}\n\nfunction registerPendingTransition(\n owner: ViewTransitionDocument,\n transition: RunningViewTransition,\n): void {\n owner[VIEW_TRANSITION_PENDING_PROPERTY] = transition;\n const release = (): void => {\n if (owner[VIEW_TRANSITION_PENDING_PROPERTY] === transition) {\n owner[VIEW_TRANSITION_PENDING_PROPERTY] = null;\n }\n };\n onSettled(transitionSettled(transition), release);\n}\n\n// React caps suspended commits at 60 seconds. Besides preventing a broken or\n// infinite animation from parking work forever, releasing the document mutex\n// lets the resumed commit start a new transition, which ends the stale one.\nfunction coordinateActiveViewTransition(\n owner: ViewTransitionDocument,\n interrupt: boolean,\n onFinished: () => void,\n): boolean {\n const pending = owner[VIEW_TRANSITION_PENDING_PROPERTY];\n if (pending == null) return false;\n const settled = transitionSettled(pending);\n if (settled === undefined) return false;\n\n let waiting = true;\n function finish(): void {\n if (!waiting) return;\n waiting = false;\n clearTimeout(timeout);\n if (owner[VIEW_TRANSITION_PENDING_PROPERTY] === pending) {\n owner[VIEW_TRANSITION_PENDING_PROPERTY] = null;\n }\n onFinished();\n }\n\n const timeout = setTimeout(finish, VIEW_TRANSITION_TIMEOUT_MS);\n onSettled(settled, finish);\n if (\n interrupt &&\n pending.skipTransition !== undefined &&\n !interruptedTransitions.has(pending)\n ) {\n interruptedTransitions.add(pending);\n try {\n pending.skipTransition();\n } catch {\n interruptedTransitions.delete(pending);\n // A failed interruption falls back to waiting for normal settlement.\n }\n }\n return true;\n}\n\nfunction onSettled(\n promise: Promise<unknown> | undefined,\n callback: () => void,\n): void {\n if (promise === undefined) callback();\n else promise.then(callback, callback);\n}\n\nfunction once<Args extends unknown[]>(\n callback: (...args: Args) => void,\n): (...args: Args) => void {\n let called = false;\n return (...args) => {\n if (called) return;\n called = true;\n callback(...args);\n };\n}\n\nfunction transitionSettled(\n transition: RunningViewTransition | undefined,\n): Promise<unknown> | undefined {\n return transition?.finished ?? transition?.ready;\n}\n\nfunction measureViewTransitionSurface(\n element: Element,\n): ViewTransitionSurfaceMeasurement | null {\n if (typeof element.getBoundingClientRect !== \"function\") return null;\n\n const rect = element.getBoundingClientRect();\n const view = element.ownerDocument?.defaultView ?? null;\n const inViewport =\n view === null\n ? true\n : rect.bottom >= 0 &&\n rect.right >= 0 &&\n rect.top <= view.innerHeight &&\n rect.left <= view.innerWidth;\n let absolutelyPositioned = false;\n try {\n absolutelyPositioned =\n view?.getComputedStyle(element).position === \"absolute\";\n } catch {\n // Detached elements or minimal test environments: assume static\n // positioning, the conservative choice (resizes keep the root snapshot).\n }\n\n return {\n absolutelyPositioned,\n height: rect.height,\n inViewport,\n width: rect.width,\n x: rect.left,\n y: rect.top,\n };\n}\n\nfunction applyViewTransitionName(\n element: Element,\n name: string,\n className: string | null,\n): void {\n const style = (element as HTMLElement).style;\n\n style.viewTransitionName = escapeViewTransitionName(name);\n if (className !== null) style.viewTransitionClass = className;\n}\n\nfunction restoreViewTransitionName(element: Element, props: Props): void {\n const style = (element as HTMLElement).style;\n const styleProp = props.style;\n const name =\n styleProp?.viewTransitionName ?? styleProp?.[\"view-transition-name\"];\n const className =\n styleProp?.viewTransitionClass ?? styleProp?.[\"view-transition-class\"];\n\n style.viewTransitionName = styleValue(name);\n style.viewTransitionClass = styleValue(className);\n}\n\nfunction ownerDocument(container: Container): ViewTransitionDocument {\n return (container.ownerDocument ?? document) as ViewTransitionDocument;\n}\n\nfunction styleValue(value: unknown): string {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return String(value).trim();\n }\n\n return \"\";\n}\n\nexport const viewTransitionHostConfig: ViewTransitionHostConfig<\n Container,\n Element\n> = {\n commit: commitViewTransition,\n apply: applyViewTransitionName,\n restore: restoreViewTransitionName,\n measure: measureViewTransitionSurface,\n createSurface: createDOMViewTransitionSurface,\n // Park eligible commits behind the shared per-document mutex while\n // rendering continues, then re-schedule once the transition settles.\n suspend(container, options, onFinished) {\n return coordinateActiveViewTransition(\n ownerDocument(container),\n options.interrupt,\n onFinished,\n );\n },\n};\n","/**\n * Opt-in DOM View Transition integration for Fig.\n *\n * @module\n */\nimport { createViewTransitionCommitCoordinator } from \"@bgub/fig-reconciler/view-transitions\";\nimport { domRenderer } from \"./renderer.ts\";\nimport { viewTransitionHostConfig } from \"./view-transition.ts\";\n\nexport {\n getViewTransitionPseudoElements,\n type ViewTransitionPseudoElement,\n type ViewTransitionPseudoElements,\n} from \"./view-transition-pseudos.ts\";\n\nconst coordinator = createViewTransitionCommitCoordinator(\n viewTransitionHostConfig,\n);\n\n/** Enables view transitions. */\nexport function enableViewTrans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,EAAK,WACpB,EAAuB,GAC3B,GAAI,CACF,EACE,GAAM,iBAAiB,CAAO,CAAC,CAAC,WAAa,UACjD,MAAQ,CAGR,CAEA,MAAO,CACL,uBACA,OAAQ,EAAK,OACb,aACA,MAAO,EAAK,MACZ,EAAG,EAAK,KACR,EAAG,EAAK,GACV,CACF,CAEA,SAAS,EACP,EACA,EACA,EACM,CACN,IAAM,EAAS,EAAwB,MAEvC,EAAM,mBAAqB,EAAyB,CAAI,EACpD,IAAc,OAAM,EAAM,oBAAsB,EACtD,CAEA,SAAS,EAA0B,EAAkB,EAAoB,CACvE,IAAM,EAAS,EAAwB,MACjC,EAAY,EAAM,MAClB,EACJ,GAAW,oBAAsB,IAAY,wBACzC,EACJ,GAAW,qBAAuB,IAAY,yBAEhD,EAAM,mBAAqB,EAAW,CAAI,EAC1C,EAAM,oBAAsB,EAAW,CAAS,CAClD,CAEA,SAAS,EAAc,EAA8C,CACnE,OAAQ,EAAU,eAAiB,QACrC,CAEA,SAAS,EAAW,EAAwB,CAK1C,OAJI,OAAO,GAAU,UAAY,OAAO,GAAU,SACzC,OAAO,CAAK,CAAC,CAAC,KAAK,EAGrB,EACT,CCnYA,MAAM,EAAc,EAClB,CDwYA,OAAQ,EACR,MAAO,EACP,QAAS,EACT,QAAS,EACT,cAAe,EAGf,QAAQ,EAAW,EAAS,EAAY,CACtC,OAAO,EACL,EAAc,CAAS,EACvB,EAAQ,UACR,CACF,CACF,CCrZA,CACF,EAGA,SAAgB,GAA8B,CAC5C,EAAY,yBAAyB,CAAW,CAClD"}
@@ -1,2 +1,2 @@
1
- import{a as e,i as t,n,o as r,r as i,t as a}from"./renderer-DNpdiLm2.js";import{assertPayloadCodecMatches as o,createPortalNode as s,jsonPayloadCodec as c,loadContextCapabilities as l}from"@bgub/fig/internal";import{dataResource as u,readData as d}from"@bgub/fig";import{decodePayloadStream as f}from"@bgub/fig/payload";const p=()=>void 0;async function m(e,t,r={}){let{signal:i}=t;if(i.aborted)throw await e.body?.cancel().catch(p),h(i);if(!e.ok)throw await e.body?.cancel().catch(p),Error(`Payload request failed with status ${e.status}.`);let a=e.body;if(a===null)throw Error(`Payload response did not include a body.`);try{o(c,e.headers.get(`content-type`))}catch(e){throw await a.cancel().catch(p),e}let s=l(t);return f(a,{hydrate:s?.hydrate,onHoleError:s?.attributeError,onStreamDone:e=>{e.status===`failed`&&console.error(`Payload decode failed after its root value published:`,e.error)},prepareAssets:r.prepareAssets??(e=>n(e)),retainAssets:r.retainAssets,resolveClientReference:r.resolveClientReference,signal:i})}function h(e){return e.reason??Error(`Payload request aborted.`)}function g(e){let t=new WeakMap,n=1;function r(e){if(e===null)return null;if(e===void 0)return[`undefined`];if(typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`)return Number.isNaN(e)?[`number`,`NaN`]:e===1/0?[`number`,`Infinity`]:e===-1/0?[`number`,`-Infinity`]:Object.is(e,-0)?[`number`,`-0`]:e;if(typeof e==`bigint`)return[`bigint`,e.toString()];if(typeof e==`symbol`){let t=Symbol.keyFor(e);if(t===void 0)throw Error(`Only global Symbol.for symbols can be serialized.`);return[`symbol`,t]}if(typeof e==`function`)throw Error(`Functions cannot be serialized into the payload.`);if(e instanceof Date){let t=e.toJSON();if(t===null)throw Error(`Invalid Date values cannot be serialized.`);return[`date`,t]}let i=t.get(e);if(i!==void 0)return[`ref`,i];let a=n++;if(t.set(e,a),Array.isArray(e))return[`array`,a,e.map(r)];if(e instanceof Map)return[`map`,a,Array.from(e,([e,t])=>[r(e),r(t)])];if(e instanceof Set)return[`set`,a,Array.from(e,r)];let o=Object.getPrototypeOf(e);if(o!==Object.prototype&&o!==null)throw Error(`Cannot serialize ${o?.constructor?.name??`object`} into the payload.`);let s=e;return[`object`,a,Object.keys(s).sort().map(e=>[e,r(s[e])])]}return r(e)}function _(e){let t=t=>{let n=v(t);return[...e.key,e.cacheKey===void 0?n:e.cacheKey(t)]},n=u({debugArgs:e.cacheKey===void 0?void 0:v,key:t,load:async(n,r)=>{let i=await e.load(n,{key:l(r)?.key??t(n),signal:r.signal});return m(i instanceof Response?i:new Response(i.stream,{headers:{"content-type":i.contentType}}),r,{prepareAssets:e.prepareAssets??e.load.prepareAssets,resolveClientReference:e.resolveClientReference??e.load.resolveClientReference,retainAssets:e.retainAssets??e.load.retainAssets})}}),r=Object.assign(function(e){return y(e),d(r,e)},n);return Object.defineProperty(r,"displayName",{configurable:!0,value:`Payload(${e.key[0]})`}),r}function v(e){return y(e),g(e)}function y(e){if(Object.hasOwn(e,`children`))throw Error(`Payload components do not accept children.`)}const b=a.flushSync;function x(e,t){let n=a.createRoot(e,t);return i(e,{run:e=>n.data.run(e)}),w(n,e)}function S(e,t,n){let r=a.hydrateRoot(e,t,n);return i(e,{hydrate:(t,n)=>a.hydrateTarget(e,t,n),run:e=>r.data.run(e)}),w(r,e)}function C(e,t,n=null){return s(e,t,n)}function w(e,n){return{...e,unmount:()=>{e.unmount(),t(n)}}}export{r as composeBind,_ as createPayloadComponent,C as createPortal,x as createRoot,b as flushSync,S as hydrateRoot,n as insertAssetResources,e as on};
1
+ import{a as e,i as t,n,o as r,r as i,t as a}from"./renderer-C0TsDuwu.js";import{assertPayloadCodecMatches as o,createPortalNode as s,jsonPayloadCodec as c,loadContextCapabilities as l}from"@bgub/fig/internal";import{dataResource as u,readData as d}from"@bgub/fig";import{decodePayloadStream as f}from"@bgub/fig/payload";const p=()=>void 0;async function m(e,t,r={}){let{signal:i}=t;if(i.aborted)throw await e.body?.cancel().catch(p),h(i);if(!e.ok)throw await e.body?.cancel().catch(p),Error(`Payload request failed with status ${e.status}.`);let a=e.body;if(a===null)throw Error(`Payload response did not include a body.`);try{o(c,e.headers.get(`content-type`))}catch(e){throw await a.cancel().catch(p),e}let s=l(t);return f(a,{hydrate:s?.hydrate,onHoleError:s?.attributeError,onStreamDone:e=>{e.status===`failed`&&console.error(`Payload decode failed after its root value published:`,e.error)},prepareAssets:r.prepareAssets??(e=>n(e)),retainAssets:r.retainAssets,resolveClientReference:r.resolveClientReference,signal:i})}function h(e){return e.reason??Error(`Payload request aborted.`)}function g(e){let t=new WeakMap,n=1;function r(e){if(e===null)return null;if(e===void 0)return[`undefined`];if(typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`)return Number.isNaN(e)?[`number`,`NaN`]:e===1/0?[`number`,`Infinity`]:e===-1/0?[`number`,`-Infinity`]:Object.is(e,-0)?[`number`,`-0`]:e;if(typeof e==`bigint`)return[`bigint`,e.toString()];if(typeof e==`symbol`){let t=Symbol.keyFor(e);if(t===void 0)throw Error(`Only global Symbol.for symbols can be serialized.`);return[`symbol`,t]}if(typeof e==`function`)throw Error(`Functions cannot be serialized into the payload.`);if(e instanceof Date){let t=e.toJSON();if(t===null)throw Error(`Invalid Date values cannot be serialized.`);return[`date`,t]}let i=t.get(e);if(i!==void 0)return[`ref`,i];let a=n++;if(t.set(e,a),Array.isArray(e))return[`array`,a,e.map(r)];if(e instanceof Map)return[`map`,a,Array.from(e,([e,t])=>[r(e),r(t)])];if(e instanceof Set)return[`set`,a,Array.from(e,r)];let o=Object.getPrototypeOf(e);if(o!==Object.prototype&&o!==null)throw Error(`Cannot serialize ${o?.constructor?.name??`object`} into the payload.`);let s=e;return[`object`,a,Object.keys(s).sort().map(e=>[e,r(s[e])])]}return r(e)}function _(e){let t=t=>{let n=v(t);return[...e.key,e.cacheKey===void 0?n:e.cacheKey(t)]},n=u({debugArgs:e.cacheKey===void 0?void 0:v,key:t,load:async(n,r)=>{let i=await e.load(n,{key:l(r)?.key??t(n),signal:r.signal});return m(i instanceof Response?i:new Response(i.stream,{headers:{"content-type":i.contentType}}),r,{prepareAssets:e.prepareAssets??e.load.prepareAssets,resolveClientReference:e.resolveClientReference??e.load.resolveClientReference,retainAssets:e.retainAssets??e.load.retainAssets})}}),r=Object.assign(function(e){return y(e),d(r,e)},n);return Object.defineProperty(r,"displayName",{configurable:!0,value:`Payload(${e.key[0]})`}),r}function v(e){return y(e),g(e)}function y(e){if(Object.hasOwn(e,`children`))throw Error(`Payload components do not accept children.`)}const b=a.flushSync;function x(e,t){let n=a.createRoot(e,t);return i(e,{run:e=>n.data.run(e)}),w(n,e)}function S(e,t,n){let r=a.hydrateRoot(e,t,n);return i(e,{hydrate:(t,n)=>a.hydrateTarget(e,t,n),run:e=>r.data.run(e)}),w(r,e)}function C(e,t,n=null){return s(e,t,n)}function w(e,n){return{...e,unmount:()=>{e.unmount(),t(n)}}}export{r as composeBind,_ as createPayloadComponent,C as createPortal,x as createRoot,b as flushSync,S as hydrateRoot,n as insertAssetResources,e as on};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/payload-decoder.ts","../src/payload-key.ts","../src/payload-component.ts","../src/index.ts"],"sourcesContent":["import type { AwaitedFigNode, DataResourceLoadContext } from \"@bgub/fig\";\nimport {\n assertPayloadCodecMatches,\n jsonPayloadCodec,\n loadContextCapabilities,\n} from \"@bgub/fig/internal\";\nimport {\n decodePayloadStream,\n type PayloadDecodeOptions,\n} from \"@bgub/fig/payload\";\nimport { insertAssetResources } from \"./asset-resources.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\nconst noop = (): void => undefined;\n\nexport type PayloadDecoderOptions = Pick<\n PayloadDecodeOptions,\n \"prepareAssets\" | \"resolveClientReference\" | \"retainAssets\"\n>;\n\n/**\n * Decodes a validated Payload response within one data-resource generation.\n * The root becomes the entry value, streamed holes keep filling for the\n * generation's lifetime, `data` rows hydrate through its guarded capability,\n * and discovered assets enter the document with dependent reveal gates.\n */\nexport async function decodePayloadResponse(\n response: Response,\n context: DataResourceLoadContext,\n options: PayloadDecoderOptions = {},\n): Promise<AwaitedFigNode> {\n const { signal } = context;\n if (signal.aborted) {\n await response.body?.cancel().catch(noop);\n throw abortReason(signal);\n }\n if (!response.ok) {\n await response.body?.cancel().catch(noop);\n throw new Error(`Payload request failed with status ${response.status}.`);\n }\n const body = response.body;\n if (body === null) {\n throw new Error(\"Payload response did not include a body.\");\n }\n try {\n assertPayloadCodecMatches(\n jsonPayloadCodec,\n response.headers.get(\"content-type\"),\n );\n } catch (error) {\n await body.cancel().catch(noop);\n throw error;\n }\n\n const capabilities = loadContextCapabilities(context);\n return decodePayloadStream(body, {\n // Absent outside a data store: data rows are ignored rather than hydrated.\n hydrate: capabilities?.hydrate,\n onHoleError: capabilities?.attributeError,\n // Post-root failures surface through the rejected holes they strand;\n // observing the stream end keeps a failure that no longer has a pending\n // slot from being silently discarded in development.\n onStreamDone: (result) => {\n if (__DEV__ && result.status === \"failed\") {\n console.error(\n \"Payload decode failed after its root value published:\",\n result.error,\n );\n }\n },\n prepareAssets:\n options.prepareAssets ?? ((assets) => insertAssetResources(assets)),\n retainAssets: options.retainAssets,\n resolveClientReference: options.resolveClientReference,\n signal,\n });\n}\n\nfunction abortReason(signal: AbortSignal): unknown {\n return signal.reason ?? new Error(\"Payload request aborted.\");\n}\n","import type { DataResourceKeyInput } from \"@bgub/fig\";\n\nexport function encodePayloadKey(value: unknown): DataResourceKeyInput {\n const ids = new WeakMap<object, number>();\n let nextId = 1;\n\n function encode(value: unknown): DataResourceKeyInput {\n if (value === null) return null;\n if (value === undefined) return [\"undefined\"];\n if (typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") {\n if (Number.isNaN(value)) return [\"number\", \"NaN\"];\n if (value === Infinity) return [\"number\", \"Infinity\"];\n if (value === -Infinity) return [\"number\", \"-Infinity\"];\n return Object.is(value, -0) ? [\"number\", \"-0\"] : value;\n }\n if (typeof value === \"bigint\") return [\"bigint\", value.toString()];\n if (typeof value === \"symbol\") {\n const key = Symbol.keyFor(value);\n if (key === undefined) {\n throw new Error(\"Only global Symbol.for symbols can be serialized.\");\n }\n return [\"symbol\", key];\n }\n if (typeof value === \"function\") {\n throw new Error(\"Functions cannot be serialized into the payload.\");\n }\n if (value instanceof Date) {\n const json = value.toJSON();\n if (json === null) {\n throw new Error(\"Invalid Date values cannot be serialized.\");\n }\n return [\"date\", json];\n }\n\n const existing = ids.get(value);\n if (existing !== undefined) return [\"ref\", existing];\n const id = nextId++;\n ids.set(value, id);\n\n if (Array.isArray(value)) {\n return [\"array\", id, value.map(encode)];\n }\n if (value instanceof Map) {\n return [\n \"map\",\n id,\n Array.from(value, ([key, item]) => [encode(key), encode(item)]),\n ];\n }\n if (value instanceof Set) {\n return [\"set\", id, Array.from(value, encode)];\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new Error(\n `Cannot serialize ${prototype?.constructor?.name ?? \"object\"} into the payload.`,\n );\n }\n const record = value as Record<string, unknown>;\n return [\n \"object\",\n id,\n Object.keys(record)\n .sort()\n .map((key) => [key, encode(record[key])]),\n ];\n }\n\n return encode(value);\n}\n","import {\n type AwaitedFigNode,\n dataResource,\n type DataResource,\n type DataResourceKey,\n type DataResourceKeyInput,\n type FigNode,\n readData,\n} from \"@bgub/fig\";\nimport { loadContextCapabilities } from \"@bgub/fig/internal\";\nimport {\n decodePayloadResponse,\n type PayloadDecoderOptions,\n} from \"./payload-decoder.ts\";\nimport { encodePayloadKey } from \"./payload-key.ts\";\n\nexport type PayloadSource =\n | Response\n | {\n contentType: string;\n stream: ReadableStream<Uint8Array>;\n };\n\nexport interface PayloadComponentLoadContext {\n key: DataResourceKey;\n signal: AbortSignal;\n}\n\nexport interface PayloadComponentLoader<\n TProps extends object,\n> extends PayloadDecoderOptions {\n (\n props: TProps,\n context: PayloadComponentLoadContext,\n ): PayloadSource | PromiseLike<PayloadSource>;\n}\n\nexport interface PayloadComponentOptions<\n TProps extends object,\n> extends PayloadDecoderOptions {\n cacheKey?: (props: TProps) => DataResourceKeyInput;\n key: DataResourceKey;\n load: PayloadComponentLoader<TProps>;\n}\n\nexport interface PayloadComponent<TProps extends object> extends DataResource<\n [TProps],\n AwaitedFigNode\n> {\n (props: TProps & { children?: FigNode }): FigNode;\n}\n\n/**\n * Creates a renderable Payload tree backed by Fig's ordinary data store.\n */\nexport function createPayloadComponent<TProps extends object>(\n options: PayloadComponentOptions<TProps>,\n): PayloadComponent<TProps> {\n const key = (props: TProps): DataResourceKey => {\n const serialized = serializedProps(props);\n return [\n ...options.key,\n options.cacheKey === undefined ? serialized : options.cacheKey(props),\n ];\n };\n const resource = dataResource<[TProps], AwaitedFigNode>({\n debugArgs: options.cacheKey === undefined ? undefined : serializedProps,\n key,\n load: async (props, context) => {\n const source = await options.load(props, {\n key: loadContextCapabilities(context)?.key ?? key(props),\n signal: context.signal,\n });\n const response =\n source instanceof Response\n ? source\n : new Response(source.stream, {\n headers: { \"content-type\": source.contentType },\n });\n return decodePayloadResponse(response, context, {\n prepareAssets: options.prepareAssets ?? options.load.prepareAssets,\n resolveClientReference:\n options.resolveClientReference ?? options.load.resolveClientReference,\n retainAssets: options.retainAssets ?? options.load.retainAssets,\n });\n },\n });\n\n const component: PayloadComponent<TProps> = Object.assign(\n function PayloadComponent(props: TProps & { children?: FigNode }): FigNode {\n rejectChildren(props);\n return readData(component, props);\n },\n resource,\n );\n Object.defineProperty(component, \"displayName\", {\n configurable: true,\n value: `Payload(${options.key[0]})`,\n });\n\n return component;\n}\n\nfunction serializedProps<TProps extends object>(\n props: TProps,\n): DataResourceKeyInput {\n rejectChildren(props);\n return encodePayloadKey(props);\n}\n\nfunction rejectChildren(props: object): void {\n if (Object.hasOwn(props, \"children\")) {\n throw new Error(\"Payload components do not accept children.\");\n }\n}\n","import type { FigNode, FigPortal, Key } from \"@bgub/fig\";\nimport { createPortalNode } from \"@bgub/fig/internal\";\nimport type {\n FigRoot,\n FigRootOptions,\n RecoverableErrorInfo,\n} from \"@bgub/fig-reconciler\";\nimport { composeBind } from \"./bind.ts\";\nimport {\n type EventCallback,\n type EventOptions,\n on,\n} from \"./event-descriptor.ts\";\nimport { type Container, registerRoot, unregisterRoot } from \"./events.ts\";\nimport { domRenderer } from \"./renderer.ts\";\n\nexport { insertAssetResources } from \"./asset-resources.ts\";\nexport type { Bind } from \"./bind.ts\";\nexport { composeBind };\nexport { type EventCallback, type EventOptions, on };\nexport type {\n EmptyPropValue,\n HostIntrinsicElements,\n HostProps,\n HostStyle,\n} from \"./jsx.ts\";\nexport {\n createPayloadComponent,\n type PayloadComponent,\n type PayloadComponentLoadContext,\n type PayloadComponentLoader,\n type PayloadComponentOptions,\n type PayloadSource,\n} from \"./payload-component.ts\";\n\nexport type { Container, FigRoot, FigRootOptions, RecoverableErrorInfo };\n\nexport const flushSync = domRenderer.flushSync;\n\nexport function createRoot(\n container: Container,\n options?: FigRootOptions,\n): FigRoot {\n const root = domRenderer.createRoot(container, options);\n registerRoot(container, { run: (callback) => root.data.run(callback) });\n return withEventTeardown(root, container);\n}\n\nexport function hydrateRoot(\n container: Container,\n children: FigNode,\n options?: FigRootOptions,\n): FigRoot {\n const root = domRenderer.hydrateRoot(container, children, options);\n registerRoot(container, {\n hydrate: (target, priority) =>\n domRenderer.hydrateTarget(container, target, priority),\n run: (callback) => root.data.run(callback),\n });\n return withEventTeardown(root, container);\n}\n\nexport function createPortal(\n children: FigNode,\n container: Container,\n key: Key | null = null,\n): FigPortal<Container> {\n return createPortalNode(children, container, key);\n}\n\n// Event routing lives outside the reconciler, so root teardown owns both.\nfunction withEventTeardown(root: FigRoot, container: Container): FigRoot {\n return {\n ...root,\n unmount: () => {\n root.unmount();\n unregisterRoot(container);\n },\n };\n}\n"],"mappings":"gUAeA,MAAM,MAAmB,IAAA,GAazB,eAAsB,EACpB,EACA,EACA,EAAiC,CAAC,EACT,CACzB,GAAM,CAAE,UAAW,EACnB,GAAI,EAAO,QAET,MADA,MAAM,EAAS,MAAM,OAAO,CAAC,CAAC,MAAM,CAAI,EAClC,EAAY,CAAM,EAE1B,GAAI,CAAC,EAAS,GAEZ,MADA,MAAM,EAAS,MAAM,OAAO,CAAC,CAAC,MAAM,CAAI,EAC9B,MAAM,sCAAsC,EAAS,OAAO,EAAE,EAE1E,IAAM,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EACd,EACA,EACA,EAAkB,KACI,CACtB,OAAO,EAAiB,EAAU,EAAW,CAAG,CAClD,CAGA,SAAS,EAAkB,EAAe,EAA+B,CACvE,MAAO,CACL,GAAG,EACH,YAAe,CACb,EAAK,QAAQ,EACb,EAAe,CAAS,CAC1B,CACF,CACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/payload-decoder.ts","../src/payload-key.ts","../src/payload-component.ts","../src/index.ts"],"sourcesContent":["import type { AwaitedFigNode, DataResourceLoadContext } from \"@bgub/fig\";\nimport {\n assertPayloadCodecMatches,\n jsonPayloadCodec,\n loadContextCapabilities,\n} from \"@bgub/fig/internal\";\nimport {\n decodePayloadStream,\n type PayloadDecodeOptions,\n} from \"@bgub/fig/payload\";\nimport { insertAssetResources } from \"./asset-resources.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\nconst noop = (): void => undefined;\n\nexport type PayloadDecoderOptions = Pick<\n PayloadDecodeOptions,\n \"prepareAssets\" | \"resolveClientReference\" | \"retainAssets\"\n>;\n\n/**\n * Decodes a validated Payload response within one data-resource generation.\n * The root becomes the entry value, streamed holes keep filling for the\n * generation's lifetime, `data` rows hydrate through its guarded capability,\n * and discovered assets enter the document with dependent reveal gates.\n */\nexport async function decodePayloadResponse(\n response: Response,\n context: DataResourceLoadContext,\n options: PayloadDecoderOptions = {},\n): Promise<AwaitedFigNode> {\n const { signal } = context;\n if (signal.aborted) {\n await response.body?.cancel().catch(noop);\n throw abortReason(signal);\n }\n if (!response.ok) {\n await response.body?.cancel().catch(noop);\n throw new Error(`Payload request failed with status ${response.status}.`);\n }\n const body = response.body;\n if (body === null) {\n throw new Error(\"Payload response did not include a body.\");\n }\n try {\n assertPayloadCodecMatches(\n jsonPayloadCodec,\n response.headers.get(\"content-type\"),\n );\n } catch (error) {\n await body.cancel().catch(noop);\n throw error;\n }\n\n const capabilities = loadContextCapabilities(context);\n return decodePayloadStream(body, {\n // Absent outside a data store: data rows are ignored rather than hydrated.\n hydrate: capabilities?.hydrate,\n onHoleError: capabilities?.attributeError,\n // Post-root failures surface through the rejected holes they strand;\n // observing the stream end keeps a failure that no longer has a pending\n // slot from being silently discarded in development.\n onStreamDone: (result) => {\n if (__DEV__ && result.status === \"failed\") {\n console.error(\n \"Payload decode failed after its root value published:\",\n result.error,\n );\n }\n },\n prepareAssets:\n options.prepareAssets ?? ((assets) => insertAssetResources(assets)),\n retainAssets: options.retainAssets,\n resolveClientReference: options.resolveClientReference,\n signal,\n });\n}\n\nfunction abortReason(signal: AbortSignal): unknown {\n return signal.reason ?? new Error(\"Payload request aborted.\");\n}\n","import type { DataResourceKeyInput } from \"@bgub/fig\";\n\nexport function encodePayloadKey(value: unknown): DataResourceKeyInput {\n const ids = new WeakMap<object, number>();\n let nextId = 1;\n\n function encode(value: unknown): DataResourceKeyInput {\n if (value === null) return null;\n if (value === undefined) return [\"undefined\"];\n if (typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") {\n if (Number.isNaN(value)) return [\"number\", \"NaN\"];\n if (value === Infinity) return [\"number\", \"Infinity\"];\n if (value === -Infinity) return [\"number\", \"-Infinity\"];\n return Object.is(value, -0) ? [\"number\", \"-0\"] : value;\n }\n if (typeof value === \"bigint\") return [\"bigint\", value.toString()];\n if (typeof value === \"symbol\") {\n const key = Symbol.keyFor(value);\n if (key === undefined) {\n throw new Error(\"Only global Symbol.for symbols can be serialized.\");\n }\n return [\"symbol\", key];\n }\n if (typeof value === \"function\") {\n throw new Error(\"Functions cannot be serialized into the payload.\");\n }\n if (value instanceof Date) {\n const json = value.toJSON();\n if (json === null) {\n throw new Error(\"Invalid Date values cannot be serialized.\");\n }\n return [\"date\", json];\n }\n\n const existing = ids.get(value);\n if (existing !== undefined) return [\"ref\", existing];\n const id = nextId++;\n ids.set(value, id);\n\n if (Array.isArray(value)) {\n return [\"array\", id, value.map(encode)];\n }\n if (value instanceof Map) {\n return [\n \"map\",\n id,\n Array.from(value, ([key, item]) => [encode(key), encode(item)]),\n ];\n }\n if (value instanceof Set) {\n return [\"set\", id, Array.from(value, encode)];\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new Error(\n `Cannot serialize ${prototype?.constructor?.name ?? \"object\"} into the payload.`,\n );\n }\n const record = value as Record<string, unknown>;\n return [\n \"object\",\n id,\n Object.keys(record)\n .sort()\n .map((key) => [key, encode(record[key])]),\n ];\n }\n\n return encode(value);\n}\n","import {\n type AwaitedFigNode,\n dataResource,\n type DataResource,\n type DataResourceKey,\n type DataResourceKeyInput,\n type FigNode,\n readData,\n} from \"@bgub/fig\";\nimport { loadContextCapabilities } from \"@bgub/fig/internal\";\nimport {\n decodePayloadResponse,\n type PayloadDecoderOptions,\n} from \"./payload-decoder.ts\";\nimport { encodePayloadKey } from \"./payload-key.ts\";\n\n/** Describes payload source. */\nexport type PayloadSource =\n | Response\n | {\n contentType: string;\n stream: ReadableStream<Uint8Array>;\n };\n\n/** Describes payload component load context. */\nexport interface PayloadComponentLoadContext {\n key: DataResourceKey;\n signal: AbortSignal;\n}\n\n/** Describes payload component loader. */\nexport interface PayloadComponentLoader<\n TProps extends object,\n> extends PayloadDecoderOptions {\n (\n props: TProps,\n context: PayloadComponentLoadContext,\n ): PayloadSource | PromiseLike<PayloadSource>;\n}\n\n/** Describes payload component options. */\nexport interface PayloadComponentOptions<\n TProps extends object,\n> extends PayloadDecoderOptions {\n cacheKey?: (props: TProps) => DataResourceKeyInput;\n key: DataResourceKey;\n load: PayloadComponentLoader<TProps>;\n}\n\n/** Describes payload component. */\nexport interface PayloadComponent<TProps extends object> extends DataResource<\n [TProps],\n AwaitedFigNode\n> {\n (props: TProps & { children?: FigNode }): FigNode;\n}\n\n/**\n * Creates a renderable Payload tree backed by Fig's ordinary data store.\n */\nexport function createPayloadComponent<TProps extends object>(\n options: PayloadComponentOptions<TProps>,\n): PayloadComponent<TProps> {\n const key = (props: TProps): DataResourceKey => {\n const serialized = serializedProps(props);\n return [\n ...options.key,\n options.cacheKey === undefined ? serialized : options.cacheKey(props),\n ];\n };\n const resource = dataResource<[TProps], AwaitedFigNode>({\n debugArgs: options.cacheKey === undefined ? undefined : serializedProps,\n key,\n load: async (props, context) => {\n const source = await options.load(props, {\n key: loadContextCapabilities(context)?.key ?? key(props),\n signal: context.signal,\n });\n const response =\n source instanceof Response\n ? source\n : new Response(source.stream, {\n headers: { \"content-type\": source.contentType },\n });\n return decodePayloadResponse(response, context, {\n prepareAssets: options.prepareAssets ?? options.load.prepareAssets,\n resolveClientReference:\n options.resolveClientReference ?? options.load.resolveClientReference,\n retainAssets: options.retainAssets ?? options.load.retainAssets,\n });\n },\n });\n\n const component: PayloadComponent<TProps> = Object.assign(\n function PayloadComponent(props: TProps & { children?: FigNode }): FigNode {\n rejectChildren(props);\n return readData(component, props);\n },\n resource,\n );\n Object.defineProperty(component, \"displayName\", {\n configurable: true,\n value: `Payload(${options.key[0]})`,\n });\n\n return component;\n}\n\nfunction serializedProps<TProps extends object>(\n props: TProps,\n): DataResourceKeyInput {\n rejectChildren(props);\n return encodePayloadKey(props);\n}\n\nfunction rejectChildren(props: object): void {\n if (Object.hasOwn(props, \"children\")) {\n throw new Error(\"Payload components do not accept children.\");\n }\n}\n","/**\n * Browser DOM rendering APIs for Fig applications.\n *\n * @module\n */\nimport type { FigNode, FigPortal, Key } from \"@bgub/fig\";\nimport { createPortalNode } from \"@bgub/fig/internal\";\nimport type {\n FigRoot,\n FigRootOptions,\n RecoverableErrorInfo,\n} from \"@bgub/fig-reconciler\";\nimport { composeBind } from \"./bind.ts\";\nimport {\n type EventCallback,\n type EventOptions,\n on,\n} from \"./event-descriptor.ts\";\nimport { type Container, registerRoot, unregisterRoot } from \"./events.ts\";\nimport { domRenderer } from \"./renderer.ts\";\n\nexport { insertAssetResources } from \"./asset-resources.ts\";\nexport type { Bind } from \"./bind.ts\";\nexport { composeBind };\nexport { type EventCallback, type EventOptions, on };\nexport type {\n EmptyPropValue,\n HostIntrinsicElements,\n HostProps,\n HostStyle,\n} from \"./jsx.ts\";\nexport {\n createPayloadComponent,\n type PayloadComponent,\n type PayloadComponentLoadContext,\n type PayloadComponentLoader,\n type PayloadComponentOptions,\n type PayloadSource,\n} from \"./payload-component.ts\";\n\nexport type { Container, FigRoot, FigRootOptions, RecoverableErrorInfo };\n\n/** The flush sync. */\nexport const flushSync = domRenderer.flushSync;\n\n/** Creates root. */\nexport function createRoot(\n container: Container,\n options?: FigRootOptions,\n): FigRoot {\n const root = domRenderer.createRoot(container, options);\n registerRoot(container, { run: (callback) => root.data.run(callback) });\n return withEventTeardown(root, container);\n}\n\n/** Hydrates root. */\nexport function hydrateRoot(\n container: Container,\n children: FigNode,\n options?: FigRootOptions,\n): FigRoot {\n const root = domRenderer.hydrateRoot(container, children, options);\n registerRoot(container, {\n hydrate: (target, priority) =>\n domRenderer.hydrateTarget(container, target, priority),\n run: (callback) => root.data.run(callback),\n });\n return withEventTeardown(root, container);\n}\n\n/** Creates portal. */\nexport function createPortal(\n children: FigNode,\n container: Container,\n key: Key | null = null,\n): FigPortal<Container> {\n return createPortalNode(children, container, key);\n}\n\n// Event routing lives outside the reconciler, so root teardown owns both.\nfunction withEventTeardown(root: FigRoot, container: Container): FigRoot {\n return {\n ...root,\n unmount: () => {\n root.unmount();\n unregisterRoot(container);\n },\n };\n}\n"],"mappings":"gUAeA,MAAM,MAAmB,IAAA,GAazB,eAAsB,EACpB,EACA,EACA,EAAiC,CAAC,EACT,CACzB,GAAM,CAAE,UAAW,EACnB,GAAI,EAAO,QAET,MADA,MAAM,EAAS,MAAM,OAAO,CAAC,CAAC,MAAM,CAAI,EAClC,EAAY,CAAM,EAE1B,GAAI,CAAC,EAAS,GAEZ,MADA,MAAM,EAAS,MAAM,OAAO,CAAC,CAAC,MAAM,CAAI,EAC9B,MAAM,sCAAsC,EAAS,OAAO,EAAE,EAE1E,IAAM,EAAO,EAAS,KACt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EAAkB,KACI,CACtB,OAAO,EAAiB,EAAU,EAAW,CAAG,CAClD,CAGA,SAAS,EAAkB,EAAe,EAA+B,CACvE,MAAO,CACL,GAAG,EACH,YAAe,CACb,EAAK,QAAQ,EACb,EAAe,CAAS,CAC1B,CACF,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-internal-B05aFp_T.js","names":[],"sources":["../src/refresh-internal.ts"],"sourcesContent":["import type { RefreshUpdate } from \"@bgub/fig-reconciler/refresh\";\n\nlet scheduleDomRefresh: ((update: RefreshUpdate) => void) | null = null;\n\n// Updates that arrive before the @bgub/fig-dom main entry has evaluated (it\n// configures the scheduler as a module side effect). A code-split app can load\n// this entry first, and dropping those updates would silently skip a refresh.\nlet pendingUpdates: RefreshUpdate[] | null = null;\n\nexport function configureDomRefreshScheduler(\n scheduleRefresh: (update: RefreshUpdate) => void,\n): void {\n scheduleDomRefresh = scheduleRefresh;\n\n if (pendingUpdates !== null) {\n const updates = pendingUpdates;\n pendingUpdates = null;\n for (const update of updates) scheduleRefresh(update);\n }\n}\n\nexport function scheduleRefresh(update: RefreshUpdate): void {\n if (scheduleDomRefresh === null) {\n (pendingUpdates ??= []).push(update);\n return;\n }\n\n scheduleDomRefresh(update);\n}\n"],"mappings":"AAEA,IAAI,EAA+D,KAK/D,EAAyC,KAE7C,SAAgB,EACd,EACM,CAGN,GAFA,EAAqB,EAEjB,IAAmB,KAAM,CAC3B,IAAM,EAAU,EAChB,EAAiB,KACjB,IAAK,IAAM,KAAU,EAAS,EAAgB,CAAM,CACtD,CACF,CAEA,SAAgB,EAAgB,EAA6B,CAC3D,GAAI,IAAuB,KAAM,EAC9B,IAAmB,CAAC,EAAA,CAAG,KAAK,CAAM,EACnC,MACF,CAEA,EAAmB,CAAM,CAC3B"}
1
+ {"version":3,"file":"refresh-internal-B05aFp_T.js","names":[],"sources":["../src/refresh-internal.ts"],"sourcesContent":["import type { RefreshUpdate } from \"@bgub/fig-reconciler/refresh\";\n\nlet scheduleDomRefresh: ((update: RefreshUpdate) => void) | null = null;\n\n// Updates that arrive before the @bgub/fig-dom main entry has evaluated (it\n// configures the scheduler as a module side effect). A code-split app can load\n// this entry first, and dropping those updates would silently skip a refresh.\nlet pendingUpdates: RefreshUpdate[] | null = null;\n\nexport function configureDomRefreshScheduler(\n scheduleRefresh: (update: RefreshUpdate) => void,\n): void {\n scheduleDomRefresh = scheduleRefresh;\n\n if (pendingUpdates !== null) {\n const updates = pendingUpdates;\n pendingUpdates = null;\n for (const update of updates) scheduleRefresh(update);\n }\n}\n\n/** Schedules refresh. */\nexport function scheduleRefresh(update: RefreshUpdate): void {\n if (scheduleDomRefresh === null) {\n (pendingUpdates ??= []).push(update);\n return;\n }\n\n scheduleDomRefresh(update);\n}\n"],"mappings":"AAEA,IAAI,EAA+D,KAK/D,EAAyC,KAE7C,SAAgB,EACd,EACM,CAGN,GAFA,EAAqB,EAEjB,IAAmB,KAAM,CAC3B,IAAM,EAAU,EAChB,EAAiB,KACjB,IAAK,IAAM,KAAU,EAAS,EAAgB,CAAM,CACtD,CACF,CAGA,SAAgB,EAAgB,EAA6B,CAC3D,GAAI,IAAuB,KAAM,EAC9B,IAAmB,CAAC,EAAA,CAAG,KAAK,CAAM,EACnC,MACF,CAEA,EAAmB,CAAM,CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"refresh.js","names":[],"sources":["../src/refresh.ts"],"sourcesContent":["import {\n type RefreshAdapter,\n type RefreshFamily,\n type RefreshUpdate,\n setRefreshHandler,\n} from \"@bgub/fig-reconciler/refresh\";\nimport { scheduleRefresh } from \"./refresh-internal.ts\";\n\nexport type { RefreshFamily, RefreshUpdate };\nexport { scheduleRefresh };\n\nexport const domRefreshAdapter: RefreshAdapter = {\n scheduleRefresh,\n setRefreshHandler,\n};\n"],"mappings":"oHAWA,MAAa,EAAoC,CAC/C,kBACA,mBACF"}
1
+ {"version":3,"file":"refresh.js","names":[],"sources":["../src/refresh.ts"],"sourcesContent":["/**\n * DOM bindings for the Fig Fast Refresh runtime.\n *\n * @module\n */\nimport {\n type RefreshAdapter,\n type RefreshFamily,\n type RefreshUpdate,\n setRefreshHandler,\n} from \"@bgub/fig-reconciler/refresh\";\nimport { scheduleRefresh } from \"./refresh-internal.ts\";\n\nexport type { RefreshFamily, RefreshUpdate };\nexport { scheduleRefresh };\n\n/** The DOM refresh adapter. */\nexport const domRefreshAdapter: RefreshAdapter = {\n scheduleRefresh,\n setRefreshHandler,\n};\n"],"mappings":"oHAiBA,MAAa,EAAoC,CAC/C,kBACA,mBACF"}
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./refresh-internal-B05aFp_T.js";import{ACTIVITY_TEMPLATE_ATTRIBUTE as t,EARLY_EVENT_HANDLER_PROPERTY as n,EARLY_EVENT_QUEUE_PROPERTY as r,HYDRATION_SKIP_ATTRIBUTE as i,REPLAYABLE_EVENT_TYPES as a,SUSPENSE_CLIENT_MARKER as o,SUSPENSE_COMPLETED_MARKER as s,SUSPENSE_END_MARKER as c,SUSPENSE_PENDING_PREFIX as l,TEXT_SEPARATOR_DATA as u,VIEW_TRANSITION_CLASS_ATTRIBUTE as ee,VIEW_TRANSITION_NAME_ATTRIBUTE as d,assetResourceFromHostAttributes as te,assetResourceFromHostProps as f,assetResourceHostProps as ne,assetResourceKey as p,isFigAssetResource as re,markClientOnlyHostBehavior as ie,mixinSlot as ae,validateInstanceNesting as oe,validateTextNesting as se}from"@bgub/fig/internal";import{createMixin as ce}from"@bgub/fig";import{createRenderer as le,runWithEventPriority as m}from"@bgub/fig-reconciler";function ue(e,t){if(!h(e))return;let n=[];de(e,n);for(let e of n)t(e)}function de(e,t){t.push(e);for(let n=e.firstChild;n!==null;n=n.nextSibling)h(n)&&de(n,t)}function h(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===1}function g(e){return h(e)?`localName`in e&&typeof e.localName==`string`?e.localName.toLowerCase():`tagName`in e&&typeof e.tagName==`string`?e.tagName.toLowerCase():``:``}function fe(e){return e.namespaceURI===null||e.namespaceURI===`http://www.w3.org/1999/xhtml`}function _(e){return typeof e==`object`&&e&&`parentNode`in e?e.parentNode:null}function v(e){return e==null||e===!1}const y=new WeakMap,b=new WeakSet;function pe(...e){let t=e.filter(e=>typeof e==`function`);return(e,n)=>{for(let r of t)r(e,n)}}function me(e,t){let n=ye(t),r=y.get(e);if(n===null){r!==void 0&&S(r),y.delete(e);return}if(r===void 0){let t={callback:n,controller:null,strictRan:!1};y.set(e,t),x(e,t)}else r.callback!==n&&(S(r),r.callback=n,x(e,r))}function he(e){let t=y.get(e);t!==void 0&&x(e,t)}function ge(e){b.add(e);let t=y.get(e);t!==void 0&&S(t)}function _e(e){b.delete(e);let t=y.get(e);t!==void 0&&x(e,t)}function ve(e){let t=y.get(e);t!==void 0&&(S(t),y.delete(e))}function x(e,t){if(t.controller!==null||e.parentNode===null||b.has(e))return;let n=!1;n=!t.strictRan,t.strictRan=!0,t.controller=new AbortController,t.callback(e,t.controller.signal),n&&(S(t),t.controller=new AbortController,t.callback(e,t.controller.signal))}function S(e){e.controller?.abort(),e.controller=null}function ye(e){if(v(e))return null;if(typeof e==`function`)return e;throw Error(`The bind prop must be a function.`)}const C=Symbol.for(`fig.native-event-descriptors`),be=ce((e,t,n,r)=>{ie(e,`on()`);let i=e.props,a=i[C];a===void 0&&(a=[],Object.defineProperty(i,C,{configurable:!0,value:a})),a.push({callback:n,options:r,slot:ae(e),type:t})});function xe(e,t,n){return be(e,t,n)}const Se=[];function Ce(e){return e[C]??Se}function we(e,t,n){let r=w(e,`currentTarget`,{value:t});try{return n(e)}finally{r()}}function Te(e,t,n){let r={immediateStopped:!1,stopped:!t&&e.cancelBubble===!0},i=Ee(e,`stopPropagation`,()=>{r.stopped=!0}),a=Ee(e,`stopImmediatePropagation`,()=>{r.stopped=!0,r.immediateStopped=!0}),o=w(e,`cancelBubble`,{get:()=>r.stopped,set(e){e===!0&&(r.stopped=!0)}});try{return n(r)}finally{o(),a(),i(),r.stopped&&e.stopPropagation()}}function Ee(e,t,n){let r=Reflect.get(e,t);return typeof r==`function`?w(e,t,{value(){n(),r.call(e)}}):De}function w(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t);return Reflect.defineProperty(e,t,{configurable:!0,...n})?r===void 0?()=>{Reflect.deleteProperty(e,t)}:()=>{Reflect.defineProperty(e,t,r)}:De}function De(){}const T=new WeakMap,E=new WeakMap,Oe=new WeakMap,D=[],ke=new Set(a),Ae=new Set([`beforeinput`,`blur`,`change`,`click`,`contextmenu`,`dblclick`,`focus`,`focusin`,`focusout`,`input`,`keydown`,`keyup`,`mousedown`,`mouseup`,`pointerdown`,`pointerup`,`submit`,`touchend`,`touchstart`]),O=new Set([`drag`,`dragover`,`mousemove`,`pointermove`,`scroll`,`touchmove`,`wheel`]),je=new Set([...Ae,...O,`mouseenter`,`mouseleave`]),Me=new Set(`abort.beforetoggle.blur.cancel.canplay.canplaythrough.close.durationchange.emptied.encrypted.ended.error.focus.invalid.load.loadeddata.loadedmetadata.loadstart.mouseenter.mouseleave.pause.play.playing.pointerenter.pointerleave.progress.ratechange.resize.scroll.scrollend.seeked.seeking.stalled.suspend.timeupdate.toggle.volumechange.waiting`.split(`.`));let Ne=e=>e();function Pe(e){Ne=e}function Fe(e,t){let n=k(e);n.run=t.run,t.hydrate!==void 0&&(n.hydrate=t.hydrate,Je(e,n),Le(e))}const Ie=new WeakMap;function Le(e){let t=e.ownerDocument??e,i=Ie.get(t);if(i===void 0){let e=t[r];if(!Array.isArray(e))return;let o=t[n];if(typeof o==`function`&&typeof t.removeEventListener==`function`)for(let e of a)t.removeEventListener(e,o,!0);delete t[r],delete t[n],i=e,Ie.set(t,i)}let o=!1;for(let t=0;t<i.length;){let n=i[t];if(ke.has(n.type)&&ut(e,n.target)){i.splice(t,1),Xe(e,n.type,n),o=!0;continue}t+=1}o&&queueMicrotask(j)}function Re(e){let t=E.get(e);if(t!==void 0){ze(e);for(let n of t.listeners.values())e.removeEventListener(n.type,n.listener,n.capture);Be(e),E.delete(e);for(let t=D.length-1;t>=0;--t)D[t].root===e&&D.splice(t,1)}}function ze(e){let t=E.get(e);if(t!==void 0&&t.run!==null){t.hydrate=null;for(let[n,r]of t.hydrationListeners??[])e.removeEventListener(n,r,!0);t.hydrationListeners=null}}function Be(e){for(let t of E.get(e)?.portals??[])Be(t),A(t)}function k(e){let t=E.get(e);return t===void 0&&(t={hydrate:null,hydrationListeners:null,listeners:new Map,portalOwner:null,portals:null,run:null},E.set(e,t)),t}function Ve(e,t){let n=T.get(e)??[];if(n.length===0&&t.length===0)return;let r=new Map;for(let e of n)r.set(e.slot,e);let i=[],a=null;for(let n of t){let t=n.options?.capture===!0,o=n.options?.passive===!0,s=r.get(n.slot);r.delete(n.slot),s===void 0||s.type!==n.type||s.capture!==t||s.passive!==o?(a??=We(e),s!==void 0&&M(s),s=Ke(e,a.root,a.listenerTarget,n,t,o)):s.callback!==n.callback&&(s.callback=n.callback),i.push(s)}for(let e of r.values())M(e);i.length===0?T.delete(e):T.set(e,i)}function He(e){let t=T.get(e);if(t===void 0)return;let{listenerTarget:n,root:r}=We(e);for(let i of t)tt(e,r,n,i)}function Ue(e){let t=T.get(e);if(t!==void 0){for(let e of t)M(e);T.delete(e)}}function We(e){let t=I(e);if(t===null)return{listenerTarget:null,root:null};let n=E.get(t);return n===void 0?{listenerTarget:null,root:null}:{listenerTarget:t,root:n.portalOwner?.root??(n.run===null?null:t)}}function Ge(e,t,n){let r=k(e),i=I(n)??t;if(r.portalOwner!==null){if(r.portalOwner.root===t&&r.portalOwner.parentTarget===i){r.portalOwner={logicalParent:n,parentTarget:i,root:t};return}A(e)}r.portalOwner={logicalParent:n,parentTarget:i,root:t};let a=k(i);(a.portals??=new Set).add(e);for(let n of a.listeners.values())it(t,e,n.type,n.capture,n.passive)}function A(e){let t=E.get(e);if(!t?.portalOwner)return;let n=t.portalOwner;t.portalOwner=null;let r=E.get(n.parentTarget);if(r!==void 0){r.portals?.delete(e);for(let t of r.listeners.keys())at(e,t)}}function j(){let e=new Set;for(let t=0;t<D.length;){let n=D[t];if(!ut(n.listenerTarget??n.root,n.event.target)){D.splice(t,1);continue}if(Ze(n)===`blocked`){e.add(n.root),t+=1;continue}if(e.has(n.root)){t+=1;continue}D.splice(t,1),Qe(n)}}function Ke(e,t,n,r,i,a){let o={attachment:null,capture:i,callback:r.callback,controller:null,passive:a,slot:r.slot,type:r.type};return tt(e,t,n,o),o}function M(e){ot(e),F(e)}function qe(e,t,n,r,i,a){let o=I(a.target);if(o!==t&&((o===null?null:E.get(o)??null)?.portalOwner?.root===e||!ut(t,a.target))||Ye(e,n,a)===`blocked`)return;let s=N(e,t,n,r,i,a);s.length!==0&&Te(a,!1,e=>P(s,a,e))}function Je(e,t){if(t.hydrationListeners===null){t.hydrationListeners=[];for(let n of je){let r=t=>Ye(e,n,t);t.hydrationListeners.push([n,r]),e.addEventListener(n,r,{capture:!0,passive:dt(n)})}}}function Ye(e,t,n){let r=E.get(e)?.hydrate??null;if(r===null)return`none`;let i=Oe.get(n),a=i?.get(e);if(a!==void 0)return a;let o=L(t),s=m(o,()=>r(n.target,o));return i===void 0&&(i=new WeakMap,Oe.set(n,i)),i.set(e,s),s===`blocked`&&ke.has(t)&&Xe(e,t,n),s}function Xe(e,t,n){D.push({event:n,listenerTarget:I(n.target),root:e,type:t})}function Ze(e){let t=E.get(e.root)?.hydrate??null;if(t===null)return`none`;let n=L(e.type);return m(n,()=>t(e.event.target,n))}function Qe(e){let{event:t,root:n,type:r}=e,i=e.listenerTarget??e.root;Te(t,!0,e=>{P(N(n,i,r,!0,null,t),t,e),!(e.immediateStopped||e.stopped)&&P(N(n,i,r,!1,null,t),t,e)})}function N(e,t,n,r,i,a){let o=ct(e,t,a),s=[],c=r?-1:1;for(let t=r?o.length-1:0;t>=0&&t<o.length;t+=c){let a=o[t],c=T.get(a);if(c!==void 0)for(let t of c){let o=st(t);o!==e||t.type!==n||t.capture!==r||i!==null&&t.passive!==i||s.push({callback:t.callback,element:a,root:o,slot:t})}}return s}function P(e,t,n){let r=null;for(let i of e){if(n.immediateStopped)return;if(i.element!==r){if(r!==null&&n.stopped)return;r=i.element}try{$e(i,t)}finally{let e=i.slot;e.attachment===null&&F(e)}}}function $e(e,t){let n=e.slot;F(n),n.controller=new AbortController;let r=n.controller.signal;Ne(()=>{et(e.root,()=>m(L(n.type),()=>{we(t,e.element,t=>{e.callback(t,r)})}))})}function et(e,t){let n=e===null?null:E.get(e)?.run??null;return n===null?t():n(t)}function F(e){e.controller?.abort(),e.controller=null}function tt(e,t,n,r){Me.has(r.type)?nt(e,t,r):rt(t,n,r)}function nt(e,t,n){let r=n.attachment;if(r!==null){if(`element`in r&&r.element===e){t!==null&&(r.root=t);return}ot(n)}let i=t=>{try{$e({callback:n.callback,element:e,root:st(n),slot:n},t)}finally{n.attachment===null&&F(n)}};n.attachment={element:e,listener:i,root:t},e.addEventListener(n.type,i,{capture:n.capture,passive:n.passive})}function rt(e,t,n){if(e===null||t===null)return;let r=n.attachment;r!==null&&`listenerTarget`in r&&r.root===e&&r.listenerTarget===t||(ot(n),n.attachment={listenerTarget:t,root:e},it(e,t,n.type,n.capture,n.passive))}function it(e,t,n,r,i){let a=k(t).listeners,o=`${n}:${r}:${i}`,s=a.get(o);if(s===void 0){s={capture:r,count:0,listener:a=>qe(e,t,n,r,i,a),passive:i,type:n},t.addEventListener(n,s.listener,{capture:r,passive:i}),a.set(o,s);for(let a of E.get(t)?.portals??[])it(e,a,n,r,i)}s.count+=1}function at(e,t){let n=E.get(e)?.listeners,r=n?.get(t);if(n!==void 0&&r!==void 0&&(--r.count,!(r.count>0))){e.removeEventListener(r.type,r.listener,r.capture),n.delete(t);for(let n of E.get(e)?.portals??[])at(n,t)}}function ot(e){let t=e.attachment;t!==null&&(e.attachment=null,`element`in t?t.element.removeEventListener(e.type,t.listener,e.capture):at(t.listenerTarget,`${e.type}:${e.capture}:${e.passive}`))}function st(e){return e.attachment?.root??null}function ct(e,t,n){let r=[],i=n.composedPath?.();if(i!==void 0){let n=i.indexOf(t);if(n!==-1){for(let e=0;e<n;e+=1){let t=i[e];h(t)&&r.push(t)}return lt(r,e,t),r}}for(let e=n.target;e!==t&&(h(e)&&r.push(e),e=_(e),e!==null););return lt(r,e,t),r}function lt(e,t,n){let r=E.get(n)?.portalOwner??null;if(r===null||r.root!==t)return;let i=r.logicalParent;for(;i!==null&&i!==t;){if(ft(i)){let e=E.get(i)?.portalOwner??null;if(e!==null&&e.root===t){i=e.logicalParent;continue}}h(i)&&e.push(i),i=_(i)}}function ut(e,t){for(let n=t;n!==null;){if(n===e)return!0;n=_(n)}return!1}function I(e){for(let t=e;t!==null;){if(ft(t)){let e=E.get(t);if(e!==void 0&&(e.portalOwner!==null||e.run!==null))return t}t=_(t)}return null}function L(e){return Ae.has(e)?`discrete`:O.has(e)?`continuous`:`default`}function dt(e){return O.has(e)||e===`touchstart`||e===`touchend`}function ft(e){return typeof e==`object`&&!!e&&`addEventListener`in e&&`childNodes`in e}function pt(e){ue(e,e=>{he(e),He(e)})}function R(e){ue(e,e=>{ve(e),Ue(e)})}const z=new WeakMap;function mt(e){return H(e)||e===`checked`||e===`defaultChecked`}function ht(e,t,n,r,i,a){if(t===`select`&&H(n))return;if(t===`option`&&n===`value`){U(e,`value`,V(r));return}let o=a.initial===!0&&a.hydrating!==!0;n===`value`?v(r)||xt(e,r):n===`defaultValue`?bt(e,r,t,o&&i.value===void 0):n===`checked`?r!==void 0&&wt(e,r):n===`defaultChecked`&&Ct(e,r,o&&i.checked===void 0)}function gt(e,t,n,r){if(t!==`select`)return;let i=n.value!==void 0,a=i?n.value:n.defaultValue;if(v(a)){z.delete(e);return}let o=!i&&r.hydrating===!0,s={appliedDefault:z.get(e)?.appliedDefault===!0||!i,applyDefaultToInsertedOptions:!o&&!i&&r.initial===!0,controlled:i,selectedValues:Array.isArray(a)?new Set(a.map(String)):String(a)};z.set(e,s),!o&&(i||r.initial===!0)&&Tt(e,s.selectedValues)}function B(e,t=!1){let n=Ot(e);if(n===null)return;let r=z.get(n);r!==void 0&&(!r.controlled&&r.appliedDefault&&!t||!r.controlled&&t&&!r.applyDefaultToInsertedOptions||(Tt(e,r.selectedValues),r.controlled||(r.appliedDefault=!0)))}function _t(e,t){return(e===`input`||e===`textarea`||e===`select`)&&(t.value!==void 0||t.checked!==void 0)}function vt(e,t){if(mt(t))return(e===`textarea`||e===`select`)&&H(t)?null:t===`defaultValue`?`value`:t===`defaultChecked`?`checked`:t}function yt(e){if(g(e)!==`option`)return!1;let t=Ot(e),n=t===null?void 0:z.get(t);return n!==void 0&&Dt(e,n.selectedValues)}function bt(e,t,n,r){let i=V(t),a=i??``;`defaultValue`in e&&(e.defaultValue=a),n===`textarea`?e.textContent=a:U(e,`value`,i),r&&`value`in e&&St(e,a)}function xt(e,t){let n=V(t);n!==null&&(`value`in e?St(e,n):U(e,`value`,n))}function St(e,t){let n=e;n.value!==t&&(n.value=t)}function Ct(e,t,n){let r=t===!0;`defaultChecked`in e&&(e.defaultChecked=r),U(e,`checked`,r),n&&wt(e,t)}function wt(e,t){let n=t===!0;`checked`in e?e.checked=n:U(e,`checked`,n)}function V(e){return v(e)?null:String(e)}function Tt(e,t){if(g(e)===`option`){Et(e,t);return}kt(e,e=>{Et(e,t)})}function Et(e,t){e.selected=Dt(e,t)}function Dt(e,t){let n=e.getAttribute(`value`)??(e.textContent??``).replace(/\s+/g,` `).trim();return typeof t==`string`?n===t:t.has(n)}function Ot(e){let t=e.parentNode;for(;t!==null;){if(h(t)&&g(t)===`select`)return t;t=t.parentNode}return null}function kt(e,t){for(let n=e.firstChild;n!==null;){let e=n.nextSibling;h(n)&&(g(n)===`option`?t(n):kt(n,t)),n=e}}function H(e){return e===`value`||e===`defaultValue`}function U(e,t,n){v(n)?e.removeAttribute(t):e.setAttribute(t,String(n))}const At=new Set;function jt(e,t,n){typeof n==`string`&&n!==``&&Lt(`string`,`The style prop must be an object of properties; string styles are ignored.`);let r=e.style;if(r===void 0)return;let i=Pt(t),a=Pt(n);for(let e of Object.keys(i))e in a||It(r,e);for(let[e,t]of Object.entries(a))v(t)?It(r,e):Ft(r,e,t)}function Mt(e,t){if(e.length===0)return[];let n=document.createElement(`div`);jt(n,{},t);let r=new Set(Nt(n));return e.filter(e=>!r.has(e)).map(e=>`style.${e}`)}function Nt(e){let t=e.style;if(t===void 0)return[];if(typeof t.length==`number`&&typeof t.item==`function`){let e=[];for(let n=0;n<t.length;n+=1){let r=t.item(n);r!==``&&e.push(r)}return e}return Object.keys(t).filter(e=>t[e]!==``)}function Pt(e){return typeof e==`object`&&e?e:{}}function Ft(e,t,n){if(typeof n==`number`||typeof n==`bigint`){Lt(`${t}:${typeof n}`,`The style property "${t}" received a ${typeof n} (${String(n)}); Fig style values must be strings, so this style is ignored.`);return}t.startsWith(`--`)&&typeof e.setProperty==`function`?e.setProperty(t,String(n)):e[t]=n}function It(e,t){t.startsWith(`--`)&&typeof e.removeProperty==`function`?e.removeProperty(t):e[t]=``}function Lt(e,t){At.has(e)||(At.add(e),console.error(t))}const Rt=`http://www.w3.org/1999/xlink`;function W(e,t,n,r={}){(`mix`in t||`mix`in n)&&Ve(e,Ce(n));let i=g(e),a=fe(e),o=Object.keys(t);for(let e in n)Object.hasOwn(n,e)&&!Object.hasOwn(t,e)&&o.push(e);for(let s of o){let o=t[s],c=n[s];if(s!==`mix`){if(s===`bind`){o!==c&&me(e,c);continue}if(s===`unsafeHTML`){r.hydrating===!0?Yt(c):o!==c&&Jt(e,c);continue}if(Qt(s)){$t(s)&&Bt(s,Vt(s,i,n));continue}if(mt(s)){(s===`checked`||s===`defaultChecked`)&&c!==void 0&&typeof c!=`boolean`&&c!==null&&Bt(`${s}:${typeof c}`,`The "${s}" prop received a ${typeof c} (${String(c)}); Fig treats only \`true\` as checked, so this renders unchecked.`),ht(e,i,s,c,n,r);continue}o!==c&&(s===`style`?jt(e,o,c):Xt(e,G(s,a),c))}}gt(e,i,n,r),(i===`option`||i===`optgroup`)&&B(e)}const zt=new Set;function Bt(e,t){zt.has(e)||(zt.add(e),console.error(t))}function Vt(e,t,n){let r=e.endsWith(`Capture`)&&e.length>9&&e!==`onGotPointerCapture`&&e!==`onLostPointerCapture`,i=e.slice(2,r?-7:void 0),a=r?`, { capture: true }`:``,o=t=>`Fig has no "${e}" event props; use mix={on("${t}", handler${a})} instead.`;return i===`DoubleClick`?o(`dblclick`):i===`Change`&&Ht(t,n)?o(`input`)+` (React's onChange on text-editing controls fires per change like the native "input" event; on("change") fires only on commit.)`:o(i.toLowerCase())}function Ht(e,t){if(e===`textarea`)return!0;if(e!==`input`)return!1;let n=typeof t.type==`string`?t.type:`text`;return n!==`checkbox`&&n!==`radio`&&n!==`file`}function Ut(e,t){let n=[],r=!1;{let t=Nt(e);n=t.filter(t=>!Gt(e,t)),r=t.length>0&&n.length===0}let i=qt(e);W(e,{},t,{hydrating:!0}),t.suppressHydrationWarning!==!0&&Wt(e,t,n,i,r)}function Wt(e,t,n,r,i){if(r.length===0&&n.length===0)return;let a=new Set,o=g(e),s=fe(e);for(let e of Object.keys(t)){if(e===`bind`||Qt(e))continue;let t=Kt(o,e,s);t!==null&&a.add(t)}o===`option`&&yt(e)&&a.add(`selected`);let c=[];for(let e of r){let t=G(e,s);t.startsWith(`data-fig-`)||i&&t===`style`||a.has(t)||c.push(e)}c.push(...Mt(n,t.style)),c.length!==0&&console.error(`Hydration preserved extra server attributes or styles on <${o}>: ${c.sort().join(`, `)}. They were preserved, so this element now differs from a pure client render.`)}function Gt(e,t){let n=e.style,r,i;switch(t){case`view-transition-name`:case`viewTransitionName`:r=d,i=n.viewTransitionName||n.getPropertyValue?.(`view-transition-name`)||``;break;case`view-transition-class`:case`viewTransitionClass`:r=ee,i=n.viewTransitionClass||n.getPropertyValue?.(`view-transition-class`)||``;break;default:return!1}let a=e.getAttribute(r);if(a===null)return!1;let o=i.trim(),s=a.trim(),c=globalThis.CSS?.escape?.(s);return o===s||o===c}function Kt(e,t,n){let r=vt(e,t);return r===void 0?G(t,n):r}function qt(e){let t=e.attributes;if(t===void 0)return[];if(`length`in t&&typeof t.length==`number`&&`item`in t&&typeof t.item==`function`){let e=[];for(let n=0;n<t.length;n+=1){let r=t.item(n);r!==null&&e.push(r.name)}return e}return Symbol.iterator in t?Array.from(t,e=>e.name):Object.keys(t)}function Jt(e,t){let n=Yt(t);`innerHTML`in e&&(e.innerHTML=n??``)}function Yt(e){if(v(e))return null;if(typeof e==`string`)return e;throw Error(`The unsafeHTML prop must be a string.`)}function G(e,t){return t?e.toLowerCase():e}function Xt(e,t,n){if(v(n)){Zt(e,t);return}if(t===`xlink:href`){e.setAttributeNS(Rt,t,String(n));return}e.setAttribute(t,String(n))}function Zt(e,t){if(t===`xlink:href`){e.removeAttributeNS(Rt,`href`);return}e.removeAttribute(t)}function Qt(e){return e===`children`||e===`key`||e===`mix`||e===`suppressHydrationWarning`||e===`unsafeHTML`||$t(e)}function $t(e){return/^on[A-Z]/.test(e)}var en=class{element;resourceKind;kind=`metadata`;byOwner=new Map;rendered=null;winner;constructor(e,t,n,r){this.element=e,this.resourceKind=t,this.winner=n,this.byOwner.set(n,r),this.applyWinner()}acquire(e,t){let n=!this.byOwner.has(e);this.byOwner.set(e,t),n&&(this.winner=e),this.winner===e&&this.applyWinner()}update(e,t){if(!this.byOwner.has(e))throw Error(`Expected a live metadata claim.`);this.byOwner.set(e,t),this.winner===e&&this.applyWinner()}release(e){if(!this.byOwner.delete(e))throw Error(`Expected a live metadata claim.`);if(this.byOwner.size===0)return`empty`;if(this.winner!==e)return`retained`;let t=null;for(let e of this.byOwner.keys())t=e;if(t===null)throw Error(`Expected a live metadata claim.`);return this.winner=t,this.applyWinner(),`retained`}applyWinner(){let e=this.byOwner.get(this.winner);if(e===void 0)throw Error(`Expected a live metadata claim.`);W(this.element,this.rendered??{},e),this.resourceKind===`title`&&(this.element.textContent=tn(e.children)),this.rendered=e}};function tn(e){return e==null||typeof e==`boolean`?``:typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(tn).join(``):``}const nn=new WeakMap,K=new WeakMap;function rn(e,t,n){let r=J();if(r===null)return;let i=dn(e),a=dn(t);for(let[e]of i)a.has(e)||mn(r,e,n);for(let[e,t]of a)i.has(e)?(t.kind===`title`||t.kind===`meta`)&&pn(r,e,t,n):fn(r,t,n)}function an(e,t){let n=J(),r=f(e,t);if(n===null||r===null)return null;let i=p(r);if(X(r)){let t=document.createElement(e);return K.set(t,{key:i,kind:r.kind}),t}let a=n.entries.get(i);if(a?.kind===`metadata`)throw Error(`Expected a persistent resource entry.`);let o=a?.element??Z(n,i)??document.createElement(e);return a===void 0&&(n.entries.set(i,{count:0,element:o,kind:`persistent`,ready:null}),K.set(o,{key:i,kind:r.kind})),o}function on(e,t,n){let r=J();if(r===null)return e;let i=f(g(e),t);return i!==null&&X(i)?Y(r,i,t,n,e):sn(r,e)}function sn(e,t){let n=K.get(t);if(n===void 0){let e=Sn(t);if(e===null)return t;n={key:p(e),kind:e.kind},K.set(t,n)}let r=e.entries.get(n.key);if(r?.kind===`metadata`)throw Error(`Expected a persistent resource entry.`);return r!==void 0&&r.element!==t?(r.count+=1,vn(e,r.element)):(r===void 0?e.entries.set(n.key,{count:1,element:t,kind:`persistent`,ready:null}):r.count+=1,vn(e,t))}function q(e,t){let n=J(),r=K.get(e);if(n===null||r===void 0)return;let i=n.entries.get(r.key);if(i?.kind===`metadata`){hn(n,r.key,i,t);return}if(r.kind===`title`||r.kind===`meta`){K.delete(e),Cn(e);return}cn(n,e)}function cn(e,t){let n=K.get(t);if(n===void 0)return;let r=e.entries.get(n.key);if(r===void 0||r.element!==t){if(bn(e,t))return;K.delete(t);return}if(r.kind!==`persistent`)throw Error(`Expected a persistent resource entry.`);r.count>0&&--r.count}function ln(e,t,n,r){let i=g(e),a=f(i,n),o=K.get(e);if(a===null){let e=f(i,t),n=o?.key??(e===null?null:p(e)),r=n===null?``:` (asset "${n}")`;throw Error(`A hoisted <${i}>${r} cannot update into an ordinary in-tree element. Keep its asset classification stable or replace it with a different Fig element key.`)}let s=p(a),c=J();if(c===null)return W(e,t,n),e;let l=o===void 0?void 0:c.entries.get(o.key);if(l?.kind===`metadata`){if(!X(a)||s===o?.key)return l.update(r,X(a)?_n(a,n):n),l.element;q(e,r);let t=document.createElement(i);return W(t,{},n),a.kind===`title`&&(t.textContent=a.value),K.set(t,{key:p(a),kind:a.kind}),Y(c,a,n,r,t)}if(o===void 0||s===o.key)return W(e,t,n),e;q(e,r);let u=c.entries.get(s),ee=u?.kind===`persistent`&&u.count>0?u.element:void 0,d=an(i,n)??e;return d===e?(W(e,t,n),e):(ee!==d&&W(d,{},n),on(d,n,r))}function un(e){let t=J();if(t===null)return Promise.resolve();let n=[];for(let r of e){if(!re(r)||r.kind===`title`||r.kind===`meta`)continue;let e=Tn(r),i=p(e),a=t.entries.get(i)?.element,o=(a?.parentNode===t.head?a:null)??Z(t,i);if(o!==null){let r=t.entries.get(i);if(r?.kind===`metadata`)throw Error(`Expected a persistent resource entry.`);r?.element!==o&&(r={count:1,element:o,kind:`persistent`,ready:null},t.entries.set(i,r),K.set(o,{key:i,kind:e.kind}));let a=xn(t,e,i,r);a!==null&&n.push(a);continue}let s=kn(e),c={count:1,element:s,kind:`persistent`,ready:null};c.ready=En(e)?On(s).then(()=>{t.entries.get(i)===c&&(c.ready=null)}):null,t.entries.set(i,c),K.set(s,{key:i,kind:e.kind}),yn(t,s),c.ready!==null&&n.push(c.ready)}return n.length===0?Promise.resolve():Promise.all(n).then(()=>void 0)}function J(){if(typeof document>`u`||document.head==null)return null;let e=nn.get(document.head);return e===void 0&&(e={entries:new Map,head:document.head},nn.set(document.head,e)),e}function dn(e){let t=new Map;if(e===null)return t;let n=Array.isArray(e)?e:[e];for(let e of n){if(!re(e))continue;let n=Tn(e),r=p(n);(!t.has(r)||X(n))&&t.set(r,n)}return t}function fn(e,t,n){if(X(t)){Y(e,t,gn(t),n);return}let r=p(t),i=e.entries.get(r);if(i?.kind===`metadata`)throw Error(`Expected a persistent resource entry.`);let a=i?.element,o=a??Z(e,r)??kn(t);a===void 0&&(e.entries.set(r,{count:0,element:o,kind:`persistent`,ready:null}),K.set(o,{key:r,kind:t.kind})),sn(e,o)}function pn(e,t,n,r){let i=e.entries.get(t);if(i===void 0){fn(e,n,r);return}if(i.kind!==`metadata`)throw Error(`Expected a metadata resource entry.`);i.update(r,gn(n))}function mn(e,t,n){let r=e.entries.get(t);r!==void 0&&(r.kind===`metadata`?hn(e,t,r,n):cn(e,r.element))}function Y(e,t,n,r,i){let a=p(t),o=_n(t,n),s=e.entries.get(a);if(s?.kind===`persistent`)throw Error(`Expected a metadata resource entry.`);if(s===void 0){let n=Z(e,a)??i??document.createElement(t.kind);s=new en(n,t.kind,r,o),e.entries.set(a,s),K.set(n,{key:a,kind:t.kind})}else s.acquire(r,o);return vn(e,s.element)}function hn(e,t,n,r){n.release(r)!==`retained`&&(e.entries.delete(t),K.delete(n.element),Cn(n.element))}function gn(e){return e.kind===`title`?{children:e.value}:{charset:e.charset,content:e.content,"data-fig-resource-key":e.key,"http-equiv":e[`http-equiv`],name:e.name,property:e.property}}function _n(e,t){return e.kind===`title`?{...t,children:e.value}:t}function X(e){return e.kind===`title`||e.kind===`meta`}function vn(e,t){return t.parentNode!==e.head&&yn(e,t),pt(t),t}function yn(e,t){let n=wn(t);if(n===null){e.head.appendChild(t);return}let r=!1;for(let i=e.head.firstChild;i!==null;i=i.nextSibling){let a=h(i)?wn(i):null;if(a!==null){if(a===n)r=!0;else if(r){e.head.insertBefore(t,i);return}}}e.head.appendChild(t)}function Z(e,t){for(let n=e.head.firstChild;n!==null;n=n.nextSibling)if(h(n)){let e=Sn(n);if(e!==null&&p(e)===t)return n}return null}function bn(e,t){for(let n of e.entries.values())if(n.element===t)return!0;return!1}function xn(e,t,n,r){if(!En(t))return null;if(r.ready!==null)return r.ready;if(!Dn(r.element))return null;let i=On(r.element).then(()=>{e.entries.get(n)===r&&(r.ready=null)});return r.ready=i,i}function Sn(e){return te(g(e),t=>e.getAttribute(t))}function Cn(e){R(e),e.parentNode?.removeChild(e)}function wn(e){if(g(e)!==`link`)return null;let t=Sn(e);return t?.kind===`stylesheet`?t.precedence??``:null}function Tn(e){return e.kind===`font`?{as:`font`,crossorigin:e.crossorigin??`anonymous`,fetchpriority:e.fetchpriority,href:e.href,key:e.key,kind:`preload`,type:e.type}:e}function En(e){return e.kind!==`stylesheet`||e.blocking===`none`?!1:e.media===void 0||e.media===``||typeof matchMedia!=`function`||matchMedia(e.media).matches}function Dn(e){return g(e)===`link`&&e.getAttribute(`rel`)===`stylesheet`&&`sheet`in e&&e.sheet===null}function On(e){return new Promise(t=>{let n=()=>{e.removeEventListener(`load`,n),e.removeEventListener(`error`,n),t()};e.addEventListener(`load`,n),e.addEventListener(`error`,n)})}function kn(e){let t=document.createElement(e.kind===`script`?`script`:`link`),n=ne(e);for(let e of Object.keys(n)){let r=n[e];t.setAttribute(e,r===!0?``:r)}return t}function An(e){if(!$(e))return null;let t=Q(e);return t===null?null:jn(e,t)}function jn(e,t){let n=Mn(e);return n===null?null:{end:n,forceClientRender:!1,id:t.id,start:e,get error(){return Nn(e)},get status(){return Q(e)?.status??t.status}}}function Q(e){if(!$(e))return null;if(e.data===s)return{id:null,status:`completed`};if(e.data===o)return{id:null,status:`client-rendered`};let t=e.data.startsWith(l)?e.data.slice(l.length):null;return t!==null&&t!==``?{id:t,status:`pending`}:null}function Mn(e){let t=0;for(let n=e.nextSibling;n!==null;n=n.nextSibling)if($(n)){if(Q(n)!==null){t+=1;continue}if(n.data===c){if(t===0)return n;--t}}return null}function Nn(e){let t=e.nextSibling;return Bn(t)?{digest:t.dataset.dgst,message:t.dataset.msg}:null}function Pn(e){if(!Vn(e))return null;for(let t=e;t!==null;t=t.parentNode){let e=0;for(let n=t.previousSibling;n!==null;n=n.previousSibling)if($(n)){if(n.data===c){e+=1;continue}if(Q(n)!==null){if(e===0)return n;--e}}}return null}function Fn(e,t){if(!Vn(e))return!1;let n=t.start.parentNode,r=t.end.parentNode;if(n===null&&r===null)return!1;for(let i=e;i!==null;i=i.parentNode){if(i===t.start||i===t.end)return!1;if(n!==null&&i.parentNode===n)return In(i,t.start,t.end);if(r!==null&&r!==n&&i.parentNode===r)return Ln(i,t.end)}return!1}function In(e,t,n){for(let r=e;r!==null;r=r.previousSibling){if(r===t)return!0;if(r===n)return!1}return!1}function Ln(e,t){for(let n=e;n!==null;n=n.nextSibling)if(n===t)return!0;return!1}function Rn(e){for(let t=e.start;t!==null;){let n=t.nextSibling;if(zn(t),t===e.end)return;t=n}}function zn(e){e.parentNode?.removeChild(e)}function $(e){return typeof e==`object`&&!!e&&`data`in e&&`nodeType`in e&&e.nodeType===8}function Bn(e){return typeof e==`object`&&!!e&&`dataset`in e}function Vn(e){return typeof e==`object`&&!!e&&`parentNode`in e}function Hn(e){return e.nodeType===9}const Un=le({createInstance:qn,createTextInstance:e=>document.createTextNode(e),validateInstanceNesting:(e,t,n)=>{oe(e,n)},validateTextNesting:(e,t)=>{se(e,t)},containerType:e=>h(e)?g(e):null,appendInitialChild:(e,t)=>{e.appendChild(t),h(t)&&or(t)&&B(t,!0)},finalizeInitialInstance:(e,t)=>W(e,{},t,{initial:!0}),setTextContent:(e,t)=>{e.textContent!==t&&(e.textContent=t)},getFirstHydratableChild:Qn,getNextHydratableSibling:e=>$n(e.nextSibling),canHydrateInstance:Kn,canHydrateTextInstance:(e,t,n)=>ar(e)&&(n===!0||e.nodeValue===t),canRetainHydrationTail:e=>{let t=g(e);return t===`html`||t===`head`||t===`body`},resolveSingletonInstance:Jn,acquireSingletonInstance:(e,t)=>{Yn(e),W(e,{},t,{initial:!0})},releaseSingletonInstance:(e,t)=>{W(e,t,{}),Yn(e)},resolveHoistedInstance:(e,t,n)=>Zn(e,n)===`http://www.w3.org/1999/xhtml`?an(e,t):null,commitHoistedInstance:on,commitAssetResources:rn,removeHoistedInstance:q,updateHoistedInstance:ln,shouldCommitUpdate:(e,t,n)=>_t(e,n),clearContainer:e=>{Xn(e,Hn(e)),queueMicrotask(j)},insertBefore:(e,t,n)=>{e.insertBefore(t,n),h(t)&&or(t)&&B(t),pt(t)},removeChild:(e,t)=>{R(t),e.removeChild(t)},commitTextUpdate:(e,t)=>{e.nodeValue!==t&&(e.nodeValue=t)},commitUpdate:W,commitHydratedInstance:Ut,getActivityBoundary:Gn,getFirstActivityHydratable:e=>$n(Wn(e).firstChild??null),commitHydratedActivityBoundary:e=>{let t=e.parentNode;if(t===null)return;let n=Wn(e);for(;n.firstChild!==null;)t.insertBefore(n.firstChild,e);t.removeChild(e)},hideInstance:e=>{ge(e),e.style.setProperty(`display`,`none`,`important`)},unhideInstance:(e,t)=>{let n=t.style?.display;e.style.setProperty(`display`,typeof n==`string`?n:``),_e(e)},hideTextInstance:e=>{e.nodeValue=``},unhideTextInstance:(e,t)=>{e.nodeValue!==t&&(e.nodeValue=t)},getSuspenseBoundary:An,getEnclosingSuspenseBoundaryStart:Pn,isTargetWithinSuspenseBoundary:Fn,shouldRecoverSuspenseMismatchAtRoot:(e,t)=>Hn(e)&&Fn(e.documentElement,t),registerSuspenseBoundaryRetry:(e,t)=>{e.start.__figRetry=t},commitHydratedSuspenseBoundary:e=>{e.status===`completed`&&!e.forceClientRender?(zn(e.start),zn(e.end)):Rn(e),queueMicrotask(j)},removeDehydratedSuspenseBoundary:e=>{Rn(e),queueMicrotask(j)},completeRootHydration:e=>{ze(e),queueMicrotask(j)},preparePortalContainer:Ge,removePortalContainer:A});Pe(Un.batchedUpdates),e(Un.scheduleRefresh);function Wn(e){return`content`in e?e.content:e}function Gn(e){return h(e)&&g(e)===`template`&&e.getAttribute(t)!==null?e:null}function Kn(e,t,n){return!h(e)||!(`setAttribute`in e)||g(e)!==t.toLowerCase()?!1:ir(e,n)}function qn(e,t,n){let r=Zn(e,n);return r===`http://www.w3.org/1999/xhtml`?document.createElement(e):document.createElementNS(r,e)}function Jn(e,t){if(Hn(t))return e.toLowerCase()===`html`?t.documentElement:null;let n=t.ownerDocument;if(n==null||t!==n.documentElement)return null;switch(e.toLowerCase()){case`head`:return n.head;case`body`:return n.body;default:return null}}function Yn(e){for(;e.attributes.length>0;)e.removeAttributeNode(e.attributes[0])}function Xn(e,t){let n=e.firstChild;for(;n!==null;){let r=n.nextSibling;if(n.nodeType===10){n=r;continue}if(t&&h(n)){let e=g(n);if(e===`html`||e===`head`||e===`body`){Xn(n,!0),n=r;continue}if(e===`script`||e===`style`||e===`link`&&n.getAttribute(`rel`)?.toLowerCase()===`stylesheet`){n=r;continue}}R(n),e.removeChild(n),n=r}}function Zn(e,t){let n=e.toLowerCase();return n===`svg`?`http://www.w3.org/2000/svg`:n===`math`?`http://www.w3.org/1998/Math/MathML`:`namespaceURI`in t&&g(t)!==`foreignobject`?t.namespaceURI??`http://www.w3.org/1999/xhtml`:`http://www.w3.org/1999/xhtml`}function Qn(e,t){return t!==void 0&&rr(t)!==null||g(e)===`textarea`&&t!==void 0&&nr(t)?null:$n(e.firstChild)}function $n(e){let t=e;for(;t!==null&&(tr(t)||t.nodeType===10||er(t));)t=t.nextSibling;return t}function er(e){return h(e)&&e.getAttribute(i)!==null}function tr(e){return e.nodeType===8&&e.nodeValue===u}function nr(e){return e.value!==void 0||e.defaultValue!==void 0}function rr(e){return v(e.unsafeHTML)?null:e.unsafeHTML}function ir(e,t){let n=rr(t);return n===null||typeof n!=`string`||`innerHTML`in e}function ar(e){return e.nodeType===3}function or(e){let t=g(e);return t===`option`||t===`optgroup`}export{xe as a,Re as i,un as n,pe as o,Fe as r,Un as t};
2
+ //# sourceMappingURL=renderer-C0TsDuwu.js.map