@bgub/fig 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,39 @@
1
+ ## @bgub/fig@2.2.2
2
+
3
+ ### Keep sibling state when a conditional child appears
4
+
5
+ An unkeyed child now keeps its identity when an earlier sibling switches
6
+ between rendering nothing and rendering something. `{open && <Panel />}<Counter />`
7
+ no longer remounts `Counter`, and an unkeyed sibling after a growing array
8
+ keeps its state. This matches React.
9
+
10
+ ### Preserve async context across Suspense retries
11
+
12
+ Keep HTML and Payload retries in their originating request context when custom
13
+ thenables settle inside a different request. Client root pings and committed
14
+ boundary retries also preserve the context where their listeners were attached,
15
+ so scheduling retains the originating interaction attribution.
16
+
17
+ Retry notifications now pass through a native promise reaction, including for
18
+ synchronously notifying thenables. Fulfillment and rejection each wake a listener
19
+ at most once without adopting the settlement value.
20
+
21
+ ## @bgub/fig@2.2.1
22
+
23
+ ### Stream shell dependencies after the shell
24
+
25
+ The shell's reads now get the same treatment as a streamed Suspense
26
+ boundary's. Their opted-in `transfer` dependencies, such as a TanStack DB
27
+ collection behind a live query, follow the shell in a `d` operation instead
28
+ of riding in `takeData()`'s snapshot. The renderer writes their markers
29
+ ahead of the shell, first in `<head>` for a document, so the browser holds
30
+ those loads until the forms arrive or the document finishes loading. A page
31
+ that awaits a query in its route loader, with no Suspense boundary, now
32
+ hydrates from the query's rows before the collection's rows download.
33
+
34
+ `takeData()` no longer returns those dependency keys; `hydrateRoot` applies
35
+ them from the stream. `streamData: false` and prerendering are unchanged.
36
+
1
37
  ## @bgub/fig@2.2.0
2
38
 
3
39
  ### Add transfer rules for data resources
@@ -44,6 +44,7 @@ interface DataStoreHost<Owner extends object, Lane> {
44
44
  interface DataStore<Owner extends object = object, Lane = unknown> extends FigDataStore {
45
45
  readonly host: DataStoreHost<Owner, Lane>;
46
46
  snapshotKeys(canonicalKeys: Iterable<string>, deferred?: FigDataHydrationEntry[]): FigDataHydrationEntry[];
47
+ snapshotDependencies(canonicalKeys: Iterable<string>): FigDataHydrationEntry[];
47
48
  }
48
49
  /** Data resource. */
49
50
  declare function dataResource<TArgs extends unknown[], TValue, TForm = unknown>(options: DataResourceOptions<TArgs, TValue, TForm>): DataResource<TArgs, TValue>;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { $t as FigDataStoreOptions, A as Fragment, At as preconnect, B as ViewTransitionPhase, Bt as DataResourceLoadContext, C as FigNode, Et as font, F as SuspenseProps, Ft as title, H as ViewTransitionSurface, Ht as DataResourceWatchContext, I as ViewTransition, It as DataRefreshResult, Kt as FigDataHydrationEntry, L as ViewTransitionCallback, Lt as DataResource, M as LazyLoader, N as Props, Nt as script, O as FigViewTransition, Ot as meta, P as Suspense, Pt as stylesheet, Q as isValidElement, R as ViewTransitionClass, Rt as DataResourceKey, U as clientReference, Ut as DataResourceWatcher, V as ViewTransitionProps, Vt as DataResourceLoader, W as createElement, Yt as FigDataStoreController, Zt as FigDataStoreHandle, _ as FigClientReference, _t as TitleResource, a as AwaitedFigNode, at as ClientReferenceAssets, c as ComponentType, cn as requireCapability, ct as FigAssetResource, d as ErrorBoundaryProps, dt as MetaResourceOptions, et as lazy, f as ErrorInfo, ft as ModulePreloadResource, gt as StylesheetResource, ht as ScriptResource, it as AssetsProps, j as Key, jt as preload, kt as modulepreload, l as ElementType, lt as FigAssetResourceList, mt as PreloadResource, n as ActivityMode, o as ClientReferenceOptions, ot as CrossOrigin, pt as PreconnectResource, r as ActivityProps, rn as MissingCapabilityError, s as ComponentProps, st as FetchPriority, t as Activity, tt as AssetResourceBlocking, u as ErrorBoundary, ut as MetaResource, w as FigPortal, wt as assets, y as FigElement, z as ViewTransitionEvent, zt as DataResourceKeyInput } from "./element-Ba2mDNM_.js";
2
- import { $ as createDataStore, A as TransitionOptions, B as MixinInput, C as useReactive, D as useTransition, E as useSyncExternalStore, F as EmptyMixinValue, H as MixinType, L as MixinContext, O as TransitionCallback, P as transition, R as MixinDescriptor, S as useMemo, T as useState, V as MixinResult, W as createMixin, Y as DataResourceOptions, _ as useBeforeLayout, a as EffectCallback, at as readDataStore, b as useDeferredValue, f as readContext, g as useActionState, i as DependencyList, j as TransitionUpdate, l as StartTransition, lt as createContext, m as readPromise, n as ActionStateRunner, nt as dataResource, o as ExternalStoreSubscribe, p as readData, st as FigContext, t as ActionStateAction, u as StateSetter, v as useBeforePaint, w as useStableEvent, x as useId, y as useCallback, z as MixinFactory } from "./hooks-CUdLWnbQ.js";
2
+ import { $ as createDataStore, A as TransitionOptions, B as MixinInput, C as useReactive, D as useTransition, E as useSyncExternalStore, F as EmptyMixinValue, H as MixinType, L as MixinContext, O as TransitionCallback, P as transition, R as MixinDescriptor, S as useMemo, T as useState, V as MixinResult, W as createMixin, Y as DataResourceOptions, _ as useBeforeLayout, a as EffectCallback, at as readDataStore, b as useDeferredValue, f as readContext, g as useActionState, i as DependencyList, j as TransitionUpdate, l as StartTransition, lt as createContext, m as readPromise, n as ActionStateRunner, nt as dataResource, o as ExternalStoreSubscribe, p as readData, st as FigContext, t as ActionStateAction, u as StateSetter, v as useBeforePaint, w as useStableEvent, x as useId, y as useCallback, z as MixinFactory } from "./hooks-DM0goMC6.js";
3
3
  export { type ActionStateAction, type ActionStateRunner, Activity, type ActivityMode, type ActivityProps, type AssetResourceBlocking, type AssetsProps, type AwaitedFigNode, type ClientReferenceAssets, type ClientReferenceOptions, type ComponentProps, type ComponentType, type CrossOrigin, type DataRefreshResult, type DataResource, type DataResourceKey, type DataResourceKeyInput, type DataResourceLoadContext, type DataResourceLoader, type DataResourceOptions, type DataResourceWatchContext, type DataResourceWatcher, type DependencyList, type EffectCallback, type ElementType, type EmptyMixinValue, ErrorBoundary, type ErrorBoundaryProps, type ErrorInfo, type ExternalStoreSubscribe, type FetchPriority, type FigAssetResource, type FigAssetResourceList, type FigClientReference, type FigContext, type FigDataHydrationEntry, type FigDataStoreController, type FigDataStoreHandle, type FigDataStoreOptions, type FigElement, type FigNode, type FigPortal, type FigViewTransition, Fragment, type Key, type LazyLoader, type MetaResource, type MetaResourceOptions, MissingCapabilityError, type MixinContext, type MixinDescriptor, type MixinFactory, type MixinInput, type MixinResult, type MixinType, type ModulePreloadResource, type PreconnectResource, type PreloadResource, type Props, type ScriptResource, type StartTransition, type StateSetter, type StylesheetResource, Suspense, type SuspenseProps, type TitleResource, type TransitionCallback, type TransitionOptions, type TransitionUpdate, ViewTransition, type ViewTransitionCallback, type ViewTransitionClass, type ViewTransitionEvent, type ViewTransitionPhase, type ViewTransitionProps, type ViewTransitionSurface, assets, clientReference, createContext, createDataStore, createElement, createMixin, dataResource, font, isValidElement, lazy, meta, modulepreload, preconnect, preload, readContext, readData, readDataStore, readPromise, requireCapability, script, stylesheet, title, transition, useActionState, useBeforeLayout, useBeforePaint, useCallback, useDeferredValue, useId, useMemo, useReactive, useStableEvent, useState, useSyncExternalStore, useTransition };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as createContext, a as createDataStore, c as dataResource, d as readDataStore, p as MissingCapabilityError, r as transition, v as requireCapability } from "./transition-C03gUimZ.js";
1
+ import { S as createContext, a as createDataStore, c as dataResource, d as readDataStore, p as MissingCapabilityError, r as transition, v as requireCapability } from "./transition-B8ZLez3D.js";
2
2
  import { B as useBeforeLayout, E as lazy, F as readContext, G as useMemo, H as useCallback, I as readData, J as useState, K as useReactive, L as readPromise, U as useDeferredValue, V as useBeforePaint, W as useId, X as useTransition, Y as useSyncExternalStore, f as Fragment, g as createElement, h as clientReference, k as createMixin, m as ViewTransition, p as Suspense, q as useStableEvent, r as ErrorBoundary, t as Activity, w as isValidElement, z as useActionState } from "./element-DpXdLgOZ.js";
3
- import { _ as stylesheet, d as meta, f as modulepreload, g as script, l as font, m as preload, p as preconnect, s as assets, v as title } from "./resource-DEDmLSNk.js";
3
+ import { _ as stylesheet, d as meta, f as modulepreload, g as script, l as font, m as preload, p as preconnect, s as assets, v as title } from "./resource-Co4W0CCc.js";
4
4
  export { Activity, ErrorBoundary, Fragment, MissingCapabilityError, Suspense, ViewTransition, assets, clientReference, createContext, createDataStore, createElement, createMixin, dataResource, font, isValidElement, lazy, meta, modulepreload, preconnect, preload, readContext, readData, readDataStore, readPromise, requireCapability, script, stylesheet, title, transition, useActionState, useBeforeLayout, useBeforePaint, useCallback, useDeferredValue, useId, useMemo, useReactive, useStableEvent, useState, useSyncExternalStore, useTransition };
@@ -1,10 +1,17 @@
1
1
  import { $ as isViewTransition, $t as FigDataStoreOptions, B as ViewTransitionPhase, Bt as DataResourceLoadContext, C as FigNode, Ct as assetResourceKey, D as FigSuspenseSymbol, Dt as isFigAssetResource, E as FigSuspense, F as SuspenseProps, G as createPortalNode, Gt as FigDataEntryStatus, H as ViewTransitionSurface, It as DataRefreshResult, J as isClientReference, Jt as FigDataStore, K as isActivity, Kt as FigDataHydrationEntry, L as ViewTransitionCallback, Lt as DataResource, M as LazyLoader, Mt as preventAssetResourceHoist, N as Props, O as FigViewTransition, Qt as FigDataStoreHost, R as ViewTransitionClass, Rt as DataResourceKey, S as FigErrorBoundarySymbol, St as assetResourceHostProps, T as FigPortalSymbol, Tt as clientReferenceAssets, V as ViewTransitionProps, Wt as DataStoreEntrySnapshot, X as isPortal, Xt as FigDataStoreFactory, Y as isErrorBoundary, Yt as FigDataStoreController, Z as isSuspense, Zt as FigDataStoreHandle, _ as FigClientReference, _t as TitleResource, a as AwaitedFigNode, an as defineLoadContextCapabilities, at as ClientReferenceAssets, b as FigElementSymbol, bt as assetResourceFromHostProps, d as ErrorBoundaryProps, en as LoadContextAttributeError, f as ErrorInfo, ft as ModulePreloadResource, g as FigAssetsSymbol, gt as StylesheetResource, h as FigAssets, ht as ScriptResource, i as Assets, in as dataResourceKeysForError, j as Key, k as FigViewTransitionSymbol, l as ElementType, ln as resolveCurrentDataStore, m as FigActivitySymbol, mt as PreloadResource, nn as LoadContextHydrate, nt as AssetResourceDestination, o as ClientReferenceOptions, on as loadContextCapabilities, p as FigActivity, pt as PreconnectResource, q as isAssets, qt as FigDataReads, r as ActivityProps, rt as AssetResourceHostProps, sn as markDataResourceError, tn as LoadContextCapabilities, un as setCurrentDataStore, ut as MetaResource, v as FigClientReferenceSymbol, vt as assetResourceDestination, w as FigPortal, x as FigErrorBoundary, xt as assetResourceFromHostValues, y as FigElement, yt as assetResourceFromHostAttributes, z as ViewTransitionEvent, zt as DataResourceKeyInput } from "./element-Ba2mDNM_.js";
2
- import { $ as createDataStore, A as TransitionOptions, G as markClientOnlyHostBehavior, I as FigMixinSymbol, J as resolveHostMix, K as markClientOnlyHostProps, M as runTransitionScope, N as setTransitionHandler, O as TransitionCallback, Q as attachDataStore, U as clientOnlyHostBehavior, X as DataStore, Z as DataStoreHost, c as StableEventCallerArgs, ct as FigContextSymbol, d as readBrowser, et as createRendererDataStore, h as setCurrentDispatcher, it as normalizeDataResourceKey, j as TransitionUpdate, k as TransitionHandler, ot as runWithDataStore, q as mixinSlot, r as BrowserRenderReason, rt as isDataStoreController, s as RenderDispatcher, st as FigContext, tt as currentDataStore, ut as isContext } from "./hooks-CUdLWnbQ.js";
2
+ import { $ as createDataStore, A as TransitionOptions, G as markClientOnlyHostBehavior, I as FigMixinSymbol, J as resolveHostMix, K as markClientOnlyHostProps, M as runTransitionScope, N as setTransitionHandler, O as TransitionCallback, Q as attachDataStore, U as clientOnlyHostBehavior, X as DataStore, Z as DataStoreHost, c as StableEventCallerArgs, ct as FigContextSymbol, d as readBrowser, et as createRendererDataStore, h as setCurrentDispatcher, it as normalizeDataResourceKey, j as TransitionUpdate, k as TransitionHandler, ot as runWithDataStore, q as mixinSlot, r as BrowserRenderReason, rt as isDataStoreController, s as RenderDispatcher, st as FigContext, tt as currentDataStore, ut as isContext } from "./hooks-DM0goMC6.js";
3
3
  //#region src/children.d.ts
4
4
  /** Describes normalized child. */
5
5
  type NormalizedChild = FigElement<any> | FigPortal<any> | PromiseLike<AwaitedFigNode> | string;
6
+ /**
7
+ * Where an unkeyed child sat before normalization: its index in the
8
+ * children array, counting empty holes, or a dotted path for a child of a
9
+ * nested array. Reconciliation matches unkeyed children by slot, so a
10
+ * conditional sibling that renders nothing keeps the rest in place.
11
+ */
12
+ type ChildSlot = number | string;
6
13
  /** Collect children. */
7
- declare function collectChildren(node: FigNode): NormalizedChild[];
14
+ declare function collectChildren(node: FigNode, slots?: ChildSlot[]): NormalizedChild[];
8
15
  /** Invalid child error. */
9
16
  declare function invalidChildError(value: unknown): Error;
10
17
  /** Describes invalid child. */
@@ -288,5 +295,7 @@ declare function trackThenable<T>(thenable: PromiseLike<T>): void;
288
295
  declare function readThenable<T>(thenable: PromiseLike<T>): T;
289
296
  /** Checks whether thenable. */
290
297
  declare function isThenable(value: unknown): value is Thenable;
298
+ /** Schedules one retry in the async context where the listener is attached. */
299
+ declare function attachThenableRetry(thenable: Thenable, retry: () => void): void;
291
300
  //#endregion
292
- export { ACTIVITY_TEMPLATE_ATTRIBUTE, type ActivityProps, type AssetResourceDestination, type AssetResourceHostProps, Assets, type AwaitedFigNode, type BrowserRenderReason, type ClientReferenceAssets, type ClientReferenceOptions, type DataRefreshResult, type DataResource, type DataResourceKey, type DataResourceKeyInput, type DataResourceLoadContext, type DataStore, type DataStoreEntrySnapshot, type DataStoreHost, EARLY_EVENT_HANDLER_PROPERTY, EARLY_EVENT_QUEUE_PROPERTY, type ElementType, type ErrorBoundaryProps, type ErrorInfo, type FigActivity, FigActivitySymbol, type FigAssets, FigAssetsSymbol, type FigClientReference, FigClientReferenceSymbol, type FigContext, FigContextSymbol, type FigDataEntryStatus, type FigDataHydrationEntry, type FigDataReads, type FigDataStore, type FigDataStoreController, type FigDataStoreFactory, type FigDataStoreHandle, type FigDataStoreHost, type FigDataStoreOptions, type FigElement, FigElementSymbol, type FigErrorBoundary, FigErrorBoundarySymbol, FigMixinSymbol, type FigNode, type FigPortal, FigPortalSymbol, type FigSuspense, FigSuspenseSymbol, type FigViewTransition, FigViewTransitionSymbol, HYDRATION_SKIP_ATTRIBUTE, type Key, type LazyLoader, type LoadContextAttributeError, type LoadContextCapabilities, type LoadContextHydrate, type NormalizedChild, type PayloadDataHydrationEntry, type PayloadElementModel, type PayloadGraphEncodeContext, type PayloadModel, type PayloadRow, type PayloadSpecialModel, type Props, REPLAYABLE_EVENT_TYPES, type RenderDispatcher, STREAMED_DATA_PROPERTY, SUSPENSE_BROWSER_MARKER, SUSPENSE_CLIENT_MARKER, SUSPENSE_COMPLETED_MARKER, SUSPENSE_END_MARKER, SUSPENSE_MARKER_PREFIX, SUSPENSE_PENDING_PREFIX, type SerializedAssetResource, type StableEventCallerArgs, type StreamedDataMarker, type SuspenseProps, TEXT_SEPARATOR_DATA, type Thenable, type TransitionCallback, type TransitionHandler, type TransitionOptions, type TransitionUpdate, VIEW_TRANSITION_CLASS_ATTRIBUTE, VIEW_TRANSITION_NAME_ATTRIBUTE, VIEW_TRANSITION_PENDING_PROPERTY, VIEW_TRANSITION_TIMEOUT_MS, type ViewTransitionCallback, type ViewTransitionClass, type ViewTransitionEvent, type ViewTransitionPhase, type ViewTransitionProps, type ViewTransitionSurface, assertPayloadCodecMatches, assetResourceDestination, assetResourceFromHostAttributes, assetResourceFromHostProps, assetResourceFromHostValues, assetResourceHostProps, assetResourceKey, attachDataStore, checkpointPayloadGraph, clientOnlyHostBehavior, clientReferenceAssets, collectChildren, createDataStore, createPayloadGraphEncodeContext, createPortalNode, createRendererDataStore, currentDataStore, dataResourceKeysForError, decodePayloadDataEntries, decodePayloadValue, defineLoadContextCapabilities, definePayloadGraphElement, describeInvalidChild, encodePayloadDataEntries, encodePayloadValue, encodePayloadValueWithGraph, invalidChildError, isActivity, isAssets, isClientReference, isContext, isDataStoreController, isErrorBoundary, isFigAssetResource, isPayloadSpecialModel, isPlainPayloadValue, isPortal, isSuspense, isThenable, isViewTransition, jsonPayloadCodec, loadContextCapabilities, markClientOnlyHostBehavior, markClientOnlyHostProps, markDataResourceError, mixinSlot, normalizeDataResourceKey, preventAssetResourceHoist, readBrowser, readThenable, resolveCurrentDataStore, resolveHostMix, rollbackPayloadGraph, runTransitionScope, runWithDataStore, serializePayloadArray, serializePayloadMap, serializePayloadPlainObject, serializePayloadSet, setCurrentDataStore, setCurrentDispatcher, setTransitionHandler, trackThenable, validateInstanceNesting, validateTextNesting };
301
+ export { ACTIVITY_TEMPLATE_ATTRIBUTE, type ActivityProps, type AssetResourceDestination, type AssetResourceHostProps, Assets, type AwaitedFigNode, type BrowserRenderReason, type ChildSlot, type ClientReferenceAssets, type ClientReferenceOptions, type DataRefreshResult, type DataResource, type DataResourceKey, type DataResourceKeyInput, type DataResourceLoadContext, type DataStore, type DataStoreEntrySnapshot, type DataStoreHost, EARLY_EVENT_HANDLER_PROPERTY, EARLY_EVENT_QUEUE_PROPERTY, type ElementType, type ErrorBoundaryProps, type ErrorInfo, type FigActivity, FigActivitySymbol, type FigAssets, FigAssetsSymbol, type FigClientReference, FigClientReferenceSymbol, type FigContext, FigContextSymbol, type FigDataEntryStatus, type FigDataHydrationEntry, type FigDataReads, type FigDataStore, type FigDataStoreController, type FigDataStoreFactory, type FigDataStoreHandle, type FigDataStoreHost, type FigDataStoreOptions, type FigElement, FigElementSymbol, type FigErrorBoundary, FigErrorBoundarySymbol, FigMixinSymbol, type FigNode, type FigPortal, FigPortalSymbol, type FigSuspense, FigSuspenseSymbol, type FigViewTransition, FigViewTransitionSymbol, HYDRATION_SKIP_ATTRIBUTE, type Key, type LazyLoader, type LoadContextAttributeError, type LoadContextCapabilities, type LoadContextHydrate, type NormalizedChild, type PayloadDataHydrationEntry, type PayloadElementModel, type PayloadGraphEncodeContext, type PayloadModel, type PayloadRow, type PayloadSpecialModel, type Props, REPLAYABLE_EVENT_TYPES, type RenderDispatcher, STREAMED_DATA_PROPERTY, SUSPENSE_BROWSER_MARKER, SUSPENSE_CLIENT_MARKER, SUSPENSE_COMPLETED_MARKER, SUSPENSE_END_MARKER, SUSPENSE_MARKER_PREFIX, SUSPENSE_PENDING_PREFIX, type SerializedAssetResource, type StableEventCallerArgs, type StreamedDataMarker, type SuspenseProps, TEXT_SEPARATOR_DATA, type Thenable, type TransitionCallback, type TransitionHandler, type TransitionOptions, type TransitionUpdate, VIEW_TRANSITION_CLASS_ATTRIBUTE, VIEW_TRANSITION_NAME_ATTRIBUTE, VIEW_TRANSITION_PENDING_PROPERTY, VIEW_TRANSITION_TIMEOUT_MS, type ViewTransitionCallback, type ViewTransitionClass, type ViewTransitionEvent, type ViewTransitionPhase, type ViewTransitionProps, type ViewTransitionSurface, assertPayloadCodecMatches, assetResourceDestination, assetResourceFromHostAttributes, assetResourceFromHostProps, assetResourceFromHostValues, assetResourceHostProps, assetResourceKey, attachDataStore, attachThenableRetry, checkpointPayloadGraph, clientOnlyHostBehavior, clientReferenceAssets, collectChildren, createDataStore, createPayloadGraphEncodeContext, createPortalNode, createRendererDataStore, currentDataStore, dataResourceKeysForError, decodePayloadDataEntries, decodePayloadValue, defineLoadContextCapabilities, definePayloadGraphElement, describeInvalidChild, encodePayloadDataEntries, encodePayloadValue, encodePayloadValueWithGraph, invalidChildError, isActivity, isAssets, isClientReference, isContext, isDataStoreController, isErrorBoundary, isFigAssetResource, isPayloadSpecialModel, isPlainPayloadValue, isPortal, isSuspense, isThenable, isViewTransition, jsonPayloadCodec, loadContextCapabilities, markClientOnlyHostBehavior, markClientOnlyHostProps, markDataResourceError, mixinSlot, normalizeDataResourceKey, preventAssetResourceHoist, readBrowser, readThenable, resolveCurrentDataStore, resolveHostMix, rollbackPayloadGraph, runTransitionScope, runWithDataStore, serializePayloadArray, serializePayloadMap, serializePayloadPlainObject, serializePayloadSet, setCurrentDataStore, setCurrentDispatcher, setTransitionHandler, trackThenable, validateInstanceNesting, validateTextNesting };
package/dist/internal.js CHANGED
@@ -1,16 +1,16 @@
1
- import { C as isContext, _ as markDataResourceError, a as createDataStore, b as setCurrentDataStore, f as runWithDataStore, g as loadContextCapabilities, h as defineLoadContextCapabilities, i as attachDataStore, l as isDataStoreController, m as dataResourceKeysForError, n as setTransitionHandler, o as createRendererDataStore, s as currentDataStore, t as runTransitionScope, u as normalizeDataResourceKey, x as FigContextSymbol, y as resolveCurrentDataStore } from "./transition-C03gUimZ.js";
1
+ import { C as isContext, _ as markDataResourceError, a as createDataStore, b as setCurrentDataStore, f as runWithDataStore, g as loadContextCapabilities, h as defineLoadContextCapabilities, i as attachDataStore, l as isDataStoreController, m as dataResourceKeysForError, n as setTransitionHandler, o as createRendererDataStore, s as currentDataStore, t as runTransitionScope, u as normalizeDataResourceKey, x as FigContextSymbol, y as resolveCurrentDataStore } from "./transition-B8ZLez3D.js";
2
2
  import { A as markClientOnlyHostBehavior, C as isSuspense, D as FigMixinSymbol, M as mixinSlot, N as resolveHostMix, O as clientOnlyHostBehavior, P as readBrowser, R as setCurrentDispatcher, S as isPortal, T as isViewTransition, _ as createPortalNode, a as FigAssetsSymbol, b as isClientReference, c as FigErrorBoundarySymbol, d as FigViewTransitionSymbol, i as FigActivitySymbol, j as markClientOnlyHostProps, l as FigPortalSymbol, n as Assets, o as FigClientReferenceSymbol, s as FigElementSymbol, u as FigSuspenseSymbol, v as isActivity, w as isValidElement, x as isErrorBoundary, y as isAssets } from "./element-DpXdLgOZ.js";
