tsdf 17.0.0-alpha.10 → 17.0.0-alpha.12

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.
@@ -1,2 +1,2 @@
1
- import { t as createAsyncStorageAdapter } from "./asyncStorageAdapter-BMYAF6rt.js";
1
+ import { t as createAsyncStorageAdapter } from "./asyncStorageAdapter-CYxABChu.js";
2
2
  export { createAsyncStorageAdapter };
@@ -1,2 +1,2 @@
1
- import { i as createAsyncStorageAdapter } from "./asyncStorageAdapter-BZSj1ZO5.js";
1
+ import { i as createAsyncStorageAdapter } from "./asyncStorageAdapter-CSzvgl3s.js";
2
2
  export { createAsyncStorageAdapter };
@@ -324,42 +324,42 @@ function serializeJsonForStorage(value) {
324
324
  sizeBytes: getSerializedStringSize(rawValue)
325
325
  };
326
326
  }
327
- function keepEntriesWithinByteBudget(args) {
327
+ function keepEntriesWithinByteBudget(entries, getKey, getLastAccessAt, getSizeBytes, isPinned, isProtected, maxBytes) {
328
328
  const keptKeys = /* @__PURE__ */ new Set();
329
329
  let unprotectedBytes = 0;
330
- for (const entry of args.entries) {
331
- if (args.isProtected(entry)) continue;
332
- unprotectedBytes += args.getSizeBytes(entry);
330
+ for (const entry of entries) {
331
+ if (isProtected(entry)) continue;
332
+ unprotectedBytes += getSizeBytes(entry);
333
333
  }
334
- if (unprotectedBytes <= args.maxBytes) {
335
- for (const entry of args.entries) keptKeys.add(args.getKey(entry));
334
+ if (unprotectedBytes <= maxBytes) {
335
+ for (const entry of entries) keptKeys.add(getKey(entry));
336
336
  return keptKeys;
337
337
  }
338
- const sortedEntries = [...args.entries].sort((a, b) => {
339
- const aProtected = args.isProtected(a);
340
- const bProtected = args.isProtected(b);
338
+ const sortedEntries = [...entries].sort((a, b) => {
339
+ const aProtected = isProtected(a);
340
+ const bProtected = isProtected(b);
341
341
  if (aProtected && !bProtected) return -1;
342
342
  if (!aProtected && bProtected) return 1;
343
- const aPinned = args.isPinned(a);
344
- const bPinned = args.isPinned(b);
343
+ const aPinned = isPinned(a);
344
+ const bPinned = isPinned(b);
345
345
  if (aPinned && !bPinned) return -1;
346
346
  if (!aPinned && bPinned) return 1;
347
- return args.getLastAccessAt(b) - args.getLastAccessAt(a);
347
+ return getLastAccessAt(b) - getLastAccessAt(a);
348
348
  });
349
349
  let keptUnprotectedBytes = 0;
350
350
  for (const entry of sortedEntries) {
351
- const key = args.getKey(entry);
352
- if (args.isProtected(entry)) {
351
+ const key = getKey(entry);
352
+ if (isProtected(entry)) {
353
353
  keptKeys.add(key);
354
354
  continue;
355
355
  }
356
- const sizeBytes = args.getSizeBytes(entry);
357
- if (args.isPinned(entry)) {
356
+ const sizeBytes = getSizeBytes(entry);
357
+ if (isPinned(entry)) {
358
358
  keptKeys.add(key);
359
359
  keptUnprotectedBytes += sizeBytes;
360
360
  continue;
361
361
  }
362
- if (keptUnprotectedBytes + sizeBytes <= args.maxBytes) {
362
+ if (keptUnprotectedBytes + sizeBytes <= maxBytes) {
363
363
  keptKeys.add(key);
364
364
  keptUnprotectedBytes += sizeBytes;
365
365
  }
@@ -390,14 +390,11 @@ function getDefaultMaxBytesKindForScope(scopeKind) {
390
390
  case "listQuery.query": return "listQuery";
391
391
  }
392
392
  }
393
- function getDefaultMaxBytesForAdapter(args) {
394
- return defaultMaxBytes[getDefaultMaxBytesProfile(args.adapter)][args.kind];
393
+ function getDefaultMaxBytesForAdapter(adapter, kind) {
394
+ return defaultMaxBytes[getDefaultMaxBytesProfile(adapter)][kind];
395
395
  }
396
- function getDefaultMaxBytesForScope(args) {
397
- return getDefaultMaxBytesForAdapter({
398
- adapter: args.adapter,
399
- kind: getDefaultMaxBytesKindForScope(args.scopeKind)
400
- });
396
+ function getDefaultMaxBytesForScope(adapter, scopeKind) {
397
+ return getDefaultMaxBytesForAdapter(adapter, getDefaultMaxBytesKindForScope(scopeKind));
401
398
  }
402
399
  //#endregion
403
400
  //#region src/persistentStorage/types.ts
@@ -456,17 +453,17 @@ function setOfflineProtectionMetadata(customMetadata, offlineProtected) {
456
453
  const { o: _ignored, ...withoutOfflineMarker } = customMetadata ?? {};
457
454
  return Object.keys(withoutOfflineMarker).length > 0 ? withoutOfflineMarker : void 0;
458
455
  }
459
- function mergeManagedAsyncStorageCustomMetadata(args) {
456
+ function mergeManagedAsyncStorageCustomMetadata(currentCustomMetadata, nextCustomMetadata, protectedKeysSnapshotSet, scope, key) {
460
457
  const merged = {
461
- ...args.currentCustomMetadata ?? {},
462
- ...args.nextCustomMetadata ?? {}
458
+ ...currentCustomMetadata ?? {},
459
+ ...nextCustomMetadata ?? {}
463
460
  };
464
461
  const mergedCustomMetadata = Object.keys(merged).length > 0 ? merged : void 0;
465
- if (args.protectedKeysSnapshotSet !== null) return setOfflineProtectionMetadata(mergedCustomMetadata, args.protectedKeysSnapshotSet?.has(serializeProtectedRef({
466
- ...args.scope,
467
- key: args.key
468
- })) === true || isOfflineProtectedMetadata(args.nextCustomMetadata) || isOfflineProtectedMetadata(args.currentCustomMetadata));
469
- return setOfflineProtectionMetadata(mergedCustomMetadata, isOfflineProtectedMetadata(args.nextCustomMetadata) || isOfflineProtectedMetadata(args.currentCustomMetadata));
462
+ if (protectedKeysSnapshotSet !== null) return setOfflineProtectionMetadata(mergedCustomMetadata, protectedKeysSnapshotSet?.has(serializeProtectedRef({
463
+ ...scope,
464
+ key
465
+ })) === true || isOfflineProtectedMetadata(nextCustomMetadata) || isOfflineProtectedMetadata(currentCustomMetadata));
466
+ return setOfflineProtectionMetadata(mergedCustomMetadata, isOfflineProtectedMetadata(nextCustomMetadata) || isOfflineProtectedMetadata(currentCustomMetadata));
470
467
  }
471
468
  const ASYNC_METADATA_LAST_ACCESS_AT_KEY = "a";
472
469
  const ASYNC_METADATA_VERSION_KEY = "v";
@@ -505,12 +502,12 @@ function serializeInternalManagedMetadataRecord(metadata) {
505
502
  ...customMetadata
506
503
  };
507
504
  }
508
- function estimateManagedAsyncStorageEntrySizeBytes(args) {
509
- return getSerializedStringSize(args.serializedValue) + getSerializedStringSize(JSON.stringify(serializeInternalManagedMetadataRecord({
510
- lastAccessAt: args.lastAccessAt,
505
+ function estimateManagedAsyncStorageEntrySizeBytes(serializedValue, lastAccessAt, version, customMetadata) {
506
+ return getSerializedStringSize(serializedValue) + getSerializedStringSize(JSON.stringify(serializeInternalManagedMetadataRecord({
507
+ lastAccessAt,
511
508
  sizeBytes: void 0,
512
- version: args.version,
513
- ...args.customMetadata ? { customMetadata: args.customMetadata } : {}
509
+ version,
510
+ ...customMetadata ? { customMetadata } : {}
514
511
  })));
515
512
  }
516
513
  function parseIndexEntries(value) {
@@ -561,18 +558,9 @@ function serializeIndexState(state) {
561
558
  }
562
559
  function getDefaultStaticPolicyForScope(scope) {
563
560
  switch (scope.kind) {
564
- case "collection.item": return { maxBytes: getDefaultMaxBytesForScope({
565
- adapter: "async",
566
- scopeKind: "collection.item"
567
- }) };
568
- case "listQuery.item": return { maxBytes: getDefaultMaxBytesForScope({
569
- adapter: "async",
570
- scopeKind: "listQuery.item"
571
- }) };
572
- case "listQuery.query": return { maxBytes: getDefaultMaxBytesForScope({
573
- adapter: "async",
574
- scopeKind: "listQuery.query"
575
- }) };
561
+ case "collection.item": return { maxBytes: getDefaultMaxBytesForScope("async", "collection.item") };
562
+ case "listQuery.item": return { maxBytes: getDefaultMaxBytesForScope("async", "listQuery.item") };
563
+ case "listQuery.query": return { maxBytes: getDefaultMaxBytesForScope("async", "listQuery.query") };
576
564
  default: return null;
577
565
  }
578
566
  }
@@ -1228,13 +1216,7 @@ var ManagedAsyncStorageAdapter = class {
1228
1216
  const touchedKeys = [...new Set(touches.map((touch) => touch.key))];
1229
1217
  const managedCapabilities = getManagedDriverCapabilities(this.#driver);
1230
1218
  if (managedCapabilities?.applyManagedCommit !== void 0) {
1231
- await managedCapabilities.applyManagedCommit(scope, args, { mergeOfflineProtectionMetadata: (key, nextCustomMetadata, currentCustomMetadata) => mergeManagedAsyncStorageCustomMetadata({
1232
- currentCustomMetadata,
1233
- key,
1234
- nextCustomMetadata,
1235
- protectedKeysSnapshotSet: getSessionProtectedKeysSnapshot(scope.sessionKey),
1236
- scope
1237
- }) });
1219
+ await managedCapabilities.applyManagedCommit(scope, args, { mergeOfflineProtectionMetadata: (key, nextCustomMetadata, currentCustomMetadata) => mergeManagedAsyncStorageCustomMetadata(currentCustomMetadata, nextCustomMetadata, getSessionProtectedKeysSnapshot(scope.sessionKey), scope, key) });
1238
1220
  this.#advanceNamespaceReadCacheGeneration(scope);
1239
1221
  this.#invalidateCachedNamespaceIndexState(scope);
1240
1222
  for (const key of removes) this.#invalidateCachedPayloadValue(scope, key);
@@ -1261,21 +1243,10 @@ var ManagedAsyncStorageAdapter = class {
1261
1243
  const protectedKeysSnapshotSet = getSessionProtectedKeysSnapshot(scope.sessionKey);
1262
1244
  for (const upsert of upserts) {
1263
1245
  const existingMetadata = indexEntries.get(upsert.key);
1264
- const customMetadata = mergeManagedAsyncStorageCustomMetadata({
1265
- currentCustomMetadata: existingMetadata?.customMetadata,
1266
- key: upsert.key,
1267
- nextCustomMetadata: upsert.metadata,
1268
- protectedKeysSnapshotSet,
1269
- scope
1270
- });
1246
+ const customMetadata = mergeManagedAsyncStorageCustomMetadata(existingMetadata?.customMetadata, upsert.metadata, protectedKeysSnapshotSet, scope, upsert.key);
1271
1247
  const nextLastAccessAt = touchesByKey.get(upsert.key) ?? existingMetadata?.lastAccessAt ?? now;
1272
1248
  const serializedValue = upsert.serializedValue !== void 0 ? { rawValue: upsert.serializedValue } : serializeJsonForStorage(upsert.value);
1273
- const nextSizeBytes = scope.kind !== "document" ? estimateManagedAsyncStorageEntrySizeBytes({
1274
- customMetadata,
1275
- lastAccessAt: nextLastAccessAt,
1276
- serializedValue: serializedValue.rawValue,
1277
- version: upsert.version
1278
- }) : void 0;
1249
+ const nextSizeBytes = scope.kind !== "document" ? estimateManagedAsyncStorageEntrySizeBytes(serializedValue.rawValue, nextLastAccessAt, upsert.version, customMetadata) : void 0;
1279
1250
  const nextMetadata = {
1280
1251
  lastAccessAt: nextLastAccessAt,
1281
1252
  version: upsert.version,
@@ -1786,15 +1757,7 @@ var ManagedAsyncStorageAdapter = class {
1786
1757
  for (const payloadKey of payloadKeys) if (!indexState.entries.has(payloadKey)) payloadRecordKeysToRemove.add(getPayloadRecordKey(payloadKey));
1787
1758
  if (effectiveStaticPolicy?.maxBytes !== void 0) {
1788
1759
  const pinnedKeys = new Set(effectiveStaticPolicy.pinnedKeys ?? []);
1789
- const keptKeys = keepEntriesWithinByteBudget({
1790
- entries: candidateEntries,
1791
- getKey: (entry) => entry.itemKey,
1792
- getLastAccessAt: (entry) => entry.lastAccessAt,
1793
- getSizeBytes: (entry) => entry.sizeBytes,
1794
- isPinned: (entry) => pinnedKeys.has(entry.itemKey),
1795
- isProtected: (entry) => entry.protected,
1796
- maxBytes: effectiveStaticPolicy.maxBytes
1797
- });
1760
+ const keptKeys = keepEntriesWithinByteBudget(candidateEntries, (entry) => entry.itemKey, (entry) => entry.lastAccessAt, (entry) => entry.sizeBytes, (entry) => pinnedKeys.has(entry.itemKey), (entry) => entry.protected, effectiveStaticPolicy.maxBytes);
1798
1761
  for (const { itemKey } of candidateEntries) {
1799
1762
  if (keptKeys.has(itemKey)) continue;
1800
1763
  payloadRecordKeysToRemove.add(getPayloadRecordKey(itemKey));
@@ -1,4 +1,4 @@
1
- import { r as AsyncStorageDriver, t as AsyncStorageAdapter } from "./types-2zQlbxtw.js";
1
+ import { r as AsyncStorageDriver, t as AsyncStorageAdapter } from "./types-DqUm_Sv7.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-BO_uDxe4.js";
2
- import { n as indexedDbPersistentStorage } from "./indexedDbPersistentStorage-DlUjN1qY.js";
1
+ import { t as opfsPersistentStorage } from "./opfsPersistentStorage-3c1zSDZi.js";
2
+ import { n as indexedDbPersistentStorage } from "./indexedDbPersistentStorage-DtWquUOj.js";
3
3
  export { indexedDbPersistentStorage, opfsPersistentStorage };
@@ -1,4 +1,4 @@
1
- import { t as AsyncStorageAdapter } from "./types-2zQlbxtw.js";
1
+ import { t as AsyncStorageAdapter } from "./types-DqUm_Sv7.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-DlUjN1qY.js";
1
+ import { n as indexedDbPersistentStorage, t as createIndexedDbPersistentStorage } from "./indexedDbPersistentStorage-DtWquUOj.js";
2
2
  export { createIndexedDbPersistentStorage, indexedDbPersistentStorage };
@@ -1,4 +1,4 @@
1
- import { B as parseAsyncStorageRecordKey, F as encodePersistedAsyncNamespaceKind, H as serializeProtectedRef, I as getNamespaceId, L as getPayloadRecordKey, P as compareMetadata, R as getPersistedNamespaceId, V as parsePersistedAsyncNamespaceKind, a as estimateManagedAsyncStorageEntrySizeBytes, i as createAsyncStorageAdapter, v as serializeJsonForStorage, z as normalizeStaticPolicy } from "./asyncStorageAdapter-BZSj1ZO5.js";
1
+ import { B as parseAsyncStorageRecordKey, F as encodePersistedAsyncNamespaceKind, H as serializeProtectedRef, I as getNamespaceId, L as getPayloadRecordKey, P as compareMetadata, R as getPersistedNamespaceId, V as parsePersistedAsyncNamespaceKind, a as estimateManagedAsyncStorageEntrySizeBytes, i as createAsyncStorageAdapter, v as serializeJsonForStorage, z as normalizeStaticPolicy } from "./asyncStorageAdapter-CSzvgl3s.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
@@ -180,12 +180,7 @@ function compactEntryValue(scope, value) {
180
180
  return { d: value };
181
181
  }
182
182
  function estimateIndexedDbManagedEntrySizeBytes(args) {
183
- return estimateManagedAsyncStorageEntrySizeBytes({
184
- customMetadata: args.customMetadata,
185
- lastAccessAt: args.lastAccessAt,
186
- serializedValue: args.serializedValue ?? serializeJsonForStorage(args.value).rawValue,
187
- version: args.version
188
- });
183
+ return estimateManagedAsyncStorageEntrySizeBytes(args.serializedValue ?? serializeJsonForStorage(args.value).rawValue, args.lastAccessAt, args.version, args.customMetadata);
189
184
  }
190
185
  function expandEntryValue(scope, record) {
191
186
  return record.d;
package/dist/main.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as OfflineResolutionRecord, A as DefineListQueryOfflineOperations, At as PayloadDebounce, B as OfflineEntityMutationKind, Bt as mutationSkipped, C as PersistentStorageSchema, Ct as OfflineUploadAdapter, D as CollectionOfflineOperationDefinition, Dt as OfflineUploadTransportContext, E as CollectionOfflineEntityRef, Et as OfflineUploadState, F as ListQueryOfflineEntityRef, Ft as TSDFStatus, G as OfflineMutationQueueingPolicy, Gt as ScheduleFetchResults, H as OfflineMutationInput, Ht as RequestSchedulerEventData, I as ListQueryOfflineOperationDefinition, It as UnwrapTSDFResult, J as OfflineReplayRetryConfig, Jt as TSDFDebugLogLevel, K as OfflineOperationKind, Kt as TSDFDebugLogArea, L as OfflineAccumulationConfig, Lt as ValidPayload, M as DocumentOfflineOperationDefinition, Mt as StoreFetchError, N as GlobalOfflineEntity, Nt as StoreMutationError, O as DefineCollectionOfflineOperations, Ot as MaybeTSDFResult, P as GlobalOfflineStatus, Pt as StoreMutationErrorOptions, Q as OfflineResolutionConflictParseErrorCode, R as OfflineAccumulationMergeContext, Rt as ValidStoreState, S as PersistentStoragePreloadResult, St as OfflineUpload, T as AnyOfflineOperationDefinition, Tt as OfflineUploadSource, U as OfflineMutationQueueingCause, Ut as RequestSchedulerEvents, V as OfflineMutationDescriptor, Vt as FetchType, W as OfflineMutationQueueingConfig, Wt as ScheduleFetchOptions, X as OfflineResolutionActionForOperation, Xt as TSDFDebugOptions, Y as OfflineResolutionAction, Yt as TSDFDebugLogger, Z as OfflineResolutionConflictParseError, _ as ListQueryOfflineOperationsConfig, _t as defaultOfflineRuntimeConfig, a as AsyncStorageMetadataOrder, at as OfflineSession, b as PersistentStorageDataSchema, bt as OfflineSessionUploadsConfig, c as AsyncStorageNamespaceCommitUpsert, ct as OfflineSyncState, d as AsyncStorageNamespaceKind, dt as OfflineTempEntityConfig, et as OfflineResolutionRecordForOperation, f as AsyncStorageNamespaceScope, ft as OfflineTempEntityPendingEntry, g as DocumentPersistentStorageConfig, gt as ParsedOfflineResolutionConflictResultForStore, h as ConvertedPersistentStorageDataSchema, ht as ParsedOfflineResolutionConflictResultForOperation, i as AsyncStorageDriverSetEntry, it as OfflineRuntimeConfigUpdate, j as DefineOfflineOperation, jt as StoreError, k as DefineDocumentOfflineOperations, kt as MutationSkipped, l as AsyncStorageNamespaceGetResult, lt as OfflineTempEntitiesConfig, m as CollectionPersistentStorageConfig, mt as OperationResult, n as AsyncStorageDiscoveredScope, nt as OfflineRetryExhaustedResolutionAction, o as AsyncStorageNamespaceCommitArgs, ot as OfflineSessionConfig, p as AsyncStorageReadOptions, pt as OperationConflict, q as OfflineQueueEntry, qt as TSDFDebugLogEntry, r as AsyncStorageDriver, rt as OfflineRuntimeConfig, s as AsyncStorageNamespaceCommitTouch, st as OfflineSupersedeConfig, t as AsyncStorageAdapter, tt as OfflineResolutionRecordForStore, u as AsyncStorageNamespaceHandle, ut as OfflineTempEntitiesReconciliation, v as ListQueryPersistentStorageConfig, vt as OfflineMutationUploadsInput, w as StorageAdapter, wt as OfflineUploadProgress, x as PersistentStorageErrorHandler, xt as OfflineStoredUploadRecord, y as PersistentStorageBaseConfig, yt as OfflineOperationUploadsContext, z as OfflineConflictResolutionAction, zt as fetchTypePriority } from "./types-2zQlbxtw.js";
1
+ import { $ as OfflineResolutionRecord, A as DefineListQueryOfflineOperations, At as PayloadDebounce, B as OfflineEntityMutationKind, Bt as mutationSkipped, C as PersistentStorageSchema, Ct as OfflineUploadAdapter, D as CollectionOfflineOperationDefinition, Dt as OfflineUploadTransportContext, E as CollectionOfflineEntityRef, Et as OfflineUploadState, F as ListQueryOfflineEntityRef, Ft as TSDFStatus, G as OfflineMutationQueueingPolicy, Gt as ScheduleFetchResults, H as OfflineMutationInput, Ht as RequestSchedulerEventData, I as ListQueryOfflineOperationDefinition, It as UnwrapTSDFResult, J as OfflineReplayRetryConfig, Jt as TSDFDebugLogLevel, K as OfflineOperationKind, Kt as TSDFDebugLogArea, L as OfflineAccumulationConfig, Lt as ValidPayload, M as DocumentOfflineOperationDefinition, Mt as StoreFetchError, N as GlobalOfflineEntity, Nt as StoreMutationError, O as DefineCollectionOfflineOperations, Ot as MaybeTSDFResult, P as GlobalOfflineStatus, Pt as StoreMutationErrorOptions, Q as OfflineResolutionConflictParseErrorCode, R as OfflineAccumulationMergeContext, Rt as ValidStoreState, S as PersistentStoragePreloadResult, St as OfflineUpload, T as AnyOfflineOperationDefinition, Tt as OfflineUploadSource, U as OfflineMutationQueueingCause, Ut as RequestSchedulerEvents, V as OfflineMutationDescriptor, Vt as FetchType, W as OfflineMutationQueueingConfig, Wt as ScheduleFetchOptions, X as OfflineResolutionActionForOperation, Xt as TSDFDebugOptions, Y as OfflineResolutionAction, Yt as TSDFDebugLogger, Z as OfflineResolutionConflictParseError, Zt as TSDFFocusDebugOperation, _ as ListQueryOfflineOperationsConfig, _t as defaultOfflineRuntimeConfig, a as AsyncStorageMetadataOrder, at as OfflineSession, b as PersistentStorageDataSchema, bt as OfflineSessionUploadsConfig, c as AsyncStorageNamespaceCommitUpsert, ct as OfflineSyncState, d as AsyncStorageNamespaceKind, dt as OfflineTempEntityConfig, et as OfflineResolutionRecordForOperation, f as AsyncStorageNamespaceScope, ft as OfflineTempEntityPendingEntry, g as DocumentPersistentStorageConfig, gt as ParsedOfflineResolutionConflictResultForStore, h as ConvertedPersistentStorageDataSchema, ht as ParsedOfflineResolutionConflictResultForOperation, i as AsyncStorageDriverSetEntry, it as OfflineRuntimeConfigUpdate, j as DefineOfflineOperation, jt as StoreError, k as DefineDocumentOfflineOperations, kt as MutationSkipped, l as AsyncStorageNamespaceGetResult, lt as OfflineTempEntitiesConfig, m as CollectionPersistentStorageConfig, mt as OperationResult, n as AsyncStorageDiscoveredScope, nt as OfflineRetryExhaustedResolutionAction, o as AsyncStorageNamespaceCommitArgs, ot as OfflineSessionConfig, p as AsyncStorageReadOptions, pt as OperationConflict, q as OfflineQueueEntry, qt as TSDFDebugLogEntry, r as AsyncStorageDriver, rt as OfflineRuntimeConfig, s as AsyncStorageNamespaceCommitTouch, st as OfflineSupersedeConfig, t as AsyncStorageAdapter, tt as OfflineResolutionRecordForStore, u as AsyncStorageNamespaceHandle, ut as OfflineTempEntitiesReconciliation, v as ListQueryPersistentStorageConfig, vt as OfflineMutationUploadsInput, w as StorageAdapter, wt as OfflineUploadProgress, x as PersistentStorageErrorHandler, xt as OfflineStoredUploadRecord, y as PersistentStorageBaseConfig, yt as OfflineOperationUploadsContext, z as OfflineConflictResolutionAction, zt as fetchTypePriority } from "./types-DqUm_Sv7.js";
2
2
  import { __LEGIT_ANY__ } from "@ls-stack/utils/saferTyping";
3
3
  import { Emitter } from "evtmitter";
4
4
  import { Context } from "react";
@@ -38,7 +38,8 @@ type DynamicRealtimeThrottleMs = (params: {
38
38
  }) => number;
39
39
  type StoreManagerStoreDefaults = {
40
40
  /** Default minimum interval between low-priority fetches for attached stores. */readonly lowPriorityThrottleMs: number; /** Default coalescing window used by attached stores when they do not override it. */
41
- readonly baseCoalescingWindowMs: number; /** Default adaptive throttle for real-time updates in attached stores. */
41
+ readonly baseCoalescingWindowMs: number; /** Extra browser-tab coalescing delay applied only while a tab is in the background. */
42
+ readonly backgroundCoalescingDelayMs: number; /** Default adaptive throttle for real-time updates in attached stores. */
42
43
  readonly dynamicRealtimeThrottleMs: DynamicRealtimeThrottleMs; /** Shared window-close blocker used by mutations in attached stores. */
43
44
  readonly blockWindowClose: BlockWindowCloseHandler | null; /** Default focus revalidation policy for attached stores. */
44
45
  readonly revalidateOnWindowFocus: boolean | (() => boolean) | undefined;
@@ -72,7 +73,7 @@ type StoreManagerOfflineApi<TUploadRef extends ValidPayload = ValidPayload> = {
72
73
  };
73
74
  /** Shared coordinator passed to every TSDF store instance in an app/session. */
74
75
  type StoreManager<TUploadRef extends ValidPayload = ValidPayload> = {
75
- /** Returns the active shared session / tenant key. */getSessionKey: () => string | false; /** Shared debug logger for browser-tab sync and persistent storage internals. */
76
+ /** Returns the active shared session / tenant key. */getSessionKey: () => string | false; /** Shared debug logger for browser-tab sync, focus lifecycle, and persistent storage internals. */
76
77
  debugLogger?: TSDFDebugLogger; /** Normalizes raw exceptions into the shared StoreError shape. */
77
78
  errorNormalizer: (exception: Error) => StoreError; /** Global fallback for persistent storage failures in attached stores. */
78
79
  onPersistentStorageError: PersistentStorageErrorHandler | undefined; /** Global fallback for mutation failures in attached stores. */
@@ -90,16 +91,17 @@ type CreateStoreManagerOptions<TUploadRef extends ValidPayload = ValidPayload> =
90
91
  * behavior while no account is loaded.
91
92
  */
92
93
  getSessionKey: () => string | false; /** Normalizes raw exceptions into the shared StoreError shape. */
93
- errorNormalizer: (exception: Error) => StoreError; /** Default minimum interval between low-priority fetches for attached stores. Defaults to 5ms. */
94
- lowPriorityThrottleMs?: number; /** Default coalescing window for attached stores. Defaults to 10ms. */
95
- baseCoalescingWindowMs?: number; /** Default adaptive throttle for real-time updates in attached stores. Store-level values override it. */
94
+ errorNormalizer: (exception: Error) => StoreError; /** Default minimum interval between low-priority fetches for attached stores. Defaults to 40 minutes. */
95
+ lowPriorityThrottleMs?: number; /** Default coalescing window for attached stores. Defaults to 16ms. */
96
+ baseCoalescingWindowMs?: number; /** Extra browser-tab coalescing delay applied only while a tab is in the background. Defaults to 3000ms. */
97
+ backgroundCoalescingDelayMs?: number; /** Default adaptive throttle for real-time updates in attached stores. Store-level values override it. */
96
98
  dynamicRealtimeThrottleMs?: DynamicRealtimeThrottleMs; /** Shared window-close blocker used by mutations in attached stores. Pass `null` to disable. */
97
99
  blockWindowClose?: BlockWindowCloseHandler | null; /** Global fallback for persistent storage failures when a store does not provide its own handler. */
98
100
  onPersistentStorageError?: PersistentStorageErrorHandler; /** Global fallback for mutation failures when a store does not provide its own handler. */
99
101
  onMutationError?: StoreManagerMutationErrorHandler; /** Default focus revalidation policy for attached stores. Store-level values override it. */
100
102
  revalidateOnWindowFocus?: boolean | (() => boolean);
101
103
  /**
102
- * Enables debug logs for browser-tab sync and persistent storage operations.
104
+ * Enables debug logs for browser-tab sync, focus revalidation, and persistent storage operations.
103
105
  * Pass `true` to use console logging, or pass a logger function.
104
106
  */
105
107
  debug?: TSDFDebugOptions; /** Optional shared offline session config for every attached store. */
@@ -1511,4 +1513,4 @@ declare function clearAllSessionStorage(sessionKey: string): Promise<void>;
1511
1513
  //#region src/persistentStorage/opfsOfflineUploadAdapter.d.ts
1512
1514
  declare const opfsOfflineUploadAdapter: OfflineUploadAdapter;
1513
1515
  //#endregion
1514
- export { type AsyncStorageAdapter, type AsyncStorageDiscoveredScope, type AsyncStorageDriver, type AsyncStorageDriverSetEntry, type AsyncStorageMetadataOrder, type AsyncStorageNamespaceCommitArgs, type AsyncStorageNamespaceCommitTouch, type AsyncStorageNamespaceCommitUpsert, type AsyncStorageNamespaceGetResult, type AsyncStorageNamespaceHandle, type AsyncStorageNamespaceKind, type AsyncStorageNamespaceScope, type AsyncStorageReadOptions, type BlockWindowCloseHandler, CollectionItemStatus, type CollectionOfflineEntityRef, type CollectionOfflineOperationDefinition, type CollectionPersistentStorageConfig, CollectionStateCleanup, CollectionStore, CollectionStoreEvents, CollectionStoreOptions, CollectionStoreStoreEvents, CollectionUseMultipleItemsQuery, type ConvertedPersistentStorageDataSchema, type CreateStoreManagerOptions, type DefineCollectionOfflineOperations, type DefineDocumentOfflineOperations, type DefineListQueryOfflineOperations, type DefineOfflineOperation, type DerivedQueriesConfig, type DerivedQueryContext, type DerivedQuerySource, type DocumentOfflineOperationDefinition, type DocumentPersistentStorageConfig, DocumentStatus, DocumentStore, DocumentStoreOptions, DocumentStoreState, DocumentStoreStoreEvents, type DynamicRealtimeThrottleMs, type FetchListFnReturn, type FetchListFnReturnItem, type FieldsInput, type FieldsOption, GET_ALL, type GlobalOfflineEntity, type GlobalOfflineStatus, IsOffScreenContext, type ListQueryOfflineEntityRef, type ListQueryOfflineOperationDefinition, type ListQueryPersistentStorageConfig, type ListQueryStore, type ListQueryStoreEvents, type ListQueryStoreOptions, type ListQueryUseMultipleItemsQuery, type ListQueryUseMultipleListQueriesQuery, type MaybeTSDFResult, type MutationDebounce, type MutationSkipped, type OfflineAccumulationConfig, type OfflineAccumulationMergeContext, type OfflineConflictResolutionAction, type OfflineEntityMutationKind, type OfflineMutationDescriptor, type OfflineMutationInput, type OfflineMutationQueueingCause, type OfflineMutationQueueingConfig, type OfflineMutationQueueingPolicy, type OfflineMutationResult, type OfflineMutationUploadsInput, type OfflineOperationKind, type OfflineOperationUploadsContext, type OfflineQueueEntry, type OfflineReplayRetryConfig, type OfflineResolutionAction, type OfflineResolutionActionForOperation, type OfflineResolutionConflictParseError, type OfflineResolutionConflictParseErrorCode, type OfflineResolutionRecord, type OfflineResolutionRecordForOperation, type OfflineResolutionRecordForStore, type OfflineRetryExhaustedResolutionAction, type OfflineRuntimeConfig, type OfflineRuntimeConfigUpdate, type OfflineSession, type OfflineSessionConfig, type OfflineSessionUploadsConfig, type OfflineStoredUploadRecord, type OfflineSupersedeConfig, type OfflineSyncState, type OfflineTempEntitiesConfig, type OfflineTempEntitiesReconciliation, type OfflineTempEntityConfig, type OfflineTempEntityPendingEntry, type OfflineUpload, type OfflineUploadAdapter, type OfflineUploadProgress, type OfflineUploadSource, type OfflineUploadState, type OfflineUploadTransportContext, type OffsetPaginationConfig, OnCollectionItemInvalidate, OnDocumentInvalidate, type OnListQueryInvalidate, type OnListQueryItemInvalidate, type OperationConflict, type OperationResult, type OptimisticListUpdate, type ParsedOfflineResolutionConflictResultForOperation, type PartialResourcesConfig, type PayloadDebounce, type PersistentStorageBaseConfig, type PersistentStorageDataSchema, type PersistentStoragePreloadResult, type PersistentStorageSchema, type QueryFetchPayload, type QueryStatus, type StorageAdapter, type StoreError, StoreFetchError, type StoreManager, StoreMutationError, type StoreMutationErrorOptions, type TSDFDebugLogArea, type TSDFDebugLogEntry, type TSDFDebugLogLevel, type TSDFDebugLogger, type TSDFDebugOptions, type TSDFItemQuery, type TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, type TSFDListQuery, type TSFDListQueryState, TSFDUseCollectionItemReturn, type TSFDUseListItemReturn, type TSFDUseListQueryReturn, type TSFDUsePendingOfflineItemsReturn, type ValidPayload, type ValidStoreState, clearAllSessionStorage, clearSessionStorage, createCollectionStore, createDocumentStore, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };
1516
+ export { type AsyncStorageAdapter, type AsyncStorageDiscoveredScope, type AsyncStorageDriver, type AsyncStorageDriverSetEntry, type AsyncStorageMetadataOrder, type AsyncStorageNamespaceCommitArgs, type AsyncStorageNamespaceCommitTouch, type AsyncStorageNamespaceCommitUpsert, type AsyncStorageNamespaceGetResult, type AsyncStorageNamespaceHandle, type AsyncStorageNamespaceKind, type AsyncStorageNamespaceScope, type AsyncStorageReadOptions, type BlockWindowCloseHandler, CollectionItemStatus, type CollectionOfflineEntityRef, type CollectionOfflineOperationDefinition, type CollectionPersistentStorageConfig, CollectionStateCleanup, CollectionStore, CollectionStoreEvents, CollectionStoreOptions, CollectionStoreStoreEvents, CollectionUseMultipleItemsQuery, type ConvertedPersistentStorageDataSchema, type CreateStoreManagerOptions, type DefineCollectionOfflineOperations, type DefineDocumentOfflineOperations, type DefineListQueryOfflineOperations, type DefineOfflineOperation, type DerivedQueriesConfig, type DerivedQueryContext, type DerivedQuerySource, type DocumentOfflineOperationDefinition, type DocumentPersistentStorageConfig, DocumentStatus, DocumentStore, DocumentStoreOptions, DocumentStoreState, DocumentStoreStoreEvents, type DynamicRealtimeThrottleMs, type FetchListFnReturn, type FetchListFnReturnItem, type FieldsInput, type FieldsOption, GET_ALL, type GlobalOfflineEntity, type GlobalOfflineStatus, IsOffScreenContext, type ListQueryOfflineEntityRef, type ListQueryOfflineOperationDefinition, type ListQueryPersistentStorageConfig, type ListQueryStore, type ListQueryStoreEvents, type ListQueryStoreOptions, type ListQueryUseMultipleItemsQuery, type ListQueryUseMultipleListQueriesQuery, type MaybeTSDFResult, type MutationDebounce, type MutationSkipped, type OfflineAccumulationConfig, type OfflineAccumulationMergeContext, type OfflineConflictResolutionAction, type OfflineEntityMutationKind, type OfflineMutationDescriptor, type OfflineMutationInput, type OfflineMutationQueueingCause, type OfflineMutationQueueingConfig, type OfflineMutationQueueingPolicy, type OfflineMutationResult, type OfflineMutationUploadsInput, type OfflineOperationKind, type OfflineOperationUploadsContext, type OfflineQueueEntry, type OfflineReplayRetryConfig, type OfflineResolutionAction, type OfflineResolutionActionForOperation, type OfflineResolutionConflictParseError, type OfflineResolutionConflictParseErrorCode, type OfflineResolutionRecord, type OfflineResolutionRecordForOperation, type OfflineResolutionRecordForStore, type OfflineRetryExhaustedResolutionAction, type OfflineRuntimeConfig, type OfflineRuntimeConfigUpdate, type OfflineSession, type OfflineSessionConfig, type OfflineSessionUploadsConfig, type OfflineStoredUploadRecord, type OfflineSupersedeConfig, type OfflineSyncState, type OfflineTempEntitiesConfig, type OfflineTempEntitiesReconciliation, type OfflineTempEntityConfig, type OfflineTempEntityPendingEntry, type OfflineUpload, type OfflineUploadAdapter, type OfflineUploadProgress, type OfflineUploadSource, type OfflineUploadState, type OfflineUploadTransportContext, type OffsetPaginationConfig, OnCollectionItemInvalidate, OnDocumentInvalidate, type OnListQueryInvalidate, type OnListQueryItemInvalidate, type OperationConflict, type OperationResult, type OptimisticListUpdate, type ParsedOfflineResolutionConflictResultForOperation, type PartialResourcesConfig, type PayloadDebounce, type PersistentStorageBaseConfig, type PersistentStorageDataSchema, type PersistentStoragePreloadResult, type PersistentStorageSchema, type QueryFetchPayload, type QueryStatus, type StorageAdapter, type StoreError, StoreFetchError, type StoreManager, StoreMutationError, type StoreMutationErrorOptions, type TSDFDebugLogArea, type TSDFDebugLogEntry, type TSDFDebugLogLevel, type TSDFDebugLogger, type TSDFDebugOptions, type TSDFFocusDebugOperation, type TSDFItemQuery, type TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, type TSFDListQuery, type TSFDListQueryState, TSFDUseCollectionItemReturn, type TSFDUseListItemReturn, type TSFDUseListQueryReturn, type TSFDUsePendingOfflineItemsReturn, type ValidPayload, type ValidStoreState, clearAllSessionStorage, clearSessionStorage, createCollectionStore, createDocumentStore, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };