@bgub/fig-dom 0.1.0-alpha.7 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +527 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{jsx-C3owhMDw.d.ts → jsx-It_Mpx4I.d.ts} +6 -0
- package/dist/jsx-runtime.d.ts +2 -1
- package/dist/refresh-internal-B05aFp_T.js.map +1 -1
- package/dist/refresh.d.ts +2 -0
- package/dist/refresh.js.map +1 -1
- package/dist/renderer-jfUYsG5x.js +2 -0
- package/dist/renderer-jfUYsG5x.js.map +1 -0
- package/dist/view-transitions.d.ts +4 -0
- package/dist/view-transitions.js +1 -1
- package/dist/view-transitions.js.map +1 -1
- package/dist-development/index.js +1 -1
- package/dist-development/index.js.map +1 -1
- package/dist-development/refresh-internal-B05aFp_T.js.map +1 -1
- package/dist-development/refresh.js.map +1 -1
- package/dist-development/renderer-DNpdiLm2.js +2 -0
- package/dist-development/renderer-DNpdiLm2.js.map +1 -0
- package/dist-development/view-transitions.js +1 -1
- package/dist-development/view-transitions.js.map +1 -1
- package/package.json +6 -6
- package/dist/renderer-DBahcxuV.js +0 -2
- package/dist/renderer-DBahcxuV.js.map +0 -1
- package/dist-development/renderer-CDHS_ArT.js +0 -2
- package/dist-development/renderer-CDHS_ArT.js.map +0 -1
|
@@ -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 };
|
package/dist/view-transitions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./renderer-
|
|
1
|
+
import{t as e}from"./renderer-jfUYsG5x.js";import{VIEW_TRANSITION_PENDING_PROPERTY as t,VIEW_TRANSITION_TIMEOUT_MS as n}from"@bgub/fig/internal";import{createViewTransitionCommitCoordinator as r}from"@bgub/fig-reconciler/view-transitions";const i=new WeakMap;function a(e,t,n){let r={name:t};return i.set(r,{owner:e.ownerDocument,snapshots:n}),r}function o(e){let t=i.get(e);if(t===void 0)throw Error(`The view-transition surface was not created by Fig DOM. Read pseudo elements from a surface passed to <ViewTransition onTransition>.`);let n=c(e.name),r=e=>s(t.owner.documentElement,`::view-transition-${e}(${n})`);return{group:r(`group`),imagePair:r(`image-pair`),new:t.snapshots.new?r(`new`):null,old:t.snapshots.old?r(`old`):null}}function s(e,t){return{selector:t,animate(n,r){let i=typeof r==`number`?{duration:r,pseudoElement:t}:{...r,pseudoElement:t};return e.animate(n,i)},getAnimations(){return e.getAnimations({subtree:!0}).filter(n=>{let r=n.effect;return r!==null&&`target`in r&&r.target===e&&`pseudoElement`in r&&r.pseudoElement===t})},getComputedStyle(){return e.ownerDocument.defaultView?.getComputedStyle(e,t)??getComputedStyle(e,t)}}}function c(e){return globalThis.CSS?.escape?.(e)??e}const l=new WeakSet;function u(e,t,n,r,i,a){let o=x(e),s=o.startViewTransition?.bind(o);if(s===void 0)return!1;let c=!1,l=!1,u=!1,v=null,y=null,b=g(i),S=g(a),C=()=>{v?.(),b(!1),S()},w=()=>{n();try{let e=()=>{c=!0,y=r(),y.cancelRootSnapshot&&(v=d(o))},n=s(t.types.length===0?e:{types:[...t.types],update:e});n!==void 0&&(p(o,n),f(o,n,()=>y));let i=_(n);i===void 0?C():(n?.ready===void 0?h(i,()=>b(!1)):n.ready.then(()=>b(!0),()=>b(!1)),h(i,()=>{v?.(),S()}))}catch(e){if(!c){if(l){c=!0;try{r()}finally{C()}}else u=!0,C();return}if(C(),!l)throw e;setTimeout(()=>{throw e})}};return m(o,t.interrupt,w)?(l=!0,`deferred`):(w(),u?!1:c?`committed`:`deferred`)}function d(e){let t=e.documentElement,n=t.style,r=n.viewTransitionName??``;return n.viewTransitionName=`none`,()=>{n.viewTransitionName=r,t.getAttribute(`style`)===``&&t.removeAttribute(`style`)}}function f(e,t,n){let r=[],i=()=>{for(let e of r)try{e.cancel()}catch{}r.length=0},a=()=>{let t=n();if(t===null||t.canceledNames.length===0&&!t.cancelRootSnapshot)return;let i=e.documentElement;if(typeof i.animate!=`function`)return;let a=e=>{typeof e?.cancel==`function`&&r.push(e)},o=e=>{a(i.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(${e})`}))};try{for(let e of t.canceledNames)o(c(e));t.cancelRootSnapshot&&(o(`root`),a(i.animate({height:[0,0],width:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})))}catch{}},o=t.ready??t.finished;o===void 0?a():o.then(a,()=>void 0),h(_(t),i)}function p(e,n){e[t]=n,h(_(n),()=>{e[t]===n&&(e[t]=null)})}function m(e,r,i){let a=e[t];if(a==null)return!1;let o=_(a);if(o===void 0)return!1;let s=!0;function c(){s&&(s=!1,clearTimeout(u),e[t]===a&&(e[t]=null),i())}let u=setTimeout(c,n);if(h(o,c),r&&a.skipTransition!==void 0&&!l.has(a)){l.add(a);try{a.skipTransition()}catch{l.delete(a)}}return!0}function h(e,t){e===void 0?t():e.then(t,t)}function g(e){let t=!1;return(...n)=>{t||(t=!0,e(...n))}}function _(e){return e?.finished??e?.ready}function v(e){if(typeof e.getBoundingClientRect!=`function`)return null;let t=e.getBoundingClientRect(),n=e.ownerDocument?.defaultView??null,r=n===null||t.bottom>=0&&t.right>=0&&t.top<=n.innerHeight&&t.left<=n.innerWidth,i=!1;try{i=n?.getComputedStyle(e).position===`absolute`}catch{}return{absolutelyPositioned:i,height:t.height,inViewport:r,width:t.width,x:t.left,y:t.top}}function y(e,t,n){let r=e.style;r.viewTransitionName=c(t),n!==null&&(r.viewTransitionClass=n)}function b(e,t){let n=e.style,r=t.style,i=r?.viewTransitionName??r?.[`view-transition-name`],a=r?.viewTransitionClass??r?.[`view-transition-class`];n.viewTransitionName=S(i),n.viewTransitionClass=S(a)}function x(e){return e.ownerDocument??document}function S(e){return typeof e==`string`||typeof e==`number`?String(e).trim():``}const C=r({commit:u,apply:y,restore:b,measure:v,createSurface:a,suspend(e,t,n){return m(x(e),t.interrupt,n)}});function w(){e.installCommitCoordinator(C)}export{w as enableViewTransitions,o as getViewTransitionPseudoElements};
|
|
2
2
|
//# sourceMappingURL=view-transitions.js.map
|
|
@@ -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,EA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Q,EAAU,eAAiB,QACrC,CAEA,SAAS,EAAW,EAAwB,CAK1C,OAJI,OAAO,GAAU,UAAY,OAAO,GAAU,SACzC,OAAO,CAAK,CAAC,CAAC,KAAK,EAGrB,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 enableViewTransitions(): void {\n domRenderer.installCommitCoordinator(coordinator);\n}\n"],"mappings":"+OAsBA,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,CAGA,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,SACf,CAAE,SAAU,EAAS,cAAe,CAAS,EAC7C,CAAE,GAAG,EAAS,cAAe,CAAS,EAC5C,OAAO,EAAQ,QAAQ,EAAW,CAAe,CACnD,EACA,eAA6B,CAC3B,OAAO,EAAQ,cAAc,CAAE,QAAS,EAAK,CAAC,CAAC,CAAC,OAAQ,GAAc,CACpE,IAAM,EAAS,EAAU,OACzB,OACE,IAAW,MACX,WAAY,GACZ,EAAO,SAAW,GAClB,kBAAmB,GACnB,EAAO,gBAAkB,CAE7B,CAAC,CACH,EACA,kBAAwC,CACtC,OACE,EAAQ,cAAc,aAAa,iBACjC,E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pdiLm2.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,EAAO,EAAS,KACtB,GAAI,IAAS,KACX,MAAU,MAAM,0CAA0C,EAE5D,GAAI,CACF,EACE,EACA,EAAS,QAAQ,IAAI,cAAc,CACrC,CACF,OAAS,EAAO,CAEd,MADA,MAAM,EAAK,OAAO,CAAC,CAAC,MAAM,CAAI,EACxB,CACR,CAEA,IAAM,EAAe,EAAwB,CAAO,EACpD,OAAO,EAAoB,EAAM,CAE/B,QAAS,GAAc,QACvB,YAAa,GAAc,eAI3B,aAAe,GAAW,CACT,EAAO,SAAW,UAC/B,QAAQ,MACN,wDACA,EAAO,KACT,CAEJ,EACA,cACE,EAAQ,gBAAmB,GAAW,EAAqB,CAAM,GACnE,aAAc,EAAQ,aACtB,uBAAwB,EAAQ,uBAChC,QACF,CAAC,CACH,CAEA,SAAS,EAAY,EAA8B,CACjD,OAAO,EAAO,QAAc,MAAM,0BAA0B,CAC9D,CChFA,SAAgB,EAAiB,EAAsC,CACrE,IAAM,EAAM,IAAI,QACZ,EAAS,EAEb,SAAS,EAAO,EAAsC,CACpD,GAAI,IAAU,KAAM,OAAO,KAC3B,GAAI,IAAU,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AAqB,CAC3C,GAAI,OAAO,OAAO,EAAO,UAAU,EACjC,MAAU,MAAM,4CAA4C,CAEhE,CC7EA,MAAa,EAAY,EAAY,UAErC,SAAgB,EACd,EACA,EACS,CACT,IAAM,EAAO,EAAY,WAAW,EAAW,CAAO,EAEtD,OADA,EAAa,EAAW,CAAE,IAAM,GAAa,EAAK,KAAK,IAAI,CAAQ,CAAE,CAAC,EAC/D,EAAkB,EAAM,CAAS,CAC1C,CAEA,SAAgB,EACd,EACA,EACA,EACS,CACT,IAAM,EAAO,EAAY,YAAY,EAAW,EAAU,CAAO,EAMjE,OALA,EAAa,EAAW,CACtB,SAAU,EAAQ,IAChB,EAAY,cAAc,EAAW,EAAQ,CAAQ,EACvD,IAAM,GAAa,EAAK,KAAK,IAAI,CAAQ,CAC3C,CAAC,EACM,EAAkB,EAAM,CAAS,CAC1C,CAEA,SAAgB,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,KACtB,GAAI,IAAS,KACX,MAAU,MAAM,0CAA0C,EAE5D,GAAI,CACF,EACE,EACA,EAAS,QAAQ,IAAI,cAAc,CACrC,CACF,OAAS,EAAO,CAEd,MADA,MAAM,EAAK,OAAO,CAAC,CAAC,MAAM,CAAI,EACxB,CACR,CAEA,IAAM,EAAe,EAAwB,CAAO,EACpD,OAAO,EAAoB,EAAM,CAE/B,QAAS,GAAc,QACvB,YAAa,GAAc,eAI3B,aAAe,GAAW,CACT,EAAO,SAAW,UAC/B,QAAQ,MACN,wDACA,EAAO,KACT,CAEJ,EACA,cACE,EAAQ,gBAAmB,GAAW,EAAqB,CAAM,GACnE,aAAc,EAAQ,aACtB,uBAAwB,EAAQ,uBAChC,QACF,CAAC,CACH,CAEA,SAAS,EAAY,EAA8B,CACjD,OAAO,EAAO,QAAc,MAAM,0BAA0B,CAC9D,CChFA,SAAgB,EAAiB,EAAsC,CACrE,IAAM,EAAM,IAAI,QACZ,EAAS,EAEb,SAAS,EAAO,EAAsC,CACpD,GAAI,IAAU,KAAM,OAAO,KAC3B,GAAI,IAAU,IAAA,GA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C3C,GAAI,OAAO,OAAO,EAAO,UAAU,EACjC,MAAU,MAAM,4CAA4C,CAEhE,CC5EA,MAAa,EAAY,EAAY,UAGrC,SAAgB,EACd,EACA,EACS,CACT,IAAM,EAAO,EAAY,WAAW,EAAW,CAAO,EAEtD,OADA,EAAa,EAAW,CAAE,IAAM,GAAa,EAAK,KAAK,IAAI,CAAQ,CAAE,CAAC,EAC/D,EAAkB,EAAM,CAAS,CAC1C,CAGA,SAAgB,EACd,EACA,EACA,EACS,CACT,IAAM,EAAO,EAAY,YAAY,EAAW,EAAU,CAAO,EAMjE,OALA,EAAa,EAAW,CACtB,SAAU,EAAQ,IAChB,EAAY,cAAc,EAAW,EAAQ,CAAQ,EACvD,IAAM,GAAa,EAAK,KAAK,IAAI,CAAQ,CAC3C,CAAC,EACM,EAAkB,EAAM,CAAS,CAC1C,CAGA,SAAgB,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 +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,
|
|
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":["
|
|
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,assetResourceFromHostAttributes as ee,assetResourceFromHostProps as d,assetResourceHostProps as f,assetResourceKey as p,isFigAssetResource as te,markClientOnlyHostBehavior as ne,mixinSlot as re,validateInstanceNesting as ie,validateTextNesting as ae}from"@bgub/fig/internal";import{createMixin as oe}from"@bgub/fig";import{createRenderer as se,runWithEventPriority as m}from"@bgub/fig-reconciler";function ce(e,t){if(!h(e))return;let n=[];le(e,n);for(let e of n)t(e)}function le(e,t){t.push(e);for(let n=e.firstChild;n!==null;n=n.nextSibling)h(n)&&le(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 ue(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 de(...e){let t=e.filter(e=>typeof e==`function`);return(e,n)=>{for(let r of t)r(e,n)}}function fe(e,t){let n=_e(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 pe(e){let t=y.get(e);t!==void 0&&x(e,t)}function me(e){b.add(e);let t=y.get(e);t!==void 0&&S(t)}function he(e){b.delete(e);let t=y.get(e);t!==void 0&&x(e,t)}function ge(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 _e(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`),ve=oe((e,t,n,r)=>{ne(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:re(e),type:t})});function ye(e,t,n){return ve(e,t,n)}const be=[];function xe(e){return e[C]??be}function Se(e,t,n){let r=w(e,`currentTarget`,{value:t});try{return n(e)}finally{r()}}function Ce(e,t,n){let r={immediateStopped:!1,stopped:!t&&e.cancelBubble===!0},i=we(e,`stopPropagation`,()=>{r.stopped=!0}),a=we(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 we(e,t,n){let r=Reflect.get(e,t);return typeof r==`function`?w(e,t,{value(){n(),r.call(e)}}):Te}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)}:Te}function Te(){}const T=new WeakMap,E=new WeakMap,Ee=new WeakMap,D=[],De=new Set(a),Oe=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`]),ke=new Set([...Oe,...O,`mouseenter`,`mouseleave`]),Ae=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 je=e=>e();function Me(e){je=e}function Ne(e,t){let n=k(e);n.run=t.run,t.hydrate!==void 0&&(n.hydrate=t.hydrate,Ke(e,n),Fe(e))}const Pe=new WeakMap;function Fe(e){let t=e.ownerDocument??e,i=Pe.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,Pe.set(t,i)}let o=!1;for(let t=0;t<i.length;){let n=i[t];if(De.has(n.type)&&ct(e,n.target)){i.splice(t,1),Je(e,n.type,n),o=!0;continue}t+=1}o&&queueMicrotask(j)}function Ie(e){let t=E.get(e);if(t!==void 0){Le(e);for(let n of t.listeners.values())e.removeEventListener(n.type,n.listener,n.capture);Re(e),E.delete(e);for(let t=D.length-1;t>=0;--t)D[t].root===e&&D.splice(t,1)}}function Le(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 Re(e){for(let t of E.get(e)?.portals??[])Re(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 ze(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??=He(e),s!==void 0&&M(s),s=We(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 Be(e){let t=T.get(e);if(t===void 0)return;let{listenerTarget:n,root:r}=He(e);for(let i of t)$e(e,r,n,i)}function Ve(e){let t=T.get(e);if(t!==void 0){for(let e of t)M(e);T.delete(e)}}function He(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 Ue(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())nt(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())rt(e,t)}}function j(){let e=new Set;for(let t=0;t<D.length;){let n=D[t];if(!ct(n.listenerTarget??n.root,n.event.target)){D.splice(t,1);continue}if(Ye(n)===`blocked`){e.add(n.root),t+=1;continue}if(e.has(n.root)){t+=1;continue}D.splice(t,1),Xe(n)}}function We(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 $e(e,t,n,o),o}function M(e){it(e),F(e)}function Ge(e,t,n,r,i,a){let o=I(a.target);if(o!==t&&((o===null?null:E.get(o)??null)?.portalOwner?.root===e||!ct(t,a.target))||qe(e,n,a)===`blocked`)return;let s=N(e,t,n,r,i,a);s.length!==0&&Ce(a,!1,e=>P(s,a,e))}function Ke(e,t){if(t.hydrationListeners===null){t.hydrationListeners=[];for(let n of ke){let r=t=>qe(e,n,t);t.hydrationListeners.push([n,r]),e.addEventListener(n,r,{capture:!0,passive:lt(n)})}}}function qe(e,t,n){let r=E.get(e)?.hydrate??null;if(r===null)return`none`;let i=Ee.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,Ee.set(n,i)),i.set(e,s),s===`blocked`&&De.has(t)&&Je(e,t,n),s}function Je(e,t,n){D.push({event:n,listenerTarget:I(n.target),root:e,type:t})}function Ye(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 Xe(e){let{event:t,root:n,type:r}=e,i=e.listenerTarget??e.root;Ce(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=ot(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=at(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{Ze(i,t)}finally{let e=i.slot;e.attachment===null&&F(e)}}}function Ze(e,t){let n=e.slot;F(n),n.controller=new AbortController;let r=n.controller.signal;je(()=>{Qe(e.root,()=>m(L(n.type),()=>{Se(t,e.element,t=>{e.callback(t,r)})}))})}function Qe(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 $e(e,t,n,r){Ae.has(r.type)?et(e,t,r):tt(t,n,r)}function et(e,t,n){let r=n.attachment;if(r!==null){if(`element`in r&&r.element===e){t!==null&&(r.root=t);return}it(n)}let i=t=>{try{Ze({callback:n.callback,element:e,root:at(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 tt(e,t,n){if(e===null||t===null)return;let r=n.attachment;r!==null&&`listenerTarget`in r&&r.root===e&&r.listenerTarget===t||(it(n),n.attachment={listenerTarget:t,root:e},nt(e,t,n.type,n.capture,n.passive))}function nt(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=>Ge(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??[])nt(e,a,n,r,i)}s.count+=1}function rt(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??[])rt(n,t)}}function it(e){let t=e.attachment;t!==null&&(e.attachment=null,`element`in t?t.element.removeEventListener(e.type,t.listener,e.capture):rt(t.listenerTarget,`${e.type}:${e.capture}:${e.passive}`))}function at(e){return e.attachment?.root??null}function ot(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 st(r,e,t),r}}for(let e=n.target;e!==t&&(h(e)&&r.push(e),e=_(e),e!==null););return st(r,e,t),r}function st(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(ut(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 ct(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(ut(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 Oe.has(e)?`discrete`:O.has(e)?`continuous`:`default`}function lt(e){return O.has(e)||e===`touchstart`||e===`touchend`}function ut(e){return typeof e==`object`&&!!e&&`addEventListener`in e&&`childNodes`in e}function dt(e){ce(e,e=>{pe(e),Be(e)})}function R(e){ce(e,e=>{ge(e),Ve(e)})}const z=new WeakMap;function ft(e){return H(e)||e===`checked`||e===`defaultChecked`}function pt(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)||yt(e,r):n===`defaultValue`?vt(e,r,t,o&&i.value===void 0):n===`checked`?r!==void 0&&St(e,r):n===`defaultChecked`&&xt(e,r,o&&i.checked===void 0)}function mt(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)&&Ct(e,s.selectedValues)}function B(e,t=!1){let n=Et(e);if(n===null)return;let r=z.get(n);r!==void 0&&(!r.controlled&&r.appliedDefault&&!t||!r.controlled&&t&&!r.applyDefaultToInsertedOptions||(Ct(e,r.selectedValues),r.controlled||(r.appliedDefault=!0)))}function ht(e,t){return(e===`input`||e===`textarea`||e===`select`)&&(t.value!==void 0||t.checked!==void 0)}function gt(e,t){if(ft(t))return(e===`textarea`||e===`select`)&&H(t)?null:t===`defaultValue`?`value`:t===`defaultChecked`?`checked`:t}function _t(e){if(g(e)!==`option`)return!1;let t=Et(e),n=t===null?void 0:z.get(t);return n!==void 0&&Tt(e,n.selectedValues)}function vt(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&&bt(e,a)}function yt(e,t){let n=V(t);n!==null&&(`value`in e?bt(e,n):U(e,`value`,n))}function bt(e,t){let n=e;n.value!==t&&(n.value=t)}function xt(e,t,n){let r=t===!0;`defaultChecked`in e&&(e.defaultChecked=r),U(e,`checked`,r),n&&St(e,t)}function St(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 Ct(e,t){if(g(e)===`option`){wt(e,t);return}Dt(e,e=>{wt(e,t)})}function wt(e,t){e.selected=Tt(e,t)}function Tt(e,t){let n=e.getAttribute(`value`)??(e.textContent??``).replace(/\s+/g,` `).trim();return typeof t==`string`?n===t:t.has(n)}function Et(e){let t=e.parentNode;for(;t!==null;){if(h(t)&&g(t)===`select`)return t;t=t.parentNode}return null}function Dt(e,t){for(let n=e.firstChild;n!==null;){let e=n.nextSibling;h(n)&&(g(n)===`option`?t(n):Dt(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 Ot=new Set;function kt(e,t,n){typeof n==`string`&&n!==``&&Ft(`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=Mt(t),a=Mt(n);for(let e of Object.keys(i))e in a||Pt(r,e);for(let[e,t]of Object.entries(a))v(t)?Pt(r,e):Nt(r,e,t)}function At(e,t){if(e.length===0)return[];let n=document.createElement(`div`);kt(n,{},t);let r=new Set(jt(n));return e.filter(e=>!r.has(e)).map(e=>`style.${e}`)}function jt(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 Mt(e){return typeof e==`object`&&e?e:{}}function Nt(e,t,n){if(typeof n==`number`||typeof n==`bigint`){Ft(`${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 Pt(e,t){t.startsWith(`--`)&&typeof e.removeProperty==`function`?e.removeProperty(t):e[t]=``}function Ft(e,t){Ot.has(e)||(Ot.add(e),console.error(t))}const It=`http://www.w3.org/1999/xlink`;function W(e,t,n,r={}){(`mix`in t||`mix`in n)&&ze(e,xe(n));let i=g(e),a=ue(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&&fe(e,c);continue}if(s===`unsafeHTML`){r.hydrating===!0?Kt(c):o!==c&&Gt(e,c);continue}if(Yt(s)){Xt(s)&&Rt(s,zt(s,i,n));continue}if(ft(s)){(s===`checked`||s===`defaultChecked`)&&c!==void 0&&typeof c!=`boolean`&&c!==null&&Rt(`${s}:${typeof c}`,`The "${s}" prop received a ${typeof c} (${String(c)}); Fig treats only \`true\` as checked, so this renders unchecked.`),pt(e,i,s,c,n,r);continue}o!==c&&(s===`style`?kt(e,o,c):qt(e,G(s,a),c))}}mt(e,i,n,r),(i===`option`||i===`optgroup`)&&B(e)}const Lt=new Set;function Rt(e,t){Lt.has(e)||(Lt.add(e),console.error(t))}function zt(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`&&Bt(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 Bt(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 Vt(e,t){let n=jt(e),r=Wt(e);W(e,{},t,{hydrating:!0}),t.suppressHydrationWarning!==!0&&Ht(e,t,n,r)}function Ht(e,t,n,r){if(r.length===0&&n.length===0)return;let i=new Set,a=g(e),o=ue(e);for(let e of Object.keys(t)){if(e===`bind`||Yt(e))continue;let t=Ut(a,e,o);t!==null&&i.add(t)}a===`option`&&_t(e)&&i.add(`selected`);let s=[];for(let e of r){let t=G(e,o);t.startsWith(`data-fig-`)||i.has(t)||s.push(e)}s.push(...At(n,t.style)),s.length!==0&&console.error(`Hydration preserved extra server attributes or styles on <${a}>: ${s.sort().join(`, `)}. They were preserved, so this element now differs from a pure client render.`)}function Ut(e,t,n){let r=gt(e,t);return r===void 0?G(t,n):r}function Wt(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 Gt(e,t){let n=Kt(t);`innerHTML`in e&&(e.innerHTML=n??``)}function Kt(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 qt(e,t,n){if(v(n)){Jt(e,t);return}if(t===`xlink:href`){e.setAttributeNS(It,t,String(n));return}e.setAttribute(t,String(n))}function Jt(e,t){if(t===`xlink:href`){e.removeAttributeNS(It,`href`);return}e.removeAttribute(t)}function Yt(e){return e===`children`||e===`key`||e===`mix`||e===`suppressHydrationWarning`||e===`unsafeHTML`||Xt(e)}function Xt(e){return/^on[A-Z]/.test(e)}var Zt=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=Qt(e.children)),this.rendered=e}};function Qt(e){return e==null||typeof e==`boolean`?``:typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(Qt).join(``):``}const $t=new WeakMap,K=new WeakMap;function en(e,t,n){let r=J();if(r===null)return;let i=cn(e),a=cn(t);for(let[e]of i)a.has(e)||dn(r,e,n);for(let[e,t]of a)i.has(e)?(t.kind===`title`||t.kind===`meta`)&&un(r,e,t,n):ln(r,t,n)}function tn(e,t){let n=J(),r=d(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 nn(e,t,n){let r=J();if(r===null)return e;let i=d(g(e),t);return i!==null&&X(i)?Y(r,i,t,n,e):rn(r,e)}function rn(e,t){let n=K.get(t);if(n===void 0){let e=yn(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,hn(e,r.element)):(r===void 0?e.entries.set(n.key,{count:1,element:t,kind:`persistent`,ready:null}):r.count+=1,hn(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`){fn(n,r.key,i,t);return}if(r.kind===`title`||r.kind===`meta`){K.delete(e),bn(e);return}an(n,e)}function an(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(_n(e,t))return;K.delete(t);return}if(r.kind!==`persistent`)throw Error(`Expected a persistent resource entry.`);r.count>0&&--r.count}function on(e,t,n,r){let i=g(e),a=d(i,n),o=K.get(e);if(a===null){let e=d(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)?mn(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,f=tn(i,n)??e;return f===e?(W(e,t,n),e):(ee!==f&&W(f,{},n),nn(f,n,r))}function sn(e){let t=J();if(t===null)return Promise.resolve();let n=[];for(let r of e){if(!te(r)||r.kind===`title`||r.kind===`meta`)continue;let e=Sn(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=vn(t,e,i,r);a!==null&&n.push(a);continue}let s=En(e),c={count:1,element:s,kind:`persistent`,ready:null};c.ready=Cn(e)?Tn(s).then(()=>{t.entries.get(i)===c&&(c.ready=null)}):null,t.entries.set(i,c),K.set(s,{key:i,kind:e.kind}),gn(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=$t.get(document.head);return e===void 0&&(e={entries:new Map,head:document.head},$t.set(document.head,e)),e}function cn(e){let t=new Map;if(e===null)return t;let n=Array.isArray(e)?e:[e];for(let e of n){if(!te(e))continue;let n=Sn(e),r=p(n);(!t.has(r)||X(n))&&t.set(r,n)}return t}function ln(e,t,n){if(X(t)){Y(e,t,pn(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)??En(t);a===void 0&&(e.entries.set(r,{count:0,element:o,kind:`persistent`,ready:null}),K.set(o,{key:r,kind:t.kind})),rn(e,o)}function un(e,t,n,r){let i=e.entries.get(t);if(i===void 0){ln(e,n,r);return}if(i.kind!==`metadata`)throw Error(`Expected a metadata resource entry.`);i.update(r,pn(n))}function dn(e,t,n){let r=e.entries.get(t);r!==void 0&&(r.kind===`metadata`?fn(e,t,r,n):an(e,r.element))}function Y(e,t,n,r,i){let a=p(t),o=mn(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 Zt(n,t.kind,r,o),e.entries.set(a,s),K.set(n,{key:a,kind:t.kind})}else s.acquire(r,o);return hn(e,s.element)}function fn(e,t,n,r){n.release(r)!==`retained`&&(e.entries.delete(t),K.delete(n.element),bn(n.element))}function pn(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 mn(e,t){return e.kind===`title`?{...t,children:e.value}:t}function X(e){return e.kind===`title`||e.kind===`meta`}function hn(e,t){return t.parentNode!==e.head&&gn(e,t),dt(t),t}function gn(e,t){let n=xn(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)?xn(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=yn(n);if(e!==null&&p(e)===t)return n}return null}function _n(e,t){for(let n of e.entries.values())if(n.element===t)return!0;return!1}function vn(e,t,n,r){if(!Cn(t))return null;if(r.ready!==null)return r.ready;if(!wn(r.element))return null;let i=Tn(r.element).then(()=>{e.entries.get(n)===r&&(r.ready=null)});return r.ready=i,i}function yn(e){return ee(g(e),t=>e.getAttribute(t))}function bn(e){R(e),e.parentNode?.removeChild(e)}function xn(e){if(g(e)!==`link`)return null;let t=yn(e);return t?.kind===`stylesheet`?t.precedence??``:null}function Sn(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 Cn(e){return e.kind!==`stylesheet`||e.blocking===`none`?!1:e.media===void 0||e.media===``||typeof matchMedia!=`function`||matchMedia(e.media).matches}function wn(e){return g(e)===`link`&&e.getAttribute(`rel`)===`stylesheet`&&`sheet`in e&&e.sheet===null}function Tn(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 En(e){let t=document.createElement(e.kind===`script`?`script`:`link`),n=f(e);for(let e of Object.keys(n)){let r=n[e];t.setAttribute(e,r===!0?``:r)}return t}function Dn(e){if(!$(e))return null;let t=Q(e);return t===null?null:On(e,t)}function On(e,t){let n=kn(e);return n===null?null:{end:n,forceClientRender:!1,id:t.id,start:e,get error(){return An(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 kn(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 An(e){let t=e.nextSibling;return Ln(t)?{digest:t.dataset.dgst,message:t.dataset.msg}:null}function jn(e){if(!Rn(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 Mn(e,t){if(!Rn(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 Nn(i,t.start,t.end);if(r!==null&&r!==n&&i.parentNode===r)return Pn(i,t.end)}return!1}function Nn(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 Pn(e,t){for(let n=e;n!==null;n=n.nextSibling)if(n===t)return!0;return!1}function Fn(e){for(let t=e.start;t!==null;){let n=t.nextSibling;if(In(t),t===e.end)return;t=n}}function In(e){e.parentNode?.removeChild(e)}function $(e){return typeof e==`object`&&!!e&&`data`in e&&`nodeType`in e&&e.nodeType===8}function Ln(e){return typeof e==`object`&&!!e&&`dataset`in e}function Rn(e){return typeof e==`object`&&!!e&&`parentNode`in e}function zn(e){return e.nodeType===9}const Bn=se({createInstance:Wn,createTextInstance:e=>document.createTextNode(e),validateInstanceNesting:(e,t,n)=>{ie(e,n)},validateTextNesting:(e,t)=>{ae(e,t)},containerType:e=>h(e)?g(e):null,appendInitialChild:(e,t)=>{e.appendChild(t),h(t)&&rr(t)&&B(t,!0)},finalizeInitialInstance:(e,t)=>W(e,{},t,{initial:!0}),setTextContent:(e,t)=>{e.textContent!==t&&(e.textContent=t)},getFirstHydratableChild:Yn,getNextHydratableSibling:e=>Xn(e.nextSibling),canHydrateInstance:Un,canHydrateTextInstance:(e,t,n)=>nr(e)&&(n===!0||e.nodeValue===t),canRetainHydrationTail:e=>{let t=g(e);return t===`html`||t===`head`||t===`body`},resolveSingletonInstance:Gn,acquireSingletonInstance:(e,t)=>{Kn(e),W(e,{},t,{initial:!0})},releaseSingletonInstance:(e,t)=>{W(e,t,{}),Kn(e)},resolveHoistedInstance:(e,t,n)=>Jn(e,n)===`http://www.w3.org/1999/xhtml`?tn(e,t):null,commitHoistedInstance:nn,commitAssetResources:en,removeHoistedInstance:q,updateHoistedInstance:on,shouldCommitUpdate:(e,t,n)=>ht(e,n),clearContainer:e=>{qn(e,zn(e)),queueMicrotask(j)},insertBefore:(e,t,n)=>{e.insertBefore(t,n),h(t)&&rr(t)&&B(t),dt(t)},removeChild:(e,t)=>{R(t),e.removeChild(t)},commitTextUpdate:(e,t)=>{e.nodeValue!==t&&(e.nodeValue=t)},commitUpdate:W,commitHydratedInstance:Vt,getActivityBoundary:Hn,getFirstActivityHydratable:e=>Xn(Vn(e).firstChild??null),commitHydratedActivityBoundary:e=>{let t=e.parentNode;if(t===null)return;let n=Vn(e);for(;n.firstChild!==null;)t.insertBefore(n.firstChild,e);t.removeChild(e)},hideInstance:e=>{me(e),e.style.setProperty(`display`,`none`,`important`)},unhideInstance:(e,t)=>{let n=t.style?.display;e.style.setProperty(`display`,typeof n==`string`?n:``),he(e)},hideTextInstance:e=>{e.nodeValue=``},unhideTextInstance:(e,t)=>{e.nodeValue!==t&&(e.nodeValue=t)},getSuspenseBoundary:Dn,getEnclosingSuspenseBoundaryStart:jn,isTargetWithinSuspenseBoundary:Mn,shouldRecoverSuspenseMismatchAtRoot:(e,t)=>zn(e)&&Mn(e.documentElement,t),registerSuspenseBoundaryRetry:(e,t)=>{e.start.__figRetry=t},commitHydratedSuspenseBoundary:e=>{e.status===`completed`&&!e.forceClientRender?(In(e.start),In(e.end)):Fn(e),queueMicrotask(j)},removeDehydratedSuspenseBoundary:e=>{Fn(e),queueMicrotask(j)},completeRootHydration:e=>{Le(e),queueMicrotask(j)},preparePortalContainer:Ue,removePortalContainer:A});Me(Bn.batchedUpdates),e(Bn.scheduleRefresh);function Vn(e){return`content`in e?e.content:e}function Hn(e){return h(e)&&g(e)===`template`&&e.getAttribute(t)!==null?e:null}function Un(e,t,n){return!h(e)||!(`setAttribute`in e)||g(e)!==t.toLowerCase()?!1:tr(e,n)}function Wn(e,t,n){let r=Jn(e,n);return r===`http://www.w3.org/1999/xhtml`?document.createElement(e):document.createElementNS(r,e)}function Gn(e,t){if(zn(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 Kn(e){for(;e.attributes.length>0;)e.removeAttributeNode(e.attributes[0])}function qn(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`){qn(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 Jn(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 Yn(e,t){return t!==void 0&&er(t)!==null||g(e)===`textarea`&&t!==void 0&&$n(t)?null:Xn(e.firstChild)}function Xn(e){let t=e;for(;t!==null&&(Qn(t)||t.nodeType===10||Zn(t));)t=t.nextSibling;return t}function Zn(e){return h(e)&&e.getAttribute(i)!==null}function Qn(e){return e.nodeType===8&&e.nodeValue===u}function $n(e){return e.value!==void 0||e.defaultValue!==void 0}function er(e){return v(e.unsafeHTML)?null:e.unsafeHTML}function tr(e,t){let n=er(t);return n===null||typeof n!=`string`||`innerHTML`in e}function nr(e){return e.nodeType===3}function rr(e){let t=g(e);return t===`option`||t===`optgroup`}export{ye as a,Ie as i,sn as n,de as o,Ne as r,Bn as t};
|
|
2
|
+
//# sourceMappingURL=renderer-DNpdiLm2.js.map
|