3
- import { a as assetResourceHostProps, b as readThenable, c as clientReferenceAssets, h as preventAssetResourceHoist, i as assetResourceFromHostValues, n as assetResourceFromHostAttributes, o as assetResourceKey, r as assetResourceFromHostProps, t as assetResourceDestination, u as isFigAssetResource, x as trackThenable, y as isThenable } from "./resource-DEDmLSNk.js";
3
+ import { S as trackThenable, a as assetResourceHostProps, b as isThenable, c as clientReferenceAssets, h as preventAssetResourceHoist, i as assetResourceFromHostValues, n as assetResourceFromHostAttributes, o as assetResourceKey, r as assetResourceFromHostProps, t as assetResourceDestination, u as isFigAssetResource, x as readThenable, y as attachThenableRetry } from "./resource-Co4W0CCc.js";
4
4
  import { _ as serializePayloadArray, b as serializePayloadSet, c as definePayloadGraphElement, d as encodePayloadValueWithGraph, g as rollbackPayloadGraph, h as jsonPayloadCodec, i as decodePayloadDataEntries, l as encodePayloadDataEntries, m as isPlainPayloadValue, n as checkpointPayloadGraph, o as decodePayloadValue, p as isPayloadSpecialModel, r as createPayloadGraphEncodeContext, t as assertPayloadCodecMatches, u as encodePayloadValue, v as serializePayloadMap, y as serializePayloadPlainObject } from "./payload-format-B9UbNtxo.js";
5
5
  //#region src/children.ts
6
6
  /** Collect children. */
