@bgub/fig-dom 1.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,124 @@
1
+ ## @bgub/fig-dom@2.1.0
2
+
3
+ ### Add intentional browser-only rendering
4
+
5
+ Components can call `readBrowser(reason?)` to leave their nearest server-rendered
6
+ Suspense boundary in its fallback state and render normally during hydration.
7
+ Server renderers can observe these intentional fallbacks through
8
+ `onBrowserBailout` without treating them as server or recoverable errors.
9
+
10
+ ### Retain bindings through error cleanup
11
+
12
+ Keep every retained binding reachable during updates so error teardown aborts
13
+ all live binding signals even when an earlier callback or host binding throws.
14
+
15
+ ### Initialize hoisted assets at commit
16
+
17
+ Keep shared hoisted assets unchanged during suspended renders. Acquire from the latest retry props at commit, preserving existing delivery-asset definitions and deduplicating assets inserted while rendering was suspended.
18
+
19
+ Hoisted host acquisition now owns initial props and text; generic host initialization no longer writes to potentially shared instances.
20
+
21
+ Keep declared client binds and event listeners when adopting an existing server or payload asset, without rewriting its live attributes or attaching callbacks from suspended work.
22
+
23
+ Index existing head assets to avoid repeated full scans when acquiring distinct assets, while preserving discovery of same-turn external DOM changes.
24
+
25
+ ### Make host bindings opaque
26
+
27
+ Make the new `HostBinding<T>` API opaque before its first release. Create host
28
+ bindings through `hostBinding()`; ownership, mixin slots, and update callbacks
29
+ are private implementation details. Reject structural lookalikes while preserving
30
+ element typing, binding composition, and committed lifetime behavior.
31
+
32
+ ### Remove redundant data store partitions
33
+
34
+ Remove `partition` from `createDataStore` and `dataPartition` from client and server renderer options. Each store already owns an isolated cache, so the fixed key prefix provided no additional isolation. Remove these options from callers; include tenant identity in resource keys when one store holds data for multiple tenants. SSR hydration entries remain unchanged.
35
+
36
+ ### Simplify font assets and binding types
37
+
38
+ Make `font()` shorthand for a font `PreloadResource`, preserving its anonymous cross-origin default. Remove `FontResource` and the separate `font` descriptor and Payload asset kind; use `preload` with `as: "font"` instead. Update clients and servers together when using Payload.
39
+
40
+ Remove the redundant `BindCallback` type alias. Use `Bind` for callbacks and `Binding` for the full bind-prop representation.
41
+
42
+ ### Stream Suspense boundary data ahead of each reveal
43
+
44
+ Server stream renders now send the data each Suspense boundary read in a `d`
45
+ operation right before that boundary's reveal, and `hydrateRoot` applies it to
46
+ the root's store. Late boundaries hydrate from server data instead of
47
+ reloading in the browser. Streamed rows fill only entries the client has no
48
+ value for. Disable with `streamData: false` or exclude entries with
49
+ `streamData: { filter }`.
50
+
51
+ `takeData()` on stream results returns the settled entries that have not been
52
+ streamed, so documents can place the shell's snapshot before the client
53
+ bootstrap without duplicating later rows.
54
+
55
+ The TanStack Start transport no longer waits for every boundary before the
56
+ router bootstrap. It uses the renderer's streamed rows, streams initial
57
+ Payload responses ahead of the boundaries that render them, and lets Router's
58
+ deferred data interleave with streamed boundaries.
59
+
60
+ ## @bgub/fig-dom@2.0.0
61
+
62
+ ### Keep binding errors and hydration requests attached to the right commit
63
+
64
+ Attribute deferred binding errors to the declaring asset owner when multiple components share a hoisted element. Preserve ownership through metadata winner changes as well as asset acquisition and updates.
65
+
66
+ Queue event-triggered hydration until an active commit finishes instead of re-entering its render attempt. Bind and layout callbacks can focus or click a dehydrated boundary without corrupting the commit; queued replayable events still dispatch once after hydration.
67
+
68
+ ### Apply host properties before updating bindings
69
+
70
+ Run callback and host bindings after the host's attributes and form properties
71
+ have been applied. Widgets now follow form reassociation through later mixins,
72
+ removing the old form's reset listener and registering with the new form.
73
+
74
+ ### Preserve host behavior lifetimes across configuration updates
75
+
76
+ Add `context.owns(prop)` to identify the last mixin writer of a host prop, even
77
+ when a later override writes the same value.
78
+
79
+ Add `hostBinding(context, owner, update)` for mixins that register committed DOM
80
+ configuration. Updates keep their lifetime signal; removal, owner replacement,
81
+ and Activity hiding abort it synchronously.
82
+
83
+ The host `bind` prop additionally accepts host-binding descriptions and nested
84
+ binding arrays through the new `Binding` type. Array members have independent
85
+ signals and development strict checks. `Bind` remains callable, and
86
+ `composeBind` preserves its callable result and shared lifetime semantics.
87
+ `BindCallback` is an alias for `Bind`.
88
+
89
+ Headless widgets adopt shared committed value, registration, and reference owners.
90
+ Controlled props cannot leak from suspended renders, accepted uncontrolled
91
+ requests compose before commit, and compound Combobox changes cancel together.
92
+ Host configuration updates preserve typeahead and toast work while actual
93
+ removal cleans up immediately. Caller-authored native disability and accessible
94
+ names remain authoritative.
95
+
96
+ ### Finish pending captures before synchronous work
97
+
98
+ Allow explicit `flushSync` and unmount to interrupt pending View Transition captures. Preserve animations through automatically scheduled synchronous work, including before-paint repairs and external-store notifications, by retaining capture ownership until readiness. Validate pending mutations, restore author styles before urgent work, suppress interrupted transition callbacks, and ignore late browser callbacks.
99
+
100
+ Automatically cancel captures whose mutation was rejected as stale or failed. Release the document animation lock and wake existing client and streamed-reveal waiters without waiting for the discarded animation, so transition-priority retries can publish promptly even when native cancellation is unavailable or throws.
101
+
102
+ Custom commit coordinators and View Transition host adapters must return `{ interrupt() }` instead of `"deferred"`. The operation must synchronously finish or reject the pending mutation, restore temporary host state, and release capture. Return `"committed"` only when both mutation and capture restoration have completed.
103
+
104
+ View Transition host adapters receive `cancelTransition: true` when no candidate was published. Skip the entire native animation and release capture in that case; `canceledNames` and `cancelRootSnapshot` alone only suppress individual snapshots.
105
+
106
+ Bind DOM pseudo-element handles to the transition signal. Cancel animations created through those handles at completion and reject expired handles, preventing filled animations or saved handles from affecting later transitions with the same surface names. Surface host adapters receive the lifetime signal as a fourth `createSurface` argument.
107
+
108
+ ### Preserve focus across DOM commits
109
+
110
+ Add an optional synchronous `HostConfig.commitMutation` scope and a named `HostCommitActivation<Instance>` type for its returned activation callback. Fig DOM captures focus before host mutations and restores surviving focus afterward, then activates binding callbacks against the published tree before component `useBeforePaint` callbacks choose their final focus policy. Binds can focus, select, or blur without restoration overwriting their choices. Native event and custom-element callbacks may be overridden before restoration finishes; native events continue to dispatch normally. Restoration is bounded to one selection repair followed by one explicit focus attempt, including when selection repair itself fires a listener that redirects focus.
111
+
112
+ Use atomic native moves when nodes share a shadow-including root to preserve browser-managed state, including native dialog/popover membership. Ordinary insertion remains the fallback. Removed or hidden elements are not restored, and focus restoration does not request scrolling.
113
+
114
+ ### Preserve text selection across DOM commits
115
+
116
+ Capture input, textarea, and DOM selection once before mutations and restore surviving boundaries and direction before `useBeforePaint`. Child boundaries follow surviving children instead of stale indices, so sibling edits preserve the selected text and caret position. Cover accessible shadow roots, multi-node moves, and focused descendants of editing hosts. Skip removed or reordered boundaries that no longer define a valid range, and clamp shortened text offsets. Component layout policy runs after preservation, replacing per-move callback-intent heuristics with explicit commit ordering.
117
+
118
+ ### Keep native widget changes in step with input
119
+
120
+ Run native toggle, dialog dismissal, form reset, and pointer/touch cancellation events at discrete priority. This prevents a dismissed popover from reopening with stale state and closing another popup opened by the next click.
121
+
1
122
  ## @bgub/fig-dom@0.1.2
