@bgub/fig 0.0.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.
@@ -0,0 +1,35 @@
1
+ import { a as DataResourceLoadContext, c as FigDataHydrationEntry, d as FigDataStoreHandle, f as FigDataStoreHost, g as setCurrentDataStore, h as resolveCurrentDataStore, i as DataResourceKeyInput, l as FigDataStore, m as markDataResourceError, n as DataResource, o as DataStoreEntrySnapshot, p as dataResourceKeysForError, r as DataResourceKey, s as FigDataEntryStatus, t as DataRefreshResult, u as FigDataStoreFactory } from "./data-CHJh_xU9.js";
2
+ import { $ as ClientReferenceAssets, A as LazyLoader, B as isActivity, C as FigSuspense, D as FigViewTransitionSymbol, E as FigViewTransition, F as ViewTransitionClass, G as isSuspense, H as isClientReference, I as ViewTransitionProps, K as isValidElement, N as SuspenseProps, S as FigPortalSymbol, T as FigText, U as isErrorBoundary, V as isAssets, W as isPortal, X as AssetResourceDestination, Z as AssetResourceHostAttribute, _ as FigElementSymbol, a as ClientReferenceOptions, b as FigNode, bt as isFigAssetResource, c as ErrorBoundaryProps, d as FigActivitySymbol, f as FigAssets, ft as assetResourceDestination, g as FigElement, gt as assetResourceKey, h as FigClientReferenceSymbol, ht as assetResourceHostAttributes, i as Assets, j as Props, k as Key, l as ErrorInfo, m as FigClientReference, mt as assetResourceFromHostProps, o as ElementType, p as FigAssetsSymbol, pt as assetResourceFromHostAttributes, q as isViewTransition, r as ActivityProps, u as FigActivity, v as FigErrorBoundary, vt as clientReferenceAssets, w as FigSuspenseSymbol, x as FigPortal, y as FigErrorBoundarySymbol } from "./element-CCOOi4Ka.js";
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";
5
+ //#region src/children.d.ts
6
+ type NormalizedChild = FigElement<any> | FigPortal<any> | string;
7
+ declare function collectChildren(node: FigNode): NormalizedChild[];
8
+ declare function invalidChildError(value: unknown): Error;
9
+ declare function describeInvalidChild(value: unknown): string;
10
+ //#endregion
11
+ //#region src/dom-nesting.d.ts
12
+ declare function validateInstanceNesting(type: string, ancestors: readonly string[]): void;
13
+ declare function validateTextNesting(text: string, ancestors: readonly string[]): void;
14
+ //#endregion
15
+ //#region src/suspense-protocol.d.ts
16
+ declare const SUSPENSE_MARKER_PREFIX = "fig:suspense:";
17
+ declare const SUSPENSE_COMPLETED_MARKER = "fig:suspense:completed";
18
+ declare const SUSPENSE_CLIENT_MARKER = "fig:suspense:client";
19
+ declare const SUSPENSE_PENDING_PREFIX = "fig:suspense:pending:";
20
+ declare const SUSPENSE_END_MARKER = "/fig:suspense";
21
+ declare const ACTIVITY_TEMPLATE_ATTRIBUTE = "data-fig-activity";
22
+ declare const VIEW_TRANSITION_NAME_ATTRIBUTE = "data-fig-vt-name";
23
+ declare const VIEW_TRANSITION_CLASS_ATTRIBUTE = "data-fig-vt-class";
24
+ declare const VIEW_TRANSITION_PENDING_PROPERTY = "__figViewTransition";
25
+ declare const EARLY_EVENT_QUEUE_PROPERTY = "__figEarlyEvents";
26
+ declare const EARLY_EVENT_HANDLER_PROPERTY = "__figEarlyEventHandler";
27
+ declare const REPLAYABLE_EVENT_TYPES: readonly ["click", "keydown", "keyup", "pointerdown", "pointerup"];
28
+ //#endregion
29
+ //#region src/thenables.d.ts
30
+ type Thenable<T = unknown> = PromiseLike<T> & object;
31
+ declare function trackThenable<T>(thenable: PromiseLike<T>): void;
32
+ declare function readThenable<T>(thenable: PromiseLike<T>): T;
33
+ declare function isThenable(value: unknown): value is Thenable;
34
+ //#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 FigText, type FigViewTransition, FigViewTransitionSymbol, type Key, type LazyLoader, type NormalizedChild, type Props, REPLAYABLE_EVENT_TYPES, type RenderDispatcher, SUSPENSE_CLIENT_MARKER, SUSPENSE_COMPLETED_MARKER, SUSPENSE_END_MARKER, SUSPENSE_MARKER_PREFIX, SUSPENSE_PENDING_PREFIX, type SuspenseProps, type Thenable, type TransitionHandler, VIEW_TRANSITION_CLASS_ATTRIBUTE, VIEW_TRANSITION_NAME_ATTRIBUTE, VIEW_TRANSITION_PENDING_PROPERTY, type ViewTransitionClass, type ViewTransitionProps, assetResourceDestination, assetResourceFromHostAttributes, assetResourceFromHostProps, assetResourceHostAttributes, assetResourceKey, clientReferenceAssets, collectChildren, createDataStore, currentDataStore, dataResourceKeysForError, describeInvalidChild, invalidChildError, isActivity, isAssets, isClientReference, isContext, isErrorBoundary, isFigAssetResource, isPortal, isSuspense, isThenable, isValidElement, isViewTransition, markDataResourceError, normalizeDataResourceKey, readThenable, resolveCurrentDataStore, runWithDataStore, setCurrentDataStore, setCurrentDispatcher, setTransitionHandler, trackThenable, validateInstanceNesting, validateTextNesting };
@@ -0,0 +1,200 @@
1
+ import { a as assetResourceFromHostProps, d as isFigAssetResource, i as assetResourceFromHostAttributes, l as clientReferenceAssets, o as assetResourceHostAttributes, r as assetResourceDestination, s as assetResourceKey, t as setTransitionHandler, x as isContext, y as FigContextSymbol } from "./transition-DEqcImne.js";
2
+ import { i as setCurrentDataStore, n as markDataResourceError, r as resolveCurrentDataStore, t as dataResourceKeysForError } from "./data-h46EcMnE.js";
3
+ import { c as normalizeDataResourceKey, d as runWithDataStore, n as currentDataStore, t as createDataStore } from "./data-store-CRnNAT9-.js";
4
+ import { C as isSuspense, S as isPortal, T as isViewTransition, a as FigAssetsSymbol, b as isClientReference, c as FigErrorBoundarySymbol, d as FigViewTransitionSymbol, i as FigActivitySymbol, j as setCurrentDispatcher, l as FigPortalSymbol, n as Assets, o as FigClientReferenceSymbol, s as FigElementSymbol, u as FigSuspenseSymbol, v as isActivity, w as isValidElement, x as isErrorBoundary, y as isAssets } from "./element-Bh_k9c3N.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
+ throw invalidChildError(node);
26
+ }
27
+ function appendTextChild(children, text) {
28
+ const previous = children.at(-1);
29
+ if (typeof previous === "string") children[children.length - 1] = `${previous}${text}`;
30
+ else children.push(text);
31
+ }
32
+ function invalidChildError(value) {
33
+ return /* @__PURE__ */ new Error(`Invalid Fig child: ${describeInvalidChild(value)}. Render a string, number, element, array, boolean, null, or undefined.`);
34
+ }
35
+ function describeInvalidChild(value) {
36
+ if (typeof value !== "object" || value === null) return typeof value;
37
+ const keys = Object.keys(value);
38
+ return keys.length === 0 ? "object" : `object with keys ${keys.join(", ")}`;
39
+ }
40
+ //#endregion
41
+ //#region src/dom-nesting.ts
42
+ const phrasingContainers = "|a|button|p|";
43
+ const scopeTerminators = "|applet|caption|desc|foreignobject|html|marquee|object|table|td|template|th|title|";
44
+ 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|";
45
+ const headChildren = "|base|basefont|bgsound|link|meta|title|noscript|noframes|script|style|template|";
46
+ 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|";
47
+ function validateInstanceNesting(type, ancestors) {
48
+ const child = normalizedTag(type);
49
+ const parent = ancestors[0] === void 0 ? null : normalizedTag(ancestors[0]);
50
+ if (parent !== null && !validWithParent(child, parent)) throw invalidNestingError(`<${child}> cannot be a child of <${parent}>.${hintFor(child, parent)}`);
51
+ const invalidAncestor = invalidAncestorFor(child, ancestors);
52
+ if (invalidAncestor !== null) throw invalidNestingError(`<${child}> cannot appear inside <${invalidAncestor}>.`);
53
+ }
54
+ function validateTextNesting(text, ancestors) {
55
+ if (!/[^ \t\n\r\f]/.test(text)) return;
56
+ const parent = ancestors[0] === void 0 ? null : normalizedTag(ancestors[0]);
57
+ if (parent === null || validTextWithParent(parent)) return;
58
+ throw invalidNestingError(`text cannot be a child of <${parent}>.`);
59
+ }
60
+ function validWithParent(child, parent) {
61
+ switch (parent) {
62
+ case "select": return child === "hr" || child === "option" || child === "optgroup" || child === "script" || child === "template";
63
+ case "optgroup": return child === "option";
64
+ case "option": return false;
65
+ case "tr": return child === "th" || child === "td" || scriptLike(child);
66
+ case "tbody":
67
+ case "thead":
68
+ case "tfoot": return child === "tr" || scriptLike(child);
69
+ case "colgroup": return child === "col" || child === "template";
70
+ case "table": return child === "caption" || child === "colgroup" || child === "tbody" || child === "tfoot" || child === "thead" || scriptLike(child);
71
+ case "head": return headChild(child);
72
+ case "html": return child === "head" || child === "body";
73
+ case "frameset": return child === "frame";
74
+ }
75
+ switch (child) {
76
+ case "caption":
77
+ case "col":
78
+ case "colgroup":
79
+ case "tbody":
80
+ case "tfoot":
81
+ case "thead":
82
+ case "tr": return parent === "template";
83
+ case "td":
84
+ case "th": return parent === "tr" || parent === "template";
85
+ case "option": return parent === "datalist" || parent === "template";
86
+ case "optgroup": return parent === "template";
87
+ case "head":
88
+ case "body":
89
+ case "frameset": return parent === "html" || parent === "template";
90
+ case "frame": return parent === "template";
91
+ case "html": return false;
92
+ }
93
+ return true;
94
+ }
95
+ function validTextWithParent(parent) {
96
+ return parent === "option" || parent === "select" || parent === "optgroup" || validWithParent("#text", parent);
97
+ }
98
+ function invalidAncestorFor(child, ancestors) {
99
+ let inScope = true;
100
+ let inButtonScope = true;
101
+ let inListScope = true;
102
+ let inTemplate = false;
103
+ for (const ancestorType of ancestors) {
104
+ const ancestor = normalizedTag(ancestorType);
105
+ if (child === ancestor && tagIn(phrasingContainers, child)) {
106
+ if (child === "p" ? inButtonScope : inScope) return ancestor;
107
+ }
108
+ if (inButtonScope && ancestor === "p" && tagIn(pAutoClosingTags, child)) return ancestor;
109
+ if (inListScope && listItemAncestor(child, ancestor)) return ancestor;
110
+ if (!inTemplate && ancestor === "form" && child === "form") return ancestor;
111
+ if (tagIn(scopeTerminators, ancestor)) {
112
+ if (ancestor === "template") inTemplate = true;
113
+ inScope = false;
114
+ inButtonScope = false;
115
+ } else if (ancestor === "button") inButtonScope = false;
116
+ if (tagIn(specialTags, ancestor) && ancestor !== "address" && ancestor !== "div" && ancestor !== "p") inListScope = false;
117
+ }
118
+ return null;
119
+ }
120
+ function listItemAncestor(child, ancestor) {
121
+ if (child === "li") return ancestor === "li";
122
+ if (child === "dd" || child === "dt") return ancestor === "dd" || ancestor === "dt";
123
+ return false;
124
+ }
125
+ function normalizedTag(type) {
126
+ return type.toLowerCase();
127
+ }
128
+ function scriptLike(tag) {
129
+ return tag === "script" || tag === "style" || tag === "template";
130
+ }
131
+ function headChild(tag) {
132
+ return tagIn(headChildren, tag);
133
+ }
134
+ function hintFor(child, parent) {
135
+ if (parent === "table" && child === "tr") return " Add a <tbody>, <thead>, or <tfoot>.";
136
+ return "";
137
+ }
138
+ function invalidNestingError(message) {
139
+ return /* @__PURE__ */ new Error(`Invalid DOM nesting: ${message}`);
140
+ }
141
+ function tagIn(tags, tag) {
142
+ return tags.includes(`|${tag}|`);
143
+ }
144
+ //#endregion
145
+ //#region src/suspense-protocol.ts
146
+ const SUSPENSE_MARKER_PREFIX = "fig:suspense:";
147
+ const SUSPENSE_COMPLETED_MARKER = "fig:suspense:completed";
148
+ const SUSPENSE_CLIENT_MARKER = "fig:suspense:client";
149
+ const SUSPENSE_PENDING_PREFIX = "fig:suspense:pending:";
150
+ const SUSPENSE_END_MARKER = "/fig:suspense";
151
+ const ACTIVITY_TEMPLATE_ATTRIBUTE = "data-fig-activity";
152
+ const VIEW_TRANSITION_NAME_ATTRIBUTE = "data-fig-vt-name";
153
+ const VIEW_TRANSITION_CLASS_ATTRIBUTE = "data-fig-vt-class";
154
+ const VIEW_TRANSITION_PENDING_PROPERTY = "__figViewTransition";
155
+ const EARLY_EVENT_QUEUE_PROPERTY = "__figEarlyEvents";
156
+ const EARLY_EVENT_HANDLER_PROPERTY = "__figEarlyEventHandler";
157
+ const REPLAYABLE_EVENT_TYPES = [
158
+ "click",
159
+ "keydown",
160
+ "keyup",
161
+ "pointerdown",
162
+ "pointerup"
163
+ ];
164
+ //#endregion
165
+ //#region src/thenables.ts
166
+ const thenableRecords = /* @__PURE__ */ new WeakMap();
167
+ function recordFor(thenable) {
168
+ const key = thenable;
169
+ let record = thenableRecords.get(key);
170
+ if (record === void 0) {
171
+ const pendingRecord = { status: "pending" };
172
+ record = pendingRecord;
173
+ thenableRecords.set(key, pendingRecord);
174
+ thenable.then((value) => {
175
+ pendingRecord.status = "fulfilled";
176
+ pendingRecord.value = value;
177
+ }, (reason) => {
178
+ pendingRecord.status = "rejected";
179
+ pendingRecord.reason = reason;
180
+ });
181
+ }
182
+ return record;
183
+ }
184
+ function trackThenable(thenable) {
185
+ recordFor(thenable);
186
+ }
187
+ function readThenable(thenable) {
188
+ const record = recordFor(thenable);
189
+ if (record.status === "fulfilled") return record.value;
190
+ if (record.status === "rejected") throw record.reason;
191
+ throw thenable;
192
+ }
193
+ function isThenable(value) {
194
+ if (typeof value !== "object" && typeof value !== "function" || value === null) return false;
195
+ return typeof value.then === "function";
196
+ }
197
+ //#endregion
198
+ export { ACTIVITY_TEMPLATE_ATTRIBUTE, Assets, EARLY_EVENT_HANDLER_PROPERTY, EARLY_EVENT_QUEUE_PROPERTY, FigActivitySymbol, FigAssetsSymbol, FigClientReferenceSymbol, FigContextSymbol, FigElementSymbol, FigErrorBoundarySymbol, FigPortalSymbol, FigSuspenseSymbol, FigViewTransitionSymbol, REPLAYABLE_EVENT_TYPES, SUSPENSE_CLIENT_MARKER, SUSPENSE_COMPLETED_MARKER, SUSPENSE_END_MARKER, SUSPENSE_MARKER_PREFIX, SUSPENSE_PENDING_PREFIX, VIEW_TRANSITION_CLASS_ATTRIBUTE, VIEW_TRANSITION_NAME_ATTRIBUTE, VIEW_TRANSITION_PENDING_PROPERTY, assetResourceDestination, assetResourceFromHostAttributes, assetResourceFromHostProps, assetResourceHostAttributes, assetResourceKey, clientReferenceAssets, collectChildren, createDataStore, currentDataStore, dataResourceKeysForError, describeInvalidChild, invalidChildError, isActivity, isAssets, isClientReference, isContext, isErrorBoundary, isFigAssetResource, isPortal, isSuspense, isThenable, isValidElement, isViewTransition, markDataResourceError, normalizeDataResourceKey, readThenable, resolveCurrentDataStore, runWithDataStore, setCurrentDataStore, setCurrentDispatcher, setTransitionHandler, trackThenable, validateInstanceNesting, validateTextNesting };
199
+
200
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","names":[],"sources":["../src/children.ts","../src/dom-nesting.ts","../src/suspense-protocol.ts","../src/thenables.ts"],"sourcesContent":["import {\n type FigElement,\n type FigNode,\n type FigPortal,\n isPortal,\n isValidElement,\n} from \"./element.ts\";\n\n// What normalization leaves behind: arrays are flattened, null/undefined/\n// booleans are dropped, and numbers are stringified into (merged) text.\nexport type NormalizedChild = FigElement<any> | FigPortal<any> | string;\n\n// Child normalization shared by the reconciler and the server renderer.\n// Adjacent text merging here MUST match on both sides: the server emits\n// merged text nodes into HTML, and hydration matches them against the\n// client's fiber children — divergence is a hydration mismatch.\nexport function collectChildren(node: FigNode): NormalizedChild[] {\n const children: NormalizedChild[] = [];\n collectChild(node, children);\n return children;\n}\n\nfunction collectChild(node: FigNode, children: NormalizedChild[]): void {\n if (Array.isArray(node)) {\n for (const child of node) collectChild(child, children);\n return;\n }\n\n if (node === null || node === undefined || typeof node === \"boolean\") return;\n\n if (typeof node === \"string\" || typeof node === \"number\") {\n appendTextChild(children, String(node));\n return;\n }\n\n if (isValidElement(node) || isPortal(node)) {\n children.push(node);\n return;\n }\n\n throw invalidChildError(node);\n}\n\nfunction appendTextChild(children: NormalizedChild[], text: string): void {\n const previous = children.at(-1);\n\n if (typeof previous === \"string\") {\n children[children.length - 1] = `${previous}${text}`;\n } else {\n children.push(text);\n }\n}\n\nexport function invalidChildError(value: unknown): Error {\n return new Error(\n `Invalid Fig child: ${describeInvalidChild(value)}. Render a string, number, element, array, boolean, null, or undefined.`,\n );\n}\n\nexport function describeInvalidChild(value: unknown): string {\n if (typeof value !== \"object\" || value === null) return typeof value;\n\n const keys = Object.keys(value);\n return keys.length === 0 ? \"object\" : `object with keys ${keys.join(\", \")}`;\n}\n","const phrasingContainers = \"|a|button|p|\";\n\n// HTML parser auto-close rules are scoped: these tags reset the \"is there an\n// open <a>/<button>/<p>?\" checks, so e.g. <a><table><td><a> and\n// <p><button><div> parse without re-parenting and must not be flagged.\n// <button> additionally terminates button scope (the <p> auto-close check).\nconst scopeTerminators =\n \"|applet|caption|desc|foreignobject|html|marquee|object|table|td|template|th|title|\";\n\nconst pAutoClosingTags =\n \"|address|article|aside|blockquote|center|details|dialog|dir|div|dl|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|main|menu|nav|ol|p|pre|section|table|ul|\";\n\nconst headChildren =\n \"|base|basefont|bgsound|link|meta|title|noscript|noframes|script|style|template|\";\n\nconst specialTags =\n \"|address|applet|area|article|aside|base|basefont|bgsound|blockquote|body|br|button|caption|center|col|colgroup|dd|details|dir|div|dl|dt|embed|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hgroup|hr|html|iframe|img|input|keygen|li|link|listing|main|marquee|menu|meta|nav|noembed|noframes|noscript|object|ol|p|param|plaintext|pre|script|section|select|source|style|summary|table|tbody|td|template|textarea|tfoot|th|thead|title|tr|track|ul|wbr|xmp|mi|mo|mn|ms|mtext|annotation-xml|foreignobject|desc|\";\n\nexport function validateInstanceNesting(\n type: string,\n ancestors: readonly string[],\n): void {\n const child = normalizedTag(type);\n const parent =\n ancestors[0] === undefined ? null : normalizedTag(ancestors[0]);\n\n if (parent !== null && !validWithParent(child, parent)) {\n throw invalidNestingError(\n `<${child}> cannot be a child of <${parent}>.${hintFor(child, parent)}`,\n );\n }\n\n const invalidAncestor = invalidAncestorFor(child, ancestors);\n if (invalidAncestor !== null) {\n throw invalidNestingError(\n `<${child}> cannot appear inside <${invalidAncestor}>.`,\n );\n }\n}\n\nexport function validateTextNesting(\n text: string,\n ancestors: readonly string[],\n): void {\n // Whitespace-only text is inserted in place even inside tables (\"in table\n // text\" mode only foster-parents non-whitespace), so it is harmless.\n if (!/[^ \\t\\n\\r\\f]/.test(text)) return;\n\n const parent =\n ancestors[0] === undefined ? null : normalizedTag(ancestors[0]);\n if (parent === null || validTextWithParent(parent)) return;\n\n throw invalidNestingError(`text cannot be a child of <${parent}>.`);\n}\n\nfunction validWithParent(child: string, parent: string): boolean {\n switch (parent) {\n case \"select\":\n return (\n child === \"hr\" ||\n child === \"option\" ||\n child === \"optgroup\" ||\n child === \"script\" ||\n child === \"template\"\n );\n case \"optgroup\":\n return child === \"option\";\n case \"option\":\n return false;\n case \"tr\":\n return child === \"th\" || child === \"td\" || scriptLike(child);\n case \"tbody\":\n case \"thead\":\n case \"tfoot\":\n return child === \"tr\" || scriptLike(child);\n case \"colgroup\":\n return child === \"col\" || child === \"template\";\n case \"table\":\n return (\n child === \"caption\" ||\n child === \"colgroup\" ||\n child === \"tbody\" ||\n child === \"tfoot\" ||\n child === \"thead\" ||\n scriptLike(child)\n );\n case \"head\":\n return headChild(child);\n case \"html\":\n return child === \"head\" || child === \"body\";\n case \"frameset\":\n return child === \"frame\";\n }\n\n switch (child) {\n case \"caption\":\n case \"col\":\n case \"colgroup\":\n case \"tbody\":\n case \"tfoot\":\n case \"thead\":\n case \"tr\":\n return parent === \"template\";\n case \"td\":\n case \"th\":\n return parent === \"tr\" || parent === \"template\";\n case \"option\":\n return parent === \"datalist\" || parent === \"template\";\n case \"optgroup\":\n return parent === \"template\";\n case \"head\":\n case \"body\":\n case \"frameset\":\n return parent === \"html\" || parent === \"template\";\n case \"frame\":\n return parent === \"template\";\n case \"html\":\n return false;\n }\n\n return true;\n}\n\nfunction validTextWithParent(parent: string): boolean {\n // <option>, <select>, and <optgroup> reject element children, but the\n // parser inserts character tokens into them in place, so text is legal.\n return (\n parent === \"option\" ||\n parent === \"select\" ||\n parent === \"optgroup\" ||\n validWithParent(\"#text\", parent)\n );\n}\n\nfunction invalidAncestorFor(\n child: string,\n ancestors: readonly string[],\n): string | null {\n let inScope = true;\n let inButtonScope = true;\n let inListScope = true;\n let inTemplate = false;\n\n for (const ancestorType of ancestors) {\n const ancestor = normalizedTag(ancestorType);\n\n if (child === ancestor && tagIn(phrasingContainers, child)) {\n if (child === \"p\" ? inButtonScope : inScope) return ancestor;\n }\n if (inButtonScope && ancestor === \"p\" && tagIn(pAutoClosingTags, child)) {\n return ancestor;\n }\n if (inListScope && listItemAncestor(child, ancestor)) return ancestor;\n // The parser's form element pointer ignores scope but resets in templates.\n if (!inTemplate && ancestor === \"form\" && child === \"form\") return ancestor;\n\n if (tagIn(scopeTerminators, ancestor)) {\n if (ancestor === \"template\") inTemplate = true;\n inScope = false;\n inButtonScope = false;\n } else if (ancestor === \"button\") {\n inButtonScope = false;\n }\n // li/dd/dt auto-closing sees through phrasing/formatting wrappers and\n // address/div/p; other special elements terminate the parser walk.\n if (\n tagIn(specialTags, ancestor) &&\n ancestor !== \"address\" &&\n ancestor !== \"div\" &&\n ancestor !== \"p\"\n ) {\n inListScope = false;\n }\n }\n\n return null;\n}\n\nfunction listItemAncestor(child: string, ancestor: string): boolean {\n if (child === \"li\") return ancestor === \"li\";\n if (child === \"dd\" || child === \"dt\") {\n return ancestor === \"dd\" || ancestor === \"dt\";\n }\n return false;\n}\n\nfunction normalizedTag(type: string): string {\n return type.toLowerCase();\n}\n\nfunction scriptLike(tag: string): boolean {\n return tag === \"script\" || tag === \"style\" || tag === \"template\";\n}\n\nfunction headChild(tag: string): boolean {\n return tagIn(headChildren, tag);\n}\n\nfunction hintFor(child: string, parent: string): string {\n if (parent === \"table\" && child === \"tr\") {\n return \" Add a <tbody>, <thead>, or <tfoot>.\";\n }\n\n return \"\";\n}\n\nfunction invalidNestingError(message: string): Error {\n return new Error(`Invalid DOM nesting: ${message}`);\n}\n\nfunction tagIn(tags: string, tag: string): boolean {\n return tags.includes(`|${tag}|`);\n}\n","// The Suspense streaming wire format shared by the server renderer (which\n// emits these markers as HTML comments and interpolates them into the inline\n// reveal script) and fig-dom (which parses them into dehydrated boundaries).\n// Changing any value is a protocol change: server output and client parsing\n// must move together.\n\nexport const SUSPENSE_MARKER_PREFIX = \"fig:suspense:\";\nexport const SUSPENSE_COMPLETED_MARKER = \"fig:suspense:completed\";\nexport const SUSPENSE_CLIENT_MARKER = \"fig:suspense:client\";\nexport const SUSPENSE_PENDING_PREFIX = \"fig:suspense:pending:\";\nexport const SUSPENSE_END_MARKER = \"/fig:suspense\";\n\n// Hidden Activity content streams inside an inert template carrying this\n// attribute; the client treats such templates as dehydrated boundaries.\nexport const ACTIVITY_TEMPLATE_ATTRIBUTE = \"data-fig-activity\";\n\nexport const VIEW_TRANSITION_NAME_ATTRIBUTE = \"data-fig-vt-name\";\nexport const VIEW_TRANSITION_CLASS_ATTRIBUTE = \"data-fig-vt-class\";\n\n// Per-document mutex holding the currently running view transition. Client\n// commits and inline streaming reveals both check it and chain on the\n// previous transition's finished promise, so concurrent transitions never\n// skip each other's animations or clobber temporarily applied names.\nexport const VIEW_TRANSITION_PENDING_PROPERTY = \"__figViewTransition\";\n\n// Early-event capture: a tiny inline script at the top of a server-rendered\n// document queues replayable events that fire before the client bundle\n// executes. The first hydration root drains the queue, removes the capture\n// listeners, and replays claimed events through the standard replay path.\n// The event list must stay in sync with fig-dom's replayable set — a\n// discrete replay forces synchronous hydration of its target, which is what\n// makes pre-bundle clicks safe to honor.\nexport const EARLY_EVENT_QUEUE_PROPERTY = \"__figEarlyEvents\";\nexport const EARLY_EVENT_HANDLER_PROPERTY = \"__figEarlyEventHandler\";\nexport const REPLAYABLE_EVENT_TYPES = [\n \"click\",\n \"keydown\",\n \"keyup\",\n \"pointerdown\",\n \"pointerup\",\n] as const;\n","export type Thenable<T = unknown> = PromiseLike<T> & object;\n\ninterface ThenableRecord<T> {\n status: \"pending\" | \"fulfilled\" | \"rejected\";\n value?: T;\n reason?: unknown;\n}\n\n// One process-wide registry keyed by thenable identity: the reconciler's\n// readPromise, the server renderers' dispatchers, and preloaders all share\n// it, so suspend/settle semantics cannot drift between client and server.\nconst thenableRecords = new WeakMap<object, ThenableRecord<unknown>>();\n\nfunction recordFor<T>(thenable: PromiseLike<T>): ThenableRecord<T> {\n const key = thenable as Thenable<T>;\n let record = thenableRecords.get(key) as ThenableRecord<T> | undefined;\n\n if (record === undefined) {\n const pendingRecord: ThenableRecord<T> = { status: \"pending\" };\n record = pendingRecord;\n thenableRecords.set(key, pendingRecord);\n thenable.then(\n (value) => {\n pendingRecord.status = \"fulfilled\";\n pendingRecord.value = value;\n },\n (reason: unknown) => {\n pendingRecord.status = \"rejected\";\n pendingRecord.reason = reason;\n },\n );\n }\n\n return record;\n}\n\n// Starts tracking without reading. Preloaders call this when they begin a\n// load so that a thenable settled before its first render read resolves\n// synchronously instead of suspending for one retry beat.\nexport function trackThenable<T>(thenable: PromiseLike<T>): void {\n recordFor(thenable);\n}\n\nexport function readThenable<T>(thenable: PromiseLike<T>): T {\n const record = recordFor(thenable);\n if (record.status === \"fulfilled\") return record.value as T;\n if (record.status === \"rejected\") throw record.reason;\n throw thenable;\n}\n\nexport function isThenable(value: unknown): value is Thenable {\n if (\n (typeof value !== \"object\" && typeof value !== \"function\") ||\n value === null\n ) {\n return false;\n }\n\n return typeof (value as PromiseLike<unknown>).then === \"function\";\n}\n"],"mappings":";;;;;AAgBA,SAAgB,gBAAgB,MAAkC;CAChE,MAAM,WAA8B,CAAC;CACrC,aAAa,MAAM,QAAQ;CAC3B,OAAO;AACT;AAEA,SAAS,aAAa,MAAe,UAAmC;CACtE,IAAI,MAAM,QAAQ,IAAI,GAAG;EACvB,KAAK,MAAM,SAAS,MAAM,aAAa,OAAO,QAAQ;EACtD;CACF;CAEA,IAAI,SAAS,QAAQ,SAAS,KAAA,KAAa,OAAO,SAAS,WAAW;CAEtE,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;EACxD,gBAAgB,UAAU,OAAO,IAAI,CAAC;EACtC;CACF;CAEA,IAAI,eAAe,IAAI,KAAK,SAAS,IAAI,GAAG;EAC1C,SAAS,KAAK,IAAI;EAClB;CACF;CAEA,MAAM,kBAAkB,IAAI;AAC9B;A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;CACpC;CACA;CACA;CACA;CACA;AACF;;;AC7BA,MAAM,kCAAkB,IAAI,QAAyC;AAErE,SAAS,UAAa,UAA6C;CACjE,MAAM,MAAM;CACZ,IAAI,SAAS,gBAAgB,IAAI,GAAG;CAEpC,IAAI,WAAW,KAAA,GAAW;EACxB,MAAM,gBAAmC,EAAE,QAAQ,UAAU;EAC7D,SAAS;EACT,gBAAgB,IAAI,KAAK,aAAa;EACtC,SAAS,MACN,UAAU;GACT,cAAc,SAAS;GACvB,cAAc,QAAQ;EACxB,IACC,WAAoB;GACnB,cAAc,SAAS;GACvB,cAAc,SAAS;EACzB,CACF;CACF;CAEA,OAAO;AACT;AAKA,SAAgB,cAAiB,UAAgC;CAC/D,UAAU,QAAQ;AACpB;AAEA,SAAgB,aAAgB,UAA6B;CAC3D,MAAM,SAAS,UAAU,QAAQ;CACjC,IAAI,OAAO,WAAW,aAAa,OAAO,OAAO;CACjD,IAAI,OAAO,WAAW,YAAY,MAAM,OAAO;CAC/C,MAAM;AACR;AAEA,SAAgB,WAAW,OAAmC;CAC5D,IACG,OAAO,UAAU,YAAY,OAAO,UAAU,cAC/C,UAAU,MAEV,OAAO;CAGT,OAAO,OAAQ,MAA+B,SAAS;AACzD"}
@@ -0,0 +1,16 @@
1
+ import { O as Fragment, b as FigNode, g as FigElement, k as Key, o as ElementType } from "./element-CCOOi4Ka.js";
2
+ //#region src/jsx-runtime.d.ts
3
+ type JSXProps = Record<string, unknown>;
4
+ declare function jsx(type: ElementType, props: JSXProps | null, key?: string | number): FigElement;
5
+ declare namespace JSX {
6
+ type Element = FigNode;
7
+ interface ElementChildrenAttribute {
8
+ children: unknown;
9
+ }
10
+ interface IntrinsicAttributes {
11
+ key?: Key | null;
12
+ }
13
+ interface IntrinsicElements {}
14
+ }
15
+ //#endregion
16
+ export { Fragment, JSX, jsx, jsx as jsxDEV, jsx as jsxs };
@@ -0,0 +1,23 @@
1
+ import { f as Fragment, s as FigElementSymbol } from "./element-Bh_k9c3N.js";
2
+ //#region src/jsx-runtime.ts
3
+ function jsx(type, props, key) {
4
+ if (props !== null && "key" in props) {
5
+ const { key: propsKey, ...rest } = props;
6
+ return {
7
+ $$typeof: FigElementSymbol,
8
+ type,
9
+ key: key ?? propsKey ?? null,
10
+ props: rest
11
+ };
12
+ }
13
+ return {
14
+ $$typeof: FigElementSymbol,
15
+ type,
16
+ key: key ?? null,
17
+ props: props ?? {}
18
+ };
19
+ }
20
+ //#endregion
21
+ export { Fragment, jsx, jsx as jsxDEV, jsx as jsxs };
22
+
23
+ //# sourceMappingURL=jsx-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx-runtime.ts"],"sourcesContent":["import {\n type ElementType,\n type FigElement,\n FigElementSymbol,\n type FigNode,\n Fragment,\n type Key,\n} from \"./element.ts\";\n\ntype JSXProps = Record<string, unknown>;\n\nexport function jsx(\n type: ElementType,\n props: JSXProps | null,\n key?: string | number,\n): FigElement {\n if (props !== null && \"key\" in props) {\n const { key: propsKey, ...rest } = props;\n return {\n $$typeof: FigElementSymbol,\n type,\n key: key ?? (propsKey as Key | null | undefined) ?? null,\n props: rest,\n };\n }\n\n return {\n $$typeof: FigElementSymbol,\n type,\n key: key ?? null,\n props: props ?? {},\n };\n}\n\n// The automatic-runtime contract is exactly jsx/jsxs/jsxDEV/Fragment. jsxDEV\n// aliases jsx: the dev transform's extra arguments (isStaticChildren, source,\n// self) are ignored — Fig builds component stacks from fibers instead.\nexport { Fragment, jsx as jsxs, jsx as jsxDEV };\n\n// The JSX namespace TypeScript resolves under jsxImportSource: \"@bgub/fig\".\n// IntrinsicElements is deliberately empty here: host-prop vocabulary belongs\n// to renderers, so @bgub/fig-dom augments it with the DOM tag map (having\n// any fig-dom import in the program is enough — augmentations are global).\n// A compilation with no renderer types in scope rejects intrinsic tags.\nexport namespace JSX {\n // The type of a JSX expression, and what function components may return:\n // any renderable node (elements, strings, numbers, booleans, null, arrays).\n export type Element = FigNode;\n\n export interface ElementChildrenAttribute {\n children: unknown;\n }\n\n // Props every JSX element accepts beyond its own declared props.\n export interface IntrinsicAttributes {\n key?: Key | null;\n }\n\n export interface IntrinsicElements {}\n}\n"],"mappings":";;AAWA,SAAgB,IACd,MACA,OACA,KACY;CACZ,IAAI,UAAU,QAAQ,SAAS,OAAO;EACpC,MAAM,EAAE,KAAK,UAAU,GAAG,SAAS;EACnC,OAAO;GACL,UAAU;GACV;GACA,KAAK,OAAQ,YAAuC;GACpD,OAAO;EACT;CACF;CAEA,OAAO;EACL,UAAU;EACV;EACA,KAAK,OAAO;EACZ,OAAO,SAAS,CAAC;CACnB;AACF"}
@@ -0,0 +1,9 @@
1
+ import { a as DataResourceLoadContext, i as DataResourceKeyInput, n as DataResource, r as DataResourceKey } from "./data-CHJh_xU9.js";
2
+ import { t as DataResourceOptions } from "./data-store-EQOLQsW4.js";
3
+ //#region src/server.browser.d.ts
4
+ interface ServerDataResourceOptions<TArgs extends unknown[], TValue> extends DataResourceOptions<TArgs, TValue> {
5
+ load: (...argsAndContext: [...TArgs, DataResourceLoadContext]) => TValue | PromiseLike<TValue>;
6
+ }
7
+ declare function serverDataResource<TArgs extends unknown[], TValue>(_options: ServerDataResourceOptions<TArgs, TValue>): DataResource<TArgs, TValue>;
8
+ //#endregion
9
+ export { type DataResource, type DataResourceKey, type DataResourceKeyInput, type DataResourceLoadContext, serverDataResource };
@@ -0,0 +1,8 @@
1
+ //#region src/server.browser.ts
2
+ function serverDataResource(_options) {
3
+ throw new Error("serverDataResource may only be imported from server-only code. Configure the Fig data transform or use a server-only module.");
4
+ }
5
+ //#endregion
6
+ export { serverDataResource };
7
+
8
+ //# sourceMappingURL=server.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.browser.js","names":[],"sources":["../src/server.browser.ts"],"sourcesContent":["import type {\n DataResource,\n DataResourceKey,\n DataResourceKeyInput,\n DataResourceLoadContext,\n} from \"./data.ts\";\nimport type { DataResourceOptions } from \"./data-store.ts\";\n\ninterface ServerDataResourceOptions<\n TArgs extends unknown[],\n TValue,\n> extends DataResourceOptions<TArgs, TValue> {\n load: (\n ...argsAndContext: [...TArgs, DataResourceLoadContext]\n ) => TValue | PromiseLike<TValue>;\n}\n\nexport function serverDataResource<TArgs extends unknown[], TValue>(\n _options: ServerDataResourceOptions<TArgs, TValue>,\n): DataResource<TArgs, TValue> {\n throw new Error(\n \"serverDataResource may only be imported from server-only code. Configure the Fig data transform or use a server-only module.\",\n );\n}\n\nexport type {\n DataResource,\n DataResourceKey,\n DataResourceKeyInput,\n DataResourceLoadContext,\n};\n"],"mappings":";AAiBA,SAAgB,mBACd,UAC6B;CAC7B,MAAM,IAAI,MACR,8HACF;AACF"}
@@ -0,0 +1,9 @@
1
+ import { a as DataResourceLoadContext, i as DataResourceKeyInput, n as DataResource, r as DataResourceKey } from "./data-CHJh_xU9.js";
2
+ import { t as DataResourceOptions } from "./data-store-EQOLQsW4.js";
3
+ //#region src/server.d.ts
4
+ interface ServerDataResourceOptions<TArgs extends unknown[], TValue> extends DataResourceOptions<TArgs, TValue> {
5
+ load: (...argsAndContext: [...TArgs, DataResourceLoadContext]) => TValue | PromiseLike<TValue>;
6
+ }
7
+ declare function serverDataResource<TArgs extends unknown[], TValue>(options: ServerDataResourceOptions<TArgs, TValue>): DataResource<TArgs, TValue>;
8
+ //#endregion
9
+ export { type DataResource, type DataResourceKey, type DataResourceKeyInput, type DataResourceLoadContext, ServerDataResourceOptions, serverDataResource };
package/dist/server.js ADDED
@@ -0,0 +1,9 @@
1
+ import { r as dataResource } from "./data-store-CRnNAT9-.js";
2
+ //#region src/server.ts
3
+ function serverDataResource(options) {
4
+ return dataResource(options);
5
+ }
6
+ //#endregion
7
+ export { serverDataResource };
8
+
9
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import type {\n DataResource,\n DataResourceKey,\n DataResourceKeyInput,\n DataResourceLoadContext,\n} from \"./data.ts\";\nimport { type DataResourceOptions, dataResource } from \"./data-store.ts\";\n\n// Same options as dataResource, but the server-only loader is required —\n// a load-less declaration belongs in a shared module as a key-only resource.\nexport interface ServerDataResourceOptions<\n TArgs extends unknown[],\n TValue,\n> extends DataResourceOptions<TArgs, TValue> {\n load: (\n ...argsAndContext: [...TArgs, DataResourceLoadContext]\n ) => TValue | PromiseLike<TValue>;\n}\n\nexport function serverDataResource<TArgs extends unknown[], TValue>(\n options: ServerDataResourceOptions<TArgs, TValue>,\n): DataResource<TArgs, TValue> {\n return dataResource(options);\n}\n\nexport type {\n DataResource,\n DataResourceKey,\n DataResourceKeyInput,\n DataResourceLoadContext,\n};\n"],"mappings":";;AAmBA,SAAgB,mBACd,SAC6B;CAC7B,OAAO,aAAa,OAAO;AAC7B"}
@@ -0,0 +1,96 @@
1
+ import { n as DataResource } from "./data-CHJh_xU9.js";
2
+ import { b as FigNode } from "./element-CCOOi4Ka.js";
3
+ //#region src/context.d.ts
4
+ interface FigContext<T> {
5
+ (props: {
6
+ value: T;
7
+ children?: FigNode;
8
+ }): FigNode;
9
+ readonly $$typeof: symbol;
10
+ readonly defaultValue: T;
11
+ }
12
+ declare const FigContextSymbol: unique symbol;
13
+ declare function createContext<T>(defaultValue: T): FigContext<T>;
14
+ declare function isContext(value: unknown): value is FigContext<unknown>;
15
+ //#endregion
16
+ //#region src/hooks.d.ts
17
+ type StateSetter<S> = (next: S | ((previous: S) => S)) => void;
18
+ type ExternalStoreSubscribe = (callback: () => void) => () => void;
19
+ type ActionStateAction<S, Args extends unknown[]> = (previousState: S, ...argsAndSignal: [...Args, AbortSignal]) => S | PromiseLike<S>;
20
+ type ActionStateRunner<Args extends unknown[]> = (...args: Args) => void;
21
+ /**
22
+ * Runs state updates scheduled by `callback` at transition priority. If
23
+ * `callback` returns a thenable, `useTransition` keeps `isPending` true until
24
+ * it settles and updates after an `await` remain in the transition priority
25
+ * scope.
26
+ *
27
+ * The callback receives an `AbortSignal` that aborts when a newer transition
28
+ * starts from the same hook, when the owning component unmounts, and when an
29
+ * enclosing Activity hides. Each `useTransition` hook is one cancellation
30
+ * domain — use separate hooks for independently cancellable workflows. An
31
+ * aborted run is retired: its pending slot is released immediately and its
32
+ * settlement (including an aborted fetch's rejection) is inert.
33
+ */
34
+ type StartTransition = (callback: (signal: AbortSignal) => void | PromiseLike<void>) => void;
35
+ type Callback = (...args: never[]) => unknown;
36
+ interface RenderDispatcher {
37
+ useState<S>(initialState: S | (() => S)): [S, StateSetter<S>];
38
+ useActionState<S, Args extends unknown[]>(action: ActionStateAction<S, Args>, initialState: S): [S, ActionStateRunner<Args>, boolean];
39
+ useId(): string;
40
+ useDeferredValue<T>(value: T, initialValue: T | undefined, hasInitialValue: boolean): T;
41
+ useMemo<T>(calculate: () => T, deps: DependencyList): T;
42
+ useTransition(): [boolean, StartTransition];
43
+ useReactive(effect: EffectCallback, deps?: DependencyList): void;
44
+ useBeforePaint(effect: EffectCallback, deps?: DependencyList): void;
45
+ useBeforeLayout(effect: EffectCallback, deps?: DependencyList): void;
46
+ useSyncExternalStore<T>(subscribe: ExternalStoreSubscribe, getSnapshot: () => T, getServerSnapshot?: () => T): T;
47
+ useStableEvent<Args extends unknown[], Result>(handler: (...args: Args) => Result): (...args: StableEventArgs<Args>) => Result;
48
+ readContext<T>(context: FigContext<T>): T;
49
+ readData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, args: TArgs): TValue;
50
+ preloadData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, args: TArgs): void;
51
+ readPromise<T>(promise: PromiseLike<T>): T;
52
+ }
53
+ type EffectCallback = (signal: AbortSignal) => undefined;
54
+ type DependencyList = readonly unknown[];
55
+ type StableEventArgs<Args extends unknown[]> = Args extends [...infer Rest, AbortSignal] ? Rest : Args;
56
+ declare function useState<S>(initialState: S | (() => S)): [S, StateSetter<S>];
57
+ /**
58
+ * Tracks state returned by a client-side action. The action receives the
59
+ * previous committed state first, then the runner's arguments, then an
60
+ * `AbortSignal` Fig appends (declare the trailing signal parameter — it also
61
+ * drives `Args` inference). Async actions run in a transition priority scope
62
+ * and keep `isPending` true until they settle.
63
+ *
64
+ * Runs are last-run-wins: starting a new run aborts the previous one's
65
+ * signal and retires it — a retired run's settlement (value or rejection)
66
+ * never touches state or pending. The signal also aborts on unmount and
67
+ * when an enclosing Activity hides.
68
+ */
69
+ declare function useActionState<S, Args extends unknown[]>(action: ActionStateAction<S, Args>, initialState: S): [S, ActionStateRunner<Args>, boolean];
70
+ declare function useId(): string;
71
+ declare function useDeferredValue<T>(value: T, initialValue?: T): T;
72
+ declare function useMemo<T>(calculate: () => T, deps: DependencyList): T;
73
+ declare function useTransition(): [boolean, StartTransition];
74
+ declare function useCallback<T extends Callback>(callback: T, deps: DependencyList): T;
75
+ declare function useReactive(effect: EffectCallback, deps?: DependencyList): void;
76
+ declare function useBeforePaint(effect: EffectCallback, deps?: DependencyList): void;
77
+ declare function useBeforeLayout(effect: EffectCallback, deps?: DependencyList): void;
78
+ declare function useSyncExternalStore<T>(subscribe: ExternalStoreSubscribe, getSnapshot: () => T, getServerSnapshot?: () => T): T;
79
+ declare function useStableEvent<Args extends unknown[], Result>(handler: (...args: Args) => Result): (...args: StableEventArgs<Args>) => Result;
80
+ declare function readContext<T>(context: FigContext<T>): T;
81
+ declare function readPromise<T>(promise: PromiseLike<T>): T;
82
+ declare function readData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): TValue;
83
+ declare function preloadData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): void;
84
+ declare function setCurrentDispatcher(dispatcher: RenderDispatcher | null): RenderDispatcher | null;
85
+ //#endregion
86
+ //#region src/transition.d.ts
87
+ type TransitionHandler = <T>(callback: () => T) => T;
88
+ /**
89
+ * Runs state updates scheduled by `callback` at transition priority. If
90
+ * `callback` returns a thenable, updates after an `await` remain in the
91
+ * transition priority scope until it settles.
92
+ */
93
+ declare function transition<T>(callback: () => T): T;
94
+ declare function setTransitionHandler(handler: TransitionHandler): TransitionHandler;
95
+ //#endregion
96
+ export { FigContext as A, useId as C, useState as D, useStableEvent as E, createContext as M, isContext as N, useSyncExternalStore as O, useDeferredValue as S, useReactive as T, setCurrentDispatcher as _, ActionStateRunner as a, useBeforePaint as b, ExternalStoreSubscribe as c, StartTransition as d, StateSetter as f, readPromise as g, readData as h, ActionStateAction as i, FigContextSymbol as j, useTransition as k, RenderDispatcher as l, readContext as m, setTransitionHandler as n, DependencyList as o, preloadData as p, transition as r, EffectCallback as s, TransitionHandler as t, StableEventArgs as u, useActionState as v, useMemo as w, useCallback as x, useBeforeLayout as y };