@bgub/fig 0.1.0-alpha.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +495 -0
- package/README.md +50 -19
- package/dist/element-BZ7r9ncY.d.ts +342 -0
- package/dist/element-DmbzNH0T.js +299 -0
- package/dist/element-DmbzNH0T.js.map +1 -0
- package/dist/hooks-QDRabULx.d.ts +158 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.js +4 -4
- package/dist/internal.d.ts +212 -6
- package/dist/internal.js +14 -43
- package/dist/internal.js.map +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +3 -3
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/payload-format-KTNaSI4h.js +366 -0
- package/dist/payload-format-KTNaSI4h.js.map +1 -0
- package/dist/payload.d.ts +92 -0
- package/dist/payload.js +429 -0
- package/dist/payload.js.map +1 -0
- package/dist/{transition-DEqcImne.js → resource-kXeIR52S.js} +121 -71
- package/dist/resource-kXeIR52S.js.map +1 -0
- package/dist/{data-store-CRnNAT9-.js → transition-CC4kjjrU.js} +165 -54
- package/dist/transition-CC4kjjrU.js.map +1 -0
- package/package.json +5 -6
- package/dist/data-CHJh_xU9.d.ts +0 -79
- package/dist/data-h46EcMnE.js +0 -37
- package/dist/data-h46EcMnE.js.map +0 -1
- package/dist/data-store-CRnNAT9-.js.map +0 -1
- package/dist/data-store-EQOLQsW4.d.ts +0 -32
- package/dist/element-Bh_k9c3N.js +0 -179
- package/dist/element-Bh_k9c3N.js.map +0 -1
- package/dist/element-CCOOi4Ka.d.ts +0 -209
- package/dist/server.browser.d.ts +0 -9
- package/dist/server.browser.js +0 -8
- package/dist/server.browser.js.map +0 -1
- package/dist/server.d.ts +0 -9
- package/dist/server.js +0 -9
- package/dist/server.js.map +0 -1
- package/dist/transition-Cl6mAPcx.d.ts +0 -96
- package/dist/transition-DEqcImne.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-DmbzNH0T.js","names":["runtimeType"],"sources":["../src/data.ts","../src/hooks.ts","../src/mixin.ts","../src/element.ts"],"sourcesContent":["export type DataResourceKeyInput =\n | string\n | number\n | boolean\n | null\n | readonly DataResourceKeyInput[]\n | { readonly [key: string]: DataResourceKeyInput };\n\nexport type DataResourceKey = readonly [string, ...DataResourceKeyInput[]];\n\nexport interface DataResourceLoadContext {\n signal: AbortSignal;\n}\n\nexport type DataResourceLoader<TArgs extends unknown[], TValue> = (\n ...argsAndContext: [...TArgs, DataResourceLoadContext]\n) => TValue | PromiseLike<TValue>;\n\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\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\nexport interface FigDataHydrationEntry {\n key: DataResourceKey;\n value: unknown;\n}\n\nexport type FigDataEntryStatus =\n | \"pending\"\n | \"fulfilled\"\n | \"rejected\"\n | \"refreshing\";\n\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.\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\nexport interface FigDataStoreOptions {\n initialData?: readonly FigDataHydrationEntry[];\n partition?: DataResourceKeyInput;\n}\n\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.\nexport interface FigDataStoreHost {\n getLane(): unknown;\n partition?: DataResourceKeyInput;\n schedule(owner: object, lane: unknown): void;\n}\n\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.\nexport type LoadContextHydrate = (\n entries: readonly FigDataHydrationEntry[],\n) => void;\nexport type LoadContextAttributeError = (error: unknown) => void;\n\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\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\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\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\nexport function setCurrentDataStore(\n store: FigDataStore | null,\n): FigDataStore | null {\n const previousStore = currentDataStore;\n currentDataStore = store;\n return previousStore;\n}\n\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\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.\nexport type StateSetter<S> = (next: S | ((previous: S) => S)) => void;\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.\nexport type ActionStateAction<S, Args extends unknown[]> = (\n previousState: S,\n ...argsAndSignal: [...Args, AbortSignal]\n) => S | PromiseLike<S>;\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\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\nexport type EffectCallback = (signal: AbortSignal) => undefined;\nexport type DependencyList = readonly unknown[];\n\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\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\nexport function useId(): string {\n return resolveDispatcher().useId();\n}\n\nexport function useDeferredValue<T>(value: T, initialValue?: T): T {\n return resolveDispatcher().useDeferredValue(\n value,\n initialValue,\n arguments.length > 1,\n );\n}\n\nexport function useMemo<T>(calculate: () => T, deps: DependencyList): T {\n return resolveDispatcher().useMemo(calculate, deps);\n}\n\nexport function useTransition(): [boolean, StartTransition] {\n return resolveDispatcher().useTransition();\n}\n\nexport function useCallback<T extends Callback>(\n callback: T,\n deps: DependencyList,\n): T {\n return resolveDispatcher().useMemo(() => callback, deps);\n}\n\nexport function useReactive(\n effect: EffectCallback,\n deps?: DependencyList,\n): void {\n resolveDispatcher().useReactive(effect, deps);\n}\n\nexport function useBeforePaint(\n effect: EffectCallback,\n deps?: DependencyList,\n): void {\n resolveDispatcher().useBeforePaint(effect, deps);\n}\n\nexport function useBeforeLayout(\n effect: EffectCallback,\n deps?: DependencyList,\n): void {\n resolveDispatcher().useBeforeLayout(effect, deps);\n}\n\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\nexport function useStableEvent<Args extends unknown[], Result>(\n handler: (...args: Args) => Result,\n): (...args: StableEventCallerArgs<Args>) => Result {\n return resolveDispatcher().useStableEvent(handler);\n}\n\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\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\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\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\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\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\nexport type EmptyMixinValue = false | 0 | 0n | \"\" | null | undefined;\n\nexport type MixinInput =\n | MixinDescriptor\n | EmptyMixinValue\n | ReadonlyArray<MixinInput>;\n\nexport type MixinResult = Props | MixinInput;\n\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\nexport interface MixinDescriptor {\n readonly $$typeof: symbol;\n readonly args: readonly unknown[];\n readonly type: MixinRuntimeType;\n}\n\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).\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\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\nexport function mixinSlot(context: MixinContext): string {\n return (context as MixinRuntimeContext)[FigMixinSlotSymbol];\n}\n\nexport function markClientOnlyHostBehavior(\n context: MixinContext,\n behavior: string,\n): void {\n const props = context.props as ClientOnlyHostProps;\n if (props[FigClientOnlyHostBehaviorSymbol] !== undefined) return;\n Object.defineProperty(context.props, FigClientOnlyHostBehaviorSymbol, {\n configurable: true,\n value: behavior,\n });\n}\n\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\nexport type Key = string | number;\nexport type Props = Record<string, any>;\nexport type ComponentType<P = Props> = (\n props: P & { children?: FigNode },\n) => FigNode;\nexport type ComponentProps<T extends ComponentType<any>> =\n Parameters<T> extends [infer P, ...unknown[]]\n ? P extends Props\n ? P\n : Props\n : {};\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>;\nexport type AwaitedFigNode =\n | FigElement<any>\n | FigPortal<any>\n | string\n | number\n | boolean\n | null\n | undefined\n | FigNode[];\nexport type FigNode = AwaitedFigNode | PromiseLike<AwaitedFigNode>;\n\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\nexport interface FigPortal<Target = unknown> {\n readonly $$typeof: symbol;\n readonly children: FigNode;\n readonly key: Key | null;\n readonly target: Target;\n}\n\nexport interface ClientReferenceOptions<P extends Props = Props> {\n assets?: ClientReferenceAssets;\n id: string;\n ssr?: ComponentType<P>;\n}\n\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\nexport type LazyLoader<T extends ComponentType<any> = ComponentType<any>> =\n () => PromiseLike<T>;\n\nexport interface SuspenseProps {\n fallback?: FigNode;\n children?: FigNode;\n}\n\nexport interface FigSuspense {\n (props: SuspenseProps): FigNode;\n readonly $$typeof: symbol;\n}\n\nexport type ActivityMode = \"visible\" | \"hidden\";\n\nexport interface ActivityProps {\n mode: ActivityMode;\n children?: FigNode;\n}\n\nexport interface FigActivity {\n (props: ActivityProps): FigNode;\n readonly $$typeof: symbol;\n}\n\nexport type ViewTransitionClass = \"auto\" | \"none\" | (string & {});\n\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.\nexport interface ViewTransitionSurface {\n readonly name: string;\n}\n\nexport interface ViewTransitionEvent {\n readonly phase: ViewTransitionPhase;\n readonly surfaces: readonly ViewTransitionSurface[];\n readonly types: readonly string[];\n}\n\nexport type ViewTransitionCallback = (\n event: ViewTransitionEvent,\n signal: AbortSignal,\n) => undefined;\n\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\nexport interface FigViewTransition {\n (props: ViewTransitionProps): FigNode;\n readonly $$typeof: symbol;\n}\n\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\nexport interface ErrorInfo {\n componentStack: string;\n dataResourceKeys?: DataResourceKey[];\n}\n\nexport interface FigErrorBoundary {\n (props: ErrorBoundaryProps): FigNode;\n readonly $$typeof: symbol;\n}\n\nexport interface FigAssets {\n (props: Props & { children?: FigNode }): FigNode;\n readonly $$typeof: symbol;\n}\n\nexport const Fragment = Symbol.for(\"fig.fragment\");\nexport const FigElementSymbol = Symbol.for(\"fig.element\");\nexport const FigClientReferenceSymbol = Symbol.for(\"fig.client-reference\");\nexport const FigActivitySymbol = Symbol.for(\"fig.activity\");\nexport const FigErrorBoundarySymbol = Symbol.for(\"fig.error-boundary\");\nexport const FigPortalSymbol = Symbol.for(\"fig.portal\");\nexport const FigAssetsSymbol = Symbol.for(\"fig.assets\");\nexport const FigSuspenseSymbol = Symbol.for(\"fig.suspense\");\nexport const FigViewTransitionSymbol = Symbol.for(\"fig.view-transition\");\n\nexport const Assets: FigAssets = Object.assign(\n (props: Props & { children?: FigNode }) => props.children,\n { $$typeof: FigAssetsSymbol },\n);\n\nexport const ErrorBoundary: FigErrorBoundary = Object.assign(\n (props: ErrorBoundaryProps) => props.children,\n { $$typeof: FigErrorBoundarySymbol },\n);\n\nexport const Suspense: FigSuspense = Object.assign(\n (props: SuspenseProps) => props.children,\n { $$typeof: FigSuspenseSymbol },\n);\n\nexport const Activity: FigActivity = Object.assign(\n (props: ActivityProps) => props.children,\n { $$typeof: FigActivitySymbol },\n);\n\nexport const ViewTransition: FigViewTransition = Object.assign(\n (props: ViewTransitionProps) => props.children,\n { $$typeof: FigViewTransitionSymbol },\n);\n\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\nexport function isValidElement(value: unknown): value is FigElement {\n return hasObjectBrand(value, FigElementSymbol);\n}\n\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\nexport function isPortal(value: unknown): value is FigPortal {\n return hasObjectBrand(value, FigPortalSymbol);\n}\n\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\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\nexport function isClientReference(value: unknown): value is FigClientReference {\n return hasFunctionBrand(value, FigClientReferenceSymbol);\n}\n\nexport function isSuspense(value: unknown): value is FigSuspense {\n return hasFunctionBrand(value, FigSuspenseSymbol);\n}\n\nexport function isActivity(value: unknown): value is FigActivity {\n return hasFunctionBrand(value, FigActivitySymbol);\n}\n\nexport function isErrorBoundary(value: unknown): value is FigErrorBoundary {\n return hasFunctionBrand(value, FigErrorBoundarySymbol);\n}\n\nexport function isViewTransition(value: unknown): value is FigViewTransition {\n return hasFunctionBrand(value, FigViewTransitionSymbol);\n}\n\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":";AAmKA,MAAM,gCAAgC,OAAO,IAAI,uBAAuB;AAKxE,SAAgB,8BACd,SACA,cACM;CACN,OAAO,eAAe,SAAS,+BAA+B;EAC5D,cAAc;EACd,YAAY;EACZ,OAAO;CACT,CAAC;AACH;AAEA,SAAgB,wBACd,SACqC;CACrC,OAAQ,QACN;AAEJ;AAEA,MAAM,mCAAmB,IAAI,QAAmC;AAEhE,IAAI,mBAAwC;AAE5C,SAAgB,wBACd,UAAU,gDACI;CACd,IAAI,qBAAqB,MAAM,MAAM,IAAI,MAAM,OAAO;CACtD,OAAO;AACT;AAEA,SAAgB,oBACd,OACqB;CACrB,MAAM,gBAAgB;CACtB,mBAAmB;CACnB,OAAO;AACT;AAEA,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,G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CACzE,OAAO,iBAAiB,OAAO,sBAAsB;AACvD;AAEA,SAAgB,iBAAiB,OAA4C;CAC3E,OAAO,iBAAiB,OAAO,uBAAuB;AACxD;AAEA,SAAgB,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"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { C as FigNode, Gt as FigDataStore, Ht as DataStoreEntrySnapshot, It as DataRefreshResult, Jt as FigDataStoreHandle, Kt as FigDataStoreController, Lt as DataResource, N as Props, Rt as DataResourceKey, Vt as DataResourceLoader, Wt as FigDataHydrationEntry, Xt as FigDataStoreOptions, Yt as FigDataStoreHost, zt as DataResourceKeyInput } from "./element-BZ7r9ncY.js";
|
|
2
|
+
//#region src/context.d.ts
|
|
3
|
+
interface FigContext<T> {
|
|
4
|
+
(props: {
|
|
5
|
+
value: T;
|
|
6
|
+
children?: FigNode;
|
|
7
|
+
}): FigNode;
|
|
8
|
+
readonly $$typeof: symbol;
|
|
9
|
+
readonly defaultValue: T;
|
|
10
|
+
}
|
|
11
|
+
declare const FigContextSymbol: unique symbol;
|
|
12
|
+
declare function createContext<T>(defaultValue: T): FigContext<T>;
|
|
13
|
+
declare function isContext(value: unknown): value is FigContext<unknown>;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/data-store.d.ts
|
|
16
|
+
interface DataResourceOptions<TArgs extends unknown[], TValue> {
|
|
17
|
+
key: (...args: TArgs) => DataResourceKey;
|
|
18
|
+
debugArgs?: (...args: TArgs) => DataResourceKeyInput;
|
|
19
|
+
load?: DataResourceLoader<TArgs, TValue>;
|
|
20
|
+
}
|
|
21
|
+
interface DataStoreHost<Owner extends object, Lane> {
|
|
22
|
+
getLane(): Lane;
|
|
23
|
+
inactiveRetentionMs?: number;
|
|
24
|
+
onEntryChange?: (entry: DataStoreEntrySnapshot) => void;
|
|
25
|
+
onEntryEvict?: (entry: DataStoreEntrySnapshot) => void;
|
|
26
|
+
partition?: DataResourceKeyInput;
|
|
27
|
+
preloadRetentionMs?: number;
|
|
28
|
+
schedule(owner: Owner, lane: Lane): void;
|
|
29
|
+
}
|
|
30
|
+
interface DataStore<Owner extends object = object, Lane = unknown> extends FigDataStore {
|
|
31
|
+
readonly host: DataStoreHost<Owner, Lane>;
|
|
32
|
+
}
|
|
33
|
+
declare function dataResource<TArgs extends unknown[], TValue>(options: DataResourceOptions<TArgs, TValue>): DataResource<TArgs, TValue>;
|
|
34
|
+
declare function ensureData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): Promise<TValue>;
|
|
35
|
+
declare function invalidateData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): void;
|
|
36
|
+
declare function invalidateDataError(error: unknown): boolean;
|
|
37
|
+
declare function invalidateDataKey(key: DataResourceKey): void;
|
|
38
|
+
declare function invalidateDataPrefix(prefix: DataResourceKey): void;
|
|
39
|
+
declare function refreshData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): Promise<DataRefreshResult<TValue>>;
|
|
40
|
+
declare function readDataStore(): FigDataStoreHandle;
|
|
41
|
+
declare function createDataStore(options?: FigDataStoreOptions): FigDataStoreController;
|
|
42
|
+
declare function isDataStoreController(value: unknown): value is FigDataStoreController;
|
|
43
|
+
declare function attachDataStore(controller: FigDataStoreController, host: FigDataStoreHost, initialData?: readonly FigDataHydrationEntry[]): FigDataStore;
|
|
44
|
+
declare function createRendererDataStore<Owner extends object, Lane>(host: DataStoreHost<Owner, Lane>): DataStore<Owner, Lane>;
|
|
45
|
+
declare function normalizeDataResourceKey(key: DataResourceKey): string;
|
|
46
|
+
declare function runWithDataStore<T>(store: FigDataStore, callback: () => T): T;
|
|
47
|
+
declare function currentDataStore(): FigDataStore;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/mixin.d.ts
|
|
50
|
+
interface MixinContext {
|
|
51
|
+
/** The intrinsic host name receiving this mixin. */
|
|
52
|
+
readonly type: string;
|
|
53
|
+
/** Props composed by the host and every preceding mixin. */
|
|
54
|
+
readonly props: Readonly<Props>;
|
|
55
|
+
}
|
|
56
|
+
type EmptyMixinValue = false | 0 | 0n | "" | null | undefined;
|
|
57
|
+
type MixinInput = MixinDescriptor | EmptyMixinValue | ReadonlyArray<MixinInput>;
|
|
58
|
+
type MixinResult = Props | MixinInput;
|
|
59
|
+
type MixinType<TArgs extends unknown[] = unknown[]> = (context: MixinContext, ...args: TArgs) => MixinResult;
|
|
60
|
+
type MixinRuntimeType = (context: MixinContext, ...args: unknown[]) => MixinResult;
|
|
61
|
+
interface MixinDescriptor {
|
|
62
|
+
readonly $$typeof: symbol;
|
|
63
|
+
readonly args: readonly unknown[];
|
|
64
|
+
readonly type: MixinRuntimeType;
|
|
65
|
+
}
|
|
66
|
+
type MixinFactory<TArgs extends unknown[]> = (...args: TArgs) => MixinDescriptor;
|
|
67
|
+
declare const FigMixinSymbol: unique symbol;
|
|
68
|
+
/** Creates a render-time host behavior for the `mix` prop. */
|
|
69
|
+
declare function createMixin<TArgs extends unknown[]>(type: MixinType<TArgs>): MixinFactory<TArgs>;
|
|
70
|
+
declare function resolveHostMix<P extends Props>(type: string, input: P): P;
|
|
71
|
+
declare function mixinSlot(context: MixinContext): string;
|
|
72
|
+
declare function markClientOnlyHostBehavior(context: MixinContext, behavior: string): void;
|
|
73
|
+
declare function clientOnlyHostBehavior(props: object): string | undefined;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/transition.d.ts
|
|
76
|
+
interface TransitionOptions {
|
|
77
|
+
types?: readonly string[];
|
|
78
|
+
}
|
|
79
|
+
type TransitionHandler = <T>(callback: () => T, options?: TransitionOptions) => T;
|
|
80
|
+
/**
|
|
81
|
+
* Runs state updates scheduled by `callback` at transition priority. If
|
|
82
|
+
* `callback` returns a thenable, updates after an `await` remain in the
|
|
83
|
+
* transition priority scope until it settles.
|
|
84
|
+
*/
|
|
85
|
+
declare function transition<T>(callback: () => T, options?: TransitionOptions): T;
|
|
86
|
+
declare function setTransitionHandler(handler: TransitionHandler): TransitionHandler;
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/hooks.d.ts
|
|
89
|
+
type StateSetter<S> = (next: S | ((previous: S) => S)) => void;
|
|
90
|
+
type ExternalStoreSubscribe = (callback: () => void) => () => void;
|
|
91
|
+
type ActionStateAction<S, Args extends unknown[]> = (previousState: S, ...argsAndSignal: [...Args, AbortSignal]) => S | PromiseLike<S>;
|
|
92
|
+
type ActionStateRunner<Args extends unknown[]> = (...args: Args) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Runs state updates scheduled by `callback` at transition priority. If
|
|
95
|
+
* `callback` returns a thenable, `useTransition` keeps `isPending` true until
|
|
96
|
+
* it settles and updates after an `await` remain in the transition priority
|
|
97
|
+
* scope.
|
|
98
|
+
*
|
|
99
|
+
* The callback receives an `AbortSignal` that aborts when a newer transition
|
|
100
|
+
* starts from the same hook, when the owning component unmounts, and when an
|
|
101
|
+
* enclosing Activity hides. Each `useTransition` hook is one cancellation
|
|
102
|
+
* domain — use separate hooks for independently cancellable workflows. An
|
|
103
|
+
* aborted run is retired: its pending slot is released immediately and its
|
|
104
|
+
* settlement (including an aborted fetch's rejection) is inert.
|
|
105
|
+
*/
|
|
106
|
+
type StartTransition = (callback: (signal: AbortSignal) => void | PromiseLike<void>, options?: TransitionOptions) => void;
|
|
107
|
+
type Callback = (...args: never[]) => unknown;
|
|
108
|
+
interface RenderDispatcher {
|
|
109
|
+
useState<S>(initialState: S | (() => S)): [S, StateSetter<S>];
|
|
110
|
+
useActionState<S, Args extends unknown[]>(action: ActionStateAction<S, Args>, initialState: S): [S, ActionStateRunner<Args>, boolean];
|
|
111
|
+
useId(): string;
|
|
112
|
+
useDeferredValue<T>(value: T, initialValue: T | undefined, hasInitialValue: boolean): T;
|
|
113
|
+
useMemo<T>(calculate: () => T, deps: DependencyList): T;
|
|
114
|
+
useTransition(): [boolean, StartTransition];
|
|
115
|
+
useReactive(effect: EffectCallback, deps?: DependencyList): void;
|
|
116
|
+
useBeforePaint(effect: EffectCallback, deps?: DependencyList): void;
|
|
117
|
+
useBeforeLayout(effect: EffectCallback, deps?: DependencyList): void;
|
|
118
|
+
useSyncExternalStore<T>(subscribe: ExternalStoreSubscribe, getSnapshot: () => T, getServerSnapshot?: () => T): T;
|
|
119
|
+
useStableEvent<Args extends unknown[], Result>(handler: (...args: Args) => Result): (...args: StableEventCallerArgs<Args>) => Result;
|
|
120
|
+
readContext<T>(context: FigContext<T>): T;
|
|
121
|
+
readData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, args: TArgs): TValue;
|
|
122
|
+
preloadData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, args: TArgs): void;
|
|
123
|
+
readPromise<T>(promise: PromiseLike<T>): T;
|
|
124
|
+
}
|
|
125
|
+
type EffectCallback = (signal: AbortSignal) => undefined;
|
|
126
|
+
type DependencyList = readonly unknown[];
|
|
127
|
+
type StableEventCallerArgs<Args extends unknown[]> = Args extends [...infer CallerArgs, AbortSignal] ? CallerArgs : Args;
|
|
128
|
+
declare function useState<S>(initialState: S | (() => S)): [S, StateSetter<S>];
|
|
129
|
+
/**
|
|
130
|
+
* Tracks state returned by a client-side action. The action receives the
|
|
131
|
+
* previous committed state first, then the runner's arguments, then an
|
|
132
|
+
* `AbortSignal` Fig appends (declare the trailing signal parameter — it also
|
|
133
|
+
* drives `Args` inference). Async actions run in a transition priority scope
|
|
134
|
+
* and keep `isPending` true until they settle.
|
|
135
|
+
*
|
|
136
|
+
* Runs are last-run-wins: starting a new run aborts the previous one's
|
|
137
|
+
* signal and retires it — a retired run's settlement (value or rejection)
|
|
138
|
+
* never touches state or pending. The signal also aborts on unmount and
|
|
139
|
+
* when an enclosing Activity hides.
|
|
140
|
+
*/
|
|
141
|
+
declare function useActionState<S, Args extends unknown[]>(action: ActionStateAction<S, Args>, initialState: S): [S, ActionStateRunner<Args>, boolean];
|
|
142
|
+
declare function useId(): string;
|
|
143
|
+
declare function useDeferredValue<T>(value: T, initialValue?: T): T;
|
|
144
|
+
declare function useMemo<T>(calculate: () => T, deps: DependencyList): T;
|
|
145
|
+
declare function useTransition(): [boolean, StartTransition];
|
|
146
|
+
declare function useCallback<T extends Callback>(callback: T, deps: DependencyList): T;
|
|
147
|
+
declare function useReactive(effect: EffectCallback, deps?: DependencyList): void;
|
|
148
|
+
declare function useBeforePaint(effect: EffectCallback, deps?: DependencyList): void;
|
|
149
|
+
declare function useBeforeLayout(effect: EffectCallback, deps?: DependencyList): void;
|
|
150
|
+
declare function useSyncExternalStore<T>(subscribe: ExternalStoreSubscribe, getSnapshot: () => T, getServerSnapshot?: () => T): T;
|
|
151
|
+
declare function useStableEvent<Args extends unknown[], Result>(handler: (...args: Args) => Result): (...args: StableEventCallerArgs<Args>) => Result;
|
|
152
|
+
declare function readContext<T>(context: FigContext<T>): T;
|
|
153
|
+
declare function readPromise<T>(promise: PromiseLike<T>): T;
|
|
154
|
+
declare function readData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): TValue;
|
|
155
|
+
declare function preloadData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): void;
|
|
156
|
+
declare function setCurrentDispatcher(dispatcher: RenderDispatcher | null): RenderDispatcher | null;
|
|
157
|
+
//#endregion
|
|
158
|
+
export { invalidateData as $, transition as A, createMixin as B, useStableEvent as C, TransitionHandler as D, useTransition as E, MixinFactory as F, DataStore as G, mixinSlot as H, MixinInput as I, createDataStore as J, DataStoreHost as K, MixinResult as L, FigMixinSymbol as M, MixinContext as N, TransitionOptions as O, MixinDescriptor as P, ensureData as Q, MixinType as R, useReactive as S, useSyncExternalStore as T, resolveHostMix as U, markClientOnlyHostBehavior as V, DataResourceOptions as W, currentDataStore as X, createRendererDataStore as Y, dataResource as Z, useBeforePaint as _, ExternalStoreSubscribe as a, readDataStore as at, useId as b, StartTransition as c, FigContext as ct, readContext as d, isContext as dt, invalidateDataError as et, readData as f, useBeforeLayout as g, useActionState as h, EffectCallback as i, normalizeDataResourceKey as it, EmptyMixinValue as j, setTransitionHandler as k, StateSetter as l, FigContextSymbol as lt, setCurrentDispatcher as m, ActionStateRunner as n, invalidateDataPrefix as nt, RenderDispatcher as o, refreshData as ot, readPromise as p, attachDataStore as q, DependencyList as r, isDataStoreController as rt, StableEventCallerArgs as s, runWithDataStore as st, ActionStateAction as t, invalidateDataKey as tt, preloadData as u, createContext as ut, useCallback as v, useState as w, useMemo as x, useDeferredValue as y, clientOnlyHostBehavior as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as
|
|
3
|
-
|
|
4
|
-
import { c as invalidateDataError, f as readDataStore, l as invalidateDataKey, o as dataResource, p as refreshData, s as invalidateData, t as DataResourceOptions, u as invalidateDataPrefix } from "./data-store-EQOLQsW4.js";
|
|
5
|
-
export { type ActionStateAction, type ActionStateRunner, Activity, type ActivityMode, type ActivityProps, type AssetResourceBlocking, type AssetsProps, type ClientReferenceAssets, type ClientReferenceOptions, type CrossOrigin, type DataRefreshResult, type DataResource, type DataResourceKey, type DataResourceKeyInput, type DataResourceLoadContext, type DataResourceOptions, type DependencyList, type EffectCallback, type ElementType, ErrorBoundary, type ErrorBoundaryProps, type ErrorInfo, type ExternalStoreSubscribe, type FetchPriority, type FigAssetResource, type FigAssetResourceList, type FigClientReference, type FigContext, type FigDataHydrationEntry, type FigDataStoreHandle, type FigElement, type FigNode, type FigPortal, type FigText, type FigViewTransition, type FontResource, Fragment, type Key, type LazyLoader, type MetaResource, type ModulePreloadResource, type PreconnectResource, type PreloadResource, type Props, type ScriptResource, type StableEventArgs, type StartTransition, type StateSetter, type StylesheetResource, Suspense, type SuspenseProps, type TitleResource, ViewTransition, type ViewTransitionClass, type ViewTransitionProps, assets, clientReference, clientReferenceAssets, createContext, createElement, createElement as h, createPortalNode, dataResource, font, invalidateData, invalidateDataError, invalidateDataKey, invalidateDataPrefix, isValidElement, lazy, meta, modulepreload, preconnect, preload, preloadData, readContext, readData, readDataStore, readPromise, refreshData, script, stylesheet, title, transition, useActionState, useBeforeLayout, useBeforePaint, useCallback, useDeferredValue, useId, useMemo, useReactive, useStableEvent, useState, useSyncExternalStore, useTransition };
|
|
1
|
+
import { A as Fragment, At as preconnect, B as ViewTransitionPhase, Bt as DataResourceLoadContext, C as FigNode, Et as font, F as SuspenseProps, Ft as title, H as ViewTransitionSurface, I as ViewTransition, It as DataRefreshResult, Jt as FigDataStoreHandle, Kt as FigDataStoreController, L as ViewTransitionCallback, Lt as DataResource, M as LazyLoader, N as Props, Nt as script, O as FigViewTransition, Ot as meta, P as Suspense, Pt as stylesheet, Q as isValidElement, R as ViewTransitionClass, Rt as DataResourceKey, U as clientReference, V as ViewTransitionProps, Vt as DataResourceLoader, W as createElement, Wt as FigDataHydrationEntry, Xt as FigDataStoreOptions, _ as FigClientReference, _t as StylesheetResource, a as AwaitedFigNode, at as ClientReferenceAssets, c as ComponentType, ct as FigAssetResource, d as ErrorBoundaryProps, dt as MetaResource, et as lazy, f as ErrorInfo, ft as MetaResourceOptions, gt as ScriptResource, ht as PreloadResource, it as AssetsProps, j as Key, jt as preload, kt as modulepreload, l as ElementType, lt as FigAssetResourceList, mt as PreconnectResource, n as ActivityMode, o as ClientReferenceOptions, ot as CrossOrigin, pt as ModulePreloadResource, r as ActivityProps, s as ComponentProps, st as FetchPriority, t as Activity, tt as AssetResourceBlocking, u as ErrorBoundary, ut as FontResource, vt as TitleResource, w as FigPortal, wt as assets, y as FigElement, z as ViewTransitionEvent, zt as DataResourceKeyInput } from "./element-BZ7r9ncY.js";
|
|
2
|
+
import { $ as invalidateData, A as transition, B as createMixin, C as useStableEvent, E as useTransition, F as MixinFactory, I as MixinInput, J as createDataStore, L as MixinResult, N as MixinContext, O as TransitionOptions, P as MixinDescriptor, Q as ensureData, R as MixinType, S as useReactive, T as useSyncExternalStore, W as DataResourceOptions, Z as dataResource, _ as useBeforePaint, a as ExternalStoreSubscribe, at as readDataStore, b as useId, c as StartTransition, ct as FigContext, d as readContext, et as invalidateDataError, f as readData, g as useBeforeLayout, h as useActionState, i as EffectCallback, j as EmptyMixinValue, l as StateSetter, n as ActionStateRunner, nt as invalidateDataPrefix, ot as refreshData, p as readPromise, r as DependencyList, t as ActionStateAction, tt as invalidateDataKey, u as preloadData, ut as createContext, v as useCallback, w as useState, x as useMemo, y as useDeferredValue } from "./hooks-QDRabULx.js";
|
|
3
|
+
export { type ActionStateAction, type ActionStateRunner, Activity, type ActivityMode, type ActivityProps, type AssetResourceBlocking, type AssetsProps, type AwaitedFigNode, type ClientReferenceAssets, type ClientReferenceOptions, type ComponentProps, type ComponentType, type CrossOrigin, type DataRefreshResult, type DataResource, type DataResourceKey, type DataResourceKeyInput, type DataResourceLoadContext, type DataResourceLoader, type DataResourceOptions, type DependencyList, type EffectCallback, type ElementType, type EmptyMixinValue, ErrorBoundary, type ErrorBoundaryProps, type ErrorInfo, type ExternalStoreSubscribe, type FetchPriority, type FigAssetResource, type FigAssetResourceList, type FigClientReference, type FigContext, type FigDataHydrationEntry, type FigDataStoreController, type FigDataStoreHandle, type FigDataStoreOptions, type FigElement, type FigNode, type FigPortal, type FigViewTransition, type FontResource, Fragment, type Key, type LazyLoader, type MetaResource, type MetaResourceOptions, type MixinContext, type MixinDescriptor, type MixinFactory, type MixinInput, type MixinResult, type MixinType, type ModulePreloadResource, type PreconnectResource, type PreloadResource, type Props, type ScriptResource, type StartTransition, type StateSetter, type StylesheetResource, Suspense, type SuspenseProps, type TitleResource, type TransitionOptions, ViewTransition, type ViewTransitionCallback, type ViewTransitionClass, type ViewTransitionEvent, type ViewTransitionPhase, type ViewTransitionProps, type ViewTransitionSurface, assets, clientReference, createContext, createDataStore, createElement, createMixin, dataResource, ensureData, font, invalidateData, invalidateDataError, invalidateDataKey, invalidateDataPrefix, isValidElement, lazy, meta, modulepreload, preconnect, preload, preloadData, readContext, readData, readDataStore, readPromise, refreshData, script, stylesheet, title, transition, useActionState, useBeforeLayout, useBeforePaint, useCallback, useDeferredValue, useId, useMemo, useReactive, useStableEvent, useState, useSyncExternalStore, useTransition };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export { Activity, ErrorBoundary, Fragment, Suspense, ViewTransition, assets, clientReference,
|
|
1
|
+
import { c as ensureData, d as invalidateDataKey, f as invalidateDataPrefix, g as refreshData, h as readDataStore, i as createDataStore, l as invalidateData, n as transition, s as dataResource, u as invalidateDataError, y as createContext } from "./transition-CC4kjjrU.js";
|
|
2
|
+
import { B as useBeforePaint, E as lazy, F as readData, G as useReactive, H as useDeferredValue, I as readPromise, J as useSyncExternalStore, K as useStableEvent, N as preloadData, P as readContext, R as useActionState, U as useId, V as useCallback, W as useMemo, Y as useTransition, f as Fragment, g as createElement, h as clientReference, k as createMixin, m as ViewTransition, p as Suspense, q as useState, r as ErrorBoundary, t as Activity, w as isValidElement, z as useBeforeLayout } from "./element-DmbzNH0T.js";
|
|
3
|
+
import { _ as title, c as font, d as modulepreload, f as preconnect, g as stylesheet, h as script, o as assets, p as preload, u as meta } from "./resource-kXeIR52S.js";
|
|
4
|
+
export { Activity, ErrorBoundary, Fragment, Suspense, ViewTransition, assets, clientReference, createContext, createDataStore, createElement, createMixin, dataResource, ensureData, font, invalidateData, invalidateDataError, invalidateDataKey, invalidateDataPrefix, isValidElement, lazy, meta, modulepreload, preconnect, preload, preloadData, readContext, readData, readDataStore, readPromise, refreshData, script, stylesheet, title, transition, useActionState, useBeforeLayout, useBeforePaint, useCallback, useDeferredValue, useId, useMemo, useReactive, useStableEvent, useState, useSyncExternalStore, useTransition };
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { A as FigContext, N as isContext, _ as setCurrentDispatcher, j as FigContextSymbol, l as RenderDispatcher, n as setTransitionHandler, t as TransitionHandler } from "./transition-Cl6mAPcx.js";
|
|
4
|
-
import { a as currentDataStore, d as normalizeDataResourceKey, i as createDataStore, m as runWithDataStore, n as DataStore, r as DataStoreHost } from "./data-store-EQOLQsW4.js";
|
|
1
|
+
import { $ as isViewTransition, $t as LoadContextHydrate, B as ViewTransitionPhase, Bt as DataResourceLoadContext, C as FigNode, Ct as assetResourceKey, D as FigSuspenseSymbol, Dt as isFigAssetResource, E as FigSuspense, F as SuspenseProps, G as createPortalNode, Gt as FigDataStore, H as ViewTransitionSurface, Ht as DataStoreEntrySnapshot, It as DataRefreshResult, J as isClientReference, Jt as FigDataStoreHandle, K as isActivity, Kt as FigDataStoreController, L as ViewTransitionCallback, Lt as DataResource, M as LazyLoader, Mt as preventAssetResourceHoist, N as Props, O as FigViewTransition, Qt as LoadContextCapabilities, R as ViewTransitionClass, Rt as DataResourceKey, S as FigErrorBoundarySymbol, St as assetResourceHostAttributes, T as FigPortalSymbol, Tt as clientReferenceAssets, Ut as FigDataEntryStatus, V as ViewTransitionProps, Wt as FigDataHydrationEntry, X as isPortal, Xt as FigDataStoreOptions, Y as isErrorBoundary, Yt as FigDataStoreHost, Z as isSuspense, Zt as LoadContextAttributeError, _ as FigClientReference, _t as StylesheetResource, a as AwaitedFigNode, an as setCurrentDataStore, at as ClientReferenceAssets, b as FigElementSymbol, bt as assetResourceFromHostAttributes, d as ErrorBoundaryProps, dt as MetaResource, en as dataResourceKeysForError, f as ErrorInfo, g as FigAssetsSymbol, gt as ScriptResource, h as FigAssets, ht as PreloadResource, i as Assets, in as resolveCurrentDataStore, j as Key, k as FigViewTransitionSymbol, l as ElementType, m as FigActivitySymbol, mt as PreconnectResource, nn as loadContextCapabilities, nt as AssetResourceDestination, o as ClientReferenceOptions, p as FigActivity, pt as ModulePreloadResource, q as isAssets, qt as FigDataStoreFactory, r as ActivityProps, rn as markDataResourceError, rt as AssetResourceHostAttribute, tn as defineLoadContextCapabilities, ut as FontResource, v as FigClientReferenceSymbol, vt as TitleResource, w as FigPortal, x as FigErrorBoundary, xt as assetResourceFromHostProps, y as FigElement, yt as assetResourceDestination, z as ViewTransitionEvent, zt as DataResourceKeyInput } from "./element-BZ7r9ncY.js";
|
|
2
|
+
import { D as TransitionHandler, G as DataStore, H as mixinSlot, J as createDataStore, K as DataStoreHost, M as FigMixinSymbol, O as TransitionOptions, U as resolveHostMix, V as markClientOnlyHostBehavior, X as currentDataStore, Y as createRendererDataStore, ct as FigContext, dt as isContext, it as normalizeDataResourceKey, k as setTransitionHandler, lt as FigContextSymbol, m as setCurrentDispatcher, o as RenderDispatcher, q as attachDataStore, rt as isDataStoreController, s as StableEventCallerArgs, st as runWithDataStore, z as clientOnlyHostBehavior } from "./hooks-QDRabULx.js";
|
|
5
3
|
//#region src/children.d.ts
|
|
6
|
-
type NormalizedChild = FigElement<any> | FigPortal<any> | string;
|
|
4
|
+
type NormalizedChild = FigElement<any> | FigPortal<any> | PromiseLike<AwaitedFigNode> | string;
|
|
7
5
|
declare function collectChildren(node: FigNode): NormalizedChild[];
|
|
8
6
|
declare function invalidChildError(value: unknown): Error;
|
|
9
7
|
declare function describeInvalidChild(value: unknown): string;
|
|
@@ -12,16 +10,224 @@ declare function describeInvalidChild(value: unknown): string;
|
|
|
12
10
|
declare function validateInstanceNesting(type: string, ancestors: readonly string[]): void;
|
|
13
11
|
declare function validateTextNesting(text: string, ancestors: readonly string[]): void;
|
|
14
12
|
//#endregion
|
|
13
|
+
//#region src/payload-format.d.ts
|
|
14
|
+
type SerializedAssetResource = {
|
|
15
|
+
crossorigin?: StylesheetResource["crossorigin"];
|
|
16
|
+
href: string;
|
|
17
|
+
kind: "stylesheet";
|
|
18
|
+
media?: string;
|
|
19
|
+
precedence?: string;
|
|
20
|
+
} | {
|
|
21
|
+
as: string;
|
|
22
|
+
crossorigin?: PreloadResource["crossorigin"];
|
|
23
|
+
fetchpriority?: PreloadResource["fetchpriority"];
|
|
24
|
+
href: string;
|
|
25
|
+
kind: "preload";
|
|
26
|
+
type?: string;
|
|
27
|
+
} | {
|
|
28
|
+
crossorigin?: ModulePreloadResource["crossorigin"];
|
|
29
|
+
fetchpriority?: ModulePreloadResource["fetchpriority"];
|
|
30
|
+
href: string;
|
|
31
|
+
kind: "modulepreload";
|
|
32
|
+
} | {
|
|
33
|
+
async?: boolean;
|
|
34
|
+
crossorigin?: ScriptResource["crossorigin"];
|
|
35
|
+
defer?: boolean;
|
|
36
|
+
kind: "script";
|
|
37
|
+
module?: boolean;
|
|
38
|
+
src: string;
|
|
39
|
+
} | {
|
|
40
|
+
crossorigin?: FontResource["crossorigin"];
|
|
41
|
+
fetchpriority?: FontResource["fetchpriority"];
|
|
42
|
+
href: string;
|
|
43
|
+
kind: "font";
|
|
44
|
+
type: string;
|
|
45
|
+
} | {
|
|
46
|
+
crossorigin?: PreconnectResource["crossorigin"];
|
|
47
|
+
href: string;
|
|
48
|
+
kind: "preconnect";
|
|
49
|
+
} | {
|
|
50
|
+
kind: "title";
|
|
51
|
+
value: TitleResource["value"];
|
|
52
|
+
} | {
|
|
53
|
+
charset?: MetaResource["charset"];
|
|
54
|
+
content?: MetaResource["content"];
|
|
55
|
+
"http-equiv"?: MetaResource["http-equiv"];
|
|
56
|
+
key?: string;
|
|
57
|
+
kind: "meta";
|
|
58
|
+
name?: MetaResource["name"];
|
|
59
|
+
property?: MetaResource["property"];
|
|
60
|
+
};
|
|
61
|
+
/** The `error` row value under the server's `onError` contract. */
|
|
62
|
+
interface PayloadErrorValue {
|
|
63
|
+
digest?: string;
|
|
64
|
+
message?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Semantic payload row before the internal codec turns it into bytes.
|
|
68
|
+
*/
|
|
69
|
+
type PayloadRow = {
|
|
70
|
+
for?: number;
|
|
71
|
+
tag: "assets";
|
|
72
|
+
value: SerializedAssetResource[];
|
|
73
|
+
} | {
|
|
74
|
+
id: number;
|
|
75
|
+
tag: "client";
|
|
76
|
+
value: {
|
|
77
|
+
id: string;
|
|
78
|
+
assets?: SerializedAssetResource[];
|
|
79
|
+
exportName?: string;
|
|
80
|
+
ssr?: true;
|
|
81
|
+
};
|
|
82
|
+
} | {
|
|
83
|
+
tag: "data";
|
|
84
|
+
value: PayloadDataHydrationEntry[];
|
|
85
|
+
} | {
|
|
86
|
+
id: number;
|
|
87
|
+
tag: "error";
|
|
88
|
+
value: PayloadErrorValue;
|
|
89
|
+
} | {
|
|
90
|
+
id: number;
|
|
91
|
+
tag: "model";
|
|
92
|
+
value: PayloadModel;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Transport-safe model value used inside internal payload rows. This is an
|
|
96
|
+
* implementation format, not an application data format.
|
|
97
|
+
*/
|
|
98
|
+
type PayloadModel = null | boolean | number | string | PayloadModel[] | {
|
|
99
|
+
[key: string]: PayloadModel;
|
|
100
|
+
} | PayloadElementModel | PayloadSpecialModel;
|
|
101
|
+
type PayloadElementModel = {
|
|
102
|
+
$fig: "element";
|
|
103
|
+
id?: number;
|
|
104
|
+
key: Key | null;
|
|
105
|
+
props: PayloadModel;
|
|
106
|
+
type: string | PayloadSpecialModel;
|
|
107
|
+
};
|
|
108
|
+
type PayloadSpecialModel = {
|
|
109
|
+
$fig: "array";
|
|
110
|
+
id: number;
|
|
111
|
+
value: PayloadModel[];
|
|
112
|
+
} | {
|
|
113
|
+
$fig: "bigint";
|
|
114
|
+
value: string;
|
|
115
|
+
} | {
|
|
116
|
+
$fig: "client";
|
|
117
|
+
id: number;
|
|
118
|
+
} | {
|
|
119
|
+
$fig: "date";
|
|
120
|
+
value: string;
|
|
121
|
+
} | {
|
|
122
|
+
$fig: "fragment";
|
|
123
|
+
} | {
|
|
124
|
+
$fig: "lazy";
|
|
125
|
+
id: number;
|
|
126
|
+
} | {
|
|
127
|
+
$fig: "map";
|
|
128
|
+
entries: Array<[PayloadModel, PayloadModel]>;
|
|
129
|
+
id: number;
|
|
130
|
+
} | {
|
|
131
|
+
$fig: "number";
|
|
132
|
+
value: "Infinity" | "-Infinity" | "-0" | "NaN";
|
|
133
|
+
} | {
|
|
134
|
+
$fig: "object";
|
|
135
|
+
id?: number;
|
|
136
|
+
value: Record<string, PayloadModel>;
|
|
137
|
+
} | {
|
|
138
|
+
$fig: "promise";
|
|
139
|
+
id: number;
|
|
140
|
+
} | {
|
|
141
|
+
$fig: "ref";
|
|
142
|
+
id: number;
|
|
143
|
+
} | {
|
|
144
|
+
$fig: "set";
|
|
145
|
+
id: number;
|
|
146
|
+
values: PayloadModel[];
|
|
147
|
+
} | {
|
|
148
|
+
$fig: "symbol";
|
|
149
|
+
key: string;
|
|
150
|
+
} | {
|
|
151
|
+
$fig: "suspense";
|
|
152
|
+
} | {
|
|
153
|
+
$fig: "undefined";
|
|
154
|
+
} | {
|
|
155
|
+
$fig: "view-transition";
|
|
156
|
+
};
|
|
157
|
+
type PayloadDataHydrationEntry = Omit<FigDataHydrationEntry, "value"> & {
|
|
158
|
+
value: PayloadModel;
|
|
159
|
+
};
|
|
160
|
+
interface PayloadCodec {
|
|
161
|
+
/**
|
|
162
|
+
* Opaque implementation id, e.g. "json" or "binary". Fig checks this id at
|
|
163
|
+
* transport boundaries; the encoded byte layout is not a public contract.
|
|
164
|
+
*/
|
|
165
|
+
readonly id: string;
|
|
166
|
+
readonly contentType: string;
|
|
167
|
+
/**
|
|
168
|
+
* Creates a streaming row decoder. The decoder calls `onRow` for each
|
|
169
|
+
* complete semantic row. If `onRow` throws, the decoder must propagate that
|
|
170
|
+
* error; when it can already see more complete sibling rows in the same
|
|
171
|
+
* input chunk, it should process those siblings before rethrowing so
|
|
172
|
+
* notifications already implied by earlier rows are not lost.
|
|
173
|
+
*/
|
|
174
|
+
createDecoder(onRow: (row: PayloadRow) => void): PayloadRowDecoder;
|
|
175
|
+
encodeRow(row: PayloadRow): Uint8Array;
|
|
176
|
+
}
|
|
177
|
+
interface PayloadRowDecoder {
|
|
178
|
+
decode(chunk: Uint8Array): void;
|
|
179
|
+
flush(): void;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Readable development-oriented codec: one JSON payload row per newline.
|
|
183
|
+
*/
|
|
184
|
+
declare const jsonPayloadCodec: PayloadCodec;
|
|
185
|
+
/**
|
|
186
|
+
* Throw when a response content-type declares a codec other than the one this
|
|
187
|
+
* client decodes with. A missing header or codec parameter passes: transports
|
|
188
|
+
* that strip content types stay usable, and mismatches still fail fast when
|
|
189
|
+
* declared.
|
|
190
|
+
*/
|
|
191
|
+
declare function assertPayloadCodecMatches(codec: PayloadCodec, contentTypeHeader: string | null): void;
|
|
192
|
+
interface PayloadGraphEncodeContext {
|
|
193
|
+
defined: object[];
|
|
194
|
+
ids: WeakMap<object, number>;
|
|
195
|
+
}
|
|
196
|
+
declare function createPayloadGraphEncodeContext(): PayloadGraphEncodeContext;
|
|
197
|
+
declare function isPlainPayloadValue(value: unknown): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Encode ordinary data values into PayloadModel. Server component references
|
|
200
|
+
* such as Fig elements, promises, and client references are handled by the
|
|
201
|
+
* payload renderer before ordinary values reach this helper.
|
|
202
|
+
*/
|
|
203
|
+
declare function encodePayloadValue(value: unknown): PayloadModel;
|
|
204
|
+
declare function encodePayloadValueWithGraph(value: unknown, graph: PayloadGraphEncodeContext): PayloadModel;
|
|
205
|
+
declare function serializePayloadMap(value: Map<unknown, unknown>, graph: PayloadGraphEncodeContext, encodeEntry: (entry: [unknown, unknown]) => [PayloadModel, PayloadModel]): PayloadModel;
|
|
206
|
+
declare function serializePayloadSet(value: Set<unknown>, graph: PayloadGraphEncodeContext, encodeItem: (value: unknown) => PayloadModel): PayloadModel;
|
|
207
|
+
declare function checkpointPayloadGraph(graph: PayloadGraphEncodeContext): number;
|
|
208
|
+
declare function rollbackPayloadGraph(graph: PayloadGraphEncodeContext, checkpoint: number): void;
|
|
209
|
+
declare function definePayloadGraphElement(graph: PayloadGraphEncodeContext, value: object): number | PayloadSpecialModel;
|
|
210
|
+
declare function serializePayloadArray<T>(value: object, graph: PayloadGraphEncodeContext, entries: () => readonly T[], encodeChild: (value: T) => PayloadModel): PayloadModel;
|
|
211
|
+
declare function serializePayloadPlainObject(value: object, graph: PayloadGraphEncodeContext, encodeChild: (value: unknown) => PayloadModel): PayloadModel;
|
|
212
|
+
/** Decode values produced by encodePayloadValue. */
|
|
213
|
+
declare function decodePayloadValue(model: PayloadModel): unknown;
|
|
214
|
+
declare function encodePayloadDataEntries(entries: readonly FigDataHydrationEntry[]): PayloadDataHydrationEntry[];
|
|
215
|
+
declare function decodePayloadDataEntries(entries: readonly PayloadDataHydrationEntry[]): FigDataHydrationEntry[];
|
|
216
|
+
declare function isPayloadSpecialModel(model: object): model is PayloadElementModel | PayloadSpecialModel;
|
|
217
|
+
//#endregion
|
|
15
218
|
//#region src/suspense-protocol.d.ts
|
|
16
219
|
declare const SUSPENSE_MARKER_PREFIX = "fig:suspense:";
|
|
17
220
|
declare const SUSPENSE_COMPLETED_MARKER = "fig:suspense:completed";
|
|
18
221
|
declare const SUSPENSE_CLIENT_MARKER = "fig:suspense:client";
|
|
19
222
|
declare const SUSPENSE_PENDING_PREFIX = "fig:suspense:pending:";
|
|
20
223
|
declare const SUSPENSE_END_MARKER = "/fig:suspense";
|
|
224
|
+
declare const TEXT_SEPARATOR_DATA = ",";
|
|
21
225
|
declare const ACTIVITY_TEMPLATE_ATTRIBUTE = "data-fig-activity";
|
|
22
226
|
declare const VIEW_TRANSITION_NAME_ATTRIBUTE = "data-fig-vt-name";
|
|
23
227
|
declare const VIEW_TRANSITION_CLASS_ATTRIBUTE = "data-fig-vt-class";
|
|
24
228
|
declare const VIEW_TRANSITION_PENDING_PROPERTY = "__figViewTransition";
|
|
229
|
+
declare const VIEW_TRANSITION_TIMEOUT_MS = 60000;
|
|
230
|
+
declare const HYDRATION_SKIP_ATTRIBUTE = "data-fig-hydration-skip";
|
|
25
231
|
declare const EARLY_EVENT_QUEUE_PROPERTY = "__figEarlyEvents";
|
|
26
232
|
declare const EARLY_EVENT_HANDLER_PROPERTY = "__figEarlyEventHandler";
|
|
27
233
|
declare const REPLAYABLE_EVENT_TYPES: readonly ["click", "keydown", "keyup", "pointerdown", "pointerup"];
|
|
@@ -32,4 +238,4 @@ declare function trackThenable<T>(thenable: PromiseLike<T>): void;
|
|
|
32
238
|
declare function readThenable<T>(thenable: PromiseLike<T>): T;
|
|
33
239
|
declare function isThenable(value: unknown): value is Thenable;
|
|
34
240
|
//#endregion
|
|
35
|
-
export { ACTIVITY_TEMPLATE_ATTRIBUTE, type ActivityProps, type AssetResourceDestination, type AssetResourceHostAttribute, Assets, type ClientReferenceAssets, type ClientReferenceOptions, type DataRefreshResult, type DataResource, type DataResourceKey, type DataResourceKeyInput, type DataResourceLoadContext, type DataStore, type DataStoreEntrySnapshot, type DataStoreHost, EARLY_EVENT_HANDLER_PROPERTY, EARLY_EVENT_QUEUE_PROPERTY, type ElementType, type ErrorBoundaryProps, type ErrorInfo, type FigActivity, FigActivitySymbol, type FigAssets, FigAssetsSymbol, type FigClientReference, FigClientReferenceSymbol, type FigContext, FigContextSymbol, type FigDataEntryStatus, type FigDataHydrationEntry, type FigDataStore, type FigDataStoreFactory, type FigDataStoreHandle, type FigDataStoreHost, type FigElement, FigElementSymbol, type FigErrorBoundary, FigErrorBoundarySymbol, type FigNode, type FigPortal, FigPortalSymbol, type FigSuspense, FigSuspenseSymbol, type
|
|
241
|
+
export { ACTIVITY_TEMPLATE_ATTRIBUTE, type ActivityProps, type AssetResourceDestination, type AssetResourceHostAttribute, Assets, type AwaitedFigNode, type ClientReferenceAssets, type ClientReferenceOptions, type DataRefreshResult, type DataResource, type DataResourceKey, type DataResourceKeyInput, type DataResourceLoadContext, type DataStore, type DataStoreEntrySnapshot, type DataStoreHost, EARLY_EVENT_HANDLER_PROPERTY, EARLY_EVENT_QUEUE_PROPERTY, type ElementType, type ErrorBoundaryProps, type ErrorInfo, type FigActivity, FigActivitySymbol, type FigAssets, FigAssetsSymbol, type FigClientReference, FigClientReferenceSymbol, type FigContext, FigContextSymbol, type FigDataEntryStatus, type FigDataHydrationEntry, type FigDataStore, type FigDataStoreController, type FigDataStoreFactory, type FigDataStoreHandle, type FigDataStoreHost, type FigDataStoreOptions, type FigElement, FigElementSymbol, type FigErrorBoundary, FigErrorBoundarySymbol, FigMixinSymbol, type FigNode, type FigPortal, FigPortalSymbol, type FigSuspense, FigSuspenseSymbol, type FigViewTransition, FigViewTransitionSymbol, HYDRATION_SKIP_ATTRIBUTE, type Key, type LazyLoader, type LoadContextAttributeError, type LoadContextCapabilities, type LoadContextHydrate, type NormalizedChild, type PayloadDataHydrationEntry, type PayloadElementModel, type PayloadGraphEncodeContext, type PayloadModel, type PayloadRow, type PayloadSpecialModel, type Props, REPLAYABLE_EVENT_TYPES, type RenderDispatcher, SUSPENSE_CLIENT_MARKER, SUSPENSE_COMPLETED_MARKER, SUSPENSE_END_MARKER, SUSPENSE_MARKER_PREFIX, SUSPENSE_PENDING_PREFIX, type SerializedAssetResource, type StableEventCallerArgs, type SuspenseProps, TEXT_SEPARATOR_DATA, type Thenable, type TransitionHandler, type TransitionOptions, VIEW_TRANSITION_CLASS_ATTRIBUTE, VIEW_TRANSITION_NAME_ATTRIBUTE, VIEW_TRANSITION_PENDING_PROPERTY, VIEW_TRANSITION_TIMEOUT_MS, type ViewTransitionCallback, type ViewTransitionClass, type ViewTransitionEvent, type ViewTransitionPhase, type ViewTransitionProps, type ViewTransitionSurface, assertPayloadCodecMatches, assetResourceDestination, assetResourceFromHostAttributes, assetResourceFromHostProps, assetResourceHostAttributes, assetResourceKey, attachDataStore, checkpointPayloadGraph, clientOnlyHostBehavior, clientReferenceAssets, collectChildren, createDataStore, createPayloadGraphEncodeContext, createPortalNode, createRendererDataStore, currentDataStore, dataResourceKeysForError, decodePayloadDataEntries, decodePayloadValue, defineLoadContextCapabilities, definePayloadGraphElement, describeInvalidChild, encodePayloadDataEntries, encodePayloadValue, encodePayloadValueWithGraph, invalidChildError, isActivity, isAssets, isClientReference, isContext, isDataStoreController, isErrorBoundary, isFigAssetResource, isPayloadSpecialModel, isPlainPayloadValue, isPortal, isSuspense, isThenable, isViewTransition, jsonPayloadCodec, loadContextCapabilities, markClientOnlyHostBehavior, markDataResourceError, mixinSlot, normalizeDataResourceKey, preventAssetResourceHoist, readThenable, resolveCurrentDataStore, resolveHostMix, rollbackPayloadGraph, runWithDataStore, serializePayloadArray, serializePayloadMap, serializePayloadPlainObject, serializePayloadSet, setCurrentDataStore, setCurrentDispatcher, setTransitionHandler, trackThenable, validateInstanceNesting, validateTextNesting };
|