@bgub/fig 0.1.0-alpha.2 → 0.1.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## @bgub/fig@0.1.0-alpha.3
2
+
3
+ ### Let Fig's Vite integration own runtime configuration
4
+
5
+ The new `fig()` Vite integration defines Fig's development gate and installs
6
+ Fast Refresh. TanStack Start composes it automatically, so applications no
7
+ longer need to configure Fig's compile-time mode or SSR package bundling
8
+ themselves.
9
+
10
+ `@bgub/fig-vite` now uses the application's Fig DOM renderer as a peer instead
11
+ of installing a private renderer copy.
12
+
13
+ The development gate follows Vite's command rather than its mode: serving
14
+ enables development behavior, while builds—including `--mode development`—strip
15
+ it from production output.
16
+
17
+ Published npm packages now expose development artifacts through a Fig-owned
18
+ condition, allowing the Vite integration to enable diagnostics and Fast Refresh
19
+ for ordinary installs while explicit static overrides remain authoritative and
20
+ default production imports retain their previous dead-code elimination. A
21
+ static `false` override also disables Fast Refresh instrumentation.
22
+
1
23
  ## @bgub/fig@0.1.0-alpha.2
2
24
 
3
25
  ### Preload eligible host images during server rendering
@@ -0,0 +1,314 @@
1
+ //#region src/data.ts
2
+ const LoadContextCapabilitiesSymbol = Symbol.for("fig.data-load-context");
3
+ function defineLoadContextCapabilities(context, capabilities) {
4
+ Object.defineProperty(context, LoadContextCapabilitiesSymbol, {
5
+ configurable: true,
6
+ enumerable: false,
7
+ value: capabilities
8
+ });
9
+ }
10
+ function loadContextCapabilities(context) {
11
+ return context[LoadContextCapabilitiesSymbol];
12
+ }
13
+ const objectDataErrors = /* @__PURE__ */ new WeakMap();
14
+ let currentDataStore = null;
15
+ function resolveCurrentDataStore(message = "Data resource APIs require a Fig data store.") {
16
+ if (currentDataStore === null) throw new Error(message);
17
+ return currentDataStore;
18
+ }
19
+ function setCurrentDataStore(store) {
20
+ const previousStore = currentDataStore;
21
+ currentDataStore = store;
22
+ return previousStore;
23
+ }
24
+ function markDataResourceError(error, key) {
25
+ if (!isAttributableError(error)) return;
26
+ let keys = objectDataErrors.get(error);
27
+ if (keys === void 0) {
28
+ keys = [];
29
+ objectDataErrors.set(error, keys);
30
+ }
31
+ if (keys.some((existing) => sameDataResourceKey(existing, key))) return;
32
+ keys.push(key);
33
+ }
34
+ function dataResourceKeysForError(error) {
35
+ if (!isAttributableError(error)) return void 0;
36
+ const keys = objectDataErrors.get(error);
37
+ return keys === void 0 || keys.length === 0 ? void 0 : [...keys];
38
+ }
39
+ function sameDataResourceKey(a, b) {
40
+ return a.length === b.length && a.every((value, index) => Object.is(value, b[index]));
41
+ }
42
+ function isAttributableError(value) {
43
+ return (typeof value === "object" || typeof value === "function") && value !== null;
44
+ }
45
+ //#endregion
46
+ //#region src/hooks.ts
47
+ let currentDispatcher = null;
48
+ function useState(initialState) {
49
+ return resolveDispatcher().useState(initialState);
50
+ }
51
+ /**
52
+ * Tracks state returned by a client-side action. The action receives the
53
+ * previous committed state first, then the runner's arguments, then an
54
+ * `AbortSignal` Fig appends (declare the trailing signal parameter — it also
55
+ * drives `Args` inference). Async actions run in a transition priority scope
56
+ * and keep `isPending` true until they settle.
57
+ *
58
+ * Runs are last-run-wins: starting a new run aborts the previous one's
59
+ * signal and retires it — a retired run's settlement (value or rejection)
60
+ * never touches state or pending. The signal also aborts on unmount and
61
+ * when an enclosing Activity hides.
62
+ */
63
+ function useActionState(action, initialState) {
64
+ return resolveDispatcher().useActionState(action, initialState);
65
+ }
66
+ function useId() {
67
+ return resolveDispatcher().useId();
68
+ }
69
+ function useDeferredValue(value, initialValue) {
70
+ return resolveDispatcher().useDeferredValue(value, initialValue, arguments.length > 1);
71
+ }
72
+ function useMemo(calculate, deps) {
73
+ return resolveDispatcher().useMemo(calculate, deps);
74
+ }
75
+ function useTransition() {
76
+ return resolveDispatcher().useTransition();
77
+ }
78
+ function useCallback(callback, deps) {
79
+ return resolveDispatcher().useMemo(() => callback, deps);
80
+ }
81
+ function useReactive(effect, deps) {
82
+ resolveDispatcher().useReactive(effect, deps);
83
+ }
84
+ function useBeforePaint(effect, deps) {
85
+ resolveDispatcher().useBeforePaint(effect, deps);
86
+ }
87
+ function useBeforeLayout(effect, deps) {
88
+ resolveDispatcher().useBeforeLayout(effect, deps);
89
+ }
90
+ function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
91
+ return resolveDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
92
+ }
93
+ function useStableEvent(handler) {
94
+ return resolveDispatcher().useStableEvent(handler);
95
+ }
96
+ function readContext(context) {
97
+ return resolveDispatcher("readContext can only be called while rendering a component.").readContext(context);
98
+ }
99
+ function readPromise(promise) {
100
+ return resolveDispatcher("readPromise can only be called while rendering a component.").readPromise(promise);
101
+ }
102
+ function readData(resource, ...args) {
103
+ return resolveDispatcher("readData can only be called while rendering a component.").readData(resource, args);
104
+ }
105
+ function preloadData(resource, ...args) {
106
+ if (currentDispatcher !== null) {
107
+ currentDispatcher.preloadData(resource, args);
108
+ return;
109
+ }
110
+ resolveDataStore().preloadData(resource, ...args);
111
+ }
112
+ function setCurrentDispatcher(dispatcher) {
113
+ const previousDispatcher = currentDispatcher;
114
+ currentDispatcher = dispatcher;
115
+ return previousDispatcher;
116
+ }
117
+ function resolveDispatcher(message = "Hooks can only be called while rendering a component.") {
118
+ if (currentDispatcher === null) throw new Error(message);
119
+ return currentDispatcher;
120
+ }
121
+ function resolveDataStore() {
122
+ return resolveCurrentDataStore("No ambient Fig data store. Data APIs work synchronously during render, event handlers, actions, and effects — not after an await. Capture readDataStore() (or root.data) synchronously and call the handle instead.");
123
+ }
124
+ //#endregion
125
+ //#region src/mixin.ts
126
+ const FigMixinSymbol = Symbol.for("fig.mixin");
127
+ const FigMixinSlotSymbol = Symbol.for("fig.mixin-slot");
128
+ const FigClientOnlyHostBehaviorSymbol = Symbol.for("fig.client-only-host-behavior");
129
+ /** Creates a render-time host behavior for the `mix` prop. */
130
+ function createMixin(type) {
131
+ const descriptorType = guardMixinType(type);
132
+ return (...args) => ({
133
+ $$typeof: FigMixinSymbol,
134
+ args,
135
+ type: descriptorType
136
+ });
137
+ }
138
+ const maximumResolvedMixins = 1024;
139
+ function resolveHostMix(type, input) {
140
+ const props = input;
141
+ const mix = props.mix;
142
+ delete props.mix;
143
+ let resolvedMixins = 0;
144
+ function resolve(value, slot) {
145
+ if (emptyMixinValue(value)) return;
146
+ if (Array.isArray(value)) {
147
+ for (let index = 0; index < value.length; index += 1) resolve(value[index], `${slot}.${index}`);
148
+ return;
149
+ }
150
+ if (!isMixinDescriptor(value)) throw new Error(`The mix prop on <${type}> must contain descriptors created by createMixin().`);
151
+ resolvedMixins += 1;
152
+ if (resolvedMixins > maximumResolvedMixins) throw new Error(`The mix prop on <${type}> resolved more than ${maximumResolvedMixins} mixins.`);
153
+ const context = {
154
+ [FigMixinSlotSymbol]: slot,
155
+ props,
156
+ type
157
+ };
158
+ const result = value.type(context, ...value.args);
159
+ if (emptyMixinValue(result)) return;
160
+ if (isMixinDescriptor(result) || Array.isArray(result)) {
161
+ resolve(result, `${slot}.result`);
162
+ return;
163
+ }
164
+ if (typeof result !== "object") throw new Error(`A mixin on <${type}> must return host props, more mixins, or nothing.`);
165
+ const returnedProps = result;
166
+ if ("children" in returnedProps || "key" in returnedProps || "unsafeHTML" in returnedProps) throw new Error(`A mixin on <${type}> cannot return children, key, or unsafeHTML.`);
167
+ const { mix: nestedMix, ...patch } = returnedProps;
168
+ Object.assign(props, patch);
169
+ resolve(nestedMix, `${slot}.mix`);
170
+ }
171
+ resolve(mix, "0");
172
+ props.mix = mix;
173
+ return props;
174
+ }
175
+ function mixinSlot(context) {
176
+ return context[FigMixinSlotSymbol];
177
+ }
178
+ function markClientOnlyHostBehavior(context, behavior) {
179
+ if (context.props[FigClientOnlyHostBehaviorSymbol] !== void 0) return;
180
+ Object.defineProperty(context.props, FigClientOnlyHostBehaviorSymbol, {
181
+ configurable: true,
182
+ value: behavior
183
+ });
184
+ }
185
+ function clientOnlyHostBehavior(props) {
186
+ const behavior = props[FigClientOnlyHostBehaviorSymbol];
187
+ return typeof behavior === "string" ? behavior : void 0;
188
+ }
189
+ function emptyMixinValue(value) {
190
+ return value === false || value === 0 || value === 0n || value === "" || value === null || value === void 0;
191
+ }
192
+ function isMixinDescriptor(value) {
193
+ return typeof value === "object" && value !== null && "$$typeof" in value && value.$$typeof === FigMixinSymbol;
194
+ }
195
+ function guardMixinType(type) {
196
+ return (context, ...args) => {
197
+ const previousDispatcher = setCurrentDispatcher(mixinDispatcher(context.type, mixinSlot(context)));
198
+ try {
199
+ return type(context, ...args);
200
+ } finally {
201
+ setCurrentDispatcher(previousDispatcher);
202
+ }
203
+ };
204
+ }
205
+ function mixinDispatcher(type, slot) {
206
+ return new Proxy({}, { get(_target, property) {
207
+ throw new Error(`A mixin on <${type}> (slot ${slot}) called ${String(property)}. Mixins are pure render-time code: hooks and read verbs belong to the component; host lifetimes belong in returned on() or bind behavior.`);
208
+ } });
209
+ }
210
+ //#endregion
211
+ //#region src/element.ts
212
+ const Fragment = Symbol.for("fig.fragment");
213
+ const FigElementSymbol = Symbol.for("fig.element");
214
+ const FigClientReferenceSymbol = Symbol.for("fig.client-reference");
215
+ const FigActivitySymbol = Symbol.for("fig.activity");
216
+ const FigErrorBoundarySymbol = Symbol.for("fig.error-boundary");
217
+ const FigPortalSymbol = Symbol.for("fig.portal");
218
+ const FigAssetsSymbol = Symbol.for("fig.assets");
219
+ const FigSuspenseSymbol = Symbol.for("fig.suspense");
220
+ const FigViewTransitionSymbol = Symbol.for("fig.view-transition");
221
+ const Assets = Object.assign((props) => props.children, { $$typeof: FigAssetsSymbol });
222
+ const ErrorBoundary = Object.assign((props) => props.children, { $$typeof: FigErrorBoundarySymbol });
223
+ const Suspense = Object.assign((props) => props.children, { $$typeof: FigSuspenseSymbol });
224
+ const Activity = Object.assign((props) => props.children, { $$typeof: FigActivitySymbol });
225
+ const ViewTransition = Object.assign((props) => props.children, { $$typeof: FigViewTransitionSymbol });
226
+ function createElement(type, config, ...children) {
227
+ const props = { ...config };
228
+ const key = props.key ?? null;
229
+ delete props.key;
230
+ if (children.length === 1) props.children = children[0];
231
+ else if (children.length > 1) props.children = children;
232
+ return {
233
+ $$typeof: FigElementSymbol,
234
+ type,
235
+ key,
236
+ props: "mix" in props && typeof type === "string" ? resolveHostMix(type, props) : props
237
+ };
238
+ }
239
+ function isValidElement(value) {
240
+ return hasObjectBrand(value, FigElementSymbol);
241
+ }
242
+ function createPortalNode(children, target, key = null) {
243
+ return {
244
+ $$typeof: FigPortalSymbol,
245
+ children,
246
+ key,
247
+ target
248
+ };
249
+ }
250
+ function isPortal(value) {
251
+ return hasObjectBrand(value, FigPortalSymbol);
252
+ }
253
+ function clientReference(options) {
254
+ return Object.assign(() => {
255
+ throw new Error(`Client reference "${options.id}" cannot be rendered on the server directly.`);
256
+ }, {
257
+ $$typeof: FigClientReferenceSymbol,
258
+ assets: options.assets,
259
+ id: options.id,
260
+ ssr: options.ssr
261
+ });
262
+ }
263
+ function lazy(load) {
264
+ let promise = null;
265
+ let rejected = false;
266
+ const Lazy = (props) => {
267
+ if (promise === null) {
268
+ rejected = false;
269
+ const next = Promise.resolve(load()).then((value) => value, (error) => {
270
+ if (promise === next) rejected = true;
271
+ throw error;
272
+ });
273
+ promise = next;
274
+ }
275
+ try {
276
+ return createElement(readPromise(promise), props);
277
+ } catch (error) {
278
+ if (rejected) {
279
+ promise = null;
280
+ rejected = false;
281
+ }
282
+ throw error;
283
+ }
284
+ };
285
+ return Lazy;
286
+ }
287
+ function isClientReference(value) {
288
+ return hasFunctionBrand(value, FigClientReferenceSymbol);
289
+ }
290
+ function isSuspense(value) {
291
+ return hasFunctionBrand(value, FigSuspenseSymbol);
292
+ }
293
+ function isActivity(value) {
294
+ return hasFunctionBrand(value, FigActivitySymbol);
295
+ }
296
+ function isErrorBoundary(value) {
297
+ return hasFunctionBrand(value, FigErrorBoundarySymbol);
298
+ }
299
+ function isViewTransition(value) {
300
+ return hasFunctionBrand(value, FigViewTransitionSymbol);
301
+ }
302
+ function isAssets(value) {
303
+ return hasFunctionBrand(value, FigAssetsSymbol);
304
+ }
305
+ function hasObjectBrand(value, brand) {
306
+ return typeof value === "object" && value !== null && "$$typeof" in value && value.$$typeof === brand;
307
+ }
308
+ function hasFunctionBrand(value, brand) {
309
+ return typeof value === "function" && "$$typeof" in value && value.$$typeof === brand;
310
+ }
311
+ //#endregion
312
+ export { loadContextCapabilities as $, markClientOnlyHostBehavior as A, useBeforePaint as B, isSuspense as C, FigMixinSymbol as D, lazy as E, readData as F, useReactive as G, useDeferredValue as H, readPromise as I, useSyncExternalStore as J, useStableEvent as K, setCurrentDispatcher as L, resolveHostMix as M, preloadData as N, clientOnlyHostBehavior as O, readContext as P, isAttributableError as Q, useActionState as R, isPortal as S, isViewTransition as T, useId as U, useCallback as V, useMemo as W, dataResourceKeysForError as X, useTransition as Y, defineLoadContextCapabilities as Z, createPortalNode as _, FigAssetsSymbol as a, isClientReference as b, FigErrorBoundarySymbol as c, FigViewTransitionSymbol as d, markDataResourceError as et, Fragment as f, createElement as g, clientReference as h, FigActivitySymbol as i, mixinSlot as j, createMixin as k, FigPortalSymbol as l, ViewTransition as m, Assets as n, setCurrentDataStore as nt, FigClientReferenceSymbol as o, Suspense as p, useState as q, ErrorBoundary as r, FigElementSymbol as s, Activity as t, resolveCurrentDataStore as tt, FigSuspenseSymbol as u, isActivity as v, isValidElement as w, isErrorBoundary as x, isAssets as y, useBeforeLayout as z };
313
+
314
+ //# sourceMappingURL=element-B7mCQIMi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element-B7mCQIMi.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,GAAG;CAEjE,KAAK,KAAK,GAAG;AACf;AAEA,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,GA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AwB;AACzD;AAEA,SAAgB,WAAW,OAAsC;CAC/D,OAAO,iBAAiB,OAAO,iBAAiB;AAClD;AAEA,SAAgB,WAAW,OAAsC;CAC/D,OAAO,iBAAiB,OAAO,iBAAiB;AAClD;AAEA,SAAgB,gBAAgB,OAA2C;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,4 @@
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-B4XiOWAj.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-B7mCQIMi.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-CP2OynG0.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 };
@@ -0,0 +1,172 @@
1
+ import { _ as runWithDataStore, a as createRendererDataStore, b as isContext, i as createDataStore, m as normalizeDataResourceKey, o as currentDataStore, p as isDataStoreController, r as attachDataStore, t as setTransitionHandler, v as FigContextSymbol } from "./transition-B4XiOWAj.js";
2
+ import { $ as loadContextCapabilities, A as markClientOnlyHostBehavior, C as isSuspense, D as FigMixinSymbol, L as setCurrentDispatcher, M as resolveHostMix, O as clientOnlyHostBehavior, S as isPortal, T as isViewTransition, X as dataResourceKeysForError, Z as defineLoadContextCapabilities, _ as createPortalNode, a as FigAssetsSymbol, b as isClientReference, c as FigErrorBoundarySymbol, d as FigViewTransitionSymbol, et as markDataResourceError, i as FigActivitySymbol, j as mixinSlot, l as FigPortalSymbol, n as Assets, nt as setCurrentDataStore, o as FigClientReferenceSymbol, s as FigElementSymbol, tt as resolveCurrentDataStore, u as FigSuspenseSymbol, v as isActivity, w as isValidElement, x as isErrorBoundary, y as isAssets } from "./element-B7mCQIMi.js";
3
+ import { a as assetResourceKey, b as trackThenable, i as assetResourceHostAttributes, l as isFigAssetResource, m as preventAssetResourceHoist, n as assetResourceFromHostAttributes, r as assetResourceFromHostProps, s as clientReferenceAssets, t as assetResourceDestination, v as isThenable, y as readThenable } from "./resource-CP2OynG0.js";
4
+ import { _ as serializePayloadArray, b as serializePayloadSet, c as definePayloadGraphElement, d as encodePayloadValueWithGraph, g as rollbackPayloadGraph, h as jsonPayloadCodec, i as decodePayloadDataEntries, l as encodePayloadDataEntries, m as isPlainPayloadValue, n as checkpointPayloadGraph, o as decodePayloadValue, p as isPayloadSpecialModel, r as createPayloadGraphEncodeContext, t as assertPayloadCodecMatches, u as encodePayloadValue, v as serializePayloadMap, y as serializePayloadPlainObject } from "./payload-format-KTNaSI4h.js";
5
+ //#region src/children.ts
6
+ function collectChildren(node) {
7
+ const children = [];
8
+ collectChild(node, children);
9
+ return children;
10
+ }
11
+ function collectChild(node, children) {
12
+ if (Array.isArray(node)) {
13
+ for (const child of node) collectChild(child, children);
14
+ return;
15
+ }
16
+ if (node === null || node === void 0 || typeof node === "boolean") return;
17
+ if (typeof node === "string" || typeof node === "number") {
18
+ appendTextChild(children, String(node));
19
+ return;
20
+ }
21
+ if (isValidElement(node) || isPortal(node)) {
22
+ children.push(node);
23
+ return;
24
+ }
25
+ if (isThenable(node)) {
26
+ children.push(node);
27
+ return;
28
+ }
29
+ throw invalidChildError(node);
30
+ }
31
+ function appendTextChild(children, text) {
32
+ if (text === "") return;
33
+ const previous = children.at(-1);
34
+ if (typeof previous === "string") children[children.length - 1] = `${previous}${text}`;
35
+ else children.push(text);
36
+ }
37
+ function invalidChildError(value) {
38
+ return /* @__PURE__ */ new Error(`Invalid Fig child: ${describeInvalidChild(value)}. Render a string, number, element, promise, array, boolean, null, or undefined.`);
39
+ }
40
+ function describeInvalidChild(value) {
41
+ if (typeof value !== "object" || value === null) return typeof value;
42
+ const keys = Object.keys(value);
43
+ return keys.length === 0 ? "object" : `object with keys ${keys.join(", ")}`;
44
+ }
45
+ //#endregion
46
+ //#region src/dom-nesting.ts
47
+ const phrasingContainers = "|a|button|p|";
48
+ const scopeTerminators = "|applet|caption|desc|foreignobject|html|marquee|object|table|td|template|th|title|";
49
+ const pAutoClosingTags = "|address|article|aside|blockquote|center|details|dialog|dir|div|dl|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|main|menu|nav|ol|p|pre|section|table|ul|";
50
+ const headChildren = "|base|basefont|bgsound|link|meta|title|noscript|noframes|script|style|template|";
51
+ const specialTags = "|address|applet|area|article|aside|base|basefont|bgsound|blockquote|body|br|button|caption|center|col|colgroup|dd|details|dir|div|dl|dt|embed|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hgroup|hr|html|iframe|img|input|keygen|li|link|listing|main|marquee|menu|meta|nav|noembed|noframes|noscript|object|ol|p|param|plaintext|pre|script|section|select|source|style|summary|table|tbody|td|template|textarea|tfoot|th|thead|title|tr|track|ul|wbr|xmp|mi|mo|mn|ms|mtext|annotation-xml|foreignobject|desc|";
52
+ function validateInstanceNesting(type, ancestors) {
53
+ const child = normalizedTag(type);
54
+ const parent = ancestors[0] === void 0 ? null : normalizedTag(ancestors[0]);
55
+ if (parent !== null && !validWithParent(child, parent)) throw invalidNestingError(`<${child}> cannot be a child of <${parent}>.${hintFor(child, parent)}`);
56
+ const invalidAncestor = invalidAncestorFor(child, ancestors);
57
+ if (invalidAncestor !== null) throw invalidNestingError(`<${child}> cannot appear inside <${invalidAncestor}>.`);
58
+ }
59
+ function validateTextNesting(text, ancestors) {
60
+ if (!/[^ \t\n\r\f]/.test(text)) return;
61
+ const parent = ancestors[0] === void 0 ? null : normalizedTag(ancestors[0]);
62
+ if (parent === null || validTextWithParent(parent)) return;
63
+ throw invalidNestingError(`text cannot be a child of <${parent}>.`);
64
+ }
65
+ function validWithParent(child, parent) {
66
+ switch (parent) {
67
+ case "select": return child === "hr" || child === "option" || child === "optgroup" || child === "script" || child === "template";
68
+ case "optgroup": return child === "option";
69
+ case "option": return false;
70
+ case "tr": return child === "th" || child === "td" || scriptLike(child);
71
+ case "tbody":
72
+ case "thead":
73
+ case "tfoot": return child === "tr" || scriptLike(child);
74
+ case "colgroup": return child === "col" || child === "template";
75
+ case "table": return child === "caption" || child === "colgroup" || child === "tbody" || child === "tfoot" || child === "thead" || scriptLike(child);
76
+ case "head": return tagIn(headChildren, child);
77
+ case "html": return child === "head" || child === "body";
78
+ case "frameset": return child === "frame";
79
+ }
80
+ switch (child) {
81
+ case "caption":
82
+ case "col":
83
+ case "colgroup":
84
+ case "tbody":
85
+ case "tfoot":
86
+ case "thead":
87
+ case "tr": return parent === "template";
88
+ case "td":
89
+ case "th": return parent === "tr" || parent === "template";
90
+ case "option": return parent === "datalist" || parent === "template";
91
+ case "optgroup": return parent === "template";
92
+ case "head":
93
+ case "body":
94
+ case "frameset": return parent === "html" || parent === "template";
95
+ case "frame": return parent === "template";
96
+ case "html": return false;
97
+ }
98
+ return true;
99
+ }
100
+ function validTextWithParent(parent) {
101
+ return parent === "option" || parent === "select" || parent === "optgroup" || validWithParent("#text", parent);
102
+ }
103
+ function invalidAncestorFor(child, ancestors) {
104
+ let inScope = true;
105
+ let inButtonScope = true;
106
+ let inListScope = true;
107
+ let inTemplate = false;
108
+ for (const ancestorType of ancestors) {
109
+ const ancestor = normalizedTag(ancestorType);
110
+ if (child === ancestor && tagIn(phrasingContainers, child)) {
111
+ if (child === "p" ? inButtonScope : inScope) return ancestor;
112
+ }
113
+ if (inButtonScope && ancestor === "p" && tagIn(pAutoClosingTags, child)) return ancestor;
114
+ if (inListScope && listItemAncestor(child, ancestor)) return ancestor;
115
+ if (!inTemplate && ancestor === "form" && child === "form") return ancestor;
116
+ if (tagIn(scopeTerminators, ancestor)) {
117
+ if (ancestor === "template") inTemplate = true;
118
+ inScope = false;
119
+ inButtonScope = false;
120
+ } else if (ancestor === "button") inButtonScope = false;
121
+ if (tagIn(specialTags, ancestor) && ancestor !== "address" && ancestor !== "div" && ancestor !== "p") inListScope = false;
122
+ }
123
+ return null;
124
+ }
125
+ function listItemAncestor(child, ancestor) {
126
+ if (child === "li") return ancestor === "li";
127
+ if (child === "dd" || child === "dt") return ancestor === "dd" || ancestor === "dt";
128
+ return false;
129
+ }
130
+ function normalizedTag(type) {
131
+ return type.toLowerCase();
132
+ }
133
+ function scriptLike(tag) {
134
+ return tag === "script" || tag === "style" || tag === "template";
135
+ }
136
+ function hintFor(child, parent) {
137
+ if (parent === "table" && child === "tr") return " Add a <tbody>, <thead>, or <tfoot>.";
138
+ return "";
139
+ }
140
+ function invalidNestingError(message) {
141
+ return /* @__PURE__ */ new Error(`Invalid DOM nesting: ${message}`);
142
+ }
143
+ function tagIn(tags, tag) {
144
+ return tags.includes(`|${tag}|`);
145
+ }
146
+ //#endregion
147
+ //#region src/suspense-protocol.ts
148
+ const SUSPENSE_MARKER_PREFIX = "fig:suspense:";
149
+ const SUSPENSE_COMPLETED_MARKER = "fig:suspense:completed";
150
+ const SUSPENSE_CLIENT_MARKER = "fig:suspense:client";
151
+ const SUSPENSE_PENDING_PREFIX = "fig:suspense:pending:";
152
+ const SUSPENSE_END_MARKER = "/fig:suspense";
153
+ const TEXT_SEPARATOR_DATA = ",";
154
+ const ACTIVITY_TEMPLATE_ATTRIBUTE = "data-fig-activity";
155
+ const VIEW_TRANSITION_NAME_ATTRIBUTE = "data-fig-vt-name";
156
+ const VIEW_TRANSITION_CLASS_ATTRIBUTE = "data-fig-vt-class";
157
+ const VIEW_TRANSITION_PENDING_PROPERTY = "__figViewTransition";
158
+ const VIEW_TRANSITION_TIMEOUT_MS = 6e4;
159
+ const HYDRATION_SKIP_ATTRIBUTE = "data-fig-hydration-skip";
160
+ const EARLY_EVENT_QUEUE_PROPERTY = "__figEarlyEvents";
161
+ const EARLY_EVENT_HANDLER_PROPERTY = "__figEarlyEventHandler";
162
+ const REPLAYABLE_EVENT_TYPES = [
163
+ "click",
164
+ "keydown",
165
+ "keyup",
166
+ "pointerdown",
167
+ "pointerup"
168
+ ];
169
+ //#endregion
170
+ export { ACTIVITY_TEMPLATE_ATTRIBUTE, Assets, EARLY_EVENT_HANDLER_PROPERTY, EARLY_EVENT_QUEUE_PROPERTY, FigActivitySymbol, FigAssetsSymbol, FigClientReferenceSymbol, FigContextSymbol, FigElementSymbol, FigErrorBoundarySymbol, FigMixinSymbol, FigPortalSymbol, FigSuspenseSymbol, FigViewTransitionSymbol, HYDRATION_SKIP_ATTRIBUTE, REPLAYABLE_EVENT_TYPES, SUSPENSE_CLIENT_MARKER, SUSPENSE_COMPLETED_MARKER, SUSPENSE_END_MARKER, SUSPENSE_MARKER_PREFIX, SUSPENSE_PENDING_PREFIX, TEXT_SEPARATOR_DATA, VIEW_TRANSITION_CLASS_ATTRIBUTE, VIEW_TRANSITION_NAME_ATTRIBUTE, VIEW_TRANSITION_PENDING_PROPERTY, VIEW_TRANSITION_TIMEOUT_MS, assertPayloadCodecMatches, assetResourceDestination, assetResourceFromHostAttributes, assetResourceFromHostProps, 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 };
171
+
172
+ //# sourceMappingURL=internal.js.map