tsdf 17.0.3 → 17.0.4

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.
Files changed (251) hide show
  1. package/dist/async-storage.d.ts +1 -1
  2. package/dist/async-storage.js +1 -1
  3. package/dist/{asyncStorageAdapter-URS9eulL.js → asyncStorageAdapter-BuGjbXYA.js} +25 -165
  4. package/dist/{asyncStorageAdapter-DgsuE-T8.d.ts → asyncStorageAdapter-CMohMeKm.d.ts} +1 -1
  5. package/dist/{asyncStorageAdapters-Bxrrj_Mt.js → asyncStorageAdapters-ClUvxNQA.js} +2 -2
  6. package/dist/indexed-db-storage.d.ts +1 -1
  7. package/dist/indexed-db-storage.js +1 -1
  8. package/dist/{indexedDbPersistentStorage-BameJ4st.js → indexedDbPersistentStorage-BSlgLveB.js} +1 -11
  9. package/dist/main.d.ts +30 -34
  10. package/dist/main.js +257 -856
  11. package/dist/opfs-storage.d.ts +1 -1
  12. package/dist/opfs-storage.js +1 -1
  13. package/dist/{opfsPersistentStorage-BngS1m0X.d.ts → opfsPersistentStorage-Ci0JcCo5.d.ts} +1 -1
  14. package/dist/{opfsPersistentStorage-JsSCNBTr.js → opfsPersistentStorage-D_k77Srq.js} +1 -1
  15. package/dist/src/async-storage.d.ts +1 -0
  16. package/dist/src/cacheLimits/lruCacheRuntime.d.ts +9 -0
  17. package/dist/src/cacheLimits/scheduleIdleThrottled.d.ts +1 -0
  18. package/dist/src/cacheLimits/useRegisterActiveKeys.d.ts +1 -0
  19. package/dist/src/collectionStore/collectionCacheLimits.d.ts +1 -0
  20. package/dist/src/collectionStore/collectionStore.d.ts +385 -0
  21. package/dist/src/collectionStore/executeBatchFetch.d.ts +6 -0
  22. package/dist/src/collectionStore/useItem.d.ts +15 -0
  23. package/dist/src/collectionStore/useMultipleItems.d.ts +35 -0
  24. package/dist/src/debug.d.ts +30 -0
  25. package/dist/src/documentStore.d.ts +290 -0
  26. package/dist/src/hooks/useListItem.d.ts +22 -0
  27. package/dist/src/hooks/useListItemIsDeleted.d.ts +13 -0
  28. package/dist/src/hooks/useListItemIsLoading.d.ts +16 -0
  29. package/dist/src/indexed-db-storage.d.ts +1 -0
  30. package/dist/src/internal/offlineTestInstrumentation.d.ts +12 -0
  31. package/dist/src/internal/testTimelineTypes.d.ts +1 -0
  32. package/dist/src/invalidationUtils.d.ts +8 -0
  33. package/dist/src/isOffScreenContext.d.ts +16 -0
  34. package/dist/src/listQueryStore/createFetchApi.d.ts +1 -0
  35. package/dist/src/listQueryStore/createMutationApi.d.ts +1 -0
  36. package/dist/src/listQueryStore/executeItemBatchFetch.d.ts +20 -0
  37. package/dist/src/listQueryStore/executeQueryFetch.d.ts +7 -0
  38. package/dist/src/listQueryStore/itemFieldUtils.d.ts +77 -0
  39. package/dist/src/listQueryStore/listQueryCacheLimits.d.ts +1 -0
  40. package/dist/src/listQueryStore/listQueryStore.d.ts +538 -0
  41. package/dist/src/listQueryStore/types.d.ts +347 -0
  42. package/dist/src/listQueryStore/useFindItem.d.ts +7 -0
  43. package/dist/src/listQueryStore/useItem.d.ts +29 -0
  44. package/dist/src/listQueryStore/useListQuery.d.ts +29 -0
  45. package/dist/src/listQueryStore/useMultipleItems.d.ts +44 -0
  46. package/dist/src/listQueryStore/useMultipleListQueries.d.ts +46 -0
  47. package/dist/src/listQueryStore/usePendingOfflineItems.d.ts +19 -0
  48. package/dist/src/main.d.ts +23 -0
  49. package/dist/src/opfs-storage.d.ts +1 -0
  50. package/dist/src/persistentStorage/asyncStorageAdapter.d.ts +95 -0
  51. package/dist/src/persistentStorage/asyncStorageAdapters.d.ts +2 -0
  52. package/dist/src/persistentStorage/asyncStorageShared.d.ts +23 -0
  53. package/dist/src/persistentStorage/collectionStorePersistence.d.ts +26 -0
  54. package/dist/src/persistentStorage/compactListQueryLocalStorageEntry.d.ts +11 -0
  55. package/dist/src/persistentStorage/compactLocalStorageEntry.d.ts +8 -0
  56. package/dist/src/persistentStorage/documentEntryKey.d.ts +1 -0
  57. package/dist/src/persistentStorage/documentStorePersistence.d.ts +17 -0
  58. package/dist/src/persistentStorage/indexedDbAsyncStorageAdapter.d.ts +165 -0
  59. package/dist/src/persistentStorage/indexedDbPersistentStorage.d.ts +6 -0
  60. package/dist/src/persistentStorage/listQueryStorePersistence.d.ts +37 -0
  61. package/dist/src/persistentStorage/localStorageMetadata.d.ts +126 -0
  62. package/dist/src/persistentStorage/navigatorLocks.d.ts +3 -0
  63. package/dist/src/persistentStorage/offline/entityMetadata.d.ts +12 -0
  64. package/dist/src/persistentStorage/offline/fetchRuntime.d.ts +35 -0
  65. package/dist/src/persistentStorage/offline/mutationRuntime.d.ts +31 -0
  66. package/dist/src/persistentStorage/offline/offlineResolution.typeGuards.d.ts +1 -0
  67. package/dist/src/persistentStorage/offline/overlayStoreLifecycle.d.ts +13 -0
  68. package/dist/src/persistentStorage/offline/sessionCoordinator.d.ts +94 -0
  69. package/dist/src/persistentStorage/offline/sessionProtectionRegistry.d.ts +11 -0
  70. package/dist/src/persistentStorage/offline/storeController.d.ts +86 -0
  71. package/dist/src/persistentStorage/offline/types.d.ts +1255 -0
  72. package/dist/src/persistentStorage/offlineUploadRegistry.d.ts +11 -0
  73. package/dist/src/persistentStorage/offlineUploadTypes.d.ts +97 -0
  74. package/dist/src/persistentStorage/offlineUploadsShared.d.ts +4 -0
  75. package/dist/src/persistentStorage/opfsAsyncStorageAdapter.d.ts +24 -0
  76. package/dist/src/persistentStorage/opfsFileNaming.d.ts +23 -0
  77. package/dist/src/persistentStorage/opfsHelpers.d.ts +3 -0
  78. package/dist/src/persistentStorage/opfsOfflineUploadAdapter.d.ts +2 -0
  79. package/dist/src/persistentStorage/opfsPersistentStorage.d.ts +2 -0
  80. package/dist/src/persistentStorage/parsePersistedData.d.ts +45 -0
  81. package/dist/src/persistentStorage/persistenceUtils.d.ts +52 -0
  82. package/dist/src/persistentStorage/persistentStorageDefaults.d.ts +4 -0
  83. package/dist/src/persistentStorage/persistentStorageManager.d.ts +197 -0
  84. package/dist/src/persistentStorage/quotaDebug.d.ts +16 -0
  85. package/dist/src/persistentStorage/scheduleIdleCleanup.d.ts +28 -0
  86. package/dist/src/persistentStorage/storageAdapter.d.ts +41 -0
  87. package/dist/src/persistentStorage/storageEntryPrefixes.d.ts +16 -0
  88. package/dist/src/persistentStorage/types.d.ts +412 -0
  89. package/dist/src/persistentStorage/validateWithSchema.d.ts +12 -0
  90. package/dist/src/requestScheduler.d.ts +81 -0
  91. package/dist/src/storeManager.d.ts +160 -0
  92. package/dist/src/utils/automaticFetchPolicy.d.ts +29 -0
  93. package/dist/src/utils/browserTabsPriority.d.ts +43 -0
  94. package/dist/src/utils/browserTabsSync.d.ts +33 -0
  95. package/dist/src/utils/optimisticMutationTracker.d.ts +20 -0
  96. package/dist/src/utils/optimisticRollback.d.ts +11 -0
  97. package/dist/src/utils/payloadDebounce.d.ts +5 -0
  98. package/dist/src/utils/performMutation.d.ts +19 -0
  99. package/dist/src/utils/reusePrevIfEqual.d.ts +1 -0
  100. package/dist/src/utils/storeFocusLifecycle.d.ts +1 -0
  101. package/dist/src/utils/storeShared.d.ts +126 -0
  102. package/dist/src/utils/useEnsureIsLoaded.d.ts +6 -0
  103. package/dist/src/utils/useRequireFreshData.d.ts +6 -0
  104. package/dist/tests/basic-functionality/collection-store.test.d.ts +1 -0
  105. package/dist/tests/basic-functionality/document-store.test.d.ts +1 -0
  106. package/dist/tests/basic-functionality/list-query-state-manipulation.test.d.ts +1 -0
  107. package/dist/tests/basic-functionality/list-query-store.test.d.ts +1 -0
  108. package/dist/tests/browser-tabs/browser-tabs-background-rtu-batch.test.d.ts +1 -0
  109. package/dist/tests/browser-tabs/browser-tabs-background-rtu.test.d.ts +1 -0
  110. package/dist/tests/browser-tabs/browser-tabs-background-scheduling.test.d.ts +1 -0
  111. package/dist/tests/browser-tabs/browser-tabs-list-query-pagination.test.d.ts +1 -0
  112. package/dist/tests/browser-tabs/browser-tabs-non-cancelable-fetches.test.d.ts +1 -0
  113. package/dist/tests/browser-tabs/browser-tabs-optimistic-sync.test.d.ts +1 -0
  114. package/dist/tests/browser-tabs/browser-tabs-partial-resources.test.d.ts +1 -0
  115. package/dist/tests/browser-tabs/browser-tabs-priority.test.d.ts +1 -0
  116. package/dist/tests/browser-tabs/browser-tabs-snapshot-consistency.test.d.ts +1 -0
  117. package/dist/tests/browser-tabs/browser-tabs-state-methods.test.d.ts +1 -0
  118. package/dist/tests/browser-tabs/browser-tabs-sync-coordinator.test.d.ts +1 -0
  119. package/dist/tests/browser-tabs/browser-tabs-test-helpers.d.ts +69 -0
  120. package/dist/tests/browser-tabs/focus-coordinator.test.d.ts +1 -0
  121. package/dist/tests/hooks/collection-hooks-2.test.d.ts +1 -0
  122. package/dist/tests/hooks/collection-hooks.test.d.ts +1 -0
  123. package/dist/tests/hooks/collection-useListItem.test.d.ts +1 -0
  124. package/dist/tests/hooks/debounce-payload-hooks.test.d.ts +1 -0
  125. package/dist/tests/hooks/disable-refetches.test.d.ts +1 -0
  126. package/dist/tests/hooks/document-hooks-2.test.d.ts +1 -0
  127. package/dist/tests/hooks/document-hooks.test.d.ts +1 -0
  128. package/dist/tests/hooks/document-useListItem.test.d.ts +1 -0
  129. package/dist/tests/hooks/fetch-error-recovery.test.d.ts +1 -0
  130. package/dist/tests/hooks/hook-memoization.test.d.ts +1 -0
  131. package/dist/tests/hooks/list-query-hooks-2.test.d.ts +1 -0
  132. package/dist/tests/hooks/list-query-hooks-3.test.d.ts +1 -0
  133. package/dist/tests/hooks/list-query-hooks-mutations.test.d.ts +1 -0
  134. package/dist/tests/hooks/list-query-hooks.test.d.ts +1 -0
  135. package/dist/tests/hooks/list-query-pending-offline-items.test.d.ts +1 -0
  136. package/dist/tests/hooks/off-screen-context.test.d.ts +1 -0
  137. package/dist/tests/list-query-features/list-query-derived-queries.test.d.ts +1 -0
  138. package/dist/tests/list-query-features/list-query-offset-pagination.test.d.ts +1 -0
  139. package/dist/tests/list-query-features/list-query-optimistic-filters.test.d.ts +1 -0
  140. package/dist/tests/list-query-features/list-query-partial-resources-2.test.d.ts +1 -0
  141. package/dist/tests/list-query-features/list-query-partial-resources-3.test.d.ts +1 -0
  142. package/dist/tests/list-query-features/list-query-partial-resources-regressions.test.d.ts +1 -0
  143. package/dist/tests/list-query-features/list-query-partial-resources-show-partial-status.test.d.ts +1 -0
  144. package/dist/tests/list-query-features/list-query-partial-resources.test.d.ts +1 -0
  145. package/dist/tests/list-query-features/list-query-size-coalescing-partial-resources.test.d.ts +1 -0
  146. package/dist/tests/mocks/browserTabsTestUtils.d.ts +17 -0
  147. package/dist/tests/mocks/collectionStoreTestEnv.d.ts +265 -0
  148. package/dist/tests/mocks/documentStoreTestEnv.d.ts +140 -0
  149. package/dist/tests/mocks/duplicateStoreGuard.test.d.ts +1 -0
  150. package/dist/tests/mocks/listQueryStoreTestEnv.d.ts +295 -0
  151. package/dist/tests/mocks/mockBrowserOpfs.d.ts +70 -0
  152. package/dist/tests/mocks/mockBrowserOpfs.test.d.ts +1 -0
  153. package/dist/tests/mocks/mockLocalStorageStore.d.ts +61 -0
  154. package/dist/tests/mocks/seedScenarioPersistentStorage.d.ts +51 -0
  155. package/dist/tests/mocks/serverMock.d.ts +56 -0
  156. package/dist/tests/mocks/serverTableMock.d.ts +174 -0
  157. package/dist/tests/mocks/testEnvUtils.d.ts +120 -0
  158. package/dist/tests/mocks/testScenarioPersistentStorage.test.d.ts +1 -0
  159. package/dist/tests/offline/offline-fetching-scenarios.test.d.ts +1 -0
  160. package/dist/tests/offline/offline-mixed-adapter-storage.test.d.ts +1 -0
  161. package/dist/tests/offline/offline-mutation-fallback.test.d.ts +1 -0
  162. package/dist/tests/offline/offline-network-recovery.test.d.ts +1 -0
  163. package/dist/tests/offline/offline-outage.test.d.ts +1 -0
  164. package/dist/tests/offline/offline-overlays.test.d.ts +1 -0
  165. package/dist/tests/offline/offline-query-replay.test.d.ts +1 -0
  166. package/dist/tests/offline/offline-reads.test.d.ts +1 -0
  167. package/dist/tests/offline/offline-replay-conflicts.test.d.ts +1 -0
  168. package/dist/tests/offline/offline-replay-queueing.test.d.ts +1 -0
  169. package/dist/tests/offline/offline-resolution-dependencies.test.d.ts +1 -0
  170. package/dist/tests/offline/offline-runtime-controls.test.d.ts +1 -0
  171. package/dist/tests/offline/offline-session-and-global-state.test.d.ts +1 -0
  172. package/dist/tests/offline/offline-storage.test.d.ts +1 -0
  173. package/dist/tests/offline/offline-uploads.test.d.ts +1 -0
  174. package/dist/tests/offline/offlineReplayTestShared.d.ts +292 -0
  175. package/dist/tests/offline/offlineTestShared.d.ts +156 -0
  176. package/dist/tests/perform-mutation/mutation-error-rollback.test.d.ts +1 -0
  177. package/dist/tests/perform-mutation/perform-mutation-block-window-close.test.d.ts +1 -0
  178. package/dist/tests/perform-mutation/perform-mutation-debounce.test.d.ts +1 -0
  179. package/dist/tests/perform-mutation/store-events.test.d.ts +1 -0
  180. package/dist/tests/persistent-storage/async-storage-efficiency/collection.test.d.ts +1 -0
  181. package/dist/tests/persistent-storage/async-storage-efficiency/document.test.d.ts +1 -0
  182. package/dist/tests/persistent-storage/async-storage-efficiency/list-query.test.d.ts +1 -0
  183. package/dist/tests/persistent-storage/async-storage-efficiency/maintenance.test.d.ts +1 -0
  184. package/dist/tests/persistent-storage/async-storage-efficiency/shared.d.ts +804 -0
  185. package/dist/tests/persistent-storage/async-storage-shared.test.d.ts +1 -0
  186. package/dist/tests/persistent-storage/collection-store-persistence.converted.opfs.test.d.ts +1 -0
  187. package/dist/tests/persistent-storage/collection-store-persistence.converted.test.d.ts +1 -0
  188. package/dist/tests/persistent-storage/collection-store-persistence.opfs.test.d.ts +1 -0
  189. package/dist/tests/persistent-storage/collection-store-persistence.test.d.ts +1 -0
  190. package/dist/tests/persistent-storage/document-store-persistence.converted.opfs.test.d.ts +1 -0
  191. package/dist/tests/persistent-storage/document-store-persistence.converted.test.d.ts +1 -0
  192. package/dist/tests/persistent-storage/document-store-persistence.opfs.test.d.ts +1 -0
  193. package/dist/tests/persistent-storage/document-store-persistence.test.d.ts +1 -0
  194. package/dist/tests/persistent-storage/expiration-scan.test.d.ts +1 -0
  195. package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/collection.test.d.ts +1 -0
  196. package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/document.test.d.ts +1 -0
  197. package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/list-query.test.d.ts +1 -0
  198. package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/maintenance.test.d.ts +1 -0
  199. package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/shared.d.ts +780 -0
  200. package/dist/tests/persistent-storage/indexeddb-storage-adapter.test.d.ts +1 -0
  201. package/dist/tests/persistent-storage/list-query-store-persistence.converted.opfs.test.d.ts +1 -0
  202. package/dist/tests/persistent-storage/list-query-store-persistence.converted.test.d.ts +1 -0
  203. package/dist/tests/persistent-storage/list-query-store-persistence.opfs.test.d.ts +1 -0
  204. package/dist/tests/persistent-storage/list-query-store-persistence.test.d.ts +1 -0
  205. package/dist/tests/persistent-storage/persistence-with-tabs-sync.test.d.ts +1 -0
  206. package/dist/tests/persistent-storage/persistentStorageByteBudgetTestUtils.d.ts +18 -0
  207. package/dist/tests/persistent-storage/quota-exceeded-recovery-no-locks.test.d.ts +1 -0
  208. package/dist/tests/persistent-storage/quota-exceeded-recovery.test.d.ts +1 -0
  209. package/dist/tests/persistent-storage/quotaRecoveryTestUtils.d.ts +228 -0
  210. package/dist/tests/persistent-storage/storage-adapter.test.d.ts +1 -0
  211. package/dist/tests/persistent-storage/sync-storage-efficiency/collection.test.d.ts +1 -0
  212. package/dist/tests/persistent-storage/sync-storage-efficiency/document.test.d.ts +1 -0
  213. package/dist/tests/persistent-storage/sync-storage-efficiency/list-query.test.d.ts +1 -0
  214. package/dist/tests/persistent-storage/sync-storage-efficiency/maintenance.test.d.ts +1 -0
  215. package/dist/tests/persistent-storage/sync-storage-efficiency/shared.d.ts +784 -0
  216. package/dist/tests/playwright/browser-tabs.spec.d.ts +1 -0
  217. package/dist/tests/playwright/persistent-storage.spec.d.ts +1 -0
  218. package/dist/tests/request-schedulling/batch-medium-priority.test.d.ts +1 -0
  219. package/dist/tests/request-schedulling/batch-realtime-updates.test.d.ts +1 -0
  220. package/dist/tests/request-schedulling/collection-batch-coalescing.test.d.ts +1 -0
  221. package/dist/tests/request-schedulling/collection-batch-key-grouping.test.d.ts +1 -0
  222. package/dist/tests/request-schedulling/collection-fetch-orchestration.test.d.ts +1 -0
  223. package/dist/tests/request-schedulling/document-await-fetch.test.d.ts +1 -0
  224. package/dist/tests/request-schedulling/document-base-coalescing.test.d.ts +1 -0
  225. package/dist/tests/request-schedulling/document-fetch-orchestration.test.d.ts +1 -0
  226. package/dist/tests/request-schedulling/document-medium-priority-fetch.test.d.ts +1 -0
  227. package/dist/tests/request-schedulling/document-realtime-updates.test.d.ts +1 -0
  228. package/dist/tests/request-schedulling/list-query-item-batch-coalescing.test.d.ts +1 -0
  229. package/dist/tests/request-schedulling/list-query-item-batch-key-grouping.test.d.ts +1 -0
  230. package/dist/tests/request-schedulling/list-query-size-coalescing.test.d.ts +1 -0
  231. package/dist/tests/request-schedulling/medium-vs-realtime.test.d.ts +1 -0
  232. package/dist/tests/request-schedulling/request-scheduler-cross-tab-sync.test.d.ts +1 -0
  233. package/dist/tests/request-schedulling/window-focus.test.d.ts +1 -0
  234. package/dist/tests/store-manager.test.d.ts +1 -0
  235. package/dist/tests/user-facing-api/collection-offline-usage.test.d.ts +1 -0
  236. package/dist/tests/user-facing-api/document-offline-usage.test.d.ts +1 -0
  237. package/dist/tests/user-facing-api/list-query-offline-usage.test.d.ts +1 -0
  238. package/dist/tests/user-facing-api/result-returning-callbacks.test.d.ts +1 -0
  239. package/dist/tests/utils/genericTestUtils.d.ts +6 -0
  240. package/dist/tests/utils/indexedDbPersistentStorageOptimizationTestUtils.d.ts +79 -0
  241. package/dist/tests/utils/indexedDbPersistentStorageTestStore.d.ts +181 -0
  242. package/dist/tests/utils/listQueryHooksTestUtils.d.ts +8 -0
  243. package/dist/tests/utils/networkMock.d.ts +11 -0
  244. package/dist/tests/utils/opfsPersistentStorageTestStore.d.ts +220 -0
  245. package/dist/tests/utils/persistentStorageOptimizationTestUtils.d.ts +54 -0
  246. package/dist/tests/utils/persistentStorageOptimizationTestUtils.test.d.ts +1 -0
  247. package/dist/tests/utils/persistentStorageTestStore.d.ts +66 -0
  248. package/dist/tests/utils/resetSessionForTests.d.ts +3 -0
  249. package/dist/tests/utils/withSuppressedActError.d.ts +4 -0
  250. package/dist/{types-BlyGC_PO.d.ts → types-D0ttVGmj.d.ts} +3 -3
  251. package/package.json +2 -2
