tsdf 17.0.0 → 17.0.2
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/dist/async-storage.d.ts +1 -1
- package/dist/async-storage.js +1 -1
- package/dist/{asyncStorageAdapter-BBKVK1S_.js → asyncStorageAdapter-BuGjbXYA.js} +154 -5
- package/dist/{asyncStorageAdapter-CMohMeKm.d.ts → asyncStorageAdapter-DuAUANgu.d.ts} +1 -1
- package/dist/{asyncStorageAdapters-CkGt87Po.js → asyncStorageAdapters-ClUvxNQA.js} +2 -2
- package/dist/indexed-db-storage.d.ts +1 -1
- package/dist/indexed-db-storage.js +1 -1
- package/dist/{indexedDbPersistentStorage-D5tGmD77.js → indexedDbPersistentStorage-BSlgLveB.js} +1 -1
- package/dist/main.d.ts +56 -30
- package/dist/main.js +842 -255
- package/dist/opfs-storage.d.ts +1 -1
- package/dist/opfs-storage.js +1 -1
- package/dist/{opfsPersistentStorage-Ci0JcCo5.d.ts → opfsPersistentStorage-BB0qqnRz.d.ts} +1 -1
- package/dist/{opfsPersistentStorage-B_lVflof.js → opfsPersistentStorage-D_k77Srq.js} +1 -1
- package/dist/{types-D0ttVGmj.d.ts → types-aWgyZHLj.d.ts} +1 -1
- package/docs/fetch-scheduling.md +6 -1
- package/docs/hooks.md +39 -4
- package/docs/persistent-storage.md +1 -0
- package/docs/shared-types.md +2 -1
- package/package.json +1 -1
package/dist/async-storage.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createAsyncStorageAdapter } from "./asyncStorageAdapter-
|
|
1
|
+
import { t as createAsyncStorageAdapter } from "./asyncStorageAdapter-DuAUANgu.js";
|
|
2
2
|
export { createAsyncStorageAdapter };
|
package/dist/async-storage.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as createAsyncStorageAdapter } from "./asyncStorageAdapter-
|
|
1
|
+
import { i as createAsyncStorageAdapter } from "./asyncStorageAdapter-BuGjbXYA.js";
|
|
2
2
|
export { createAsyncStorageAdapter };
|
|
@@ -7,19 +7,76 @@ import { sleep } from "@ls-stack/utils/sleep";
|
|
|
7
7
|
import { rc_array, rc_discriminated_union, rc_literals, rc_number, rc_object, rc_parse, rc_parse_json, rc_record, rc_string, rc_tuple, rc_unknown } from "runcheck";
|
|
8
8
|
import { asPossiblyUndefined } from "@ls-stack/utils/typingFnUtils";
|
|
9
9
|
//#region src/persistentStorage/scheduleIdleCleanup.ts
|
|
10
|
+
const FALLBACK_IDLE_BUDGET_MS = 12;
|
|
11
|
+
const MIN_IDLE_TIME_REMAINING_MS = 1;
|
|
12
|
+
function getMonotonicNow() {
|
|
13
|
+
return performance.now();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Timeout-fired idle callbacks and the timer fallback do not receive a usable
|
|
17
|
+
* browser deadline. Give those ordinary tasks a small synthetic budget so
|
|
18
|
+
* maintenance still yields instead of running to completion on a busy page.
|
|
19
|
+
*/
|
|
20
|
+
function normalizeIdleDeadline(deadline) {
|
|
21
|
+
if (deadline !== void 0 && !deadline.didTimeout) return deadline;
|
|
22
|
+
const startedAt = getMonotonicNow();
|
|
23
|
+
return {
|
|
24
|
+
didTimeout: true,
|
|
25
|
+
timeRemaining: () => Math.max(0, FALLBACK_IDLE_BUDGET_MS - (getMonotonicNow() - startedAt))
|
|
26
|
+
};
|
|
27
|
+
}
|
|
10
28
|
/**
|
|
11
29
|
* Schedules a fire-and-forget cleanup callback during idle time.
|
|
12
|
-
* Uses `requestIdleCallback` when available,
|
|
30
|
+
* Uses `requestIdleCallback` when available, falling back to a timer-backed
|
|
31
|
+
* synthetic 12 ms deadline.
|
|
13
32
|
*/
|
|
14
33
|
function scheduleIdleCleanup(callback) {
|
|
15
34
|
if (typeof requestIdleCallback === "function") {
|
|
16
|
-
const idleCallbackId = requestIdleCallback(() => callback(), { timeout: 3e3 });
|
|
35
|
+
const idleCallbackId = requestIdleCallback((deadline) => callback(normalizeIdleDeadline(deadline)), { timeout: 3e3 });
|
|
17
36
|
return () => cancelIdleCallback(idleCallbackId);
|
|
18
37
|
} else {
|
|
19
|
-
const timeoutId = setTimeout(callback, 2e3);
|
|
38
|
+
const timeoutId = setTimeout(() => callback(normalizeIdleDeadline(void 0)), 2e3);
|
|
20
39
|
return () => clearTimeout(timeoutId);
|
|
21
40
|
}
|
|
22
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Tracks the current idle deadline and schedules cancellable continuations
|
|
44
|
+
* when a maintenance pass exhausts it.
|
|
45
|
+
*/
|
|
46
|
+
function createIdleCleanupContext(initialDeadline) {
|
|
47
|
+
let currentDeadline = initialDeadline;
|
|
48
|
+
let continuationCount = 0;
|
|
49
|
+
let canceled = false;
|
|
50
|
+
let cancelContinuation = null;
|
|
51
|
+
let resolveContinuation = null;
|
|
52
|
+
return {
|
|
53
|
+
cancel() {
|
|
54
|
+
if (canceled) return;
|
|
55
|
+
canceled = true;
|
|
56
|
+
cancelContinuation?.();
|
|
57
|
+
cancelContinuation = null;
|
|
58
|
+
resolveContinuation?.(null);
|
|
59
|
+
resolveContinuation = null;
|
|
60
|
+
},
|
|
61
|
+
getContinuationCount: () => continuationCount,
|
|
62
|
+
isCanceled: () => canceled,
|
|
63
|
+
shouldYield: () => canceled || currentDeadline.timeRemaining() <= MIN_IDLE_TIME_REMAINING_MS,
|
|
64
|
+
async yieldIfNeeded() {
|
|
65
|
+
if (canceled) return false;
|
|
66
|
+
if (currentDeadline.timeRemaining() > MIN_IDLE_TIME_REMAINING_MS) return true;
|
|
67
|
+
const nextDeadline = await new Promise((resolve) => {
|
|
68
|
+
resolveContinuation = resolve;
|
|
69
|
+
cancelContinuation = scheduleIdleCleanup(resolve);
|
|
70
|
+
});
|
|
71
|
+
cancelContinuation = null;
|
|
72
|
+
resolveContinuation = null;
|
|
73
|
+
if (nextDeadline === null) return false;
|
|
74
|
+
currentDeadline = nextDeadline;
|
|
75
|
+
continuationCount++;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
23
80
|
const INITIAL_MAINTENANCE_CLEANUP_DELAY_MS = 1e4;
|
|
24
81
|
/**
|
|
25
82
|
* Gives startup maintenance a short grace period before using the regular
|
|
@@ -32,7 +89,7 @@ function scheduleInitialMaintenanceCleanup(callback) {
|
|
|
32
89
|
}
|
|
33
90
|
let cancelIdleCleanup = null;
|
|
34
91
|
const timeoutId = setTimeout(() => {
|
|
35
|
-
cancelIdleCleanup = scheduleIdleCleanup(callback);
|
|
92
|
+
cancelIdleCleanup = scheduleIdleCleanup(() => callback());
|
|
36
93
|
}, INITIAL_MAINTENANCE_CLEANUP_DELAY_MS);
|
|
37
94
|
return () => {
|
|
38
95
|
clearTimeout(timeoutId);
|
|
@@ -298,6 +355,8 @@ var OfflineResolutionConflictParseError = class extends Error {
|
|
|
298
355
|
};
|
|
299
356
|
//#endregion
|
|
300
357
|
//#region src/persistentStorage/persistenceUtils.ts
|
|
358
|
+
const MAINTENANCE_SORT_CHUNK_SIZE = 100;
|
|
359
|
+
const MAINTENANCE_LOOP_CHUNK_SIZE = 25;
|
|
301
360
|
/**
|
|
302
361
|
* Creates a key set that auto-clears entries after a microtask.
|
|
303
362
|
* Used to deduplicate sync storage reads within the same event loop tick.
|
|
@@ -399,6 +458,96 @@ function keepEntriesWithinByteBudget(entries, getKey, getLastAccessAt, getSizeBy
|
|
|
399
458
|
unprotectedBytes
|
|
400
459
|
};
|
|
401
460
|
}
|
|
461
|
+
/** Deadline-aware variant used by synchronous localStorage maintenance. */
|
|
462
|
+
async function keepEntriesWithinByteBudgetDuringIdle(entries, getKey, getLastAccessAt, getSizeBytes, isPinned, isProtected, maxBytes, idleContext) {
|
|
463
|
+
const keptKeys = /* @__PURE__ */ new Set();
|
|
464
|
+
let unprotectedBytes = 0;
|
|
465
|
+
for (const [entryIndex, entry] of entries.entries()) {
|
|
466
|
+
if (entryIndex % MAINTENANCE_LOOP_CHUNK_SIZE === 0 && !await idleContext.yieldIfNeeded()) return null;
|
|
467
|
+
if (!isProtected(entry)) unprotectedBytes += getSizeBytes(entry);
|
|
468
|
+
}
|
|
469
|
+
if (unprotectedBytes <= maxBytes) {
|
|
470
|
+
for (const [entryIndex, entry] of entries.entries()) {
|
|
471
|
+
if (entryIndex % MAINTENANCE_LOOP_CHUNK_SIZE === 0 && !await idleContext.yieldIfNeeded()) return null;
|
|
472
|
+
keptKeys.add(getKey(entry));
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
keptKeys,
|
|
476
|
+
unprotectedBytes
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
const compareEntries = (left, right) => {
|
|
480
|
+
const leftProtected = isProtected(left);
|
|
481
|
+
const rightProtected = isProtected(right);
|
|
482
|
+
if (leftProtected && !rightProtected) return -1;
|
|
483
|
+
if (!leftProtected && rightProtected) return 1;
|
|
484
|
+
const leftPinned = isPinned(left);
|
|
485
|
+
const rightPinned = isPinned(right);
|
|
486
|
+
if (leftPinned && !rightPinned) return -1;
|
|
487
|
+
if (!leftPinned && rightPinned) return 1;
|
|
488
|
+
return getLastAccessAt(right) - getLastAccessAt(left);
|
|
489
|
+
};
|
|
490
|
+
const sortedChunks = [];
|
|
491
|
+
for (let chunkStart = 0; chunkStart < entries.length; chunkStart += MAINTENANCE_SORT_CHUNK_SIZE) {
|
|
492
|
+
if (!await idleContext.yieldIfNeeded()) return null;
|
|
493
|
+
sortedChunks.push(entries.slice(chunkStart, chunkStart + MAINTENANCE_SORT_CHUNK_SIZE).sort(compareEntries));
|
|
494
|
+
}
|
|
495
|
+
let mergeChunks = sortedChunks;
|
|
496
|
+
while (mergeChunks.length > 1) {
|
|
497
|
+
const nextMergeChunks = [];
|
|
498
|
+
for (let chunkIndex = 0; chunkIndex < mergeChunks.length; chunkIndex += 2) {
|
|
499
|
+
if (!await idleContext.yieldIfNeeded()) return null;
|
|
500
|
+
const leftChunk = mergeChunks[chunkIndex];
|
|
501
|
+
const rightChunk = mergeChunks[chunkIndex + 1];
|
|
502
|
+
if (leftChunk === void 0) continue;
|
|
503
|
+
if (rightChunk === void 0) {
|
|
504
|
+
nextMergeChunks.push(leftChunk);
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
const mergedChunk = [];
|
|
508
|
+
let leftIndex = 0;
|
|
509
|
+
let rightIndex = 0;
|
|
510
|
+
while (leftIndex < leftChunk.length || rightIndex < rightChunk.length) {
|
|
511
|
+
if (mergedChunk.length % MAINTENANCE_LOOP_CHUNK_SIZE === 0 && !await idleContext.yieldIfNeeded()) return null;
|
|
512
|
+
const leftEntry = leftChunk[leftIndex];
|
|
513
|
+
const rightEntry = rightChunk[rightIndex];
|
|
514
|
+
if (rightEntry === void 0 || leftEntry !== void 0 && compareEntries(leftEntry, rightEntry) <= 0) {
|
|
515
|
+
if (leftEntry !== void 0) mergedChunk.push(leftEntry);
|
|
516
|
+
leftIndex++;
|
|
517
|
+
} else {
|
|
518
|
+
mergedChunk.push(rightEntry);
|
|
519
|
+
rightIndex++;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
nextMergeChunks.push(mergedChunk);
|
|
523
|
+
}
|
|
524
|
+
mergeChunks = nextMergeChunks;
|
|
525
|
+
}
|
|
526
|
+
const sortedEntries = mergeChunks[0] ?? [];
|
|
527
|
+
let keptUnprotectedBytes = 0;
|
|
528
|
+
for (const [entryIndex, entry] of sortedEntries.entries()) {
|
|
529
|
+
if (entryIndex % MAINTENANCE_LOOP_CHUNK_SIZE === 0 && !await idleContext.yieldIfNeeded()) return null;
|
|
530
|
+
const key = getKey(entry);
|
|
531
|
+
if (isProtected(entry)) {
|
|
532
|
+
keptKeys.add(key);
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
const sizeBytes = getSizeBytes(entry);
|
|
536
|
+
if (isPinned(entry)) {
|
|
537
|
+
keptKeys.add(key);
|
|
538
|
+
keptUnprotectedBytes += sizeBytes;
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
if (keptUnprotectedBytes + sizeBytes <= maxBytes) {
|
|
542
|
+
keptKeys.add(key);
|
|
543
|
+
keptUnprotectedBytes += sizeBytes;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return {
|
|
547
|
+
keptKeys,
|
|
548
|
+
unprotectedBytes
|
|
549
|
+
};
|
|
550
|
+
}
|
|
402
551
|
//#endregion
|
|
403
552
|
//#region src/persistentStorage/persistentStorageDefaults.ts
|
|
404
553
|
const defaultMaxBytes = {
|
|
@@ -1962,4 +2111,4 @@ function serializeProtectedRef(ref) {
|
|
|
1962
2111
|
return serializeProtectedRef$1(ref);
|
|
1963
2112
|
}
|
|
1964
2113
|
//#endregion
|
|
1965
|
-
export {
|
|
2114
|
+
export { scheduleIdleCleanup as $, getIsOfflineModeFromStatus as A, createCompactLocalStorageEntry as B, isQuotaExceededError as C, OfflineResolutionConflictParseError as D, serializeJsonForStorage as E, clearSessionProtectedKeysSnapshot as F, getPayloadRecordKey as G, compareMetadata as H, getSessionProtectedKeysSnapshot as I, parseAsyncStorageRecordKey as J, getPersistedNamespaceId as K, setSessionProtectedKeysSnapshot as L, isOfflineModeStatusValue as M, offlineItemEntityRefSchema as N, compactOfflineStatusSnapshotSchema as O, offlineResolutionRecordSchema as P, createIdleCleanupContext as Q, getNavigatorLockManager as R, getSerializedStringSize as S, keepEntriesWithinByteBudgetDuringIdle as T, encodePersistedAsyncNamespaceKind as U, parseCompactLocalStorageEntry as V, getNamespaceId as W, serializeProtectedRef$1 as X, parsePersistedAsyncNamespaceKind as Y, INITIAL_MAINTENANCE_CLEANUP_DELAY_MS as Z, getTSDFDebugTimingMs as _, estimateManagedAsyncStorageEntrySizeBytes as a, createShouldIgnoreItemPredicate as b, readAsyncStorageNamespaceIndexStateUsingDriver as c, unregisterAsyncStartupStoreCleanup as d, parseAsyncStorageNamespaceKind as f, emitTSDFDebugLog as g, logPersistentStorageQuotaCleanup as h, createAsyncStorageAdapter as i, isModeEffectivelyActive as j, defaultOfflineRuntimeConfig as k, registerAsyncStartupStoreCleanup as l, getOfflineSessionStatusStorageKey as m, ASYNC_STORAGE_MAX_AGE_MS as n, getProtectedKeysFromMetadata as o, OFFLINE_SESSION_STATUS_STORE_NAME as p, normalizeStaticPolicy as q, buildPersistedStaticPolicy as r, mergeManagedAsyncStorageCustomMetadata as s, ASYNC_MAINTENANCE_LOCAL_STORAGE_KEY as t, serializeProtectedRef as u, resolveTSDFLogger as v, keepEntriesWithinByteBudget as w, createTimedKeySet as x, getDefaultMaxBytesForScope as y, warnIfNavigatorLockUnavailable as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as AsyncStorageDriver, t as AsyncStorageAdapter } from "./types-
|
|
1
|
+
import { r as AsyncStorageDriver, t as AsyncStorageAdapter } from "./types-aWgyZHLj.js";
|
|
2
2
|
|
|
3
3
|
//#region src/persistentStorage/asyncStorageAdapter.d.ts
|
|
4
4
|
declare function createAsyncStorageAdapter(driver: AsyncStorageDriver): AsyncStorageAdapter;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as opfsPersistentStorage } from "./opfsPersistentStorage-
|
|
2
|
-
import { n as indexedDbPersistentStorage } from "./indexedDbPersistentStorage-
|
|
1
|
+
import { t as opfsPersistentStorage } from "./opfsPersistentStorage-D_k77Srq.js";
|
|
2
|
+
import { n as indexedDbPersistentStorage } from "./indexedDbPersistentStorage-BSlgLveB.js";
|
|
3
3
|
export { indexedDbPersistentStorage, opfsPersistentStorage };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as AsyncStorageAdapter } from "./types-
|
|
1
|
+
import { t as AsyncStorageAdapter } from "./types-aWgyZHLj.js";
|
|
2
2
|
//#region src/persistentStorage/indexedDbAsyncStorageAdapter.d.ts
|
|
3
3
|
/** Options for creating the IndexedDB persistent storage adapter. */
|
|
4
4
|
type IndexedDbPersistentStorageOptions$1 = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as indexedDbPersistentStorage, t as createIndexedDbPersistentStorage } from "./indexedDbPersistentStorage-
|
|
1
|
+
import { n as indexedDbPersistentStorage, t as createIndexedDbPersistentStorage } from "./indexedDbPersistentStorage-BSlgLveB.js";
|
|
2
2
|
export { createIndexedDbPersistentStorage, indexedDbPersistentStorage };
|
package/dist/{indexedDbPersistentStorage-D5tGmD77.js → indexedDbPersistentStorage-BSlgLveB.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as serializeJsonForStorage, G as getPayloadRecordKey, H as compareMetadata, J as parseAsyncStorageRecordKey, K as getPersistedNamespaceId, U as encodePersistedAsyncNamespaceKind, W as getNamespaceId, X as serializeProtectedRef, Y as parsePersistedAsyncNamespaceKind, _ as getTSDFDebugTimingMs, a as estimateManagedAsyncStorageEntrySizeBytes, g as emitTSDFDebugLog, i as createAsyncStorageAdapter, q as normalizeStaticPolicy } from "./asyncStorageAdapter-BuGjbXYA.js";
|
|
2
2
|
import { __LEGIT_CAST__ } from "@ls-stack/utils/saferTyping";
|
|
3
3
|
import { isObject } from "@ls-stack/utils/typeGuards";
|
|
4
4
|
//#region src/persistentStorage/indexedDbAsyncStorageAdapter.ts
|
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as OfflineResolutionRecord, $t as StoreError, A as DefineListQueryOfflineOperations, At as DerivedQuerySource, B as OfflineEntityMutationKind, Bt as OptimisticListUpdate, C as PersistentStorageSchema, Ct as OfflineUploadAdapter, D as CollectionOfflineOperationDefinition, Dt as OfflineUploadTransportContext, E as CollectionOfflineEntityRef, Et as OfflineUploadState, F as ListQueryOfflineEntityRef, Ft as ListQueryUseMultipleItemsQuery, G as OfflineMutationQueueingPolicy, Gt as TSFDListQuery, H as OfflineMutationInput, Ht as QueryFetchPayload, I as ListQueryOfflineOperationDefinition, It as ListQueryUseMultipleListQueriesQuery, J as OfflineReplayRetryConfig, Jt as TSFDUseListQueryReturn, K as OfflineOperationKind, Kt as TSFDListQueryState, L as OfflineAccumulationConfig, Lt as OffsetPaginationConfig, M as DocumentOfflineOperationDefinition, Mt as FetchListFnReturnItem, N as GlobalOfflineEntity, Nt as FieldsInput, O as DefineCollectionOfflineOperations, Ot as DerivedQueriesConfig, P as GlobalOfflineStatus, Pt as FieldsOption, Q as OfflineResolutionConflictParseErrorCode, Qt as PayloadDebounce, R as OfflineAccumulationMergeContext, Rt as OnListQueryInvalidate, S as PersistentStoragePreloadResult, St as OfflineUpload, T as AnyOfflineOperationDefinition, Tt as OfflineUploadSource, U as OfflineMutationQueueingCause, Ut as QueryStatus, V as OfflineMutationDescriptor, Vt as PartialResourcesConfig, W as OfflineMutationQueueingConfig, Wt as TSDFItemQuery, X as OfflineResolutionActionForOperation, Xt as MaybeTSDFResult, Y as OfflineResolutionAction, Yt as TSFDUsePendingOfflineItemsReturn, Z as OfflineResolutionConflictParseError, Zt as MutationSkipped, _ as ListQueryOfflineOperationsConfig, _n as TSDFDebugLogger, _t as defaultOfflineRuntimeConfig, a as AsyncStorageMetadataOrder, an as ValidPayload, at as OfflineSession, b as PersistentStorageDataSchema, bt as OfflineSessionUploadsConfig, c as AsyncStorageNamespaceCommitUpsert, cn as mutationSkipped, ct as OfflineSyncState, d as AsyncStorageNamespaceKind, dn as RequestSchedulerEvents, dt as OfflineTempEntityConfig, en as StoreFetchError, et as OfflineResolutionRecordForOperation, f as AsyncStorageNamespaceScope, fn as ScheduleFetchOptions, ft as OfflineTempEntityPendingEntry, g as DocumentPersistentStorageConfig, gn as TSDFDebugLogLevel, gt as ParsedOfflineResolutionConflictResultForStore, h as ConvertedPersistentStorageDataSchema, hn as TSDFDebugLogEntry, ht as ParsedOfflineResolutionConflictResultForOperation, i as AsyncStorageDriverSetEntry, in as UnwrapTSDFResult, it as OfflineRuntimeConfigUpdate, j as DefineOfflineOperation, jt as FetchListFnReturn, k as DefineDocumentOfflineOperations, kt as DerivedQueryContext, l as AsyncStorageNamespaceGetResult, ln as FetchType, lt as OfflineTempEntitiesConfig, m as CollectionPersistentStorageConfig, mn as TSDFDebugLogArea, mt as OperationResult, n as AsyncStorageDiscoveredScope, nn as StoreMutationErrorOptions, nt as OfflineRetryExhaustedResolutionAction, o as AsyncStorageNamespaceCommitArgs, on as ValidStoreState, ot as OfflineSessionConfig, p as AsyncStorageReadOptions, pn as ScheduleFetchResults, pt as OperationConflict, q as OfflineQueueEntry, qt as TSFDUseListItemReturn, r as AsyncStorageDriver, rn as TSDFStatus, rt as OfflineRuntimeConfig, s as AsyncStorageNamespaceCommitTouch, sn as fetchTypePriority, st as OfflineSupersedeConfig, t as AsyncStorageAdapter, tn as StoreMutationError, tt as OfflineResolutionRecordForStore, u as AsyncStorageNamespaceHandle, un as RequestSchedulerEventData, ut as OfflineTempEntitiesReconciliation, v as ListQueryPersistentStorageConfig, vn as TSDFFocusDebugOperation, vt as OfflineMutationUploadsInput, w as StorageAdapter, wt as OfflineUploadProgress, x as PersistentStorageErrorHandler, xt as OfflineStoredUploadRecord, y as PersistentStorageBaseConfig, yn as TSDFLoggerOptions, yt as OfflineOperationUploadsContext, z as OfflineConflictResolutionAction, zt as OnListQueryItemInvalidate } from "./types-
|
|
1
|
+
import { $ as OfflineResolutionRecord, $t as StoreError, A as DefineListQueryOfflineOperations, At as DerivedQuerySource, B as OfflineEntityMutationKind, Bt as OptimisticListUpdate, C as PersistentStorageSchema, Ct as OfflineUploadAdapter, D as CollectionOfflineOperationDefinition, Dt as OfflineUploadTransportContext, E as CollectionOfflineEntityRef, Et as OfflineUploadState, F as ListQueryOfflineEntityRef, Ft as ListQueryUseMultipleItemsQuery, G as OfflineMutationQueueingPolicy, Gt as TSFDListQuery, H as OfflineMutationInput, Ht as QueryFetchPayload, I as ListQueryOfflineOperationDefinition, It as ListQueryUseMultipleListQueriesQuery, J as OfflineReplayRetryConfig, Jt as TSFDUseListQueryReturn, K as OfflineOperationKind, Kt as TSFDListQueryState, L as OfflineAccumulationConfig, Lt as OffsetPaginationConfig, M as DocumentOfflineOperationDefinition, Mt as FetchListFnReturnItem, N as GlobalOfflineEntity, Nt as FieldsInput, O as DefineCollectionOfflineOperations, Ot as DerivedQueriesConfig, P as GlobalOfflineStatus, Pt as FieldsOption, Q as OfflineResolutionConflictParseErrorCode, Qt as PayloadDebounce, R as OfflineAccumulationMergeContext, Rt as OnListQueryInvalidate, S as PersistentStoragePreloadResult, St as OfflineUpload, T as AnyOfflineOperationDefinition, Tt as OfflineUploadSource, U as OfflineMutationQueueingCause, Ut as QueryStatus, V as OfflineMutationDescriptor, Vt as PartialResourcesConfig, W as OfflineMutationQueueingConfig, Wt as TSDFItemQuery, X as OfflineResolutionActionForOperation, Xt as MaybeTSDFResult, Y as OfflineResolutionAction, Yt as TSFDUsePendingOfflineItemsReturn, Z as OfflineResolutionConflictParseError, Zt as MutationSkipped, _ as ListQueryOfflineOperationsConfig, _n as TSDFDebugLogger, _t as defaultOfflineRuntimeConfig, a as AsyncStorageMetadataOrder, an as ValidPayload, at as OfflineSession, b as PersistentStorageDataSchema, bt as OfflineSessionUploadsConfig, c as AsyncStorageNamespaceCommitUpsert, cn as mutationSkipped, ct as OfflineSyncState, d as AsyncStorageNamespaceKind, dn as RequestSchedulerEvents, dt as OfflineTempEntityConfig, en as StoreFetchError, et as OfflineResolutionRecordForOperation, f as AsyncStorageNamespaceScope, fn as ScheduleFetchOptions, ft as OfflineTempEntityPendingEntry, g as DocumentPersistentStorageConfig, gn as TSDFDebugLogLevel, gt as ParsedOfflineResolutionConflictResultForStore, h as ConvertedPersistentStorageDataSchema, hn as TSDFDebugLogEntry, ht as ParsedOfflineResolutionConflictResultForOperation, i as AsyncStorageDriverSetEntry, in as UnwrapTSDFResult, it as OfflineRuntimeConfigUpdate, j as DefineOfflineOperation, jt as FetchListFnReturn, k as DefineDocumentOfflineOperations, kt as DerivedQueryContext, l as AsyncStorageNamespaceGetResult, ln as FetchType, lt as OfflineTempEntitiesConfig, m as CollectionPersistentStorageConfig, mn as TSDFDebugLogArea, mt as OperationResult, n as AsyncStorageDiscoveredScope, nn as StoreMutationErrorOptions, nt as OfflineRetryExhaustedResolutionAction, o as AsyncStorageNamespaceCommitArgs, on as ValidStoreState, ot as OfflineSessionConfig, p as AsyncStorageReadOptions, pn as ScheduleFetchResults, pt as OperationConflict, q as OfflineQueueEntry, qt as TSFDUseListItemReturn, r as AsyncStorageDriver, rn as TSDFStatus, rt as OfflineRuntimeConfig, s as AsyncStorageNamespaceCommitTouch, sn as fetchTypePriority, st as OfflineSupersedeConfig, t as AsyncStorageAdapter, tn as StoreMutationError, tt as OfflineResolutionRecordForStore, u as AsyncStorageNamespaceHandle, un as RequestSchedulerEventData, ut as OfflineTempEntitiesReconciliation, v as ListQueryPersistentStorageConfig, vn as TSDFFocusDebugOperation, vt as OfflineMutationUploadsInput, w as StorageAdapter, wt as OfflineUploadProgress, x as PersistentStorageErrorHandler, xt as OfflineStoredUploadRecord, y as PersistentStorageBaseConfig, yn as TSDFLoggerOptions, yt as OfflineOperationUploadsContext, z as OfflineConflictResolutionAction, zt as OnListQueryItemInvalidate } from "./types-aWgyZHLj.js";
|
|
2
2
|
import { __LEGIT_ANY__ } from "@ls-stack/utils/saferTyping";
|
|
3
3
|
import { Emitter } from "evtmitter";
|
|
4
4
|
import { Context } from "react";
|
|
@@ -141,11 +141,12 @@ type UseMultipleItemsOptions$1<ItemState extends ValidStoreState, Selected> = {
|
|
|
141
141
|
//#region src/collectionStore/useItem.d.ts
|
|
142
142
|
type UseItemOptions$1<ItemState extends ValidStoreState, Selected> = UseMultipleItemsOptions$1<ItemState, Selected> & {
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
145
|
-
* until
|
|
146
|
-
*
|
|
144
|
+
* Unconditionally schedules a high-priority fetch on mount and reports
|
|
145
|
+
* `loading` until that refresh succeeds or fails, even when cached data
|
|
146
|
+
* exists. Use sparingly because each mount can cause an extra request.
|
|
147
|
+
* Cannot be combined with `debouncePayload`.
|
|
147
148
|
*/
|
|
148
|
-
|
|
149
|
+
requireFreshData?: boolean;
|
|
149
150
|
};
|
|
150
151
|
//#endregion
|
|
151
152
|
//#region src/collectionStore/collectionStore.d.ts
|
|
@@ -372,21 +373,21 @@ type CollectionStore<ItemState extends ValidStoreState, ItemPayload extends Vali
|
|
|
372
373
|
useListItemIsLoading: (payload: ItemPayload, args: {
|
|
373
374
|
/** Unique identifier of the sub-item within the collection item. */itemId: string; /** Extracts the sub-item from the collection item data. */
|
|
374
375
|
selector: (data: ItemState | null) => unknown; /** Called if the sub-item is still missing and no refetch is in progress. */
|
|
375
|
-
loadItemFallback?: () => void; /**
|
|
376
|
-
|
|
376
|
+
loadItemFallback?: () => void; /** Requires a mount refresh before reporting ready. May cause an extra request. */
|
|
377
|
+
requireFreshData?: boolean;
|
|
377
378
|
}) => boolean; /** React hook that tracks whether a nested list item has been deleted. */
|
|
378
379
|
useListItemIsDeleted: (payload: ItemPayload, args: {
|
|
379
380
|
/** Unique identifier of the sub-item within the collection item. */itemId: string; /** Extracts the sub-item from the collection item data. */
|
|
380
381
|
selector: (data: ItemState | null) => unknown; /** Called once when deletion is detected. */
|
|
381
|
-
onDelete?: () => void; /**
|
|
382
|
-
|
|
382
|
+
onDelete?: () => void; /** Requires a mount refresh before reporting ready. May cause an extra request. */
|
|
383
|
+
requireFreshData?: boolean;
|
|
383
384
|
}) => boolean; /** React hook for selecting one nested list item plus loading/deleted flags. */
|
|
384
385
|
useListItem: <Selected>(payload: ItemPayload, args: {
|
|
385
386
|
/** Unique identifier of the sub-item within the collection item. */itemId: string; /** Extracts and maps the sub-item from the collection item data. */
|
|
386
387
|
selector: (data: ItemState | null) => Selected; /** Called if the sub-item is still missing and no refetch is in progress. */
|
|
387
388
|
loadItemFallback?: () => void; /** Called once when deletion is detected. */
|
|
388
|
-
onDelete?: () => void; /**
|
|
389
|
-
|
|
389
|
+
onDelete?: () => void; /** Requires a mount refresh before reporting ready. May cause an extra request. */
|
|
390
|
+
requireFreshData?: boolean;
|
|
390
391
|
}) => {
|
|
391
392
|
isLoading: boolean;
|
|
392
393
|
isDeleted: boolean;
|
|
@@ -598,30 +599,31 @@ type DocumentStore<State extends ValidStoreState, TOfflineOperations extends Doc
|
|
|
598
599
|
disableRefetchOnMount?: boolean; /** Returns `idle` instead of `loading` while the document has not been fetched. */
|
|
599
600
|
returnIdleStatus?: boolean;
|
|
600
601
|
/**
|
|
601
|
-
*
|
|
602
|
-
* until
|
|
602
|
+
* Unconditionally schedules a high-priority fetch on mount and reports
|
|
603
|
+
* `loading` until that refresh succeeds or fails, even when cached data
|
|
604
|
+
* exists. Use sparingly because each mount can cause an extra request.
|
|
603
605
|
*/
|
|
604
|
-
|
|
606
|
+
requireFreshData?: boolean; /** Returns `refetching` instead of keeping `loaded` status during refetches. */
|
|
605
607
|
returnRefetchingStatus?: boolean;
|
|
606
608
|
}) => TSDFUseDocumentReturn<Selected>; /** React hook that tracks whether a nested list item is still loading. */
|
|
607
609
|
useListItemIsLoading: (args: {
|
|
608
610
|
/** Unique identifier of the item within the document. */itemId: string; /** Extracts the item from the document data. */
|
|
609
611
|
selector: (data: State | null) => unknown; /** Called if the item is still missing and no refetch is in progress. */
|
|
610
|
-
loadItemFallback?: () => void; /**
|
|
611
|
-
|
|
612
|
+
loadItemFallback?: () => void; /** Requires a mount refresh before reporting ready. May cause an extra request. */
|
|
613
|
+
requireFreshData?: boolean;
|
|
612
614
|
}) => boolean; /** React hook that tracks whether a nested list item has been deleted. */
|
|
613
615
|
useListItemIsDeleted: (args: {
|
|
614
616
|
/** Unique identifier of the item within the document. */itemId: string; /** Extracts the item from the document data. */
|
|
615
617
|
selector: (data: State | null) => unknown; /** Called once when deletion is detected. */
|
|
616
|
-
onDelete?: () => void; /**
|
|
617
|
-
|
|
618
|
+
onDelete?: () => void; /** Requires a mount refresh before reporting ready. May cause an extra request. */
|
|
619
|
+
requireFreshData?: boolean;
|
|
618
620
|
}) => boolean; /** React hook for selecting one nested list item plus loading/deleted flags. */
|
|
619
621
|
useListItem: <Selected>(args: {
|
|
620
622
|
/** Unique identifier of the item within the document. */itemId: string; /** Extracts and maps the item from the document data. */
|
|
621
623
|
selector: (data: State | null) => Selected; /** Called if the item is still missing and no refetch is in progress. */
|
|
622
624
|
loadItemFallback?: () => void; /** Called once when deletion is detected. */
|
|
623
|
-
onDelete?: () => void; /**
|
|
624
|
-
|
|
625
|
+
onDelete?: () => void; /** Requires a mount refresh before reporting ready. May cause an extra request. */
|
|
626
|
+
requireFreshData?: boolean;
|
|
625
627
|
}) => {
|
|
626
628
|
isLoading: boolean;
|
|
627
629
|
isDeleted: boolean;
|
|
@@ -665,11 +667,12 @@ type UseMultipleItemsOptions<ItemState extends ValidStoreState, Selected> = {
|
|
|
665
667
|
//#region src/listQueryStore/useItem.d.ts
|
|
666
668
|
type UseItemOptions<ItemState extends ValidStoreState, Selected> = UseMultipleItemsOptions<ItemState, Selected> & {
|
|
667
669
|
/**
|
|
668
|
-
*
|
|
669
|
-
* until
|
|
670
|
-
*
|
|
670
|
+
* Unconditionally schedules a high-priority fetch on mount and reports
|
|
671
|
+
* `loading` until that refresh succeeds or fails, even when cached data
|
|
672
|
+
* exists. Use sparingly because each mount can cause an extra request.
|
|
673
|
+
* Cannot be combined with `debouncePayload`.
|
|
671
674
|
*/
|
|
672
|
-
|
|
675
|
+
requireFreshData?: boolean;
|
|
673
676
|
/**
|
|
674
677
|
* Partial-resource fields to request for this item.
|
|
675
678
|
*
|
|
@@ -714,11 +717,12 @@ type UseMultipleListQueriesOptions<ItemState extends ValidStoreState, ItemPayloa
|
|
|
714
717
|
//#region src/listQueryStore/useListQuery.d.ts
|
|
715
718
|
type UseListQueryOptions<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, SelectedItem> = UseMultipleListQueriesOptions<ItemState, ItemPayload, SelectedItem> & {
|
|
716
719
|
/**
|
|
717
|
-
*
|
|
718
|
-
* until
|
|
719
|
-
*
|
|
720
|
+
* Unconditionally schedules a high-priority fetch on mount and reports
|
|
721
|
+
* `loading` until that refresh succeeds or fails, even when cached data
|
|
722
|
+
* exists. Use sparingly because each mount can cause an extra request.
|
|
723
|
+
* Cannot be combined with `debouncePayload`.
|
|
720
724
|
*/
|
|
721
|
-
|
|
725
|
+
requireFreshData?: boolean;
|
|
722
726
|
/**
|
|
723
727
|
* Partial-resource fields to request for each item in this query.
|
|
724
728
|
*
|
|
@@ -1199,8 +1203,18 @@ declare function useGlobalOfflineEntities(sessionKey: string): readonly GlobalOf
|
|
|
1199
1203
|
*/
|
|
1200
1204
|
declare function useGlobalOfflineResolutions(sessionKey: string): readonly OfflineResolutionRecord[];
|
|
1201
1205
|
//#endregion
|
|
1206
|
+
//#region src/persistentStorage/scheduleIdleCleanup.d.ts
|
|
1207
|
+
type IdleCleanupContext = {
|
|
1208
|
+
cancel(): void;
|
|
1209
|
+
getContinuationCount(): number;
|
|
1210
|
+
isCanceled(): boolean;
|
|
1211
|
+
shouldYield(): boolean;
|
|
1212
|
+
yieldIfNeeded(): Promise<boolean>;
|
|
1213
|
+
};
|
|
1214
|
+
//#endregion
|
|
1202
1215
|
//#region src/persistentStorage/localStorageMetadata.d.ts
|
|
1203
1216
|
type ManagedLocalStorageIo = {
|
|
1217
|
+
invalidate?(key: string): void;
|
|
1204
1218
|
getItem(key: string): string | null;
|
|
1205
1219
|
setItem(key: string, value: string): void;
|
|
1206
1220
|
removeItem(key: string): void;
|
|
@@ -1244,6 +1258,16 @@ type UpsertNamespaceEntryParams = {
|
|
|
1244
1258
|
meta?: unknown;
|
|
1245
1259
|
};
|
|
1246
1260
|
declare function upsertManagedLocalStorageNamespaceEntry(params: UpsertNamespaceEntryParams, io?: ManagedLocalStorageIo): string;
|
|
1261
|
+
type ManagedLocalStorageNamespaceRemovalCandidate = {
|
|
1262
|
+
entryKey: string;
|
|
1263
|
+
lastAccessAt: number;
|
|
1264
|
+
offlineProtected: boolean;
|
|
1265
|
+
};
|
|
1266
|
+
type ManagedLocalStorageNamespaceRemovalResult = {
|
|
1267
|
+
processedCount: number;
|
|
1268
|
+
removedEntryKeys: string[];
|
|
1269
|
+
staleEntryKeys: string[];
|
|
1270
|
+
};
|
|
1247
1271
|
//#endregion
|
|
1248
1272
|
//#region src/persistentStorage/storageAdapter.d.ts
|
|
1249
1273
|
type LocalStorageMetadataOptions = {
|
|
@@ -1255,6 +1279,7 @@ type LocalStorageMetadataOptions = {
|
|
|
1255
1279
|
type LocalPersistentStorage = {
|
|
1256
1280
|
kind: 'local-sync';
|
|
1257
1281
|
runLocked<T>(callback: () => T | Promise<T>): Promise<T>;
|
|
1282
|
+
runMaintenanceLocked<T>(context: IdleCleanupContext, callback: () => T | Promise<T>): Promise<T>;
|
|
1258
1283
|
readRaw(key: string): string | null;
|
|
1259
1284
|
write<T>(key: string, value: T): {
|
|
1260
1285
|
rawValue: string;
|
|
@@ -1273,11 +1298,12 @@ type LocalPersistentStorage = {
|
|
|
1273
1298
|
upsertNamespaceEntry(args: Parameters<typeof upsertManagedLocalStorageNamespaceEntry>[0]): string;
|
|
1274
1299
|
touchSingleEntry(payloadKey: string): boolean;
|
|
1275
1300
|
touchNamespaceEntry(payloadKey: string, namespacePrefix: string): boolean;
|
|
1301
|
+
removeNamespaceEntriesIfUnchanged(storagePrefix: string, candidates: ManagedLocalStorageNamespaceRemovalCandidate[], candidateIndex: number, shouldYield: () => boolean): ManagedLocalStorageNamespaceRemovalResult;
|
|
1276
1302
|
clearManifest(manifestKey: string): void;
|
|
1277
1303
|
clearSession(sessionKey: string): void;
|
|
1278
|
-
registerMaintenanceCallback(manifestKey: string, callback: () => Promise<void>): void;
|
|
1304
|
+
registerMaintenanceCallback(manifestKey: string, callback: (context?: IdleCleanupContext) => Promise<void>): void;
|
|
1279
1305
|
unregisterMaintenanceCallback(manifestKey: string): void;
|
|
1280
|
-
runMaintenance(forceManifestKeys
|
|
1306
|
+
runMaintenance(forceManifestKeys: Iterable<string> | undefined, context: IdleCleanupContext): Promise<void>;
|
|
1281
1307
|
readProtectedStorageKeys(sessionKey: string): Set<string>;
|
|
1282
1308
|
syncSessionProtectedKeys(sessionKey: string, protectedKeys: Iterable<string>): void;
|
|
1283
1309
|
};
|