@bgub/fig 0.1.3 → 2.0.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 +60 -0
- package/dist/{element-9MtOc5qb.d.ts → element-B4LrR2ZB.d.ts} +7 -4
- package/dist/{element-mHDfizuh.js → element-j7AKp0nu.js} +15 -6
- package/dist/element-j7AKp0nu.js.map +1 -0
- package/dist/{hooks-Bw3vbom7.d.ts → hooks-QSWYd3Vl.d.ts} +27 -15
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/internal.d.ts +5 -3
- package/dist/internal.js +5 -5
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/{dist-development/payload-format-BbsvTG9V.js → dist/payload-format-B9UbNtxo.js} +2 -1
- package/dist/payload-format-B9UbNtxo.js.map +1 -0
- package/dist/payload.d.ts +1 -1
- package/dist/payload.js +4 -3
- package/dist/payload.js.map +1 -1
- package/{dist-development/resource-Bhusybfq.js → dist/resource-Lwjz_b4h.js} +17 -11
- package/dist/resource-Lwjz_b4h.js.map +1 -0
- package/dist/{transition-WvgFiYNY.js → transition-DJfG2ZSm.js} +108 -65
- package/dist/transition-DJfG2ZSm.js.map +1 -0
- package/dist-development/{element-CVlfN_3_.js → element-DzmNF67v.js} +15 -6
- package/dist-development/element-DzmNF67v.js.map +1 -0
- package/dist-development/index.js +3 -3
- package/dist-development/internal.js +5 -5
- package/dist-development/jsx-runtime.js +1 -1
- package/{dist/payload-format-BbsvTG9V.js → dist-development/payload-format-B9UbNtxo.js} +2 -1
- package/dist-development/payload-format-B9UbNtxo.js.map +1 -0
- package/dist-development/payload.js +4 -3
- package/dist-development/payload.js.map +1 -1
- package/{dist/resource-BJxS62H2.js → dist-development/resource-YO25HR7G.js} +17 -11
- package/dist-development/resource-YO25HR7G.js.map +1 -0
- package/dist-development/{transition-BSxdDR9D.js → transition-CrIF0Kz_.js} +108 -65
- package/dist-development/transition-CrIF0Kz_.js.map +1 -0
- package/package.json +1 -1
- package/dist/element-mHDfizuh.js.map +0 -1
- package/dist/payload-format-BbsvTG9V.js.map +0 -1
- package/dist/resource-BJxS62H2.js.map +0 -1
- package/dist/transition-WvgFiYNY.js.map +0 -1
- package/dist-development/element-CVlfN_3_.js.map +0 -1
- package/dist-development/payload-format-BbsvTG9V.js.map +0 -1
- package/dist-development/resource-Bhusybfq.js.map +0 -1
- package/dist-development/transition-BSxdDR9D.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"element-mHDfizuh.js","names":["runtimeType"],"sources":["../src/data.ts","../src/hooks.ts","../src/mixin.ts","../src/element.ts"],"sourcesContent":["/** Describes data resource key input. */\nexport type DataResourceKeyInput =\n | string\n | number\n | boolean\n | null\n | readonly DataResourceKeyInput[]\n | { readonly [key: string]: DataResourceKeyInput };\n\n/** Describes data resource key. */\nexport type DataResourceKey = readonly [string, ...DataResourceKeyInput[]];\n\n/** Describes data resource load context. */\nexport interface DataResourceLoadContext {\n signal: AbortSignal;\n}\n\n/** Describes data resource loader. */\nexport type DataResourceLoader<TArgs extends unknown[], TValue> = (\n ...argsAndContext: [...TArgs, DataResourceLoadContext]\n) => TValue | PromiseLike<TValue>;\n\n/** Describes data resource. */\nexport interface DataResource<\n TArgs extends unknown[] = unknown[],\n TValue = unknown,\n> {\n readonly $$typeof: symbol;\n readonly debugArgs?: (...args: TArgs) => DataResourceKeyInput;\n readonly key: (...args: TArgs) => DataResourceKey;\n readonly load?: DataResourceLoader<TArgs, TValue>;\n}\n\n/** Describes data refresh result. */\nexport type DataRefreshResult<T> =\n | { status: \"fulfilled\"; value: T }\n | { status: \"rejected\"; error: unknown; staleValue?: T }\n | {\n status: \"aborted\";\n reason: \"superseded\" | \"store-disposed\" | \"evicted\";\n staleValue?: T;\n }\n | {\n status: \"unsupported\";\n reason: \"no-client-loader\";\n staleValue?: T;\n };\n\n/** Describes Fig data hydration entry. */\nexport interface FigDataHydrationEntry {\n key: DataResourceKey;\n value: unknown;\n}\n\n/** Describes Fig data entry status. */\nexport type FigDataEntryStatus =\n | \"pending\"\n | \"fulfilled\"\n | \"rejected\"\n | \"refreshing\";\n\n/** Describes data store entry snapshot. */\nexport interface DataStoreEntrySnapshot {\n canonicalKey: string;\n error?: unknown;\n hasValue: boolean;\n key: DataResourceKey;\n pending: boolean;\n refreshError?: unknown;\n stale: boolean;\n status: FigDataEntryStatus;\n subscriberCount: number;\n value?: unknown;\n}\n\n// The explicit, app-facing store surface (FigRoot.data, readDataStore()).\n// The free functions in @bgub/fig resolve the ambient store slot, which\n// is only set while Fig executes synchronously — render, event handlers, the\n// synchronous prefix of actions and transitions, and effects. After an\n// `await` the slot is gone, so async flows capture this handle first and call\n// its methods instead.\n/** Describes Fig data store handle. */\nexport interface FigDataStoreHandle {\n // The awaitable read for code outside render (route loaders, actions after\n // an await): resolve the value this key would render with — the cached\n // value when the entry has one (kicking the same background revalidation a\n // stale readData does), the in-flight load's settlement on a cache miss —\n // and reject with the error readData would throw. Does not subscribe;\n // pair with readData in the component, which claims the settled entry\n // within the preload retention window.\n ensureData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): Promise<TValue>;\n hydrate(entries: readonly FigDataHydrationEntry[]): void;\n invalidateData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): void;\n invalidateDataError(error: unknown): boolean;\n invalidateDataKey(key: DataResourceKey): void;\n invalidateDataPrefix(prefix: DataResourceKey): void;\n preloadData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): void;\n refreshData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): Promise<DataRefreshResult<TValue>>;\n run<T>(callback: () => T): T;\n}\n\n/**\n * A root-neutral data store. A renderer adopts it exactly once, preserving\n * entries loaded before rendering while attaching subscriber scheduling.\n */\nexport interface FigDataStoreController extends FigDataStoreHandle {\n dispose(): void;\n snapshot(): FigDataHydrationEntry[];\n}\n\n/** Describes Fig data store options. */\nexport interface FigDataStoreOptions {\n initialData?: readonly FigDataHydrationEntry[];\n partition?: DataResourceKeyInput;\n}\n\n/** Describes Fig data store. */\nexport interface FigDataStore extends FigDataStoreHandle {\n commitDataDependencies(owner: object, previousOwner: object | null): void;\n deleteDataOwner(owner: object): void;\n releaseDataOwner(owner: object): void;\n resetDataDependencies(owner: object): void;\n dispose(): void;\n inspectDataDependencyCanonicalKeys(owner: object): string[];\n inspectDataEntries(): DataStoreEntrySnapshot[];\n snapshot(): FigDataHydrationEntry[];\n // Renderer plumbing, not handle surface: args stay an array because the\n // subscribing owner trails them.\n readData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n owner: object,\n ): TValue;\n}\n\n// The host callbacks a renderer hands to the data-store factory. Structurally\n// compatible with @bgub/fig's DataStoreHost so its renderer store can\n// register directly.\n/** Describes Fig data store host. */\nexport interface FigDataStoreHost {\n getLane(): unknown;\n partition?: DataResourceKeyInput;\n schedule(owner: object, lane: unknown): void;\n}\n\n/** Describes Fig data store factory. */\nexport type FigDataStoreFactory = (host: FigDataStoreHost) => FigDataStore;\n\n// The internal, generation-guarded metadata a store attaches to each loader\n// context (symbol-keyed: DataResourceLoadContext stays { signal } publicly).\n// Adapters use the resolved key and decode Payload rows through the calling\n// store without recomputing identity or exposing these capabilities to loaders.\n/** Describes load context hydrate. */\nexport type LoadContextHydrate = (\n entries: readonly FigDataHydrationEntry[],\n) => void;\n/** Describes load context attribute error. */\nexport type LoadContextAttributeError = (error: unknown) => void;\n\n/** Describes load context capabilities. */\nexport interface LoadContextCapabilities {\n attributeError: LoadContextAttributeError;\n hydrate: LoadContextHydrate;\n // Store contexts always provide this; optional keeps synthetic decoder\n // contexts usable without pretending they belong to a cache entry.\n key?: DataResourceKey;\n}\n\nconst LoadContextCapabilitiesSymbol = Symbol.for(\"fig.data-load-context\");\ntype DataResourceLoadContextWithCapabilities = DataResourceLoadContext & {\n [LoadContextCapabilitiesSymbol]?: LoadContextCapabilities;\n};\n\n/** Define load context capabilities. */\nexport function defineLoadContextCapabilities(\n context: DataResourceLoadContext,\n capabilities: LoadContextCapabilities,\n): void {\n Object.defineProperty(context, LoadContextCapabilitiesSymbol, {\n configurable: true,\n enumerable: false,\n value: capabilities,\n });\n}\n\n/** Load context capabilities. */\nexport function loadContextCapabilities(\n context: DataResourceLoadContext,\n): LoadContextCapabilities | undefined {\n return (context as DataResourceLoadContextWithCapabilities)[\n LoadContextCapabilitiesSymbol\n ];\n}\n\nconst objectDataErrors = new WeakMap<object, DataResourceKey[]>();\n\nlet currentDataStore: FigDataStore | null = null;\n\n/** Resolves current data store. */\nexport function resolveCurrentDataStore(\n message = \"Data resource APIs require a Fig data store.\",\n): FigDataStore {\n if (currentDataStore === null) throw new Error(message);\n return currentDataStore;\n}\n\n/** Sets current data store. */\nexport function setCurrentDataStore(\n store: FigDataStore | null,\n): FigDataStore | null {\n const previousStore = currentDataStore;\n currentDataStore = store;\n return previousStore;\n}\n\n/** Marks data resource error. */\nexport function markDataResourceError(\n error: unknown,\n key: DataResourceKey,\n): void {\n // Only object errors are attributed: the WeakMap keys them by identity, so the\n // registry is GC-safe and cannot cross-attribute. Primitive rejection values\n // would collide by value and accumulate forever in a plain Map, so a thrown\n // primitive simply carries no resource-key metadata.\n if (!isAttributableError(error)) return;\n\n let keys = objectDataErrors.get(error);\n if (keys === undefined) {\n keys = [];\n objectDataErrors.set(error, keys);\n }\n\n if (keys.some((existing) => sameDataResourceKey(existing, key))) return;\n\n keys.push(key);\n}\n\n/** Data resource keys for error. */\nexport function dataResourceKeysForError(\n error: unknown,\n): DataResourceKey[] | undefined {\n if (!isAttributableError(error)) return undefined;\n\n const keys = objectDataErrors.get(error);\n return keys === undefined || keys.length === 0 ? undefined : [...keys];\n}\n\nfunction sameDataResourceKey(a: DataResourceKey, b: DataResourceKey): boolean {\n return (\n a.length === b.length &&\n a.every((value, index) => Object.is(value, b[index]))\n );\n}\n\n// The single rule for which errors can carry attribution: identity-keyed\n// (WeakMap/WeakSet) registries require object errors. Shared with the store's\n// per-generation value-error sets so the two can never disagree.\nexport function isAttributableError(value: unknown): value is object {\n return (\n (typeof value === \"object\" || typeof value === \"function\") && value !== null\n );\n}\n","import type { FigContext } from \"./context.ts\";\nimport type { DataResource, FigDataStore } from \"./data.ts\";\nimport { resolveCurrentDataStore } from \"./data.ts\";\nimport type { TransitionOptions } from \"./transition.ts\";\n\n// The useState updater: accepts the next state, or an updater function of\n// the previous state for stale-closure safety.\n/** Describes state setter. */\nexport type StateSetter<S> = (next: S | ((previous: S) => S)) => void;\n/** Describes external store subscribe. */\nexport type ExternalStoreSubscribe = (callback: () => void) => () => void;\n// Fig appends the AbortSignal after the runner's args (the data-loader\n// shape). The signal aborts when a newer run supersedes this one, when the\n// owning component unmounts, and when an enclosing Activity hides.\n/** Describes action state action. */\nexport type ActionStateAction<S, Args extends unknown[]> = (\n previousState: S,\n ...argsAndSignal: [...Args, AbortSignal]\n) => S | PromiseLike<S>;\n/** Describes action state runner. */\nexport type ActionStateRunner<Args extends unknown[]> = (...args: Args) => void;\n\n/**\n * Runs state updates scheduled by `callback` at transition priority. If\n * `callback` returns a thenable, `useTransition` keeps `isPending` true until\n * it settles and updates after an `await` remain in the transition priority\n * scope.\n *\n * The callback receives an `AbortSignal` that aborts when a newer transition\n * starts from the same hook, when the owning component unmounts, and when an\n * enclosing Activity hides. Each `useTransition` hook is one cancellation\n * domain — use separate hooks for independently cancellable workflows. An\n * aborted run is retired: its pending slot is released immediately and its\n * settlement (including an aborted fetch's rejection) is inert.\n */\nexport type StartTransition = (\n callback: (signal: AbortSignal) => void | PromiseLike<void>,\n options?: TransitionOptions,\n) => void;\ntype Callback = (...args: never[]) => unknown;\n\n/** Describes render dispatcher. */\nexport interface RenderDispatcher {\n useState<S>(initialState: S | (() => S)): [S, StateSetter<S>];\n useActionState<S, Args extends unknown[]>(\n action: ActionStateAction<S, Args>,\n initialState: S,\n ): [S, ActionStateRunner<Args>, boolean];\n useId(): string;\n useDeferredValue<T>(\n value: T,\n initialValue: T | undefined,\n hasInitialValue: boolean,\n ): T;\n useMemo<T>(calculate: () => T, deps: DependencyList): T;\n useTransition(): [boolean, StartTransition];\n useReactive(effect: EffectCallback, deps?: DependencyList): void;\n useBeforePaint(effect: EffectCallback, deps?: DependencyList): void;\n useBeforeLayout(effect: EffectCallback, deps?: DependencyList): void;\n useSyncExternalStore<T>(\n subscribe: ExternalStoreSubscribe,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n ): T;\n useStableEvent<Args extends unknown[], Result>(\n handler: (...args: Args) => Result,\n ): (...args: StableEventCallerArgs<Args>) => Result;\n readContext<T>(context: FigContext<T>): T;\n readData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n ): TValue;\n preloadData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n ): void;\n readPromise<T>(promise: PromiseLike<T>): T;\n}\n\n/** Describes effect callback. */\nexport type EffectCallback = (signal: AbortSignal) => undefined;\n/** Describes dependency list. */\nexport type DependencyList = readonly unknown[];\n\n/** Describes stable event caller args. */\nexport type StableEventCallerArgs<Args extends unknown[]> = Args extends [\n ...infer CallerArgs,\n AbortSignal,\n]\n ? CallerArgs\n : Args;\n\n// Fig appends the AbortSignal when invoking the handler; callers never pass\n// it, so a declared trailing signal is stripped from the callable signature.\nlet currentDispatcher: RenderDispatcher | null = null;\n\n/** Returns state. */\nexport function useState<S>(initialState: S | (() => S)): [S, StateSetter<S>] {\n return resolveDispatcher().useState(initialState);\n}\n\n/**\n * Tracks state returned by a client-side action. The action receives the\n * previous committed state first, then the runner's arguments, then an\n * `AbortSignal` Fig appends (declare the trailing signal parameter — it also\n * drives `Args` inference). Async actions run in a transition priority scope\n * and keep `isPending` true until they settle.\n *\n * Runs are last-run-wins: starting a new run aborts the previous one's\n * signal and retires it — a retired run's settlement (value or rejection)\n * never touches state or pending. The signal also aborts on unmount and\n * when an enclosing Activity hides.\n */\nexport function useActionState<S, Args extends unknown[]>(\n action: ActionStateAction<S, Args>,\n initialState: S,\n): [S, ActionStateRunner<Args>, boolean] {\n return resolveDispatcher().useActionState(action, initialState);\n}\n\n/** Returns ID. */\nexport function useId(): string {\n return resolveDispatcher().useId();\n}\n\n/** Returns deferred value. */\nexport function useDeferredValue<T>(value: T, initialValue?: T): T {\n return resolveDispatcher().useDeferredValue(\n value,\n initialValue,\n arguments.length > 1,\n );\n}\n\n/** Returns memo. */\nexport function useMemo<T>(calculate: () => T, deps: DependencyList): T {\n return resolveDispatcher().useMemo(calculate, deps);\n}\n\n/** Returns transition. */\nexport function useTransition(): [boolean, StartTransition] {\n return resolveDispatcher().useTransition();\n}\n\n/** Returns callback. */\nexport function useCallback<T extends Callback>(\n callback: T,\n deps: DependencyList,\n): T {\n return resolveDispatcher().useMemo(() => callback, deps);\n}\n\n/** Returns reactive. */\nexport function useReactive(\n effect: EffectCallback,\n deps?: DependencyList,\n): void {\n resolveDispatcher().useReactive(effect, deps);\n}\n\n/** Returns before paint. */\nexport function useBeforePaint(\n effect: EffectCallback,\n deps?: DependencyList,\n): void {\n resolveDispatcher().useBeforePaint(effect, deps);\n}\n\n/** Returns before layout. */\nexport function useBeforeLayout(\n effect: EffectCallback,\n deps?: DependencyList,\n): void {\n resolveDispatcher().useBeforeLayout(effect, deps);\n}\n\n/** Returns sync external store. */\nexport function useSyncExternalStore<T>(\n subscribe: ExternalStoreSubscribe,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n): T {\n return resolveDispatcher().useSyncExternalStore(\n subscribe,\n getSnapshot,\n getServerSnapshot,\n );\n}\n\n/** Returns stable event. */\nexport function useStableEvent<Args extends unknown[], Result>(\n handler: (...args: Args) => Result,\n): (...args: StableEventCallerArgs<Args>) => Result {\n return resolveDispatcher().useStableEvent(handler);\n}\n\n/** Reads context. */\nexport function readContext<T>(context: FigContext<T>): T {\n return resolveDispatcher(\n \"readContext can only be called while rendering a component.\",\n ).readContext(context);\n}\n\n/** Reads promise. */\nexport function readPromise<T>(promise: PromiseLike<T>): T {\n return resolveDispatcher(\n \"readPromise can only be called while rendering a component.\",\n ).readPromise(promise);\n}\n\n/** Reads data. */\nexport function readData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): TValue {\n return resolveDispatcher(\n \"readData can only be called while rendering a component.\",\n ).readData(resource, args);\n}\n\n/** Preloads data. */\nexport function preloadData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): void {\n if (currentDispatcher !== null) {\n currentDispatcher.preloadData(resource, args);\n return;\n }\n\n resolveDataStore().preloadData(resource, ...args);\n}\n\n/** Sets current dispatcher. */\nexport function setCurrentDispatcher(\n dispatcher: RenderDispatcher | null,\n): RenderDispatcher | null {\n const previousDispatcher = currentDispatcher;\n currentDispatcher = dispatcher;\n return previousDispatcher;\n}\n\nfunction resolveDispatcher(\n message = \"Hooks can only be called while rendering a component.\",\n): RenderDispatcher {\n if (currentDispatcher === null) {\n throw new Error(message);\n }\n\n return currentDispatcher;\n}\n\nfunction resolveDataStore(): FigDataStore {\n return resolveCurrentDataStore(\n \"No ambient Fig data store. Data APIs work synchronously during render, \" +\n \"event handlers, actions, and effects — not after an await. Capture \" +\n \"readDataStore() (or root.data) synchronously and call the handle \" +\n \"instead.\",\n );\n}\n","import type { Props } from \"./element.ts\";\nimport { type RenderDispatcher, setCurrentDispatcher } from \"./hooks.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\n/** Describes mixin context. */\nexport interface MixinContext {\n /** The intrinsic host name receiving this mixin. */\n readonly type: string;\n /** Props composed by the host and every preceding mixin. */\n readonly props: Readonly<Props>;\n}\n\n/** Describes empty mixin value. */\nexport type EmptyMixinValue = false | 0 | 0n | \"\" | null | undefined;\n\n/** Describes mixin input. */\nexport type MixinInput =\n | MixinDescriptor\n | EmptyMixinValue\n | ReadonlyArray<MixinInput>;\n\n/** Describes mixin result. */\nexport type MixinResult = Props | MixinInput;\n\n/** Describes mixin type. */\nexport type MixinType<TArgs extends unknown[] = unknown[]> = (\n context: MixinContext,\n ...args: TArgs\n) => MixinResult;\n\ntype MixinRuntimeType = (\n context: MixinContext,\n ...args: unknown[]\n) => MixinResult;\n\n/** Describes mixin descriptor. */\nexport interface MixinDescriptor {\n readonly $$typeof: symbol;\n readonly args: readonly unknown[];\n readonly type: MixinRuntimeType;\n}\n\n/** Describes mixin factory. */\nexport type MixinFactory<TArgs extends unknown[]> = (\n ...args: TArgs\n) => MixinDescriptor;\n\n// Registered symbols: descriptors and contexts must stay recognizable when\n// duplicate copies of this module are live (linked source next to a\n// prebundled copy).\n/** The Fig mixin symbol. */\nexport const FigMixinSymbol = Symbol.for(\"fig.mixin\");\nconst FigMixinSlotSymbol = Symbol.for(\"fig.mixin-slot\");\nconst FigClientOnlyHostBehaviorSymbol = Symbol.for(\n \"fig.client-only-host-behavior\",\n);\ntype ClientOnlyHostProps = object & {\n [FigClientOnlyHostBehaviorSymbol]?: string;\n};\n\n/** Creates a render-time host behavior for the `mix` prop. */\nexport function createMixin<TArgs extends unknown[]>(\n type: MixinType<TArgs>,\n): MixinFactory<TArgs> {\n const runtimeType = type as MixinRuntimeType;\n const descriptorType = __DEV__ ? guardMixinType(runtimeType) : runtimeType;\n return (...args) => ({\n $$typeof: FigMixinSymbol,\n args,\n type: descriptorType,\n });\n}\n\nconst maximumResolvedMixins = 1024;\n\n/** Resolves host mix. */\nexport function resolveHostMix<P extends Props>(type: string, input: P): P {\n const props: Props = input;\n const mix = props.mix;\n delete props.mix;\n let resolvedMixins = 0;\n\n function resolve(value: unknown, slot: string): void {\n if (emptyMixinValue(value)) return;\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index += 1) {\n resolve(value[index], `${slot}.${index}`);\n }\n return;\n }\n if (!isMixinDescriptor(value)) {\n throw new Error(\n `The mix prop on <${type}> must contain descriptors created by createMixin().`,\n );\n }\n\n resolvedMixins += 1;\n if (resolvedMixins > maximumResolvedMixins) {\n throw new Error(\n `The mix prop on <${type}> resolved more than ${maximumResolvedMixins} mixins.`,\n );\n }\n\n const context: MixinRuntimeContext = {\n [FigMixinSlotSymbol]: slot,\n props,\n type,\n };\n const result = value.type(context, ...value.args);\n if (emptyMixinValue(result)) return;\n\n if (isMixinDescriptor(result) || Array.isArray(result)) {\n resolve(result, `${slot}.result`);\n return;\n }\n if (typeof result !== \"object\") {\n throw new Error(\n `A mixin on <${type}> must return host props, more mixins, or nothing.`,\n );\n }\n const returnedProps = result as Props;\n\n if (\n \"children\" in returnedProps ||\n \"key\" in returnedProps ||\n \"unsafeHTML\" in returnedProps\n ) {\n throw new Error(\n `A mixin on <${type}> cannot return children, key, or unsafeHTML.`,\n );\n }\n\n const { mix: nestedMix, ...patch } = returnedProps;\n Object.assign(props, patch);\n resolve(nestedMix, `${slot}.mix`);\n }\n\n resolve(mix, \"0\");\n props.mix = mix;\n return props as P;\n}\n\ninterface MixinRuntimeContext extends MixinContext {\n readonly [FigMixinSlotSymbol]: string;\n}\n\n/** Mixin slot. */\nexport function mixinSlot(context: MixinContext): string {\n return (context as MixinRuntimeContext)[FigMixinSlotSymbol];\n}\n\n/** Marks client only host behavior. */\nexport function markClientOnlyHostBehavior(\n context: MixinContext,\n behavior: string,\n): void {\n markClientOnlyHostProps(context.props, behavior);\n}\n\n/** Marks client only host props. */\nexport function markClientOnlyHostProps(value: object, behavior: string): void {\n const props = value as ClientOnlyHostProps;\n if (props[FigClientOnlyHostBehaviorSymbol] !== undefined) return;\n Object.defineProperty(props, FigClientOnlyHostBehaviorSymbol, {\n configurable: true,\n value: behavior,\n });\n}\n\n/** Client only host behavior. */\nexport function clientOnlyHostBehavior(props: object): string | undefined {\n const behavior = (props as ClientOnlyHostProps)[\n FigClientOnlyHostBehaviorSymbol\n ];\n return typeof behavior === \"string\" ? behavior : undefined;\n}\n\nfunction emptyMixinValue(value: unknown): value is EmptyMixinValue {\n return (\n value === false ||\n value === 0 ||\n value === 0n ||\n value === \"\" ||\n value === null ||\n value === undefined\n );\n}\n\nfunction isMixinDescriptor(value: unknown): value is MixinDescriptor {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"$$typeof\" in value &&\n value.$$typeof === FigMixinSymbol\n );\n}\n\n// Dev-only: the wrapper lives in the createMixin module copy, so it guards the\n// dispatcher used by hooks imported alongside that factory even when another\n// linked or prebundled copy resolves the descriptor.\nfunction guardMixinType(type: MixinRuntimeType): MixinRuntimeType {\n return (context, ...args) => {\n const previousDispatcher = setCurrentDispatcher(\n mixinDispatcher(context.type, mixinSlot(context)),\n );\n try {\n return type(context, ...args);\n } finally {\n setCurrentDispatcher(previousDispatcher);\n }\n };\n}\n\nfunction mixinDispatcher(type: string, slot: string): RenderDispatcher {\n return new Proxy({} as RenderDispatcher, {\n get(_target, property) {\n throw new Error(\n `A mixin on <${type}> (slot ${slot}) called ${String(property)}. ` +\n \"Mixins are pure render-time code: hooks and read verbs belong to \" +\n \"the component; host lifetimes belong in returned on() or bind \" +\n \"behavior.\",\n );\n },\n });\n}\n","import type { DataResourceKey } from \"./data.ts\";\nimport { readPromise } from \"./hooks.ts\";\nimport type { ClientReferenceAssets } from \"./resource.ts\";\nimport { resolveHostMix } from \"./mixin.ts\";\n\n/** Describes key. */\nexport type Key = string | number;\n/** Describes props. */\nexport type Props = Record<string, any>;\n/** Describes component type. */\nexport type ComponentType<P = Props> = (\n props: P & { children?: FigNode },\n) => FigNode;\n/** Describes component props. */\nexport type ComponentProps<T extends ComponentType<any>> =\n Parameters<T> extends [infer P, ...unknown[]]\n ? P extends Props\n ? P\n : Props\n : {};\n/** Describes element type. */\nexport type ElementType<P = Props> =\n | string\n | typeof Fragment\n | FigAssets\n | FigClientReference<P>\n | FigErrorBoundary\n | FigSuspense\n | FigActivity\n | FigViewTransition\n | ComponentType<P>;\n/** Describes awaited Fig node. */\nexport type AwaitedFigNode =\n | FigElement<any>\n | FigPortal<any>\n | string\n | number\n | boolean\n | null\n | undefined\n | FigNode[];\n/** Describes Fig node. */\nexport type FigNode = AwaitedFigNode | PromiseLike<AwaitedFigNode>;\n\n/** Describes Fig element. */\nexport interface FigElement<P = Props> {\n readonly $$typeof: symbol;\n readonly type: ElementType<any>;\n readonly key: Key | null;\n readonly props: P & { children?: FigNode };\n}\n\n/** Describes Fig portal. */\nexport interface FigPortal<Target = unknown> {\n readonly $$typeof: symbol;\n readonly children: FigNode;\n readonly key: Key | null;\n readonly target: Target;\n}\n\n/** Describes client reference options. */\nexport interface ClientReferenceOptions<P extends Props = Props> {\n assets?: ClientReferenceAssets;\n id: string;\n ssr?: ComponentType<P>;\n}\n\n/** Describes Fig client reference. */\nexport interface FigClientReference<P = Props> {\n (props: P & { children?: FigNode }): FigNode;\n readonly $$typeof: symbol;\n readonly assets?: ClientReferenceAssets;\n readonly id: string;\n readonly ssr?: ComponentType<P>;\n}\n\n/** Describes lazy loader. */\nexport type LazyLoader<T extends ComponentType<any> = ComponentType<any>> =\n () => PromiseLike<T>;\n\n/** Describes suspense props. */\nexport interface SuspenseProps {\n fallback?: FigNode;\n children?: FigNode;\n}\n\n/** Describes Fig suspense. */\nexport interface FigSuspense {\n (props: SuspenseProps): FigNode;\n readonly $$typeof: symbol;\n}\n\n/** Describes activity mode. */\nexport type ActivityMode = \"visible\" | \"hidden\";\n\n/** Describes activity props. */\nexport interface ActivityProps {\n mode: ActivityMode;\n children?: FigNode;\n}\n\n/** Describes Fig activity. */\nexport interface FigActivity {\n (props: ActivityProps): FigNode;\n readonly $$typeof: symbol;\n}\n\n/** Describes view transition class. */\nexport type ViewTransitionClass = \"auto\" | \"none\" | (string & {});\n\n/** Describes view transition phase. */\nexport type ViewTransitionPhase = \"enter\" | \"exit\" | \"share\" | \"update\";\n\n// Renderer-neutral identity for one named host surface in the native\n// transition. Renderer packages can resolve it into their own imperative\n// handles without putting host types in core.\n/** Describes view transition surface. */\nexport interface ViewTransitionSurface {\n readonly name: string;\n}\n\n/** Describes view transition event. */\nexport interface ViewTransitionEvent {\n readonly phase: ViewTransitionPhase;\n readonly surfaces: readonly ViewTransitionSurface[];\n readonly types: readonly string[];\n}\n\n/** Describes view transition callback. */\nexport type ViewTransitionCallback = (\n event: ViewTransitionEvent,\n signal: AbortSignal,\n) => undefined;\n\n/** Describes view transition props. */\nexport interface ViewTransitionProps {\n name?: string;\n children?: FigNode;\n default?: ViewTransitionClass;\n enter?: ViewTransitionClass;\n exit?: ViewTransitionClass;\n share?: ViewTransitionClass;\n update?: ViewTransitionClass;\n onTransition?: ViewTransitionCallback;\n}\n\n/** Describes Fig view transition. */\nexport interface FigViewTransition {\n (props: ViewTransitionProps): FigNode;\n readonly $$typeof: symbol;\n}\n\n/** Describes error boundary props. */\nexport interface ErrorBoundaryProps {\n // A function fallback receives the caught error so error UIs can render\n // it (message, retry affordance) without smuggling state above the\n // boundary through onError. Callable thenables are nodes, so the runtime\n // distinguishes them from render fallbacks before invoking the function.\n fallback?: FigNode | ((error: unknown, info: ErrorInfo) => FigNode);\n onError?: (error: unknown, info: ErrorInfo) => void;\n children?: FigNode;\n}\n\n/** Describes error info. */\nexport interface ErrorInfo {\n componentStack: string;\n dataResourceKeys?: DataResourceKey[];\n}\n\n/** Describes Fig error boundary. */\nexport interface FigErrorBoundary {\n (props: ErrorBoundaryProps): FigNode;\n readonly $$typeof: symbol;\n}\n\n/** Describes Fig assets. */\nexport interface FigAssets {\n (props: Props & { children?: FigNode }): FigNode;\n readonly $$typeof: symbol;\n}\n\n/** The fragment. */\nexport const Fragment = Symbol.for(\"fig.fragment\");\n/** The Fig element symbol. */\nexport const FigElementSymbol = Symbol.for(\"fig.element\");\n/** The Fig client reference symbol. */\nexport const FigClientReferenceSymbol = Symbol.for(\"fig.client-reference\");\n/** The Fig activity symbol. */\nexport const FigActivitySymbol = Symbol.for(\"fig.activity\");\n/** The Fig error boundary symbol. */\nexport const FigErrorBoundarySymbol = Symbol.for(\"fig.error-boundary\");\n/** The Fig portal symbol. */\nexport const FigPortalSymbol = Symbol.for(\"fig.portal\");\n/** The Fig assets symbol. */\nexport const FigAssetsSymbol = Symbol.for(\"fig.assets\");\n/** The Fig suspense symbol. */\nexport const FigSuspenseSymbol = Symbol.for(\"fig.suspense\");\n/** The Fig view transition symbol. */\nexport const FigViewTransitionSymbol = Symbol.for(\"fig.view-transition\");\n\n/** The assets. */\nexport const Assets: FigAssets = Object.assign(\n (props: Props & { children?: FigNode }) => props.children,\n { $$typeof: FigAssetsSymbol },\n);\n\n/** The error boundary. */\nexport const ErrorBoundary: FigErrorBoundary = Object.assign(\n (props: ErrorBoundaryProps) => props.children,\n { $$typeof: FigErrorBoundarySymbol },\n);\n\n/** The suspense. */\nexport const Suspense: FigSuspense = Object.assign(\n (props: SuspenseProps) => props.children,\n { $$typeof: FigSuspenseSymbol },\n);\n\n/** The activity. */\nexport const Activity: FigActivity = Object.assign(\n (props: ActivityProps) => props.children,\n { $$typeof: FigActivitySymbol },\n);\n\n/** The view transition. */\nexport const ViewTransition: FigViewTransition = Object.assign(\n (props: ViewTransitionProps) => props.children,\n { $$typeof: FigViewTransitionSymbol },\n);\n\n/** Creates element. */\nexport function createElement<P extends Props>(\n type: ElementType<P>,\n config?: (P & { key?: Key | null }) | null,\n ...children: FigNode[]\n): FigElement<P> {\n const props = { ...config } as P & {\n children?: FigNode;\n key?: Key | null;\n };\n const key = props.key ?? null;\n delete props.key;\n\n if (children.length === 1) props.children = children[0];\n else if (children.length > 1) props.children = children;\n\n return {\n $$typeof: FigElementSymbol,\n type,\n key,\n props:\n \"mix\" in props && typeof type === \"string\"\n ? resolveHostMix(type, props)\n : props,\n };\n}\n\n/** Checks whether valid element. */\nexport function isValidElement(value: unknown): value is FigElement {\n return hasObjectBrand(value, FigElementSymbol);\n}\n\n/** Creates portal node. */\nexport function createPortalNode<Target>(\n children: FigNode,\n target: Target,\n key: Key | null = null,\n): FigPortal<Target> {\n return { $$typeof: FigPortalSymbol, children, key, target };\n}\n\n/** Checks whether portal. */\nexport function isPortal(value: unknown): value is FigPortal {\n return hasObjectBrand(value, FigPortalSymbol);\n}\n\n/** Client reference. */\nexport function clientReference<P extends Props = Props>(\n options: ClientReferenceOptions<P>,\n): FigClientReference<P> {\n return Object.assign(\n (): never => {\n throw new Error(\n `Client reference \"${options.id}\" cannot be rendered on the server directly.`,\n );\n },\n {\n $$typeof: FigClientReferenceSymbol,\n assets: options.assets,\n id: options.id,\n ssr: options.ssr,\n },\n );\n}\n\n/** Lazy. */\nexport function lazy<T extends ComponentType<any>>(\n load: LazyLoader<T>,\n): ComponentType<ComponentProps<T>> {\n let promise: PromiseLike<T> | null = null;\n let rejected = false;\n\n const Lazy: ComponentType<ComponentProps<T>> = (props) => {\n if (promise === null) {\n rejected = false;\n const next = Promise.resolve(load()).then(\n (value) => value,\n (error) => {\n if (promise === next) rejected = true;\n throw error;\n },\n );\n promise = next;\n }\n\n try {\n return createElement(readPromise(promise), props);\n } catch (error) {\n if (rejected) {\n promise = null;\n rejected = false;\n }\n throw error;\n }\n };\n\n return Lazy;\n}\n\n/** Checks whether client reference. */\nexport function isClientReference(value: unknown): value is FigClientReference {\n return hasFunctionBrand(value, FigClientReferenceSymbol);\n}\n\n/** Checks whether suspense. */\nexport function isSuspense(value: unknown): value is FigSuspense {\n return hasFunctionBrand(value, FigSuspenseSymbol);\n}\n\n/** Checks whether activity. */\nexport function isActivity(value: unknown): value is FigActivity {\n return hasFunctionBrand(value, FigActivitySymbol);\n}\n\n/** Checks whether error boundary. */\nexport function isErrorBoundary(value: unknown): value is FigErrorBoundary {\n return hasFunctionBrand(value, FigErrorBoundarySymbol);\n}\n\n/** Checks whether view transition. */\nexport function isViewTransition(value: unknown): value is FigViewTransition {\n return hasFunctionBrand(value, FigViewTransitionSymbol);\n}\n\n/** Checks whether assets. */\nexport function isAssets(value: unknown): value is FigAssets {\n return hasFunctionBrand(value, FigAssetsSymbol);\n}\n\nfunction hasObjectBrand(value: unknown, brand: symbol): boolean {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"$$typeof\" in value &&\n value.$$typeof === brand\n );\n}\n\nfunction hasFunctionBrand(value: unknown, brand: symbol): boolean {\n return (\n typeof value === \"function\" &&\n \"$$typeof\" in value &&\n value.$$typeof === brand\n );\n}\n"],"mappings":";AAoLA,MAAM,gCAAgC,OAAO,IAAI,uBAAuB;;AAMxE,SAAgB,8BACd,SACA,cACM;CACN,OAAO,eAAe,SAAS,+BAA+B;EAC5D,cAAc;EACd,YAAY;EACZ,OAAO;CACT,CAAC;AACH;;AAGA,SAAgB,wBACd,SACqC;CACrC,OAAQ,QACN;AAEJ;AAEA,MAAM,mCAAmB,IAAI,QAAmC;AAEhE,IAAI,mBAAwC;;AAG5C,SAAgB,wBACd,UAAU,gDACI;CACd,IAAI,qBAAqB,MAAM,MAAM,IAAI,MAAM,OAAO;CACtD,OAAO;AACT;;AAGA,SAAgB,oBACd,OACqB;CACrB,MAAM,gBAAgB;CACtB,mBAAmB;CACnB,OAAO;AACT;;AAGA,SAAgB,sBACd,OACA,KACM;CAKN,IAAI,CAAC,oBAAoB,KAAK,GAAG;CAEjC,IAAI,OAAO,iBAAiB,IAAI,KAAK;CACrC,IAAI,SAAS,KAAA,GAAW;EACtB,OAAO,CAAC;EACR,iBAAiB,IAAI,OAAO,IAAI;CAClC;CAEA,IAAI,KAAK,MAAM,aAAa,oBAAoB,UAAU,GAAG,CAAC,GAAG;CAEjE,KAAK,KAAK,GAAG;AACf;;AAGA,SAAgB,yBACd,OAC+B;CAC/B,IAAI,CAAC,oBAAoB,KAAK,GAAG,OAAO,KAAA;CAExC,MAAM,OAAO,iBAAiB,IAAI,KAAK;CACvC,OAAO,SAAS,KAAA,KAAa,KAAK,WAAW,IAAI,KAAA,IAAY,CAAC,GAAG,IAAI;AACvE;AAEA,SAAS,oBAAoB,GAAoB,G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gB,SAAS,OAAoC;CAC3D,OAAO,iBAAiB,OAAO,eAAe;AAChD;AAEA,SAAS,eAAe,OAAgB,OAAwB;CAC9D,OACE,OAAO,UAAU,YACjB,UAAU,QACV,cAAc,SACd,MAAM,aAAa;AAEvB;AAEA,SAAS,iBAAiB,OAAgB,OAAwB;CAChE,OACE,OAAO,UAAU,cACjB,cAAc,SACd,MAAM,aAAa;AAEvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payload-format-BbsvTG9V.js","names":[],"sources":["../src/payload-format.ts"],"sourcesContent":["import type { FigDataHydrationEntry } from \"./data.ts\";\nimport type { Key } from \"./element.ts\";\nimport type {\n FontResource,\n MetaResource,\n ModulePreloadResource,\n PreconnectResource,\n PreloadResource,\n ScriptResource,\n StylesheetResource,\n TitleResource,\n} from \"./resource.ts\";\n\n// Asset resources represented as descriptor data. Optional fields stay optional\n// on the wire; omitted `undefined` values are part of the payload contract, not\n// a serializer implementation detail. Delivery assets prepare eagerly at row\n// arrival; document metadata stays attached to its owning decoded row until\n// that row commits.\n/** Describes serialized asset resource. */\nexport type SerializedAssetResource =\n | {\n crossorigin?: StylesheetResource[\"crossorigin\"];\n href: string;\n kind: \"stylesheet\";\n media?: string;\n precedence?: string;\n }\n | {\n as: string;\n crossorigin?: PreloadResource[\"crossorigin\"];\n fetchpriority?: PreloadResource[\"fetchpriority\"];\n href?: string;\n imagesizes?: PreloadResource[\"imagesizes\"];\n imagesrcset?: PreloadResource[\"imagesrcset\"];\n kind: \"preload\";\n referrerpolicy?: PreloadResource[\"referrerpolicy\"];\n type?: string;\n }\n | {\n crossorigin?: ModulePreloadResource[\"crossorigin\"];\n fetchpriority?: ModulePreloadResource[\"fetchpriority\"];\n href: string;\n kind: \"modulepreload\";\n }\n | {\n async?: boolean;\n crossorigin?: ScriptResource[\"crossorigin\"];\n defer?: boolean;\n kind: \"script\";\n module?: boolean;\n src: string;\n }\n | {\n crossorigin?: FontResource[\"crossorigin\"];\n fetchpriority?: FontResource[\"fetchpriority\"];\n href: string;\n kind: \"font\";\n type: string;\n }\n | {\n crossorigin?: PreconnectResource[\"crossorigin\"];\n href: string;\n kind: \"preconnect\";\n }\n | {\n kind: \"title\";\n value: TitleResource[\"value\"];\n }\n | {\n charset?: MetaResource[\"charset\"];\n content?: MetaResource[\"content\"];\n \"http-equiv\"?: MetaResource[\"http-equiv\"];\n key?: string;\n kind: \"meta\";\n name?: MetaResource[\"name\"];\n property?: MetaResource[\"property\"];\n };\n\n/** The `error` row value under the server's `onError` contract. */\nexport interface PayloadErrorValue {\n digest?: string;\n message?: string;\n}\n\n/**\n * Semantic payload row before the internal codec turns it into bytes.\n */\nexport type PayloadRow =\n | { for?: number; tag: \"assets\"; value: SerializedAssetResource[] }\n | {\n id: number;\n tag: \"client\";\n value: {\n id: string;\n assets?: SerializedAssetResource[];\n exportName?: string;\n ssr?: true;\n };\n }\n | { tag: \"data\"; value: PayloadDataHydrationEntry[] }\n | { id: number; tag: \"error\"; value: PayloadErrorValue }\n | { id: number; tag: \"model\"; value: PayloadModel };\n\n/**\n * Transport-safe model value used inside internal payload rows. This is an\n * implementation format, not an application data format.\n */\nexport type PayloadModel =\n | null\n | boolean\n | number\n | string\n | PayloadModel[]\n | { [key: string]: PayloadModel }\n | PayloadElementModel\n | PayloadSpecialModel;\n\n/** Describes payload element model. */\nexport type PayloadElementModel = {\n $fig: \"element\";\n id?: number;\n key: Key | null;\n props: PayloadModel;\n type: string | PayloadSpecialModel;\n};\n\n/** Describes payload special model. */\nexport type PayloadSpecialModel =\n | { $fig: \"array\"; id: number; value: PayloadModel[] }\n | { $fig: \"bigint\"; value: string }\n | { $fig: \"client\"; id: number }\n | { $fig: \"date\"; value: string }\n | { $fig: \"fragment\" }\n | { $fig: \"lazy\"; id: number }\n | { $fig: \"map\"; entries: Array<[PayloadModel, PayloadModel]>; id: number }\n | { $fig: \"number\"; value: \"Infinity\" | \"-Infinity\" | \"-0\" | \"NaN\" }\n | { $fig: \"object\"; id?: number; value: Record<string, PayloadModel> }\n | { $fig: \"promise\"; id: number }\n | { $fig: \"ref\"; id: number }\n | { $fig: \"set\"; id: number; values: PayloadModel[] }\n | { $fig: \"symbol\"; key: string }\n | { $fig: \"suspense\" }\n | { $fig: \"undefined\" }\n | { $fig: \"view-transition\" };\n\nexport type PayloadValueSpecialModel = Extract<\n PayloadSpecialModel,\n {\n $fig:\n | \"array\"\n | \"bigint\"\n | \"date\"\n | \"map\"\n | \"number\"\n | \"object\"\n | \"ref\"\n | \"set\"\n | \"symbol\"\n | \"undefined\";\n }\n>;\n\n/** Describes payload data hydration entry. */\nexport type PayloadDataHydrationEntry = Omit<FigDataHydrationEntry, \"value\"> & {\n value: PayloadModel;\n};\n\nexport interface PayloadCodec {\n /**\n * Opaque implementation id, e.g. \"json\" or \"binary\". Fig checks this id at\n * transport boundaries; the encoded byte layout is not a public contract.\n */\n readonly id: string;\n readonly contentType: string;\n /**\n * Creates a streaming row decoder. The decoder calls `onRow` for each\n * complete semantic row. If `onRow` throws, the decoder must propagate that\n * error; when it can already see more complete sibling rows in the same\n * input chunk, it should process those siblings before rethrowing so\n * notifications already implied by earlier rows are not lost.\n */\n createDecoder(onRow: (row: PayloadRow) => void): PayloadRowDecoder;\n encodeRow(row: PayloadRow): Uint8Array;\n}\n\nexport interface PayloadRowDecoder {\n decode(chunk: Uint8Array): void;\n flush(): void;\n}\n\nconst textEncoder = new TextEncoder();\n\n/**\n * Readable development-oriented codec: one JSON payload row per newline.\n */\nexport const jsonPayloadCodec: PayloadCodec = {\n id: \"json\",\n contentType: \"text/x-fig-payload; codec=json; charset=utf-8\",\n createDecoder(onRow) {\n return createJsonPayloadDecoder(onRow);\n },\n encodeRow(row) {\n return textEncoder.encode(`${JSON.stringify(row)}\\n`);\n },\n};\n\nfunction createJsonPayloadDecoder(\n onRow: (row: PayloadRow) => void,\n): PayloadRowDecoder {\n const decoder = new TextDecoder();\n let buffer = \"\";\n let searchStart = 0;\n\n function processBufferedLines(): void {\n let lineStart = 0;\n let firstError: unknown;\n\n for (;;) {\n const newlineIndex = buffer.indexOf(\"\\n\", searchStart);\n if (newlineIndex === -1) {\n searchStart = buffer.length;\n break;\n }\n try {\n processPayloadLine(buffer.slice(lineStart, newlineIndex), onRow);\n } catch (error) {\n firstError ??= error;\n }\n lineStart = newlineIndex + 1;\n searchStart = lineStart;\n }\n\n if (firstError !== undefined) {\n buffer = \"\";\n searchStart = 0;\n throw firstError;\n }\n if (lineStart > 0) {\n buffer = buffer.slice(lineStart);\n searchStart -= lineStart;\n }\n }\n\n return {\n decode(chunk) {\n buffer += decoder.decode(chunk, { stream: true });\n processBufferedLines();\n },\n flush() {\n buffer += decoder.decode();\n if (buffer.length > 0) {\n const line = buffer;\n buffer = \"\";\n searchStart = 0;\n processPayloadLine(line, onRow);\n }\n },\n };\n}\n\nfunction processPayloadLine(\n line: string,\n onRow: (row: PayloadRow) => void,\n): void {\n if (line.length > 0) onRow(JSON.parse(line) as PayloadRow);\n}\n\n/**\n * Extract the codec id from a payload content-type header, or null when the\n * header carries no codec parameter.\n */\nexport function payloadCodecIdFromContentType(\n contentTypeHeader: string,\n): string | null {\n const parts = contentTypeHeader.split(\";\").slice(1);\n for (const part of parts) {\n const [name, rawValue] = part.split(\"=\");\n if (name?.trim().toLowerCase() !== \"codec\") continue;\n const value = rawValue?.trim();\n if (value === undefined || value.length === 0) return null;\n return value.replace(/^\"|\"$/g, \"\");\n }\n return null;\n}\n\n/**\n * Throw when a response content-type declares a codec other than the one this\n * client decodes with. A missing header or codec parameter passes: transports\n * that strip content types stay usable, and mismatches still fail fast when\n * declared.\n */\nexport function assertPayloadCodecMatches(\n codec: PayloadCodec,\n contentTypeHeader: string | null,\n): void {\n if (contentTypeHeader === null) return;\n const received = payloadCodecIdFromContentType(contentTypeHeader);\n if (received === null || received === codec.id) return;\n throw new Error(\n `Payload codec mismatch: producer used \"${received}\" but this client expects \"${codec.id}\".`,\n );\n}\n\n/** Decode an `error` row value into a digest-carrying Error. */\nexport function errorFromPayloadValue(value: PayloadErrorValue): Error & {\n digest?: string;\n} {\n const error = new Error(value.message ?? \"The server render failed.\");\n return value.digest === undefined\n ? error\n : Object.assign(error, { digest: value.digest });\n}\n\n/** Describes payload graph encode context. */\nexport interface PayloadGraphEncodeContext {\n // Ids are dense and monotonic: id = position in `defined` + 1, so rollback\n // is popping the stack. A reverse id→object map would be redundant state.\n defined: object[];\n ids: WeakMap<object, number>;\n}\n\ninterface PayloadGraphDecodeContext {\n decodeChild: (model: PayloadModel) => unknown;\n refs: PayloadDecodeRefs;\n}\n\nfunction createPayloadGraphDecodeContext(): PayloadGraphDecodeContext {\n const refs = new Map<number, unknown>();\n const context: PayloadGraphDecodeContext = {\n decodeChild: (model) => decodeModelValue(model, context),\n refs: {\n define(id, create, fill) {\n const value = create();\n refs.set(id, value);\n fill(value);\n return value;\n },\n read(id) {\n if (!refs.has(id)) {\n throw new Error(`Payload referenced unknown object id ${id}.`);\n }\n return refs.get(id);\n },\n },\n };\n return context;\n}\n\n/** Creates payload graph encode context. */\nexport function createPayloadGraphEncodeContext(): PayloadGraphEncodeContext {\n return { defined: [], ids: new WeakMap() };\n}\n\n/** Checks whether plain payload value. */\nexport function isPlainPayloadValue(value: unknown): boolean {\n return (\n value === null ||\n value === undefined ||\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\" ||\n typeof value === \"bigint\" ||\n typeof value === \"symbol\"\n );\n}\n\n/**\n * Encode ordinary data values into PayloadModel. Server component references\n * such as Fig elements, promises, and client references are handled by the\n * payload renderer before ordinary values reach this helper.\n */\nexport function encodePayloadValue(value: unknown): PayloadModel {\n return encodePayloadValueWithGraph(value, createPayloadGraphEncodeContext());\n}\n\n/** Encodes payload value with graph. */\nexport function encodePayloadValueWithGraph(\n value: unknown,\n graph: PayloadGraphEncodeContext,\n): PayloadModel {\n if (value === null) return null;\n if (value === undefined) return { $fig: \"undefined\" };\n\n if (typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") return encodePayloadNumber(value);\n if (typeof value === \"bigint\") {\n return { $fig: \"bigint\", value: value.toString() };\n }\n if (typeof value === \"symbol\") {\n const key = Symbol.keyFor(value);\n if (key === undefined) {\n throw new Error(\"Only global Symbol.for symbols can be serialized.\");\n }\n return { $fig: \"symbol\", key };\n }\n if (typeof value === \"function\") {\n throw new Error(\"Functions cannot be serialized into the payload.\");\n }\n\n if (Array.isArray(value)) {\n return serializePayloadArray(value, graph, (item) =>\n encodePayloadValueWithGraph(item, graph),\n );\n }\n if (value instanceof Date) {\n const json = value.toJSON();\n if (json === null) {\n throw new Error(\"Invalid Date values cannot be serialized.\");\n }\n return { $fig: \"date\", value: json };\n }\n if (value instanceof Map) {\n return serializePayloadMap(value, graph, ([key, item]) => [\n encodePayloadValueWithGraph(key, graph),\n encodePayloadValueWithGraph(item, graph),\n ]);\n }\n if (value instanceof Set) {\n return serializePayloadSet(value, graph, (item) =>\n encodePayloadValueWithGraph(item, graph),\n );\n }\n\n if (typeof value === \"object\" && value !== null) {\n return serializePayloadPlainObject(value, graph, (child) =>\n encodePayloadValueWithGraph(child, graph),\n );\n }\n\n throw new Error(`Cannot serialize ${typeof value} into the payload.`);\n}\n\n/** Serializes payload map. */\nexport function serializePayloadMap(\n value: Map<unknown, unknown>,\n graph: PayloadGraphEncodeContext,\n encodeEntry: (entry: [unknown, unknown]) => [PayloadModel, PayloadModel],\n): PayloadModel {\n const existing = payloadGraphReference(graph, value);\n if (existing !== null) return existing;\n const id = definePayloadGraphObject(graph, value);\n const entries: Array<[PayloadModel, PayloadModel]> = [];\n for (const entry of value) entries.push(encodeEntry(entry));\n return { $fig: \"map\", id, entries };\n}\n\n/** Serializes payload set. */\nexport function serializePayloadSet(\n value: Set<unknown>,\n graph: PayloadGraphEncodeContext,\n encodeItem: (value: unknown) => PayloadModel,\n): PayloadModel {\n const existing = payloadGraphReference(graph, value);\n if (existing !== null) return existing;\n const id = definePayloadGraphObject(graph, value);\n const values: PayloadModel[] = [];\n for (const item of value) values.push(encodeItem(item));\n return { $fig: \"set\", id, values };\n}\n\nfunction payloadGraphReference(\n graph: PayloadGraphEncodeContext,\n value: object,\n): PayloadSpecialModel | null {\n const id = graph.ids.get(value);\n return id === undefined ? null : { $fig: \"ref\", id };\n}\n\nfunction definePayloadGraphObject(\n graph: PayloadGraphEncodeContext,\n value: object,\n): number {\n graph.defined.push(value);\n const id = graph.defined.length;\n graph.ids.set(value, id);\n return id;\n}\n\n/** Checkpoint payload graph. */\nexport function checkpointPayloadGraph(\n graph: PayloadGraphEncodeContext,\n): number {\n return graph.defined.length;\n}\n\n/** Rollback payload graph. */\nexport function rollbackPayloadGraph(\n graph: PayloadGraphEncodeContext,\n checkpoint: number,\n): void {\n while (graph.defined.length > checkpoint) {\n graph.ids.delete(graph.defined.pop() as object);\n }\n}\n\n/** Define payload graph element. */\nexport function definePayloadGraphElement(\n graph: PayloadGraphEncodeContext,\n value: object,\n): number | PayloadSpecialModel {\n const existing = payloadGraphReference(graph, value);\n if (existing !== null) return existing;\n return definePayloadGraphObject(graph, value);\n}\n\n/** Serializes payload array. */\nexport function serializePayloadArray<T>(\n value: readonly T[],\n graph: PayloadGraphEncodeContext,\n encodeChild: (value: T) => PayloadModel,\n): PayloadModel {\n const existing = payloadGraphReference(graph, value);\n if (existing !== null) return existing;\n const id = definePayloadGraphObject(graph, value);\n return { $fig: \"array\", id, value: value.map(encodeChild) };\n}\n\n/** Serializes payload plain object. */\nexport function serializePayloadPlainObject(\n value: object,\n graph: PayloadGraphEncodeContext,\n encodeChild: (value: unknown) => PayloadModel,\n): PayloadModel {\n const existing = payloadGraphReference(graph, value);\n if (existing !== null) return existing;\n const id = definePayloadGraphObject(graph, value);\n return {\n $fig: \"object\",\n id,\n value: encodePayloadRecord(plainPayloadObject(value), encodeChild),\n };\n}\n\nfunction plainPayloadObject(value: object): Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new Error(\n `Cannot serialize ${prototype?.constructor?.name ?? \"object\"} into the payload.`,\n );\n }\n return value as Record<string, unknown>;\n}\n\nfunction encodePayloadRecord(\n record: Record<string, unknown>,\n encodeChild: (value: unknown) => PayloadModel,\n): Record<string, PayloadModel> {\n const encoded: Record<string, PayloadModel> = {};\n for (const [name, child] of Object.entries(record)) {\n encoded[name] = encodeChild(child);\n }\n return encoded;\n}\n\nfunction encodePayloadNumber(value: number): number | PayloadSpecialModel {\n if (Number.isNaN(value)) return { $fig: \"number\", value: \"NaN\" };\n if (value === Infinity) return { $fig: \"number\", value: \"Infinity\" };\n if (value === -Infinity) return { $fig: \"number\", value: \"-Infinity\" };\n if (Object.is(value, -0)) return { $fig: \"number\", value: \"-0\" };\n return value;\n}\n\n/** Decode values produced by encodePayloadValue. */\nexport function decodePayloadValue(model: PayloadModel): unknown {\n return decodeModelValue(model, createPayloadGraphDecodeContext());\n}\n\nfunction decodeModelValue(\n model: PayloadModel,\n graph: PayloadGraphDecodeContext,\n): unknown {\n if (model === null) return null;\n if (Array.isArray(model))\n return model.map((item) => decodeModelValue(item, graph));\n if (typeof model !== \"object\") return model;\n\n if (isPayloadValueSpecialModel(model)) {\n return decodePayloadValueTag(model, graph.refs, graph.decodeChild);\n }\n\n return decodePayloadRecord(model, graph.decodeChild);\n}\n\nexport function isPayloadValueSpecialModel(\n model: object,\n): model is PayloadValueSpecialModel {\n if (!(\"$fig\" in model)) return false;\n const tag = model.$fig;\n return (\n tag === \"bigint\" ||\n tag === \"array\" ||\n tag === \"date\" ||\n tag === \"map\" ||\n tag === \"number\" ||\n tag === \"object\" ||\n tag === \"ref\" ||\n tag === \"set\" ||\n tag === \"symbol\" ||\n tag === \"undefined\"\n );\n}\n\n// The ref-store seam shared by the two decode entry points: the value codec\n// registers into a per-call refs map, while the stream decoder registers into\n// its request-wide chunk-adjacent store (with rollback on failed fills).\nexport interface PayloadDecodeRefs {\n define<T>(id: number, create: () => T, fill: (value: T) => void): T;\n read(id: number): unknown;\n}\n\nexport function decodePayloadValueTag(\n model: PayloadValueSpecialModel,\n refs: PayloadDecodeRefs,\n decodeChild: (model: PayloadModel) => unknown,\n): unknown {\n switch (model.$fig) {\n case \"array\":\n return refs.define<unknown[]>(\n model.id,\n () => [],\n (value) => {\n for (const item of model.value) value.push(decodeChild(item));\n },\n );\n case \"bigint\":\n return BigInt(model.value);\n case \"date\":\n return new Date(model.value);\n case \"map\":\n return refs.define(\n model.id,\n () => new Map<unknown, unknown>(),\n (value) => {\n for (const [key, item] of model.entries) {\n value.set(decodeChild(key), decodeChild(item));\n }\n },\n );\n case \"number\":\n return decodePayloadNumber(model.value);\n case \"object\": {\n if (model.id === undefined) {\n return decodePayloadRecord(model.value, decodeChild);\n }\n return refs.define(\n model.id,\n () => ({}),\n (value) => {\n for (const [name, child] of Object.entries(model.value)) {\n definePayloadProperty(value, name, decodeChild(child));\n }\n },\n );\n }\n case \"ref\":\n return refs.read(model.id);\n case \"set\":\n return refs.define(\n model.id,\n () => new Set<unknown>(),\n (value) => {\n for (const item of model.values) value.add(decodeChild(item));\n },\n );\n case \"symbol\":\n return Symbol.for(model.key);\n case \"undefined\":\n return undefined;\n }\n}\n\nexport function decodePayloadRecord(\n value: Record<string, PayloadModel>,\n decodeChild: (model: PayloadModel) => unknown,\n): Record<string, unknown> {\n const decoded: Record<string, unknown> = {};\n for (const [name, child] of Object.entries(value)) {\n definePayloadProperty(decoded, name, decodeChild(child));\n }\n return decoded;\n}\n\n// \"__proto__\" must go through defineProperty so a hostile payload key defines\n// an own property instead of mutating the prototype chain via the setter\n// path; every other key gets the identical own data property from plain\n// assignment at a fraction of the cost (this is the decode inner loop).\nexport function definePayloadProperty(\n target: Record<string, unknown>,\n name: string,\n value: unknown,\n): void {\n if (name === \"__proto__\") {\n Object.defineProperty(target, name, {\n configurable: true,\n enumerable: true,\n value,\n writable: true,\n });\n return;\n }\n target[name] = value;\n}\n\nexport function decodePayloadNumber(\n value: \"Infinity\" | \"-Infinity\" | \"-0\" | \"NaN\",\n): number {\n switch (value) {\n case \"Infinity\":\n return Infinity;\n case \"-Infinity\":\n return -Infinity;\n case \"-0\":\n return -0;\n case \"NaN\":\n return NaN;\n }\n}\n\n/** Encodes payload data entries. */\nexport function encodePayloadDataEntries(\n entries: readonly FigDataHydrationEntry[],\n): PayloadDataHydrationEntry[] {\n const graph = createPayloadGraphEncodeContext();\n return entries.map((entry) => ({\n ...entry,\n value: encodePayloadValueWithGraph(entry.value, graph),\n }));\n}\n\n/** Decodes payload data entries. */\nexport function decodePayloadDataEntries(\n entries: readonly PayloadDataHydrationEntry[],\n): FigDataHydrationEntry[] {\n const graph = createPayloadGraphDecodeContext();\n return entries.map((entry) => ({\n ...entry,\n value: decodeModelValue(entry.value, graph),\n }));\n}\n\n/** Checks whether payload special model. */\nexport function isPayloadSpecialModel(\n model: object,\n): model is PayloadElementModel | PayloadSpecialModel {\n if (!(\"$fig\" in model)) return false;\n\n switch (model.$fig) {\n case \"array\":\n case \"bigint\":\n case \"client\":\n case \"date\":\n case \"element\":\n case \"fragment\":\n case \"lazy\":\n case \"map\":\n case \"number\":\n case \"object\":\n case \"promise\":\n case \"ref\":\n case \"set\":\n case \"suspense\":\n case \"symbol\":\n case \"undefined\":\n case \"view-transition\":\n return true;\n default:\n return false;\n }\n}\n"],"mappings":";AA8LA,MAAM,cAAc,IAAI,YAAY;;;;AAKpC,MAAa,mBAAiC;CAC5C,IAAI;CACJ,aAAa;CACb,cAAc,OAAO;EACnB,OAAO,yBAAyB,KAAK;CACvC;CACA,UAAU,KAAK;EACb,OAAO,YAAY,OAAO,GAAG,KAAK,UAAU,GAAG,EAAE,GAAG;CACtD;AACF;AAEA,SAAS,yBACP,OACmB;CACnB,MAAM,UAAU,IAAI,YAAY;CAChC,IAAI,SAAS;CACb,IAAI,cAAc;CAElB,SAAS,uBAA6B;EACpC,IAAI,YAAY;EAChB,IAAI;EAEJ,SAAS;GACP,MAAM,eAAe,OAAO,QAAQ,MAAM,WAAW;GACrD,IAAI,iBAA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,sBACd,QACA,MACA,OACM;CACN,IAAI,SAAS,aAAa;EACxB,OAAO,eAAe,QAAQ,MAAM;GAClC,cAAc;GACd,YAAY;GACZ;GACA,UAAU;EACZ,CAAC;EACD;CACF;CACA,OAAO,QAAQ;AACjB;AAEA,SAAgB,oBACd,OACQ;CACR,QAAQ,OAAR;EACE,KAAK,YACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,KAAK,OACH,OAAO;CACX;AACF;;AAGA,SAAgB,yBACd,SAC6B;CAC7B,MAAM,QAAQ,gCAAgC;CAC9C,OAAO,QAAQ,KAAK,WAAW;EAC7B,GAAG;EACH,OAAO,4BAA4B,MAAM,OAAO,KAAK;CACvD,EAAE;AACJ;;AAGA,SAAgB,yBACd,SACyB;CACzB,MAAM,QAAQ,gCAAgC;CAC9C,OAAO,QAAQ,KAAK,WAAW;EAC7B,GAAG;EACH,OAAO,iBAAiB,MAAM,OAAO,KAAK;CAC5C,EAAE;AACJ;;AAGA,SAAgB,sBACd,OACoD;CACpD,IAAI,EAAE,UAAU,QAAQ,OAAO;CAE/B,QAAQ,MAAM,MAAd;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,mBACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-BJxS62H2.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 thenable.then(\n (value) => {\n record = { status: \"fulfilled\", value };\n thenableRecords.set(key, record);\n },\n (reason: unknown) => {\n record = { reason, status: \"rejected\" };\n thenableRecords.set(key, record);\n },\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","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 | FontResource\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 font resource. */\nexport interface FontResource extends ResourceBase {\n crossorigin?: CrossOrigin;\n fetchpriority?: FetchPriority;\n href: string;\n kind: \"font\";\n type: 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: Omit<FontResource, \"href\" | \"kind\" | \"type\"> = {},\n): FontResource {\n return { ...options, href, kind: \"font\", type };\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 \"font\":\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 // A font is serialized and inserted as <link rel=\"preload\" as=\"font\">, so an\n // explicit key must also live in the preload key space.\n if (resource.kind === \"font\" && resource.key !== undefined)\n return `preload:${resource.key}`;\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 \"font\":\n // A font is loaded as <link rel=\"preload\" as=\"font\">, so it must share the\n // preload-font key space across every package (SSR registry, payload record,\n // client insert) — otherwise a font() and an equivalent preload(href,\n // \"font\") would key separately and fail to dedupe.\n return `preload:font:${resource.href}`;\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 \"font\":\n props.rel = \"preload\";\n props.href = resource.href;\n props.as = \"font\";\n if (resource.key !== undefined) {\n props[\"data-fig-resource-key\"] = resource.key;\n }\n props.type = resource.type;\n props.crossorigin = resource.crossorigin ?? \"anonymous\";\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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OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO,OAAO,IAAI;CAC5E,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO,KAAK,IAAI,iBAAiB,CAAC,CAAC,KAAK,EAAE;CACnE,IAAI,WAAW,IAAI,GAAG,OAAO,kBAAkB,aAAa,IAAI,CAAC;CAEjE,MAAM,IAAI,MAAM,qDAAqD;AACvE;AAEA,SAAS,gBAAgB,UAAgC;CACvD,IAAI,SAAS,YAAY,KAAA,GAAW,OAAO,gBAAgB,SAAS;CACpE,IAAI,SAAS,SAAS,KAAA,GAAW,OAAO,aAAa,SAAS;CAC9D,IAAI,SAAS,aAAa,KAAA,GACxB,OAAO,iBAAiB,SAAS;CACnC,OAAO,mBAAmB,SAAS;AACrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transition-WvgFiYNY.js","names":[],"sources":["../src/context.ts","../src/data-store.ts","../src/transition.ts"],"sourcesContent":["import type { FigNode } from \"./element.ts\";\n\n/** Describes Fig context. */\nexport interface FigContext<T> {\n (props: { value: T; children?: FigNode }): FigNode;\n readonly $$typeof: symbol;\n readonly defaultValue: T;\n}\n\n/** The Fig context symbol. */\nexport const FigContextSymbol = Symbol.for(\"fig.context\");\n\n/** Creates context. */\nexport function createContext<T>(defaultValue: T): FigContext<T> {\n return Object.assign(\n (props: { value: T; children?: FigNode }) => props.children,\n {\n $$typeof: FigContextSymbol,\n defaultValue,\n },\n );\n}\n\n/** Checks whether context. */\nexport function isContext(value: unknown): value is FigContext<unknown> {\n return (\n typeof value === \"function\" &&\n \"$$typeof\" in value &&\n value.$$typeof === FigContextSymbol\n );\n}\n","import {\n type DataRefreshResult,\n type DataResource,\n type DataResourceKey,\n type DataResourceKeyInput,\n type DataResourceLoadContext,\n type DataResourceLoader,\n type DataStoreEntrySnapshot,\n dataResourceKeysForError,\n defineLoadContextCapabilities,\n type FigDataEntryStatus,\n type FigDataHydrationEntry,\n type FigDataStore,\n type FigDataStoreController,\n type FigDataStoreFactory,\n type FigDataStoreHandle,\n type FigDataStoreHost,\n type FigDataStoreOptions,\n isAttributableError,\n markDataResourceError,\n resolveCurrentDataStore,\n setCurrentDataStore,\n} from \"./data.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\n/** Describes data resource options. */\nexport interface DataResourceOptions<TArgs extends unknown[], TValue> {\n key: (...args: TArgs) => DataResourceKey;\n debugArgs?: (...args: TArgs) => DataResourceKeyInput;\n load?: DataResourceLoader<TArgs, TValue>;\n}\n\n/** Describes data store host. */\nexport interface DataStoreHost<Owner extends object, Lane> {\n getLane(): Lane;\n inactiveRetentionMs?: number;\n onEntryChange?: (entry: DataStoreEntrySnapshot) => void;\n onEntryEvict?: (entry: DataStoreEntrySnapshot) => void;\n partition?: DataResourceKeyInput;\n preloadRetentionMs?: number;\n schedule(owner: Owner, lane: Lane): void;\n}\n\n/** Describes data store. */\nexport interface DataStore<\n Owner extends object = object,\n Lane = unknown,\n> extends FigDataStore {\n readonly host: DataStoreHost<Owner, Lane>;\n}\n\ninterface Entry<Owner extends object, Lane> {\n canonicalKey: string;\n // The in-flight load's controller (null when no load is pending).\n controller: AbortController | null;\n // The authoritative generation's controller — the load whose value the\n // entry holds. Deliberately retained after that loader settles: the\n // signal's lifetime is the generation's authority, not the pending\n // promise's, so loaders that keep streaming into their value (payload\n // decodes filling holes) learn when a SUCCESSOR becomes authoritative, a\n // server push hydrates over them, the entry evicts, or the store is\n // disposed. A superseding load that starts does not abort it — a visible\n // stale value keeps streaming through the refresh window, and a failed\n // refresh leaves it fully alive.\n valueController: AbortController | null;\n // Errors rejected by streamed holes inside the authoritative fulfilled\n // value. Invalidating one retires that broken value instead of serving it\n // stale into a freshly remounted ErrorBoundary.\n valueErrors: WeakSet<object>;\n // Count of ensureData calls currently awaiting this entry's load. A\n // retainer like a subscriber or the preload timer: an awaited ensure must\n // not be evicted-and-aborted out from under its caller mid-load.\n ensureRetainers: number;\n error: unknown;\n fingerprint: string | null;\n generation: number;\n invalidationVersion: number;\n inactiveTimer: TimerHandle | null;\n key: DataResourceKey;\n lane: Lane | null;\n pending: PendingResult<unknown> | null;\n preloadTimer: TimerHandle | null;\n refreshError: unknown;\n resource: DataResource<unknown[], unknown> | null;\n stale: boolean;\n status: FigDataEntryStatus;\n storeKey: string;\n subscribers: Set<Owner>;\n value: unknown;\n}\n\ninterface PendingResult<T> {\n promise: Promise<DataRefreshResult<T>>;\n resolve: (result: DataRefreshResult<T>) => void;\n}\n\ninterface NormalizedKey {\n canonical: string;\n key: DataResourceKey;\n}\n\ninterface EncodePath {\n root: string;\n segments: Array<string | number>;\n}\n\ninterface LoadOptions<Lane> {\n lane: Lane;\n refresh: boolean;\n}\n\n// Why an in-flight load was aborted: \"superseded\" by a newer load, the store was\n// \"store-disposed\", or the entry was \"evicted\" from a live store because nothing\n// retained it (retention window elapsed, or last subscriber released).\ntype AbortReason = \"superseded\" | \"store-disposed\" | \"evicted\";\n\nconst DataResourceSymbol = Symbol.for(\"fig.data-resource\");\nconst DataStoreFactorySymbol = Symbol.for(\"fig.data-store-factory\");\nconst DataStoreControllerSymbol = Symbol.for(\"fig.data-store-controller\");\nconst DEFAULT_INACTIVE_RETENTION_MS = 5 * 60 * 1000;\nconst DEFAULT_PRELOAD_RETENTION_MS = 30 * 1000;\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\ntype TimerHandle = ReturnType<typeof setTimeout>;\n\nconst dataStoreFactory: FigDataStoreFactory = createRendererDataStore;\n\n/** Data resource. */\nexport function dataResource<TArgs extends unknown[], TValue>(\n options: DataResourceOptions<TArgs, TValue>,\n): DataResource<TArgs, TValue> {\n const resource = {\n $$typeof: DataResourceSymbol,\n [DataStoreFactorySymbol]: dataStoreFactory,\n debugArgs: options.debugArgs,\n key: options.key,\n load: options.load,\n };\n return resource;\n}\n\n/** Ensures data. */\nexport function ensureData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): Promise<TValue> {\n return resolveDataMutationStore(\"ensureData\").ensureData(resource, ...args);\n}\n\n/** Invalidates data. */\nexport function invalidateData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): void {\n resolveDataMutationStore(\"invalidateData\").invalidateData(resource, ...args);\n}\n\n/** Invalidates data error. */\nexport function invalidateDataError(error: unknown): boolean {\n return resolveDataMutationStore(\"invalidateDataError\").invalidateDataError(\n error,\n );\n}\n\n/** Invalidates data key. */\nexport function invalidateDataKey(key: DataResourceKey): void {\n resolveDataMutationStore(\"invalidateDataKey\").invalidateDataKey(key);\n}\n\n/** Invalidates data prefix. */\nexport function invalidateDataPrefix(prefix: DataResourceKey): void {\n resolveDataMutationStore(\"invalidateDataPrefix\").invalidateDataPrefix(prefix);\n}\n\n/** Refreshes data. */\nexport function refreshData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): Promise<DataRefreshResult<TValue>> {\n return resolveDataMutationStore(\"refreshData\").refreshData(resource, ...args);\n}\n\n// Captures the ambient store as an explicit handle. Call it synchronously\n// wherever Fig is executing — render, event handlers, actions, effects — and\n// keep the reference: unlike the free functions above, the handle's methods\n// still work after an `await`, where the ambient slot is gone.\n/** Reads data store. */\nexport function readDataStore(): FigDataStoreHandle {\n return resolveCurrentDataStore(\n \"readDataStore() must be called synchronously while Fig is executing — \" +\n \"during render, an event handler, an action, or an effect. Capture \" +\n \"the handle there and use it after awaits.\",\n );\n}\n\ninterface DataStoreControllerState {\n host: FigDataStoreHost | null;\n}\n\n/** Creates data store. */\nexport function createDataStore(\n options: FigDataStoreOptions = {},\n): FigDataStoreController {\n const state: DataStoreControllerState = { host: null };\n const store = createRendererDataStore<object, unknown>({\n getLane: () => (state.host === null ? null : state.host.getLane()),\n partition: options.partition,\n schedule: (owner, lane) => state.host?.schedule(owner, lane),\n });\n Object.defineProperty(store, DataStoreControllerSymbol, { value: state });\n if (options.initialData !== undefined) store.hydrate(options.initialData);\n return store;\n}\n\n/** Checks whether data store controller. */\nexport function isDataStoreController(\n value: unknown,\n): value is FigDataStoreController {\n return (\n (typeof value === \"object\" || typeof value === \"function\") &&\n value !== null &&\n Object.hasOwn(value, DataStoreControllerSymbol)\n );\n}\n\n/** Attach data store. */\nexport function attachDataStore(\n controller: FigDataStoreController,\n host: FigDataStoreHost,\n initialData?: readonly FigDataHydrationEntry[],\n): FigDataStore {\n if (host.partition !== undefined || initialData !== undefined) {\n throw new Error(\n \"Pass partition and initialData to createDataStore(), not the renderer, when adopting a data store.\",\n );\n }\n const state = (\n controller as FigDataStoreController &\n Record<symbol, DataStoreControllerState | undefined>\n )[DataStoreControllerSymbol];\n if (state === undefined) {\n throw new Error(\"dataStore must be created with createDataStore().\");\n }\n if (state.host !== null) {\n throw new Error(\"A data store can only be adopted by one Fig renderer.\");\n }\n state.host = host;\n return controller as FigDataStore;\n}\n\nfunction resolveDataMutationStore(name: string): FigDataStore {\n return resolveCurrentDataStore(\n `${name}() must be called synchronously while Fig is executing — ` +\n \"during render, an event handler, an action, or an effect. Capture \" +\n \"readDataStore() (or root.data) synchronously and call the handle instead.\",\n );\n}\n\n/** Creates renderer data store. */\nexport function createRendererDataStore<Owner extends object, Lane>(\n host: DataStoreHost<Owner, Lane>,\n): DataStore<Owner, Lane> {\n return new DefaultDataStore(host);\n}\n\n/** Normalizes data resource key. */\nexport function normalizeDataResourceKey(key: DataResourceKey): string {\n return normalizeKey(key).canonical;\n}\n\nclass DefaultDataStore<Owner extends object, Lane> implements DataStore<\n Owner,\n Lane\n> {\n private readonly entries = new Map<string, Entry<Owner, Lane>>();\n private readonly inactiveRetentionMs: number;\n private readonly ownerKeys = new WeakMap<object, Set<string>>();\n private readonly pendingOwnerKeys = new WeakMap<object, Set<string>>();\n private readonly partitionKey: string;\n private readonly preloadRetentionMs: number;\n private disposed = false;\n\n constructor(readonly host: DataStoreHost<Owner, Lane>) {\n this.inactiveRetentionMs =\n host.inactiveRetentionMs ?? DEFAULT_INACTIVE_RETENTION_MS;\n this.partitionKey =\n host.partition === undefined\n ? \"\"\n : encodeValue(host.partition, createEncodePath(\"partition\"));\n this.preloadRetentionMs =\n host.preloadRetentionMs ?? DEFAULT_PRELOAD_RETENTION_MS;\n }\n\n commitDataDependencies(owner: Owner, previousOwner: object | null): void {\n const nextKeys = this.pendingOwnerKeys.get(owner) ?? null;\n const ownerKeys = this.ownerKeys.get(owner) ?? null;\n const previousOwnerKeys =\n previousOwner === null\n ? null\n : (this.ownerKeys.get(previousOwner) ?? null);\n this.pendingOwnerKeys.delete(owner);\n\n if (\n (nextKeys === null || nextKeys.size === 0) &&\n ownerKeys === null &&\n previousOwnerKeys === null\n ) {\n return;\n }\n\n // Capture the entries this fiber's generations subscribed to before the\n // delete, then abort any that end up with no retainer once the new owner has\n // re-subscribed. Keys the owner still reads keep at least one subscriber, so\n // only genuinely dropped keys are orphaned.\n let orphanCandidates: Set<Entry<Owner, Lane>> | null = null;\n orphanCandidates = this.collectSubscribedEntries(\n ownerKeys,\n orphanCandidates,\n );\n orphanCandidates = this.collectSubscribedEntries(\n previousOwnerKeys,\n orphanCandidates,\n );\n\n this.deleteDataOwner(owner, nextKeys);\n if (previousOwner !== null) this.deleteDataOwner(previousOwner, nextKeys);\n\n if (nextKeys !== null && nextKeys.size > 0) {\n this.ownerKeys.set(owner, nextKeys);\n\n for (const key of nextKeys) {\n const entry = this.entries.get(key);\n if (entry !== undefined) {\n this.clearInactiveTimer(entry);\n entry.subscribers.add(owner);\n this.notifyEntryChange(entry);\n }\n }\n }\n\n if (orphanCandidates !== null) {\n for (const entry of orphanCandidates) this.abortOrphanedLoad(entry);\n }\n }\n\n releaseDataOwner(owner: object): void {\n // The genuine-deletion path (fiber unmount). Unlike deleteDataOwner, which\n // is also used for transient commit churn, this aborts in-flight loads left\n // with no retainer so an unmounted subtree does not keep fetching.\n const orphanCandidates = this.collectSubscribedEntries(\n this.ownerKeys.get(owner) ?? null,\n null,\n );\n this.deleteDataOwner(owner);\n if (orphanCandidates !== null) {\n for (const entry of orphanCandidates) this.abortOrphanedLoad(entry);\n }\n }\n\n resetDataDependencies(owner: object): void {\n // Reads accumulate into pendingOwnerKeys as a render runs. A render attempt\n // can be abandoned before commit (suspense retry, concurrent interruption,\n // the strict shadow pass), and the work-in-progress fiber object is reused\n // across attempts, so the keys must be cleared at the start of each render\n // or stale dependencies from a discarded attempt would be committed.\n this.pendingOwnerKeys.delete(owner);\n }\n\n deleteDataOwner(\n owner: object,\n retainedKeys: ReadonlySet<string> | null = null,\n ): void {\n this.pendingOwnerKeys.delete(owner);\n const keys = this.ownerKeys.get(owner);\n if (keys === undefined) return;\n\n this.ownerKeys.delete(owner);\n for (const key of keys) {\n const entry = this.entries.get(key);\n if (entry === undefined) continue;\n\n entry.subscribers.delete(owner as Owner);\n this.notifyEntryChange(entry);\n if (retainedKeys?.has(key) !== true) this.scheduleInactiveCleanup(entry);\n }\n }\n\n private collectSubscribedEntries(\n keys: ReadonlySet<string> | null,\n into: Set<Entry<Owner, Lane>> | null,\n ): Set<Entry<Owner, Lane>> | null {\n if (keys === null) return into;\n\n for (const key of keys) {\n const entry = this.entries.get(key);\n if (entry !== undefined) {\n into ??= new Set();\n into.add(entry);\n }\n }\n\n return into;\n }\n\n private abortOrphanedLoad(entry: Entry<Owner, Lane>): void {\n // Only a value-less in-flight load (a cache-miss \"pending\" entry) with no\n // committed subscriber and no preload retainer is safe to drop: it has no\n // value to lose, and any reader of such a key suspends rather than commits,\n // so it cannot be handed off to a sibling mid-commit. Value-bearing entries\n // are left alone — a \"refreshing\" entry still serves a usable value, and its\n // refresh settles into the normal inactive-retention path. Evicting those\n // would discard a live value or strand a sibling that read it without\n // suspending.\n if (this.entries.get(entry.storeKey) !== entry) return;\n if (\n entry.subscribers.size > 0 ||\n entry.preloadTimer !== null ||\n entry.ensureRetainers > 0 ||\n entry.pending === null ||\n entryHasValue(entry)\n ) {\n return;\n }\n\n this.evictEntry(entry, \"evicted\");\n }\n\n dispose(): void {\n this.disposed = true;\n\n for (const entry of this.entries.values()) {\n this.clearInactiveTimer(entry);\n this.clearPreloadTimer(entry);\n this.abortEntryGenerations(entry, \"store-disposed\");\n this.notifyEntryChange(entry);\n }\n }\n\n hydrate(entries: readonly FigDataHydrationEntry[]): void {\n if (this.disposed) return;\n\n for (const hydrated of entries) {\n const normalized = normalizeKey(hydrated.key);\n const storeKey = this.storeKey(normalized.canonical);\n const current = this.entries.get(storeKey);\n\n if (current !== undefined) {\n this.hydrateEntry(current, normalized.key, hydrated.value);\n this.publish(current);\n continue;\n }\n\n const entry = this.createEntry(\n normalized,\n storeKey,\n null,\n null,\n \"fulfilled\",\n hydrated.value,\n );\n this.entries.set(storeKey, entry);\n this.notifyEntryChange(entry);\n }\n }\n\n snapshot(): FigDataHydrationEntry[] {\n const entries: FigDataHydrationEntry[] = [];\n\n for (const entry of this.entries.values()) {\n if (entryHasValue(entry))\n entries.push({ key: entry.key, value: entry.value });\n }\n\n return entries;\n }\n\n inspectDataEntries(): DataStoreEntrySnapshot[] {\n return Array.from(this.entries.values(), (entry) =>\n this.snapshotEntry(entry),\n );\n }\n\n inspectDataDependencyCanonicalKeys(owner: object): string[] {\n // Inspection surface only (devtools snapshots are dev-gated); returns\n // empty in prod even though ownerKeys is populated there.\n if (!__DEV__) return [];\n\n const keys = this.ownerKeys.get(owner);\n if (keys === undefined) return [];\n\n const dependencies: string[] = [];\n for (const key of keys) {\n const entry = this.entries.get(key);\n if (entry !== undefined) dependencies.push(entry.canonicalKey);\n }\n return dependencies;\n }\n\n invalidateData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): void {\n if (this.disposed) return;\n\n const entry = this.entryFor(resource, args, false);\n if (entry === null) return;\n\n this.invalidateEntry(entry, this.host.getLane());\n }\n\n invalidateDataError(error: unknown): boolean {\n if (this.disposed) return false;\n\n const keys = dataResourceKeysForError(error);\n if (keys === undefined || keys.length === 0) return false;\n\n const entries: Entry<Owner, Lane>[] = [];\n for (const key of keys) {\n const entry = this.entryForKey(key);\n if (entry !== null) entries.push(entry);\n }\n\n this.invalidateEntries(entries, error);\n return true;\n }\n\n invalidateDataKey(key: DataResourceKey): void {\n if (this.disposed) return;\n\n const entry = this.entryForKey(key);\n if (entry === null) return;\n\n this.invalidateEntry(entry, this.host.getLane());\n }\n\n invalidateDataPrefix(prefix: DataResourceKey): void {\n if (this.disposed) return;\n\n const prefixCanonical = normalizeKey(prefix).canonical;\n const entries: Entry<Owner, Lane>[] = [];\n for (const entry of this.entries.values()) {\n if (canonicalKeyStartsWith(entry.canonicalKey, prefixCanonical)) {\n entries.push(entry);\n }\n }\n\n this.invalidateEntries(entries);\n }\n\n async ensureData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): Promise<TValue> {\n for (;;) {\n if (this.disposed) {\n throw new Error(\n \"ensureData() requires a live data store; this store was disposed.\",\n );\n }\n\n const entry = this.entryFor(resource, args, true);\n this.clearInactiveTimer(entry);\n this.retainPreload(entry);\n\n if (entryHasValue(entry)) {\n this.revalidateIfStale(entry, resource, args);\n return entry.value as TValue;\n }\n\n if (entry.status === \"rejected\") throwDataResourceError(entry);\n\n entry.ensureRetainers += 1;\n try {\n if (entry.pending !== null) {\n await entry.pending.promise;\n } else {\n await this.startLoad(entry, resource, args, {\n lane: this.host.getLane(),\n refresh: false,\n });\n }\n } finally {\n entry.ensureRetainers -= 1;\n // Hand retention back to the normal preload window so a reader\n // (the route component about to render) can still claim the entry.\n if (this.entries.get(entry.storeKey) === entry) {\n this.retainPreload(entry);\n }\n }\n // Loop and re-inspect the entry rather than trusting this load's\n // result: a superseding load, a server hydration, or an eviction may\n // have changed the authoritative state while we awaited.\n }\n }\n\n preloadData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): void {\n if (this.disposed || resource.load === undefined) return;\n\n const entry = this.entryFor(resource, args, true);\n this.clearInactiveTimer(entry);\n this.retainPreload(entry);\n if (entry.pending !== null) return;\n if (entry.status === \"fulfilled\" && !entry.stale) return;\n\n void this.startLoad(entry, resource, args, {\n lane: this.host.getLane(),\n refresh: entry.status === \"fulfilled\",\n });\n }\n\n readData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n owner: Owner,\n ): TValue {\n const entry = this.entryFor(resource, args, true);\n this.clearInactiveTimer(entry);\n this.clearPreloadTimer(entry);\n this.addOwnerKey(owner, entry.storeKey);\n this.revalidateIfStale(entry, resource, args);\n\n if (entry.status === \"pending\" && entry.pending === null) {\n void this.startLoad(entry, resource, args, {\n lane: this.host.getLane(),\n refresh: false,\n });\n }\n\n return this.readCurrentValue(entry);\n }\n\n refreshData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): Promise<DataRefreshResult<TValue>> {\n if (this.disposed) {\n return Promise.resolve({\n reason: \"store-disposed\",\n staleValue: undefined,\n status: \"aborted\",\n });\n }\n\n if (resource.load === undefined) {\n const entry = this.entryFor(resource, args, false);\n if (entry === null) {\n return Promise.resolve(unsupportedRefreshResult<TValue>());\n }\n\n this.clearInactiveTimer(entry);\n return Promise.resolve(unsupportedRefreshResult<TValue>(entry));\n }\n\n const entry = this.entryFor(resource, args, true);\n this.clearInactiveTimer(entry);\n\n if (entry.pending !== null && entry.status !== \"refreshing\") {\n return entry.pending.promise as Promise<DataRefreshResult<TValue>>;\n }\n\n return this.startLoad(entry, resource, args, {\n lane: this.host.getLane(),\n refresh: entry.status === \"fulfilled\" || entry.status === \"refreshing\",\n });\n }\n\n run<T>(callback: () => T): T {\n const previousStore = setCurrentDataStore(this);\n try {\n return callback();\n } finally {\n setCurrentDataStore(previousStore);\n }\n }\n\n private addOwnerKey(owner: Owner, key: string): void {\n let keys = this.pendingOwnerKeys.get(owner);\n if (keys === undefined) {\n keys = new Set();\n this.pendingOwnerKeys.set(owner, keys);\n }\n\n keys.add(key);\n }\n\n private entryFor<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n create: true,\n ): Entry<Owner, Lane>;\n private entryFor<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n create: false,\n ): Entry<Owner, Lane> | null;\n private entryFor<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n create: boolean,\n ): Entry<Owner, Lane> | null {\n const normalized = normalizeKey(resource.key(...args));\n // The fingerprint feeds only the dev drift diagnostics below, so\n // production never pays for encoding the args on every read.\n const fingerprint = __DEV__ ? fingerprintFor(resource, args) : null;\n const key = this.storeKey(normalized.canonical);\n const current = this.entries.get(key);\n\n if (current !== undefined) {\n if (__DEV__) {\n diagnoseEntryDrift(\n current,\n resource,\n normalized.canonical,\n fingerprint,\n );\n }\n return current;\n }\n\n if (!create) return null;\n\n const entry = this.createEntry(\n normalized,\n key,\n resource as DataResource<unknown[], unknown>,\n fingerprint,\n \"pending\",\n undefined,\n );\n // A disposed store is terminal: hand back a transient entry but never\n // register it, so post-dispose reads cannot resurrect the cache.\n if (this.disposed) return entry;\n\n this.entries.set(key, entry);\n this.notifyEntryChange(entry);\n return entry;\n }\n\n private revalidateIfStale<TArgs extends unknown[], TValue>(\n entry: Entry<Owner, Lane>,\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n ): void {\n if (\n entry.status !== \"fulfilled\" ||\n !entry.stale ||\n entry.pending !== null ||\n entry.refreshError !== undefined ||\n resource.load === undefined\n ) {\n return;\n }\n\n // Serve the stale value and revalidate in the background. A recorded\n // refreshError blocks retries until an explicit invalidate/refresh.\n void this.startLoad(entry, resource, args, {\n lane: this.host.getLane(),\n refresh: true,\n });\n }\n\n private entryForKey(key: DataResourceKey): Entry<Owner, Lane> | null {\n const normalized = normalizeKey(key);\n return this.entries.get(this.storeKey(normalized.canonical)) ?? null;\n }\n\n private createEntry(\n normalized: NormalizedKey,\n storeKey: string,\n resource: DataResource<unknown[], unknown> | null,\n fingerprint: string | null,\n status: FigDataEntryStatus,\n value: unknown,\n ): Entry<Owner, Lane> {\n return {\n canonicalKey: normalized.canonical,\n controller: null,\n ensureRetainers: 0,\n error: undefined,\n fingerprint,\n generation: 0,\n invalidationVersion: 0,\n inactiveTimer: null,\n key: normalized.key,\n lane: null,\n pending: null,\n preloadTimer: null,\n refreshError: undefined,\n resource,\n stale: false,\n status,\n storeKey,\n subscribers: new Set(),\n value,\n valueController: null,\n valueErrors: new WeakSet(),\n };\n }\n\n private hydrateEntry(\n entry: Entry<Owner, Lane>,\n key: DataResourceKey,\n value: unknown,\n ): void {\n this.clearInactiveTimer(entry);\n this.abortEntryGenerations(entry, \"superseded\");\n entry.error = undefined;\n entry.generation += 1;\n // The hydrated value replaces whatever attributed hole errors the old\n // value carried; a boundary still holding one must not retire it.\n entry.valueErrors = new WeakSet();\n entry.invalidationVersion = 0;\n entry.key = key;\n entry.lane = null;\n entry.refreshError = undefined;\n entry.stale = false;\n entry.status = \"fulfilled\";\n entry.value = value;\n }\n\n private storeKey(canonicalKey: string): string {\n return this.partitionKey === \"\"\n ? canonicalKey\n : `${this.partitionKey}:${canonicalKey}`;\n }\n\n private startLoad<TArgs extends unknown[], TValue>(\n entry: Entry<Owner, Lane>,\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n options: LoadOptions<Lane>,\n ): Promise<DataRefreshResult<TValue>> {\n const hadValue = entryHasValue(entry);\n const load = resource.load;\n\n if (this.disposed) {\n return Promise.resolve(abortedRefreshResult(entry, \"store-disposed\"));\n }\n\n if (load === undefined) {\n const error = new Error(\n `Data resource \"${entry.canonicalKey}\" has no loader and no hydrated value.`,\n );\n entry.error = error;\n entry.status = \"rejected\";\n markDataResourceError(error, entry.key);\n this.notifyEntryChange(entry);\n return Promise.resolve(unsupportedRefreshResult<TValue>(entry));\n }\n\n this.abortPendingLoad(entry, \"superseded\");\n const controller = new AbortController();\n // This generation's attributed hole errors. Allocated per load and\n // installed on the entry only at publish: attribution can fire before the\n // root value settles (a hole's error row can share a network chunk with\n // the root row), so the set must survive fulfillment, and a generation\n // that never publishes must never make the entry's live value\n // invalidatable through its own errors.\n const valueErrors = new WeakSet<object>();\n const generation = entry.generation + 1;\n const invalidationVersion = entry.invalidationVersion;\n const pending = createPendingResult<TValue>();\n\n entry.controller = controller;\n entry.generation = generation;\n entry.lane = options.lane;\n entry.pending = pending as PendingResult<unknown>;\n entry.status = options.refresh && hadValue ? \"refreshing\" : \"pending\";\n this.notifyEntryChange(entry);\n\n let loaded: TValue | PromiseLike<TValue>;\n try {\n loaded = load(\n ...args,\n this.createLoadContext(entry, controller, valueErrors),\n );\n } catch (error) {\n loaded = Promise.reject(error);\n }\n\n const settleAborted = (): DataRefreshResult<TValue> => {\n const result = abortedRefreshResult<TValue, Owner, Lane>(\n entry,\n \"superseded\",\n );\n pending.resolve(result);\n return result;\n };\n const fulfill = (value: TValue): DataRefreshResult<TValue> => {\n if (entry.generation !== generation || controller.signal.aborted) {\n return settleAborted();\n }\n\n const superseded = entry.valueController;\n // This generation is now the authoritative value; its controller stays\n // live for the background work still streaming into the value.\n entry.controller = null;\n entry.valueController = controller;\n entry.valueErrors = valueErrors;\n entry.error = undefined;\n entry.pending = null;\n entry.refreshError = undefined;\n entry.stale = entry.invalidationVersion !== invalidationVersion;\n entry.status = \"fulfilled\";\n entry.value = value;\n this.publish(entry);\n // The predecessor loses authority only now that the successor's value\n // has published: subscribers re-render top-down onto the new tree in\n // the same pass, so the old generation's retired holes unmount before\n // their abort rejections could reach a mounted reader.\n superseded?.abort(\"superseded\");\n const result: DataRefreshResult<TValue> = { status: \"fulfilled\", value };\n pending.resolve(result);\n return result;\n };\n const reject = (error: unknown): DataRefreshResult<TValue> => {\n if (entry.generation !== generation || controller.signal.aborted) {\n return settleAborted();\n }\n\n // A rejected load's generation never becomes authoritative; abort its\n // signal so background work it started stops. The previous\n // generation's valueController is deliberately untouched: a failed\n // refresh keeps the stale value fully alive, live holes included.\n entry.controller = null;\n controller.abort(error);\n entry.pending = null;\n\n if (hadValue && entryHasValue(entry)) {\n entry.refreshError = error;\n entry.stale = true;\n entry.status = \"fulfilled\";\n this.publish(entry);\n const result: DataRefreshResult<TValue> = {\n error,\n staleValue: entry.value as TValue,\n status: \"rejected\",\n };\n pending.resolve(result);\n return result;\n }\n\n entry.error = error;\n entry.status = \"rejected\";\n markDataResourceError(error, entry.key);\n this.publish(entry);\n const result: DataRefreshResult<TValue> = { error, status: \"rejected\" };\n pending.resolve(result);\n return result;\n };\n\n if (!isThenable(loaded)) {\n fulfill(loaded);\n return pending.promise;\n }\n\n void Promise.resolve(loaded).then(fulfill, reject);\n\n return pending.promise;\n }\n\n private createLoadContext(\n entry: Entry<Owner, Lane>,\n controller: AbortController,\n valueErrors: WeakSet<object>,\n ): DataResourceLoadContext {\n const context: DataResourceLoadContext = { signal: controller.signal };\n defineLoadContextCapabilities(context, {\n key: entry.key,\n attributeError: (error) => {\n // A fulfilled payload value may reject one of its streamed holes later.\n // Attribute that error for as long as this generation's signal is live —\n // the signal's lifetime IS its authority, so a visible value keeps\n // attributing through a superseding refresh's window. Retired decodes\n // must not make their successor invalidatable by a stale error object;\n // the errors land in this generation's own set, which reaches the entry\n // only if this generation publishes.\n if (this.disposed || controller.signal.aborted) return;\n markDataResourceError(error, entry.key);\n if (isAttributableError(error)) valueErrors.add(error);\n },\n hydrate: (entries) => {\n // Server-pushed rows hydrate for as long as this generation's signal\n // is live — the same authority window as attributeError. A visible\n // value keeps hydrating through a superseding refresh's window;\n // retired, evicted, and disposed decodes cannot mutate the store\n // (every retirement path aborts the signal).\n if (this.disposed || controller.signal.aborted) return;\n\n // The loading entry's own value comes from the loader's return, never\n // from a data row: hydrating its key here would supersede — and abort —\n // the very load delivering it.\n const foreign = entries.filter(\n (hydrated) =>\n this.storeKey(normalizeKey(hydrated.key).canonical) !==\n entry.storeKey,\n );\n if (__DEV__ && foreign.length !== entries.length) {\n warn(\n `Data rows targeting the loading key ${entry.canonicalKey} were skipped: a loader cannot hydrate its own entry.`,\n );\n }\n if (foreign.length > 0) this.hydrate(foreign);\n },\n });\n return context;\n }\n\n private publish(entry: Entry<Owner, Lane>): void {\n this.notifyEntryChange(entry);\n this.scheduleInactiveCleanup(entry);\n\n this.scheduleSubscribers(entry, entry.lane ?? this.host.getLane());\n }\n\n private scheduleSubscribers(entry: Entry<Owner, Lane>, lane: Lane): void {\n for (const subscriber of entry.subscribers) {\n this.host.schedule(subscriber, lane);\n }\n }\n\n // Aborts only the in-flight load: supersession-at-start cancels a wasted\n // request without revoking the authoritative generation's signal.\n private abortPendingLoad(\n entry: Entry<Owner, Lane>,\n reason: AbortReason,\n ): void {\n entry.controller?.abort(reason);\n entry.controller = null;\n\n const pending = entry.pending;\n if (pending === null) return;\n\n entry.pending = null;\n pending.resolve(abortedRefreshResult(entry, reason));\n }\n\n // Terminal paths (hydrate-over, eviction, disposal) end every generation:\n // the pending load and the authoritative value's background work.\n private abortEntryGenerations(\n entry: Entry<Owner, Lane>,\n reason: AbortReason,\n ): void {\n this.abortPendingLoad(entry, reason);\n entry.valueController?.abort(reason);\n entry.valueController = null;\n }\n\n private retainPreload(entry: Entry<Owner, Lane>): void {\n this.clearPreloadTimer(entry);\n if (this.disposed || !Number.isFinite(this.preloadRetentionMs)) return;\n\n entry.preloadTimer = scheduleStoreTimer(\n () => {\n entry.preloadTimer = null;\n if (\n entry.subscribers.size === 0 &&\n entry.ensureRetainers === 0 &&\n entry.pending !== null &&\n !entryHasValue(entry)\n ) {\n this.evictEntry(entry, \"evicted\");\n return;\n }\n this.scheduleInactiveCleanup(entry);\n },\n Math.max(0, this.preloadRetentionMs),\n );\n }\n\n private scheduleInactiveCleanup(entry: Entry<Owner, Lane>): void {\n if (\n this.disposed ||\n entry.subscribers.size > 0 ||\n entry.pending !== null ||\n entry.preloadTimer !== null ||\n entry.ensureRetainers > 0 ||\n !Number.isFinite(this.inactiveRetentionMs)\n ) {\n return;\n }\n\n this.clearInactiveTimer(entry);\n entry.inactiveTimer = scheduleStoreTimer(\n () => {\n entry.inactiveTimer = null;\n if (\n entry.subscribers.size > 0 ||\n entry.pending !== null ||\n entry.preloadTimer !== null ||\n entry.ensureRetainers > 0\n ) {\n return;\n }\n this.evictEntry(entry, \"evicted\");\n },\n Math.max(0, this.inactiveRetentionMs),\n );\n }\n\n private evictEntry(entry: Entry<Owner, Lane>, reason: AbortReason): void {\n if (this.entries.get(entry.storeKey) !== entry) return;\n\n this.clearInactiveTimer(entry);\n this.clearPreloadTimer(entry);\n this.abortEntryGenerations(entry, reason);\n this.entries.delete(entry.storeKey);\n this.host.onEntryEvict?.(this.snapshotEntry(entry));\n }\n\n private clearInactiveTimer(entry: Entry<Owner, Lane>): void {\n if (entry.inactiveTimer === null) return;\n\n clearTimeout(entry.inactiveTimer);\n entry.inactiveTimer = null;\n }\n\n private clearPreloadTimer(entry: Entry<Owner, Lane>): void {\n if (entry.preloadTimer === null) return;\n\n clearTimeout(entry.preloadTimer);\n entry.preloadTimer = null;\n }\n\n private notifyEntryChange(entry: Entry<Owner, Lane>): void {\n this.host.onEntryChange?.(this.snapshotEntry(entry));\n }\n\n private snapshotEntry(entry: Entry<Owner, Lane>): DataStoreEntrySnapshot {\n const hasValue = entryHasValue(entry);\n return {\n canonicalKey: entry.canonicalKey,\n error: entry.status === \"rejected\" ? entry.error : undefined,\n hasValue,\n key: entry.key,\n pending: entry.pending !== null,\n refreshError: entry.refreshError,\n stale: entry.stale,\n status: entry.status,\n subscriberCount: entry.subscribers.size,\n value: hasValue ? entry.value : undefined,\n };\n }\n\n private readCurrentValue<TValue>(entry: Entry<Owner, Lane>): TValue {\n if (entryHasValue(entry)) {\n return entry.value as TValue;\n }\n\n if (entry.status === \"rejected\") throwDataResourceError(entry);\n\n if (entry.pending === null) {\n throw new Error(\n `Data resource \"${entry.canonicalKey}\" has no pending load.`,\n );\n }\n\n throw entry.pending.promise;\n }\n\n private invalidateEntry(\n entry: Entry<Owner, Lane>,\n lane: Lane,\n attributedError?: unknown,\n ): void {\n entry.invalidationVersion += 1;\n entry.stale = true;\n // Clearing the prior refresh failure re-enables auto-refresh-on-read; an\n // explicit invalidation is a fresh \"this is stale, fetch again\" intent.\n entry.refreshError = undefined;\n if (\n isAttributableError(attributedError) &&\n entry.valueErrors.has(attributedError)\n ) {\n entry.valueController?.abort(attributedError);\n entry.valueController = null;\n entry.valueErrors = new WeakSet();\n entry.value = undefined;\n entry.error = undefined;\n entry.status = \"pending\";\n } else if (entry.status === \"rejected\") {\n // The same intent applies to a cached rejection: without this, every\n // read rethrows the old error forever — remounting an ErrorBoundary\n // could never recover. Back to pending, so the next read loads afresh.\n entry.error = undefined;\n entry.status = \"pending\";\n }\n this.notifyEntryChange(entry);\n if (entry.subscribers.size === 0) return;\n\n this.scheduleSubscribers(entry, lane);\n }\n\n private invalidateEntries(\n entries: readonly Entry<Owner, Lane>[],\n attributedError?: unknown,\n ): void {\n if (entries.length === 0) return;\n\n const lane = this.host.getLane();\n for (const entry of entries) {\n this.invalidateEntry(entry, lane, attributedError);\n }\n }\n}\n\nfunction normalizeKey(key: DataResourceKey): NormalizedKey {\n if (!Array.isArray(key) || typeof key[0] !== \"string\") {\n throw new Error(\n \"Data resource keys must be arrays starting with a string.\",\n );\n }\n\n return {\n canonical: encodeArray(key, createEncodePath(\"key\")),\n key,\n };\n}\n\nfunction canonicalKeyStartsWith(key: string, prefix: string): boolean {\n if (key === prefix) return true;\n\n const arrayPrefix = prefix.slice(0, -1);\n return key.startsWith(arrayPrefix) && key[arrayPrefix.length] === \",\";\n}\n\nfunction entryHasValue<Owner extends object, Lane>(\n entry: Entry<Owner, Lane>,\n): boolean {\n return entry.status === \"fulfilled\" || entry.status === \"refreshing\";\n}\n\nfunction throwDataResourceError<Owner extends object, Lane>(\n entry: Entry<Owner, Lane>,\n): never {\n markDataResourceError(entry.error, entry.key);\n throw entry.error;\n}\n\nfunction abortedRefreshResult<T, Owner extends object, Lane>(\n entry: Entry<Owner, Lane>,\n reason: AbortReason,\n): DataRefreshResult<T> {\n return {\n reason,\n staleValue: entryHasValue(entry) ? (entry.value as T) : undefined,\n status: \"aborted\",\n };\n}\n\nfunction unsupportedRefreshResult<\n T,\n Owner extends object = object,\n Lane = unknown,\n>(entry?: Entry<Owner, Lane>): DataRefreshResult<T> {\n const result: DataRefreshResult<T> = {\n reason: \"no-client-loader\",\n status: \"unsupported\",\n };\n\n if (entry !== undefined) {\n result.staleValue = entryHasValue(entry) ? (entry.value as T) : undefined;\n }\n\n return result;\n}\n\nfunction fingerprintFor<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n): string | null {\n if (resource.debugArgs !== undefined) {\n return encodeValue(\n resource.debugArgs(...args),\n createEncodePath(\"debugArgs\"),\n );\n }\n\n try {\n return encodeArray(args, createEncodePath(\"args\"));\n } catch {\n return null;\n }\n}\n\nfunction diagnoseEntryDrift<\n Owner extends object,\n Lane,\n TArgs extends unknown[],\n TValue,\n>(\n entry: Entry<Owner, Lane>,\n resource: DataResource<TArgs, TValue>,\n key: string,\n fingerprint: string | null,\n): void {\n if (!__DEV__) return;\n\n if (entry.resource === null) {\n entry.resource = resource as DataResource<unknown[], unknown>;\n } else if (entry.resource !== resource) {\n warn(`Data resource key ${key} was read by multiple resource definitions.`);\n }\n\n if (\n entry.fingerprint !== null &&\n fingerprint !== null &&\n entry.fingerprint !== fingerprint\n ) {\n warn(\n `Data resource key ${key} was read with different argument fingerprints.`,\n );\n }\n}\n\nfunction warn(message: string): void {\n if (typeof console === \"undefined\") return;\n console.warn(message);\n}\n\nfunction createEncodePath(root: string): EncodePath {\n return { root, segments: [] };\n}\n\nfunction formatEncodePath(path: EncodePath): string {\n let text = path.root;\n for (const segment of path.segments) {\n text += typeof segment === \"number\" ? `[${segment}]` : `.${segment}`;\n }\n return text;\n}\n\nfunction encodeArray(values: readonly unknown[], path: EncodePath): string {\n const parts: string[] = [];\n for (let index = 0; index < values.length; index += 1) {\n path.segments.push(index);\n parts.push(encodeValue(values[index], path));\n path.segments.pop();\n }\n return `[${parts.join(\",\")}]`;\n}\n\nfunction encodeObject(value: object, path: EncodePath): string {\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new Error(\n `Invalid data resource key value at ${formatEncodePath(path)}.`,\n );\n }\n\n const record = value as Record<string, unknown>;\n const keys = Object.keys(record).sort();\n const parts: string[] = [];\n\n for (const key of keys) {\n const child = record[key];\n if (child === undefined) {\n throw new Error(\n `Invalid undefined data resource key value at ${formatEncodePath(path)}.`,\n );\n }\n path.segments.push(key);\n parts.push(`${JSON.stringify(key)}:${encodeValue(child, path)}`);\n path.segments.pop();\n }\n\n return `{${parts.join(\",\")}}`;\n}\n\nfunction encodeValue(value: unknown, path: EncodePath): string {\n if (value === null) return \"null\";\n\n switch (typeof value) {\n case \"string\":\n return JSON.stringify(value);\n case \"boolean\":\n return value ? \"true\" : \"false\";\n case \"number\":\n if (!Number.isFinite(value)) {\n throw new Error(\n `Invalid number in data resource key at ${formatEncodePath(path)}.`,\n );\n }\n return Object.is(value, -0) ? \"0\" : JSON.stringify(value);\n case \"object\":\n if (Array.isArray(value)) return encodeArray(value, path);\n return encodeObject(value, path);\n default:\n throw new Error(\n `Invalid data resource key value at ${formatEncodePath(path)}.`,\n );\n }\n}\n\nfunction isThenable<T>(value: T | PromiseLike<T>): value is PromiseLike<T> {\n return (\n (typeof value === \"object\" || typeof value === \"function\") &&\n value !== null &&\n \"then\" in value &&\n typeof value.then === \"function\"\n );\n}\n\nfunction createPendingResult<T>(): PendingResult<T> {\n let resolve: (result: DataRefreshResult<T>) => void = () => undefined;\n const promise = new Promise<DataRefreshResult<T>>((settle) => {\n resolve = settle;\n });\n\n return {\n promise,\n resolve,\n };\n}\n\nfunction scheduleStoreTimer(callback: () => void, delay: number): TimerHandle {\n const timer = setTimeout(callback, delay);\n const unref = (timer as { unref?: () => void }).unref;\n if (unref !== undefined) unref.call(timer);\n return timer;\n}\n\n/** Runs with data store. */\nexport function runWithDataStore<T>(store: FigDataStore, callback: () => T): T {\n return store.run(callback);\n}\n\n/** Current data store. */\nexport function currentDataStore(): FigDataStore {\n return resolveCurrentDataStore();\n}\n","/** Describes transition options. */\nexport interface TransitionOptions {\n types?: readonly string[];\n /**\n * Interrupts an active native View Transition before committing this\n * transition. The new commit still waits for the interrupted transition to\n * settle so host restoration cannot race its old-state snapshot.\n */\n viewTransition?: \"interrupt\";\n}\n\n/** Describes transition handler. */\nexport type TransitionHandler = <T>(\n callback: () => T,\n options?: TransitionOptions,\n) => T;\n\nlet transitionHandler: TransitionHandler = (callback) => callback();\n\n/**\n * Runs state updates scheduled by `callback` at transition priority. If\n * `callback` returns a thenable, updates after an `await` remain in the\n * transition priority scope until it settles.\n */\nexport function transition<T>(\n callback: () => T,\n options?: TransitionOptions,\n): T {\n return transitionHandler(callback, options);\n}\n\n/** Sets transition handler. */\nexport function setTransitionHandler(\n handler: TransitionHandler,\n): TransitionHandler {\n const previous = transitionHandler;\n transitionHandler = handler;\n return previous;\n}\n"],"mappings":";;;AAUA,MAAa,mBAAmB,OAAO,IAAI,aAAa;;AAGxD,SAAgB,cAAiB,cAAgC;CAC/D,OAAO,OAAO,QACX,UAA4C,MAAM,UACnD;EACE,UAAU;EACV;CACF,CACF;AACF;;AAGA,SAAgB,UAAU,OAA8C;CACtE,OACE,OAAO,UAAU,cACjB,cAAc,SACd,MAAM,aAAa;AAEvB;;;ACuFA,MAAM,qBAAqB,OAAO,IAAI,mBAAmB;AACzD,MAAM,yBAAyB,OAAO,IAAI,wBAAwB;AAClE,MAAM,4BAA4B,OAAO,IAAI,2BAA2B;AACxE,MAAM,gCAAgC;AACtC,MAAM,+BAA+B;AAKrC,MAAM,mBAAwC;;AAG9C,SAAgB,aACd,SAC6B;CAQ7B,OAAO;EANL,UAAU;GACT,yBAAyB;EAC1B,WAAW,QAAQ;EACnB,KAAK,QAAQ;EACb,MAAM,QAAQ;CAEF;AAChB;;AAGA,SAAgB,WACd,UACA,GAAG,MACc;CACjB,OA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AAU,OAAO;AAC5C;;AAGA,SAAgB,qBACd,SACmB;CACnB,MAAM,WAAW;CACjB,oBAAoB;CACpB,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"element-CVlfN_3_.js","names":["runtimeType"],"sources":["../src/data.ts","../src/hooks.ts","../src/mixin.ts","../src/element.ts"],"sourcesContent":["/** Describes data resource key input. */\nexport type DataResourceKeyInput =\n | string\n | number\n | boolean\n | null\n | readonly DataResourceKeyInput[]\n | { readonly [key: string]: DataResourceKeyInput };\n\n/** Describes data resource key. */\nexport type DataResourceKey = readonly [string, ...DataResourceKeyInput[]];\n\n/** Describes data resource load context. */\nexport interface DataResourceLoadContext {\n signal: AbortSignal;\n}\n\n/** Describes data resource loader. */\nexport type DataResourceLoader<TArgs extends unknown[], TValue> = (\n ...argsAndContext: [...TArgs, DataResourceLoadContext]\n) => TValue | PromiseLike<TValue>;\n\n/** Describes data resource. */\nexport interface DataResource<\n TArgs extends unknown[] = unknown[],\n TValue = unknown,\n> {\n readonly $$typeof: symbol;\n readonly debugArgs?: (...args: TArgs) => DataResourceKeyInput;\n readonly key: (...args: TArgs) => DataResourceKey;\n readonly load?: DataResourceLoader<TArgs, TValue>;\n}\n\n/** Describes data refresh result. */\nexport type DataRefreshResult<T> =\n | { status: \"fulfilled\"; value: T }\n | { status: \"rejected\"; error: unknown; staleValue?: T }\n | {\n status: \"aborted\";\n reason: \"superseded\" | \"store-disposed\" | \"evicted\";\n staleValue?: T;\n }\n | {\n status: \"unsupported\";\n reason: \"no-client-loader\";\n staleValue?: T;\n };\n\n/** Describes Fig data hydration entry. */\nexport interface FigDataHydrationEntry {\n key: DataResourceKey;\n value: unknown;\n}\n\n/** Describes Fig data entry status. */\nexport type FigDataEntryStatus =\n | \"pending\"\n | \"fulfilled\"\n | \"rejected\"\n | \"refreshing\";\n\n/** Describes data store entry snapshot. */\nexport interface DataStoreEntrySnapshot {\n canonicalKey: string;\n error?: unknown;\n hasValue: boolean;\n key: DataResourceKey;\n pending: boolean;\n refreshError?: unknown;\n stale: boolean;\n status: FigDataEntryStatus;\n subscriberCount: number;\n value?: unknown;\n}\n\n// The explicit, app-facing store surface (FigRoot.data, readDataStore()).\n// The free functions in @bgub/fig resolve the ambient store slot, which\n// is only set while Fig executes synchronously — render, event handlers, the\n// synchronous prefix of actions and transitions, and effects. After an\n// `await` the slot is gone, so async flows capture this handle first and call\n// its methods instead.\n/** Describes Fig data store handle. */\nexport interface FigDataStoreHandle {\n // The awaitable read for code outside render (route loaders, actions after\n // an await): resolve the value this key would render with — the cached\n // value when the entry has one (kicking the same background revalidation a\n // stale readData does), the in-flight load's settlement on a cache miss —\n // and reject with the error readData would throw. Does not subscribe;\n // pair with readData in the component, which claims the settled entry\n // within the preload retention window.\n ensureData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): Promise<TValue>;\n hydrate(entries: readonly FigDataHydrationEntry[]): void;\n invalidateData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): void;\n invalidateDataError(error: unknown): boolean;\n invalidateDataKey(key: DataResourceKey): void;\n invalidateDataPrefix(prefix: DataResourceKey): void;\n preloadData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): void;\n refreshData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): Promise<DataRefreshResult<TValue>>;\n run<T>(callback: () => T): T;\n}\n\n/**\n * A root-neutral data store. A renderer adopts it exactly once, preserving\n * entries loaded before rendering while attaching subscriber scheduling.\n */\nexport interface FigDataStoreController extends FigDataStoreHandle {\n dispose(): void;\n snapshot(): FigDataHydrationEntry[];\n}\n\n/** Describes Fig data store options. */\nexport interface FigDataStoreOptions {\n initialData?: readonly FigDataHydrationEntry[];\n partition?: DataResourceKeyInput;\n}\n\n/** Describes Fig data store. */\nexport interface FigDataStore extends FigDataStoreHandle {\n commitDataDependencies(owner: object, previousOwner: object | null): void;\n deleteDataOwner(owner: object): void;\n releaseDataOwner(owner: object): void;\n resetDataDependencies(owner: object): void;\n dispose(): void;\n inspectDataDependencyCanonicalKeys(owner: object): string[];\n inspectDataEntries(): DataStoreEntrySnapshot[];\n snapshot(): FigDataHydrationEntry[];\n // Renderer plumbing, not handle surface: args stay an array because the\n // subscribing owner trails them.\n readData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n owner: object,\n ): TValue;\n}\n\n// The host callbacks a renderer hands to the data-store factory. Structurally\n// compatible with @bgub/fig's DataStoreHost so its renderer store can\n// register directly.\n/** Describes Fig data store host. */\nexport interface FigDataStoreHost {\n getLane(): unknown;\n partition?: DataResourceKeyInput;\n schedule(owner: object, lane: unknown): void;\n}\n\n/** Describes Fig data store factory. */\nexport type FigDataStoreFactory = (host: FigDataStoreHost) => FigDataStore;\n\n// The internal, generation-guarded metadata a store attaches to each loader\n// context (symbol-keyed: DataResourceLoadContext stays { signal } publicly).\n// Adapters use the resolved key and decode Payload rows through the calling\n// store without recomputing identity or exposing these capabilities to loaders.\n/** Describes load context hydrate. */\nexport type LoadContextHydrate = (\n entries: readonly FigDataHydrationEntry[],\n) => void;\n/** Describes load context attribute error. */\nexport type LoadContextAttributeError = (error: unknown) => void;\n\n/** Describes load context capabilities. */\nexport interface LoadContextCapabilities {\n attributeError: LoadContextAttributeError;\n hydrate: LoadContextHydrate;\n // Store contexts always provide this; optional keeps synthetic decoder\n // contexts usable without pretending they belong to a cache entry.\n key?: DataResourceKey;\n}\n\nconst LoadContextCapabilitiesSymbol = Symbol.for(\"fig.data-load-context\");\ntype DataResourceLoadContextWithCapabilities = DataResourceLoadContext & {\n [LoadContextCapabilitiesSymbol]?: LoadContextCapabilities;\n};\n\n/** Define load context capabilities. */\nexport function defineLoadContextCapabilities(\n context: DataResourceLoadContext,\n capabilities: LoadContextCapabilities,\n): void {\n Object.defineProperty(context, LoadContextCapabilitiesSymbol, {\n configurable: true,\n enumerable: false,\n value: capabilities,\n });\n}\n\n/** Load context capabilities. */\nexport function loadContextCapabilities(\n context: DataResourceLoadContext,\n): LoadContextCapabilities | undefined {\n return (context as DataResourceLoadContextWithCapabilities)[\n LoadContextCapabilitiesSymbol\n ];\n}\n\nconst objectDataErrors = new WeakMap<object, DataResourceKey[]>();\n\nlet currentDataStore: FigDataStore | null = null;\n\n/** Resolves current data store. */\nexport function resolveCurrentDataStore(\n message = \"Data resource APIs require a Fig data store.\",\n): FigDataStore {\n if (currentDataStore === null) throw new Error(message);\n return currentDataStore;\n}\n\n/** Sets current data store. */\nexport function setCurrentDataStore(\n store: FigDataStore | null,\n): FigDataStore | null {\n const previousStore = currentDataStore;\n currentDataStore = store;\n return previousStore;\n}\n\n/** Marks data resource error. */\nexport function markDataResourceError(\n error: unknown,\n key: DataResourceKey,\n): void {\n // Only object errors are attributed: the WeakMap keys them by identity, so the\n // registry is GC-safe and cannot cross-attribute. Primitive rejection values\n // would collide by value and accumulate forever in a plain Map, so a thrown\n // primitive simply carries no resource-key metadata.\n if (!isAttributableError(error)) return;\n\n let keys = objectDataErrors.get(error);\n if (keys === undefined) {\n keys = [];\n objectDataErrors.set(error, keys);\n }\n\n if (keys.some((existing) => sameDataResourceKey(existing, key))) return;\n\n keys.push(key);\n}\n\n/** Data resource keys for error. */\nexport function dataResourceKeysForError(\n error: unknown,\n): DataResourceKey[] | undefined {\n if (!isAttributableError(error)) return undefined;\n\n const keys = objectDataErrors.get(error);\n return keys === undefined || keys.length === 0 ? undefined : [...keys];\n}\n\nfunction sameDataResourceKey(a: DataResourceKey, b: DataResourceKey): boolean {\n return (\n a.length === b.length &&\n a.every((value, index) => Object.is(value, b[index]))\n );\n}\n\n// The single rule for which errors can carry attribution: identity-keyed\n// (WeakMap/WeakSet) registries require object errors. Shared with the store's\n// per-generation value-error sets so the two can never disagree.\nexport function isAttributableError(value: unknown): value is object {\n return (\n (typeof value === \"object\" || typeof value === \"function\") && value !== null\n );\n}\n","import type { FigContext } from \"./context.ts\";\nimport type { DataResource, FigDataStore } from \"./data.ts\";\nimport { resolveCurrentDataStore } from \"./data.ts\";\nimport type { TransitionOptions } from \"./transition.ts\";\n\n// The useState updater: accepts the next state, or an updater function of\n// the previous state for stale-closure safety.\n/** Describes state setter. */\nexport type StateSetter<S> = (next: S | ((previous: S) => S)) => void;\n/** Describes external store subscribe. */\nexport type ExternalStoreSubscribe = (callback: () => void) => () => void;\n// Fig appends the AbortSignal after the runner's args (the data-loader\n// shape). The signal aborts when a newer run supersedes this one, when the\n// owning component unmounts, and when an enclosing Activity hides.\n/** Describes action state action. */\nexport type ActionStateAction<S, Args extends unknown[]> = (\n previousState: S,\n ...argsAndSignal: [...Args, AbortSignal]\n) => S | PromiseLike<S>;\n/** Describes action state runner. */\nexport type ActionStateRunner<Args extends unknown[]> = (...args: Args) => void;\n\n/**\n * Runs state updates scheduled by `callback` at transition priority. If\n * `callback` returns a thenable, `useTransition` keeps `isPending` true until\n * it settles and updates after an `await` remain in the transition priority\n * scope.\n *\n * The callback receives an `AbortSignal` that aborts when a newer transition\n * starts from the same hook, when the owning component unmounts, and when an\n * enclosing Activity hides. Each `useTransition` hook is one cancellation\n * domain — use separate hooks for independently cancellable workflows. An\n * aborted run is retired: its pending slot is released immediately and its\n * settlement (including an aborted fetch's rejection) is inert.\n */\nexport type StartTransition = (\n callback: (signal: AbortSignal) => void | PromiseLike<void>,\n options?: TransitionOptions,\n) => void;\ntype Callback = (...args: never[]) => unknown;\n\n/** Describes render dispatcher. */\nexport interface RenderDispatcher {\n useState<S>(initialState: S | (() => S)): [S, StateSetter<S>];\n useActionState<S, Args extends unknown[]>(\n action: ActionStateAction<S, Args>,\n initialState: S,\n ): [S, ActionStateRunner<Args>, boolean];\n useId(): string;\n useDeferredValue<T>(\n value: T,\n initialValue: T | undefined,\n hasInitialValue: boolean,\n ): T;\n useMemo<T>(calculate: () => T, deps: DependencyList): T;\n useTransition(): [boolean, StartTransition];\n useReactive(effect: EffectCallback, deps?: DependencyList): void;\n useBeforePaint(effect: EffectCallback, deps?: DependencyList): void;\n useBeforeLayout(effect: EffectCallback, deps?: DependencyList): void;\n useSyncExternalStore<T>(\n subscribe: ExternalStoreSubscribe,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n ): T;\n useStableEvent<Args extends unknown[], Result>(\n handler: (...args: Args) => Result,\n ): (...args: StableEventCallerArgs<Args>) => Result;\n readContext<T>(context: FigContext<T>): T;\n readData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n ): TValue;\n preloadData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n ): void;\n readPromise<T>(promise: PromiseLike<T>): T;\n}\n\n/** Describes effect callback. */\nexport type EffectCallback = (signal: AbortSignal) => undefined;\n/** Describes dependency list. */\nexport type DependencyList = readonly unknown[];\n\n/** Describes stable event caller args. */\nexport type StableEventCallerArgs<Args extends unknown[]> = Args extends [\n ...infer CallerArgs,\n AbortSignal,\n]\n ? CallerArgs\n : Args;\n\n// Fig appends the AbortSignal when invoking the handler; callers never pass\n// it, so a declared trailing signal is stripped from the callable signature.\nlet currentDispatcher: RenderDispatcher | null = null;\n\n/** Returns state. */\nexport function useState<S>(initialState: S | (() => S)): [S, StateSetter<S>] {\n return resolveDispatcher().useState(initialState);\n}\n\n/**\n * Tracks state returned by a client-side action. The action receives the\n * previous committed state first, then the runner's arguments, then an\n * `AbortSignal` Fig appends (declare the trailing signal parameter — it also\n * drives `Args` inference). Async actions run in a transition priority scope\n * and keep `isPending` true until they settle.\n *\n * Runs are last-run-wins: starting a new run aborts the previous one's\n * signal and retires it — a retired run's settlement (value or rejection)\n * never touches state or pending. The signal also aborts on unmount and\n * when an enclosing Activity hides.\n */\nexport function useActionState<S, Args extends unknown[]>(\n action: ActionStateAction<S, Args>,\n initialState: S,\n): [S, ActionStateRunner<Args>, boolean] {\n return resolveDispatcher().useActionState(action, initialState);\n}\n\n/** Returns ID. */\nexport function useId(): string {\n return resolveDispatcher().useId();\n}\n\n/** Returns deferred value. */\nexport function useDeferredValue<T>(value: T, initialValue?: T): T {\n return resolveDispatcher().useDeferredValue(\n value,\n initialValue,\n arguments.length > 1,\n );\n}\n\n/** Returns memo. */\nexport function useMemo<T>(calculate: () => T, deps: DependencyList): T {\n return resolveDispatcher().useMemo(calculate, deps);\n}\n\n/** Returns transition. */\nexport function useTransition(): [boolean, StartTransition] {\n return resolveDispatcher().useTransition();\n}\n\n/** Returns callback. */\nexport function useCallback<T extends Callback>(\n callback: T,\n deps: DependencyList,\n): T {\n return resolveDispatcher().useMemo(() => callback, deps);\n}\n\n/** Returns reactive. */\nexport function useReactive(\n effect: EffectCallback,\n deps?: DependencyList,\n): void {\n resolveDispatcher().useReactive(effect, deps);\n}\n\n/** Returns before paint. */\nexport function useBeforePaint(\n effect: EffectCallback,\n deps?: DependencyList,\n): void {\n resolveDispatcher().useBeforePaint(effect, deps);\n}\n\n/** Returns before layout. */\nexport function useBeforeLayout(\n effect: EffectCallback,\n deps?: DependencyList,\n): void {\n resolveDispatcher().useBeforeLayout(effect, deps);\n}\n\n/** Returns sync external store. */\nexport function useSyncExternalStore<T>(\n subscribe: ExternalStoreSubscribe,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n): T {\n return resolveDispatcher().useSyncExternalStore(\n subscribe,\n getSnapshot,\n getServerSnapshot,\n );\n}\n\n/** Returns stable event. */\nexport function useStableEvent<Args extends unknown[], Result>(\n handler: (...args: Args) => Result,\n): (...args: StableEventCallerArgs<Args>) => Result {\n return resolveDispatcher().useStableEvent(handler);\n}\n\n/** Reads context. */\nexport function readContext<T>(context: FigContext<T>): T {\n return resolveDispatcher(\n \"readContext can only be called while rendering a component.\",\n ).readContext(context);\n}\n\n/** Reads promise. */\nexport function readPromise<T>(promise: PromiseLike<T>): T {\n return resolveDispatcher(\n \"readPromise can only be called while rendering a component.\",\n ).readPromise(promise);\n}\n\n/** Reads data. */\nexport function readData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): TValue {\n return resolveDispatcher(\n \"readData can only be called while rendering a component.\",\n ).readData(resource, args);\n}\n\n/** Preloads data. */\nexport function preloadData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): void {\n if (currentDispatcher !== null) {\n currentDispatcher.preloadData(resource, args);\n return;\n }\n\n resolveDataStore().preloadData(resource, ...args);\n}\n\n/** Sets current dispatcher. */\nexport function setCurrentDispatcher(\n dispatcher: RenderDispatcher | null,\n): RenderDispatcher | null {\n const previousDispatcher = currentDispatcher;\n currentDispatcher = dispatcher;\n return previousDispatcher;\n}\n\nfunction resolveDispatcher(\n message = \"Hooks can only be called while rendering a component.\",\n): RenderDispatcher {\n if (currentDispatcher === null) {\n throw new Error(message);\n }\n\n return currentDispatcher;\n}\n\nfunction resolveDataStore(): FigDataStore {\n return resolveCurrentDataStore(\n \"No ambient Fig data store. Data APIs work synchronously during render, \" +\n \"event handlers, actions, and effects — not after an await. Capture \" +\n \"readDataStore() (or root.data) synchronously and call the handle \" +\n \"instead.\",\n );\n}\n","import type { Props } from \"./element.ts\";\nimport { type RenderDispatcher, setCurrentDispatcher } from \"./hooks.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\n/** Describes mixin context. */\nexport interface MixinContext {\n /** The intrinsic host name receiving this mixin. */\n readonly type: string;\n /** Props composed by the host and every preceding mixin. */\n readonly props: Readonly<Props>;\n}\n\n/** Describes empty mixin value. */\nexport type EmptyMixinValue = false | 0 | 0n | \"\" | null | undefined;\n\n/** Describes mixin input. */\nexport type MixinInput =\n | MixinDescriptor\n | EmptyMixinValue\n | ReadonlyArray<MixinInput>;\n\n/** Describes mixin result. */\nexport type MixinResult = Props | MixinInput;\n\n/** Describes mixin type. */\nexport type MixinType<TArgs extends unknown[] = unknown[]> = (\n context: MixinContext,\n ...args: TArgs\n) => MixinResult;\n\ntype MixinRuntimeType = (\n context: MixinContext,\n ...args: unknown[]\n) => MixinResult;\n\n/** Describes mixin descriptor. */\nexport interface MixinDescriptor {\n readonly $$typeof: symbol;\n readonly args: readonly unknown[];\n readonly type: MixinRuntimeType;\n}\n\n/** Describes mixin factory. */\nexport type MixinFactory<TArgs extends unknown[]> = (\n ...args: TArgs\n) => MixinDescriptor;\n\n// Registered symbols: descriptors and contexts must stay recognizable when\n// duplicate copies of this module are live (linked source next to a\n// prebundled copy).\n/** The Fig mixin symbol. */\nexport const FigMixinSymbol = Symbol.for(\"fig.mixin\");\nconst FigMixinSlotSymbol = Symbol.for(\"fig.mixin-slot\");\nconst FigClientOnlyHostBehaviorSymbol = Symbol.for(\n \"fig.client-only-host-behavior\",\n);\ntype ClientOnlyHostProps = object & {\n [FigClientOnlyHostBehaviorSymbol]?: string;\n};\n\n/** Creates a render-time host behavior for the `mix` prop. */\nexport function createMixin<TArgs extends unknown[]>(\n type: MixinType<TArgs>,\n): MixinFactory<TArgs> {\n const runtimeType = type as MixinRuntimeType;\n const descriptorType = __DEV__ ? guardMixinType(runtimeType) : runtimeType;\n return (...args) => ({\n $$typeof: FigMixinSymbol,\n args,\n type: descriptorType,\n });\n}\n\nconst maximumResolvedMixins = 1024;\n\n/** Resolves host mix. */\nexport function resolveHostMix<P extends Props>(type: string, input: P): P {\n const props: Props = input;\n const mix = props.mix;\n delete props.mix;\n let resolvedMixins = 0;\n\n function resolve(value: unknown, slot: string): void {\n if (emptyMixinValue(value)) return;\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index += 1) {\n resolve(value[index], `${slot}.${index}`);\n }\n return;\n }\n if (!isMixinDescriptor(value)) {\n throw new Error(\n `The mix prop on <${type}> must contain descriptors created by createMixin().`,\n );\n }\n\n resolvedMixins += 1;\n if (resolvedMixins > maximumResolvedMixins) {\n throw new Error(\n `The mix prop on <${type}> resolved more than ${maximumResolvedMixins} mixins.`,\n );\n }\n\n const context: MixinRuntimeContext = {\n [FigMixinSlotSymbol]: slot,\n props,\n type,\n };\n const result = value.type(context, ...value.args);\n if (emptyMixinValue(result)) return;\n\n if (isMixinDescriptor(result) || Array.isArray(result)) {\n resolve(result, `${slot}.result`);\n return;\n }\n if (typeof result !== \"object\") {\n throw new Error(\n `A mixin on <${type}> must return host props, more mixins, or nothing.`,\n );\n }\n const returnedProps = result as Props;\n\n if (\n \"children\" in returnedProps ||\n \"key\" in returnedProps ||\n \"unsafeHTML\" in returnedProps\n ) {\n throw new Error(\n `A mixin on <${type}> cannot return children, key, or unsafeHTML.`,\n );\n }\n\n const { mix: nestedMix, ...patch } = returnedProps;\n Object.assign(props, patch);\n resolve(nestedMix, `${slot}.mix`);\n }\n\n resolve(mix, \"0\");\n props.mix = mix;\n return props as P;\n}\n\ninterface MixinRuntimeContext extends MixinContext {\n readonly [FigMixinSlotSymbol]: string;\n}\n\n/** Mixin slot. */\nexport function mixinSlot(context: MixinContext): string {\n return (context as MixinRuntimeContext)[FigMixinSlotSymbol];\n}\n\n/** Marks client only host behavior. */\nexport function markClientOnlyHostBehavior(\n context: MixinContext,\n behavior: string,\n): void {\n markClientOnlyHostProps(context.props, behavior);\n}\n\n/** Marks client only host props. */\nexport function markClientOnlyHostProps(value: object, behavior: string): void {\n const props = value as ClientOnlyHostProps;\n if (props[FigClientOnlyHostBehaviorSymbol] !== undefined) return;\n Object.defineProperty(props, FigClientOnlyHostBehaviorSymbol, {\n configurable: true,\n value: behavior,\n });\n}\n\n/** Client only host behavior. */\nexport function clientOnlyHostBehavior(props: object): string | undefined {\n const behavior = (props as ClientOnlyHostProps)[\n FigClientOnlyHostBehaviorSymbol\n ];\n return typeof behavior === \"string\" ? behavior : undefined;\n}\n\nfunction emptyMixinValue(value: unknown): value is EmptyMixinValue {\n return (\n value === false ||\n value === 0 ||\n value === 0n ||\n value === \"\" ||\n value === null ||\n value === undefined\n );\n}\n\nfunction isMixinDescriptor(value: unknown): value is MixinDescriptor {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"$$typeof\" in value &&\n value.$$typeof === FigMixinSymbol\n );\n}\n\n// Dev-only: the wrapper lives in the createMixin module copy, so it guards the\n// dispatcher used by hooks imported alongside that factory even when another\n// linked or prebundled copy resolves the descriptor.\nfunction guardMixinType(type: MixinRuntimeType): MixinRuntimeType {\n return (context, ...args) => {\n const previousDispatcher = setCurrentDispatcher(\n mixinDispatcher(context.type, mixinSlot(context)),\n );\n try {\n return type(context, ...args);\n } finally {\n setCurrentDispatcher(previousDispatcher);\n }\n };\n}\n\nfunction mixinDispatcher(type: string, slot: string): RenderDispatcher {\n return new Proxy({} as RenderDispatcher, {\n get(_target, property) {\n throw new Error(\n `A mixin on <${type}> (slot ${slot}) called ${String(property)}. ` +\n \"Mixins are pure render-time code: hooks and read verbs belong to \" +\n \"the component; host lifetimes belong in returned on() or bind \" +\n \"behavior.\",\n );\n },\n });\n}\n","import type { DataResourceKey } from \"./data.ts\";\nimport { readPromise } from \"./hooks.ts\";\nimport type { ClientReferenceAssets } from \"./resource.ts\";\nimport { resolveHostMix } from \"./mixin.ts\";\n\n/** Describes key. */\nexport type Key = string | number;\n/** Describes props. */\nexport type Props = Record<string, any>;\n/** Describes component type. */\nexport type ComponentType<P = Props> = (\n props: P & { children?: FigNode },\n) => FigNode;\n/** Describes component props. */\nexport type ComponentProps<T extends ComponentType<any>> =\n Parameters<T> extends [infer P, ...unknown[]]\n ? P extends Props\n ? P\n : Props\n : {};\n/** Describes element type. */\nexport type ElementType<P = Props> =\n | string\n | typeof Fragment\n | FigAssets\n | FigClientReference<P>\n | FigErrorBoundary\n | FigSuspense\n | FigActivity\n | FigViewTransition\n | ComponentType<P>;\n/** Describes awaited Fig node. */\nexport type AwaitedFigNode =\n | FigElement<any>\n | FigPortal<any>\n | string\n | number\n | boolean\n | null\n | undefined\n | FigNode[];\n/** Describes Fig node. */\nexport type FigNode = AwaitedFigNode | PromiseLike<AwaitedFigNode>;\n\n/** Describes Fig element. */\nexport interface FigElement<P = Props> {\n readonly $$typeof: symbol;\n readonly type: ElementType<any>;\n readonly key: Key | null;\n readonly props: P & { children?: FigNode };\n}\n\n/** Describes Fig portal. */\nexport interface FigPortal<Target = unknown> {\n readonly $$typeof: symbol;\n readonly children: FigNode;\n readonly key: Key | null;\n readonly target: Target;\n}\n\n/** Describes client reference options. */\nexport interface ClientReferenceOptions<P extends Props = Props> {\n assets?: ClientReferenceAssets;\n id: string;\n ssr?: ComponentType<P>;\n}\n\n/** Describes Fig client reference. */\nexport interface FigClientReference<P = Props> {\n (props: P & { children?: FigNode }): FigNode;\n readonly $$typeof: symbol;\n readonly assets?: ClientReferenceAssets;\n readonly id: string;\n readonly ssr?: ComponentType<P>;\n}\n\n/** Describes lazy loader. */\nexport type LazyLoader<T extends ComponentType<any> = ComponentType<any>> =\n () => PromiseLike<T>;\n\n/** Describes suspense props. */\nexport interface SuspenseProps {\n fallback?: FigNode;\n children?: FigNode;\n}\n\n/** Describes Fig suspense. */\nexport interface FigSuspense {\n (props: SuspenseProps): FigNode;\n readonly $$typeof: symbol;\n}\n\n/** Describes activity mode. */\nexport type ActivityMode = \"visible\" | \"hidden\";\n\n/** Describes activity props. */\nexport interface ActivityProps {\n mode: ActivityMode;\n children?: FigNode;\n}\n\n/** Describes Fig activity. */\nexport interface FigActivity {\n (props: ActivityProps): FigNode;\n readonly $$typeof: symbol;\n}\n\n/** Describes view transition class. */\nexport type ViewTransitionClass = \"auto\" | \"none\" | (string & {});\n\n/** Describes view transition phase. */\nexport type ViewTransitionPhase = \"enter\" | \"exit\" | \"share\" | \"update\";\n\n// Renderer-neutral identity for one named host surface in the native\n// transition. Renderer packages can resolve it into their own imperative\n// handles without putting host types in core.\n/** Describes view transition surface. */\nexport interface ViewTransitionSurface {\n readonly name: string;\n}\n\n/** Describes view transition event. */\nexport interface ViewTransitionEvent {\n readonly phase: ViewTransitionPhase;\n readonly surfaces: readonly ViewTransitionSurface[];\n readonly types: readonly string[];\n}\n\n/** Describes view transition callback. */\nexport type ViewTransitionCallback = (\n event: ViewTransitionEvent,\n signal: AbortSignal,\n) => undefined;\n\n/** Describes view transition props. */\nexport interface ViewTransitionProps {\n name?: string;\n children?: FigNode;\n default?: ViewTransitionClass;\n enter?: ViewTransitionClass;\n exit?: ViewTransitionClass;\n share?: ViewTransitionClass;\n update?: ViewTransitionClass;\n onTransition?: ViewTransitionCallback;\n}\n\n/** Describes Fig view transition. */\nexport interface FigViewTransition {\n (props: ViewTransitionProps): FigNode;\n readonly $$typeof: symbol;\n}\n\n/** Describes error boundary props. */\nexport interface ErrorBoundaryProps {\n // A function fallback receives the caught error so error UIs can render\n // it (message, retry affordance) without smuggling state above the\n // boundary through onError. Callable thenables are nodes, so the runtime\n // distinguishes them from render fallbacks before invoking the function.\n fallback?: FigNode | ((error: unknown, info: ErrorInfo) => FigNode);\n onError?: (error: unknown, info: ErrorInfo) => void;\n children?: FigNode;\n}\n\n/** Describes error info. */\nexport interface ErrorInfo {\n componentStack: string;\n dataResourceKeys?: DataResourceKey[];\n}\n\n/** Describes Fig error boundary. */\nexport interface FigErrorBoundary {\n (props: ErrorBoundaryProps): FigNode;\n readonly $$typeof: symbol;\n}\n\n/** Describes Fig assets. */\nexport interface FigAssets {\n (props: Props & { children?: FigNode }): FigNode;\n readonly $$typeof: symbol;\n}\n\n/** The fragment. */\nexport const Fragment = Symbol.for(\"fig.fragment\");\n/** The Fig element symbol. */\nexport const FigElementSymbol = Symbol.for(\"fig.element\");\n/** The Fig client reference symbol. */\nexport const FigClientReferenceSymbol = Symbol.for(\"fig.client-reference\");\n/** The Fig activity symbol. */\nexport const FigActivitySymbol = Symbol.for(\"fig.activity\");\n/** The Fig error boundary symbol. */\nexport const FigErrorBoundarySymbol = Symbol.for(\"fig.error-boundary\");\n/** The Fig portal symbol. */\nexport const FigPortalSymbol = Symbol.for(\"fig.portal\");\n/** The Fig assets symbol. */\nexport const FigAssetsSymbol = Symbol.for(\"fig.assets\");\n/** The Fig suspense symbol. */\nexport const FigSuspenseSymbol = Symbol.for(\"fig.suspense\");\n/** The Fig view transition symbol. */\nexport const FigViewTransitionSymbol = Symbol.for(\"fig.view-transition\");\n\n/** The assets. */\nexport const Assets: FigAssets = Object.assign(\n (props: Props & { children?: FigNode }) => props.children,\n { $$typeof: FigAssetsSymbol },\n);\n\n/** The error boundary. */\nexport const ErrorBoundary: FigErrorBoundary = Object.assign(\n (props: ErrorBoundaryProps) => props.children,\n { $$typeof: FigErrorBoundarySymbol },\n);\n\n/** The suspense. */\nexport const Suspense: FigSuspense = Object.assign(\n (props: SuspenseProps) => props.children,\n { $$typeof: FigSuspenseSymbol },\n);\n\n/** The activity. */\nexport const Activity: FigActivity = Object.assign(\n (props: ActivityProps) => props.children,\n { $$typeof: FigActivitySymbol },\n);\n\n/** The view transition. */\nexport const ViewTransition: FigViewTransition = Object.assign(\n (props: ViewTransitionProps) => props.children,\n { $$typeof: FigViewTransitionSymbol },\n);\n\n/** Creates element. */\nexport function createElement<P extends Props>(\n type: ElementType<P>,\n config?: (P & { key?: Key | null }) | null,\n ...children: FigNode[]\n): FigElement<P> {\n const props = { ...config } as P & {\n children?: FigNode;\n key?: Key | null;\n };\n const key = props.key ?? null;\n delete props.key;\n\n if (children.length === 1) props.children = children[0];\n else if (children.length > 1) props.children = children;\n\n return {\n $$typeof: FigElementSymbol,\n type,\n key,\n props:\n \"mix\" in props && typeof type === \"string\"\n ? resolveHostMix(type, props)\n : props,\n };\n}\n\n/** Checks whether valid element. */\nexport function isValidElement(value: unknown): value is FigElement {\n return hasObjectBrand(value, FigElementSymbol);\n}\n\n/** Creates portal node. */\nexport function createPortalNode<Target>(\n children: FigNode,\n target: Target,\n key: Key | null = null,\n): FigPortal<Target> {\n return { $$typeof: FigPortalSymbol, children, key, target };\n}\n\n/** Checks whether portal. */\nexport function isPortal(value: unknown): value is FigPortal {\n return hasObjectBrand(value, FigPortalSymbol);\n}\n\n/** Client reference. */\nexport function clientReference<P extends Props = Props>(\n options: ClientReferenceOptions<P>,\n): FigClientReference<P> {\n return Object.assign(\n (): never => {\n throw new Error(\n `Client reference \"${options.id}\" cannot be rendered on the server directly.`,\n );\n },\n {\n $$typeof: FigClientReferenceSymbol,\n assets: options.assets,\n id: options.id,\n ssr: options.ssr,\n },\n );\n}\n\n/** Lazy. */\nexport function lazy<T extends ComponentType<any>>(\n load: LazyLoader<T>,\n): ComponentType<ComponentProps<T>> {\n let promise: PromiseLike<T> | null = null;\n let rejected = false;\n\n const Lazy: ComponentType<ComponentProps<T>> = (props) => {\n if (promise === null) {\n rejected = false;\n const next = Promise.resolve(load()).then(\n (value) => value,\n (error) => {\n if (promise === next) rejected = true;\n throw error;\n },\n );\n promise = next;\n }\n\n try {\n return createElement(readPromise(promise), props);\n } catch (error) {\n if (rejected) {\n promise = null;\n rejected = false;\n }\n throw error;\n }\n };\n\n return Lazy;\n}\n\n/** Checks whether client reference. */\nexport function isClientReference(value: unknown): value is FigClientReference {\n return hasFunctionBrand(value, FigClientReferenceSymbol);\n}\n\n/** Checks whether suspense. */\nexport function isSuspense(value: unknown): value is FigSuspense {\n return hasFunctionBrand(value, FigSuspenseSymbol);\n}\n\n/** Checks whether activity. */\nexport function isActivity(value: unknown): value is FigActivity {\n return hasFunctionBrand(value, FigActivitySymbol);\n}\n\n/** Checks whether error boundary. */\nexport function isErrorBoundary(value: unknown): value is FigErrorBoundary {\n return hasFunctionBrand(value, FigErrorBoundarySymbol);\n}\n\n/** Checks whether view transition. */\nexport function isViewTransition(value: unknown): value is FigViewTransition {\n return hasFunctionBrand(value, FigViewTransitionSymbol);\n}\n\n/** Checks whether assets. */\nexport function isAssets(value: unknown): value is FigAssets {\n return hasFunctionBrand(value, FigAssetsSymbol);\n}\n\nfunction hasObjectBrand(value: unknown, brand: symbol): boolean {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"$$typeof\" in value &&\n value.$$typeof === brand\n );\n}\n\nfunction hasFunctionBrand(value: unknown, brand: symbol): boolean {\n return (\n typeof value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