2
123
 
3
124
  ### Ignore temporary view transition styles during hydration
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Bind, i as HostStyle, n as EmptyPropValue, o as composeBind, r as HostProps, t as HostIntrinsicElements } from "./jsx-It_Mpx4I.js";
1
+ import { a as Bind, c as composeBind, i as HostStyle, l as hostBinding, n as EmptyPropValue, o as Binding, r as HostProps, s as HostBinding, t as HostIntrinsicElements } from "./jsx-CUjg0W41.js";
2
2
  import { AwaitedFigNode, DataResource, DataResourceKey, DataResourceKeyInput, FigAssetResource, FigNode, FigPortal, Key, MixinDescriptor } from "@bgub/fig";
3
3
  import { FigRoot, FigRootOptions, RecoverableErrorInfo } from "@bgub/fig-reconciler";
4
4
  import { PayloadDecodeOptions } from "@bgub/fig/payload";
@@ -64,6 +64,14 @@ interface PayloadComponent<TProps extends object> extends DataResource<[TProps],
64
64
  declare function createPayloadComponent<TProps extends object>(options: PayloadComponentOptions<TProps>): PayloadComponent<TProps>;
65
65
  //#endregion
66
66
  //#region src/index.d.ts
67
+ /** Describes why a component requires browser rendering. */
68
+ type BrowserRenderReason = string | (() => unknown);
69
+ /**
70
+ * Leaves the closest server-rendered Suspense boundary in its fallback state
71
+ * so this component can render in the browser. This is a no-op during browser
72
+ * rendering. A lazy reason is evaluated only by the server.
73
+ */
74
+ declare function readBrowser(reason?: BrowserRenderReason): void;
67
75
  /** The flush sync. */
68
76
  declare const flushSync: <T>(this: void, callback: () => T) => T;
69
77
  /** Creates root. */
