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
@@ -1,2 +1,2 @@
1
- import { t as createAsyncStorageAdapter } from "./asyncStorageAdapter-DgsuE-T8.js";
1
+ import { t as createAsyncStorageAdapter } from "./asyncStorageAdapter-CMohMeKm.js";
2
2
  export { createAsyncStorageAdapter };
@@ -1,2 +1,2 @@
1
- import { i as createAsyncStorageAdapter } from "./asyncStorageAdapter-URS9eulL.js";
1
+ import { i as createAsyncStorageAdapter } from "./asyncStorageAdapter-BuGjbXYA.js";
2
2
  export { createAsyncStorageAdapter };
@@ -1,9 +1,8 @@
1
- import { filterAndMap } from "@ls-stack/utils/arrayUtils";
2
- import { deepEqual } from "@ls-stack/utils/deepEqual";
3
1
  import { __LEGIT_CAST__ } from "@ls-stack/utils/saferTyping";
4
2
  import { klona } from "klona/json";
5
3
  import { isObject } from "@ls-stack/utils/typeGuards";
6
4
  import { createCache } from "@ls-stack/utils/cache";
5
+ import { deepEqual } from "@ls-stack/utils/deepEqual";
7
6
  import { sleep } from "@ls-stack/utils/sleep";
8
7
  import { rc_array, rc_discriminated_union, rc_literals, rc_number, rc_object, rc_parse, rc_parse_json, rc_record, rc_string, rc_tuple, rc_unknown } from "runcheck";
9
8
  import { asPossiblyUndefined } from "@ls-stack/utils/typingFnUtils";
@@ -193,10 +192,6 @@ function compareMetadata(left, right, order) {
193
192
  if (left.lastAccessAt !== right.lastAccessAt) return order === "lru-asc" ? left.lastAccessAt - right.lastAccessAt : right.lastAccessAt - left.lastAccessAt;
194
193
  return left.key.localeCompare(right.key);
195
194
  }
196
- /** Whether an entry still has the metadata a conditional remove expects. */
197
- function matchesConditionalRemove(remove, lastAccessAt, sizeBytes, version, offlineProtected) {
198
- return remove.lastAccessAt === lastAccessAt && remove.sizeBytes === sizeBytes && remove.version === version && remove.offlineProtected === offlineProtected;
199
- }
200
195
  //#endregion
201
196
  //#region src/persistentStorage/compactLocalStorageEntry.ts
202
197
  function createCompactLocalStorageEntry(value, version) {
@@ -415,41 +410,6 @@ function serializeJsonForStorage(value) {
415
410
  sizeBytes: getSerializedStringSize(rawValue)
416
411
  };
417
412
  }
418
- /**
419
- * Removes planned async maintenance entries in bounded batches. Each batch is
420
- * a conditional remove, so entries other code or tabs changed since planning
421
- * are kept as stale in the same write instead of being deleted through an
422
- * outdated plan. The plan itself is never restarted, so every deadline makes
423
- * progress. `shouldContinue` is checked around every batch so a plan never
424
- * outlives the session it was built for; `onRemoved` only runs while it holds.
425
- */
426
- async function removeAsyncMaintenanceEntriesIfUnchanged(plannedEntries, isOfflineProtected, removeIfUnchanged, onRemoved, batchSize, shouldContinue, idleContext) {
427
- let hasStaleEntries = false;
428
- for (let batchStart = 0; batchStart < plannedEntries.length; batchStart += batchSize) {
429
- if (!await idleContext.yieldIfNeeded() || !shouldContinue()) return {
430
- completed: false,
431
- hasStaleEntries
432
- };
433
- const batch = plannedEntries.slice(batchStart, batchStart + batchSize).map((entry) => ({
434
- key: entry.key,
435
- lastAccessAt: entry.lastAccessAt,
436
- sizeBytes: entry.sizeBytes,
437
- version: entry.version,
438
- offlineProtected: isOfflineProtected(entry.customMetadata)
439
- }));
440
- const staleKeys = await removeIfUnchanged(batch);
441
- if (staleKeys === null || idleContext.isCanceled() || !shouldContinue()) return {
442
- completed: false,
443
- hasStaleEntries
444
- };
445
- if (staleKeys.size > 0) hasStaleEntries = true;
446
- onRemoved(filterAndMap(batch, ({ key }) => staleKeys.has(key) ? false : key));
447
- }
448
- return {
449
- completed: true,
450
- hasStaleEntries
451
- };
452
- }
453
413
  function keepEntriesWithinByteBudget(entries, getKey, getLastAccessAt, getSizeBytes, isPinned, isProtected, maxBytes) {
454
414
  const keptKeys = /* @__PURE__ */ new Set();
455
415
  let unprotectedBytes = 0;
@@ -498,7 +458,7 @@ function keepEntriesWithinByteBudget(entries, getKey, getLastAccessAt, getSizeBy
498
458
  unprotectedBytes
499
459
  };
500
460
  }
