@bgub/fig 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/{element-DT9ziqWN.d.ts → element-Ba2mDNM_.d.ts} +32 -4
- package/dist/{hooks-GeZ4mX7W.d.ts → hooks-CUdLWnbQ.d.ts} +10 -6
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/internal.d.ts +8 -3
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/payload.d.ts +1 -1
- package/dist/{transition-BFLGYE4q.js → transition-C03gUimZ.js} +156 -16
- package/dist/transition-C03gUimZ.js.map +1 -0
- package/dist-development/index.js +2 -2
- package/dist-development/internal.js +1 -1
- package/dist-development/internal.js.map +1 -1
- package/dist-development/{transition-CWjp9qRO.js → transition-BZTyeaMo.js} +162 -18
- package/dist-development/transition-BZTyeaMo.js.map +1 -0
- package/package.json +1 -1
- package/dist/transition-BFLGYE4q.js.map +0 -1
- package/dist-development/transition-CWjp9qRO.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## @bgub/fig@2.2.0
|
|
2
|
+
|
|
3
|
+
### Add transfer rules for data resources
|
|
4
|
+
|
|
5
|
+
Add the `transfer` data-resource option. `transfer: false` keeps a resource's entries (a database client, a connection) out of `getData()`, `takeData()`, `snapshot()`, streamed Suspense data, and Payload data rows. `transfer(value)` requires a loader and sends a serializable form instead, taken when the snapshot or row is written (or just before disposal retires the value); the receiving store hands that form to the resource's next load as `context.transferred` rather than rendering it. In dev, a render read whose load returns a promise for a transferred value throws, since that read would suspend hydration for state that already arrived. Streamed Suspense data and Payload data rows now also carry the entries a read's load ensured through `data` that declare a `transfer` function, ahead of the read, so a derived value arrives with its sources.
|
|
6
|
+
|
|
7
|
+
Add `requireCapability(condition, reason?)` and `MissingCapabilityError`. A load that needs a capability (such as IndexedDB) asserts its availability with this function; a true condition narrows in TypeScript and continues, while a false condition throws `MissingCapabilityError`; during server rendering a read of that entry leaves the nearest Suspense fallback for the browser (via `readBrowser`) without reporting `onError`, and `data.ensureData` rejects with the error. A requirement thrown before any asynchronous work settles synchronously so the shell decides it.
|
|
8
|
+
|
|
9
|
+
### Stream only opted-in data dependencies
|
|
10
|
+
|
|
11
|
+
Stream ensured data dependencies only when their resource declares a `transfer` function. Continue traversing plain intermediary dependencies to discover opted-in sources. Direct reads and explicit snapshots retain their existing transfer behavior; use `transfer: false` to exclude an entry from all transfer paths.
|
|
12
|
+
|
|
13
|
+
Payload data rows now carry only the entries a payload read, plus the opted-in dependencies those reads ensured. Previously every entry that settled during a payload render was sent, including entries only ensured through `data` for computation; those no longer cross unless read directly or opted in. This keeps entries out of the stream, not on the server: use `transfer: false` for values that must never leave it.
|
|
14
|
+
|
|
15
|
+
### Stream transfer dependencies after the reveal
|
|
16
|
+
|
|
17
|
+
Streamed Suspense data now sends a read's `transfer` dependencies after the boundary's reveal instead of ahead of it, so their size no longer delays the reveal. A marker for each key goes ahead of the reveal. The browser holds a load of a marked key until the key's form arrives, and the form seeds that load as `transferred`. If the document finishes loading without the form, the load runs without one. A seeded TanStack DB collection therefore still imports its rows and sync metadata before its sync starts. Shell reads, `getData()`, and Payload data rows are unchanged.
|
|
18
|
+
|
|
19
|
+
A direct reader in another boundary can receive a queued dependency form without waiting for the original boundary to finish. Queued forms also remain available to `takeData()`, and each form is delivered only once.
|
|
20
|
+
|
|
21
|
+
### Keep transfer forms out of watch equality
|
|
22
|
+
|
|
23
|
+
Keep unconsumed custom transfer forms out of watched data resources' live-value equality callbacks. A new watch publication replaces the form without loading it; ordinary hydrated values still use equality to suppress unchanged publications.
|
|
24
|
+
|
|
1
25
|
## @bgub/fig@2.1.0
|
|
2
26
|
|
|
3
27
|
### Add intentional browser-only rendering
|
|
@@ -5,17 +5,25 @@ type DataResourceKeyInput = string | number | boolean | null | readonly DataReso
|
|
|
5
5
|
};
|
|
6
6
|
/** Describes data resource key. */
|
|
7
7
|
type DataResourceKey = readonly [string, ...DataResourceKeyInput[]];
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Describes data resource load context. `TForm` is what the resource's
|
|
10
|
+
* `transfer` returns, so `transferred` has the type the server sent.
|
|
11
|
+
*/
|
|
12
|
+
interface DataResourceLoadContext<TForm = unknown> {
|
|
10
13
|
/**
|
|
11
14
|
* The store running this load. Entries ensured through it stay cached
|
|
12
15
|
* while this load's value is visible.
|
|
13
16
|
*/
|
|
14
17
|
data: FigDataStoreHandle;
|
|
15
18
|
signal: AbortSignal;
|
|
19
|
+
/**
|
|
20
|
+
* The transfer form a server snapshot sent for this entry, when its
|
|
21
|
+
* resource has a `transfer` function; consumed by this load.
|
|
22
|
+
*/
|
|
23
|
+
transferred?: TForm;
|
|
16
24
|
}
|
|
17
25
|
/** Describes data resource loader. */
|
|
18
|
-
type DataResourceLoader<TArgs extends unknown[], TValue> = (...argsAndContext: [...TArgs, DataResourceLoadContext]) => TValue | PromiseLike<TValue>;
|
|
26
|
+
type DataResourceLoader<TArgs extends unknown[], TValue, TForm = unknown> = (...argsAndContext: [...TArgs, DataResourceLoadContext<TForm>]) => TValue | PromiseLike<TValue>;
|
|
19
27
|
/**
|
|
20
28
|
* Capabilities a watch receives. Every operation is bound to the watched key
|
|
21
29
|
* and becomes inert once `signal` aborts.
|
|
@@ -49,6 +57,7 @@ interface DataResource<TArgs extends unknown[] = unknown[], TValue = unknown> {
|
|
|
49
57
|
readonly inactiveRetentionMs?: number;
|
|
50
58
|
readonly key: (...args: TArgs) => DataResourceKey;
|
|
51
59
|
readonly load?: DataResourceLoader<TArgs, TValue>;
|
|
60
|
+
readonly transfer?: false | ((value: TValue) => unknown);
|
|
52
61
|
readonly watch?: DataResourceWatcher<TArgs, TValue>;
|
|
53
62
|
}
|
|
54
63
|
/** Describes data refresh result. */
|
|
@@ -127,6 +136,8 @@ interface FigDataStore extends FigDataStoreHandle {
|
|
|
127
136
|
releaseDataReads(reads: FigDataReads): void;
|
|
128
137
|
dispose(): void;
|
|
129
138
|
hydrateMissing(entries: readonly FigDataHydrationEntry[]): void;
|
|
139
|
+
awaitTransferForms(keys: readonly DataResourceKey[]): void;
|
|
140
|
+
releaseTransferForms(): void;
|
|
130
141
|
inspectDataDependencyCanonicalKeys(owner: object): string[];
|
|
131
142
|
inspectDataEntries(): DataStoreEntrySnapshot[];
|
|
132
143
|
snapshot(): FigDataHydrationEntry[];
|
|
@@ -162,6 +173,23 @@ declare function setCurrentDataStore(store: FigDataStore | null): FigDataStore |
|
|
|
162
173
|
declare function markDataResourceError(error: unknown, key: DataResourceKey): void;
|
|
163
174
|
/** Data resource keys for error. */
|
|
164
175
|
declare function dataResourceKeysForError(error: unknown): DataResourceKey[] | undefined;
|
|
176
|
+
declare const MissingCapabilityBrand: unique symbol;
|
|
177
|
+
/**
|
|
178
|
+
* Thrown by `requireCapability`: this load cannot run in the current
|
|
179
|
+
* environment. During server rendering, a read of the entry leaves the
|
|
180
|
+
* nearest Suspense fallback for the browser to render.
|
|
181
|
+
*/
|
|
182
|
+
declare class MissingCapabilityError extends Error {
|
|
183
|
+
readonly [MissingCapabilityBrand] = true;
|
|
184
|
+
readonly reason: string | (() => unknown) | undefined;
|
|
185
|
+
constructor(reason?: string | (() => unknown));
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Asserts that a load's required capability is available. A false condition
|
|
189
|
+
* throws MissingCapabilityError; a true condition narrows it and lets the
|
|
190
|
+
* load continue in environments that provide the capability.
|
|
191
|
+
*/
|
|
192
|
+
declare function requireCapability(condition: boolean, reason?: string | (() => unknown)): asserts condition;
|
|
165
193
|
//#endregion
|
|
166
194
|
//#region src/resource.d.ts
|
|
167
195
|
/** Describes asset resource blocking. */
|
|
@@ -488,4 +516,4 @@ declare function isViewTransition(value: unknown): value is FigViewTransition;
|
|
|
488
516
|
/** Checks whether assets. */
|
|
489
517
|
declare function isAssets(value: unknown): value is FigAssets;
|
|
490
518
|
//#endregion
|
|
491
|
-
export { isViewTransition as $, FigDataStoreOptions as $t, Fragment as A, preconnect as At, ViewTransitionPhase as B, DataResourceLoadContext as Bt, FigNode as C, assetResourceKey as Ct, FigSuspenseSymbol as D, isFigAssetResource as Dt, FigSuspense as E, font as Et, SuspenseProps as F, title as Ft, createPortalNode as G, FigDataEntryStatus as Gt, ViewTransitionSurface as H, DataResourceWatchContext as Ht, ViewTransition as I, DataRefreshResult as It, isClientReference as J, FigDataStore as Jt, isActivity as K, FigDataHydrationEntry as Kt, ViewTransitionCallback as L, DataResource as Lt, LazyLoader as M, preventAssetResourceHoist as Mt, Props as N, script as Nt, FigViewTransition as O, meta as Ot, Suspense as P, stylesheet as Pt, isValidElement as Q, FigDataStoreHost as Qt, ViewTransitionClass as R, DataResourceKey as Rt, FigErrorBoundarySymbol as S, assetResourceHostProps as St, FigPortalSymbol as T, clientReferenceAssets as Tt, clientReference as U, DataResourceWatcher as Ut, ViewTransitionProps as V, DataResourceLoader as Vt, createElement as W, DataStoreEntrySnapshot as Wt, isPortal as X, FigDataStoreFactory as Xt, isErrorBoundary as Y, FigDataStoreController as Yt, isSuspense as Z, FigDataStoreHandle as Zt, FigClientReference as _, TitleResource as _t, AwaitedFigNode as a,
|
|
519
|
+
export { isViewTransition as $, FigDataStoreOptions as $t, Fragment as A, preconnect as At, ViewTransitionPhase as B, DataResourceLoadContext as Bt, FigNode as C, assetResourceKey as Ct, FigSuspenseSymbol as D, isFigAssetResource as Dt, FigSuspense as E, font as Et, SuspenseProps as F, title as Ft, createPortalNode as G, FigDataEntryStatus as Gt, ViewTransitionSurface as H, DataResourceWatchContext as Ht, ViewTransition as I, DataRefreshResult as It, isClientReference as J, FigDataStore as Jt, isActivity as K, FigDataHydrationEntry as Kt, ViewTransitionCallback as L, DataResource as Lt, LazyLoader as M, preventAssetResourceHoist as Mt, Props as N, script as Nt, FigViewTransition as O, meta as Ot, Suspense as P, stylesheet as Pt, isValidElement as Q, FigDataStoreHost as Qt, ViewTransitionClass as R, DataResourceKey as Rt, FigErrorBoundarySymbol as S, assetResourceHostProps as St, FigPortalSymbol as T, clientReferenceAssets as Tt, clientReference as U, DataResourceWatcher as Ut, ViewTransitionProps as V, DataResourceLoader as Vt, createElement as W, DataStoreEntrySnapshot as Wt, isPortal as X, FigDataStoreFactory as Xt, isErrorBoundary as Y, FigDataStoreController as Yt, isSuspense as Z, FigDataStoreHandle as Zt, FigClientReference as _, TitleResource as _t, AwaitedFigNode as a, defineLoadContextCapabilities as an, ClientReferenceAssets as at, FigElementSymbol as b, assetResourceFromHostProps as bt, ComponentType as c, requireCapability as cn, FigAssetResource as ct, ErrorBoundaryProps as d, MetaResourceOptions as dt, LoadContextAttributeError as en, lazy as et, ErrorInfo as f, ModulePreloadResource as ft, FigAssetsSymbol as g, StylesheetResource as gt, FigAssets as h, ScriptResource as ht, Assets as i, dataResourceKeysForError as in, AssetsProps as it, Key as j, preload as jt, FigViewTransitionSymbol as k, modulepreload as kt, ElementType as l, resolveCurrentDataStore as ln, FigAssetResourceList as lt, FigActivitySymbol as m, PreloadResource as mt, ActivityMode as n, LoadContextHydrate as nn, AssetResourceDestination as nt, ClientReferenceOptions as o, loadContextCapabilities as on, CrossOrigin as ot, FigActivity as p, PreconnectResource as pt, isAssets as q, FigDataReads as qt, ActivityProps as r, MissingCapabilityError as rn, AssetResourceHostProps as rt, ComponentProps as s, markDataResourceError as sn, FetchPriority as st, Activity as t, LoadContextCapabilities as tn, AssetResourceBlocking as tt, ErrorBoundary as u, setCurrentDataStore as un, MetaResource as ut, FigClientReferenceSymbol as v, assetResourceDestination as vt, FigPortal as w, assets as wt, FigErrorBoundary as x, assetResourceFromHostValues as xt, FigElement as y, assetResourceFromHostAttributes as yt, ViewTransitionEvent as z, DataResourceKeyInput as zt };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as FigDataStoreOptions, C as FigNode, Jt as FigDataStore, Kt as FigDataHydrationEntry, Lt as DataResource, N as Props, Qt as FigDataStoreHost, Rt as DataResourceKey, Ut as DataResourceWatcher, Vt as DataResourceLoader, Wt as DataStoreEntrySnapshot, Yt as FigDataStoreController, Zt as FigDataStoreHandle, zt as DataResourceKeyInput } from "./element-
|
|
1
|
+
import { $t as FigDataStoreOptions, C as FigNode, Jt as FigDataStore, Kt as FigDataHydrationEntry, Lt as DataResource, N as Props, Qt as FigDataStoreHost, Rt as DataResourceKey, Ut as DataResourceWatcher, Vt as DataResourceLoader, Wt as DataStoreEntrySnapshot, Yt as FigDataStoreController, Zt as FigDataStoreHandle, zt as DataResourceKeyInput } from "./element-Ba2mDNM_.js";
|
|
2
2
|
//#region src/context.d.ts
|
|
3
3
|
/** Describes Fig context. */
|
|
4
4
|
interface FigContext<T> {
|
|
@@ -17,13 +17,17 @@ declare function createContext<T>(defaultValue: T): FigContext<T>;
|
|
|
17
17
|
declare function isContext(value: unknown): value is FigContext<unknown>;
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/data-store.d.ts
|
|
20
|
-
/**
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Describes data resource options. `TForm` is inferred from `transfer` and
|
|
22
|
+
* types the `transferred` value `load` receives.
|
|
23
|
+
*/
|
|
24
|
+
interface DataResourceOptions<TArgs extends unknown[], TValue, TForm = unknown> {
|
|
22
25
|
key: (...args: TArgs) => DataResourceKey;
|
|
23
26
|
debugArgs?: (...args: TArgs) => DataResourceKeyInput;
|
|
24
27
|
equals?: (previous: TValue, next: TValue) => boolean;
|
|
25
28
|
inactiveRetentionMs?: number;
|
|
26
|
-
load?: DataResourceLoader<TArgs, TValue>;
|
|
29
|
+
load?: DataResourceLoader<TArgs, TValue, TForm>;
|
|
30
|
+
transfer?: false | ((value: TValue) => TForm | undefined);
|
|
27
31
|
watch?: DataResourceWatcher<TArgs, TValue>;
|
|
28
32
|
}
|
|
29
33
|
/** Describes data store host. */
|
|
@@ -39,10 +43,10 @@ interface DataStoreHost<Owner extends object, Lane> {
|
|
|
39
43
|
/** Describes data store. */
|
|
40
44
|
interface DataStore<Owner extends object = object, Lane = unknown> extends FigDataStore {
|
|
41
45
|
readonly host: DataStoreHost<Owner, Lane>;
|
|
42
|
-
snapshotKeys(canonicalKeys: Iterable<string
|
|
46
|
+
snapshotKeys(canonicalKeys: Iterable<string>, deferred?: FigDataHydrationEntry[]): FigDataHydrationEntry[];
|
|
43
47
|
}
|
|
44
48
|
/** Data resource. */
|
|
45
|
-
declare function dataResource<TArgs extends unknown[], TValue>(options: DataResourceOptions<TArgs, TValue>): DataResource<TArgs, TValue>;
|
|
49
|
+
declare function dataResource<TArgs extends unknown[], TValue, TForm = unknown>(options: DataResourceOptions<TArgs, TValue, TForm>): DataResource<TArgs, TValue>;
|
|
46
50
|
/** Reads data store. */
|
|
47
51
|
declare function readDataStore(): FigDataStoreHandle;
|
|
48
52
|
/** Creates data store. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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, 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, 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-
|
|
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-
|
|
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, 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, script, stylesheet, title, transition, useActionState, useBeforeLayout, useBeforePaint, useCallback, useDeferredValue, useId, useMemo, useReactive, useStableEvent, useState, useSyncExternalStore, useTransition };
|
|
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";
|
|
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 {
|
|
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";
|
|
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
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";
|
|
4
|
-
export { Activity, ErrorBoundary, Fragment, Suspense, ViewTransition, assets, clientReference, createContext, createDataStore, createElement, createMixin, dataResource, font, isValidElement, lazy, meta, modulepreload, preconnect, preload, readContext, readData, readDataStore, readPromise, script, stylesheet, title, transition, useActionState, useBeforeLayout, useBeforePaint, useCallback, useDeferredValue, useId, useMemo, useReactive, useStableEvent, useState, useSyncExternalStore, useTransition };
|
|
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 };
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
|
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-
|
|
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";
|
|
3
3
|
//#region src/children.d.ts
|
|
4
4
|
/** Describes normalized child. */
|
|
5
5
|
type NormalizedChild = FigElement<any> | FigPortal<any> | PromiseLike<AwaitedFigNode> | string;
|
|
@@ -271,6 +271,11 @@ declare const EARLY_EVENT_QUEUE_PROPERTY = "__figEarlyEvents";
|
|
|
271
271
|
declare const EARLY_EVENT_HANDLER_PROPERTY = "__figEarlyEventHandler";
|
|
272
272
|
/** The streamed data property. */
|
|
273
273
|
declare const STREAMED_DATA_PROPERTY = "__figStreamedData";
|
|
274
|
+
/** Describes a streamed data marker. */
|
|
275
|
+
interface StreamedDataMarker {
|
|
276
|
+
key: DataResourceKey;
|
|
277
|
+
pending: true;
|
|
278
|
+
}
|
|
274
279
|
/** The replayable event types. */
|
|
275
280
|
declare const REPLAYABLE_EVENT_TYPES: readonly ["click", "keydown", "keyup", "pointerdown", "pointerup"];
|
|
276
281
|
//#endregion
|
|
@@ -284,4 +289,4 @@ declare function readThenable<T>(thenable: PromiseLike<T>): T;
|
|
|
284
289
|
/** Checks whether thenable. */
|
|
285
290
|
declare function isThenable(value: unknown): value is Thenable;
|
|
286
291
|
//#endregion
|
|
287
|
-
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 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 };
|
|
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 };
|
package/dist/internal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
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";
|
|
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
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";
|
|
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";
|
package/dist/internal.js.map
CHANGED
|
@@ -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.\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/** 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;IAEF,MAAM,kBAAkB,KAAK;GAC/B;EACF;EAEA,MAAM,aAAa,SAAS,MAAM,GAAG,KAAK;EAC1C,OAAO,QAAQ,SAAS,QAAQ,SAAS,GACvC,aAAa,SAAS,QAAQ,UAAU;EAE1C,OAAO;CACT;CACA,OAAO;AACT;AAEA,SAAS,aAAa,MAAe,UAAmC;CACtE,IAAI,MAAM,QAAQ,IAAI,GAAG;EACvB,KAAK,MAAM,SAAS,MAAM,aAAa,OAAO,QAAQ;EACtD;CACF;CAEA,IAAI,SAAS,QAAQ,SAAS,KAAA,KAAa,OAAO,SAAS,WAAW;CAEtE,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;EACxD,gB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;;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;;AAEtC,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// 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;IAEF,MAAM,kBAAkB,KAAK;GAC/B;EACF;EAEA,MAAM,aAAa,SAAS,MAAM,GAAG,KAAK;EAC1C,OAAO,QAAQ,SAAS,QAAQ,SAAS,GACvC,aAAa,SAAS,QAAQ,UAAU;EAE1C,OAAO;CACT;CACA,OAAO;AACT;AAEA,SAAS,aAAa,MAAe,UAAmC;CACtE,IAAI,MAAM,QAAQ,IAAI,GAAG;EACvB,KAAK,MAAM,SAAS,MAAM,aAAa,OAAO,QAAQ;EACtD;CACF;CAEA,IAAI,SAAS,QAAQ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;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/jsx-runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Fragment, C as FigNode, j as Key, l as ElementType, y as FigElement } from "./element-
|
|
1
|
+
import { A as Fragment, C as FigNode, j as Key, l as ElementType, y as FigElement } from "./element-Ba2mDNM_.js";
|
|
2
2
|
//#region src/jsx-runtime.d.ts
|
|
3
3
|
/** Describes JSX props. */
|
|
4
4
|
type JSXProps = Record<string, unknown>;
|
package/dist/payload.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kt as FigDataHydrationEntry, a as AwaitedFigNode, ct as FigAssetResource, l as ElementType } from "./element-
|
|
1
|
+
import { Kt as FigDataHydrationEntry, a as AwaitedFigNode, ct as FigAssetResource, l as ElementType } from "./element-Ba2mDNM_.js";
|
|
2
2
|
//#region src/payload-client-reference.d.ts
|
|
3
3
|
/** Describes payload client reference. */
|
|
4
4
|
interface PayloadClientReference {
|