@@ -0,0 +1,95 @@
1
+ import type { AsyncStorageAdapter, AsyncStorageDiscoveredScope, AsyncStorageDriver, AsyncStorageEntryMetadata, AsyncStorageMetadataOrder, ManagedAsyncStorageNamespaceCommitArgs, AsyncStorageNamespaceCommitConditionalRemove, AsyncStorageNamespaceGetResult, AsyncStorageProtectedEntryRef, AsyncStorageNamespaceScope, AsyncStorageNamespaceStaticPolicy } from './types';
2
+ export declare const ASYNC_STORAGE_COMMIT_DEBOUNCE_MS: number;
3
+ export declare const ASYNC_STORAGE_MAX_AGE_MS: number;
4
+ export declare const ASYNC_MAINTENANCE_LOCAL_STORAGE_KEY: "tsdf._am.g";
5
+ export declare function isAsyncStorageMetadataOfflineProtected(customMetadata: Record<string, unknown> | undefined): boolean;
6
+ export declare function getProtectedKeysFromMetadata(entries: ReadonlyArray<{
7
+ customMetadata?: Record<string, unknown>;
8
+ key: string;
9
+ }>): Set<string>;
10
+ export declare function mergeManagedAsyncStorageCustomMetadata(currentCustomMetadata: Record<string, unknown> | undefined, nextCustomMetadata: Record<string, unknown> | undefined, protectedKeysSnapshotSet: Set<string> | null | undefined, scope: AsyncStorageNamespaceScope, key: string): Record<string, unknown> | undefined;
11
+ type InternalManagedMetadataRecord = {
12
+ customMetadata?: Record<string, unknown>;
13
+ lastAccessAt: number;
14
+ sizeBytes?: number;
15
+ version: number;
16
+ };
17
+ export declare function estimateManagedAsyncStorageEntrySizeBytes(serializedValue: string, lastAccessAt: number, version: number, customMetadata?: Record<string, unknown>): number;
18
+ /**
19
+ * Builds a persisted static policy from config values, omitting fields that
20
+ * match the provided default. Returns null when no overrides are needed.
21
+ */
22
+ export declare function buildPersistedStaticPolicy(maxBytes: number | undefined, defaultMaxBytes: number, pinnedKeys: ReadonlySet<string>): AsyncStorageNamespaceStaticPolicy | null;
23
+ export type AsyncStorageManagedMetadataRecord = InternalManagedMetadataRecord;
24
+ type AsyncStorageManagedMetadataFilter = {
25
+ equals: unknown;
26
+ key: string;
27
+ };
28
+ type AsyncStorageManagedMetadataListArgs = {
29
+ filter?: AsyncStorageManagedMetadataFilter;
30
+ knownRecordKeys?: string[] | null;
31
+ order?: AsyncStorageMetadataOrder;
32
+ };
33
+ export type AsyncStorageManagedDriverCapabilities = {
34
+ /** Resolves with the `conditionalRemoves` keys kept because they changed. */
35
+ applyManagedCommit?: (scope: AsyncStorageNamespaceScope, args: ManagedAsyncStorageNamespaceCommitArgs<unknown, Record<string, unknown>>, helpers: {
36
+ mergeOfflineProtectionMetadata: (key: string, nextCustomMetadata: Record<string, unknown> | undefined, currentCustomMetadata: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
37
+ }) => Promise<ReadonlySet<string> | undefined>;
38
+ clearManagedNamespace?: (scope: AsyncStorageNamespaceScope) => Promise<void>;
39
+ listManagedKeys?: (scope: AsyncStorageNamespaceScope) => Promise<string[]>;
40
+ listManagedMetadata?: (scope: AsyncStorageNamespaceScope, args?: AsyncStorageManagedMetadataListArgs) => Promise<AsyncStorageEntryMetadata<Record<string, unknown>>[]>;
41
+ readProtectedStorageKeys?: (sessionKey: string) => Promise<string[]>;
42
+ readManagedEntries?: <TValue>(scope: AsyncStorageNamespaceScope, keys: string[]) => Promise<Map<string, AsyncStorageNamespaceGetResult<TValue, Record<string, unknown>> | null>>;
43
+ readNamespaceIndexState?: (scope: AsyncStorageNamespaceScope, knownRecordKeys?: string[] | null) => Promise<{
44
+ entries: Map<string, AsyncStorageManagedMetadataRecord> | null;
45
+ exists: boolean;
46
+ staticPolicy: AsyncStorageNamespaceStaticPolicy | null;
47
+ valid: boolean;
48
+ }>;
49
+ persistNamespaceIndexState?: (scope: AsyncStorageNamespaceScope, state: {
50
+ entries: Map<string, AsyncStorageManagedMetadataRecord>;
51
+ staticPolicy: AsyncStorageNamespaceStaticPolicy | null;
52
+ }) => Promise<void>;
53
+ syncSessionProtectedKeys?: (sessionKey: string, protectedKeys: Iterable<string>) => Promise<void>;
54
+ };
55
+ export declare function readAsyncStorageNamespaceIndexStateUsingDriver(driver: AsyncStorageDriver, scope: AsyncStorageNamespaceScope, knownRecordKeys?: string[] | null): Promise<{
56
+ entries: Map<string, AsyncStorageManagedMetadataRecord> | null;
57
+ exists: boolean;
58
+ staticPolicy: AsyncStorageNamespaceStaticPolicy | null;
59
+ valid: boolean;
60
+ }>;
61
+ export type AsyncStartupCleanupStoreDeletePlan = {
62
+ representativeScope: AsyncStorageNamespaceScope;
63
+ removedKeysByScope: Array<{
64
+ keys: string[];
65
+ scope: AsyncStorageNamespaceScope;
66
+ }>;
67
+ };
68
+ export type AsyncStartupCleanupScopePlan = {
69
+ deleteKeys: string[];
70
+ persistEntries: Map<string, AsyncStorageManagedMetadataRecord> | null;
71
+ persistStaticPolicy?: AsyncStorageNamespaceStaticPolicy | null;
72
+ scope: AsyncStorageNamespaceScope;
73
+ };
74
+ type AsyncStartupStoreCleanupCallback = (args: {
75
+ discoveredScopes: AsyncStorageDiscoveredScope[];
76
+ driver: AsyncStorageDriver;
77
+ now: number;
78
+ }) => Promise<{
79
+ scopePlans: AsyncStartupCleanupScopePlan[];
80
+ storeDeletePlans?: AsyncStartupCleanupStoreDeletePlan[];
81
+ }>;
82
+ export declare function registerAsyncStartupStoreCleanup(adapter: AsyncStorageAdapter, sessionKey: string, storeName: string, callback: AsyncStartupStoreCleanupCallback): void;
83
+ export declare function unregisterAsyncStartupStoreCleanup(adapter: AsyncStorageAdapter, sessionKey: string, storeName: string): void;
84
+ export declare function createAsyncStorageAdapter(driver: AsyncStorageDriver): AsyncStorageAdapter;
85
+ /** Number of keys idle-deadline maintenance removes per commit. */
86
+ export declare function getAsyncStorageMaintenanceRemoveBatchSize(adapter: AsyncStorageAdapter | null): number;
87
+ /**
88
+ * Removes entries only while they still have the metadata the caller read,
89
+ * without waiting for the namespace batching debounce. Resolves with the keys
90
+ * kept because they changed. Managed adapters check and remove atomically;
91
+ * other adapters only get a best-effort metadata re-read before removing.
92
+ */
93
+ export declare function removeAsyncStorageNamespaceEntriesIfUnchanged(adapter: AsyncStorageAdapter, scope: AsyncStorageNamespaceScope, entries: AsyncStorageNamespaceCommitConditionalRemove[]): Promise<ReadonlySet<string>>;
94
+ export declare function serializeProtectedRef(ref: AsyncStorageProtectedEntryRef): string;
95
+ export {};
@@ -0,0 +1,2 @@
1
+ export { indexedDbPersistentStorage } from './indexedDbPersistentStorage';
2
+ export { opfsPersistentStorage } from './opfsPersistentStorage';
@@ -0,0 +1,23 @@
1
+ import type { AsyncStorageEntryMetadata, AsyncStorageMetadataOrder, AsyncStorageNamespaceCommitConditionalRemove, AsyncStorageNamespaceKind, AsyncStorageNamespaceScope, AsyncStorageNamespaceStaticPolicy, AsyncStorageProtectedEntryRef } from './types';
2
+ export declare const PAYLOAD_RECORD_PREFIX = "__tsdf_payload__:";
3
+ export declare const ASYNC_NAMESPACE_INDEX_RECORD_KEY = "_i";
4
+ export declare function getNamespaceId(scope: AsyncStorageNamespaceScope): string;
5
+ type PersistedAsyncNamespaceKindAlias = 'd' | 'ci' | 'li' | 'lq' | 'oq' | 'oc' | 'oe' | 'ip';
6
+ export declare function encodePersistedAsyncNamespaceKind(kind: AsyncStorageNamespaceKind): PersistedAsyncNamespaceKindAlias;
7
+ export declare function parsePersistedAsyncNamespaceKind(value: string): AsyncStorageNamespaceKind | null;
8
+ export declare function getPersistedNamespaceId(scope: AsyncStorageNamespaceScope): string;
9
+ export declare function getPayloadRecordKey(key: string): string;
10
+ export declare function serializeProtectedRef(ref: AsyncStorageProtectedEntryRef): string;
11
+ export declare function parseProtectedRef(value: string): AsyncStorageProtectedEntryRef | null;
12
+ export declare function parseAsyncStorageRecordKey(key: string): {
13
+ recordKind: 'payload';
14
+ userKey: string;
15
+ } | {
16
+ rawKey: string;
17
+ recordKind: 'raw';
18
+ };
19
+ export declare function normalizeStaticPolicy(policy: AsyncStorageNamespaceStaticPolicy | null | undefined): AsyncStorageNamespaceStaticPolicy | null;
20
+ export declare function compareMetadata(left: AsyncStorageEntryMetadata<Record<string, unknown>>, right: AsyncStorageEntryMetadata<Record<string, unknown>>, order: AsyncStorageMetadataOrder): number;
21
+ /** Whether an entry still has the metadata a conditional remove expects. */
22
+ export declare function matchesConditionalRemove(remove: AsyncStorageNamespaceCommitConditionalRemove, lastAccessAt: number, sizeBytes: number | undefined, version: number, offlineProtected: boolean): boolean;
23
+ export {};
@@ -0,0 +1,26 @@
1
+ import { type __LEGIT_ANY__ } from '@ls-stack/utils/saferTyping';
2
+ import type { Store } from 't-state';
3
+ import type { TSFDCollectionItem, TSFDCollectionState } from '../collectionStore/collectionStore';
4
+ import type { ValidPayload, ValidStoreState } from '../utils/storeShared';
5
+ import type { AnyOfflineOperationDefinition, CollectionOfflineEntityRef } from './offline/types';
6
+ import type { ResolvedCollectionPersistentStorageConfig } from './types';
7
+ type CollectionPersistenceOfflineOperations<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = (Record<string, AnyOfflineOperationDefinition & {
8
+ getEntityRefs: (ctx: {
9
+ input: __LEGIT_ANY__;
10
+ }) => CollectionOfflineEntityRef<ItemPayload>[];
11
+ }> & ([ItemState | ItemPayload] extends [never] ? never : unknown)) | null;
12
+ type CollectionPersistenceSetup<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = {
13
+ createInitialState(baseState: TSFDCollectionState<ItemState, ItemPayload>): TSFDCollectionState<ItemState, ItemPayload>;
14
+ attach(store: Store<TSFDCollectionState<ItemState, ItemPayload>>): void;
15
+ maybeHydrateItems(itemKeys: string[]): Promise<boolean[]>;
16
+ preloadItems(itemKeys: string[]): Promise<boolean[]>;
17
+ getHydratedItemKeys(this: void): string[];
18
+ readHydratedItem(this: void, itemKey: string): TSFDCollectionItem<ItemState, ItemPayload> | undefined;
19
+ hasAsyncPreload: boolean;
20
+ dispose(): void;
21
+ clear(): Promise<void>;
22
+ };
23
+ export declare function setupCollectionPersistence<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, TOfflineOperations extends CollectionPersistenceOfflineOperations<ItemState, ItemPayload> = null, StorageState = unknown>(config: ResolvedCollectionPersistentStorageConfig<ItemState, ItemPayload, StorageState, TOfflineOperations>, options?: {
24
+ getItemKey?: (payload: ItemPayload) => string;
25
+ }): CollectionPersistenceSetup<ItemState, ItemPayload>;
26
+ export {};
@@ -0,0 +1,11 @@
1
+ export declare function isCompactListQueryLocalStorageKey(storageKey: string): boolean;
2
+ export type CompactListQueryLocalStorageEntry = {
3
+ hasMore: boolean;
4
+ items: string[];
5
+ lastAccessAt: number;
6
+ offlineProtected: boolean;
7
+ payload: unknown;
8
+ version?: number;
9
+ };
10
+ export declare function parseCompactListQueryLocalStorageEntry(raw: string | null): CompactListQueryLocalStorageEntry | null;
11
+ export declare function createCompactListQueryLocalStorageEntry(entry: CompactListQueryLocalStorageEntry): Record<string, unknown>;
@@ -0,0 +1,8 @@
1
+ export type CompactLocalStorageEntryValue = Record<string, unknown>;
2
+ export declare function createCompactLocalStorageEntry(value: CompactLocalStorageEntryValue, version: number | undefined): CompactLocalStorageEntryValue;
3
+ type ParsedCompactLocalStorageEntry = {
4
+ value: CompactLocalStorageEntryValue;
5
+ version?: number;
6
+ };
7
+ export declare function parseCompactLocalStorageEntry(raw: string | null): ParsedCompactLocalStorageEntry | null;
8
+ export {};
@@ -0,0 +1 @@
1
+ export declare const DOCUMENT_PERSISTED_ENTRY_KEY = "d";
@@ -0,0 +1,17 @@
1
+ import type { Store } from 't-state';
2
+ import type { DocumentStoreState } from '../documentStore';
3
+ import type { ValidStoreState } from '../utils/storeShared';
4
+ import type { AnyOfflineOperationDefinition } from './offline/types';
5
+ import type { ResolvedDocumentPersistentStorageConfig } from './types';
6
+ type DocumentPersistenceOfflineOperations<State extends ValidStoreState> = (Record<string, AnyOfflineOperationDefinition> & ([State] extends [never] ? never : unknown)) | null;
7
+ type DocumentPersistenceSetup<State extends ValidStoreState> = {
8
+ createInitialState(baseState: DocumentStoreState<State>): DocumentStoreState<State>;
9
+ attach(store: Store<DocumentStoreState<State>>): void;
10
+ maybeHydrateFromStorage(): Promise<void>;
11
+ preloadPersistentStorage(): Promise<void>;
12
+ hasAsyncPreload: boolean;
13
+ dispose(): void;
14
+ clear(): Promise<void>;
15
+ };
16
+ export declare function setupDocumentPersistence<State extends ValidStoreState, TOfflineOperations extends DocumentPersistenceOfflineOperations<State> = null, StorageState = unknown>(config: ResolvedDocumentPersistentStorageConfig<State, StorageState, TOfflineOperations>): DocumentPersistenceSetup<State>;
17
+ export {};
@@ -0,0 +1,165 @@
1
+ import { type TSDFDebugLogger } from '../debug';
2
+ import { type AsyncStorageManagedDriverCapabilities } from './asyncStorageAdapter';
3
+ import type { AsyncStorageAdapter, AsyncStorageDiscoveredScope, AsyncStorageDriver, AsyncStorageDriverSetEntry, AsyncStorageEntryMetadata, AsyncStorageMetadataOrder, ManagedAsyncStorageNamespaceCommitArgs, AsyncStorageNamespaceGetResult, AsyncStorageNamespaceScope, AsyncStorageNamespaceStaticPolicy } from './types';
4
+ type IndexedDbManagedMetadataRecord = {
5
+ customMetadata?: Record<string, unknown>;
6
+ lastAccessAt: number;
7
+ sizeBytes?: number;
8
+ version: number;
9
+ };
10
+ type IndexedDbManagedIndexState = {
11
+ entries: Map<string, IndexedDbManagedMetadataRecord> | null;
12
+ exists: boolean;
13
+ staticPolicy: AsyncStorageNamespaceStaticPolicy | null;
14
+ valid: boolean;
15
+ };
16
+ type IndexedDbManagedMetadataFilter = {
17
+ equals: unknown;
18
+ key: string;
19
+ };
20
+ type IndexedDbTestOperation = {
21
+ order: AsyncStorageMetadataOrder;
22
+ resultKeys: string[];
23
+ scope: AsyncStorageNamespaceScope;
24
+ time: number;
25
+ type: 'listManagedMetadata';
26
+ usedIndex: 'group' | 'key' | 'lru';
27
+ } | {
28
+ keys: string[];
29
+ resultKeys: string[];
30
+ scope: AsyncStorageNamespaceScope;
31
+ time: number;
32
+ type: 'readManagedEntries';
33
+ } | {
34
+ removes: string[];
35
+ scope: AsyncStorageNamespaceScope;
36
+ staticPolicyChanged: boolean;
37
+ time: number;
38
+ touches: string[];
39
+ type: 'applyManagedCommit';
40
+ upserts: string[];
41
+ } | {
42
+ scope: AsyncStorageNamespaceScope;
43
+ time: number;
44
+ type: 'clearManagedNamespace';
45
+ } | {
46
+ scopeIds: string[];
47
+ sessionKey?: string;
48
+ time: number;
49
+ type: 'listScopesWithKnownRecordKeys';
50
+ } | {
51
+ exists: boolean;
52
+ keyCount: number;
53
+ scope: AsyncStorageNamespaceScope;
54
+ time: number;
55
+ type: 'readManagedIndexState';
56
+ valid: boolean;
57
+ } | {
58
+ keys: string[];
59
+ scope: AsyncStorageNamespaceScope;
60
+ time: number;
61
+ type: 'removeManagedRecords';
62
+ } | {
63
+ keyCount: number;
64
+ scope: AsyncStorageNamespaceScope;
65
+ staticPolicy: AsyncStorageNamespaceStaticPolicy | null;
66
+ time: number;
67
+ type: 'persistManagedIndexState';
68
+ } | {
69
+ sessionKey: string;
70
+ time: number;
71
+ type: 'readProtectedStorageKeys';
72
+ values: string[];
73
+ } | {
74
+ sessionKey: string;
75
+ time: number;
76
+ type: 'syncSessionProtectedKeys';
77
+ values: string[];
78
+ };
79
+ type IndexedDbDriverInstrumentation = {
80
+ onApplyManagedCommit?: (scope: AsyncStorageNamespaceScope, args: ManagedAsyncStorageNamespaceCommitArgs<unknown, Record<string, unknown>>) => void;
81
+ onClearManagedNamespace?: (scope: AsyncStorageNamespaceScope) => void;
82
+ onPersistNamespaceIndexState?: (scope: AsyncStorageNamespaceScope, state: {
83
+ entries: Map<string, IndexedDbManagedMetadataRecord>;
84
+ staticPolicy: AsyncStorageNamespaceStaticPolicy | null;
85
+ }) => void;
86
+ onRemoveMany?: (scope: AsyncStorageNamespaceScope, keys: string[]) => void;
87
+ operations: IndexedDbTestOperation[];
88
+ record: (operation: IndexedDbTestOperation) => void;
89
+ reset: () => void;
90
+ };
91
+ type IndexedDbStructureInspection = {
92
+ stores: Array<{
93
+ autoIncrement: boolean;
94
+ indexes: Array<{
95
+ keyPath: string | string[] | null;
96
+ multiEntry: boolean;
97
+ name: string;
98
+ unique: boolean;
99
+ }>;
100
+ keyPath: string | string[] | null;
101
+ name: string;
102
+ rows: Array<{
103
+ key: unknown;
104
+ value: unknown;
105
+ }>;
106
+ }>;
107
+ version: number;
108
+ };
109
+ declare class IndexedDbAsyncStorageDriver implements AsyncStorageDriver {
110
+ #private;
111
+ debugLogger?: TSDFDebugLogger;
112
+ readonly __tsdfManagedStorage: Required<Pick<AsyncStorageManagedDriverCapabilities, 'applyManagedCommit' | 'clearManagedNamespace' | 'listManagedKeys' | 'listManagedMetadata' | 'persistNamespaceIndexState' | 'readProtectedStorageKeys' | 'readManagedEntries' | 'readNamespaceIndexState' | 'syncSessionProtectedKeys'>>;
113
+ readonly databaseName: string;
114
+ constructor(databaseName?: string, instrumentation?: IndexedDbDriverInstrumentation | undefined);
115
+ get(scope: AsyncStorageNamespaceScope, key: string): Promise<unknown>;
116
+ set(scope: AsyncStorageNamespaceScope, key: string, value: unknown): Promise<void>;
117
+ remove(scope: AsyncStorageNamespaceScope, key: string): Promise<void>;
118
+ getMany(scope: AsyncStorageNamespaceScope, keys: string[]): Promise<unknown[]>;
119
+ setMany(scope: AsyncStorageNamespaceScope, entries: AsyncStorageDriverSetEntry[]): Promise<void>;
120
+ removeMany(scope: AsyncStorageNamespaceScope, keys: string[]): Promise<void>;
121
+ listKeys(scope: AsyncStorageNamespaceScope): Promise<string[]>;
122
+ clear(scope: AsyncStorageNamespaceScope): Promise<void>;
123
+ listScopes(sessionKey?: string): Promise<AsyncStorageNamespaceScope[]>;
124
+ listScopesWithKnownRecordKeys(sessionKey?: string): Promise<AsyncStorageDiscoveredScope[]>;
125
+ readManagedEntries<TValue>(scope: AsyncStorageNamespaceScope, keys: string[]): Promise<Map<string, AsyncStorageNamespaceGetResult<TValue, Record<string, unknown>> | null>>;
126
+ listManagedMetadata(scope: AsyncStorageNamespaceScope, args?: {
127
+ filter?: IndexedDbManagedMetadataFilter;
128
+ order?: AsyncStorageMetadataOrder;
129
+ }): Promise<AsyncStorageEntryMetadata<Record<string, unknown>>[]>;
130
+ listManagedKeys(scope: AsyncStorageNamespaceScope): Promise<string[]>;
131
+ clearManagedNamespace(scope: AsyncStorageNamespaceScope): Promise<void>;
132
+ applyManagedCommit(scope: AsyncStorageNamespaceScope, args: ManagedAsyncStorageNamespaceCommitArgs<unknown, Record<string, unknown>>, helpers: {
133
+ mergeOfflineProtectionMetadata: (key: string, nextCustomMetadata: Record<string, unknown> | undefined, currentCustomMetadata: Record<string, unknown> | undefined) => Record<string, unknown> | undefined;
134
+ }): Promise<ReadonlySet<string>>;
135
+ readNamespaceIndexState(scope: AsyncStorageNamespaceScope, knownRecordKeys_?: string[] | null): Promise<IndexedDbManagedIndexState>;
136
+ persistNamespaceIndexState(scope: AsyncStorageNamespaceScope, state: {
137
+ entries: Map<string, IndexedDbManagedMetadataRecord>;
138
+ staticPolicy: AsyncStorageNamespaceStaticPolicy | null;
139
+ }): Promise<void>;
140
+ readProtectedStorageKeys(sessionKey: string): Promise<string[]>;
141
+ syncSessionProtectedKeys(sessionKey: string, protectedKeys: Iterable<string>): Promise<void>;
142
+ readMaintenanceState(): Promise<{
143
+ lastSuccessfulCleanupAt: number | null;
144
+ }>;
145
+ writeMaintenanceState(value: {
146
+ lastSuccessfulCleanupAt: number | null;
147
+ }): Promise<void>;
148
+ __resetForTests(): Promise<void>;
149
+ __inspectStructureForTests(): Promise<IndexedDbStructureInspection>;
150
+ }
151
+ /** Options for creating the IndexedDB persistent storage adapter. */
152
+ export type IndexedDbPersistentStorageOptions = {
153
+ /** IndexedDB database name used by the adapter. */
154
+ databaseName?: string;
155
+ };
156
+ export declare function createIndexedDbPersistentStorage(options?: IndexedDbPersistentStorageOptions): AsyncStorageAdapter;
157
+ type IndexedDbPersistentStorageInternalOptions = IndexedDbPersistentStorageOptions & {
158
+ instrumentation?: IndexedDbDriverInstrumentation;
159
+ };
160
+ export declare function createIndexedDbPersistentStorageForTests(options?: IndexedDbPersistentStorageInternalOptions): {
161
+ adapter: AsyncStorageAdapter;
162
+ driver: IndexedDbAsyncStorageDriver;
163
+ };
164
+ export type IndexedDbPersistentStorageOperation = IndexedDbTestOperation;
165
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type IndexedDbPersistentStorageOptions as IndexedDbPersistentStorageOptionsInternal } from './indexedDbAsyncStorageAdapter';
2
+ import type { AsyncStorageAdapter } from './types';
3
+ export declare const indexedDbPersistentStorage: AsyncStorageAdapter;
4
+ /** Options for creating the IndexedDB persistent storage adapter. */
5
+ export type IndexedDbPersistentStorageOptions = IndexedDbPersistentStorageOptionsInternal;
6
+ export declare function createIndexedDbPersistentStorage(options?: IndexedDbPersistentStorageOptions): AsyncStorageAdapter;
@@ -0,0 +1,37 @@
1
+ import { type __LEGIT_ANY__ } from '@ls-stack/utils/saferTyping';
2
+ import type { Store } from 't-state';
3
+ import type { ItemLoadedFields, TSDFItemQuery, TSFDListQuery, TSFDListQueryState } from '../listQueryStore/types';
4
+ import { type ValidPayload, type ValidStoreState } from '../utils/storeShared';
5
+ import type { AnyOfflineOperationDefinition, ListQueryOfflineEntityRef } from './offline/types';
6
+ import type { ResolvedListQueryPersistentStorageConfig } from './types';
7
+ type ListQueryPersistenceOfflineOperations<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = (Record<string, AnyOfflineOperationDefinition & {
8
+ getEntityRefs: (ctx: {
9
+ input: __LEGIT_ANY__;
10
+ }) => ListQueryOfflineEntityRef<ItemPayload>[];
11
+ }> & ([ItemState | QueryPayload | ItemPayload] extends [never] ? never : unknown)) | null;
12
+ type ListQueryPersistenceSetup<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
13
+ createInitialState(baseState: TSFDListQueryState<ItemState, QueryPayload, ItemPayload>): TSFDListQueryState<ItemState, QueryPayload, ItemPayload>;
14
+ attach(store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>): void;
15
+ maybeHydrateItems(itemKeys: string[]): Promise<boolean[]>;
16
+ maybeHydrateQueries(queryKeys: string[]): Promise<boolean[]>;
17
+ preloadItems(itemKeys: string[]): Promise<boolean[]>;
18
+ preloadQueries(queryKeys: string[]): Promise<boolean[]>;
19
+ preloadItemsByDerivedQueryGroup(groupKeys: string[]): Promise<boolean[]>;
20
+ getHydratedItemKeys(this: void): string[];
21
+ getHydratedQueryKeys(this: void): string[];
22
+ readHydratedItem(this: void, itemKey: string): {
23
+ item: ItemState;
24
+ itemQuery: TSDFItemQuery<ItemPayload>;
25
+ loadedFields: ItemLoadedFields | undefined;
26
+ } | undefined;
27
+ readHydratedQuery(this: void, queryKey: string): TSFDListQuery<QueryPayload> | undefined;
28
+ hasAsyncPreload: boolean;
29
+ dispose(): void;
30
+ clear(): Promise<void>;
31
+ };
32
+ export declare function setupListQueryPersistence<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, TOfflineOperations extends ListQueryPersistenceOfflineOperations<ItemState, QueryPayload, ItemPayload> = null, StorageState = unknown>(config: ResolvedListQueryPersistentStorageConfig<ItemState, QueryPayload, ItemPayload, StorageState, TOfflineOperations>, options?: {
33
+ getItemKey?: (payload: ItemPayload) => string;
34
+ getQueryKey?: (payload: QueryPayload) => string;
35
+ getItemDerivedGroup?: (item: ItemState, itemPayload: ItemPayload) => string;
36
+ }): ListQueryPersistenceSetup<ItemState, QueryPayload, ItemPayload>;
37
+ export {};
@@ -0,0 +1,126 @@
1
+ import type { IdleCleanupContext } from './scheduleIdleCleanup';
2
+ type ManagedLocalStorageMaintenanceCallback = (context?: IdleCleanupContext) => Promise<void>;
3
+ type ManagedLocalStorageRuntimeConfig = {
4
+ cleanupIntervalMs: number;
5
+ maxAgeMs: number;
6
+ };
7
+ export declare function addManagedLocalStorageMutationListener(listener: (key: string) => void): () => void;
8
+ export type ManagedLocalStorageIo = {
9
+ invalidate?(key: string): void;
10
+ getItem(key: string): string | null;
11
+ setItem(key: string, value: string): void;
12
+ removeItem(key: string): void;
13
+ listKeys(): string[];
14
+ queueManifestWrite?(key: string, value: string | null): void;
15
+ };
16
+ export declare const directManagedLocalStorageIo: ManagedLocalStorageIo;
17
+ /**
18
+ * True after a `QuotaExceededError` recovery failed even with all unprotected
19
+ * TSDF entries evicted. Persistence writes are silently dropped for the rest
20
+ * of the page lifetime so a full origin quota does not produce an error on
21
+ * every subsequent flush.
22
+ */
23
+ export declare function isLocalStorageQuotaWritesDisabled(): boolean;
24
+ /**
25
+ * Runs a locked `localStorage` mutation while tracking every key it writes,
26
+ * so a quota recovery triggered mid-mutation never evicts them.
27
+ */
28
+ export declare function trackManagedLocalStorageMutationWrites<T>(callback: () => T | Promise<T>): Promise<T>;
29
+ export declare function takePendingQuotaWritesDisabledError(): unknown;
30
+ /**
31
+ * Error sink for background persistence work (idle flushes, scheduled
32
+ * removals) that has no caller to propagate errors to. The terminal
33
+ * quota-disable error is stashed for later delivery through
34
+ * `onPersistentStorageError`; anything else is only logged, since a dropped
35
+ * background write self-heals via maintenance sweeps.
36
+ */
37
+ export declare function handleManagedLocalStorageBackgroundError(error: unknown): void;
38
+ /**
39
+ * Writes to `localStorage`, recovering from `QuotaExceededError` by evicting
40
+ * TSDF-managed entries: first the least recently used half of the evictable
41
+ * bytes, then everything unprotected. If the write still fails, persistence
42
+ * writes are disabled for the rest of the page lifetime and a descriptive
43
+ * error is thrown once so it reaches `onPersistentStorageError`.
44
+ *
45
+ * Returns whether the value was written (false when writes are disabled).
46
+ */
47
+ export declare function setManagedLocalStorageItemWithQuotaRecovery(key: string, value: string, io: ManagedLocalStorageIo): boolean;
48
+ export declare function getManagedLocalStorageRuntimeConfig(): ManagedLocalStorageRuntimeConfig;
49
+ export declare function setManagedLocalStorageRuntimeConfigForTests(nextConfig: Partial<ManagedLocalStorageRuntimeConfig>): void;
50
+ export declare function getManagedLocalStorageManifestKeyForSingle(storageKey: string): string;
51
+ export declare function getManagedLocalStorageManifestKeyForPrefix(storagePrefix: string): string;
52
+ type StoredManagedLocalStorageManifestEntry = {
53
+ entryKey: string | undefined;
54
+ lastAccessAt: number;
55
+ sizeBytes?: number;
56
+ meta?: unknown;
57
+ };
58
+ type ManagedLocalStorageManifestEntry<TMeta = unknown> = {
59
+ entryKey: string | undefined;
60
+ payloadKey: string;
61
+ lastAccessAt: number;
62
+ sizeBytes?: number;
63
+ meta?: TMeta;
64
+ };
65
+ export declare function listManagedLocalStorageKeysSync(prefix: string, io?: ManagedLocalStorageIo): string[] | null;
66
+ type ManagedLocalStorageNamespaceManifestEntry<TMeta = unknown> = ManagedLocalStorageManifestEntry<TMeta> & {
67
+ entryKey: string;
68
+ };
69
+ export declare function readManagedLocalStorageManifestEntriesByPrefix(prefix: string, io?: ManagedLocalStorageIo): ManagedLocalStorageNamespaceManifestEntry[];
70
+ export declare function readManagedLocalStorageSingleEntryByPayload(payloadKey: string, io?: ManagedLocalStorageIo): ManagedLocalStorageManifestEntry | null;
71
+ export declare function readManagedLocalStorageNamespaceEntryByPayload(payloadKey: string, storagePrefix: string, io?: ManagedLocalStorageIo): ManagedLocalStorageManifestEntry | null;
72
+ export declare function isManagedLocalStorageEntryOfflineProtected(meta: unknown): boolean;
73
+ export declare function setManagedLocalStorageEntryOfflineProtected(meta: unknown, offlineProtected: boolean): unknown;
74
+ export declare function readManagedLocalStorageProtectedKeys(sessionKey: string, io?: ManagedLocalStorageIo): Set<string>;
75
+ export declare function syncManagedLocalStorageSessionProtection(sessionKey: string, protectedKeys: Iterable<string>, io?: ManagedLocalStorageIo): void;
76
+ type UpsertSingleEntryParams = {
77
+ storageKey: string;
78
+ lastAccessAt?: number;
79
+ clearSizeBytes?: boolean;
80
+ sizeBytes?: number;
81
+ mergeMeta?: (currentMeta: StoredManagedLocalStorageManifestEntry['meta']) => unknown;
82
+ meta?: unknown;
83
+ };
84
+ export declare function upsertManagedLocalStorageSingleEntry(params: UpsertSingleEntryParams, io?: ManagedLocalStorageIo): string;
85
+ type UpsertNamespaceEntryParams = {
86
+ storagePrefix: string;
87
+ entryKey: string;
88
+ lastAccessAt?: number;
89
+ sizeBytes?: number;
90
+ mergeMeta?: (currentMeta: StoredManagedLocalStorageManifestEntry['meta']) => unknown;
91
+ meta?: unknown;
92
+ };
93
+ export declare function upsertManagedLocalStorageNamespaceEntry(params: UpsertNamespaceEntryParams, io?: ManagedLocalStorageIo): string;
94
+ export declare function touchManagedLocalStorageNamespacePayload(payloadKey: string, storagePrefix: string, io?: ManagedLocalStorageIo): boolean;
95
+ export declare function touchManagedLocalStorageSinglePayload(payloadKey: string, io?: ManagedLocalStorageIo): boolean;
96
+ export declare function removeManagedLocalStorageNamespacePayload(payloadKey: string, storagePrefix: string, io?: ManagedLocalStorageIo): boolean;
97
+ export type ManagedLocalStorageNamespaceRemovalCandidate = {
98
+ entryKey: string;
99
+ lastAccessAt: number;
100
+ offlineProtected: boolean;
101
+ };
102
+ export type ManagedLocalStorageNamespaceRemovalResult = {
103
+ processedCount: number;
104
+ removedEntryKeys: string[];
105
+ staleEntryKeys: string[];
106
+ };
107
+ /**
108
+ * Removes a deadline-bounded batch from one namespace and rewrites its
109
+ * manifest once. The access timestamp is an optimistic concurrency token: a
110
+ * payload refreshed between maintenance slices is left untouched and can be
111
+ * reconsidered by a later pass.
112
+ */
113
+ export declare function removeManagedLocalStorageNamespaceEntriesIfUnchanged(storagePrefix: string, candidates: ManagedLocalStorageNamespaceRemovalCandidate[], candidateIndex: number, shouldYield: () => boolean, io?: ManagedLocalStorageIo): ManagedLocalStorageNamespaceRemovalResult;
114
+ export declare function removeManagedLocalStorageSinglePayload(payloadKey: string, io?: ManagedLocalStorageIo): boolean;
115
+ export declare function clearManagedLocalStorageManifest(manifestKey: string, io?: ManagedLocalStorageIo): void;
116
+ export declare function clearManagedLocalStorageSession(sessionKey: string, io?: ManagedLocalStorageIo): void;
117
+ export declare function registerManagedLocalStorageMaintenanceCallback(manifestKey: string, callback: ManagedLocalStorageMaintenanceCallback): void;
118
+ export declare function unregisterManagedLocalStorageMaintenanceCallback(manifestKey: string): void;
119
+ type RunManagedLocalStorageLocked = <T>(callback: (io: ManagedLocalStorageIo) => T | Promise<T>) => Promise<T>;
120
+ export declare function runManagedLocalStorageMaintenance({ context, forceManifestKeys, runLocked }: {
121
+ context: IdleCleanupContext;
122
+ forceManifestKeys?: Iterable<string>;
123
+ runLocked: RunManagedLocalStorageLocked;
124
+ }): Promise<void>;
125
+ export declare function resetManagedLocalStorageState(): void;
126
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare function getNavigatorLockManager(): LockManager | null;
2
+ export declare function warnIfNavigatorLockUnavailable(warning: string): void;
3
+ export declare function runWithNavigatorLock<T>(lockName: string, unavailableWarning: string, callback: () => T | Promise<T>): Promise<T>;
@@ -0,0 +1,12 @@
1
+ import type { GlobalOfflineEntity } from './types';
2
+ export declare function createOfflineEntityLookup(entities: readonly GlobalOfflineEntity[]): ReadonlyMap<string, GlobalOfflineEntity>;
3
+ export declare function getIsPendingOfflineSync(entity: GlobalOfflineEntity | null | undefined): boolean;
4
+ export declare function hasPendingOfflineSync(entitiesByKey: ReadonlyMap<string, GlobalOfflineEntity>, entityKeys: readonly string[]): boolean;
5
+ export declare function shouldApplyOfflineOverlay(entity: GlobalOfflineEntity | null | undefined, overlay: unknown): boolean;
6
+ /**
7
+ * Batch-filters offline overlays to only include entries with a pending sync
8
+ * (entity exists and does not require resolution). Use this instead of calling
9
+ * {@link getActiveOfflineOverlay} per item when all active overlays are needed
10
+ * at once.
11
+ */
12
+ export declare function filterActiveOfflineOverlays<Overlay>(entitiesByKey: ReadonlyMap<string, GlobalOfflineEntity>, overlays: Readonly<Record<string, Overlay>>): Record<string, Overlay>;
@@ -0,0 +1,35 @@
1
+ import type { StoreError } from '../../utils/storeShared';
2
+ import { type MaybeTSDFResult } from '../../utils/storeShared';
3
+ export declare const offlineConnectivityError: {
4
+ readonly code: 0;
5
+ readonly id: "offline";
6
+ readonly message: "Offline";
7
+ };
8
+ export declare function normalizeFetchResultError(fetchResult: {
9
+ offline: true;
10
+ } | {
11
+ offline: false;
12
+ error: unknown;
13
+ }, errorNormalizer: (error: Error) => StoreError): StoreError;
14
+ export type OfflineAwareFetchController = {
15
+ prepareForFetch?: () => Promise<void>;
16
+ getSessionStatus: () => {
17
+ isOfflineMode: boolean;
18
+ } | null;
19
+ shouldTreatFetchAsOffline?: () => boolean;
20
+ handleFetchSuccess?: () => Promise<void>;
21
+ evaluateOfflineFetchError: (error: unknown, operationName?: string) => Promise<void>;
22
+ };
23
+ type OfflineAwareFetchResult<T> = {
24
+ ok: true;
25
+ data: T;
26
+ } | {
27
+ ok: false;
28
+ offline: true;
29
+ } | {
30
+ ok: false;
31
+ offline: false;
32
+ error: unknown;
33
+ };
34
+ export declare function runOfflineAwareFetch<T>(controller: OfflineAwareFetchController | null | undefined, fetcher: () => Promise<MaybeTSDFResult<T>>, operationName?: string): Promise<OfflineAwareFetchResult<T>>;
35
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { OfflineMutationUploadsInput } from '../offlineUploadTypes';
2
+ import type { OfflineMutationInput, OfflineOperationSchemaShape } from './types';
3
+ /**
4
+ * Successful result of an offline-enabled mutation attempt.
5
+ *
6
+ * `online` means the direct request completed and returned the server payload.
7
+ * `queued` means the mutation was durably persisted for offline replay.
8
+ */
9
+ export type OfflineMutationResult<T> = {
10
+ /** The direct online mutation completed successfully. */
11
+ kind: 'online';
12
+ /** Server payload returned by the direct mutation. */
13
+ data: Awaited<T>;
14
+ } | {
15
+ /** The mutation was durably queued for offline replay. */
16
+ kind: 'queued';
17
+ };
18
+ export type PreparedOfflineMutation = {
19
+ initialAction: 'run' | 'queue';
20
+ queueMutation: () => Promise<void>;
21
+ classifyError: (error: unknown) => Promise<boolean>;
22
+ handleDirectSuccess: () => Promise<void>;
23
+ };
24
+ export type OfflineAwareMutationController<TOperations extends Record<string, OfflineOperationSchemaShape>> = {
25
+ canQueueMutation: () => boolean;
26
+ prepareForMutation: <TName extends keyof TOperations & string>(args: {
27
+ offline: OfflineMutationInput<TOperations, TName>;
28
+ upload?: OfflineMutationUploadsInput;
29
+ }) => Promise<PreparedOfflineMutation>;
30
+ };
31
+ export declare function runHybridOfflineMutation<T, TOperations extends Record<string, OfflineOperationSchemaShape>, TName extends keyof TOperations & string>(controller: OfflineAwareMutationController<TOperations> | null | undefined, offline: OfflineMutationInput<TOperations, TName> | undefined, upload: OfflineMutationUploadsInput | undefined, directMutation: () => Promise<T>): Promise<OfflineMutationResult<T>>;
@@ -0,0 +1,13 @@
1
+ import { Store } from 't-state';
2
+ type OverlayWithVisibilityFlag = {
3
+ keepVisibleWhileResolutionRequired?: boolean;
4
+ };
5
+ export declare function rebindOfflineOverlayEntries<TOverlay extends OverlayWithVisibilityFlag>(overlayStore: Store<Record<string, TOverlay>>, itemKeyRewrites: readonly {
6
+ nextItemKey: string;
7
+ previousItemKey: string;
8
+ }[], createReboundOverlay: (params: {
9
+ existingOverlay: TOverlay;
10
+ nextItemKey: string;
11
+ }) => TOverlay): void;
12
+ export declare function captureOfflineOverlayEntries<TOverlay extends OverlayWithVisibilityFlag>(overlayStore: Store<Record<string, TOverlay>>, itemKeys: readonly string[], createOverlay: (itemKey: string) => TOverlay): void;
13
+ export {};