501
- /** Deadline-aware variant used by background storage maintenance. */
461
+ /** Deadline-aware variant used by synchronous localStorage maintenance. */
502
462
  async function keepEntriesWithinByteBudgetDuringIdle(entries, getKey, getLastAccessAt, getSizeBytes, isPinned, isProtected, maxBytes, idleContext) {
503
463
  const keptKeys = /* @__PURE__ */ new Set();
504
464
  let unprotectedBytes = 0;
@@ -710,12 +670,12 @@ function getRecord(value) {
710
670
  if (!isObject(value)) return null;
711
671
  return value;
712
672
  }
713
- function isAsyncStorageMetadataOfflineProtected(customMetadata) {
673
+ function isOfflineProtectedMetadata(customMetadata) {
714
674
  return customMetadata?.o === true;
715
675
  }
716
676
  function getProtectedKeysFromMetadata(entries) {
717
677
  const keys = /* @__PURE__ */ new Set();
718
- for (const entry of entries) if (isAsyncStorageMetadataOfflineProtected(entry.customMetadata)) keys.add(entry.key);
678
+ for (const entry of entries) if (isOfflineProtectedMetadata(entry.customMetadata)) keys.add(entry.key);
719
679
  return keys;
720
680
  }
721
681
  function isSessionOfflineInLocalStorage(sessionKey) {
@@ -743,8 +703,8 @@ function mergeManagedAsyncStorageCustomMetadata(currentCustomMetadata, nextCusto
743
703
  if (protectedKeysSnapshotSet !== null) return setOfflineProtectionMetadata(mergedCustomMetadata, protectedKeysSnapshotSet?.has(serializeProtectedRef({
744
704
  ...scope,
745
705
  key
746
- })) === true || isAsyncStorageMetadataOfflineProtected(nextCustomMetadata) || isAsyncStorageMetadataOfflineProtected(currentCustomMetadata));
747
- return setOfflineProtectionMetadata(mergedCustomMetadata, isAsyncStorageMetadataOfflineProtected(nextCustomMetadata) || isAsyncStorageMetadataOfflineProtected(currentCustomMetadata));
706
+ })) === true || isOfflineProtectedMetadata(nextCustomMetadata) || isOfflineProtectedMetadata(currentCustomMetadata));
707
+ return setOfflineProtectionMetadata(mergedCustomMetadata, isOfflineProtectedMetadata(nextCustomMetadata) || isOfflineProtectedMetadata(currentCustomMetadata));
748
708
  }
749
709
  const ASYNC_METADATA_LAST_ACCESS_AT_KEY = "a";
750
710
  const ASYNC_METADATA_VERSION_KEY = "v";
@@ -1073,8 +1033,8 @@ var ManagedAsyncStorageNamespaceHandle = class {
1073
1033
  })) }).catch(() => {});
1074
1034
  return keys.map((key) => entryByKey.get(key) ?? null);
1075
1035
  }