@@ -73,4 +81,4 @@ declare function hydrateRoot(container: Container, children: FigNode, options?:
73
81
  /** Creates portal. */
74
82
  declare function createPortal(children: FigNode, container: Container, key?: Key | null): FigPortal<Container>;
75
83
  //#endregion
76
- export { type Bind, type Container, type EmptyPropValue, type EventCallback, type EventOptions, type FigRoot, type FigRootOptions, type HostIntrinsicElements, type HostProps, type HostStyle, type PayloadComponent, type PayloadComponentLoadContext, type PayloadComponentLoader, type PayloadComponentOptions, type PayloadSource, type RecoverableErrorInfo, composeBind, createPayloadComponent, createPortal, createRoot, flushSync, hydrateRoot, insertAssetResources, on };
84
+ export { type Bind, type Binding, BrowserRenderReason, type Container, type EmptyPropValue, type EventCallback, type EventOptions, type FigRoot, type FigRootOptions, type HostBinding, type HostIntrinsicElements, type HostProps, type HostStyle, type PayloadComponent, type PayloadComponentLoadContext, type PayloadComponentLoader, type PayloadComponentOptions, type PayloadSource, type RecoverableErrorInfo, composeBind, createPayloadComponent, createPortal, createRoot, flushSync, hostBinding, hydrateRoot, insertAssetResources, on, readBrowser };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,i as t,n,o as r,r as i,t as a}from"./renderer-jfUYsG5x.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=>{},prepareAssets:r.prepareAssets??(e=>n(e)),retainAssets:r.retainAssets,resolveClientReference:r.resolveClientReference,signal:i})}function h(e){return e.reason??Error(`Payload request aborted.`)}function g(e){let t=new WeakMap,n=1;function r(e){if(e===null)return null;if(e===void 0)return[`undefined`];if(typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`)return Number.isNaN(e)?[`number`,`NaN`]:e===1/0?[`number`,`Infinity`]:e===-1/0?[`number`,`-Infinity`]:Object.is(e,-0)?[`number`,`-0`]:e;if(typeof e==`bigint`)return[`bigint`,e.toString()];if(typeof e==`symbol`){let t=Symbol.keyFor(e);if(t===void 0)throw Error(`Only global Symbol.for symbols can be serialized.`);return[`symbol`,t]}if(typeof e==`function`)throw Error(`Functions cannot be serialized into the payload.`);if(e instanceof Date){let t=e.toJSON();if(t===null)throw Error(`Invalid Date values cannot be serialized.`);return[`date`,t]}let i=t.get(e);if(i!==void 0)return[`ref`,i];let a=n++;if(t.set(e,a),Array.isArray(e))return[`array`,a,e.map(r)];if(e instanceof Map)return[`map`,a,Array.from(e,([e,t])=>[r(e),r(t)])];if(e instanceof Set)return[`set`,a,Array.from(e,r)];let o=Object.getPrototypeOf(e);if(o!==Object.prototype&&o!==null)throw Error(`Cannot serialize ${o?.constructor?.name??`object`} into the payload.`);let s=e;return[`object`,a,Object.keys(s).sort().map(e=>[e,r(s[e])])]}return r(e)}function _(e){let t=t=>{let n=v(t);return[...e.key,e.cacheKey===void 0?n:e.cacheKey(t)]},n=u({debugArgs:e.cacheKey===void 0?void 0:v,key:t,load:async(n,r)=>{let i=await e.load(n,{key:l(r)?.key??t(n),signal:r.signal});return m(i instanceof Response?i:new Response(i.stream,{headers:{"content-type":i.contentType}}),r,{prepareAssets:e.prepareAssets??e.load.prepareAssets,resolveClientReference:e.resolveClientReference??e.load.resolveClientReference,retainAssets:e.retainAssets??e.load.retainAssets})}}),r=Object.assign(function(e){return y(e),d(r,e)},n);return Object.defineProperty(r,"displayName",{configurable:!0,value:`Payload(${e.key[0]})`}),r}function v(e){return y(e),g(e)}function y(e){if(Object.hasOwn(e,`children`))throw Error(`Payload components do not accept children.`)}const b=a.flushSync;function x(e,t){let n=a.createRoot(e,t);return i(e,{run:e=>n.data.run(e)}),w(n,e)}function S(e,t,n){let r=a.hydrateRoot(e,t,n);return i(e,{hydrate:(t,n)=>a.hydrateTarget(e,t,n),run:e=>r.data.run(e)}),w(r,e)}function C(e,t,n=null){return s(e,t,n)}function w(e,n){return{...e,unmount:()=>{e.unmount(),t(n)}}}export{r as composeBind,_ as createPayloadComponent,C as createPortal,x as createRoot,b as flushSync,S as hydrateRoot,n as insertAssetResources,e as on};
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./renderer-BPuY1pdy.js";import{STREAMED_DATA_PROPERTY as s,assertPayloadCodecMatches as c,createPortalNode as l,decodePayloadDataEntries as u,jsonPayloadCodec as d,loadContextCapabilities as f,readBrowser as p}from"@bgub/fig/internal";import{dataResource as m,readData as h}from"@bgub/fig";import{decodePayloadStream as g}from"@bgub/fig/payload";function _(e,t,n){let r=e.ownerDocument??e,i=r[s]??={},a=i[t];if(a!==void 0&&!Array.isArray(a))return;let o={push(...e){for(let t of e)n.hydrateMissing(u(t))}};return i[t]=o,a!==void 0&&o.push(...a),()=>{i[t]===o&&delete i[t]}}const v=()=>void 0;async function y(e,t,r={}){let{signal:i}=t;if(i.aborted)throw await e.body?.cancel().catch(v),b(i);if(!e.ok)throw await e.body?.cancel().catch(v),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{c(d,e.headers.get(`content-type`))}catch(e){throw await a.cancel().catch(v),e}let o=f(t);return g(a,{hydrate:o?.hydrate,onHoleError:o?.attributeError,onStreamDone:e=>{},prepareAssets:r.prepareAssets??(e=>n(e)),retainAssets:r.retainAssets,resolveClientReference:r.resolveClientReference,signal:i})}function b(e){return e.reason??Error(`Payload request aborted.`)}function x(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 S(e){let t=t=>{let n=C(t);return[...e.key,e.cacheKey===void 0?n:e.cacheKey(t)]},n=m({debugArgs:e.cacheKey===void 0?void 0:C,key:t,load:async(n,r)=>{let i=await e.load(n,{key:f(r)?.key??t(n),signal:r.signal});return y(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 w(e),h(r,e)},n);return Object.defineProperty(r,"displayName",{configurable:!0,value:`Payload(${e.key[0]})`}),r}function C(e){return w(e),x(e)}function w(e){if(Object.hasOwn(e,`children`))throw Error(`Payload components do not accept children.`)}function T(e){p(e)}const E=o.flushSync;function D(e,t){let n=o.createRoot(e,t);return i(e,{run:e=>n.data.run(e)}),A(n,e)}function O(e,t,n){let r=o.hydrateRoot(e,t,n);return i(e,{hydrate:(t,n)=>o.hydrateTarget(e,t,n),run:e=>r.data.run(e)}),A(r,e,_(e,n?.identifierPrefix??``,r.data))}function k(e,t,n=null){return l(e,t,n)}function A(e,n,r){return{...e,unmount:()=>{r?.(),e.unmount(),t(n)}}}export{r as composeBind,S as createPayloadComponent,k as createPortal,D as createRoot,E as flushSync,a as hostBinding,O as hydrateRoot,n as insertAssetResources,e as on,T as readBrowser};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -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\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"],"mapp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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
+ {"version":3,"file":"index.js","names":[],"sources":["../src/streamed-data.ts","../src/payload-decoder.ts","../src/payload-key.ts","../src/payload-component.ts","../src/index.ts"],"sourcesContent":["import {\n decodePayloadDataEntries,\n type FigDataStore,\n type PayloadDataHydrationEntry,\n STREAMED_DATA_PROPERTY,\n} from \"@bgub/fig/internal\";\nimport type { Container } from \"./events.ts\";\n\ntype StreamedDataRows = PayloadDataHydrationEntry[];\n\n// Rows queued before a root claims the prefix, or that root's receiver.\ninterface StreamedDataQueue {\n push(...batches: StreamedDataRows[]): unknown;\n}\n\ntype StreamedDataCarrier = {\n [STREAMED_DATA_PROPERTY]?: Record<string, StreamedDataQueue>;\n};\n\n// The server's `d` operation pushes rows per identifierPrefix. The first\n// hydrating root with that prefix drains the queued rows and replaces the\n// queue with a receiver that applies later rows directly, owning the prefix\n// until it unmounts. Rows fill only entries the client has no value for, so a\n// late row never overwrites client state.\nexport function adoptStreamedData(\n container: Container,\n identifierPrefix: string,\n store: FigDataStore,\n): (() => void) | undefined {\n const carrier = (container.ownerDocument ?? container) as StreamedDataCarrier;\n const queues = (carrier[STREAMED_DATA_PROPERTY] ??= {});\n const queued = queues[identifierPrefix];\n if (queued !== undefined && !Array.isArray(queued)) return undefined;\n\n const receiver: StreamedDataQueue = {\n push(...batches) {\n for (const rows of batches) {\n store.hydrateMissing(decodePayloadDataEntries(rows));\n }\n },\n };\n queues[identifierPrefix] = receiver;\n if (queued !== undefined) receiver.push(...(queued as StreamedDataRows[]));\n return () => {\n if (queues[identifierPrefix] === receiver) delete queues[identifierPrefix];\n };\n}\n","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 {\n createPortalNode,\n type FigDataStore,\n readBrowser as readBrowserDuringRender,\n} from \"@bgub/fig/internal\";\nimport type {\n FigRoot,\n FigRootOptions,\n RecoverableErrorInfo,\n} from \"@bgub/fig-reconciler\";\nimport { composeBind, hostBinding } 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\";\nimport { adoptStreamedData } from \"./streamed-data.ts\";\n\nexport { insertAssetResources } from \"./asset-resources.ts\";\nexport type { Bind, Binding, HostBinding } from \"./bind.ts\";\nexport { composeBind, hostBinding };\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/** Describes why a component requires browser rendering. */\nexport type BrowserRenderReason = string | (() => unknown);\n\n/**\n * Leaves the closest server-rendered Suspense boundary in its fallback state\n * so this component can render in the browser. This is a no-op during browser\n * rendering. A lazy reason is evaluated only by the server.\n */\nexport function readBrowser(reason?: BrowserRenderReason): void {\n readBrowserDuringRender(reason);\n}\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 // The root's handle is its renderer store, which accepts streamed rows.\n return withEventTeardown(\n root,\n container,\n adoptStreamedData(\n container,\n options?.identifierPrefix ?? \"\",\n root.data as FigDataStore,\n ),\n );\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(\n root: FigRoot,\n container: Container,\n release?: () => void,\n): FigRoot {\n return {\n ...root,\n unmount: () => {\n release?.();\n root.unmount();\n unregisterRoot(container);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O,eAAe,EAAW,cAAe,CAC9C,aAAc,GACd,MAAO,WAAW,EAAQ,IAAI,GAAG,EACnC,CAAC,EAEM,CACT,CAEA,SAAS,EACP,EACsB,CAEtB,OADA,EAAe,CAAK,EACb,EAAiB,CAAK,CAC/B,CAEA,SAAS,EAAe,EAAqB,CAC3C,GAAI,OAAO,OAAO,EAAO,UAAU,EACjC,MAAU,MAAM,4CAA4C,CAEhE,CChEA,SAAgB,EAAY,EAAoC,CAC9D,EAAwB,CAAM,CAChC,CAGA,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,EAOjE,OANA,EAAa,EAAW,CACtB,SAAU,EAAQ,IAChB,EAAY,cAAc,EAAW,EAAQ,CAAQ,EACvD,IAAM,GAAa,EAAK,KAAK,IAAI,CAAQ,CAC3C,CAAC,EAEM,EACL,EACA,EACA,EACE,EACA,GAAS,kBAAoB,GAC7B,EAAK,IACP,CACF,CACF,CAGA,SAAgB,EACd,EACA,EACA,EAAkB,KACI,CACtB,OAAO,EAAiB,EAAU,EAAW,CAAG,CAClD,CAGA,SAAS,EACP,EACA,EACA,EACS,CACT,MAAO,CACL,GAAG,EACH,YAAe,CACb,IAAU,EACV,EAAK,QAAQ,EACb,EAAe,CAAS,CAC1B,CACF,CACF"}
@@ -1,8 +1,22 @@
1
- import { FigNode, Key, MixinDescriptor, MixinInput } from "@bgub/fig";
1
+ import { FigNode, Key, MixinContext, MixinDescriptor, MixinInput } from "@bgub/fig";
2
+ import "@bgub/fig-reconciler";
2
3
  //#region src/bind.d.ts
3
- /** Describes bind. */
4
+ /** A callback owns work until its binding signal aborts. */
4
5
  type Bind<T extends Element = Element> = (node: T, signal: AbortSignal) => undefined;
5
- /** Compose bind. */
6
+ declare const HostBindingBrand: unique symbol;
7
+ /** An opaque committed host behavior created by hostBinding(). */
8
+ interface HostBinding<T extends Element = Element> {
9
+ readonly [HostBindingBrand]: Bind<T>;
10
+ }
11
+ /** Host prop value; arrays preserve each member's independent lifetime. */
12
+ type Binding<T extends Element = Element> = Bind<T> | HostBinding<T> | readonly (Binding<T> | false | null | undefined)[];
13
+ /**
14
+ * Declare a behavior inside a mixin. Its callback runs on each committed
15
+ * update, with the same signal until the owner/slot disappears, is replaced,
16
+ * or Activity hides the host. Raw bind functions retain callback lifetimes.
17
+ */
18
+ declare function hostBinding<T extends Element = Element>(context: MixinContext, owner: object, update: Bind<T>): HostBinding<T>;
19
+ /** Compose callbacks into one callable binding with a shared lifetime. */
6
20
  declare function composeBind<T extends Element = Element>(...binds: Array<Bind<T> | false | null | undefined>): Bind<T>;
7
21
  //#endregion
8
22
  //#region src/jsx-attributes.generated.d.ts
@@ -191,7 +205,7 @@ type AttributeValue = string | number | true | EmptyPropValue;
191
205
  /** Describes host style. */
192
206
  type HostStyle = Readonly<Record<string, string | EmptyPropValue>>;
193
207
  interface FigHostProps<E extends Element> {
194
- bind?: Bind<E> | EmptyPropValue;
208
+ bind?: Binding<E> | EmptyPropValue;
195
209
  children?: FigNode;
196
210
  key?: Key | null;
197
211
  mix?: MixinInput;
@@ -238,7 +252,7 @@ type HtmlHostProps<Tag extends string, E extends Element> = HostProps<E, Tag ext
238
252
  type SvgHostProps<Tag extends string, E extends Element> = HostProps<E, Tag extends keyof SvgAttributeNameByTag ? SvgAttributes<Tag> : SvgGlobalAttributeName | FigGlobalAttributeName | SvgLegacyAttributeName>;
239
253
  type OpenHtmlHostProps<E extends Element> = HostProps<E, HtmlGlobalAttributeName | FigGlobalAttributeName>;
240
254
  interface OpenHostProps<E extends Element> extends FigHostProps<E>, ReactHabitTraps {
241
- [attribute: string]: FigNode | HostStyle | MixinDescriptor | ReadonlyArray<MixinInput> | 0n | Bind<E>;
255
+ [attribute: string]: FigNode | HostStyle | MixinDescriptor | ReadonlyArray<MixinInput> | 0n | Binding<E>;
242
256
  }
243
257
  //#endregion
244
258
  //#region src/jsx.d.ts
@@ -250,4 +264,4 @@ type HostIntrinsicElements = HtmlHostPropsByTag<HTMLElementTagNameMap> & SvgHost
250
264
  [customElement: `${string}-${string}`]: OpenHostProps<HTMLElement>;
251
265
  };
252
266
  //#endregion
253
- export { Bind as a, HostStyle as i, EmptyPropValue as n, composeBind as o, HostProps as r, HostIntrinsicElements as t };
267
+ export { Bind as a, composeBind as c, HostStyle as i, hostBinding as l, EmptyPropValue as n, Binding as o, HostProps as r, HostBinding as s, HostIntrinsicElements as t };
@@ -1,4 +1,4 @@
1
- import { t as HostIntrinsicElements } from "./jsx-It_Mpx4I.js";
1
+ import { t as HostIntrinsicElements } from "./jsx-CUjg0W41.js";
2
2
  import { FigNode, Key } from "@bgub/fig";
3
3
  import { Fragment, jsx, jsxDEV, jsxs } from "@bgub/fig/jsx-runtime";
4
4
  //#region src/jsx-runtime.d.ts
@@ -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_BROWSER_MARKER as o,SUSPENSE_CLIENT_MARKER as s,SUSPENSE_COMPLETED_MARKER as c,SUSPENSE_END_MARKER as l,SUSPENSE_PENDING_PREFIX as u,TEXT_SEPARATOR_DATA as d,assetResourceFromHostAttributes as f,assetResourceFromHostProps as p,assetResourceHostProps as m,assetResourceKey as h,isFigAssetResource as ee,markClientOnlyHostBehavior as te,mixinSlot as ne}from"@bgub/fig/internal";import{createMixin as re}from"@bgub/fig";import{createRenderer as ie,runWithEventPriority as ae}from"@bgub/fig-reconciler";function oe(e,t){if(!g(e))return;let n=[];se(e,n);for(let e of n)t(e)}function se(e,t){t.push(e);for(let n=e.firstChild;n!==null;n=n.nextSibling)g(n)&&se(n,t)}function g(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===1}function _(e){return g(e)?`localName`in e&&typeof e.localName==`string`?e.localName.toLowerCase():`tagName`in e&&typeof e.tagName==`string`?e.tagName.toLowerCase():``:``}function ce(e){return e.namespaceURI===null||e.namespaceURI===`http://www.w3.org/1999/xhtml`}function v(e){return typeof e==`object`&&e&&`parentNode`in e?e.parentNode:null}function y(e){return e==null||e===!1}const b=Symbol.for(`fig.host-binding`);function le(e,t,n){return{[b]:n,owner:t,slot:ne(e)}}const x=new WeakMap,ue=new WeakSet;let S=null;function de(e){let t=S,n=new Map;S=n;try{e()}finally{S=t}return e=>{let t=S;S=null;try{for(let[t,{element:r,key:i,update:a}]of n)e(r,()=>ye(r,i,t,a),t.assetOwner)}finally{n.clear(),S=t}}}function fe(...e){let t=e.filter(e=>typeof e==`function`);return(e,n)=>{for(let r of t)r(e,n)}}function pe(e,t,n){let r=x.get(e)??new Map,i=new Map,a=0;function o(e){if(y(e)){a++;return}if(Array.isArray(e)){e.forEach(o);return}if(typeof e==`function`){i.set(`callback:${a++}`,{callback:e,owner:void 0});return}if(be(e)){let t=`host:${e.slot}`;if(i.has(t))throw Error(`Duplicate host binding slot.`);i.set(t,{callback:e[b],owner:e.owner});return}throw Error(`The bind prop must contain callbacks or host bindings.`)}o(t);for(let[e,t]of r){let n=i.get(e);(n===void 0||n.owner!==t.owner||n.owner===void 0&&n.callback!==t.callback)&&C(t)}let s=new Map;for(let[e,t]of i){let i=r.get(e),a=i!==void 0&&i.owner===t.owner?i:{assetOwner:n,callback:t.callback,owner:t.owner,controller:null,strictRan:!1};a.assetOwner=n,a.callback=t.callback,s.set(e,a)}x.set(e,s);for(let[t,n]of s)ve(e,t,n,n.owner!==void 0);s.size===0&&x.delete(e)}function me(e){for(let[t,n]of x.get(e)??[])ve(e,t,n,!1)}function he(e){ue.add(e);for(let t of x.get(e)?.values()??[])C(t)}function ge(e){ue.delete(e),me(e)}function _e(e){for(let t of x.get(e)?.values()??[])C(t);x.delete(e)}function ve(e,t,n,r){n.controller!==null&&!r||(S===null?ye(e,t,n,r):S.set(n,{element:e,key:t,update:r}))}function ye(e,t,n,r){if(!(x.get(e)?.get(t)!==n||e.parentNode===null||ue.has(e))){if(n.controller!==null){r&&n.callback(e,n.controller.signal);return}n.controller=new AbortController,n.callback(e,n.controller.signal)}}function C(e){let t=e.controller;e.controller=null,t?.abort()}function be(e){return typeof e==`object`&&!!e&&`owner`in e&&(typeof e.owner==`object`||typeof e.owner==`function`)&&e.owner!==null&&`slot`in e&&typeof e.slot==`string`&&b in e&&typeof e[b]==`function`}const w=Symbol.for(`fig.native-event-descriptors`),xe=re((e,t,n,r)=>{te(e,`on()`);let i=e.props,a=i[w];a===void 0&&(a=[],Object.defineProperty(i,w,{configurable:!0,value:a})),a.push({callback:n,options:r,slot:ne(e),type:t})});function Se(e,t,n){return xe(e,t,n)}const Ce=[];function we(e){return e[w]??Ce}function Te(e,t,n){let r=T(e,`currentTarget`,{value:t});try{return n(e)}finally{r()}}function Ee(e,t,n){let r={immediateStopped:!1,stopped:!t&&e.cancelBubble===!0},i=De(e,`stopPropagation`,()=>{r.stopped=!0}),a=De(e,`stopImmediatePropagation`,()=>{r.stopped=!0,r.immediateStopped=!0}),o=T(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 De(e,t,n){let r=Reflect.get(e,t);return typeof r==`function`?T(e,t,{value(){n(),r.call(e)}}):Oe}function T(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)}:Oe}function Oe(){}const E=new WeakMap,D=new WeakMap,ke=new WeakMap,O=[],Ae=new Set(a),je=new Set(`beforeinput.beforetoggle.cancel.close.blur.change.click.contextmenu.dblclick.focus.focusin.focusout.input.keydown.keyup.mousedown.mouseup.pointercancel.pointerdown.pointerup.reset.submit.toggle.touchcancel.touchend.touchstart`.split(`.`)),k=new Set([`drag`,`dragover`,`mousemove`,`pointermove`,`scroll`,`touchmove`,`wheel`]),Me=new Set([...je,...k,`mouseenter`,`mouseleave`]),Ne=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 Pe=e=>e();function Fe(e){Pe=e}function Ie(e,t){let n=A(e);n.run=t.run,t.hydrate!==void 0&&(n.hydrate=t.hydrate,Ye(e,n),Re(e))}const Le=new WeakMap;function Re(e){let t=e.ownerDocument??e,i=Le.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,Le.set(t,i)}let o=!1;for(let t=0;t<i.length;){let n=i[t];if(Ae.has(n.type)&&B(e,n.target)){i.splice(t,1),Ze(e,n.type,n),o=!0;continue}t+=1}o&&queueMicrotask(M)}function ze(e){let t=D.get(e);if(t!==void 0){Be(e);for(let n of t.listeners.values())e.removeEventListener(n.type,n.listener,n.capture);Ve(e),D.delete(e);for(let t=O.length-1;t>=0;--t)O[t].root===e&&O.splice(t,1)}}function Be(e){let t=D.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 Ve(e){for(let t of D.get(e)?.portals??[])Ve(t),j(t)}function A(e){let t=D.get(e);return t===void 0&&(t={hydrate:null,hydrationListeners:null,listeners:new Map,portalOwner:null,portals:null,run:null},D.set(e,t)),t}function He(e,t){let n=E.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??=Ge(e),s!==void 0&&N(s),s=qe(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())N(e);i.length===0?E.delete(e):E.set(e,i)}function Ue(e){let t=E.get(e);if(t===void 0)return;let{listenerTarget:n,root:r}=Ge(e);for(let i of t)nt(e,r,n,i)}function We(e){let t=E.get(e);if(t!==void 0){for(let e of t)N(e);E.delete(e)}}function Ge(e){let t=V(e);if(t===null)return{listenerTarget:null,root:null};let n=D.get(t);return n===void 0?{listenerTarget:null,root:null}:{listenerTarget:t,root:n.portalOwner?.root??(n.run===null?null:t)}}function Ke(e,t,n){let r=A(e),i=V(n)??t;if(r.portalOwner!==null){if(r.portalOwner.root===t&&r.portalOwner.parentTarget===i){r.portalOwner={logicalParent:n,parentTarget:i,root:t};return}j(e)}r.portalOwner={logicalParent:n,parentTarget:i,root:t};let a=A(i);(a.portals??=new Set).add(e);for(let n of a.listeners.values())L(t,e,n.type,n.capture,n.passive)}function j(e){let t=D.get(e);if(!t?.portalOwner)return;let n=t.portalOwner;t.portalOwner=null;let r=D.get(n.parentTarget);if(r!==void 0){r.portals?.delete(e);for(let t of r.listeners.keys())R(e,t)}}function M(){let e=new Set;for(let t=0;t<O.length;){let n=O[t];if(!B(n.listenerTarget??n.root,n.event.target)){O.splice(t,1);continue}if(Qe(n)===`blocked`){e.add(n.root),t+=1;continue}if(e.has(n.root)){t+=1;continue}O.splice(t,1),$e(n)}}function qe(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 nt(e,t,n,o),o}function N(e){z(e),I(e)}function Je(e,t,n,r,i,a){let o=V(a.target);if(o!==t&&((o===null?null:D.get(o)??null)?.portalOwner?.root===e||!B(t,a.target))||Xe(e,n,a)===`blocked`)return;let s=P(e,t,n,r,i,a);s.length!==0&&Ee(a,!1,e=>F(s,a,e))}function Ye(e,t){if(t.hydrationListeners===null){t.hydrationListeners=[];for(let n of Me){let r=t=>Xe(e,n,t);t.hydrationListeners.push([n,r]),e.addEventListener(n,r,{capture:!0,passive:ct(n)})}}}function Xe(e,t,n){let r=D.get(e)?.hydrate??null;if(r===null)return`none`;let i=ke.get(n),a=i?.get(e);if(a!==void 0)return a;let o=H(t),s=ae(o,()=>r(n.target,o));return i===void 0&&(i=new WeakMap,ke.set(n,i)),i.set(e,s),s===`blocked`&&Ae.has(t)&&Ze(e,t,n),s}function Ze(e,t,n){O.push({event:n,listenerTarget:V(n.target),root:e,type:t})}function Qe(e){let t=D.get(e.root)?.hydrate??null;if(t===null)return`none`;let n=H(e.type);return ae(n,()=>t(e.event.target,n))}function $e(e){let{event:t,root:n,type:r}=e,i=e.listenerTarget??e.root;Ee(t,!0,e=>{F(P(n,i,r,!0,null,t),t,e),!(e.immediateStopped||e.stopped)&&F(P(n,i,r,!1,null,t),t,e)})}function P(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=E.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 F(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{et(i,t)}finally{let e=i.slot;e.attachment===null&&I(e)}}}function et(e,t){let n=e.slot;I(n),n.controller=new AbortController;let r=n.controller.signal;Pe(()=>{tt(e.root,()=>ae(H(n.type),()=>{Te(t,e.element,t=>{e.callback(t,r)})}))})}function tt(e,t){let n=e===null?null:D.get(e)?.run??null;return n===null?t():n(t)}function I(e){e.controller?.abort(),e.controller=null}function nt(e,t,n,r){Ne.has(r.type)?rt(e,t,r):it(t,n,r)}function rt(e,t,n){let r=n.attachment;if(r!==null){if(`element`in r&&r.element===e){t!==null&&(r.root=t);return}z(n)}let i=t=>{try{et({callback:n.callback,element:e,root:at(n),slot:n},t)}finally{n.attachment===null&&I(n)}};n.attachment={element:e,listener:i,root:t},e.addEventListener(n.type,i,{capture:n.capture,passive:n.passive})}function it(e,t,n){if(e===null||t===null)return;let r=n.attachment;r!==null&&`listenerTarget`in r&&r.root===e&&r.listenerTarget===t||(z(n),n.attachment={listenerTarget:t,root:e},L(e,t,n.type,n.capture,n.passive))}function L(e,t,n,r,i){let a=A(t).listeners,o=`${n}:${r}:${i}`,s=a.get(o);if(s===void 0){s={capture:r,count:0,listener:a=>Je(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 D.get(t)?.portals??[])L(e,a,n,r,i)}s.count+=1}function R(e,t){let n=D.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 D.get(e)?.portals??[])R(n,t)}}function z(e){let t=e.attachment;t!==null&&(e.attachment=null,`element`in t?t.element.removeEventListener(e.type,t.listener,e.capture):R(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];g(t)&&r.push(t)}return st(r,e,t),r}}for(let e=n.target;e!==t&&(g(e)&&r.push(e),e=v(e),e!==null););return st(r,e,t),r}function st(e,t,n){let r=D.get(n)?.portalOwner??null;if(r===null||r.root!==t)return;let i=r.logicalParent;for(;i!==null&&i!==t;){if(lt(i)){let e=D.get(i)?.portalOwner??null;if(e!==null&&e.root===t){i=e.logicalParent;continue}}g(i)&&e.push(i),i=v(i)}}function B(e,t){for(let n=t;n!==null;){if(n===e)return!0;n=v(n)}return!1}function V(e){for(let t=e;t!==null;){if(lt(t)){let e=D.get(t);if(e!==void 0&&(e.portalOwner!==null||e.run!==null))return t}t=v(t)}return null}function H(e){return je.has(e)?`discrete`:k.has(e)?`continuous`:`default`}function ct(e){return k.has(e)||e===`touchstart`||e===`touchend`}function lt(e){return typeof e==`object`&&!!e&&`addEventListener`in e&&`childNodes`in e}function ut(e){oe(e,e=>{me(e),Ue(e)})}function U(e){oe(e,e=>{_e(e),We(e)})}const W=new WeakMap;function dt(e){return Dt(e)||e===`checked`||e===`defaultChecked`}function ft(e,t,n,r,i,a){if(t===`select`&&Dt(n))return;if(t===`option`&&n===`value`){G(e,`value`,xt(r));return}let o=a.initial===!0&&a.hydrating!==!0;n===`value`?y(r)||_t(e,r):n===`defaultValue`?gt(e,r,t,o&&i.value===void 0):n===`checked`?r!==void 0&&bt(e,r):n===`defaultChecked`&&yt(e,r,o&&i.checked===void 0)}function pt(e,t,n,r){if(t!==`select`)return;let i=n.value!==void 0,a=i?n.value:n.defaultValue;if(y(a)){W.delete(e);return}let o=!i&&r.hydrating===!0,s={appliedDefault:W.get(e)?.appliedDefault===!0||!i,applyDefaultToInsertedOptions:!o&&!i&&r.initial===!0,controlled:i,selectedValues:Array.isArray(a)?new Set(a.map(String)):String(a)};W.set(e,s),!o&&(i||r.initial===!0)&&St(e,s.selectedValues)}function mt(e,t=!1){let n=Tt(e);if(n===null)return;let r=W.get(n);r!==void 0&&(!r.controlled&&r.appliedDefault&&!t||!r.controlled&&t&&!r.applyDefaultToInsertedOptions||(St(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,n,r){let i=xt(t),a=i??``;`defaultValue`in e&&(e.defaultValue=a),n===`textarea`?e.textContent=a:G(e,`value`,i),r&&`value`in e&&vt(e,a)}function _t(e,t){let n=xt(t);n!==null&&(`value`in e?vt(e,n):G(e,`value`,n))}function vt(e,t){let n=e;n.value!==t&&(n.value=t)}function yt(e,t,n){let r=t===!0;`defaultChecked`in e&&(e.defaultChecked=r),G(e,`checked`,r),n&&bt(e,t)}function bt(e,t){let n=t===!0;`checked`in e?e.checked=n:G(e,`checked`,n)}function xt(e){return y(e)?null:String(e)}function St(e,t){if(_(e)===`option`){Ct(e,t);return}Et(e,e=>{Ct(e,t)})}function Ct(e,t){e.selected=wt(e,t)}function wt(e,t){let n=e.getAttribute(`value`)??(e.textContent??``).replace(/\s+/g,` `).trim();return typeof t==`string`?n===t:t.has(n)}function Tt(e){let t=e.parentNode;for(;t!==null;){if(g(t)&&_(t)===`select`)return t;t=t.parentNode}return null}function Et(e,t){for(let n=e.firstChild;n!==null;){let e=n.nextSibling;g(n)&&(_(n)===`option`?t(n):Et(n,t)),n=e}}function Dt(e){return e===`value`||e===`defaultValue`}function G(e,t,n){y(n)?e.removeAttribute(t):e.setAttribute(t,String(n))}function Ot(e,t,n){let r=e.style;if(r===void 0)return;let i=kt(t),a=kt(n);for(let e of Object.keys(i))e in a||jt(r,e);for(let[e,t]of Object.entries(a))y(t)?jt(r,e):At(r,e,t)}function kt(e){return typeof e==`object`&&e?e:{}}function At(e,t,n){typeof n!=`number`&&typeof n!=`bigint`&&(t.startsWith(`--`)&&typeof e.setProperty==`function`?e.setProperty(t,String(n)):e[t]=n)}function jt(e,t){t.startsWith(`--`)&&typeof e.removeProperty==`function`?e.removeProperty(t):e[t]=``}const Mt=`http://www.w3.org/1999/xlink`;function K(e,t,n,r={}){(`mix`in t||`mix`in n)&&He(e,we(n));let i=_(e),a=ce(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`&&s!==`bind`){if(s===`unsafeHTML`){r.hydrating===!0?Ft(c):o!==c&&Pt(e,c);continue}if(!zt(s)){if(dt(s)){ft(e,i,s,c,n,r);continue}o!==c&&(s===`style`?Ot(e,o,c):Lt(e,It(s,a),c))}}}pt(e,i,n,r),(i===`option`||i===`optgroup`)&&mt(e),t.bind!==n.bind&&pe(e,n.bind,r.assetOwner)}function Nt(e,t){K(e,{},t,{hydrating:!0})}function Pt(e,t){let n=Ft(t);`innerHTML`in e&&(e.innerHTML=n??``)}function Ft(e){if(y(e))return null;if(typeof e==`string`)return e;throw Error(`The unsafeHTML prop must be a string.`)}function It(e,t){return t?e.toLowerCase():e}function Lt(e,t,n){if(y(n)){Rt(e,t);return}if(t===`xlink:href`){e.setAttributeNS(Mt,t,String(n));return}e.setAttribute(t,String(n))}function Rt(e,t){if(t===`xlink:href`){e.removeAttributeNS(Mt,`href`);return}e.removeAttribute(t)}function zt(e){return e===`children`||e===`key`||e===`mix`||e===`suppressHydrationWarning`||e===`unsafeHTML`||Bt(e)}function Bt(e){return/^on[A-Z]/.test(e)}var Vt=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))return`retained`;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.`);K(this.element,this.rendered??{},e,{assetOwner:this.winner}),this.resourceKind===`title`&&(this.element.textContent=Ht(e.children)),this.rendered=e}};function Ht(e){return e==null||typeof e==`boolean`?``:typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(Ht).join(``):``}const Ut=new WeakMap,q=new WeakMap,Wt=new WeakSet;function Gt(e,t,n){let r=J();if(r===null)return;let i=$t(e),a=$t(t);for(let[e]of i)a.has(e)||nn(r,e,n);for(let[e,t]of a)i.has(e)?(t.kind===`title`||t.kind===`meta`)&&tn(r,e,t,n):en(r,t,n)}function Kt(e,t){let n=J(),r=p(e,t);return n===null||r===null?null:document.createElement(e)}function qt(e,t,n){let r=J();if(r===null)return e;let i=p(_(e),t);if(i===null)return e;if(Y(i))return rn(r,i,t,n,e);let a=h(i),o=r.entries.get(a)?.element??X(r,a),s=o??e;if(o===null)K(e,{},t,{initial:!0,assetOwner:n});else{let e=we(t);e.length!==0&&He(o,e),y(t.bind)||pe(o,t.bind,n)}return Jt(r,s,a,i.kind)}function Jt(e,t,n,r){let i=e.entries.get(n);if(i?.kind===`metadata`)throw Error(`Expected a persistent resource entry.`);return i===void 0?(q.set(t,{key:n,kind:r}),e.entries.set(n,{count:1,element:t,kind:`persistent`,ready:null})):i.count+=1,cn(e,i?.element??t)}function Yt(e,t){let n=J(),r=q.get(e);if(n===null||r===void 0)return;let i=n.entries.get(r.key);if(i?.kind===`metadata`){an(n,r.key,i,t);return}if(r.kind===`title`||r.kind===`meta`){q.delete(e),mn(e);return}Xt(n,e)}function Xt(e,t){let n=q.get(t);if(n===void 0)return;let r=e.entries.get(n.key);if(r===void 0||r.element!==t){if(dn(e,t))return;q.delete(t);return}if(r.kind!==`persistent`)throw Error(`Expected a persistent resource entry.`);r.count>0&&--r.count}function Zt(e,t,n,r){let i=_(e),a=p(i,n),o=q.get(e);if(a===null)return e;let s=h(a),c=J();if(c===null)return K(e,t,n,{assetOwner:r}),e;let l=o===void 0?void 0:c.entries.get(o.key);return l?.kind===`metadata`?!Y(a)||s===o?.key?(l.update(r,Y(a)?sn(a,n):n),l.element):(Yt(e,r),rn(c,a,n,r)):o===void 0||s===o.key?(K(e,t,n,{assetOwner:r}),e):(Yt(e,r),qt(Kt(i,n)??e,n,r))}function Qt(e){let t=J();if(t===null)return Promise.resolve();let n=[];for(let r of e){if(!ee(r)||r.kind===`title`||r.kind===`meta`)continue;let e=h(r),i=t.entries.get(e)?.element,a=(i?.parentNode===t.head?i:null)??X(t,e);if(a!==null){let i=t.entries.get(e);if(i?.kind===`metadata`)throw Error(`Expected a persistent resource entry.`);i?.element!==a&&(i={count:1,element:a,kind:`persistent`,ready:null},t.entries.set(e,i),q.set(a,{key:e,kind:r.kind}));let o=fn(t,r,e,i);o!==null&&n.push(o);continue}let o=yn(r),s={count:1,element:o,kind:`persistent`,ready:null};s.ready=gn(r)?vn(o).then(()=>{t.entries.get(e)===s&&(s.ready=null)}):null,t.entries.set(e,s),q.set(o,{key:e,kind:r.kind}),ln(t,o),s.ready!==null&&n.push(s.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=Ut.get(document.head);if(e===void 0){let t={entries:new Map,head:document.head,discovered:null,observer:null},n=document.defaultView?.MutationObserver;n!==void 0&&(t.observer=new n(e=>un(t,e)),t.observer.observe(t.head,{childList:!0,attributes:!0,subtree:!0})),e=t,Ut.set(document.head,e)}return e}function $t(e){let t=new Map;if(e===null)return t;let n=Array.isArray(e)?e:[e];for(let e of n){if(!ee(e))continue;let n=h(e);(!t.has(n)||Y(e))&&t.set(n,e)}return t}function en(e,t,n){if(Y(t)){rn(e,t,on(t),n);return}let r=h(t);Jt(e,e.entries.get(r)?.element??X(e,r)??yn(t),r,t.kind)}function tn(e,t,n,r){let i=e.entries.get(t);if(i===void 0){en(e,n,r);return}if(i.kind!==`metadata`)throw Error(`Expected a metadata resource entry.`);i.update(r,on(n))}function nn(e,t,n){let r=e.entries.get(t);r!==void 0&&(r.kind===`metadata`?an(e,t,r,n):Xt(e,r.element))}function rn(e,t,n,r,i){let a=h(t),o=sn(t,n),s=e.entries.get(a);if(s?.kind===`persistent`)throw Error(`Expected a metadata resource entry.`);if(s===void 0){let n=X(e,a)??i??document.createElement(t.kind);s=new Vt(n,t.kind,r,o),e.entries.set(a,s),q.set(n,{key:a,kind:t.kind})}else s.acquire(r,o);return cn(e,s.element)}function an(e,t,n,r){n.release(r)!==`retained`&&(e.entries.delete(t),q.delete(n.element),mn(n.element))}function on(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 sn(e,t){return e.kind===`title`?{...t,children:e.value}:t}function Y(e){return e.kind===`title`||e.kind===`meta`}function cn(e,t){return t.parentNode!==e.head&&ln(e,t),ut(t),t}function ln(e,t){Wt.add(t);let n=hn(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=g(i)?hn(i):null;if(a!==null){if(a===n)r=!0;else if(r){e.head.insertBefore(t,i);return}}}e.head.appendChild(t)}function X(e,t){if(e.observer===null?e.discovered=null:un(e,e.observer.takeRecords()),e.discovered===null){let t=new Map;for(let n=e.head.firstChild;n!==null;n=n.nextSibling)if(g(n)){let e=pn(n);if(e!==null){let r=h(e);t.has(r)||t.set(r,n)}}e.discovered=t}return e.discovered.get(t)??null}function un(e,t){for(let n of t){(n.type===`attributes`||n.removedNodes.length!==0)&&(e.discovered=null);for(let t of n.addedNodes)Wt.delete(t)||(e.discovered=null)}}function dn(e,t){for(let n of e.entries.values())if(n.element===t)return!0;return!1}function fn(e,t,n,r){if(!gn(t))return null;if(r.ready!==null)return r.ready;if(!_n(r.element))return null;let i=vn(r.element).then(()=>{e.entries.get(n)===r&&(r.ready=null)});return r.ready=i,i}function pn(e){return f(_(e),t=>e.getAttribute(t))}function mn(e){U(e),e.parentNode?.removeChild(e)}function hn(e){if(_(e)!==`link`)return null;let t=pn(e);return t?.kind===`stylesheet`?t.precedence??``:null}function gn(e){return e.kind!==`stylesheet`||e.blocking===`none`?!1:e.media===void 0||e.media===``||typeof matchMedia!=`function`||matchMedia(e.media).matches}function _n(e){return _(e)===`link`&&e.getAttribute(`rel`)===`stylesheet`&&`sheet`in e&&e.sheet===null}function vn(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 yn(e){let t=document.createElement(e.kind===`script`?`script`:`link`),n=m(e);for(let e of Object.keys(n)){let r=n[e];t.setAttribute(e,r===!0?``:r)}return t}function bn(e,t){let n=e.ownerDocument??e,r=e.getRootNode(),i=r.nodeType===11&&`host`in r?r:n;i.activeElement||(i=n);let a=i.activeElement;for(;a?.shadowRoot?.activeElement;)i=a.shadowRoot,a=i.activeElement;if(!a||a===n.body||a===n.documentElement){t();return}let o=a,s=xn(o,i);try{t()}finally{o.isConnected&&o.ownerDocument===n&&(s?.(),i.activeElement!==o&&Tn(o)&&o.focus?.({preventScroll:!0}))}}function xn(e,t){if(e.localName===`input`||e.localName===`textarea`){let t=e,{selectionStart:n,selectionEnd:r,selectionDirection:i}=t;return n===null||r===null?null:()=>{t.selectionStart!==null&&(t.selectionStart!==n||t.selectionEnd!==r||t.selectionDirection!==i)&&Tn(t)&&t.setSelectionRange(n,r,i??void 0)}}let n=e.ownerDocument.getSelection(),r=n&&Sn(n,t);if(!n||!r||!e.contains(r.startContainer)||!e.contains(r.endContainer))return null;let{startContainer:i,startOffset:a,endContainer:o,endOffset:s}=r,c=r.collapsed,l=wn(i,a,!1),u=c?l:wn(o,s,!0),d=Cn(n,r);return()=>{let r=l(),f=c?r:u();if(!r||!f||!e.contains(r.node)||!e.contains(f.node))return;let p=Sn(n,t);if(r.node===i&&r.offset===a&&f.node===o&&f.offset===s&&p?.startContainer===r.node&&p.startOffset===r.offset&&p.endContainer===f.node&&p.endOffset===f.offset&&Cn(n,p)===d)return;let m=e.ownerDocument.createRange();m.setStart(r.node,r.offset),m.setEnd(f.node,f.offset),!(m.startContainer!==r.node||m.startOffset!==r.offset||!c&&m.collapsed&&(i.nodeType!==3||o.nodeType!==3))&&Tn(e)&&n.setBaseAndExtent(d?f.node:r.node,d?f.offset:r.offset,d?r.node:f.node,d?r.offset:f.offset)}}function Sn(e,t){return t.nodeType===11&&e.getComposedRanges?e.getComposedRanges({shadowRoots:[t]})[0]??null:e.rangeCount?e.getRangeAt(0):null}function Cn(e,t){return e.direction===`backward`||e.direction===void 0&&e.anchorNode===t.endContainer&&e.anchorOffset===t.endOffset}function wn(e,t,n){if(e.nodeType===3)return()=>({node:e,offset:Math.min(t,e.nodeValue?.length??0)});let r=t>0&&(n||t===e.childNodes.length),i=e.childNodes[t-+!!r];return i?()=>{let e=i.parentNode;if(!e)return null;let t=+!!r;for(let e=i.previousSibling;e;e=e.previousSibling)t++;return{node:e,offset:t}}:()=>({node:e,offset:0})}function Tn(e){return e.checkVisibility?.({visibilityProperty:!0})!==!1}function En(e,t,n){(t.parentNode!==e||t!==n&&t.nextSibling!==n)&&(t.parentNode!==null&&typeof e.moveBefore==`function`&&t.getRootNode({composed:!0})===e.getRootNode({composed:!0})?e.moveBefore(t,n):e.insertBefore(t,n))}function Dn(e){if(!Q(e))return null;let t=Z(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 Z(e)?.status??t.status}}}function Z(e){if(!Q(e))return null;if(e.data===c)return{id:null,status:`completed`};if(e.data===s)return{id:null,status:`client-rendered`};if(e.data===o)return{id:null,status:`browser-rendered`};let t=e.data.startsWith(u)?e.data.slice(u.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(Q(n)){if(Z(n)!==null){t+=1;continue}if(n.data===l){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(Q(n)){if(n.data===l){e+=1;continue}if(Z(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 Q(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=ie({createInstance:Wn,commitMutation:(e,t)=>de(()=>bn(e,t)),createTextInstance:e=>document.createTextNode(e),validateInstanceNesting:(e,t,n)=>{},validateTextNesting:(e,t)=>{},containerType:e=>g(e)?_(e):null,appendInitialChild:(e,t)=>{e.appendChild(t),g(t)&&nr(t)&&mt(t,!0)},finalizeInitialInstance:(e,t)=>K(e,{},t,{initial:!0}),setTextContent:(e,t)=>{e.textContent!==t&&(e.textContent=t)},getFirstHydratableChild:Yn,getNextHydratableSibling:e=>$(e.nextSibling),canHydrateInstance:Un,canHydrateTextInstance:(e,t,n)=>tr(e)&&(n===!0||e.nodeValue===t),canRetainHydrationTail:e=>{let t=_(e);return t===`html`||t===`head`||t===`body`},resolveSingletonInstance:Gn,acquireSingletonInstance:(e,t)=>{Kn(e),K(e,{},t,{initial:!0})},releaseSingletonInstance:(e,t)=>{K(e,t,{}),Kn(e)},resolveHoistedInstance:(e,t,n)=>Jn(e,n)===`http://www.w3.org/1999/xhtml`?Kt(e,t):null,commitHoistedInstance:qt,commitAssetResources:Gt,removeHoistedInstance:Yt,updateHoistedInstance:Zt,shouldCommitUpdate:(e,t,n)=>ht(e,n),clearContainer:e=>{qn(e,zn(e)),queueMicrotask(M)},insertBefore:(e,t,n)=>{En(e,t,n),g(t)&&nr(t)&&mt(t),ut(t)},removeChild:(e,t)=>{U(t),e.removeChild(t)},commitTextUpdate:(e,t)=>{e.nodeValue!==t&&(e.nodeValue=t)},commitUpdate:K,commitHydratedInstance:Nt,getActivityBoundary:Hn,getFirstActivityHydratable:e=>$(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=>{he(e),e.style.setProperty(`display`,`none`,`important`)},unhideInstance:(e,t)=>{let n=t.style?.display;e.style.setProperty(`display`,typeof n==`string`?n:``),ge(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(M)},removeDehydratedSuspenseBoundary:e=>{Fn(e),queueMicrotask(M)},completeRootHydration:e=>{Be(e),queueMicrotask(M)},preparePortalContainer:Ke,removePortalContainer:j});Fe(Bn.batchedUpdates),e(Bn.scheduleRefresh);function Vn(e){return`content`in e?e.content:e}function Hn(e){return g(e)&&_(e)===`template`&&e.getAttribute(t)!==null?e:null}function Un(e,t,n){return!g(e)||!(`setAttribute`in e)||_(e)!==t.toLowerCase()?!1:er(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&&g(n)){let e=_(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}}U(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&&_(t)!==`foreignobject`?t.namespaceURI??`http://www.w3.org/1999/xhtml`:`http://www.w3.org/1999/xhtml`}function Yn(e,t){return t!==void 0&&$n(t)!==null||_(e)===`textarea`&&t!==void 0&&Qn(t)?null:$(e.firstChild)}function $(e){let t=e;for(;t!==null&&(Zn(t)||t.nodeType===10||Xn(t));)t=t.nextSibling;return t}function Xn(e){return g(e)&&e.getAttribute(i)!==null}function Zn(e){return e.nodeType===8&&e.nodeValue===d}function Qn(e){return e.value!==void 0||e.defaultValue!==void 0}function $n(e){return y(e.unsafeHTML)?null:e.unsafeHTML}function er(e,t){let n=$n(t);return n===null||typeof n!=`string`||`innerHTML`in e}function tr(e){return e.nodeType===3}function nr(e){let t=_(e);return t===`option`||t===`optgroup`}export{Se as a,ze as i,Qt as n,fe as o,Ie as r,le as s,Bn as t};
2
+ //# sourceMappingURL=renderer-BPuY1pdy.js.map