7
- function collectChildren(node) {
8
- if (Array.isArray(node)) return collectArrayChildren(node);
7
+ function collectChildren(node, slots) {
8
+ if (Array.isArray(node)) return collectArrayChildren(node, slots);
9
9
  const children = [];
10
- collectChild(node, children);
10
+ collectChild(node, children, void 0, null, 0);
11
11
  return children;
12
12
  }
13
- function collectArrayChildren(children) {
13
+ function collectArrayChildren(children, slots) {
14
14
  let previousWasText = false;
15
15
  for (let index = 0; index < children.length; index += 1) {
16
16
  const child = children[index];
@@ -27,36 +27,46 @@ function collectArrayChildren(children) {
27
27
  }
28
28
  }
29
29
  const normalized = children.slice(0, index);
30
- for (; index < children.length; index += 1) collectChild(children[index], normalized);
30
+ if (slots !== void 0) for (let slot = 0; slot < index; slot += 1) slots.push(slot);
31
+ for (; index < children.length; index += 1) collectChild(children[index], normalized, slots, null, index);
31
32
  return normalized;
32
33
  }
33
34
  return children;
34
35
  }
35
- function collectChild(node, children) {
36
+ function collectChild(node, children, slots, path, index) {
36
37
  if (Array.isArray(node)) {
37
- for (const child of node) collectChild(child, children);
38
+ const nested = slots === void 0 ? null : path === null ? String(index) : `${path}.${index}`;
39
+ for (let child = 0; child < node.length; child += 1) collectChild(node[child], children, slots, nested, child);
38
40
  return;
39
41
  }
40
42
  if (node === null || node === void 0 || typeof node === "boolean") return;
41
43
  if (typeof node === "string" || typeof node === "number") {
42
- appendTextChild(children, String(node));
44
+ appendTextChild(children, String(node), slots, path, index);
43
45
  return;
44
46
  }
45
47
  if (isValidElement(node) || isPortal(node)) {
46
48
  children.push(node);
49
+ slots?.push(node.key === null ? slotPath(path, index) : index);
47
50
  return;
48
51
  }
49
52
  if (isThenable(node)) {
50
53
  children.push(node);
54
+ slots?.push(slotPath(path, index));
51
55
  return;
52
56
  }
53
57
  throw invalidChildError(node);
54
58
  }
55
- function appendTextChild(children, text) {
59
+ function slotPath(path, index) {
60
+ return path === null ? index : `${path}.${index}`;
61
+ }
62
+ function appendTextChild(children, text, slots, path, index) {
56
63
  if (text === "") return;
57
64
  const previous = children.at(-1);
58
65
  if (typeof previous === "string") children[children.length - 1] = `${previous}${text}`;
59
- else children.push(text);
66
+ else {
67
+ children.push(text);
68
+ slots?.push(slotPath(path, index));
69
+ }
60
70
  }
61
71
  /** Invalid child error. */
62
72
  function invalidChildError(value) {
@@ -214,6 +224,6 @@ const REPLAYABLE_EVENT_TYPES = [
214
224
  "pointerup"
215
225
  ];
216
226
  //#endregion
217
- export { ACTIVITY_TEMPLATE_ATTRIBUTE, Assets, EARLY_EVENT_HANDLER_PROPERTY, EARLY_EVENT_QUEUE_PROPERTY, FigActivitySymbol, FigAssetsSymbol, FigClientReferenceSymbol, FigContextSymbol, FigElementSymbol, FigErrorBoundarySymbol, FigMixinSymbol, FigPortalSymbol, FigSuspenseSymbol, FigViewTransitionSymbol, HYDRATION_SKIP_ATTRIBUTE, REPLAYABLE_EVENT_TYPES, STREAMED_DATA_PROPERTY, SUSPENSE_BROWSER_MARKER, SUSPENSE_CLIENT_MARKER, SUSPENSE_COMPLETED_MARKER, SUSPENSE_END_MARKER, SUSPENSE_MARKER_PREFIX, SUSPENSE_PENDING_PREFIX, TEXT_SEPARATOR_DATA, VIEW_TRANSITION_CLASS_ATTRIBUTE, VIEW_TRANSITION_NAME_ATTRIBUTE, VIEW_TRANSITION_PENDING_PROPERTY, VIEW_TRANSITION_TIMEOUT_MS, assertPayloadCodecMatches, assetResourceDestination, assetResourceFromHostAttributes, assetResourceFromHostProps, assetResourceFromHostValues, assetResourceHostProps, assetResourceKey, attachDataStore, checkpointPayloadGraph, clientOnlyHostBehavior, clientReferenceAssets, collectChildren, createDataStore, createPayloadGraphEncodeContext, createPortalNode, createRendererDataStore, currentDataStore, dataResourceKeysForError, decodePayloadDataEntries, decodePayloadValue, defineLoadContextCapabilities, definePayloadGraphElement, describeInvalidChild, encodePayloadDataEntries, encodePayloadValue, encodePayloadValueWithGraph, invalidChildError, isActivity, isAssets, isClientReference, isContext, isDataStoreController, isErrorBoundary, isFigAssetResource, isPayloadSpecialModel, isPlainPayloadValue, isPortal, isSuspense, isThenable, isViewTransition, jsonPayloadCodec, loadContextCapabilities, markClientOnlyHostBehavior, markClientOnlyHostProps, markDataResourceError, mixinSlot, normalizeDataResourceKey, preventAssetResourceHoist, readBrowser, readThenable, resolveCurrentDataStore, resolveHostMix, rollbackPayloadGraph, runTransitionScope, runWithDataStore, serializePayloadArray, serializePayloadMap, serializePayloadPlainObject, serializePayloadSet, setCurrentDataStore, setCurrentDispatcher, setTransitionHandler, trackThenable, validateInstanceNesting, validateTextNesting };
227
+ export { ACTIVITY_TEMPLATE_ATTRIBUTE, Assets, EARLY_EVENT_HANDLER_PROPERTY, EARLY_EVENT_QUEUE_PROPERTY, FigActivitySymbol, FigAssetsSymbol, FigClientReferenceSymbol, FigContextSymbol, FigElementSymbol, FigErrorBoundarySymbol, FigMixinSymbol, FigPortalSymbol, FigSuspenseSymbol, FigViewTransitionSymbol, HYDRATION_SKIP_ATTRIBUTE, REPLAYABLE_EVENT_TYPES, STREAMED_DATA_PROPERTY, SUSPENSE_BROWSER_MARKER, SUSPENSE_CLIENT_MARKER, SUSPENSE_COMPLETED_MARKER, SUSPENSE_END_MARKER, SUSPENSE_MARKER_PREFIX, SUSPENSE_PENDING_PREFIX, TEXT_SEPARATOR_DATA, VIEW_TRANSITION_CLASS_ATTRIBUTE, VIEW_TRANSITION_NAME_ATTRIBUTE, VIEW_TRANSITION_PENDING_PROPERTY, VIEW_TRANSITION_TIMEOUT_MS, assertPayloadCodecMatches, assetResourceDestination, assetResourceFromHostAttributes, assetResourceFromHostProps, assetResourceFromHostValues, assetResourceHostProps, assetResourceKey, attachDataStore, attachThenableRetry, checkpointPayloadGraph, clientOnlyHostBehavior, clientReferenceAssets, collectChildren, createDataStore, createPayloadGraphEncodeContext, createPortalNode, createRendererDataStore, currentDataStore, dataResourceKeysForError, decodePayloadDataEntries, decodePayloadValue, defineLoadContextCapabilities, definePayloadGraphElement, describeInvalidChild, encodePayloadDataEntries, encodePayloadValue, encodePayloadValueWithGraph, invalidChildError, isActivity, isAssets, isClientReference, isContext, isDataStoreController, isErrorBoundary, isFigAssetResource, isPayloadSpecialModel, isPlainPayloadValue, isPortal, isSuspense, isThenable, isViewTransition, jsonPayloadCodec, loadContextCapabilities, markClientOnlyHostBehavior, markClientOnlyHostProps, markDataResourceError, mixinSlot, normalizeDataResourceKey, preventAssetResourceHoist, readBrowser, readThenable, resolveCurrentDataStore, resolveHostMix, rollbackPayloadGraph, runTransitionScope, runWithDataStore, serializePayloadArray, serializePayloadMap, serializePayloadPlainObject, serializePayloadSet, setCurrentDataStore, setCurrentDispatcher, setTransitionHandler, trackThenable, validateInstanceNesting, validateTextNesting };
218
228
 
219
229
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","names":[],"sources":["../src/children.ts","../src/dom-nesting.ts","../src/suspense-protocol.ts"],"sourcesContent":["import {\n type AwaitedFigNode,\n type FigElement,\n type FigNode,\n type FigPortal,\n isPortal,\n isValidElement,\n} from \"./element.ts\";\nimport { isThenable } from \"./thenables.ts\";\n\n// What normalization leaves behind: arrays are flattened, null/undefined/\n// booleans are dropped, and numbers are stringified into (merged) text.\n/** Describes normalized child. */\nexport type NormalizedChild =\n | FigElement<any>\n | FigPortal<any>\n | PromiseLike<AwaitedFigNode>\n | string;\n\n// Child normalization shared by the reconciler and the server renderer.\n// Adjacent text merging here MUST match on both sides: the server emits\n// merged text nodes into HTML, and hydration matches them against the\n// client's fiber children — divergence is a hydration mismatch.\n/** Collect children. */\nexport function collectChildren(node: FigNode): NormalizedChild[] {\n if (Array.isArray(node)) return collectArrayChildren(node);\n\n const children: NormalizedChild[] = [];\n collectChild(node, children);\n return children;\n}\n\nfunction collectArrayChildren(children: FigNode[]): NormalizedChild[] {\n let previousWasText = false;\n for (let index = 0; index < children.length; index += 1) {\n const child = children[index];\n if (typeof child === \"string\") {\n if (child !== \"\" && !previousWasText) {\n previousWasText = true;\n continue;\n }\n } else {\n previousWasText = false;\n if (\n !Array.isArray(child) &&\n child !== null &&\n child !== undefined &&\n typeof child !== \"boolean\" &&\n typeof child !== \"number\"\n ) {\n if (isValidElement(child) || isPortal(child) || isThenable(child)) {\n continue;\n }\n throw invalidChildError(child);\n }\n }\n\n const normalized = children.slice(0, index) as NormalizedChild[];\n for (; index < children.length; index += 1) {\n collectChild(children[index], normalized);\n }\n return normalized;\n }\n return children as NormalizedChild[];\n}\n\nfunction collectChild(node: FigNode, children: NormalizedChild[]): void {\n if (Array.isArray(node)) {\n for (const child of node) collectChild(child, children);\n return;\n }\n\n if (node === null || node === undefined || typeof node === \"boolean\") return;\n\n if (typeof node === \"string\" || typeof node === \"number\") {\n appendTextChild(children, String(node));\n return;\n }\n\n if (isValidElement(node) || isPortal(node)) {\n children.push(node);\n return;\n }\n\n if (isThenable(node)) {\n children.push(node);\n return;\n }\n\n throw invalidChildError(node);\n}\n\nfunction appendTextChild(children: NormalizedChild[], text: string): void {\n if (text === \"\") return;\n\n const previous = children.at(-1);\n\n if (typeof previous === \"string\") {\n children[children.length - 1] = `${previous}${text}`;\n } else {\n children.push(text);\n }\n}\n\n/** Invalid child error. */\nexport function invalidChildError(value: unknown): Error {\n return new Error(\n `Invalid Fig child: ${describeInvalidChild(value)}. Render a string, number, element, promise, array, boolean, null, or undefined.`,\n );\n}\n\n/** Describes invalid child. */\nexport function describeInvalidChild(value: unknown): string {\n if (typeof value !== \"object\" || value === null) return typeof value;\n\n const keys = Object.keys(value);\n return keys.length === 0 ? \"object\" : `object with keys ${keys.join(\", \")}`;\n}\n","const phrasingContainers = \"|a|button|p|\";\n\n// HTML parser auto-close rules are scoped: these tags reset the \"is there an\n// open <a>/<button>/<p>?\" checks, so e.g. <a><table><td><a> and\n// <p><button><div> parse without re-parenting and must not be flagged.\n// <button> additionally terminates button scope (the <p> auto-close check).\nconst scopeTerminators =\n \"|applet|caption|desc|foreignobject|html|marquee|object|table|td|template|th|title|\";\n\nconst pAutoClosingTags =\n \"|address|article|aside|blockquote|center|details|dialog|dir|div|dl|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|main|menu|nav|ol|p|pre|section|table|ul|\";\n\nconst headChildren =\n \"|base|basefont|bgsound|link|meta|title|noscript|noframes|script|style|template|\";\n\nconst specialTags =\n \"|address|applet|area|article|aside|base|basefont|bgsound|blockquote|body|br|button|caption|center|col|colgroup|dd|details|dir|div|dl|dt|embed|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hgroup|hr|html|iframe|img|input|keygen|li|link|listing|main|marquee|menu|meta|nav|noembed|noframes|noscript|object|ol|p|param|plaintext|pre|script|section|select|source|style|summary|table|tbody|td|template|textarea|tfoot|th|thead|title|tr|track|ul|wbr|xmp|mi|mo|mn|ms|mtext|annotation-xml|foreignobject|desc|\";\n\n/** Validates instance nesting. */\nexport function validateInstanceNesting(\n type: string,\n ancestors: readonly string[],\n): void {\n const child = normalizedTag(type);\n const parent =\n ancestors[0] === undefined ? null : normalizedTag(ancestors[0]);\n\n if (parent !== null && !validWithParent(child, parent)) {\n throw invalidNestingError(\n `<${child}> cannot be a child of <${parent}>.${hintFor(child, parent)}`,\n );\n }\n\n const invalidAncestor = invalidAncestorFor(child, ancestors);\n if (invalidAncestor !== null) {\n throw invalidNestingError(\n `<${child}> cannot appear inside <${invalidAncestor}>.`,\n );\n }\n}\n\n/** Validates text nesting. */\nexport function validateTextNesting(\n text: string,\n ancestors: readonly string[],\n): void {\n // Whitespace-only text is inserted in place even inside tables (\"in table\n // text\" mode only foster-parents non-whitespace), so it is harmless.\n if (!/[^ \\t\\n\\r\\f]/.test(text)) return;\n\n const parent =\n ancestors[0] === undefined ? null : normalizedTag(ancestors[0]);\n if (parent === null || validTextWithParent(parent)) return;\n\n throw invalidNestingError(`text cannot be a child of <${parent}>.`);\n}\n\nfunction validWithParent(child: string, parent: string): boolean {\n switch (parent) {\n case \"select\":\n return (\n child === \"hr\" ||\n child === \"option\" ||\n child === \"optgroup\" ||\n child === \"script\" ||\n child === \"template\"\n );\n case \"optgroup\":\n return child === \"option\";\n case \"option\":\n return false;\n case \"tr\":\n return child === \"th\" || child === \"td\" || scriptLike(child);\n case \"tbody\":\n case \"thead\":\n case \"tfoot\":\n return child === \"tr\" || scriptLike(child);\n case \"colgroup\":\n return child === \"col\" || child === \"template\";\n case \"table\":\n return (\n child === \"caption\" ||\n child === \"colgroup\" ||\n child === \"tbody\" ||\n child === \"tfoot\" ||\n child === \"thead\" ||\n scriptLike(child)\n );\n case \"head\":\n return tagIn(headChildren, child);\n case \"html\":\n return child === \"head\" || child === \"body\";\n case \"frameset\":\n return child === \"frame\";\n }\n\n switch (child) {\n case \"caption\":\n case \"col\":\n case \"colgroup\":\n case \"tbody\":\n case \"tfoot\":\n case \"thead\":\n case \"tr\":\n return parent === \"template\";\n case \"td\":\n case \"th\":\n return parent === \"tr\" || parent === \"template\";\n case \"option\":\n return parent === \"datalist\" || parent === \"template\";\n case \"optgroup\":\n return parent === \"template\";\n case \"head\":\n case \"body\":\n case \"frameset\":\n return parent === \"html\" || parent === \"template\";\n case \"frame\":\n return parent === \"template\";\n case \"html\":\n return false;\n }\n\n return true;\n}\n\nfunction validTextWithParent(parent: string): boolean {\n // <option>, <select>, and <optgroup> reject element children, but the\n // parser inserts character tokens into them in place, so text is legal.\n return (\n parent === \"option\" ||\n parent === \"select\" ||\n parent === \"optgroup\" ||\n validWithParent(\"#text\", parent)\n );\n}\n\nfunction invalidAncestorFor(\n child: string,\n ancestors: readonly string[],\n): string | null {\n let inScope = true;\n let inButtonScope = true;\n let inListScope = true;\n let inTemplate = false;\n\n for (const ancestorType of ancestors) {\n const ancestor = normalizedTag(ancestorType);\n\n if (child === ancestor && tagIn(phrasingContainers, child)) {\n if (child === \"p\" ? inButtonScope : inScope) return ancestor;\n }\n if (inButtonScope && ancestor === \"p\" && tagIn(pAutoClosingTags, child)) {\n return ancestor;\n }\n if (inListScope && listItemAncestor(child, ancestor)) return ancestor;\n // The parser's form element pointer ignores scope but resets in templates.\n if (!inTemplate && ancestor === \"form\" && child === \"form\") return ancestor;\n\n if (tagIn(scopeTerminators, ancestor)) {\n if (ancestor === \"template\") inTemplate = true;\n inScope = false;\n inButtonScope = false;\n } else if (ancestor === \"button\") {\n inButtonScope = false;\n }\n // li/dd/dt auto-closing sees through phrasing/formatting wrappers and\n // address/div/p; other special elements terminate the parser walk.\n if (\n tagIn(specialTags, ancestor) &&\n ancestor !== \"address\" &&\n ancestor !== \"div\" &&\n ancestor !== \"p\"\n ) {\n inListScope = false;\n }\n }\n\n return null;\n}\n\nfunction listItemAncestor(child: string, ancestor: string): boolean {\n if (child === \"li\") return ancestor === \"li\";\n if (child === \"dd\" || child === \"dt\") {\n return ancestor === \"dd\" || ancestor === \"dt\";\n }\n return false;\n}\n\nfunction normalizedTag(type: string): string {\n return type.toLowerCase();\n}\n\nfunction scriptLike(tag: string): boolean {\n return tag === \"script\" || tag === \"style\" || tag === \"template\";\n}\n\nfunction hintFor(child: string, parent: string): string {\n if (parent === \"table\" && child === \"tr\") {\n return \" Add a <tbody>, <thead>, or <tfoot>.\";\n }\n\n return \"\";\n}\n\nfunction invalidNestingError(message: string): Error {\n return new Error(`Invalid DOM nesting: ${message}`);\n}\n\nfunction tagIn(tags: string, tag: string): boolean {\n return tags.includes(`|${tag}|`);\n}\n","// The Suspense streaming wire format shared by the server renderer (which\n// emits these markers as HTML comments and interpolates them into the inline\n// reveal script) and fig-dom (which parses them into dehydrated boundaries).\n// Changing any value is a protocol change: server output and client parsing\n// must move together.\nimport type { DataResourceKey } from \"./data.ts\";\n\n/** The suspense marker prefix. */\nexport const SUSPENSE_MARKER_PREFIX = \"fig:suspense:\";\n/** The suspense completed marker. */\nexport const SUSPENSE_COMPLETED_MARKER = \"fig:suspense:completed\";\n/** The suspense browser-rendered marker. */\nexport const SUSPENSE_BROWSER_MARKER = \"fig:suspense:browser\";\n/** The suspense client marker. */\nexport const SUSPENSE_CLIENT_MARKER = \"fig:suspense:client\";\n/** The suspense pending prefix. */\nexport const SUSPENSE_PENDING_PREFIX = \"fig:suspense:pending:\";\n/** The suspense end marker. */\nexport const SUSPENSE_END_MARKER = \"/fig:suspense\";\n\n// The server emits a comment with exactly this data between adjacent text\n// writes that come from different normalized text children: the HTML parser\n// would otherwise merge them into one DOM text node while the client keeps\n// one text fiber each. fig-dom's hydration cursor skips only comments whose\n// data matches this value (fig:suspense markers use their own prefixes).\n/** The text separator data. */\nexport const TEXT_SEPARATOR_DATA = \",\";\n\n// Hidden Activity content streams inside an inert template carrying this\n// attribute; the client treats such templates as dehydrated boundaries.\n/** The activity template attribute. */\nexport const ACTIVITY_TEMPLATE_ATTRIBUTE = \"data-fig-activity\";\n\n/** The view transition name attribute. */\nexport const VIEW_TRANSITION_NAME_ATTRIBUTE = \"data-fig-vt-name\";\n/** The view transition class attribute. */\nexport const VIEW_TRANSITION_CLASS_ATTRIBUTE = \"data-fig-vt-class\";\n\n// Per-document mutex holding the currently running view transition. Client\n// commits and inline streaming reveals both wait on it before proceeding.\n/** The view transition pending property. */\nexport const VIEW_TRANSITION_PENDING_PROPERTY = \"__figViewTransition\";\n// React's maximum suspended-commit wait, shared with streaming reveals so a\n// non-settling transition cannot hold either path indefinitely.\n/** The view transition timeout ms. */\nexport const VIEW_TRANSITION_TIMEOUT_MS = 60_000;\n\n// Early-event capture: a tiny inline script at the top of a server-rendered\n// document queues replayable events that fire before the client bundle\n// executes. The first hydration root drains the queue, removes the capture\n// listeners, and replays claimed events through the standard replay path.\n// The event list must stay in sync with fig-dom's replayable set — a\n// discrete replay forces synchronous hydration of its target, which is what\n// makes pre-bundle clicks safe to honor.\n/** The hydration skip attribute. */\nexport const HYDRATION_SKIP_ATTRIBUTE = \"data-fig-hydration-skip\";\n/** The early event queue property. */\nexport const EARLY_EVENT_QUEUE_PROPERTY = \"__figEarlyEvents\";\n/** The early event handler property. */\nexport const EARLY_EVENT_HANDLER_PROPERTY = \"__figEarlyEventHandler\";\n// Streamed data rows: the `d` operation queues encoded rows on this document\n// property, keyed by the render's identifierPrefix, until the hydrating root\n// that owns the prefix drains it and replaces it with a live receiver.\n/** The streamed data property. */\nexport const STREAMED_DATA_PROPERTY = \"__figStreamedData\";\n// A `d` row with this shape carries no value: it promises that key's transfer\n// form in a later `d` operation, after the reveal. The browser holds that\n// key's load until the form arrives or the document finishes loading.\n/** Describes a streamed data marker. */\nexport interface StreamedDataMarker {\n key: DataResourceKey;\n pending: true;\n}\n/** The replayable event types. */\nexport const REPLAYABLE_EVENT_TYPES = [\n \"click\",\n \"keydown\",\n \"keyup\",\n \"pointerdown\",\n \"pointerup\",\n] as const;\n"],"mappings":";;;;;;AAwBA,SAAgB,gBAAgB,MAAkC;CAChE,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO,qBAAqB,IAAI;CAEzD,MAAM,WAA8B,CAAC;CACrC,aAAa,MAAM,QAAQ;CAC3B,OAAO;AACT;AAEA,SAAS,qBAAqB,UAAwC;CACpE,IAAI,kBAAkB;CACtB,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAAS,GAAG;EACvD,MAAM,QAAQ,SAAS;EACvB,IAAI,OAAO,UAAU,UACf;OAAA,UAAU,MAAM,CAAC,iBAAiB;IACpC,kBAAkB;IAClB;GACF;SACK;GACL,kBAAkB;GAClB,IACE,CAAC,MAAM,QAAQ,KAAK,KACpB,UAAU,QACV,UAAU,KAAA,KACV,OAAO,UAAU,aACjB,OAAO,UAAU,UACjB;IACA,IAAI,eAAe,KAAK,KAAK,SAAS,KAAK,KAAK,WAAW,KAAK,GAC9D;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O;AACT;AAEA,SAAS,cAAc,MAAsB;CAC3C,OAAO,KAAK,YAAY;AAC1B;AAEA,SAAS,WAAW,KAAsB;CACxC,OAAO,QAAQ,YAAY,QAAQ,WAAW,QAAQ;AACxD;AAEA,SAAS,QAAQ,OAAe,QAAwB;CACtD,IAAI,WAAW,WAAW,UAAU,MAClC,OAAO;CAGT,OAAO;AACT;AAEA,SAAS,oBAAoB,SAAwB;CACnD,uBAAO,IAAI,MAAM,wBAAwB,SAAS;AACpD;AAEA,SAAS,MAAM,MAAc,KAAsB;CACjD,OAAO,KAAK,SAAS,IAAI,IAAI,EAAE;AACjC;;;;AC1MA,MAAa,yBAAyB;;AAEtC,MAAa,4BAA4B;;AAEzC,MAAa,0BAA0B;;AAEvC,MAAa,yBAAyB;;AAEtC,MAAa,0BAA0B;;AAEvC,MAAa,sBAAsB;;AAQnC,MAAa,sBAAsB;;AAKnC,MAAa,8BAA8B;;AAG3C,MAAa,iCAAiC;;AAE9C,MAAa,kCAAkC;;AAK/C,MAAa,mCAAmC;;AAIhD,MAAa,6BAA6B;;AAU1C,MAAa,2BAA2B;;AAExC,MAAa,6BAA6B;;AAE1C,MAAa,+BAA+B;;AAK5C,MAAa,yBAAyB;;AAUtC,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"internal.js","names":[],"sources":["../src/children.ts","../src/dom-nesting.ts","../src/suspense-protocol.ts"],"sourcesContent":["import {\n type AwaitedFigNode,\n type FigElement,\n type FigNode,\n type FigPortal,\n isPortal,\n isValidElement,\n} from \"./element.ts\";\nimport { isThenable } from \"./thenables.ts\";\n\n// What normalization leaves behind: arrays are flattened, null/undefined/\n// booleans are dropped, and numbers are stringified into (merged) text.\n/** Describes normalized child. */\nexport type NormalizedChild =\n | FigElement<any>\n | FigPortal<any>\n | PromiseLike<AwaitedFigNode>\n | string;\n\n/**\n * Where an unkeyed child sat before normalization: its index in the\n * children array, counting empty holes, or a dotted path for a child of a\n * nested array. Reconciliation matches unkeyed children by slot, so a\n * conditional sibling that renders nothing keeps the rest in place.\n */\nexport type ChildSlot = number | string;\n\n// Child normalization shared by the reconciler and the server renderer.\n// Adjacent text merging here MUST match on both sides: the server emits\n// merged text nodes into HTML, and hydration matches them against the\n// client's fiber children — divergence is a hydration mismatch.\n//\n// When `slots` is passed, it receives each normalized child's slot, unless\n// the children were already normalized; then it stays empty and each\n// child's slot is its index.\n/** Collect children. */\nexport function collectChildren(\n node: FigNode,\n slots?: ChildSlot[],\n): NormalizedChild[] {\n if (Array.isArray(node)) return collectArrayChildren(node, slots);\n\n // A lone child's slot is 0, its index.\n const children: NormalizedChild[] = [];\n collectChild(node, children, undefined, null, 0);\n return children;\n}\n\nfunction collectArrayChildren(\n children: FigNode[],\n slots: ChildSlot[] | undefined,\n): NormalizedChild[] {\n let previousWasText = false;\n for (let index = 0; index < children.length; index += 1) {\n const child = children[index];\n if (typeof child === \"string\") {\n if (child !== \"\" && !previousWasText) {\n previousWasText = true;\n continue;\n }\n } else {\n previousWasText = false;\n if (\n !Array.isArray(child) &&\n child !== null &&\n child !== undefined &&\n typeof child !== \"boolean\" &&\n typeof child !== \"number\"\n ) {\n if (isValidElement(child) || isPortal(child) || isThenable(child)) {\n continue;\n }\n throw invalidChildError(child);\n }\n }\n\n const normalized = children.slice(0, index) as NormalizedChild[];\n if (slots !== undefined) {\n for (let slot = 0; slot < index; slot += 1) slots.push(slot);\n }\n for (; index < children.length; index += 1) {\n collectChild(children[index], normalized, slots, null, index);\n }\n return normalized;\n }\n return children as NormalizedChild[];\n}\n\n// A child's slot is `index` within the array at `path` (null at the top\n// level). Paths are only built for unkeyed children of nested arrays, so\n// keyed lists pay nothing for them.\nfunction collectChild(\n node: FigNode,\n children: NormalizedChild[],\n slots: ChildSlot[] | undefined,\n path: string | null,\n index: number,\n): void {\n if (Array.isArray(node)) {\n const nested =\n slots === undefined\n ? null\n : path === null\n ? String(index)\n : `${path}.${index}`;\n for (let child = 0; child < node.length; child += 1) {\n collectChild(node[child], children, slots, nested, child);\n }\n return;\n }\n\n if (node === null || node === undefined || typeof node === \"boolean\") return;\n\n if (typeof node === \"string\" || typeof node === \"number\") {\n appendTextChild(children, String(node), slots, path, index);\n return;\n }\n\n if (isValidElement(node) || isPortal(node)) {\n children.push(node);\n // A keyed child is matched by key; its slot is never read.\n slots?.push(node.key === null ? slotPath(path, index) : index);\n return;\n }\n\n if (isThenable(node)) {\n children.push(node);\n slots?.push(slotPath(path, index));\n return;\n }\n\n throw invalidChildError(node);\n}\n\nfunction slotPath(path: string | null, index: number): ChildSlot {\n return path === null ? index : `${path}.${index}`;\n}\n\nfunction appendTextChild(\n children: NormalizedChild[],\n text: string,\n slots: ChildSlot[] | undefined,\n path: string | null,\n index: number,\n): void {\n if (text === \"\") return;\n\n const previous = children.at(-1);\n\n if (typeof previous === \"string\") {\n children[children.length - 1] = `${previous}${text}`;\n } else {\n children.push(text);\n slots?.push(slotPath(path, index));\n }\n}\n\n/** Invalid child error. */\nexport function invalidChildError(value: unknown): Error {\n return new Error(\n `Invalid Fig child: ${describeInvalidChild(value)}. Render a string, number, element, promise, array, boolean, null, or undefined.`,\n );\n}\n\n/** Describes invalid child. */\nexport function describeInvalidChild(value: unknown): string {\n if (typeof value !== \"object\" || value === null) return typeof value;\n\n const keys = Object.keys(value);\n return keys.length === 0 ? \"object\" : `object with keys ${keys.join(\", \")}`;\n}\n","const phrasingContainers = \"|a|button|p|\";\n\n// HTML parser auto-close rules are scoped: these tags reset the \"is there an\n// open <a>/<button>/<p>?\" checks, so e.g. <a><table><td><a> and\n// <p><button><div> parse without re-parenting and must not be flagged.\n// <button> additionally terminates button scope (the <p> auto-close check).\nconst scopeTerminators =\n \"|applet|caption|desc|foreignobject|html|marquee|object|table|td|template|th|title|\";\n\nconst pAutoClosingTags =\n \"|address|article|aside|blockquote|center|details|dialog|dir|div|dl|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|main|menu|nav|ol|p|pre|section|table|ul|\";\n\nconst headChildren =\n \"|base|basefont|bgsound|link|meta|title|noscript|noframes|script|style|template|\";\n\nconst specialTags =\n \"|address|applet|area|article|aside|base|basefont|bgsound|blockquote|body|br|button|caption|center|col|colgroup|dd|details|dir|div|dl|dt|embed|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hgroup|hr|html|iframe|img|input|keygen|li|link|listing|main|marquee|menu|meta|nav|noembed|noframes|noscript|object|ol|p|param|plaintext|pre|script|section|select|source|style|summary|table|tbody|td|template|textarea|tfoot|th|thead|title|tr|track|ul|wbr|xmp|mi|mo|mn|ms|mtext|annotation-xml|foreignobject|desc|\";\n\n/** Validates instance nesting. */\nexport function validateInstanceNesting(\n type: string,\n ancestors: readonly string[],\n): void {\n const child = normalizedTag(type);\n const parent =\n ancestors[0] === undefined ? null : normalizedTag(ancestors[0]);\n\n if (parent !== null && !validWithParent(child, parent)) {\n throw invalidNestingError(\n `<${child}> cannot be a child of <${parent}>.${hintFor(child, parent)}`,\n );\n }\n\n const invalidAncestor = invalidAncestorFor(child, ancestors);\n if (invalidAncestor !== null) {\n throw invalidNestingError(\n `<${child}> cannot appear inside <${invalidAncestor}>.`,\n );\n }\n}\n\n/** Validates text nesting. */\nexport function validateTextNesting(\n text: string,\n ancestors: readonly string[],\n): void {\n // Whitespace-only text is inserted in place even inside tables (\"in table\n // text\" mode only foster-parents non-whitespace), so it is harmless.\n if (!/[^ \\t\\n\\r\\f]/.test(text)) return;\n\n const parent =\n ancestors[0] === undefined ? null : normalizedTag(ancestors[0]);\n if (parent === null || validTextWithParent(parent)) return;\n\n throw invalidNestingError(`text cannot be a child of <${parent}>.`);\n}\n\nfunction validWithParent(child: string, parent: string): boolean {\n switch (parent) {\n case \"select\":\n return (\n child === \"hr\" ||\n child === \"option\" ||\n child === \"optgroup\" ||\n child === \"script\" ||\n child === \"template\"\n );\n case \"optgroup\":\n return child === \"option\";\n case \"option\":\n return false;\n case \"tr\":\n return child === \"th\" || child === \"td\" || scriptLike(child);\n case \"tbody\":\n case \"thead\":\n case \"tfoot\":\n return child === \"tr\" || scriptLike(child);\n case \"colgroup\":\n return child === \"col\" || child === \"template\";\n case \"table\":\n return (\n child === \"caption\" ||\n child === \"colgroup\" ||\n child === \"tbody\" ||\n child === \"tfoot\" ||\n child === \"thead\" ||\n scriptLike(child)\n );\n case \"head\":\n return tagIn(headChildren, child);\n case \"html\":\n return child === \"head\" || child === \"body\";\n case \"frameset\":\n return child === \"frame\";\n }\n\n switch (child) {\n case \"caption\":\n case \"col\":\n case \"colgroup\":\n case \"tbody\":\n case \"tfoot\":\n case \"thead\":\n case \"tr\":\n return parent === \"template\";\n case \"td\":\n case \"th\":\n return parent === \"tr\" || parent === \"template\";\n case \"option\":\n return parent === \"datalist\" || parent === \"template\";\n case \"optgroup\":\n return parent === \"template\";\n case \"head\":\n case \"body\":\n case \"frameset\":\n return parent === \"html\" || parent === \"template\";\n case \"frame\":\n return parent === \"template\";\n case \"html\":\n return false;\n }\n\n return true;\n}\n\nfunction validTextWithParent(parent: string): boolean {\n // <option>, <select>, and <optgroup> reject element children, but the\n // parser inserts character tokens into them in place, so text is legal.\n return (\n parent === \"option\" ||\n parent === \"select\" ||\n parent === \"optgroup\" ||\n validWithParent(\"#text\", parent)\n );\n}\n\nfunction invalidAncestorFor(\n child: string,\n ancestors: readonly string[],\n): string | null {\n let inScope = true;\n let inButtonScope = true;\n let inListScope = true;\n let inTemplate = false;\n\n for (const ancestorType of ancestors) {\n const ancestor = normalizedTag(ancestorType);\n\n if (child === ancestor && tagIn(phrasingContainers, child)) {\n if (child === \"p\" ? inButtonScope : inScope) return ancestor;\n }\n if (inButtonScope && ancestor === \"p\" && tagIn(pAutoClosingTags, child)) {\n return ancestor;\n }\n if (inListScope && listItemAncestor(child, ancestor)) return ancestor;\n // The parser's form element pointer ignores scope but resets in templates.\n if (!inTemplate && ancestor === \"form\" && child === \"form\") return ancestor;\n\n if (tagIn(scopeTerminators, ancestor)) {\n if (ancestor === \"template\") inTemplate = true;\n inScope = false;\n inButtonScope = false;\n } else if (ancestor === \"button\") {\n inButtonScope = false;\n }\n // li/dd/dt auto-closing sees through phrasing/formatting wrappers and\n // address/div/p; other special elements terminate the parser walk.\n if (\n tagIn(specialTags, ancestor) &&\n ancestor !== \"address\" &&\n ancestor !== \"div\" &&\n ancestor !== \"p\"\n ) {\n inListScope = false;\n }\n }\n\n return null;\n}\n\nfunction listItemAncestor(child: string, ancestor: string): boolean {\n if (child === \"li\") return ancestor === \"li\";\n if (child === \"dd\" || child === \"dt\") {\n return ancestor === \"dd\" || ancestor === \"dt\";\n }\n return false;\n}\n\nfunction normalizedTag(type: string): string {\n return type.toLowerCase();\n}\n\nfunction scriptLike(tag: string): boolean {\n return tag === \"script\" || tag === \"style\" || tag === \"template\";\n}\n\nfunction hintFor(child: string, parent: string): string {\n if (parent === \"table\" && child === \"tr\") {\n return \" Add a <tbody>, <thead>, or <tfoot>.\";\n }\n\n return \"\";\n}\n\nfunction invalidNestingError(message: string): Error {\n return new Error(`Invalid DOM nesting: ${message}`);\n}\n\nfunction tagIn(tags: string, tag: string): boolean {\n return tags.includes(`|${tag}|`);\n}\n","// The Suspense streaming wire format shared by the server renderer (which\n// emits these markers as HTML comments and interpolates them into the inline\n// reveal script) and fig-dom (which parses them into dehydrated boundaries).\n// Changing any value is a protocol change: server output and client parsing\n// must move together.\nimport type { DataResourceKey } from \"./data.ts\";\n\n/** The suspense marker prefix. */\nexport const SUSPENSE_MARKER_PREFIX = \"fig:suspense:\";\n/** The suspense completed marker. */\nexport const SUSPENSE_COMPLETED_MARKER = \"fig:suspense:completed\";\n/** The suspense browser-rendered marker. */\nexport const SUSPENSE_BROWSER_MARKER = \"fig:suspense:browser\";\n/** The suspense client marker. */\nexport const SUSPENSE_CLIENT_MARKER = \"fig:suspense:client\";\n/** The suspense pending prefix. */\nexport const SUSPENSE_PENDING_PREFIX = \"fig:suspense:pending:\";\n/** The suspense end marker. */\nexport const SUSPENSE_END_MARKER = \"/fig:suspense\";\n\n// The server emits a comment with exactly this data between adjacent text\n// writes that come from different normalized text children: the HTML parser\n// would otherwise merge them into one DOM text node while the client keeps\n// one text fiber each. fig-dom's hydration cursor skips only comments whose\n// data matches this value (fig:suspense markers use their own prefixes).\n/** The text separator data. */\nexport const TEXT_SEPARATOR_DATA = \",\";\n\n// Hidden Activity content streams inside an inert template carrying this\n// attribute; the client treats such templates as dehydrated boundaries.\n/** The activity template attribute. */\nexport const ACTIVITY_TEMPLATE_ATTRIBUTE = \"data-fig-activity\";\n\n/** The view transition name attribute. */\nexport const VIEW_TRANSITION_NAME_ATTRIBUTE = \"data-fig-vt-name\";\n/** The view transition class attribute. */\nexport const VIEW_TRANSITION_CLASS_ATTRIBUTE = \"data-fig-vt-class\";\n\n// Per-document mutex holding the currently running view transition. Client\n// commits and inline streaming reveals both wait on it before proceeding.\n/** The view transition pending property. */\nexport const VIEW_TRANSITION_PENDING_PROPERTY = \"__figViewTransition\";\n// React's maximum suspended-commit wait, shared with streaming reveals so a\n// non-settling transition cannot hold either path indefinitely.\n/** The view transition timeout ms. */\nexport const VIEW_TRANSITION_TIMEOUT_MS = 60_000;\n\n// Early-event capture: a tiny inline script at the top of a server-rendered\n// document queues replayable events that fire before the client bundle\n// executes. The first hydration root drains the queue, removes the capture\n// listeners, and replays claimed events through the standard replay path.\n// The event list must stay in sync with fig-dom's replayable set — a\n// discrete replay forces synchronous hydration of its target, which is what\n// makes pre-bundle clicks safe to honor.\n/** The hydration skip attribute. */\nexport const HYDRATION_SKIP_ATTRIBUTE = \"data-fig-hydration-skip\";\n/** The early event queue property. */\nexport const EARLY_EVENT_QUEUE_PROPERTY = \"__figEarlyEvents\";\n/** The early event handler property. */\nexport const EARLY_EVENT_HANDLER_PROPERTY = \"__figEarlyEventHandler\";\n// Streamed data rows: the `d` operation queues encoded rows on this document\n// property, keyed by the render's identifierPrefix, until the hydrating root\n// that owns the prefix drains it and replaces it with a live receiver.\n/** The streamed data property. */\nexport const STREAMED_DATA_PROPERTY = \"__figStreamedData\";\n// A `d` row with this shape carries no value: it promises that key's transfer\n// form in a later `d` operation, after the reveal. The browser holds that\n// key's load until the form arrives or the document finishes loading.\n/** Describes a streamed data marker. */\nexport interface StreamedDataMarker {\n key: DataResourceKey;\n pending: true;\n}\n/** The replayable event types. */\nexport const REPLAYABLE_EVENT_TYPES = [\n \"click\",\n \"keydown\",\n \"keyup\",\n \"pointerdown\",\n \"pointerup\",\n] as const;\n"],"mappings":";;;;;;AAoCA,SAAgB,gBACd,MACA,OACmB;CACnB,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO,qBAAqB,MAAM,KAAK;CAGhE,MAAM,WAA8B,CAAC;CACrC,aAAa,MAAM,UAAU,KAAA,GAAW,MAAM,CAAC;CAC/C,OAAO;AACT;AAEA,SAAS,qBACP,UACA,OACmB;CACnB,IAAI,kBAAkB;CACtB,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAAS,GAAG;EACvD,MAAM,QAAQ,SAAS;EACvB,IAAI,OAAO,UAAU,UACf;OAAA,UAAU,MAAM,CAAC,iBAAiB;IACpC,kBAAkB;IAClB;GACF;SACK;GACL,kBAAkB;GAClB,IACE,CAAC,MAAM,QAAQ,KAAK,KACpB,UAAU,QACV,UAAU,KAAA,KACV,OAAO,UAAU,aACjB,OAAO,UAAU,UACjB;IACA,IAAI,eAAe,KAAK,KAAK,SAAS,KAAK,KAAK,WAAW,KAAK,GAC9D;IAEF,MAAM,kBAAkB,KAAK;GAC/B;EACF;EAEA,MAAM,aAAa,SAAS,MAAM,GAAG,KAAK;EAC1C,IAAI,UAAU,KAAA,GACZ,KAAK,IAAI,OAAO,GAAG,OAAO,OAAO,QAAQ,GAAG,MAAM,KAAK,IAAI;EAE7D,OAAO,QAAQ,SAAS,QAAQ,SAAS,GACvC,aAAa,SAAS,QAAQ,YAAY,OAAO,MAAM,KAAK;EAE9D,OAAO;CACT;CACA,OAAO;AACT;AAKA,SAAS,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MAAM,aAAa,QAAQ,KAC3B,aAAa,aACb,aAAa,SACb,aAAa,KAEb,cAAc;CAElB;CAEA,OAAO;AACT;AAEA,SAAS,iBAAiB,OAAe,UAA2B;CAClE,IAAI,UAAU,MAAM,OAAO,aAAa;CACxC,IAAI,UAAU,QAAQ,UAAU,MAC9B,OAAO,aAAa,QAAQ,aAAa;CAE3C,OAAO;AACT;AAEA,SAAS,cAAc,MAAsB;CAC3C,OAAO,KAAK,YAAY;AAC1B;AAEA,SAAS,WAAW,KAAsB;CACxC,OAAO,QAAQ,YAAY,QAAQ,WAAW,QAAQ;AACxD;AAEA,SAAS,QAAQ,OAAe,QAAwB;CACtD,IAAI,WAAW,WAAW,UAAU,MAClC,OAAO;CAGT,OAAO;AACT;AAEA,SAAS,oBAAoB,SAAwB;CACnD,uBAAO,IAAI,MAAM,wBAAwB,SAAS;AACpD;AAEA,SAAS,MAAM,MAAc,KAAsB;CACjD,OAAO,KAAK,SAAS,IAAI,IAAI,EAAE;AACjC;;;;AC1MA,MAAa,yBAAyB;;AAEtC,MAAa,4BAA4B;;AAEzC,MAAa,0BAA0B;;AAEvC,MAAa,yBAAyB;;AAEtC,MAAa,0BAA0B;;AAEvC,MAAa,sBAAsB;;AAQnC,MAAa,sBAAsB;;AAKnC,MAAa,8BAA8B;;AAG3C,MAAa,iCAAiC;;AAE9C,MAAa,kCAAkC;;AAK/C,MAAa,mCAAmC;;AAIhD,MAAa,6BAA6B;;AAU1C,MAAa,2BAA2B;;AAExC,MAAa,6BAA6B;;AAE1C,MAAa,+BAA+B;;AAK5C,MAAa,yBAAyB;;AAUtC,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;AACF"}
package/dist/payload.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { L as readPromise, f as Fragment, g as createElement, m as ViewTransition, p as Suspense, s as FigElementSymbol, t as Activity } from "./element-DpXdLgOZ.js";
2
- import { s as assets, t as assetResourceDestination, u as isFigAssetResource, x as trackThenable, y as isThenable } from "./resource-DEDmLSNk.js";
2
+ import { S as trackThenable, b as isThenable, s as assets, t as assetResourceDestination, u as isFigAssetResource } from "./resource-Co4W0CCc.js";
3
3
  import { a as decodePayloadRecord, f as errorFromPayloadValue, h as jsonPayloadCodec, i as decodePayloadDataEntries, p as isPayloadSpecialModel, s as decodePayloadValueTag } from "./payload-format-B9UbNtxo.js";
4
4
  //#region src/payload-client-reference.ts
5
5
  const resolverEntries = /* @__PURE__ */ new WeakMap();
@@ -45,6 +45,23 @@ function isThenable(value) {
45
45
  if (typeof value !== "object" && typeof value !== "function" || value === null) return false;
46
46
  return "then" in value && typeof value.then === "function";
47
47
  }
48
+ /** Schedules one retry in the async context where the listener is attached. */
49
+ function attachThenableRetry(thenable, retry) {
50
+ if (thenable instanceof Promise && Object.getPrototypeOf(thenable) === Promise.prototype && thenable.constructor === Promise && thenable.then === Promise.prototype.then) try {
51
+ thenable.then(retry, retry);
52
+ return;
53
+ } catch {}
54
+ let resolve = () => {};
55
+ new Promise((resolvePromise) => {
56
+ resolve = resolvePromise;
57
+ }).then(retry);
58
+ const settle = () => resolve();
59
+ try {
60
+ thenable.then(settle, settle);
61
+ } catch {
62
+ settle();
63
+ }
64
+ }
48
65
  //#endregion
49
66
  //#region src/resource.ts
50
67
  const PreventAssetResourceHoistSymbol = Symbol.for("fig.prevent-asset-resource-hoist");
@@ -374,6 +391,6 @@ function metaResourceKey(resource) {
374
391
  return `meta:http-equiv:${resource["http-equiv"]}`;
375
392
  }
376
393
  //#endregion
377
- export { stylesheet as _, assetResourceHostProps as a, readThenable as b, clientReferenceAssets as c, meta as d, modulepreload as f, script as g, preventAssetResourceHoist as h, assetResourceFromHostValues as i, font as l, preload as m, assetResourceFromHostAttributes as n, assetResourceKey as o, preconnect as p, assetResourceFromHostProps as r, assets as s, assetResourceDestination as t, isFigAssetResource as u, title as v, trackThenable as x, isThenable as y };
394
+ export { trackThenable as S, stylesheet as _, assetResourceHostProps as a, isThenable as b, clientReferenceAssets as c, meta as d, modulepreload as f, script as g, preventAssetResourceHoist as h, assetResourceFromHostValues as i, font as l, preload as m, assetResourceFromHostAttributes as n, assetResourceKey as o, preconnect as p, assetResourceFromHostProps as r, assets as s, assetResourceDestination as t, isFigAssetResource as u, title as v, readThenable as x, attachThenableRetry as y };
378
395
 
379
- //# sourceMappingURL=resource-DEDmLSNk.js.map
396
+ //# sourceMappingURL=resource-Co4W0CCc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-Co4W0CCc.js","names":[],"sources":["../src/thenables.ts","../src/resource.ts"],"sourcesContent":["/** Describes thenable. */\nexport type Thenable<T = unknown> = PromiseLike<T> & object;\n\ntype ThenableRecord<T> =\n | { status: \"pending\" }\n | { status: \"fulfilled\"; value: T }\n | { status: \"rejected\"; reason: unknown };\n\n// One process-wide registry keyed by thenable identity: the reconciler's\n// readPromise, the server renderers' dispatchers, and preloaders all share\n// it, so suspend/settle semantics cannot drift between client and server.\nconst thenableRecords = new WeakMap<object, ThenableRecord<unknown>>();\n\nfunction recordFor<T>(thenable: PromiseLike<T>): ThenableRecord<T> {\n const key = thenable as Thenable<T>;\n let record = thenableRecords.get(key) as ThenableRecord<T> | undefined;\n\n if (record === undefined) {\n record = { status: \"pending\" };\n thenableRecords.set(key, record);\n const settle = (next: ThenableRecord<T>) => {\n // Custom thenables can call both callbacks or throw after fulfilling.\n // Preserve the first settlement, just as native promise resolution does.\n if (record?.status !== \"pending\") return;\n record = next;\n thenableRecords.set(key, next);\n };\n try {\n thenable.then(\n (value) => settle({ status: \"fulfilled\", value }),\n (reason: unknown) => settle({ reason, status: \"rejected\" }),\n );\n } catch (reason) {\n // A failed subscription is a cached rejection, not a forever-pending read.\n settle({ reason, status: \"rejected\" });\n }\n }\n\n return record;\n}\n\n// Starts tracking without reading. Preloaders call this when they begin a\n// load so that a thenable settled before its first render read resolves\n// synchronously instead of suspending for one retry beat.\n/** Tracks thenable. */\nexport function trackThenable<T>(thenable: PromiseLike<T>): void {\n recordFor(thenable);\n}\n\n/** Reads thenable. */\nexport function readThenable<T>(thenable: PromiseLike<T>): T {\n const record = recordFor(thenable);\n if (record.status === \"fulfilled\") return record.value;\n if (record.status === \"rejected\") throw record.reason;\n throw thenable;\n}\n\n/** Checks whether thenable. */\nexport function isThenable(value: unknown): value is Thenable {\n if (\n (typeof value !== \"object\" && typeof value !== \"function\") ||\n value === null\n ) {\n return false;\n }\n\n return \"then\" in value && typeof value.then === \"function\";\n}\n\n/** Schedules one retry in the async context where the listener is attached. */\nexport function attachThenableRetry(\n thenable: Thenable,\n retry: () => void,\n): void {\n // Native promises already capture the subscriber's async context in .then().\n if (\n thenable instanceof Promise &&\n Object.getPrototypeOf(thenable) === Promise.prototype &&\n thenable.constructor === Promise &&\n thenable.then === Promise.prototype.then\n ) {\n try {\n void thenable.then(retry, retry);\n return;\n } catch {\n // Fall through for non-Promise receivers inheriting Promise.prototype.\n }\n }\n // Custom thenables invoke listeners in the resolver's context. Native\n // promise reactions capture the subscriber's context instead, preserving\n // request-local values on servers and interaction attribution in browsers.\n let resolve = () => {};\n const settled = new Promise<void>((resolvePromise) => {\n resolve = resolvePromise;\n });\n void settled.then(retry);\n // Ignore the value: adopting a nested thenable could delay the retry forever.\n const settle = () => resolve();\n try {\n thenable.then(settle, settle);\n } catch {\n settle();\n }\n}\n","import {\n Assets,\n createElement,\n type FigClientReference,\n type FigElement,\n type FigNode,\n type Props,\n} from \"./element.ts\";\nimport { isThenable, readThenable } from \"./thenables.ts\";\n\nconst PreventAssetResourceHoistSymbol = Symbol.for(\n \"fig.prevent-asset-resource-hoist\",\n);\ntype PreventAssetResourceHostProps = Props & {\n [PreventAssetResourceHoistSymbol]?: true;\n};\n\n/** Describes asset resource blocking. */\nexport type AssetResourceBlocking = \"reveal\" | \"none\";\n/** Describes cross origin. */\nexport type CrossOrigin = \"anonymous\" | \"use-credentials\" | \"\";\n/** Describes fetch priority. */\nexport type FetchPriority = \"high\" | \"low\" | \"auto\";\n/** Describes asset resource destination. */\nexport type AssetResourceDestination = \"head\" | \"stream\";\n\n/** Describes Fig asset resource. */\nexport type FigAssetResource =\n | StylesheetResource\n | PreloadResource\n | ModulePreloadResource\n | ScriptResource\n | PreconnectResource\n | TitleResource\n | MetaResource;\n\ninterface ResourceBase {\n key?: string;\n}\n\n/** Describes stylesheet resource. */\nexport interface StylesheetResource extends ResourceBase {\n blocking?: AssetResourceBlocking;\n crossorigin?: CrossOrigin;\n href: string;\n kind: \"stylesheet\";\n media?: string;\n precedence?: string;\n}\n\n/** Describes preload resource. */\nexport interface PreloadResource extends ResourceBase {\n as: string;\n crossorigin?: CrossOrigin;\n fetchpriority?: FetchPriority;\n href?: string;\n imagesizes?: string;\n imagesrcset?: string;\n kind: \"preload\";\n referrerpolicy?: string;\n type?: string;\n}\n\n/** Describes module preload resource. */\nexport interface ModulePreloadResource extends ResourceBase {\n crossorigin?: CrossOrigin;\n fetchpriority?: FetchPriority;\n href: string;\n kind: \"modulepreload\";\n}\n\n/** Describes script resource. */\nexport interface ScriptResource extends ResourceBase {\n async?: boolean;\n crossorigin?: CrossOrigin;\n defer?: boolean;\n kind: \"script\";\n module?: boolean;\n src: string;\n}\n\n/** Describes preconnect resource. */\nexport interface PreconnectResource extends ResourceBase {\n crossorigin?: CrossOrigin;\n href: string;\n kind: \"preconnect\";\n}\n\n/** Describes title resource. */\nexport interface TitleResource extends ResourceBase {\n kind: \"title\";\n value: string;\n}\n\ninterface MetaResourceBase extends ResourceBase {\n kind: \"meta\";\n}\n\ntype DistributiveOmit<Value, Key extends PropertyKey> = Value extends unknown\n ? Omit<Value, Key>\n : never;\n\n/** Describes meta resource. */\nexport type MetaResource =\n | (MetaResourceBase & {\n charset: string;\n content?: never;\n \"http-equiv\"?: never;\n name?: never;\n property?: never;\n })\n | (MetaResourceBase & {\n charset?: never;\n content: string;\n \"http-equiv\"?: never;\n name: string;\n property?: never;\n })\n | (MetaResourceBase & {\n charset?: never;\n content: string;\n \"http-equiv\"?: never;\n name?: never;\n property: string;\n })\n | (MetaResourceBase & {\n charset?: never;\n content: string;\n \"http-equiv\": string;\n name?: never;\n property?: never;\n });\n\n/** Describes meta resource options. */\nexport type MetaResourceOptions = DistributiveOmit<MetaResource, \"kind\">;\n\n/** Describes Fig asset resource list. */\nexport type FigAssetResourceList =\n | FigAssetResource\n | readonly FigAssetResource[];\n\n// Asset resources a client reference contributes when it renders. Eager for\n// hand-written lists; a thunk for bundler-manifest resolution that may not be\n// available until serialization time, or that maps paths differently per build.\n/** Describes client reference assets. */\nexport type ClientReferenceAssets =\n | FigAssetResourceList\n | (() => FigAssetResourceList);\n\n/** Describes assets props. */\nexport interface AssetsProps {\n assets: FigAssetResourceList;\n children?: FigNode;\n}\n\n/** Assets. */\nexport function assets(\n value: FigAssetResourceList,\n children?: FigNode,\n): FigElement<AssetsProps> {\n return createElement(Assets, { assets: value }, children);\n}\n\n/** Stylesheet. */\nexport function stylesheet(\n href: string,\n options: Omit<StylesheetResource, \"href\" | \"kind\"> = {},\n): StylesheetResource {\n return { ...options, href, kind: \"stylesheet\" };\n}\n\n/** Preload. */\nexport function preload(\n href: string,\n as: string,\n options: Omit<PreloadResource, \"as\" | \"href\" | \"kind\"> = {},\n): PreloadResource {\n return {\n ...options,\n as,\n href,\n imagesrcset: as === \"image\" ? options.imagesrcset || undefined : undefined,\n kind: \"preload\",\n };\n}\n\n/** Modulepreload. */\nexport function modulepreload(\n href: string,\n options: Omit<ModulePreloadResource, \"href\" | \"kind\"> = {},\n): ModulePreloadResource {\n return { ...options, href, kind: \"modulepreload\" };\n}\n\n/** Script. */\nexport function script(\n src: string,\n options: Omit<ScriptResource, \"kind\" | \"src\"> = {},\n): ScriptResource {\n return { ...options, kind: \"script\", src };\n}\n\n/** Font. */\nexport function font(\n href: string,\n type: string,\n options: Pick<PreloadResource, \"key\" | \"crossorigin\" | \"fetchpriority\"> = {},\n): PreloadResource {\n return preload(href, \"font\", {\n ...options,\n crossorigin: options.crossorigin ?? \"anonymous\",\n type,\n });\n}\n\n/** Preconnect. */\nexport function preconnect(\n href: string,\n options: Omit<PreconnectResource, \"href\" | \"kind\"> = {},\n): PreconnectResource {\n return { ...options, href, kind: \"preconnect\" };\n}\n\n/** Title. */\nexport function title(value: string): TitleResource {\n return { kind: \"title\", value };\n}\n\n/** Meta. */\nexport function meta(options: MetaResourceOptions): MetaResource {\n return { ...options, kind: \"meta\" };\n}\n\n/** Checks whether Fig asset resource. */\nexport function isFigAssetResource(value: unknown): value is FigAssetResource {\n if (typeof value !== \"object\" || value === null || !(\"kind\" in value)) {\n return false;\n }\n\n switch (value.kind) {\n case \"stylesheet\":\n case \"preload\":\n case \"modulepreload\":\n case \"script\":\n case \"preconnect\":\n case \"title\":\n case \"meta\":\n return true;\n default:\n return false;\n }\n}\n\n/** Client reference assets. */\nexport function clientReferenceAssets(\n reference: FigClientReference,\n): readonly FigAssetResource[] {\n const value = reference.assets;\n if (value === undefined) return [];\n\n // Resolved on each call rather than memoized: a lazy resolver may read a\n // manifest that is not loaded until serialization, and a consumer that wants\n // to cache can do so against the stable reference identity.\n const list = typeof value === \"function\" ? value() : value;\n if (isFigAssetResource(list)) return [list];\n // A thunk that yields nothing (e.g. a missing manifest entry) normalizes to an\n // empty list rather than leaking a non-array through the readonly contract.\n return Array.isArray(list) ? list : [];\n}\n\n/** Asset resource key. */\nexport function assetResourceKey(resource: FigAssetResource): string {\n // A document carries a single <title>; collapse every title to one key even\n // when an author supplies an explicit key, so the singleton invariant cannot\n // be bypassed into emitting multiple <title> elements (invalid HTML).\n if (resource.kind === \"title\") return \"title\";\n\n if (resource.key !== undefined) return `${resource.kind}:${resource.key}`;\n\n switch (resource.kind) {\n case \"stylesheet\":\n return `stylesheet:${resource.href}`;\n case \"preload\": {\n const imagesrcset = resource.imagesrcset || undefined;\n return `preload:${resource.as}:${\n imagesrcset === undefined\n ? (resource.href ?? \"\")\n : `${imagesrcset}\\n${resource.imagesizes ?? \"\"}`\n }`;\n }\n case \"modulepreload\":\n return `modulepreload:${resource.href}`;\n case \"script\":\n return `script:${resource.src}`;\n case \"preconnect\":\n return `preconnect:${resource.href}`;\n case \"meta\":\n return metaResourceKey(resource);\n }\n}\n\n/** Asset resource destination. */\nexport function assetResourceDestination(\n resource: FigAssetResource,\n): AssetResourceDestination {\n return resource.kind === \"title\" || resource.kind === \"meta\"\n ? \"head\"\n : \"stream\";\n}\n\n/** Asset resource from host props. */\nexport function assetResourceFromHostProps(\n type: string,\n props: Props,\n): FigAssetResource | null {\n if (\n (props as PreventAssetResourceHostProps)[\n PreventAssetResourceHoistSymbol\n ] === true\n ) {\n return null;\n }\n return assetResourceFromHostValues(\n type,\n (name) => props[name],\n props.children,\n true,\n );\n}\n\n/** Prevent asset resource hoist. */\nexport function preventAssetResourceHoist<P extends Props>(props: P): P {\n Object.defineProperty(props, PreventAssetResourceHoistSymbol, {\n enumerable: true,\n value: true,\n });\n return props;\n}\n\n/** Asset resource from host attributes. */\nexport function assetResourceFromHostAttributes(\n type: string,\n getAttribute: (name: string) => unknown,\n): FigAssetResource | null {\n return assetResourceFromHostValues(type, getAttribute, undefined, false);\n}\n\n/** Describes asset resource host props. */\nexport type AssetResourceHostProps = Record<string, string | true>;\n\n// Canonical host props for hoisted asset-resource elements, shared by the\n// server's registry writer and the client's head insertion so the two renders\n// cannot drift. `true` marks a boolean attribute (bare on the server,\n// empty-string in the DOM). Server-only attributes (id, nonce) stay with the\n// server writer; title/meta are written by their own paths.\n/** Asset resource host props. */\nexport function assetResourceHostProps(\n resource: FigAssetResource,\n props: AssetResourceHostProps = {},\n): AssetResourceHostProps {\n if (resource.kind === \"title\" || resource.kind === \"meta\") return props;\n\n switch (resource.kind) {\n case \"stylesheet\":\n props.rel = \"stylesheet\";\n props.href = resource.href;\n if (resource.key !== undefined) {\n props[\"data-fig-resource-key\"] = resource.key;\n }\n if (resource.precedence !== undefined) {\n props[\"data-precedence\"] = resource.precedence;\n }\n if (resource.media !== undefined) props.media = resource.media;\n if (resource.crossorigin !== undefined) {\n props.crossorigin = resource.crossorigin;\n }\n break;\n case \"preload\": {\n const imagesrcset = resource.imagesrcset || undefined;\n props.rel = \"preload\";\n if (imagesrcset === undefined && resource.href !== undefined) {\n props.href = resource.href;\n }\n props.as = resource.as;\n if (resource.key !== undefined) {\n props[\"data-fig-resource-key\"] = resource.key;\n }\n if (resource.type !== undefined) props.type = resource.type;\n if (resource.crossorigin !== undefined) {\n props.crossorigin = resource.crossorigin;\n }\n if (resource.fetchpriority !== undefined) {\n props.fetchpriority = resource.fetchpriority;\n }\n if (imagesrcset !== undefined) props.imagesrcset = imagesrcset;\n if (resource.imagesizes !== undefined) {\n props.imagesizes = resource.imagesizes;\n }\n if (resource.referrerpolicy !== undefined) {\n props.referrerpolicy = resource.referrerpolicy;\n }\n break;\n }\n case \"modulepreload\":\n props.rel = \"modulepreload\";\n props.href = resource.href;\n if (resource.key !== undefined) {\n props[\"data-fig-resource-key\"] = resource.key;\n }\n if (resource.crossorigin !== undefined) {\n props.crossorigin = resource.crossorigin;\n }\n if (resource.fetchpriority !== undefined) {\n props.fetchpriority = resource.fetchpriority;\n }\n break;\n case \"preconnect\":\n props.rel = \"preconnect\";\n props.href = resource.href;\n if (resource.key !== undefined) {\n props[\"data-fig-resource-key\"] = resource.key;\n }\n if (resource.crossorigin !== undefined) {\n props.crossorigin = resource.crossorigin;\n }\n break;\n case \"script\":\n props.src = resource.src;\n if (resource.module === true) props.type = \"module\";\n if (resource.key !== undefined) {\n props[\"data-fig-resource-key\"] = resource.key;\n }\n // Hoisted scripts default to async, but an explicit defer opts into\n // ordered execution and must not be overridden (async wins over defer in\n // browsers).\n if (resource.async ?? resource.defer !== true) props.async = true;\n if (resource.defer === true) props.defer = true;\n if (resource.crossorigin !== undefined) {\n props.crossorigin = resource.crossorigin;\n }\n break;\n }\n return props;\n}\n\n/** Asset resource from host values. */\nexport function assetResourceFromHostValues(\n type: string,\n prop: (name: string) => unknown,\n children?: FigNode,\n requireAsyncScript = false,\n): FigAssetResource | null {\n const withKey = (\n resource: FigAssetResource | null,\n ): FigAssetResource | null => {\n if (resource === null) return null;\n const key = readProp(prop, \"data-fig-resource-key\");\n return key === undefined ? resource : { ...resource, key };\n };\n\n switch (type.toLowerCase()) {\n case \"title\":\n if (readProp(prop, \"itemprop\") !== undefined) return null;\n return withKey({ kind: \"title\", value: textResourceValue(children) });\n case \"meta\":\n if (readProp(prop, \"itemprop\") !== undefined) return null;\n return withKey(metaResourceFromHost(prop));\n case \"link\":\n return withKey(linkResourceFromHost(prop));\n case \"script\": {\n const src = readProp(prop, \"src\");\n // A raw script keeps native placement and execution semantics unless the\n // author explicitly marks it async. Explicit script() descriptors remain\n // the opt-in path for hoisted defer, module, or synchronous scripts.\n const async = hasBooleanAttribute(prop(\"async\"));\n if (src === undefined || (requireAsyncScript && !async)) return null;\n return withKey({\n async,\n crossorigin: readCrossorigin(prop),\n defer: hasBooleanAttribute(prop(\"defer\")),\n kind: \"script\",\n module: prop(\"type\") === \"module\",\n src,\n });\n }\n default:\n return null;\n }\n}\n\nfunction metaResourceFromHost(\n prop: (name: string) => unknown,\n): MetaResource | null {\n const charset = readProp(prop, \"charset\");\n const httpEquiv = readProp(prop, \"http-equiv\");\n const name = readProp(prop, \"name\");\n const property = readProp(prop, \"property\");\n const identities = [charset, httpEquiv, name, property].filter(\n (value) => value !== undefined,\n );\n\n if (identities.length !== 1) return null;\n if (charset !== undefined) return { charset, kind: \"meta\" };\n\n const content = readProp(prop, \"content\");\n if (content === undefined) return null;\n if (httpEquiv !== undefined) {\n return { content, \"http-equiv\": httpEquiv, kind: \"meta\" };\n }\n if (name !== undefined) return { content, kind: \"meta\", name };\n if (property !== undefined) return { content, kind: \"meta\", property };\n return null;\n}\n\nfunction hasBooleanAttribute(value: unknown): boolean {\n return value !== undefined && value !== null && value !== false;\n}\n\nfunction linkResourceFromHost(\n prop: (name: string) => unknown,\n): FigAssetResource | null {\n const rel = readProp(prop, \"rel\")?.toLowerCase();\n const href = readProp(prop, \"href\");\n if (rel === undefined || readProp(prop, \"itemprop\") !== undefined) {\n return null;\n }\n\n if (rel === \"preload\") {\n const as = readProp(prop, \"as\");\n const imagesrcset =\n as === \"image\" ? readProp(prop, \"imagesrcset\") || undefined : undefined;\n if (as === undefined || (href === undefined && imagesrcset === undefined)) {\n return null;\n }\n return {\n as,\n crossorigin: readCrossorigin(prop),\n fetchpriority: fetchpriorityProp(readProp(prop, \"fetchpriority\")),\n href,\n imagesizes:\n imagesrcset === undefined ? undefined : readProp(prop, \"imagesizes\"),\n imagesrcset,\n kind: \"preload\",\n referrerpolicy: readProp(prop, \"referrerpolicy\"),\n type: readProp(prop, \"type\"),\n };\n }\n\n if (href === undefined) return null;\n\n if (rel === \"stylesheet\") {\n return {\n blocking: prop(\"blocking\") === \"none\" ? \"none\" : undefined,\n crossorigin: readCrossorigin(prop),\n href,\n kind: \"stylesheet\",\n media: readProp(prop, \"media\"),\n // Hoisted elements serialize the canonical data-precedence attribute;\n // host-rendered <link precedence> keeps the author-facing prop name.\n precedence: readProp(prop, \"precedence\", \"data-precedence\"),\n };\n }\n\n if (rel === \"modulepreload\") {\n return {\n crossorigin: readCrossorigin(prop),\n fetchpriority: fetchpriorityProp(readProp(prop, \"fetchpriority\")),\n href,\n kind: \"modulepreload\",\n };\n }\n\n if (rel === \"preconnect\") {\n return {\n crossorigin: readCrossorigin(prop),\n href,\n kind: \"preconnect\",\n };\n }\n\n return null;\n}\n\nfunction readProp(\n prop: (name: string) => unknown,\n ...names: string[]\n): string | undefined {\n for (const name of names) {\n const value = stringProp(prop(name));\n if (value !== undefined) return value;\n }\n\n return undefined;\n}\n\nfunction stringProp(value: unknown): string | undefined {\n if (value === undefined || value === null || value === false)\n return undefined;\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"bigint\" ||\n value === true\n ) {\n return String(value);\n }\n\n throw new Error(\n \"Resource host props must be serializable during server render.\",\n );\n}\n\nfunction readCrossorigin(\n prop: (name: string) => unknown,\n): CrossOrigin | undefined {\n return crossoriginProp(readProp(prop, \"crossorigin\"));\n}\n\nfunction crossoriginProp(value: unknown): CrossOrigin | undefined {\n return value === \"anonymous\" || value === \"use-credentials\" || value === \"\"\n ? value\n : undefined;\n}\n\nfunction fetchpriorityProp(value: unknown): FetchPriority | undefined {\n return value === \"high\" || value === \"low\" || value === \"auto\"\n ? value\n : undefined;\n}\n\nfunction textResourceValue(node: FigNode): string {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return \"\";\n }\n if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(textResourceValue).join(\"\");\n if (isThenable(node)) return textResourceValue(readThenable(node));\n\n throw new Error(\"<title> can only contain text during server render.\");\n}\n\nfunction metaResourceKey(resource: MetaResource): string {\n if (resource.charset !== undefined) return `meta:charset:${resource.charset}`;\n if (resource.name !== undefined) return `meta:name:${resource.name}`;\n if (resource.property !== undefined)\n return `meta:property:${resource.property}`;\n return `meta:http-equiv:${resource[\"http-equiv\"]}`;\n}\n"],"mappings":";;AAWA,MAAM,kCAAkB,IAAI,QAAyC;AAErE,SAAS,UAAa,UAA6C;CACjE,MAAM,MAAM;CACZ,IAAI,SAAS,gBAAgB,IAAI,GAAG;CAEpC,IAAI,WAAW,KAAA,GAAW;EACxB,SAAS,EAAE,QAAQ,UAAU;EAC7B,gBAAgB,IAAI,KAAK,MAAM;EAC/B,MAAM,UAAU,SAA4B;GAG1C,IAAI,QAAQ,WAAW,WAAW;GAClC,SAAS;GACT,gBAAgB,IAAI,KAAK,IAAI;EAC/B;EACA,IAAI;GACF,SAAS,MACN,UAAU,OAAO;IAAE,QAAQ;IAAa;GAAM,CAAC,IAC/C,WAAoB,OAAO;IAAE;IAAQ,QAAQ;GAAW,CAAC,CAC5D;EACF,SAAS,QAAQ;GAEf,OAAO;IAAE;IAAQ,QAAQ;GAAW,CAAC;EACvC;CACF;CAEA,OAAO;AACT;;AAMA,SAAgB,cAAiB,UAAgC;CAC/D,UAAU,QAAQ;AACpB;;AAGA,SAAgB,aAAgB,UAA6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AAW,OAAO,aAAa,SAAS;CAC9D,IAAI,SAAS,aAAa,KAAA,GACxB,OAAO,iBAAiB,SAAS;CACnC,OAAO,mBAAmB,SAAS;AACrC"}
@@ -1,5 +1,5 @@
1
1
  import { P as readBrowser } from "./element-DpXdLgOZ.js";
2
- import { y as isThenable$1 } from "./resource-DEDmLSNk.js";
2
+ import { b as isThenable$1 } from "./resource-Co4W0CCc.js";
3
3
  //#region src/context.ts
4
4
  /** The Fig context symbol. */
5
5
  const FigContextSymbol = Symbol.for("fig.context");
@@ -317,13 +317,22 @@ var DefaultDataStore = class {
317
317
  return this.snapshotKeys(this.entries.keys());
318
318
  }
319
319
  snapshotKeys(canonicalKeys, deferred) {
320
+ const entries = [];
321
+ this.collectSnapshot(canonicalKeys, entries, deferred ?? entries);
322
+ return entries;
323
+ }
324
+ snapshotDependencies(canonicalKeys) {
325
+ const dependencies = [];
326
+ this.collectSnapshot(canonicalKeys, null, dependencies);
327
+ return dependencies;
328
+ }
329
+ collectSnapshot(canonicalKeys, requestedRows, dependencyRows) {
320
330
  const sources = /* @__PURE__ */ new Map();
321
331
  for (const entry of this.entries.values()) for (const retainer of entry.retainers ?? []) {
322
332
  const retained = sources.get(retainer);
323
333
  if (retained === void 0) sources.set(retainer, [entry]);
324
334
  else retained.push(entry);
325
335
  }
326
- const entries = [];
327
336
  const visited = /* @__PURE__ */ new Set();
328
337
  const requested = new Set(canonicalKeys);
329
338
  const visit = (entry) => {
@@ -331,17 +340,16 @@ var DefaultDataStore = class {
331
340
  visited.add(entry);
332
341
  const signal = entry.valueController?.signal;
333
342
  if (signal !== void 0) sources.get(signal)?.forEach(visit);
334
- const isRequested = requested.has(entry.canonicalKey);
335
- if (!isRequested && typeof entry.resource?.transfer !== "function") return;
343
+ const rows = requested.has(entry.canonicalKey) ? requestedRows : typeof entry.resource?.transfer === "function" ? dependencyRows : null;
344
+ if (rows === null) return;
336
345
  const transferred = transferValue(entry);
337
346
  if (transferred === void 0) return;
338
- (isRequested ? entries : deferred ?? entries).push({
347
+ rows.push({
339
348
  key: entry.key,
340
349
  value: transferred.value
341
350
  });
342
351
  };
343
352
  for (const key of requested) visit(this.entries.get(key));
344
- return entries;
345
353
  }
346
354
  inspectDataEntries() {
347
355
  return Array.from(this.entries.values(), (entry) => this.snapshotEntry(entry));
@@ -1208,4 +1216,4 @@ function setTransitionHandler(handler) {
1208
1216
  //#endregion
1209
1217
  export { isContext as C, createContext as S, markDataResourceError as _, createDataStore as a, setCurrentDataStore as b, dataResource as c, readDataStore as d, runWithDataStore as f, loadContextCapabilities as g, defineLoadContextCapabilities as h, attachDataStore as i, isDataStoreController as l, dataResourceKeysForError as m, setTransitionHandler as n, createRendererDataStore as o, MissingCapabilityError as p, transition as r, currentDataStore as s, runTransitionScope as t, normalizeDataResourceKey as u, requireCapability as v, FigContextSymbol as x, resolveCurrentDataStore as y };
1210
1218
 
1211
- //# sourceMappingURL=transition-C03gUimZ.js.map
1219
+ //# sourceMappingURL=transition-B8ZLez3D.js.map