1076
- async commit(args) {
1077
- await this.#adapter.queueCommitToNamespace(this.#scope, args);
1036
+ commit(args) {
1037
+ return this.#adapter.queueCommitToNamespace(this.#scope, args);
1078
1038
  }
1079
1039
  async listKeys() {
1080
1040
  await this.#adapter.flushPendingNamespaceCommit(this.#scope);
@@ -1152,7 +1112,7 @@ var ManagedAsyncStorageAdapter = class {
1152
1112
  await this.#runWithSessionWriterLock(sessionKey, async () => {
1153
1113
  await this.#flushPendingNamespaceCommitsForSessionUnlocked(sessionKey);
1154
1114
  const scopesToClear = await this.#listDiscoveredScopes(sessionKey);
1155
- await Promise.all(scopesToClear.map((scope) => this.#clearManagedNamespaceUnlocked(scope, false)));
1115
+ await Promise.all(scopesToClear.map((scope) => this.#clearManagedNamespaceUnlocked(scope)));
1156
1116
  });
1157
1117
  }
1158
1118
  async readProtectedStorageKeys(sessionKey, driver = this.#driver) {
@@ -1167,7 +1127,7 @@ var ManagedAsyncStorageAdapter = class {
1167
1127
  order: "key"
1168
1128
  });
1169
1129
  const refs = [];
1170
- for (const entry of metadataEntries) if (isAsyncStorageMetadataOfflineProtected(entry.customMetadata)) refs.push(serializeProtectedRef({
1130
+ for (const entry of metadataEntries) if (isOfflineProtectedMetadata(entry.customMetadata)) refs.push(serializeProtectedRef({
1171
1131
  ...scope,
1172
1132
  key: entry.key
1173
1133
  }));
@@ -1218,7 +1178,7 @@ var ManagedAsyncStorageAdapter = class {
1218
1178
  for (const [key, shouldProtect] of protectionByKey.entries()) {
1219
1179
  const existingMetadata = indexEntries.get(key);
1220
1180
  if (existingMetadata === void 0) continue;
1221
- if (isAsyncStorageMetadataOfflineProtected(existingMetadata.customMetadata) === shouldProtect) continue;
1181
+ if (isOfflineProtectedMetadata(existingMetadata.customMetadata) === shouldProtect) continue;
1222
1182
  const nextCustomMetadata = setOfflineProtectionMetadata(existingMetadata.customMetadata, shouldProtect);
1223
1183
  const nextMetadata = { ...existingMetadata };
1224
1184
  if (nextCustomMetadata !== void 0) nextMetadata.customMetadata = nextCustomMetadata;
@@ -1261,37 +1221,23 @@ var ManagedAsyncStorageAdapter = class {
1261
1221
  }
1262
1222
  #hasPendingBarrierForKeys(pending, keys) {
1263
1223
  return keys.some((key) => {
1264
- return pending.upserts.has(key) || pending.removes.has(key) || pending.conditionalRemoves.has(key) || pending.inFlightBarrierKeys?.has(key) === true;
1224
+ return pending.upserts.has(key) || pending.removes.has(key) || pending.inFlightBarrierKeys?.has(key) === true;
1265
1225
  });
1266
1226
  }
1267
- /** Resolves with the `conditionalRemoves` keys kept because they changed. */
1268
1227
  async queueCommitToNamespace(scope, args) {
1269
1228
  const pending = this.#getOrCreatePendingNamespaceCommit(scope);
1270
1229
  const now = Date.now();
1271
- for (const touch of args.touches ?? []) {
1272
- this.#cancelPendingConditionalRemove(pending, touch.key);
1273
- pending.touches.set(touch.key, touch.lastAccessAt ?? now);
1274
- }
1230
+ for (const touch of args.touches ?? []) pending.touches.set(touch.key, touch.lastAccessAt ?? now);
1275
1231
  for (const remove of args.removes ?? []) {
1276
1232
  pending.upserts.delete(remove);
1277
1233
  pending.touches.delete(remove);
1278
- pending.conditionalRemoves.delete(remove);
1279
1234
  pending.removes.add(remove);
1280
1235
  }
1281
- for (const remove of args.conditionalRemoves ?? []) {
1282
- if (pending.upserts.has(remove.key) || pending.touches.has(remove.key)) {
1283
- pending.staleConditionalRemoveKeys.add(remove.key);
1284
- continue;
1285
- }
1286
- if (pending.removes.has(remove.key)) continue;
1287
- pending.conditionalRemoves.set(remove.key, remove);
1288
- }
1289
1236
  if ("staticPolicy" in args) {
1290
1237
  pending.hasStaticPolicyUpdate = true;
1291
1238
  pending.staticPolicy = args.staticPolicy ?? null;
1292
1239
  }
1293
1240
  for (const upsert of args.upserts ?? []) {
1294
- this.#cancelPendingConditionalRemove(pending, upsert.key);
1295
1241
  pending.removes.delete(upsert.key);
1296
1242
  pending.upserts.set(upsert.key, __LEGIT_CAST__(upsert));
1297
1243
  }
@@ -1303,19 +1249,6 @@ var ManagedAsyncStorageAdapter = class {
1303
1249
  });
1304
1250
  });
1305
1251
  }
1306
- /** A later write wins over a queued conditional remove of the same key. */
1307
- #cancelPendingConditionalRemove(pending, key) {
1308
- if (pending.conditionalRemoves.delete(key)) pending.staleConditionalRemoveKeys.add(key);
1309
- }
1310
- getMaintenanceRemoveBatchSize() {
1311
- return getManagedDriverCapabilities(this.#driver)?.applyManagedCommit !== void 0 ? PER_KEY_COMMIT_MAINTENANCE_REMOVE_BATCH_SIZE : INDEX_REWRITE_COMMIT_MAINTENANCE_REMOVE_BATCH_SIZE;
1312
- }
1313
- async commitToNamespaceNow(scope, args) {
1314
- const committed = this.queueCommitToNamespace(scope, args);
1315
- const flushed = this.flushPendingNamespaceCommit(scope).then(() => this.flushPendingNamespaceCommit(scope));
1316
- const [staleConditionalRemoveKeys] = await Promise.all([committed, flushed]);
1317
- return staleConditionalRemoveKeys;
1318
- }
1319
1252
  async flushPendingNamespaceCommit(scope, keys) {
1320
1253
  const namespaceKey = getNamespaceId(scope);
1321
1254
  const pending = this.#pendingNamespaceCommits.get(namespaceKey);
@@ -1338,47 +1271,37 @@ var ManagedAsyncStorageAdapter = class {
1338
1271
  pending.cancelFlush = null;
1339
1272
  const upserts = [...pending.upserts.values()];
1340
1273
  const removes = [...pending.removes];
1341
- const conditionalRemoves = [...pending.conditionalRemoves.values()];
1342
- const staleConditionalRemoveKeys = pending.staleConditionalRemoveKeys;
1343
1274
  const hasStaticPolicyUpdate = pending.hasStaticPolicyUpdate;
1344
1275
  const staticPolicy = pending.staticPolicy;
1345
1276
  const touches = [...pending.touches.entries()].map(([key, lastAccessAt]) => ({
1346
1277
  key,
1347
1278
  lastAccessAt
1348
1279
  }));
1349
- const inFlightBarrierKeys = new Set([
1350
- ...pending.upserts.keys(),
1351
- ...pending.removes,
1352
- ...pending.conditionalRemoves.keys()
1353
- ]);
1280
+ const inFlightBarrierKeys = new Set([...pending.upserts.keys(), ...pending.removes]);
1354
1281
  const waiters = [...pending.waiters];
1355
1282
  pending.hasStaticPolicyUpdate = false;
1356
1283
  pending.upserts = /* @__PURE__ */ new Map();
1357
1284
  pending.removes = /* @__PURE__ */ new Set();
1358
- pending.conditionalRemoves = /* @__PURE__ */ new Map();
1359
- pending.staleConditionalRemoveKeys = /* @__PURE__ */ new Set();
1360
1285
  pending.staticPolicy = null;
1361
1286
  pending.touches = /* @__PURE__ */ new Map();
1362
1287
  pending.waiters = [];
1363
1288
  pending.inFlightBarrierKeys = inFlightBarrierKeys.size > 0 ? inFlightBarrierKeys : null;
1364
- if (upserts.length === 0 && removes.length === 0 && conditionalRemoves.length === 0 && touches.length === 0 && !hasStaticPolicyUpdate) {
1289
+ if (upserts.length === 0 && removes.length === 0 && touches.length === 0 && !hasStaticPolicyUpdate) {
1365
1290
  this.#pendingNamespaceCommits.delete(namespaceKey);
1366
- for (const waiter of waiters) waiter.resolve(staleConditionalRemoveKeys);
1291
+ for (const waiter of waiters) waiter.resolve();
1367
1292
  return;
1368
1293
  }
1369
1294
  pending.flushPromise = this.#applyManagedCommit(scope, {
1370
1295
  upserts,
1371
1296
  removes,
1372
- ...conditionalRemoves.length > 0 ? { conditionalRemoves } : {},
1373
1297
  ...hasStaticPolicyUpdate ? { staticPolicy } : {},
1374
1298
  touches
1375
- }).then((committedStaleKeys) => {
1376
- for (const key of committedStaleKeys) staleConditionalRemoveKeys.add(key);
1299
+ }).then(() => {
1377
1300
  const currentBucket = getBucketId(Date.now());
1378
1301
  for (const touch of touches) this.#recentTouchedBuckets.set(`${namespaceKey}::${touch.key}`, getBucketId(touch.lastAccessAt));
1379
1302
  for (const upsert of upserts) this.#recentTouchedBuckets.set(`${namespaceKey}::${upsert.key}`, currentBucket);
1380
1303
  this.#pruneRecentTouchedBuckets(currentBucket);
1381
- for (const waiter of waiters) waiter.resolve(staleConditionalRemoveKeys);
1304
+ for (const waiter of waiters) waiter.resolve();
1382
1305
  }).catch((error) => {
1383
1306
  for (const waiter of waiters) waiter.reject(error);
1384
1307
  throw error;
@@ -1521,16 +1444,10 @@ var ManagedAsyncStorageAdapter = class {
1521
1444
  }
1522
1445
  async clearManagedNamespace(scope) {
1523
1446
  await this.#runWithSessionWriterLock(scope.sessionKey, async () => {
1524
- await this.#clearManagedNamespaceUnlocked(scope, true);
1447
+ await this.#clearManagedNamespaceUnlocked(scope);
1525
1448
  });
1526
1449
  }
1527
- /**
1528
- * Commits still pending here were queued after the clear was requested,
1529
- * because both clear paths flush first. A namespace clear keeps them so
1530
- * they flush once the writer lock is released; a session clear discards
1531
- * them with the session data.
1532
- */
1533
- async #clearManagedNamespaceUnlocked(scope, keepPendingCommits) {
1450
+ async #clearManagedNamespaceUnlocked(scope) {
1534
1451
  const managedCapabilities = getManagedDriverCapabilities(this.#driver);
1535
1452
  if (managedCapabilities?.clearManagedNamespace !== void 0) await managedCapabilities.clearManagedNamespace(scope);
1536
1453
  else await this.#driver.clear(scope);
@@ -1538,13 +1455,7 @@ var ManagedAsyncStorageAdapter = class {
1538
1455
  this.#broadcastNamespaceInvalidation(scope, "clear");
1539
1456
  const namespaceKey = getNamespaceId(scope);
1540
1457
  this.#observedScopes.delete(namespaceKey);
1541
- const pending = this.#pendingNamespaceCommits.get(namespaceKey);
1542
- if (pending && keepPendingCommits) this.#schedulePendingNamespaceFlush(pending);
1543
- else if (pending) {
1544
- this.#pendingNamespaceCommits.delete(namespaceKey);
1545
- pending.cancelFlush?.();
1546
- for (const waiter of pending.waiters) waiter.resolve(pending.staleConditionalRemoveKeys);
1547
- }
1458
+ this.#pendingNamespaceCommits.delete(namespaceKey);
1548
1459
  this.clearRecentTouchedBucketsForNamespace(scope);
1549
1460
  }
1550
1461
  #toPublicMetadata(key, metadata) {
@@ -1558,38 +1469,23 @@ var ManagedAsyncStorageAdapter = class {
1558
1469
  customMetadata: metadata.customMetadata ?? {}
1559
1470
  };
1560
1471
  }
1561
- /** Resolves with the `conditionalRemoves` keys kept because they changed. */
1562
1472
  async #applyManagedCommit(scope, args) {
1563
1473
  const upserts = args.upserts ?? [];
1564
1474
  const removes = [...new Set(args.removes ?? [])];
1565
- const conditionalRemoves = args.conditionalRemoves ?? [];
1566
1475
  const touches = args.touches ?? [];
1567
1476
  const touchedKeys = [...new Set(touches.map((touch) => touch.key))];
1568
1477
  const managedCapabilities = getManagedDriverCapabilities(this.#driver);
1569
1478
  if (managedCapabilities?.applyManagedCommit !== void 0) {
1570
- const reportedStaleKeys = await managedCapabilities.applyManagedCommit(scope, args, { mergeOfflineProtectionMetadata: (key, nextCustomMetadata, currentCustomMetadata) => mergeManagedAsyncStorageCustomMetadata(currentCustomMetadata, nextCustomMetadata, getSessionProtectedKeysSnapshot(scope.sessionKey), scope, key) });
1479
+ await managedCapabilities.applyManagedCommit(scope, args, { mergeOfflineProtectionMetadata: (key, nextCustomMetadata, currentCustomMetadata) => mergeManagedAsyncStorageCustomMetadata(currentCustomMetadata, nextCustomMetadata, getSessionProtectedKeysSnapshot(scope.sessionKey), scope, key) });
1571
1480
  this.#advanceNamespaceReadCacheGeneration(scope);
1572
1481
  this.#invalidateCachedNamespaceIndexState(scope);
1573
1482
  for (const key of removes) this.#invalidateCachedPayloadValue(scope, key);
1574
- for (const { key } of conditionalRemoves) this.#invalidateCachedPayloadValue(scope, key);
1575
1483
  for (const upsert of upserts) this.#setCachedPayloadValue(scope, upsert.key, { value: upsert.value });
1576
1484
  this.#broadcastNamespaceInvalidation(scope, "commit");
1577
- return reportedStaleKeys ?? new Set(conditionalRemoves.map((remove) => remove.key));
1485
+ return;
1578
1486
  }
1579
- if (conditionalRemoves.length > 0) this.#invalidateCachedNamespaceIndexState(scope);
1580
1487
  const currentIndexState = await this.#readNamespaceIndexStateUsingDriver(this.#driver, scope);
1581
1488
  const indexEntries = currentIndexState.valid && currentIndexState.entries !== null ? currentIndexState.entries : /* @__PURE__ */ new Map();
1582
- const staleConditionalRemoveKeys = /* @__PURE__ */ new Set();
1583
- for (const remove of conditionalRemoves) {
1584
- if (!currentIndexState.valid) {
1585
- staleConditionalRemoveKeys.add(remove.key);
1586
- continue;
1587
- }
1588
- const metadata = indexEntries.get(remove.key);
1589
- if (metadata === void 0) continue;
1590
- if (matchesConditionalRemove(remove, metadata.lastAccessAt, metadata.sizeBytes, metadata.version, isAsyncStorageMetadataOfflineProtected(metadata.customMetadata))) removes.push(remove.key);
1591
- else staleConditionalRemoveKeys.add(remove.key);
1592
- }
1593
1489
  const now = Date.now();
1594
1490
  const touchesByKey = new Map(touches.map((touch) => [touch.key, touch.lastAccessAt ?? now]));
1595
1491
  const setEntries = [];
@@ -1657,7 +1553,6 @@ var ManagedAsyncStorageAdapter = class {
1657
1553
  valid: currentIndexState.valid
1658
1554
  });
1659
1555
  this.#broadcastNamespaceInvalidation(scope, "commit");
1660
- return staleConditionalRemoveKeys;
1661
1556
  }
1662
1557
  async #removeManagedKeysUsingDriver(driver, scope, keys) {
1663
1558
  const uniqueKeys = [...new Set(keys)];
@@ -1807,12 +1702,10 @@ var ManagedAsyncStorageAdapter = class {
1807
1702
  const created = {
1808
1703
  scope,
1809
1704
  cancelFlush: null,
1810
- conditionalRemoves: /* @__PURE__ */ new Map(),
1811
1705
  inFlightBarrierKeys: null,
1812
1706
  flushPromise: null,
1813
1707
  hasStaticPolicyUpdate: false,
1814
1708
  removes: /* @__PURE__ */ new Set(),
1815
- staleConditionalRemoveKeys: /* @__PURE__ */ new Set(),
1816
1709
  staticPolicy: null,
1817
1710
  touches: /* @__PURE__ */ new Map(),
1818
1711
  upserts: /* @__PURE__ */ new Map(),
@@ -2109,7 +2002,7 @@ var ManagedAsyncStorageAdapter = class {
2109
2002
  const payloadRecordKeysToRemove = new Set(rawKeysToRemove);
2110
2003
  const candidateEntries = [];
2111
2004
  for (const [key, metadata] of indexState.entries.entries()) {
2112
- const isProtected = isAsyncStorageMetadataOfflineProtected(metadata.customMetadata) || args.protectedRefs?.has(serializeProtectedRef({
2005
+ const isProtected = isOfflineProtectedMetadata(metadata.customMetadata) || args.protectedRefs?.has(serializeProtectedRef({
2113
2006
  ...args.scope,
2114
2007
  key
2115
2008
  })) === true;
@@ -2214,41 +2107,8 @@ var ManagedAsyncStorageAdapter = class {
2214
2107
  function createAsyncStorageAdapter(driver) {
2215
2108
  return new ManagedAsyncStorageAdapter(driver);
2216
2109
  }
2217
- /**
2218
- * Drivers with a per-key managed commit (IndexedDB) keep each maintenance
2219
- * transaction short. Drivers without one rewrite the whole namespace index on
2220
- * every commit, so larger batches avoid repeating that work for every few
2221
- * removals while still bounding concurrent driver requests.
2222
- */
2223
- const PER_KEY_COMMIT_MAINTENANCE_REMOVE_BATCH_SIZE = 25;
2224
- const INDEX_REWRITE_COMMIT_MAINTENANCE_REMOVE_BATCH_SIZE = 250;
2225
- /** Number of keys idle-deadline maintenance removes per commit. */
2226
- function getAsyncStorageMaintenanceRemoveBatchSize(adapter) {
2227
- return adapter instanceof ManagedAsyncStorageAdapter ? adapter.getMaintenanceRemoveBatchSize() : INDEX_REWRITE_COMMIT_MAINTENANCE_REMOVE_BATCH_SIZE;
2228
- }
2229
- /**
2230
- * Removes entries only while they still have the metadata the caller read,
2231
- * without waiting for the namespace batching debounce. Resolves with the keys
2232
- * kept because they changed. Managed adapters check and remove atomically;
2233
- * other adapters only get a best-effort metadata re-read before removing.
2234
- */
2235
- async function removeAsyncStorageNamespaceEntriesIfUnchanged(adapter, scope, entries) {
2236
- if (adapter instanceof ManagedAsyncStorageAdapter) return adapter.commitToNamespaceNow(scope, { conditionalRemoves: entries });
2237
- const namespace = adapter.openNamespace(scope);
2238
- const currentEntries = new Map((await namespace.listMetadata()).map((entry) => [entry.key, entry]));
2239
- const removes = [];
2240
- const staleKeys = /* @__PURE__ */ new Set();
2241
- for (const remove of entries) {
2242
- const current = currentEntries.get(remove.key);
2243
- if (current === void 0) continue;
2244
- if (matchesConditionalRemove(remove, current.lastAccessAt, current.sizeBytes, current.version, isAsyncStorageMetadataOfflineProtected(current.customMetadata))) removes.push(remove.key);
2245
- else staleKeys.add(remove.key);
2246
- }
2247
- if (removes.length > 0) await namespace.commit({ removes });
2248
- return staleKeys;
2249
- }
2250
2110
  function serializeProtectedRef(ref) {
2251
2111
  return serializeProtectedRef$1(ref);
2252
2112
  }
2253
2113
  //#endregion
2254
- export { parseAsyncStorageRecordKey as $, serializeJsonForStorage as A, getSessionProtectedKeysSnapshot as B, createShouldIgnoreItemPredicate as C, keepEntriesWithinByteBudget as D, isQuotaExceededError as E, isModeEffectivelyActive as F, parseCompactLocalStorageEntry as G, getNavigatorLockManager as H, isOfflineModeStatusValue as I, getNamespaceId as J, compareMetadata as K, offlineItemEntityRefSchema as L, compactOfflineStatusSnapshotSchema as M, defaultOfflineRuntimeConfig as N, keepEntriesWithinByteBudgetDuringIdle as O, getIsOfflineModeFromStatus as P, normalizeStaticPolicy as Q, offlineResolutionRecordSchema as R, getDefaultMaxBytesForScope as S, getSerializedStringSize as T, warnIfNavigatorLockUnavailable as U, setSessionProtectedKeysSnapshot as V, createCompactLocalStorageEntry as W, getPersistedNamespaceId as X, getPayloadRecordKey as Y, matchesConditionalRemove as Z, getOfflineSessionStatusStorageKey as _, estimateManagedAsyncStorageEntrySizeBytes as a, getTSDFDebugTimingMs as b, isAsyncStorageMetadataOfflineProtected as c, registerAsyncStartupStoreCleanup as d, parsePersistedAsyncNamespaceKind as et, removeAsyncStorageNamespaceEntriesIfUnchanged as f, OFFLINE_SESSION_STATUS_STORE_NAME as g, parseAsyncStorageNamespaceKind as h, createAsyncStorageAdapter as i, scheduleIdleCleanup as it, OfflineResolutionConflictParseError as j, removeAsyncMaintenanceEntriesIfUnchanged as k, mergeManagedAsyncStorageCustomMetadata as l, unregisterAsyncStartupStoreCleanup as m, ASYNC_STORAGE_MAX_AGE_MS as n, INITIAL_MAINTENANCE_CLEANUP_DELAY_MS as nt, getAsyncStorageMaintenanceRemoveBatchSize as o, serializeProtectedRef as p, encodePersistedAsyncNamespaceKind as q, buildPersistedStaticPolicy as r, createIdleCleanupContext as rt, getProtectedKeysFromMetadata as s, ASYNC_MAINTENANCE_LOCAL_STORAGE_KEY as t, serializeProtectedRef$1 as tt, readAsyncStorageNamespaceIndexStateUsingDriver as u, logPersistentStorageQuotaCleanup as v, createTimedKeySet as w, resolveTSDFLogger as x, emitTSDFDebugLog as y, clearSessionProtectedKeysSnapshot as z };
2114
+ export { scheduleIdleCleanup as $, getIsOfflineModeFromStatus as A, createCompactLocalStorageEntry as B, isQuotaExceededError as C, OfflineResolutionConflictParseError as D, serializeJsonForStorage as E, clearSessionProtectedKeysSnapshot as F, getPayloadRecordKey as G, compareMetadata as H, getSessionProtectedKeysSnapshot as I, parseAsyncStorageRecordKey as J, getPersistedNamespaceId as K, setSessionProtectedKeysSnapshot as L, isOfflineModeStatusValue as M, offlineItemEntityRefSchema as N, compactOfflineStatusSnapshotSchema as O, offlineResolutionRecordSchema as P, createIdleCleanupContext as Q, getNavigatorLockManager as R, getSerializedStringSize as S, keepEntriesWithinByteBudgetDuringIdle as T, encodePersistedAsyncNamespaceKind as U, parseCompactLocalStorageEntry as V, getNamespaceId as W, serializeProtectedRef$1 as X, parsePersistedAsyncNamespaceKind as Y, INITIAL_MAINTENANCE_CLEANUP_DELAY_MS as Z, getTSDFDebugTimingMs as _, estimateManagedAsyncStorageEntrySizeBytes as a, createShouldIgnoreItemPredicate as b, readAsyncStorageNamespaceIndexStateUsingDriver as c, unregisterAsyncStartupStoreCleanup as d, parseAsyncStorageNamespaceKind as f, emitTSDFDebugLog as g, logPersistentStorageQuotaCleanup as h, createAsyncStorageAdapter as i, isModeEffectivelyActive as j, defaultOfflineRuntimeConfig as k, registerAsyncStartupStoreCleanup as l, getOfflineSessionStatusStorageKey as m, ASYNC_STORAGE_MAX_AGE_MS as n, getProtectedKeysFromMetadata as o, OFFLINE_SESSION_STATUS_STORE_NAME as p, normalizeStaticPolicy as q, buildPersistedStaticPolicy as r, mergeManagedAsyncStorageCustomMetadata as s, ASYNC_MAINTENANCE_LOCAL_STORAGE_KEY as t, serializeProtectedRef as u, resolveTSDFLogger as v, keepEntriesWithinByteBudget as w, createTimedKeySet as x, getDefaultMaxBytesForScope as y, warnIfNavigatorLockUnavailable as z };
@@ -1,4 +1,4 @@
1
- import { r as AsyncStorageDriver, t as AsyncStorageAdapter } from "./types-BlyGC_PO.js";
1
+ import { r as AsyncStorageDriver, t as AsyncStorageAdapter } from "./types-D0ttVGmj.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-JsSCNBTr.js";
2
- import { n as indexedDbPersistentStorage } from "./indexedDbPersistentStorage-BameJ4st.js";
1
+ import { t as opfsPersistentStorage } from "./opfsPersistentStorage-D_k77Srq.js";
2
+ import { n as indexedDbPersistentStorage } from "./indexedDbPersistentStorage-BSlgLveB.js";
3
3
  export { indexedDbPersistentStorage, opfsPersistentStorage };
@@ -1,4 +1,4 @@
1
- import { t as AsyncStorageAdapter } from "./types-BlyGC_PO.js";
1
+ import { t as AsyncStorageAdapter } from "./types-D0ttVGmj.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-BameJ4st.js";
1
+ import { n as indexedDbPersistentStorage, t as createIndexedDbPersistentStorage } from "./indexedDbPersistentStorage-BSlgLveB.js";
2
2
  export { createIndexedDbPersistentStorage, indexedDbPersistentStorage };
@@ -1,4 +1,4 @@
1
- import { $ as parseAsyncStorageRecordKey, A as serializeJsonForStorage, J as getNamespaceId, K as compareMetadata, Q as normalizeStaticPolicy, X as getPersistedNamespaceId, Y as getPayloadRecordKey, Z as matchesConditionalRemove, a as estimateManagedAsyncStorageEntrySizeBytes, b as getTSDFDebugTimingMs, et as parsePersistedAsyncNamespaceKind, i as createAsyncStorageAdapter, q as encodePersistedAsyncNamespaceKind, tt as serializeProtectedRef, y as emitTSDFDebugLog } from "./asyncStorageAdapter-URS9eulL.js";
1
+ import { E as serializeJsonForStorage, G as getPayloadRecordKey, H as compareMetadata, J as parseAsyncStorageRecordKey, K as getPersistedNamespaceId, U as encodePersistedAsyncNamespaceKind, W as getNamespaceId, X as serializeProtectedRef, Y as parsePersistedAsyncNamespaceKind, _ as getTSDFDebugTimingMs, a as estimateManagedAsyncStorageEntrySizeBytes, g as emitTSDFDebugLog, i as createAsyncStorageAdapter, q as normalizeStaticPolicy } from "./asyncStorageAdapter-BuGjbXYA.js";
2
2
  import { __LEGIT_CAST__ } from "@ls-stack/utils/saferTyping";
3
3
  import { isObject } from "@ls-stack/utils/typeGuards";
4
4
  //#region src/persistentStorage/indexedDbAsyncStorageAdapter.ts
@@ -508,12 +508,10 @@ var IndexedDbAsyncStorageDriver = class {
508
508
  const policyStore = transaction.objectStore(INDEXED_DB_NAMESPACE_POLICY_STORE);
509
509
  const upserts = args.upserts ?? [];
510
510
  const removes = [...new Set(args.removes ?? [])];
511
- const conditionalRemoves = args.conditionalRemoves ?? [];
512
511
  const touches = args.touches ?? [];
513
512
  const scopeId = createScopeId(scope.sessionKey, scope.storeName, scope.kind);
514
513
  const uniqueKeys = [...new Set([
515
514
  ...removes,
516
- ...conditionalRemoves.map((remove) => remove.key),
517
515
  ...touches.map((touch) => touch.key),
518
516
  ...upserts.map((upsert) => upsert.key)
519
517
  ])];
@@ -526,13 +524,6 @@ var IndexedDbAsyncStorageDriver = class {
526
524
  const record = await openRequestAsPromise(entryStore.get(createEntryPrimaryKey(scope, key)));
527
525
  if (isValidEntryRecord(record)) existingEntries.set(key, toEntryRecordValue(record));
528
526
  }));
529
- const staleConditionalRemoveKeys = /* @__PURE__ */ new Set();
530
- for (const remove of conditionalRemoves) {
531
- const existing = existingEntries.get(remove.key);
532
- if (existing === void 0) continue;
533
- if (matchesConditionalRemove(remove, existing.a, existing.z, existing.v ?? 1, existing.o === 1)) removes.push(remove.key);
534
- else staleConditionalRemoveKeys.add(remove.key);
535
- }
536
527
  for (const key of removes) entryStore.delete(createEntryPrimaryKey(scope, key));
537
528
  const upsertKeySet = new Set(upserts.map((upsert) => upsert.key));
538
529
  for (const upsert of upserts) {
@@ -594,7 +585,6 @@ var IndexedDbAsyncStorageDriver = class {
594
585
  type: "applyManagedCommit",
595
586
  upserts: upserts.map((upsert) => upsert.key).sort((left, right) => left.localeCompare(right))
596
587
  });
597
- return staleConditionalRemoveKeys;
598
588
  }
599
589
  async readNamespaceIndexState(scope, knownRecordKeys_) {
600
590
  const transaction = (await this.#getDatabase()).transaction([INDEXED_DB_ENTRY_STORE, INDEXED_DB_NAMESPACE_POLICY_STORE], "readonly");