@bgub/fig 0.0.1 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +501 -0
- package/README.md +50 -19
- package/dist/element-BZ7r9ncY.d.ts +342 -0
- package/dist/element-DmbzNH0T.js +299 -0
- package/dist/element-DmbzNH0T.js.map +1 -0
- package/dist/hooks-QDRabULx.d.ts +158 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.js +4 -4
- package/dist/internal.d.ts +212 -6
- package/dist/internal.js +14 -43
- package/dist/internal.js.map +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +3 -3
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/payload-format-KTNaSI4h.js +366 -0
- package/dist/payload-format-KTNaSI4h.js.map +1 -0
- package/dist/payload.d.ts +92 -0
- package/dist/payload.js +429 -0
- package/dist/payload.js.map +1 -0
- package/dist/{transition-DEqcImne.js → resource-kXeIR52S.js} +121 -71
- package/dist/resource-kXeIR52S.js.map +1 -0
- package/dist/{data-store-CRnNAT9-.js → transition-CC4kjjrU.js} +165 -54
- package/dist/transition-CC4kjjrU.js.map +1 -0
- package/package.json +5 -6
- package/dist/data-CHJh_xU9.d.ts +0 -79
- package/dist/data-h46EcMnE.js +0 -37
- package/dist/data-h46EcMnE.js.map +0 -1
- package/dist/data-store-CRnNAT9-.js.map +0 -1
- package/dist/data-store-EQOLQsW4.d.ts +0 -32
- package/dist/element-Bh_k9c3N.js +0 -179
- package/dist/element-Bh_k9c3N.js.map +0 -1
- package/dist/element-CCOOi4Ka.d.ts +0 -209
- package/dist/server.browser.d.ts +0 -9
- package/dist/server.browser.js +0 -8
- package/dist/server.browser.js.map +0 -1
- package/dist/server.d.ts +0 -9
- package/dist/server.js +0 -9
- package/dist/server.js.map +0 -1
- package/dist/transition-Cl6mAPcx.d.ts +0 -96
- package/dist/transition-DEqcImne.js.map +0 -1
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
//#region src/data.d.ts
|
|
2
|
+
type DataResourceKeyInput = string | number | boolean | null | readonly DataResourceKeyInput[] | {
|
|
3
|
+
readonly [key: string]: DataResourceKeyInput;
|
|
4
|
+
};
|
|
5
|
+
type DataResourceKey = readonly [string, ...DataResourceKeyInput[]];
|
|
6
|
+
interface DataResourceLoadContext {
|
|
7
|
+
signal: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
type DataResourceLoader<TArgs extends unknown[], TValue> = (...argsAndContext: [...TArgs, DataResourceLoadContext]) => TValue | PromiseLike<TValue>;
|
|
10
|
+
interface DataResource<TArgs extends unknown[] = unknown[], TValue = unknown> {
|
|
11
|
+
readonly $$typeof: symbol;
|
|
12
|
+
readonly debugArgs?: (...args: TArgs) => DataResourceKeyInput;
|
|
13
|
+
readonly key: (...args: TArgs) => DataResourceKey;
|
|
14
|
+
readonly load?: DataResourceLoader<TArgs, TValue>;
|
|
15
|
+
}
|
|
16
|
+
type DataRefreshResult<T> = {
|
|
17
|
+
status: "fulfilled";
|
|
18
|
+
value: T;
|
|
19
|
+
} | {
|
|
20
|
+
status: "rejected";
|
|
21
|
+
error: unknown;
|
|
22
|
+
staleValue?: T;
|
|
23
|
+
} | {
|
|
24
|
+
status: "aborted";
|
|
25
|
+
reason: "superseded" | "store-disposed" | "evicted";
|
|
26
|
+
staleValue?: T;
|
|
27
|
+
} | {
|
|
28
|
+
status: "unsupported";
|
|
29
|
+
reason: "no-client-loader";
|
|
30
|
+
staleValue?: T;
|
|
31
|
+
};
|
|
32
|
+
interface FigDataHydrationEntry {
|
|
33
|
+
key: DataResourceKey;
|
|
34
|
+
value: unknown;
|
|
35
|
+
}
|
|
36
|
+
type FigDataEntryStatus = "pending" | "fulfilled" | "rejected" | "refreshing";
|
|
37
|
+
interface DataStoreEntrySnapshot {
|
|
38
|
+
canonicalKey: string;
|
|
39
|
+
error?: unknown;
|
|
40
|
+
hasValue: boolean;
|
|
41
|
+
key: DataResourceKey;
|
|
42
|
+
pending: boolean;
|
|
43
|
+
refreshError?: unknown;
|
|
44
|
+
stale: boolean;
|
|
45
|
+
status: FigDataEntryStatus;
|
|
46
|
+
subscriberCount: number;
|
|
47
|
+
value?: unknown;
|
|
48
|
+
}
|
|
49
|
+
interface FigDataStoreHandle {
|
|
50
|
+
ensureData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): Promise<TValue>;
|
|
51
|
+
hydrate(entries: readonly FigDataHydrationEntry[]): void;
|
|
52
|
+
invalidateData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): void;
|
|
53
|
+
invalidateDataError(error: unknown): boolean;
|
|
54
|
+
invalidateDataKey(key: DataResourceKey): void;
|
|
55
|
+
invalidateDataPrefix(prefix: DataResourceKey): void;
|
|
56
|
+
preloadData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): void;
|
|
57
|
+
refreshData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, ...args: TArgs): Promise<DataRefreshResult<TValue>>;
|
|
58
|
+
run<T>(callback: () => T): T;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A root-neutral data store. A renderer adopts it exactly once, preserving
|
|
62
|
+
* entries loaded before rendering while attaching subscriber scheduling.
|
|
63
|
+
*/
|
|
64
|
+
interface FigDataStoreController extends FigDataStoreHandle {
|
|
65
|
+
dispose(): void;
|
|
66
|
+
snapshot(): FigDataHydrationEntry[];
|
|
67
|
+
}
|
|
68
|
+
interface FigDataStoreOptions {
|
|
69
|
+
initialData?: readonly FigDataHydrationEntry[];
|
|
70
|
+
partition?: DataResourceKeyInput;
|
|
71
|
+
}
|
|
72
|
+
interface FigDataStore extends FigDataStoreHandle {
|
|
73
|
+
commitDataDependencies(owner: object, previousOwner: object | null): void;
|
|
74
|
+
deleteDataOwner(owner: object): void;
|
|
75
|
+
releaseDataOwner(owner: object): void;
|
|
76
|
+
resetDataDependencies(owner: object): void;
|
|
77
|
+
dispose(): void;
|
|
78
|
+
inspectDataDependencyCanonicalKeys(owner: object): string[];
|
|
79
|
+
inspectDataEntries(): DataStoreEntrySnapshot[];
|
|
80
|
+
snapshot(): FigDataHydrationEntry[];
|
|
81
|
+
readData<TArgs extends unknown[], TValue>(resource: DataResource<TArgs, TValue>, args: TArgs, owner: object): TValue;
|
|
82
|
+
}
|
|
83
|
+
interface FigDataStoreHost {
|
|
84
|
+
getLane(): unknown;
|
|
85
|
+
partition?: DataResourceKeyInput;
|
|
86
|
+
schedule(owner: object, lane: unknown): void;
|
|
87
|
+
}
|
|
88
|
+
type FigDataStoreFactory = (host: FigDataStoreHost) => FigDataStore;
|
|
89
|
+
type LoadContextHydrate = (entries: readonly FigDataHydrationEntry[]) => void;
|
|
90
|
+
type LoadContextAttributeError = (error: unknown) => void;
|
|
91
|
+
interface LoadContextCapabilities {
|
|
92
|
+
attributeError: LoadContextAttributeError;
|
|
93
|
+
hydrate: LoadContextHydrate;
|
|
94
|
+
key?: DataResourceKey;
|
|
95
|
+
}
|
|
96
|
+
declare function defineLoadContextCapabilities(context: DataResourceLoadContext, capabilities: LoadContextCapabilities): void;
|
|
97
|
+
declare function loadContextCapabilities(context: DataResourceLoadContext): LoadContextCapabilities | undefined;
|
|
98
|
+
declare function resolveCurrentDataStore(message?: string): FigDataStore;
|
|
99
|
+
declare function setCurrentDataStore(store: FigDataStore | null): FigDataStore | null;
|
|
100
|
+
declare function markDataResourceError(error: unknown, key: DataResourceKey): void;
|
|
101
|
+
declare function dataResourceKeysForError(error: unknown): DataResourceKey[] | undefined;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/resource.d.ts
|
|
104
|
+
type AssetResourceBlocking = "reveal" | "none";
|
|
105
|
+
type CrossOrigin = "anonymous" | "use-credentials" | "";
|
|
106
|
+
type FetchPriority = "high" | "low" | "auto";
|
|
107
|
+
type AssetResourceDestination = "head" | "stream";
|
|
108
|
+
type FigAssetResource = StylesheetResource | PreloadResource | ModulePreloadResource | ScriptResource | FontResource | PreconnectResource | TitleResource | MetaResource;
|
|
109
|
+
interface ResourceBase {
|
|
110
|
+
key?: string;
|
|
111
|
+
}
|
|
112
|
+
interface StylesheetResource extends ResourceBase {
|
|
113
|
+
blocking?: AssetResourceBlocking;
|
|
114
|
+
crossorigin?: CrossOrigin;
|
|
115
|
+
href: string;
|
|
116
|
+
kind: "stylesheet";
|
|
117
|
+
media?: string;
|
|
118
|
+
precedence?: string;
|
|
119
|
+
}
|
|
120
|
+
interface PreloadResource extends ResourceBase {
|
|
121
|
+
as: string;
|
|
122
|
+
crossorigin?: CrossOrigin;
|
|
123
|
+
fetchpriority?: FetchPriority;
|
|
124
|
+
href: string;
|
|
125
|
+
kind: "preload";
|
|
126
|
+
type?: string;
|
|
127
|
+
}
|
|
128
|
+
interface ModulePreloadResource extends ResourceBase {
|
|
129
|
+
crossorigin?: CrossOrigin;
|
|
130
|
+
fetchpriority?: FetchPriority;
|
|
131
|
+
href: string;
|
|
132
|
+
kind: "modulepreload";
|
|
133
|
+
}
|
|
134
|
+
interface ScriptResource extends ResourceBase {
|
|
135
|
+
async?: boolean;
|
|
136
|
+
crossorigin?: CrossOrigin;
|
|
137
|
+
defer?: boolean;
|
|
138
|
+
kind: "script";
|
|
139
|
+
module?: boolean;
|
|
140
|
+
src: string;
|
|
141
|
+
}
|
|
142
|
+
interface FontResource extends ResourceBase {
|
|
143
|
+
crossorigin?: CrossOrigin;
|
|
144
|
+
fetchpriority?: FetchPriority;
|
|
145
|
+
href: string;
|
|
146
|
+
kind: "font";
|
|
147
|
+
type: string;
|
|
148
|
+
}
|
|
149
|
+
interface PreconnectResource extends ResourceBase {
|
|
150
|
+
crossorigin?: CrossOrigin;
|
|
151
|
+
href: string;
|
|
152
|
+
kind: "preconnect";
|
|
153
|
+
}
|
|
154
|
+
interface TitleResource extends ResourceBase {
|
|
155
|
+
kind: "title";
|
|
156
|
+
value: string;
|
|
157
|
+
}
|
|
158
|
+
interface MetaResourceBase extends ResourceBase {
|
|
159
|
+
kind: "meta";
|
|
160
|
+
}
|
|
161
|
+
type DistributiveOmit<Value, Key extends PropertyKey> = Value extends unknown ? Omit<Value, Key> : never;
|
|
162
|
+
type MetaResource = (MetaResourceBase & {
|
|
163
|
+
charset: string;
|
|
164
|
+
content?: never;
|
|
165
|
+
"http-equiv"?: never;
|
|
166
|
+
name?: never;
|
|
167
|
+
property?: never;
|
|
168
|
+
}) | (MetaResourceBase & {
|
|
169
|
+
charset?: never;
|
|
170
|
+
content: string;
|
|
171
|
+
"http-equiv"?: never;
|
|
172
|
+
name: string;
|
|
173
|
+
property?: never;
|
|
174
|
+
}) | (MetaResourceBase & {
|
|
175
|
+
charset?: never;
|
|
176
|
+
content: string;
|
|
177
|
+
"http-equiv"?: never;
|
|
178
|
+
name?: never;
|
|
179
|
+
property: string;
|
|
180
|
+
}) | (MetaResourceBase & {
|
|
181
|
+
charset?: never;
|
|
182
|
+
content: string;
|
|
183
|
+
"http-equiv": string;
|
|
184
|
+
name?: never;
|
|
185
|
+
property?: never;
|
|
186
|
+
});
|
|
187
|
+
type MetaResourceOptions = DistributiveOmit<MetaResource, "kind">;
|
|
188
|
+
type FigAssetResourceList = FigAssetResource | readonly FigAssetResource[];
|
|
189
|
+
type ClientReferenceAssets = FigAssetResourceList | (() => FigAssetResourceList);
|
|
190
|
+
interface AssetsProps {
|
|
191
|
+
assets: FigAssetResourceList;
|
|
192
|
+
children?: FigNode;
|
|
193
|
+
}
|
|
194
|
+
declare function assets(value: FigAssetResourceList, children?: FigNode): FigElement<AssetsProps>;
|
|
195
|
+
declare function stylesheet(href: string, options?: Omit<StylesheetResource, "href" | "kind">): StylesheetResource;
|
|
196
|
+
declare function preload(href: string, as: string, options?: Omit<PreloadResource, "as" | "href" | "kind">): PreloadResource;
|
|
197
|
+
declare function modulepreload(href: string, options?: Omit<ModulePreloadResource, "href" | "kind">): ModulePreloadResource;
|
|
198
|
+
declare function script(src: string, options?: Omit<ScriptResource, "kind" | "src">): ScriptResource;
|
|
199
|
+
declare function font(href: string, type: string, options?: Omit<FontResource, "href" | "kind" | "type">): FontResource;
|
|
200
|
+
declare function preconnect(href: string, options?: Omit<PreconnectResource, "href" | "kind">): PreconnectResource;
|
|
201
|
+
declare function title(value: string): TitleResource;
|
|
202
|
+
declare function meta(options: MetaResourceOptions): MetaResource;
|
|
203
|
+
declare function isFigAssetResource(value: unknown): value is FigAssetResource;
|
|
204
|
+
declare function clientReferenceAssets(reference: FigClientReference): readonly FigAssetResource[];
|
|
205
|
+
declare function assetResourceKey(resource: FigAssetResource): string;
|
|
206
|
+
declare function assetResourceDestination(resource: FigAssetResource): AssetResourceDestination;
|
|
207
|
+
declare function assetResourceFromHostProps(type: string, props: Props): FigAssetResource | null;
|
|
208
|
+
declare function preventAssetResourceHoist<P extends Props>(props: P): P;
|
|
209
|
+
declare function assetResourceFromHostAttributes(type: string, getAttribute: (name: string) => unknown): FigAssetResource | null;
|
|
210
|
+
type AssetResourceHostAttribute = readonly [name: string, value: string | true];
|
|
211
|
+
declare function assetResourceHostAttributes(resource: FigAssetResource): AssetResourceHostAttribute[];
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/element.d.ts
|
|
214
|
+
type Key = string | number;
|
|
215
|
+
type Props = Record<string, any>;
|
|
216
|
+
type ComponentType<P = Props> = (props: P & {
|
|
217
|
+
children?: FigNode;
|
|
218
|
+
}) => FigNode;
|
|
219
|
+
type ComponentProps<T extends ComponentType<any>> = Parameters<T> extends [infer P, ...unknown[]] ? P extends Props ? P : Props : {};
|
|
220
|
+
type ElementType<P = Props> = string | typeof Fragment | FigAssets | FigClientReference<P> | FigErrorBoundary | FigSuspense | FigActivity | FigViewTransition | ComponentType<P>;
|
|
221
|
+
type AwaitedFigNode = FigElement<any> | FigPortal<any> | string | number | boolean | null | undefined | FigNode[];
|
|
222
|
+
type FigNode = AwaitedFigNode | PromiseLike<AwaitedFigNode>;
|
|
223
|
+
interface FigElement<P = Props> {
|
|
224
|
+
readonly $$typeof: symbol;
|
|
225
|
+
readonly type: ElementType<any>;
|
|
226
|
+
readonly key: Key | null;
|
|
227
|
+
readonly props: P & {
|
|
228
|
+
children?: FigNode;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
interface FigPortal<Target = unknown> {
|
|
232
|
+
readonly $$typeof: symbol;
|
|
233
|
+
readonly children: FigNode;
|
|
234
|
+
readonly key: Key | null;
|
|
235
|
+
readonly target: Target;
|
|
236
|
+
}
|
|
237
|
+
interface ClientReferenceOptions<P extends Props = Props> {
|
|
238
|
+
assets?: ClientReferenceAssets;
|
|
239
|
+
id: string;
|
|
240
|
+
ssr?: ComponentType<P>;
|
|
241
|
+
}
|
|
242
|
+
interface FigClientReference<P = Props> {
|
|
243
|
+
(props: P & {
|
|
244
|
+
children?: FigNode;
|
|
245
|
+
}): FigNode;
|
|
246
|
+
readonly $$typeof: symbol;
|
|
247
|
+
readonly assets?: ClientReferenceAssets;
|
|
248
|
+
readonly id: string;
|
|
249
|
+
readonly ssr?: ComponentType<P>;
|
|
250
|
+
}
|
|
251
|
+
type LazyLoader<T extends ComponentType<any> = ComponentType<any>> = () => PromiseLike<T>;
|
|
252
|
+
interface SuspenseProps {
|
|
253
|
+
fallback?: FigNode;
|
|
254
|
+
children?: FigNode;
|
|
255
|
+
}
|
|
256
|
+
interface FigSuspense {
|
|
257
|
+
(props: SuspenseProps): FigNode;
|
|
258
|
+
readonly $$typeof: symbol;
|
|
259
|
+
}
|
|
260
|
+
type ActivityMode = "visible" | "hidden";
|
|
261
|
+
interface ActivityProps {
|
|
262
|
+
mode: ActivityMode;
|
|
263
|
+
children?: FigNode;
|
|
264
|
+
}
|
|
265
|
+
interface FigActivity {
|
|
266
|
+
(props: ActivityProps): FigNode;
|
|
267
|
+
readonly $$typeof: symbol;
|
|
268
|
+
}
|
|
269
|
+
type ViewTransitionClass = "auto" | "none" | (string & {});
|
|
270
|
+
type ViewTransitionPhase = "enter" | "exit" | "share" | "update";
|
|
271
|
+
interface ViewTransitionSurface {
|
|
272
|
+
readonly name: string;
|
|
273
|
+
}
|
|
274
|
+
interface ViewTransitionEvent {
|
|
275
|
+
readonly phase: ViewTransitionPhase;
|
|
276
|
+
readonly surfaces: readonly ViewTransitionSurface[];
|
|
277
|
+
readonly types: readonly string[];
|
|
278
|
+
}
|
|
279
|
+
type ViewTransitionCallback = (event: ViewTransitionEvent, signal: AbortSignal) => undefined;
|
|
280
|
+
interface ViewTransitionProps {
|
|
281
|
+
name?: string;
|
|
282
|
+
children?: FigNode;
|
|
283
|
+
default?: ViewTransitionClass;
|
|
284
|
+
enter?: ViewTransitionClass;
|
|
285
|
+
exit?: ViewTransitionClass;
|
|
286
|
+
share?: ViewTransitionClass;
|
|
287
|
+
update?: ViewTransitionClass;
|
|
288
|
+
onTransition?: ViewTransitionCallback;
|
|
289
|
+
}
|
|
290
|
+
interface FigViewTransition {
|
|
291
|
+
(props: ViewTransitionProps): FigNode;
|
|
292
|
+
readonly $$typeof: symbol;
|
|
293
|
+
}
|
|
294
|
+
interface ErrorBoundaryProps {
|
|
295
|
+
fallback?: FigNode | ((error: unknown, info: ErrorInfo) => FigNode);
|
|
296
|
+
onError?: (error: unknown, info: ErrorInfo) => void;
|
|
297
|
+
children?: FigNode;
|
|
298
|
+
}
|
|
299
|
+
interface ErrorInfo {
|
|
300
|
+
componentStack: string;
|
|
301
|
+
dataResourceKeys?: DataResourceKey[];
|
|
302
|
+
}
|
|
303
|
+
interface FigErrorBoundary {
|
|
304
|
+
(props: ErrorBoundaryProps): FigNode;
|
|
305
|
+
readonly $$typeof: symbol;
|
|
306
|
+
}
|
|
307
|
+
interface FigAssets {
|
|
308
|
+
(props: Props & {
|
|
309
|
+
children?: FigNode;
|
|
310
|
+
}): FigNode;
|
|
311
|
+
readonly $$typeof: symbol;
|
|
312
|
+
}
|
|
313
|
+
declare const Fragment: unique symbol;
|
|
314
|
+
declare const FigElementSymbol: unique symbol;
|
|
315
|
+
declare const FigClientReferenceSymbol: unique symbol;
|
|
316
|
+
declare const FigActivitySymbol: unique symbol;
|
|
317
|
+
declare const FigErrorBoundarySymbol: unique symbol;
|
|
318
|
+
declare const FigPortalSymbol: unique symbol;
|
|
319
|
+
declare const FigAssetsSymbol: unique symbol;
|
|
320
|
+
declare const FigSuspenseSymbol: unique symbol;
|
|
321
|
+
declare const FigViewTransitionSymbol: unique symbol;
|
|
322
|
+
declare const Assets: FigAssets;
|
|
323
|
+
declare const ErrorBoundary: FigErrorBoundary;
|
|
324
|
+
declare const Suspense: FigSuspense;
|
|
325
|
+
declare const Activity: FigActivity;
|
|
326
|
+
declare const ViewTransition: FigViewTransition;
|
|
327
|
+
declare function createElement<P extends Props>(type: ElementType<P>, config?: (P & {
|
|
328
|
+
key?: Key | null;
|
|
329
|
+
}) | null, ...children: FigNode[]): FigElement<P>;
|
|
330
|
+
declare function isValidElement(value: unknown): value is FigElement;
|
|
331
|
+
declare function createPortalNode<Target>(children: FigNode, target: Target, key?: Key | null): FigPortal<Target>;
|
|
332
|
+
declare function isPortal(value: unknown): value is FigPortal;
|
|
333
|
+
declare function clientReference<P extends Props = Props>(options: ClientReferenceOptions<P>): FigClientReference<P>;
|
|
334
|
+
declare function lazy<T extends ComponentType<any>>(load: LazyLoader<T>): ComponentType<ComponentProps<T>>;
|
|
335
|
+
declare function isClientReference(value: unknown): value is FigClientReference;
|
|
336
|
+
declare function isSuspense(value: unknown): value is FigSuspense;
|
|
337
|
+
declare function isActivity(value: unknown): value is FigActivity;
|
|
338
|
+
declare function isErrorBoundary(value: unknown): value is FigErrorBoundary;
|
|
339
|
+
declare function isViewTransition(value: unknown): value is FigViewTransition;
|
|
340
|
+
declare function isAssets(value: unknown): value is FigAssets;
|
|
341
|
+
//#endregion
|
|
342
|
+
export { isViewTransition as $, LoadContextHydrate as $t, Fragment as A, preconnect as At, ViewTransitionPhase as B, DataResourceLoadContext as Bt, FigNode as C, assetResourceKey as Ct, FigSuspenseSymbol as D, isFigAssetResource as Dt, FigSuspense as E, font as Et, SuspenseProps as F, title as Ft, createPortalNode as G, FigDataStore as Gt, ViewTransitionSurface as H, DataStoreEntrySnapshot as Ht, ViewTransition as I, DataRefreshResult as It, isClientReference as J, FigDataStoreHandle as Jt, isActivity as K, FigDataStoreController as Kt, ViewTransitionCallback as L, DataResource as Lt, LazyLoader as M, preventAssetResourceHoist as Mt, Props as N, script as Nt, FigViewTransition as O, meta as Ot, Suspense as P, stylesheet as Pt, isValidElement as Q, LoadContextCapabilities as Qt, ViewTransitionClass as R, DataResourceKey as Rt, FigErrorBoundarySymbol as S, assetResourceHostAttributes as St, FigPortalSymbol as T, clientReferenceAssets as Tt, clientReference as U, FigDataEntryStatus as Ut, ViewTransitionProps as V, DataResourceLoader as Vt, createElement as W, FigDataHydrationEntry as Wt, isPortal as X, FigDataStoreOptions as Xt, isErrorBoundary as Y, FigDataStoreHost as Yt, isSuspense as Z, LoadContextAttributeError as Zt, FigClientReference as _, StylesheetResource as _t, AwaitedFigNode as a, setCurrentDataStore as an, ClientReferenceAssets as at, FigElementSymbol as b, assetResourceFromHostAttributes as bt, ComponentType as c, FigAssetResource as ct, ErrorBoundaryProps as d, MetaResource as dt, dataResourceKeysForError as en, lazy as et, ErrorInfo as f, MetaResourceOptions as ft, FigAssetsSymbol as g, ScriptResource as gt, FigAssets as h, PreloadResource as ht, Assets as i, resolveCurrentDataStore as in, AssetsProps as it, Key as j, preload as jt, FigViewTransitionSymbol as k, modulepreload as kt, ElementType as l, FigAssetResourceList as lt, FigActivitySymbol as m, PreconnectResource as mt, ActivityMode as n, loadContextCapabilities as nn, AssetResourceDestination as nt, ClientReferenceOptions as o, CrossOrigin as ot, FigActivity as p, ModulePreloadResource as pt, isAssets as q, FigDataStoreFactory as qt, ActivityProps as r, markDataResourceError as rn, AssetResourceHostAttribute as rt, ComponentProps as s, FetchPriority as st, Activity as t, defineLoadContextCapabilities as tn, AssetResourceBlocking as tt, ErrorBoundary as u, FontResource as ut, FigClientReferenceSymbol as v, TitleResource as vt, FigPortal as w, assets as wt, FigErrorBoundary as x, assetResourceFromHostProps as xt, FigElement as y, assetResourceDestination as yt, ViewTransitionEvent as z, DataResourceKeyInput as zt };
|
|
@@ -0,0 +1,299 @@
|
|
|
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 = 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
|
+
//#endregion
|
|
196
|
+
//#region src/element.ts
|
|
197
|
+
const Fragment = Symbol.for("fig.fragment");
|
|
198
|
+
const FigElementSymbol = Symbol.for("fig.element");
|
|
199
|
+
const FigClientReferenceSymbol = Symbol.for("fig.client-reference");
|
|
200
|
+
const FigActivitySymbol = Symbol.for("fig.activity");
|
|
201
|
+
const FigErrorBoundarySymbol = Symbol.for("fig.error-boundary");
|
|
202
|
+
const FigPortalSymbol = Symbol.for("fig.portal");
|
|
203
|
+
const FigAssetsSymbol = Symbol.for("fig.assets");
|
|
204
|
+
const FigSuspenseSymbol = Symbol.for("fig.suspense");
|
|
205
|
+
const FigViewTransitionSymbol = Symbol.for("fig.view-transition");
|
|
206
|
+
const Assets = Object.assign((props) => props.children, { $$typeof: FigAssetsSymbol });
|
|
207
|
+
const ErrorBoundary = Object.assign((props) => props.children, { $$typeof: FigErrorBoundarySymbol });
|
|
208
|
+
const Suspense = Object.assign((props) => props.children, { $$typeof: FigSuspenseSymbol });
|
|
209
|
+
const Activity = Object.assign((props) => props.children, { $$typeof: FigActivitySymbol });
|
|
210
|
+
const ViewTransition = Object.assign((props) => props.children, { $$typeof: FigViewTransitionSymbol });
|
|
211
|
+
function createElement(type, config, ...children) {
|
|
212
|
+
const props = { ...config };
|
|
213
|
+
const key = props.key ?? null;
|
|
214
|
+
delete props.key;
|
|
215
|
+
if (children.length === 1) props.children = children[0];
|
|
216
|
+
else if (children.length > 1) props.children = children;
|
|
217
|
+
return {
|
|
218
|
+
$$typeof: FigElementSymbol,
|
|
219
|
+
type,
|
|
220
|
+
key,
|
|
221
|
+
props: "mix" in props && typeof type === "string" ? resolveHostMix(type, props) : props
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function isValidElement(value) {
|
|
225
|
+
return hasObjectBrand(value, FigElementSymbol);
|
|
226
|
+
}
|
|
227
|
+
function createPortalNode(children, target, key = null) {
|
|
228
|
+
return {
|
|
229
|
+
$$typeof: FigPortalSymbol,
|
|
230
|
+
children,
|
|
231
|
+
key,
|
|
232
|
+
target
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function isPortal(value) {
|
|
236
|
+
return hasObjectBrand(value, FigPortalSymbol);
|
|
237
|
+
}
|
|
238
|
+
function clientReference(options) {
|
|
239
|
+
return Object.assign(() => {
|
|
240
|
+
throw new Error(`Client reference "${options.id}" cannot be rendered on the server directly.`);
|
|
241
|
+
}, {
|
|
242
|
+
$$typeof: FigClientReferenceSymbol,
|
|
243
|
+
assets: options.assets,
|
|
244
|
+
id: options.id,
|
|
245
|
+
ssr: options.ssr
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
function lazy(load) {
|
|
249
|
+
let promise = null;
|
|
250
|
+
let rejected = false;
|
|
251
|
+
const Lazy = (props) => {
|
|
252
|
+
if (promise === null) {
|
|
253
|
+
rejected = false;
|
|
254
|
+
const next = Promise.resolve(load()).then((value) => value, (error) => {
|
|
255
|
+
if (promise === next) rejected = true;
|
|
256
|
+
throw error;
|
|
257
|
+
});
|
|
258
|
+
promise = next;
|
|
259
|
+
}
|
|
260
|
+
try {
|
|
261
|
+
return createElement(readPromise(promise), props);
|
|
262
|
+
} catch (error) {
|
|
263
|
+
if (rejected) {
|
|
264
|
+
promise = null;
|
|
265
|
+
rejected = false;
|
|
266
|
+
}
|
|
267
|
+
throw error;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
return Lazy;
|
|
271
|
+
}
|
|
272
|
+
function isClientReference(value) {
|
|
273
|
+
return hasFunctionBrand(value, FigClientReferenceSymbol);
|
|
274
|
+
}
|
|
275
|
+
function isSuspense(value) {
|
|
276
|
+
return hasFunctionBrand(value, FigSuspenseSymbol);
|
|
277
|
+
}
|
|
278
|
+
function isActivity(value) {
|
|
279
|
+
return hasFunctionBrand(value, FigActivitySymbol);
|
|
280
|
+
}
|
|
281
|
+
function isErrorBoundary(value) {
|
|
282
|
+
return hasFunctionBrand(value, FigErrorBoundarySymbol);
|
|
283
|
+
}
|
|
284
|
+
function isViewTransition(value) {
|
|
285
|
+
return hasFunctionBrand(value, FigViewTransitionSymbol);
|
|
286
|
+
}
|
|
287
|
+
function isAssets(value) {
|
|
288
|
+
return hasFunctionBrand(value, FigAssetsSymbol);
|
|
289
|
+
}
|
|
290
|
+
function hasObjectBrand(value, brand) {
|
|
291
|
+
return typeof value === "object" && value !== null && "$$typeof" in value && value.$$typeof === brand;
|
|
292
|
+
}
|
|
293
|
+
function hasFunctionBrand(value, brand) {
|
|
294
|
+
return typeof value === "function" && "$$typeof" in value && value.$$typeof === brand;
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
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 };
|
|
298
|
+
|
|
299
|
+
//# sourceMappingURL=element-DmbzNH0T.js.map
|