@bgub/fig 0.1.0-alpha.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +495 -0
- package/README.md +50 -19
- package/dist/element-BZ7r9ncY.d.ts +342 -0
- package/dist/element-DmbzNH0T.js +299 -0
- package/dist/element-DmbzNH0T.js.map +1 -0
- package/dist/hooks-QDRabULx.d.ts +158 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.js +4 -4
- package/dist/internal.d.ts +212 -6
- package/dist/internal.js +14 -43
- package/dist/internal.js.map +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +3 -3
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/payload-format-KTNaSI4h.js +366 -0
- package/dist/payload-format-KTNaSI4h.js.map +1 -0
- package/dist/payload.d.ts +92 -0
- package/dist/payload.js +429 -0
- package/dist/payload.js.map +1 -0
- package/dist/{transition-DEqcImne.js → resource-kXeIR52S.js} +121 -71
- package/dist/resource-kXeIR52S.js.map +1 -0
- package/dist/{data-store-CRnNAT9-.js → transition-CC4kjjrU.js} +165 -54
- package/dist/transition-CC4kjjrU.js.map +1 -0
- package/package.json +5 -6
- package/dist/data-CHJh_xU9.d.ts +0 -79
- package/dist/data-h46EcMnE.js +0 -37
- package/dist/data-h46EcMnE.js.map +0 -1
- package/dist/data-store-CRnNAT9-.js.map +0 -1
- package/dist/data-store-EQOLQsW4.d.ts +0 -32
- package/dist/element-Bh_k9c3N.js +0 -179
- package/dist/element-Bh_k9c3N.js.map +0 -1
- package/dist/element-CCOOi4Ka.d.ts +0 -209
- package/dist/server.browser.d.ts +0 -9
- package/dist/server.browser.js +0 -8
- package/dist/server.browser.js.map +0 -1
- package/dist/server.d.ts +0 -9
- package/dist/server.js +0 -9
- package/dist/server.js.map +0 -1
- package/dist/transition-Cl6mAPcx.d.ts +0 -96
- package/dist/transition-DEqcImne.js.map +0 -1
|
@@ -1,19 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Q as isAttributableError, X as dataResourceKeysForError, Z as defineLoadContextCapabilities, et as markDataResourceError, nt as setCurrentDataStore, tt as resolveCurrentDataStore } from "./element-DmbzNH0T.js";
|
|
2
|
+
//#region src/context.ts
|
|
3
|
+
const FigContextSymbol = Symbol.for("fig.context");
|
|
4
|
+
function createContext(defaultValue) {
|
|
5
|
+
return Object.assign((props) => props.children, {
|
|
6
|
+
$$typeof: FigContextSymbol,
|
|
7
|
+
defaultValue
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function isContext(value) {
|
|
11
|
+
return typeof value === "function" && "$$typeof" in value && value.$$typeof === FigContextSymbol;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
2
14
|
//#region src/data-store.ts
|
|
3
15
|
const DataResourceSymbol = Symbol.for("fig.data-resource");
|
|
4
16
|
const DataStoreFactorySymbol = Symbol.for("fig.data-store-factory");
|
|
17
|
+
const DataStoreControllerSymbol = Symbol.for("fig.data-store-controller");
|
|
5
18
|
const DEFAULT_INACTIVE_RETENTION_MS = 300 * 1e3;
|
|
6
19
|
const DEFAULT_PRELOAD_RETENTION_MS = 30 * 1e3;
|
|
7
|
-
const dataStoreFactory =
|
|
20
|
+
const dataStoreFactory = createRendererDataStore;
|
|
8
21
|
function dataResource(options) {
|
|
9
|
-
|
|
22
|
+
return {
|
|
10
23
|
$$typeof: DataResourceSymbol,
|
|
24
|
+
[DataStoreFactorySymbol]: dataStoreFactory,
|
|
11
25
|
debugArgs: options.debugArgs,
|
|
12
26
|
key: options.key,
|
|
13
27
|
load: options.load
|
|
14
28
|
};
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
}
|
|
30
|
+
function ensureData(resource, ...args) {
|
|
31
|
+
return resolveDataMutationStore("ensureData").ensureData(resource, ...args);
|
|
17
32
|
}
|
|
18
33
|
function invalidateData(resource, ...args) {
|
|
19
34
|
resolveDataMutationStore("invalidateData").invalidateData(resource, ...args);
|
|
@@ -33,10 +48,32 @@ function refreshData(resource, ...args) {
|
|
|
33
48
|
function readDataStore() {
|
|
34
49
|
return resolveCurrentDataStore("readDataStore() must be called synchronously while Fig is executing — during render, an event handler, an action, or an effect. Capture the handle there and use it after awaits.");
|
|
35
50
|
}
|
|
51
|
+
function createDataStore(options = {}) {
|
|
52
|
+
const state = { host: null };
|
|
53
|
+
const store = createRendererDataStore({
|
|
54
|
+
getLane: () => state.host === null ? null : state.host.getLane(),
|
|
55
|
+
partition: options.partition,
|
|
56
|
+
schedule: (owner, lane) => state.host?.schedule(owner, lane)
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(store, DataStoreControllerSymbol, { value: state });
|
|
59
|
+
if (options.initialData !== void 0) store.hydrate(options.initialData);
|
|
60
|
+
return store;
|
|
61
|
+
}
|
|
62
|
+
function isDataStoreController(value) {
|
|
63
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && Object.hasOwn(value, DataStoreControllerSymbol);
|
|
64
|
+
}
|
|
65
|
+
function attachDataStore(controller, host, initialData) {
|
|
66
|
+
if (host.partition !== void 0 || initialData !== void 0) throw new Error("Pass partition and initialData to createDataStore(), not the renderer, when adopting a data store.");
|
|
67
|
+
const state = controller[DataStoreControllerSymbol];
|
|
68
|
+
if (state === void 0) throw new Error("dataStore must be created with createDataStore().");
|
|
69
|
+
if (state.host !== null) throw new Error("A data store can only be adopted by one Fig renderer.");
|
|
70
|
+
state.host = host;
|
|
71
|
+
return controller;
|
|
72
|
+
}
|
|
36
73
|
function resolveDataMutationStore(name) {
|
|
37
74
|
return resolveCurrentDataStore(`${name}() must be called synchronously while Fig is executing — during render, an event handler, an action, or an effect. Capture readDataStore() (or root.data) synchronously and call the handle instead.`);
|
|
38
75
|
}
|
|
39
|
-
function
|
|
76
|
+
function createRendererDataStore(host) {
|
|
40
77
|
return new DefaultDataStore(host);
|
|
41
78
|
}
|
|
42
79
|
function normalizeDataResourceKey(key) {
|
|
@@ -115,7 +152,7 @@ var DefaultDataStore = class {
|
|
|
115
152
|
}
|
|
116
153
|
abortOrphanedLoad(entry) {
|
|
117
154
|
if (this.entries.get(entry.storeKey) !== entry) return;
|
|
118
|
-
if (entry.subscribers.size > 0 || entry.preloadTimer !== null || entry.pending === null || entryHasValue(entry)) return;
|
|
155
|
+
if (entry.subscribers.size > 0 || entry.preloadTimer !== null || entry.ensureRetainers > 0 || entry.pending === null || entryHasValue(entry)) return;
|
|
119
156
|
this.evictEntry(entry, "evicted");
|
|
120
157
|
}
|
|
121
158
|
dispose() {
|
|
@@ -123,7 +160,7 @@ var DefaultDataStore = class {
|
|
|
123
160
|
for (const entry of this.entries.values()) {
|
|
124
161
|
this.clearInactiveTimer(entry);
|
|
125
162
|
this.clearPreloadTimer(entry);
|
|
126
|
-
this.
|
|
163
|
+
this.abortEntryGenerations(entry, "store-disposed");
|
|
127
164
|
this.notifyEntryChange(entry);
|
|
128
165
|
}
|
|
129
166
|
}
|
|
@@ -154,9 +191,12 @@ var DefaultDataStore = class {
|
|
|
154
191
|
inspectDataEntries() {
|
|
155
192
|
return Array.from(this.entries.values(), (entry) => this.snapshotEntry(entry));
|
|
156
193
|
}
|
|
194
|
+
inspectDataDependencyCanonicalKeys(owner) {
|
|
195
|
+
return [];
|
|
196
|
+
}
|
|
157
197
|
invalidateData(resource, ...args) {
|
|
158
198
|
if (this.disposed) return;
|
|
159
|
-
const
|
|
199
|
+
const entry = this.entryFor(resource, args, false);
|
|
160
200
|
if (entry === null) return;
|
|
161
201
|
this.invalidateEntry(entry, this.host.getLane());
|
|
162
202
|
}
|
|
@@ -169,7 +209,7 @@ var DefaultDataStore = class {
|
|
|
169
209
|
const entry = this.entryForKey(key);
|
|
170
210
|
if (entry !== null) entries.push(entry);
|
|
171
211
|
}
|
|
172
|
-
this.invalidateEntries(entries);
|
|
212
|
+
this.invalidateEntries(entries, error);
|
|
173
213
|
return true;
|
|
174
214
|
}
|
|
175
215
|
invalidateDataKey(key) {
|
|
@@ -185,9 +225,33 @@ var DefaultDataStore = class {
|
|
|
185
225
|
for (const entry of this.entries.values()) if (canonicalKeyStartsWith(entry.canonicalKey, prefixCanonical)) entries.push(entry);
|
|
186
226
|
this.invalidateEntries(entries);
|
|
187
227
|
}
|
|
228
|
+
async ensureData(resource, ...args) {
|
|
229
|
+
for (;;) {
|
|
230
|
+
if (this.disposed) throw new Error("ensureData() requires a live data store; this store was disposed.");
|
|
231
|
+
const entry = this.entryFor(resource, args, true);
|
|
232
|
+
this.clearInactiveTimer(entry);
|
|
233
|
+
this.retainPreload(entry);
|
|
234
|
+
if (entryHasValue(entry)) {
|
|
235
|
+
this.revalidateIfStale(entry, resource, args);
|
|
236
|
+
return entry.value;
|
|
237
|
+
}
|
|
238
|
+
if (entry.status === "rejected") throwDataResourceError(entry);
|
|
239
|
+
entry.ensureRetainers += 1;
|
|
240
|
+
try {
|
|
241
|
+
if (entry.pending !== null) await entry.pending.promise;
|
|
242
|
+
else await this.startLoad(entry, resource, args, {
|
|
243
|
+
lane: this.host.getLane(),
|
|
244
|
+
refresh: false
|
|
245
|
+
});
|
|
246
|
+
} finally {
|
|
247
|
+
entry.ensureRetainers -= 1;
|
|
248
|
+
if (this.entries.get(entry.storeKey) === entry) this.retainPreload(entry);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
188
252
|
preloadData(resource, ...args) {
|
|
189
253
|
if (this.disposed || resource.load === void 0) return;
|
|
190
|
-
const
|
|
254
|
+
const entry = this.entryFor(resource, args, true);
|
|
191
255
|
this.clearInactiveTimer(entry);
|
|
192
256
|
this.retainPreload(entry);
|
|
193
257
|
if (entry.pending !== null) return;
|
|
@@ -198,14 +262,11 @@ var DefaultDataStore = class {
|
|
|
198
262
|
});
|
|
199
263
|
}
|
|
200
264
|
readData(resource, args, owner) {
|
|
201
|
-
const
|
|
265
|
+
const entry = this.entryFor(resource, args, true);
|
|
202
266
|
this.clearInactiveTimer(entry);
|
|
203
267
|
this.clearPreloadTimer(entry);
|
|
204
|
-
this.addOwnerKey(owner,
|
|
205
|
-
|
|
206
|
-
lane: this.host.getLane(),
|
|
207
|
-
refresh: true
|
|
208
|
-
});
|
|
268
|
+
this.addOwnerKey(owner, entry.storeKey);
|
|
269
|
+
this.revalidateIfStale(entry, resource, args);
|
|
209
270
|
if (entry.status === "pending" && entry.pending === null) this.startLoad(entry, resource, args, {
|
|
210
271
|
lane: this.host.getLane(),
|
|
211
272
|
refresh: false
|
|
@@ -219,12 +280,12 @@ var DefaultDataStore = class {
|
|
|
219
280
|
status: "aborted"
|
|
220
281
|
});
|
|
221
282
|
if (resource.load === void 0) {
|
|
222
|
-
const
|
|
283
|
+
const entry = this.entryFor(resource, args, false);
|
|
223
284
|
if (entry === null) return Promise.resolve(unsupportedRefreshResult());
|
|
224
285
|
this.clearInactiveTimer(entry);
|
|
225
286
|
return Promise.resolve(unsupportedRefreshResult(entry));
|
|
226
287
|
}
|
|
227
|
-
const
|
|
288
|
+
const entry = this.entryFor(resource, args, true);
|
|
228
289
|
this.clearInactiveTimer(entry);
|
|
229
290
|
if (entry.pending !== null && entry.status !== "refreshing") return entry.pending.promise;
|
|
230
291
|
return this.startLoad(entry, resource, args, {
|
|
@@ -253,25 +314,20 @@ var DefaultDataStore = class {
|
|
|
253
314
|
const fingerprint = null;
|
|
254
315
|
const key = this.storeKey(normalized.canonical);
|
|
255
316
|
const current = this.entries.get(key);
|
|
256
|
-
if (current !== void 0) return
|
|
257
|
-
|
|
258
|
-
key
|
|
259
|
-
};
|
|
260
|
-
if (!create) return {
|
|
261
|
-
entry: null,
|
|
262
|
-
key
|
|
263
|
-
};
|
|
317
|
+
if (current !== void 0) return current;
|
|
318
|
+
if (!create) return null;
|
|
264
319
|
const entry = this.createEntry(normalized, key, resource, fingerprint, "pending", void 0);
|
|
265
|
-
if (this.disposed) return
|
|
266
|
-
entry,
|
|
267
|
-
key
|
|
268
|
-
};
|
|
320
|
+
if (this.disposed) return entry;
|
|
269
321
|
this.entries.set(key, entry);
|
|
270
322
|
this.notifyEntryChange(entry);
|
|
271
|
-
return
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
323
|
+
return entry;
|
|
324
|
+
}
|
|
325
|
+
revalidateIfStale(entry, resource, args) {
|
|
326
|
+
if (entry.status !== "fulfilled" || !entry.stale || entry.pending !== null || entry.refreshError !== void 0 || resource.load === void 0) return;
|
|
327
|
+
this.startLoad(entry, resource, args, {
|
|
328
|
+
lane: this.host.getLane(),
|
|
329
|
+
refresh: true
|
|
330
|
+
});
|
|
275
331
|
}
|
|
276
332
|
entryForKey(key) {
|
|
277
333
|
const normalized = normalizeKey(key);
|
|
@@ -281,6 +337,7 @@ var DefaultDataStore = class {
|
|
|
281
337
|
return {
|
|
282
338
|
canonicalKey: normalized.canonical,
|
|
283
339
|
controller: null,
|
|
340
|
+
ensureRetainers: 0,
|
|
284
341
|
error: void 0,
|
|
285
342
|
fingerprint,
|
|
286
343
|
generation: 0,
|
|
@@ -296,14 +353,17 @@ var DefaultDataStore = class {
|
|
|
296
353
|
status,
|
|
297
354
|
storeKey,
|
|
298
355
|
subscribers: /* @__PURE__ */ new Set(),
|
|
299
|
-
value
|
|
356
|
+
value,
|
|
357
|
+
valueController: null,
|
|
358
|
+
valueErrors: /* @__PURE__ */ new WeakSet()
|
|
300
359
|
};
|
|
301
360
|
}
|
|
302
361
|
hydrateEntry(entry, key, value) {
|
|
303
362
|
this.clearInactiveTimer(entry);
|
|
304
|
-
this.
|
|
363
|
+
this.abortEntryGenerations(entry, "superseded");
|
|
305
364
|
entry.error = void 0;
|
|
306
365
|
entry.generation += 1;
|
|
366
|
+
entry.valueErrors = /* @__PURE__ */ new WeakSet();
|
|
307
367
|
entry.invalidationVersion = 0;
|
|
308
368
|
entry.key = key;
|
|
309
369
|
entry.lane = null;
|
|
@@ -327,8 +387,9 @@ var DefaultDataStore = class {
|
|
|
327
387
|
this.notifyEntryChange(entry);
|
|
328
388
|
return Promise.resolve(unsupportedRefreshResult(entry));
|
|
329
389
|
}
|
|
330
|
-
this.
|
|
390
|
+
this.abortPendingLoad(entry, "superseded");
|
|
331
391
|
const controller = new AbortController();
|
|
392
|
+
const valueErrors = /* @__PURE__ */ new WeakSet();
|
|
332
393
|
const generation = entry.generation + 1;
|
|
333
394
|
const invalidationVersion = entry.invalidationVersion;
|
|
334
395
|
const pending = createPendingResult();
|
|
@@ -340,7 +401,7 @@ var DefaultDataStore = class {
|
|
|
340
401
|
this.notifyEntryChange(entry);
|
|
341
402
|
let loaded;
|
|
342
403
|
try {
|
|
343
|
-
loaded = load(...args,
|
|
404
|
+
loaded = load(...args, this.createLoadContext(entry, controller, valueErrors));
|
|
344
405
|
} catch (error) {
|
|
345
406
|
loaded = Promise.reject(error);
|
|
346
407
|
}
|
|
@@ -351,7 +412,10 @@ var DefaultDataStore = class {
|
|
|
351
412
|
};
|
|
352
413
|
const fulfill = (value) => {
|
|
353
414
|
if (entry.generation !== generation || controller.signal.aborted) return settleAborted();
|
|
415
|
+
const superseded = entry.valueController;
|
|
354
416
|
entry.controller = null;
|
|
417
|
+
entry.valueController = controller;
|
|
418
|
+
entry.valueErrors = valueErrors;
|
|
355
419
|
entry.error = void 0;
|
|
356
420
|
entry.pending = null;
|
|
357
421
|
entry.refreshError = void 0;
|
|
@@ -359,6 +423,7 @@ var DefaultDataStore = class {
|
|
|
359
423
|
entry.status = "fulfilled";
|
|
360
424
|
entry.value = value;
|
|
361
425
|
this.publish(entry);
|
|
426
|
+
superseded?.abort();
|
|
362
427
|
const result = {
|
|
363
428
|
status: "fulfilled",
|
|
364
429
|
value
|
|
@@ -369,8 +434,9 @@ var DefaultDataStore = class {
|
|
|
369
434
|
const reject = (error) => {
|
|
370
435
|
if (entry.generation !== generation || controller.signal.aborted) return settleAborted();
|
|
371
436
|
entry.controller = null;
|
|
437
|
+
controller.abort();
|
|
372
438
|
entry.pending = null;
|
|
373
|
-
if (hadValue) {
|
|
439
|
+
if (hadValue && entryHasValue(entry)) {
|
|
374
440
|
entry.refreshError = error;
|
|
375
441
|
entry.stale = true;
|
|
376
442
|
entry.status = "fulfilled";
|
|
@@ -401,6 +467,23 @@ var DefaultDataStore = class {
|
|
|
401
467
|
Promise.resolve(loaded).then(fulfill, reject);
|
|
402
468
|
return pending.promise;
|
|
403
469
|
}
|
|
470
|
+
createLoadContext(entry, controller, valueErrors) {
|
|
471
|
+
const context = { signal: controller.signal };
|
|
472
|
+
defineLoadContextCapabilities(context, {
|
|
473
|
+
key: entry.key,
|
|
474
|
+
attributeError: (error) => {
|
|
475
|
+
if (this.disposed || controller.signal.aborted) return;
|
|
476
|
+
markDataResourceError(error, entry.key);
|
|
477
|
+
if (isAttributableError(error)) valueErrors.add(error);
|
|
478
|
+
},
|
|
479
|
+
hydrate: (entries) => {
|
|
480
|
+
if (this.disposed || controller.signal.aborted) return;
|
|
481
|
+
const foreign = entries.filter((hydrated) => this.storeKey(normalizeKey(hydrated.key).canonical) !== entry.storeKey);
|
|
482
|
+
if (foreign.length > 0) this.hydrate(foreign);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
return context;
|
|
486
|
+
}
|
|
404
487
|
publish(entry) {
|
|
405
488
|
this.notifyEntryChange(entry);
|
|
406
489
|
this.scheduleInactiveCleanup(entry);
|
|
@@ -409,20 +492,25 @@ var DefaultDataStore = class {
|
|
|
409
492
|
scheduleSubscribers(entry, lane) {
|
|
410
493
|
for (const subscriber of entry.subscribers) this.host.schedule(subscriber, lane);
|
|
411
494
|
}
|
|
412
|
-
|
|
413
|
-
const pending = entry.pending;
|
|
414
|
-
if (pending === null) return;
|
|
495
|
+
abortPendingLoad(entry, reason) {
|
|
415
496
|
entry.controller?.abort();
|
|
416
497
|
entry.controller = null;
|
|
498
|
+
const pending = entry.pending;
|
|
499
|
+
if (pending === null) return;
|
|
417
500
|
entry.pending = null;
|
|
418
501
|
pending.resolve(abortedRefreshResult(entry, reason));
|
|
419
502
|
}
|
|
503
|
+
abortEntryGenerations(entry, reason) {
|
|
504
|
+
this.abortPendingLoad(entry, reason);
|
|
505
|
+
entry.valueController?.abort();
|
|
506
|
+
entry.valueController = null;
|
|
507
|
+
}
|
|
420
508
|
retainPreload(entry) {
|
|
421
509
|
this.clearPreloadTimer(entry);
|
|
422
510
|
if (this.disposed || !Number.isFinite(this.preloadRetentionMs)) return;
|
|
423
511
|
entry.preloadTimer = scheduleStoreTimer(() => {
|
|
424
512
|
entry.preloadTimer = null;
|
|
425
|
-
if (entry.subscribers.size === 0 && entry.pending !== null && !entryHasValue(entry)) {
|
|
513
|
+
if (entry.subscribers.size === 0 && entry.ensureRetainers === 0 && entry.pending !== null && !entryHasValue(entry)) {
|
|
426
514
|
this.evictEntry(entry, "evicted");
|
|
427
515
|
return;
|
|
428
516
|
}
|
|
@@ -430,11 +518,11 @@ var DefaultDataStore = class {
|
|
|
430
518
|
}, Math.max(0, this.preloadRetentionMs));
|
|
431
519
|
}
|
|
432
520
|
scheduleInactiveCleanup(entry) {
|
|
433
|
-
if (this.disposed || entry.subscribers.size > 0 || entry.pending !== null || entry.preloadTimer !== null || !Number.isFinite(this.inactiveRetentionMs)) return;
|
|
521
|
+
if (this.disposed || entry.subscribers.size > 0 || entry.pending !== null || entry.preloadTimer !== null || entry.ensureRetainers > 0 || !Number.isFinite(this.inactiveRetentionMs)) return;
|
|
434
522
|
this.clearInactiveTimer(entry);
|
|
435
523
|
entry.inactiveTimer = scheduleStoreTimer(() => {
|
|
436
524
|
entry.inactiveTimer = null;
|
|
437
|
-
if (entry.subscribers.size > 0 || entry.pending !== null || entry.preloadTimer !== null) return;
|
|
525
|
+
if (entry.subscribers.size > 0 || entry.pending !== null || entry.preloadTimer !== null || entry.ensureRetainers > 0) return;
|
|
438
526
|
this.evictEntry(entry, "evicted");
|
|
439
527
|
}, Math.max(0, this.inactiveRetentionMs));
|
|
440
528
|
}
|
|
@@ -442,7 +530,7 @@ var DefaultDataStore = class {
|
|
|
442
530
|
if (this.entries.get(entry.storeKey) !== entry) return;
|
|
443
531
|
this.clearInactiveTimer(entry);
|
|
444
532
|
this.clearPreloadTimer(entry);
|
|
445
|
-
this.
|
|
533
|
+
this.abortEntryGenerations(entry, reason);
|
|
446
534
|
this.entries.delete(entry.storeKey);
|
|
447
535
|
this.host.onEntryEvict?.(this.snapshotEntry(entry));
|
|
448
536
|
}
|
|
@@ -480,11 +568,18 @@ var DefaultDataStore = class {
|
|
|
480
568
|
if (entry.pending === null) throw new Error(`Data resource "${entry.canonicalKey}" has no pending load.`);
|
|
481
569
|
throw entry.pending.promise;
|
|
482
570
|
}
|
|
483
|
-
invalidateEntry(entry, lane) {
|
|
571
|
+
invalidateEntry(entry, lane, attributedError) {
|
|
484
572
|
entry.invalidationVersion += 1;
|
|
485
573
|
entry.stale = true;
|
|
486
574
|
entry.refreshError = void 0;
|
|
487
|
-
if (entry.
|
|
575
|
+
if (isAttributableError(attributedError) && entry.valueErrors.has(attributedError)) {
|
|
576
|
+
entry.valueController?.abort();
|
|
577
|
+
entry.valueController = null;
|
|
578
|
+
entry.valueErrors = /* @__PURE__ */ new WeakSet();
|
|
579
|
+
entry.value = void 0;
|
|
580
|
+
entry.error = void 0;
|
|
581
|
+
entry.status = "pending";
|
|
582
|
+
} else if (entry.status === "rejected") {
|
|
488
583
|
entry.error = void 0;
|
|
489
584
|
entry.status = "pending";
|
|
490
585
|
}
|
|
@@ -492,10 +587,10 @@ var DefaultDataStore = class {
|
|
|
492
587
|
if (entry.subscribers.size === 0) return;
|
|
493
588
|
this.scheduleSubscribers(entry, lane);
|
|
494
589
|
}
|
|
495
|
-
invalidateEntries(entries) {
|
|
590
|
+
invalidateEntries(entries, attributedError) {
|
|
496
591
|
if (entries.length === 0) return;
|
|
497
592
|
const lane = this.host.getLane();
|
|
498
|
-
for (const entry of entries) this.invalidateEntry(entry, lane);
|
|
593
|
+
for (const entry of entries) this.invalidateEntry(entry, lane, attributedError);
|
|
499
594
|
}
|
|
500
595
|
};
|
|
501
596
|
function normalizeKey(key) {
|
|
@@ -582,7 +677,7 @@ function encodeValue(value, path) {
|
|
|
582
677
|
}
|
|
583
678
|
}
|
|
584
679
|
function isThenable(value) {
|
|
585
|
-
return (typeof value === "object" || typeof value === "function") && value !== null && typeof value.then === "function";
|
|
680
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && "then" in value && typeof value.then === "function";
|
|
586
681
|
}
|
|
587
682
|
function createPendingResult() {
|
|
588
683
|
let resolve = () => void 0;
|
|
@@ -606,6 +701,22 @@ function currentDataStore() {
|
|
|
606
701
|
return resolveCurrentDataStore();
|
|
607
702
|
}
|
|
608
703
|
//#endregion
|
|
609
|
-
|
|
704
|
+
//#region src/transition.ts
|
|
705
|
+
let transitionHandler = (callback) => callback();
|
|
706
|
+
/**
|
|
707
|
+
* Runs state updates scheduled by `callback` at transition priority. If
|
|
708
|
+
* `callback` returns a thenable, updates after an `await` remain in the
|
|
709
|
+
* transition priority scope until it settles.
|
|
710
|
+
*/
|
|
711
|
+
function transition(callback, options) {
|
|
712
|
+
return transitionHandler(callback, options);
|
|
713
|
+
}
|
|
714
|
+
function setTransitionHandler(handler) {
|
|
715
|
+
const previous = transitionHandler;
|
|
716
|
+
transitionHandler = handler;
|
|
717
|
+
return previous;
|
|
718
|
+
}
|
|
719
|
+
//#endregion
|
|
720
|
+
export { runWithDataStore as _, createRendererDataStore as a, isContext as b, ensureData as c, invalidateDataKey as d, invalidateDataPrefix as f, refreshData as g, readDataStore as h, createDataStore as i, invalidateData as l, normalizeDataResourceKey as m, transition as n, currentDataStore as o, isDataStoreController as p, attachDataStore as r, dataResource as s, setTransitionHandler as t, invalidateDataError as u, FigContextSymbol as v, createContext as y };
|
|
610
721
|
|
|
611
|
-
//# sourceMappingURL=
|
|
722
|
+
//# sourceMappingURL=transition-CC4kjjrU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transition-CC4kjjrU.js","names":[],"sources":["../src/context.ts","../src/data-store.ts","../src/transition.ts"],"sourcesContent":["import type { FigNode } from \"./element.ts\";\n\nexport interface FigContext<T> {\n (props: { value: T; children?: FigNode }): FigNode;\n readonly $$typeof: symbol;\n readonly defaultValue: T;\n}\n\nexport const FigContextSymbol = Symbol.for(\"fig.context\");\n\nexport function createContext<T>(defaultValue: T): FigContext<T> {\n return Object.assign(\n (props: { value: T; children?: FigNode }) => props.children,\n {\n $$typeof: FigContextSymbol,\n defaultValue,\n },\n );\n}\n\nexport function isContext(value: unknown): value is FigContext<unknown> {\n return (\n typeof value === \"function\" &&\n \"$$typeof\" in value &&\n value.$$typeof === FigContextSymbol\n );\n}\n","import {\n type DataRefreshResult,\n type DataResource,\n type DataResourceKey,\n type DataResourceKeyInput,\n type DataResourceLoadContext,\n type DataResourceLoader,\n type DataStoreEntrySnapshot,\n dataResourceKeysForError,\n defineLoadContextCapabilities,\n type FigDataEntryStatus,\n type FigDataHydrationEntry,\n type FigDataStore,\n type FigDataStoreController,\n type FigDataStoreFactory,\n type FigDataStoreHandle,\n type FigDataStoreHost,\n type FigDataStoreOptions,\n isAttributableError,\n markDataResourceError,\n resolveCurrentDataStore,\n setCurrentDataStore,\n} from \"./data.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nexport interface DataResourceOptions<TArgs extends unknown[], TValue> {\n key: (...args: TArgs) => DataResourceKey;\n debugArgs?: (...args: TArgs) => DataResourceKeyInput;\n load?: DataResourceLoader<TArgs, TValue>;\n}\n\nexport interface DataStoreHost<Owner extends object, Lane> {\n getLane(): Lane;\n inactiveRetentionMs?: number;\n onEntryChange?: (entry: DataStoreEntrySnapshot) => void;\n onEntryEvict?: (entry: DataStoreEntrySnapshot) => void;\n partition?: DataResourceKeyInput;\n preloadRetentionMs?: number;\n schedule(owner: Owner, lane: Lane): void;\n}\n\nexport interface DataStore<\n Owner extends object = object,\n Lane = unknown,\n> extends FigDataStore {\n readonly host: DataStoreHost<Owner, Lane>;\n}\n\ninterface Entry<Owner extends object, Lane> {\n canonicalKey: string;\n // The in-flight load's controller (null when no load is pending).\n controller: AbortController | null;\n // The authoritative generation's controller — the load whose value the\n // entry holds. Deliberately retained after that loader settles: the\n // signal's lifetime is the generation's authority, not the pending\n // promise's, so loaders that keep streaming into their value (payload\n // decodes filling holes) learn when a SUCCESSOR becomes authoritative, a\n // server push hydrates over them, the entry evicts, or the store is\n // disposed. A superseding load that starts does not abort it — a visible\n // stale value keeps streaming through the refresh window, and a failed\n // refresh leaves it fully alive.\n valueController: AbortController | null;\n // Errors rejected by streamed holes inside the authoritative fulfilled\n // value. Invalidating one retires that broken value instead of serving it\n // stale into a freshly remounted ErrorBoundary.\n valueErrors: WeakSet<object>;\n // Count of ensureData calls currently awaiting this entry's load. A\n // retainer like a subscriber or the preload timer: an awaited ensure must\n // not be evicted-and-aborted out from under its caller mid-load.\n ensureRetainers: number;\n error: unknown;\n fingerprint: string | null;\n generation: number;\n invalidationVersion: number;\n inactiveTimer: TimerHandle | null;\n key: DataResourceKey;\n lane: Lane | null;\n pending: PendingResult<unknown> | null;\n preloadTimer: TimerHandle | null;\n refreshError: unknown;\n resource: DataResource<unknown[], unknown> | null;\n stale: boolean;\n status: FigDataEntryStatus;\n storeKey: string;\n subscribers: Set<Owner>;\n value: unknown;\n}\n\ninterface PendingResult<T> {\n promise: Promise<DataRefreshResult<T>>;\n resolve: (result: DataRefreshResult<T>) => void;\n}\n\ninterface NormalizedKey {\n canonical: string;\n key: DataResourceKey;\n}\n\ninterface EncodePath {\n root: string;\n segments: Array<string | number>;\n}\n\ninterface LoadOptions<Lane> {\n lane: Lane;\n refresh: boolean;\n}\n\n// Why an in-flight load was aborted: \"superseded\" by a newer load, the store was\n// \"store-disposed\", or the entry was \"evicted\" from a live store because nothing\n// retained it (retention window elapsed, or last subscriber released).\ntype AbortReason = \"superseded\" | \"store-disposed\" | \"evicted\";\n\nconst DataResourceSymbol = Symbol.for(\"fig.data-resource\");\nconst DataStoreFactorySymbol = Symbol.for(\"fig.data-store-factory\");\nconst DataStoreControllerSymbol = Symbol.for(\"fig.data-store-controller\");\nconst DEFAULT_INACTIVE_RETENTION_MS = 5 * 60 * 1000;\nconst DEFAULT_PRELOAD_RETENTION_MS = 30 * 1000;\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\ntype TimerHandle = ReturnType<typeof setTimeout>;\n\nconst dataStoreFactory: FigDataStoreFactory = createRendererDataStore;\n\nexport function dataResource<TArgs extends unknown[], TValue>(\n options: DataResourceOptions<TArgs, TValue>,\n): DataResource<TArgs, TValue> {\n const resource = {\n $$typeof: DataResourceSymbol,\n [DataStoreFactorySymbol]: dataStoreFactory,\n debugArgs: options.debugArgs,\n key: options.key,\n load: options.load,\n };\n return resource;\n}\n\nexport function ensureData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): Promise<TValue> {\n return resolveDataMutationStore(\"ensureData\").ensureData(resource, ...args);\n}\n\nexport function invalidateData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): void {\n resolveDataMutationStore(\"invalidateData\").invalidateData(resource, ...args);\n}\n\nexport function invalidateDataError(error: unknown): boolean {\n return resolveDataMutationStore(\"invalidateDataError\").invalidateDataError(\n error,\n );\n}\n\nexport function invalidateDataKey(key: DataResourceKey): void {\n resolveDataMutationStore(\"invalidateDataKey\").invalidateDataKey(key);\n}\n\nexport function invalidateDataPrefix(prefix: DataResourceKey): void {\n resolveDataMutationStore(\"invalidateDataPrefix\").invalidateDataPrefix(prefix);\n}\n\nexport function refreshData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): Promise<DataRefreshResult<TValue>> {\n return resolveDataMutationStore(\"refreshData\").refreshData(resource, ...args);\n}\n\n// Captures the ambient store as an explicit handle. Call it synchronously\n// wherever Fig is executing — render, event handlers, actions, effects — and\n// keep the reference: unlike the free functions above, the handle's methods\n// still work after an `await`, where the ambient slot is gone.\nexport function readDataStore(): FigDataStoreHandle {\n return resolveCurrentDataStore(\n \"readDataStore() must be called synchronously while Fig is executing — \" +\n \"during render, an event handler, an action, or an effect. Capture \" +\n \"the handle there and use it after awaits.\",\n );\n}\n\ninterface DataStoreControllerState {\n host: FigDataStoreHost | null;\n}\n\nexport function createDataStore(\n options: FigDataStoreOptions = {},\n): FigDataStoreController {\n const state: DataStoreControllerState = { host: null };\n const store = createRendererDataStore<object, unknown>({\n getLane: () => (state.host === null ? null : state.host.getLane()),\n partition: options.partition,\n schedule: (owner, lane) => state.host?.schedule(owner, lane),\n });\n Object.defineProperty(store, DataStoreControllerSymbol, { value: state });\n if (options.initialData !== undefined) store.hydrate(options.initialData);\n return store;\n}\n\nexport function isDataStoreController(\n value: unknown,\n): value is FigDataStoreController {\n return (\n (typeof value === \"object\" || typeof value === \"function\") &&\n value !== null &&\n Object.hasOwn(value, DataStoreControllerSymbol)\n );\n}\n\nexport function attachDataStore(\n controller: FigDataStoreController,\n host: FigDataStoreHost,\n initialData?: readonly FigDataHydrationEntry[],\n): FigDataStore {\n if (host.partition !== undefined || initialData !== undefined) {\n throw new Error(\n \"Pass partition and initialData to createDataStore(), not the renderer, when adopting a data store.\",\n );\n }\n const state = (\n controller as FigDataStoreController &\n Record<symbol, DataStoreControllerState | undefined>\n )[DataStoreControllerSymbol];\n if (state === undefined) {\n throw new Error(\"dataStore must be created with createDataStore().\");\n }\n if (state.host !== null) {\n throw new Error(\"A data store can only be adopted by one Fig renderer.\");\n }\n state.host = host;\n return controller as FigDataStore;\n}\n\nfunction resolveDataMutationStore(name: string): FigDataStore {\n return resolveCurrentDataStore(\n `${name}() must be called synchronously while Fig is executing — ` +\n \"during render, an event handler, an action, or an effect. Capture \" +\n \"readDataStore() (or root.data) synchronously and call the handle instead.\",\n );\n}\n\nexport function createRendererDataStore<Owner extends object, Lane>(\n host: DataStoreHost<Owner, Lane>,\n): DataStore<Owner, Lane> {\n return new DefaultDataStore(host);\n}\n\nexport function normalizeDataResourceKey(key: DataResourceKey): string {\n return normalizeKey(key).canonical;\n}\n\nclass DefaultDataStore<Owner extends object, Lane> implements DataStore<\n Owner,\n Lane\n> {\n private readonly entries = new Map<string, Entry<Owner, Lane>>();\n private readonly inactiveRetentionMs: number;\n private readonly ownerKeys = new WeakMap<object, Set<string>>();\n private readonly pendingOwnerKeys = new WeakMap<object, Set<string>>();\n private readonly partitionKey: string;\n private readonly preloadRetentionMs: number;\n private disposed = false;\n\n constructor(readonly host: DataStoreHost<Owner, Lane>) {\n this.inactiveRetentionMs =\n host.inactiveRetentionMs ?? DEFAULT_INACTIVE_RETENTION_MS;\n this.partitionKey =\n host.partition === undefined\n ? \"\"\n : encodeValue(host.partition, createEncodePath(\"partition\"));\n this.preloadRetentionMs =\n host.preloadRetentionMs ?? DEFAULT_PRELOAD_RETENTION_MS;\n }\n\n commitDataDependencies(owner: Owner, previousOwner: object | null): void {\n const nextKeys = this.pendingOwnerKeys.get(owner) ?? null;\n const ownerKeys = this.ownerKeys.get(owner) ?? null;\n const previousOwnerKeys =\n previousOwner === null\n ? null\n : (this.ownerKeys.get(previousOwner) ?? null);\n this.pendingOwnerKeys.delete(owner);\n\n if (\n (nextKeys === null || nextKeys.size === 0) &&\n ownerKeys === null &&\n previousOwnerKeys === null\n ) {\n return;\n }\n\n // Capture the entries this fiber's generations subscribed to before the\n // delete, then abort any that end up with no retainer once the new owner has\n // re-subscribed. Keys the owner still reads keep at least one subscriber, so\n // only genuinely dropped keys are orphaned.\n let orphanCandidates: Set<Entry<Owner, Lane>> | null = null;\n orphanCandidates = this.collectSubscribedEntries(\n ownerKeys,\n orphanCandidates,\n );\n orphanCandidates = this.collectSubscribedEntries(\n previousOwnerKeys,\n orphanCandidates,\n );\n\n this.deleteDataOwner(owner, nextKeys);\n if (previousOwner !== null) this.deleteDataOwner(previousOwner, nextKeys);\n\n if (nextKeys !== null && nextKeys.size > 0) {\n this.ownerKeys.set(owner, nextKeys);\n\n for (const key of nextKeys) {\n const entry = this.entries.get(key);\n if (entry !== undefined) {\n this.clearInactiveTimer(entry);\n entry.subscribers.add(owner);\n this.notifyEntryChange(entry);\n }\n }\n }\n\n if (orphanCandidates !== null) {\n for (const entry of orphanCandidates) this.abortOrphanedLoad(entry);\n }\n }\n\n releaseDataOwner(owner: object): void {\n // The genuine-deletion path (fiber unmount). Unlike deleteDataOwner, which\n // is also used for transient commit churn, this aborts in-flight loads left\n // with no retainer so an unmounted subtree does not keep fetching.\n const orphanCandidates = this.collectSubscribedEntries(\n this.ownerKeys.get(owner) ?? null,\n null,\n );\n this.deleteDataOwner(owner);\n if (orphanCandidates !== null) {\n for (const entry of orphanCandidates) this.abortOrphanedLoad(entry);\n }\n }\n\n resetDataDependencies(owner: object): void {\n // Reads accumulate into pendingOwnerKeys as a render runs. A render attempt\n // can be abandoned before commit (suspense retry, concurrent interruption,\n // the strict shadow pass), and the work-in-progress fiber object is reused\n // across attempts, so the keys must be cleared at the start of each render\n // or stale dependencies from a discarded attempt would be committed.\n this.pendingOwnerKeys.delete(owner);\n }\n\n deleteDataOwner(\n owner: object,\n retainedKeys: ReadonlySet<string> | null = null,\n ): void {\n this.pendingOwnerKeys.delete(owner);\n const keys = this.ownerKeys.get(owner);\n if (keys === undefined) return;\n\n this.ownerKeys.delete(owner);\n for (const key of keys) {\n const entry = this.entries.get(key);\n if (entry === undefined) continue;\n\n entry.subscribers.delete(owner as Owner);\n this.notifyEntryChange(entry);\n if (retainedKeys?.has(key) !== true) this.scheduleInactiveCleanup(entry);\n }\n }\n\n private collectSubscribedEntries(\n keys: ReadonlySet<string> | null,\n into: Set<Entry<Owner, Lane>> | null,\n ): Set<Entry<Owner, Lane>> | null {\n if (keys === null) return into;\n\n for (const key of keys) {\n const entry = this.entries.get(key);\n if (entry !== undefined) {\n into ??= new Set();\n into.add(entry);\n }\n }\n\n return into;\n }\n\n private abortOrphanedLoad(entry: Entry<Owner, Lane>): void {\n // Only a value-less in-flight load (a cache-miss \"pending\" entry) with no\n // committed subscriber and no preload retainer is safe to drop: it has no\n // value to lose, and any reader of such a key suspends rather than commits,\n // so it cannot be handed off to a sibling mid-commit. Value-bearing entries\n // are left alone — a \"refreshing\" entry still serves a usable value, and its\n // refresh settles into the normal inactive-retention path. Evicting those\n // would discard a live value or strand a sibling that read it without\n // suspending.\n if (this.entries.get(entry.storeKey) !== entry) return;\n if (\n entry.subscribers.size > 0 ||\n entry.preloadTimer !== null ||\n entry.ensureRetainers > 0 ||\n entry.pending === null ||\n entryHasValue(entry)\n ) {\n return;\n }\n\n this.evictEntry(entry, \"evicted\");\n }\n\n dispose(): void {\n this.disposed = true;\n\n for (const entry of this.entries.values()) {\n this.clearInactiveTimer(entry);\n this.clearPreloadTimer(entry);\n this.abortEntryGenerations(entry, \"store-disposed\");\n this.notifyEntryChange(entry);\n }\n }\n\n hydrate(entries: readonly FigDataHydrationEntry[]): void {\n if (this.disposed) return;\n\n for (const hydrated of entries) {\n const normalized = normalizeKey(hydrated.key);\n const storeKey = this.storeKey(normalized.canonical);\n const current = this.entries.get(storeKey);\n\n if (current !== undefined) {\n this.hydrateEntry(current, normalized.key, hydrated.value);\n this.publish(current);\n continue;\n }\n\n const entry = this.createEntry(\n normalized,\n storeKey,\n null,\n null,\n \"fulfilled\",\n hydrated.value,\n );\n this.entries.set(storeKey, entry);\n this.notifyEntryChange(entry);\n }\n }\n\n snapshot(): FigDataHydrationEntry[] {\n const entries: FigDataHydrationEntry[] = [];\n\n for (const entry of this.entries.values()) {\n if (entryHasValue(entry))\n entries.push({ key: entry.key, value: entry.value });\n }\n\n return entries;\n }\n\n inspectDataEntries(): DataStoreEntrySnapshot[] {\n return Array.from(this.entries.values(), (entry) =>\n this.snapshotEntry(entry),\n );\n }\n\n inspectDataDependencyCanonicalKeys(owner: object): string[] {\n // Inspection surface only (devtools snapshots are dev-gated); returns\n // empty in prod even though ownerKeys is populated there.\n if (!__DEV__) return [];\n\n const keys = this.ownerKeys.get(owner);\n if (keys === undefined) return [];\n\n const dependencies: string[] = [];\n for (const key of keys) {\n const entry = this.entries.get(key);\n if (entry !== undefined) dependencies.push(entry.canonicalKey);\n }\n return dependencies;\n }\n\n invalidateData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): void {\n if (this.disposed) return;\n\n const entry = this.entryFor(resource, args, false);\n if (entry === null) return;\n\n this.invalidateEntry(entry, this.host.getLane());\n }\n\n invalidateDataError(error: unknown): boolean {\n if (this.disposed) return false;\n\n const keys = dataResourceKeysForError(error);\n if (keys === undefined || keys.length === 0) return false;\n\n const entries: Entry<Owner, Lane>[] = [];\n for (const key of keys) {\n const entry = this.entryForKey(key);\n if (entry !== null) entries.push(entry);\n }\n\n this.invalidateEntries(entries, error);\n return true;\n }\n\n invalidateDataKey(key: DataResourceKey): void {\n if (this.disposed) return;\n\n const entry = this.entryForKey(key);\n if (entry === null) return;\n\n this.invalidateEntry(entry, this.host.getLane());\n }\n\n invalidateDataPrefix(prefix: DataResourceKey): void {\n if (this.disposed) return;\n\n const prefixCanonical = normalizeKey(prefix).canonical;\n const entries: Entry<Owner, Lane>[] = [];\n for (const entry of this.entries.values()) {\n if (canonicalKeyStartsWith(entry.canonicalKey, prefixCanonical)) {\n entries.push(entry);\n }\n }\n\n this.invalidateEntries(entries);\n }\n\n async ensureData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): Promise<TValue> {\n for (;;) {\n if (this.disposed) {\n throw new Error(\n \"ensureData() requires a live data store; this store was disposed.\",\n );\n }\n\n const entry = this.entryFor(resource, args, true);\n this.clearInactiveTimer(entry);\n this.retainPreload(entry);\n\n if (entryHasValue(entry)) {\n this.revalidateIfStale(entry, resource, args);\n return entry.value as TValue;\n }\n\n if (entry.status === \"rejected\") throwDataResourceError(entry);\n\n entry.ensureRetainers += 1;\n try {\n if (entry.pending !== null) {\n await entry.pending.promise;\n } else {\n await this.startLoad(entry, resource, args, {\n lane: this.host.getLane(),\n refresh: false,\n });\n }\n } finally {\n entry.ensureRetainers -= 1;\n // Hand retention back to the normal preload window so a reader\n // (the route component about to render) can still claim the entry.\n if (this.entries.get(entry.storeKey) === entry) {\n this.retainPreload(entry);\n }\n }\n // Loop and re-inspect the entry rather than trusting this load's\n // result: a superseding load, a server hydration, or an eviction may\n // have changed the authoritative state while we awaited.\n }\n }\n\n preloadData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): void {\n if (this.disposed || resource.load === undefined) return;\n\n const entry = this.entryFor(resource, args, true);\n this.clearInactiveTimer(entry);\n this.retainPreload(entry);\n if (entry.pending !== null) return;\n if (entry.status === \"fulfilled\" && !entry.stale) return;\n\n void this.startLoad(entry, resource, args, {\n lane: this.host.getLane(),\n refresh: entry.status === \"fulfilled\",\n });\n }\n\n readData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n owner: Owner,\n ): TValue {\n const entry = this.entryFor(resource, args, true);\n this.clearInactiveTimer(entry);\n this.clearPreloadTimer(entry);\n this.addOwnerKey(owner, entry.storeKey);\n this.revalidateIfStale(entry, resource, args);\n\n if (entry.status === \"pending\" && entry.pending === null) {\n void this.startLoad(entry, resource, args, {\n lane: this.host.getLane(),\n refresh: false,\n });\n }\n\n return this.readCurrentValue(entry);\n }\n\n refreshData<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n ): Promise<DataRefreshResult<TValue>> {\n if (this.disposed) {\n return Promise.resolve({\n reason: \"store-disposed\",\n staleValue: undefined,\n status: \"aborted\",\n });\n }\n\n if (resource.load === undefined) {\n const entry = this.entryFor(resource, args, false);\n if (entry === null) {\n return Promise.resolve(unsupportedRefreshResult<TValue>());\n }\n\n this.clearInactiveTimer(entry);\n return Promise.resolve(unsupportedRefreshResult<TValue>(entry));\n }\n\n const entry = this.entryFor(resource, args, true);\n this.clearInactiveTimer(entry);\n\n if (entry.pending !== null && entry.status !== \"refreshing\") {\n return entry.pending.promise as Promise<DataRefreshResult<TValue>>;\n }\n\n return this.startLoad(entry, resource, args, {\n lane: this.host.getLane(),\n refresh: entry.status === \"fulfilled\" || entry.status === \"refreshing\",\n });\n }\n\n run<T>(callback: () => T): T {\n const previousStore = setCurrentDataStore(this);\n try {\n return callback();\n } finally {\n setCurrentDataStore(previousStore);\n }\n }\n\n private addOwnerKey(owner: Owner, key: string): void {\n let keys = this.pendingOwnerKeys.get(owner);\n if (keys === undefined) {\n keys = new Set();\n this.pendingOwnerKeys.set(owner, keys);\n }\n\n keys.add(key);\n }\n\n private entryFor<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n create: true,\n ): Entry<Owner, Lane>;\n private entryFor<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n create: false,\n ): Entry<Owner, Lane> | null;\n private entryFor<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n create: boolean,\n ): Entry<Owner, Lane> | null {\n const normalized = normalizeKey(resource.key(...args));\n // The fingerprint feeds only the dev drift diagnostics below, so\n // production never pays for encoding the args on every read.\n const fingerprint = __DEV__ ? fingerprintFor(resource, args) : null;\n const key = this.storeKey(normalized.canonical);\n const current = this.entries.get(key);\n\n if (current !== undefined) {\n if (__DEV__) {\n diagnoseEntryDrift(\n current,\n resource,\n normalized.canonical,\n fingerprint,\n );\n }\n return current;\n }\n\n if (!create) return null;\n\n const entry = this.createEntry(\n normalized,\n key,\n resource as DataResource<unknown[], unknown>,\n fingerprint,\n \"pending\",\n undefined,\n );\n // A disposed store is terminal: hand back a transient entry but never\n // register it, so post-dispose reads cannot resurrect the cache.\n if (this.disposed) return entry;\n\n this.entries.set(key, entry);\n this.notifyEntryChange(entry);\n return entry;\n }\n\n private revalidateIfStale<TArgs extends unknown[], TValue>(\n entry: Entry<Owner, Lane>,\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n ): void {\n if (\n entry.status !== \"fulfilled\" ||\n !entry.stale ||\n entry.pending !== null ||\n entry.refreshError !== undefined ||\n resource.load === undefined\n ) {\n return;\n }\n\n // Serve the stale value and revalidate in the background. A recorded\n // refreshError blocks retries until an explicit invalidate/refresh.\n void this.startLoad(entry, resource, args, {\n lane: this.host.getLane(),\n refresh: true,\n });\n }\n\n private entryForKey(key: DataResourceKey): Entry<Owner, Lane> | null {\n const normalized = normalizeKey(key);\n return this.entries.get(this.storeKey(normalized.canonical)) ?? null;\n }\n\n private createEntry(\n normalized: NormalizedKey,\n storeKey: string,\n resource: DataResource<unknown[], unknown> | null,\n fingerprint: string | null,\n status: FigDataEntryStatus,\n value: unknown,\n ): Entry<Owner, Lane> {\n return {\n canonicalKey: normalized.canonical,\n controller: null,\n ensureRetainers: 0,\n error: undefined,\n fingerprint,\n generation: 0,\n invalidationVersion: 0,\n inactiveTimer: null,\n key: normalized.key,\n lane: null,\n pending: null,\n preloadTimer: null,\n refreshError: undefined,\n resource,\n stale: false,\n status,\n storeKey,\n subscribers: new Set(),\n value,\n valueController: null,\n valueErrors: new WeakSet(),\n };\n }\n\n private hydrateEntry(\n entry: Entry<Owner, Lane>,\n key: DataResourceKey,\n value: unknown,\n ): void {\n this.clearInactiveTimer(entry);\n this.abortEntryGenerations(entry, \"superseded\");\n entry.error = undefined;\n entry.generation += 1;\n // The hydrated value replaces whatever attributed hole errors the old\n // value carried; a boundary still holding one must not retire it.\n entry.valueErrors = new WeakSet();\n entry.invalidationVersion = 0;\n entry.key = key;\n entry.lane = null;\n entry.refreshError = undefined;\n entry.stale = false;\n entry.status = \"fulfilled\";\n entry.value = value;\n }\n\n private storeKey(canonicalKey: string): string {\n return this.partitionKey === \"\"\n ? canonicalKey\n : `${this.partitionKey}:${canonicalKey}`;\n }\n\n private startLoad<TArgs extends unknown[], TValue>(\n entry: Entry<Owner, Lane>,\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n options: LoadOptions<Lane>,\n ): Promise<DataRefreshResult<TValue>> {\n const hadValue = entryHasValue(entry);\n const load = resource.load;\n\n if (this.disposed) {\n return Promise.resolve(abortedRefreshResult(entry, \"store-disposed\"));\n }\n\n if (load === undefined) {\n const error = new Error(\n `Data resource \"${entry.canonicalKey}\" has no loader and no hydrated value.`,\n );\n entry.error = error;\n entry.status = \"rejected\";\n markDataResourceError(error, entry.key);\n this.notifyEntryChange(entry);\n return Promise.resolve(unsupportedRefreshResult<TValue>(entry));\n }\n\n this.abortPendingLoad(entry, \"superseded\");\n const controller = new AbortController();\n // This generation's attributed hole errors. Allocated per load and\n // installed on the entry only at publish: attribution can fire before the\n // root value settles (a hole's error row can share a network chunk with\n // the root row), so the set must survive fulfillment, and a generation\n // that never publishes must never make the entry's live value\n // invalidatable through its own errors.\n const valueErrors = new WeakSet<object>();\n const generation = entry.generation + 1;\n const invalidationVersion = entry.invalidationVersion;\n const pending = createPendingResult<TValue>();\n\n entry.controller = controller;\n entry.generation = generation;\n entry.lane = options.lane;\n entry.pending = pending as PendingResult<unknown>;\n entry.status = options.refresh && hadValue ? \"refreshing\" : \"pending\";\n this.notifyEntryChange(entry);\n\n let loaded: TValue | PromiseLike<TValue>;\n try {\n loaded = load(\n ...args,\n this.createLoadContext(entry, controller, valueErrors),\n );\n } catch (error) {\n loaded = Promise.reject(error);\n }\n\n const settleAborted = (): DataRefreshResult<TValue> => {\n const result = abortedRefreshResult<TValue, Owner, Lane>(\n entry,\n \"superseded\",\n );\n pending.resolve(result);\n return result;\n };\n const fulfill = (value: TValue): DataRefreshResult<TValue> => {\n if (entry.generation !== generation || controller.signal.aborted) {\n return settleAborted();\n }\n\n const superseded = entry.valueController;\n // This generation is now the authoritative value; its controller stays\n // live for the background work still streaming into the value.\n entry.controller = null;\n entry.valueController = controller;\n entry.valueErrors = valueErrors;\n entry.error = undefined;\n entry.pending = null;\n entry.refreshError = undefined;\n entry.stale = entry.invalidationVersion !== invalidationVersion;\n entry.status = \"fulfilled\";\n entry.value = value;\n this.publish(entry);\n // The predecessor loses authority only now that the successor's value\n // has published: subscribers re-render top-down onto the new tree in\n // the same pass, so the old generation's retired holes unmount before\n // their abort rejections could reach a mounted reader.\n superseded?.abort();\n const result: DataRefreshResult<TValue> = { status: \"fulfilled\", value };\n pending.resolve(result);\n return result;\n };\n const reject = (error: unknown): DataRefreshResult<TValue> => {\n if (entry.generation !== generation || controller.signal.aborted) {\n return settleAborted();\n }\n\n // A rejected load's generation never becomes authoritative; abort its\n // signal so background work it started stops. The previous\n // generation's valueController is deliberately untouched: a failed\n // refresh keeps the stale value fully alive, live holes included.\n entry.controller = null;\n controller.abort();\n entry.pending = null;\n\n if (hadValue && entryHasValue(entry)) {\n entry.refreshError = error;\n entry.stale = true;\n entry.status = \"fulfilled\";\n this.publish(entry);\n const result: DataRefreshResult<TValue> = {\n error,\n staleValue: entry.value as TValue,\n status: \"rejected\",\n };\n pending.resolve(result);\n return result;\n }\n\n entry.error = error;\n entry.status = \"rejected\";\n markDataResourceError(error, entry.key);\n this.publish(entry);\n const result: DataRefreshResult<TValue> = { error, status: \"rejected\" };\n pending.resolve(result);\n return result;\n };\n\n if (!isThenable(loaded)) {\n fulfill(loaded);\n return pending.promise;\n }\n\n void Promise.resolve(loaded).then(fulfill, reject);\n\n return pending.promise;\n }\n\n private createLoadContext(\n entry: Entry<Owner, Lane>,\n controller: AbortController,\n valueErrors: WeakSet<object>,\n ): DataResourceLoadContext {\n const context: DataResourceLoadContext = { signal: controller.signal };\n defineLoadContextCapabilities(context, {\n key: entry.key,\n attributeError: (error) => {\n // A fulfilled payload value may reject one of its streamed holes later.\n // Attribute that error for as long as this generation's signal is live —\n // the signal's lifetime IS its authority, so a visible value keeps\n // attributing through a superseding refresh's window. Retired decodes\n // must not make their successor invalidatable by a stale error object;\n // the errors land in this generation's own set, which reaches the entry\n // only if this generation publishes.\n if (this.disposed || controller.signal.aborted) return;\n markDataResourceError(error, entry.key);\n if (isAttributableError(error)) valueErrors.add(error);\n },\n hydrate: (entries) => {\n // Server-pushed rows hydrate for as long as this generation's signal\n // is live — the same authority window as attributeError. A visible\n // value keeps hydrating through a superseding refresh's window;\n // retired, evicted, and disposed decodes cannot mutate the store\n // (every retirement path aborts the signal).\n if (this.disposed || controller.signal.aborted) return;\n\n // The loading entry's own value comes from the loader's return, never\n // from a data row: hydrating its key here would supersede — and abort —\n // the very load delivering it.\n const foreign = entries.filter(\n (hydrated) =>\n this.storeKey(normalizeKey(hydrated.key).canonical) !==\n entry.storeKey,\n );\n if (__DEV__ && foreign.length !== entries.length) {\n warn(\n `Data rows targeting the loading key ${entry.canonicalKey} were skipped: a loader cannot hydrate its own entry.`,\n );\n }\n if (foreign.length > 0) this.hydrate(foreign);\n },\n });\n return context;\n }\n\n private publish(entry: Entry<Owner, Lane>): void {\n this.notifyEntryChange(entry);\n this.scheduleInactiveCleanup(entry);\n\n this.scheduleSubscribers(entry, entry.lane ?? this.host.getLane());\n }\n\n private scheduleSubscribers(entry: Entry<Owner, Lane>, lane: Lane): void {\n for (const subscriber of entry.subscribers) {\n this.host.schedule(subscriber, lane);\n }\n }\n\n // Aborts only the in-flight load: supersession-at-start cancels a wasted\n // request without revoking the authoritative generation's signal.\n private abortPendingLoad(\n entry: Entry<Owner, Lane>,\n reason: AbortReason,\n ): void {\n entry.controller?.abort();\n entry.controller = null;\n\n const pending = entry.pending;\n if (pending === null) return;\n\n entry.pending = null;\n pending.resolve(abortedRefreshResult(entry, reason));\n }\n\n // Terminal paths (hydrate-over, eviction, disposal) end every generation:\n // the pending load and the authoritative value's background work.\n private abortEntryGenerations(\n entry: Entry<Owner, Lane>,\n reason: AbortReason,\n ): void {\n this.abortPendingLoad(entry, reason);\n entry.valueController?.abort();\n entry.valueController = null;\n }\n\n private retainPreload(entry: Entry<Owner, Lane>): void {\n this.clearPreloadTimer(entry);\n if (this.disposed || !Number.isFinite(this.preloadRetentionMs)) return;\n\n entry.preloadTimer = scheduleStoreTimer(\n () => {\n entry.preloadTimer = null;\n if (\n entry.subscribers.size === 0 &&\n entry.ensureRetainers === 0 &&\n entry.pending !== null &&\n !entryHasValue(entry)\n ) {\n this.evictEntry(entry, \"evicted\");\n return;\n }\n this.scheduleInactiveCleanup(entry);\n },\n Math.max(0, this.preloadRetentionMs),\n );\n }\n\n private scheduleInactiveCleanup(entry: Entry<Owner, Lane>): void {\n if (\n this.disposed ||\n entry.subscribers.size > 0 ||\n entry.pending !== null ||\n entry.preloadTimer !== null ||\n entry.ensureRetainers > 0 ||\n !Number.isFinite(this.inactiveRetentionMs)\n ) {\n return;\n }\n\n this.clearInactiveTimer(entry);\n entry.inactiveTimer = scheduleStoreTimer(\n () => {\n entry.inactiveTimer = null;\n if (\n entry.subscribers.size > 0 ||\n entry.pending !== null ||\n entry.preloadTimer !== null ||\n entry.ensureRetainers > 0\n ) {\n return;\n }\n this.evictEntry(entry, \"evicted\");\n },\n Math.max(0, this.inactiveRetentionMs),\n );\n }\n\n private evictEntry(entry: Entry<Owner, Lane>, reason: AbortReason): void {\n if (this.entries.get(entry.storeKey) !== entry) return;\n\n this.clearInactiveTimer(entry);\n this.clearPreloadTimer(entry);\n this.abortEntryGenerations(entry, reason);\n this.entries.delete(entry.storeKey);\n this.host.onEntryEvict?.(this.snapshotEntry(entry));\n }\n\n private clearInactiveTimer(entry: Entry<Owner, Lane>): void {\n if (entry.inactiveTimer === null) return;\n\n clearTimeout(entry.inactiveTimer);\n entry.inactiveTimer = null;\n }\n\n private clearPreloadTimer(entry: Entry<Owner, Lane>): void {\n if (entry.preloadTimer === null) return;\n\n clearTimeout(entry.preloadTimer);\n entry.preloadTimer = null;\n }\n\n private notifyEntryChange(entry: Entry<Owner, Lane>): void {\n this.host.onEntryChange?.(this.snapshotEntry(entry));\n }\n\n private snapshotEntry(entry: Entry<Owner, Lane>): DataStoreEntrySnapshot {\n const hasValue = entryHasValue(entry);\n return {\n canonicalKey: entry.canonicalKey,\n error: entry.status === \"rejected\" ? entry.error : undefined,\n hasValue,\n key: entry.key,\n pending: entry.pending !== null,\n refreshError: entry.refreshError,\n stale: entry.stale,\n status: entry.status,\n subscriberCount: entry.subscribers.size,\n value: hasValue ? entry.value : undefined,\n };\n }\n\n private readCurrentValue<TValue>(entry: Entry<Owner, Lane>): TValue {\n if (entryHasValue(entry)) {\n return entry.value as TValue;\n }\n\n if (entry.status === \"rejected\") throwDataResourceError(entry);\n\n if (entry.pending === null) {\n throw new Error(\n `Data resource \"${entry.canonicalKey}\" has no pending load.`,\n );\n }\n\n throw entry.pending.promise;\n }\n\n private invalidateEntry(\n entry: Entry<Owner, Lane>,\n lane: Lane,\n attributedError?: unknown,\n ): void {\n entry.invalidationVersion += 1;\n entry.stale = true;\n // Clearing the prior refresh failure re-enables auto-refresh-on-read; an\n // explicit invalidation is a fresh \"this is stale, fetch again\" intent.\n entry.refreshError = undefined;\n if (\n isAttributableError(attributedError) &&\n entry.valueErrors.has(attributedError)\n ) {\n entry.valueController?.abort();\n entry.valueController = null;\n entry.valueErrors = new WeakSet();\n entry.value = undefined;\n entry.error = undefined;\n entry.status = \"pending\";\n } else if (entry.status === \"rejected\") {\n // The same intent applies to a cached rejection: without this, every\n // read rethrows the old error forever — remounting an ErrorBoundary\n // could never recover. Back to pending, so the next read loads afresh.\n entry.error = undefined;\n entry.status = \"pending\";\n }\n this.notifyEntryChange(entry);\n if (entry.subscribers.size === 0) return;\n\n this.scheduleSubscribers(entry, lane);\n }\n\n private invalidateEntries(\n entries: readonly Entry<Owner, Lane>[],\n attributedError?: unknown,\n ): void {\n if (entries.length === 0) return;\n\n const lane = this.host.getLane();\n for (const entry of entries) {\n this.invalidateEntry(entry, lane, attributedError);\n }\n }\n}\n\nfunction normalizeKey(key: DataResourceKey): NormalizedKey {\n if (!Array.isArray(key) || typeof key[0] !== \"string\") {\n throw new Error(\n \"Data resource keys must be arrays starting with a string.\",\n );\n }\n\n return {\n canonical: encodeArray(key, createEncodePath(\"key\")),\n key,\n };\n}\n\nfunction canonicalKeyStartsWith(key: string, prefix: string): boolean {\n if (key === prefix) return true;\n\n const arrayPrefix = prefix.slice(0, -1);\n return key.startsWith(arrayPrefix) && key[arrayPrefix.length] === \",\";\n}\n\nfunction entryHasValue<Owner extends object, Lane>(\n entry: Entry<Owner, Lane>,\n): boolean {\n return entry.status === \"fulfilled\" || entry.status === \"refreshing\";\n}\n\nfunction throwDataResourceError<Owner extends object, Lane>(\n entry: Entry<Owner, Lane>,\n): never {\n markDataResourceError(entry.error, entry.key);\n throw entry.error;\n}\n\nfunction abortedRefreshResult<T, Owner extends object, Lane>(\n entry: Entry<Owner, Lane>,\n reason: AbortReason,\n): DataRefreshResult<T> {\n return {\n reason,\n staleValue: entryHasValue(entry) ? (entry.value as T) : undefined,\n status: \"aborted\",\n };\n}\n\nfunction unsupportedRefreshResult<\n T,\n Owner extends object = object,\n Lane = unknown,\n>(entry?: Entry<Owner, Lane>): DataRefreshResult<T> {\n const result: DataRefreshResult<T> = {\n reason: \"no-client-loader\",\n status: \"unsupported\",\n };\n\n if (entry !== undefined) {\n result.staleValue = entryHasValue(entry) ? (entry.value as T) : undefined;\n }\n\n return result;\n}\n\nfunction fingerprintFor<TArgs extends unknown[], TValue>(\n resource: DataResource<TArgs, TValue>,\n args: TArgs,\n): string | null {\n if (resource.debugArgs !== undefined) {\n return encodeValue(\n resource.debugArgs(...args),\n createEncodePath(\"debugArgs\"),\n );\n }\n\n try {\n return encodeArray(args, createEncodePath(\"args\"));\n } catch {\n return null;\n }\n}\n\nfunction diagnoseEntryDrift<\n Owner extends object,\n Lane,\n TArgs extends unknown[],\n TValue,\n>(\n entry: Entry<Owner, Lane>,\n resource: DataResource<TArgs, TValue>,\n key: string,\n fingerprint: string | null,\n): void {\n if (!__DEV__) return;\n\n if (entry.resource === null) {\n entry.resource = resource as DataResource<unknown[], unknown>;\n } else if (entry.resource !== resource) {\n warn(`Data resource key ${key} was read by multiple resource definitions.`);\n }\n\n if (\n entry.fingerprint !== null &&\n fingerprint !== null &&\n entry.fingerprint !== fingerprint\n ) {\n warn(\n `Data resource key ${key} was read with different argument fingerprints.`,\n );\n }\n}\n\nfunction warn(message: string): void {\n if (typeof console === \"undefined\") return;\n console.warn(message);\n}\n\nfunction createEncodePath(root: string): EncodePath {\n return { root, segments: [] };\n}\n\nfunction formatEncodePath(path: EncodePath): string {\n let text = path.root;\n for (const segment of path.segments) {\n text += typeof segment === \"number\" ? `[${segment}]` : `.${segment}`;\n }\n return text;\n}\n\nfunction encodeArray(values: readonly unknown[], path: EncodePath): string {\n const parts: string[] = [];\n for (let index = 0; index < values.length; index += 1) {\n path.segments.push(index);\n parts.push(encodeValue(values[index], path));\n path.segments.pop();\n }\n return `[${parts.join(\",\")}]`;\n}\n\nfunction encodeObject(value: object, path: EncodePath): string {\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new Error(\n `Invalid data resource key value at ${formatEncodePath(path)}.`,\n );\n }\n\n const record = value as Record<string, unknown>;\n const keys = Object.keys(record).sort();\n const parts: string[] = [];\n\n for (const key of keys) {\n const child = record[key];\n if (child === undefined) {\n throw new Error(\n `Invalid undefined data resource key value at ${formatEncodePath(path)}.`,\n );\n }\n path.segments.push(key);\n parts.push(`${JSON.stringify(key)}:${encodeValue(child, path)}`);\n path.segments.pop();\n }\n\n return `{${parts.join(\",\")}}`;\n}\n\nfunction encodeValue(value: unknown, path: EncodePath): string {\n if (value === null) return \"null\";\n\n switch (typeof value) {\n case \"string\":\n return JSON.stringify(value);\n case \"boolean\":\n return value ? \"true\" : \"false\";\n case \"number\":\n if (!Number.isFinite(value)) {\n throw new Error(\n `Invalid number in data resource key at ${formatEncodePath(path)}.`,\n );\n }\n return Object.is(value, -0) ? \"0\" : JSON.stringify(value);\n case \"object\":\n if (Array.isArray(value)) return encodeArray(value, path);\n return encodeObject(value, path);\n default:\n throw new Error(\n `Invalid data resource key value at ${formatEncodePath(path)}.`,\n );\n }\n}\n\nfunction isThenable<T>(value: T | PromiseLike<T>): value is PromiseLike<T> {\n return (\n (typeof value === \"object\" || typeof value === \"function\") &&\n value !== null &&\n \"then\" in value &&\n typeof value.then === \"function\"\n );\n}\n\nfunction createPendingResult<T>(): PendingResult<T> {\n let resolve: (result: DataRefreshResult<T>) => void = () => undefined;\n const promise = new Promise<DataRefreshResult<T>>((settle) => {\n resolve = settle;\n });\n\n return {\n promise,\n resolve,\n };\n}\n\nfunction scheduleStoreTimer(callback: () => void, delay: number): TimerHandle {\n const timer = setTimeout(callback, delay);\n const unref = (timer as { unref?: () => void }).unref;\n if (unref !== undefined) unref.call(timer);\n return timer;\n}\n\nexport function runWithDataStore<T>(store: FigDataStore, callback: () => T): T {\n return store.run(callback);\n}\n\nexport function currentDataStore(): FigDataStore {\n return resolveCurrentDataStore();\n}\n","export interface TransitionOptions {\n types?: readonly string[];\n}\n\nexport type TransitionHandler = <T>(\n callback: () => T,\n options?: TransitionOptions,\n) => T;\n\nlet transitionHandler: TransitionHandler = (callback) => callback();\n\n/**\n * Runs state updates scheduled by `callback` at transition priority. If\n * `callback` returns a thenable, updates after an `await` remain in the\n * transition priority scope until it settles.\n */\nexport function transition<T>(\n callback: () => T,\n options?: TransitionOptions,\n): T {\n return transitionHandler(callback, options);\n}\n\nexport function setTransitionHandler(\n handler: TransitionHandler,\n): TransitionHandler {\n const previous = transitionHandler;\n transitionHandler = handler;\n return previous;\n}\n"],"mappings":";;AAQA,MAAa,mBAAmB,OAAO,IAAI,aAAa;AAExD,SAAgB,cAAiB,cAAgC;CAC/D,OAAO,OAAO,QACX,UAA4C,MAAM,UACnD;EACE,UAAU;EACV;CACF,CACF;AACF;AAEA,SAAgB,UAAU,OAA8C;CACtE,OACE,OAAO,UAAU,cACjB,cAAc,SACd,MAAM,aAAa;AAEvB;;;ACwFA,MAAM,qBAAqB,OAAO,IAAI,mBAAmB;AACzD,MAAM,yBAAyB,OAAO,IAAI,wBAAwB;AAClE,MAAM,4BAA4B,OAAO,IAAI,2BAA2B;AACxE,MAAM,gCAAgC,MAAS;AAC/C,MAAM,+BAA+B,KAAK;AAK1C,MAAM,mBAAwC;AAE9C,SAAgB,aACd,SAC6B;CAQ7B,OAAO;EANL,UAAU;GACT,yBAAyB;EAC1B,WAAW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;;;AAOlE,SAAgB,WACd,UACA,SACG;CACH,OAAO,kBAAkB,UAAU,OAAO;AAC5C;AAEA,SAAgB,qBACd,SACmB;CACnB,MAAM,WAAW;CACjB,oBAAoB;CACpB,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgub/fig",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
4
|
"description": "Fig — a UI library",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/bgub/fig",
|
|
@@ -16,11 +16,10 @@
|
|
|
16
16
|
"import": "./dist/internal.js",
|
|
17
17
|
"default": "./dist/internal.js"
|
|
18
18
|
},
|
|
19
|
-
"./
|
|
20
|
-
"types": "./dist/
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"default": "./dist/server.js"
|
|
19
|
+
"./payload": {
|
|
20
|
+
"types": "./dist/payload.d.ts",
|
|
21
|
+
"import": "./dist/payload.js",
|
|
22
|
+
"default": "./dist/payload.js"
|
|
24
23
|
},
|
|
25
24
|
"./jsx-runtime": {
|
|
26
25
|
"types": "./dist/jsx-runtime.d.ts",
|