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.
- package/dist/async-storage.d.ts +1 -1
- package/dist/async-storage.js +1 -1
- package/dist/{asyncStorageAdapter-URS9eulL.js → asyncStorageAdapter-BuGjbXYA.js} +25 -165
- package/dist/{asyncStorageAdapter-DgsuE-T8.d.ts → asyncStorageAdapter-CMohMeKm.d.ts} +1 -1
- package/dist/{asyncStorageAdapters-Bxrrj_Mt.js → asyncStorageAdapters-ClUvxNQA.js} +2 -2
- package/dist/indexed-db-storage.d.ts +1 -1
- package/dist/indexed-db-storage.js +1 -1
- package/dist/{indexedDbPersistentStorage-BameJ4st.js → indexedDbPersistentStorage-BSlgLveB.js} +1 -11
- package/dist/main.d.ts +30 -34
- package/dist/main.js +257 -856
- package/dist/opfs-storage.d.ts +1 -1
- package/dist/opfs-storage.js +1 -1
- package/dist/{opfsPersistentStorage-BngS1m0X.d.ts → opfsPersistentStorage-Ci0JcCo5.d.ts} +1 -1
- package/dist/{opfsPersistentStorage-JsSCNBTr.js → opfsPersistentStorage-D_k77Srq.js} +1 -1
- package/dist/src/async-storage.d.ts +1 -0
- package/dist/src/cacheLimits/lruCacheRuntime.d.ts +9 -0
- package/dist/src/cacheLimits/scheduleIdleThrottled.d.ts +1 -0
- package/dist/src/cacheLimits/useRegisterActiveKeys.d.ts +1 -0
- package/dist/src/collectionStore/collectionCacheLimits.d.ts +1 -0
- package/dist/src/collectionStore/collectionStore.d.ts +385 -0
- package/dist/src/collectionStore/executeBatchFetch.d.ts +6 -0
- package/dist/src/collectionStore/useItem.d.ts +15 -0
- package/dist/src/collectionStore/useMultipleItems.d.ts +35 -0
- package/dist/src/debug.d.ts +30 -0
- package/dist/src/documentStore.d.ts +290 -0
- package/dist/src/hooks/useListItem.d.ts +22 -0
- package/dist/src/hooks/useListItemIsDeleted.d.ts +13 -0
- package/dist/src/hooks/useListItemIsLoading.d.ts +16 -0
- package/dist/src/indexed-db-storage.d.ts +1 -0
- package/dist/src/internal/offlineTestInstrumentation.d.ts +12 -0
- package/dist/src/internal/testTimelineTypes.d.ts +1 -0
- package/dist/src/invalidationUtils.d.ts +8 -0
- package/dist/src/isOffScreenContext.d.ts +16 -0
- package/dist/src/listQueryStore/createFetchApi.d.ts +1 -0
- package/dist/src/listQueryStore/createMutationApi.d.ts +1 -0
- package/dist/src/listQueryStore/executeItemBatchFetch.d.ts +20 -0
- package/dist/src/listQueryStore/executeQueryFetch.d.ts +7 -0
- package/dist/src/listQueryStore/itemFieldUtils.d.ts +77 -0
- package/dist/src/listQueryStore/listQueryCacheLimits.d.ts +1 -0
- package/dist/src/listQueryStore/listQueryStore.d.ts +538 -0
- package/dist/src/listQueryStore/types.d.ts +347 -0
- package/dist/src/listQueryStore/useFindItem.d.ts +7 -0
- package/dist/src/listQueryStore/useItem.d.ts +29 -0
- package/dist/src/listQueryStore/useListQuery.d.ts +29 -0
- package/dist/src/listQueryStore/useMultipleItems.d.ts +44 -0
- package/dist/src/listQueryStore/useMultipleListQueries.d.ts +46 -0
- package/dist/src/listQueryStore/usePendingOfflineItems.d.ts +19 -0
- package/dist/src/main.d.ts +23 -0
- package/dist/src/opfs-storage.d.ts +1 -0
- package/dist/src/persistentStorage/asyncStorageAdapter.d.ts +95 -0
- package/dist/src/persistentStorage/asyncStorageAdapters.d.ts +2 -0
- package/dist/src/persistentStorage/asyncStorageShared.d.ts +23 -0
- package/dist/src/persistentStorage/collectionStorePersistence.d.ts +26 -0
- package/dist/src/persistentStorage/compactListQueryLocalStorageEntry.d.ts +11 -0
- package/dist/src/persistentStorage/compactLocalStorageEntry.d.ts +8 -0
- package/dist/src/persistentStorage/documentEntryKey.d.ts +1 -0
- package/dist/src/persistentStorage/documentStorePersistence.d.ts +17 -0
- package/dist/src/persistentStorage/indexedDbAsyncStorageAdapter.d.ts +165 -0
- package/dist/src/persistentStorage/indexedDbPersistentStorage.d.ts +6 -0
- package/dist/src/persistentStorage/listQueryStorePersistence.d.ts +37 -0
- package/dist/src/persistentStorage/localStorageMetadata.d.ts +126 -0
- package/dist/src/persistentStorage/navigatorLocks.d.ts +3 -0
- package/dist/src/persistentStorage/offline/entityMetadata.d.ts +12 -0
- package/dist/src/persistentStorage/offline/fetchRuntime.d.ts +35 -0
- package/dist/src/persistentStorage/offline/mutationRuntime.d.ts +31 -0
- package/dist/src/persistentStorage/offline/offlineResolution.typeGuards.d.ts +1 -0
- package/dist/src/persistentStorage/offline/overlayStoreLifecycle.d.ts +13 -0
- package/dist/src/persistentStorage/offline/sessionCoordinator.d.ts +94 -0
- package/dist/src/persistentStorage/offline/sessionProtectionRegistry.d.ts +11 -0
- package/dist/src/persistentStorage/offline/storeController.d.ts +86 -0
- package/dist/src/persistentStorage/offline/types.d.ts +1255 -0
- package/dist/src/persistentStorage/offlineUploadRegistry.d.ts +11 -0
- package/dist/src/persistentStorage/offlineUploadTypes.d.ts +97 -0
- package/dist/src/persistentStorage/offlineUploadsShared.d.ts +4 -0
- package/dist/src/persistentStorage/opfsAsyncStorageAdapter.d.ts +24 -0
- package/dist/src/persistentStorage/opfsFileNaming.d.ts +23 -0
- package/dist/src/persistentStorage/opfsHelpers.d.ts +3 -0
- package/dist/src/persistentStorage/opfsOfflineUploadAdapter.d.ts +2 -0
- package/dist/src/persistentStorage/opfsPersistentStorage.d.ts +2 -0
- package/dist/src/persistentStorage/parsePersistedData.d.ts +45 -0
- package/dist/src/persistentStorage/persistenceUtils.d.ts +52 -0
- package/dist/src/persistentStorage/persistentStorageDefaults.d.ts +4 -0
- package/dist/src/persistentStorage/persistentStorageManager.d.ts +197 -0
- package/dist/src/persistentStorage/quotaDebug.d.ts +16 -0
- package/dist/src/persistentStorage/scheduleIdleCleanup.d.ts +28 -0
- package/dist/src/persistentStorage/storageAdapter.d.ts +41 -0
- package/dist/src/persistentStorage/storageEntryPrefixes.d.ts +16 -0
- package/dist/src/persistentStorage/types.d.ts +412 -0
- package/dist/src/persistentStorage/validateWithSchema.d.ts +12 -0
- package/dist/src/requestScheduler.d.ts +81 -0
- package/dist/src/storeManager.d.ts +160 -0
- package/dist/src/utils/automaticFetchPolicy.d.ts +29 -0
- package/dist/src/utils/browserTabsPriority.d.ts +43 -0
- package/dist/src/utils/browserTabsSync.d.ts +33 -0
- package/dist/src/utils/optimisticMutationTracker.d.ts +20 -0
- package/dist/src/utils/optimisticRollback.d.ts +11 -0
- package/dist/src/utils/payloadDebounce.d.ts +5 -0
- package/dist/src/utils/performMutation.d.ts +19 -0
- package/dist/src/utils/reusePrevIfEqual.d.ts +1 -0
- package/dist/src/utils/storeFocusLifecycle.d.ts +1 -0
- package/dist/src/utils/storeShared.d.ts +126 -0
- package/dist/src/utils/useEnsureIsLoaded.d.ts +6 -0
- package/dist/src/utils/useRequireFreshData.d.ts +6 -0
- package/dist/tests/basic-functionality/collection-store.test.d.ts +1 -0
- package/dist/tests/basic-functionality/document-store.test.d.ts +1 -0
- package/dist/tests/basic-functionality/list-query-state-manipulation.test.d.ts +1 -0
- package/dist/tests/basic-functionality/list-query-store.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-background-rtu-batch.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-background-rtu.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-background-scheduling.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-list-query-pagination.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-non-cancelable-fetches.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-optimistic-sync.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-partial-resources.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-priority.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-snapshot-consistency.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-state-methods.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-sync-coordinator.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-test-helpers.d.ts +69 -0
- package/dist/tests/browser-tabs/focus-coordinator.test.d.ts +1 -0
- package/dist/tests/hooks/collection-hooks-2.test.d.ts +1 -0
- package/dist/tests/hooks/collection-hooks.test.d.ts +1 -0
- package/dist/tests/hooks/collection-useListItem.test.d.ts +1 -0
- package/dist/tests/hooks/debounce-payload-hooks.test.d.ts +1 -0
- package/dist/tests/hooks/disable-refetches.test.d.ts +1 -0
- package/dist/tests/hooks/document-hooks-2.test.d.ts +1 -0
- package/dist/tests/hooks/document-hooks.test.d.ts +1 -0
- package/dist/tests/hooks/document-useListItem.test.d.ts +1 -0
- package/dist/tests/hooks/fetch-error-recovery.test.d.ts +1 -0
- package/dist/tests/hooks/hook-memoization.test.d.ts +1 -0
- package/dist/tests/hooks/list-query-hooks-2.test.d.ts +1 -0
- package/dist/tests/hooks/list-query-hooks-3.test.d.ts +1 -0
- package/dist/tests/hooks/list-query-hooks-mutations.test.d.ts +1 -0
- package/dist/tests/hooks/list-query-hooks.test.d.ts +1 -0
- package/dist/tests/hooks/list-query-pending-offline-items.test.d.ts +1 -0
- package/dist/tests/hooks/off-screen-context.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-derived-queries.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-offset-pagination.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-optimistic-filters.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-partial-resources-2.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-partial-resources-3.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-partial-resources-regressions.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-partial-resources-show-partial-status.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-partial-resources.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-size-coalescing-partial-resources.test.d.ts +1 -0
- package/dist/tests/mocks/browserTabsTestUtils.d.ts +17 -0
- package/dist/tests/mocks/collectionStoreTestEnv.d.ts +265 -0
- package/dist/tests/mocks/documentStoreTestEnv.d.ts +140 -0
- package/dist/tests/mocks/duplicateStoreGuard.test.d.ts +1 -0
- package/dist/tests/mocks/listQueryStoreTestEnv.d.ts +295 -0
- package/dist/tests/mocks/mockBrowserOpfs.d.ts +70 -0
- package/dist/tests/mocks/mockBrowserOpfs.test.d.ts +1 -0
- package/dist/tests/mocks/mockLocalStorageStore.d.ts +61 -0
- package/dist/tests/mocks/seedScenarioPersistentStorage.d.ts +51 -0
- package/dist/tests/mocks/serverMock.d.ts +56 -0
- package/dist/tests/mocks/serverTableMock.d.ts +174 -0
- package/dist/tests/mocks/testEnvUtils.d.ts +120 -0
- package/dist/tests/mocks/testScenarioPersistentStorage.test.d.ts +1 -0
- package/dist/tests/offline/offline-fetching-scenarios.test.d.ts +1 -0
- package/dist/tests/offline/offline-mixed-adapter-storage.test.d.ts +1 -0
- package/dist/tests/offline/offline-mutation-fallback.test.d.ts +1 -0
- package/dist/tests/offline/offline-network-recovery.test.d.ts +1 -0
- package/dist/tests/offline/offline-outage.test.d.ts +1 -0
- package/dist/tests/offline/offline-overlays.test.d.ts +1 -0
- package/dist/tests/offline/offline-query-replay.test.d.ts +1 -0
- package/dist/tests/offline/offline-reads.test.d.ts +1 -0
- package/dist/tests/offline/offline-replay-conflicts.test.d.ts +1 -0
- package/dist/tests/offline/offline-replay-queueing.test.d.ts +1 -0
- package/dist/tests/offline/offline-resolution-dependencies.test.d.ts +1 -0
- package/dist/tests/offline/offline-runtime-controls.test.d.ts +1 -0
- package/dist/tests/offline/offline-session-and-global-state.test.d.ts +1 -0
- package/dist/tests/offline/offline-storage.test.d.ts +1 -0
- package/dist/tests/offline/offline-uploads.test.d.ts +1 -0
- package/dist/tests/offline/offlineReplayTestShared.d.ts +292 -0
- package/dist/tests/offline/offlineTestShared.d.ts +156 -0
- package/dist/tests/perform-mutation/mutation-error-rollback.test.d.ts +1 -0
- package/dist/tests/perform-mutation/perform-mutation-block-window-close.test.d.ts +1 -0
- package/dist/tests/perform-mutation/perform-mutation-debounce.test.d.ts +1 -0
- package/dist/tests/perform-mutation/store-events.test.d.ts +1 -0
- package/dist/tests/persistent-storage/async-storage-efficiency/collection.test.d.ts +1 -0
- package/dist/tests/persistent-storage/async-storage-efficiency/document.test.d.ts +1 -0
- package/dist/tests/persistent-storage/async-storage-efficiency/list-query.test.d.ts +1 -0
- package/dist/tests/persistent-storage/async-storage-efficiency/maintenance.test.d.ts +1 -0
- package/dist/tests/persistent-storage/async-storage-efficiency/shared.d.ts +804 -0
- package/dist/tests/persistent-storage/async-storage-shared.test.d.ts +1 -0
- package/dist/tests/persistent-storage/collection-store-persistence.converted.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/collection-store-persistence.converted.test.d.ts +1 -0
- package/dist/tests/persistent-storage/collection-store-persistence.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/collection-store-persistence.test.d.ts +1 -0
- package/dist/tests/persistent-storage/document-store-persistence.converted.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/document-store-persistence.converted.test.d.ts +1 -0
- package/dist/tests/persistent-storage/document-store-persistence.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/document-store-persistence.test.d.ts +1 -0
- package/dist/tests/persistent-storage/expiration-scan.test.d.ts +1 -0
- package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/collection.test.d.ts +1 -0
- package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/document.test.d.ts +1 -0
- package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/list-query.test.d.ts +1 -0
- package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/maintenance.test.d.ts +1 -0
- package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/shared.d.ts +780 -0
- package/dist/tests/persistent-storage/indexeddb-storage-adapter.test.d.ts +1 -0
- package/dist/tests/persistent-storage/list-query-store-persistence.converted.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/list-query-store-persistence.converted.test.d.ts +1 -0
- package/dist/tests/persistent-storage/list-query-store-persistence.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/list-query-store-persistence.test.d.ts +1 -0
- package/dist/tests/persistent-storage/persistence-with-tabs-sync.test.d.ts +1 -0
- package/dist/tests/persistent-storage/persistentStorageByteBudgetTestUtils.d.ts +18 -0
- package/dist/tests/persistent-storage/quota-exceeded-recovery-no-locks.test.d.ts +1 -0
- package/dist/tests/persistent-storage/quota-exceeded-recovery.test.d.ts +1 -0
- package/dist/tests/persistent-storage/quotaRecoveryTestUtils.d.ts +228 -0
- package/dist/tests/persistent-storage/storage-adapter.test.d.ts +1 -0
- package/dist/tests/persistent-storage/sync-storage-efficiency/collection.test.d.ts +1 -0
- package/dist/tests/persistent-storage/sync-storage-efficiency/document.test.d.ts +1 -0
- package/dist/tests/persistent-storage/sync-storage-efficiency/list-query.test.d.ts +1 -0
- package/dist/tests/persistent-storage/sync-storage-efficiency/maintenance.test.d.ts +1 -0
- package/dist/tests/persistent-storage/sync-storage-efficiency/shared.d.ts +784 -0
- package/dist/tests/playwright/browser-tabs.spec.d.ts +1 -0
- package/dist/tests/playwright/persistent-storage.spec.d.ts +1 -0
- package/dist/tests/request-schedulling/batch-medium-priority.test.d.ts +1 -0
- package/dist/tests/request-schedulling/batch-realtime-updates.test.d.ts +1 -0
- package/dist/tests/request-schedulling/collection-batch-coalescing.test.d.ts +1 -0
- package/dist/tests/request-schedulling/collection-batch-key-grouping.test.d.ts +1 -0
- package/dist/tests/request-schedulling/collection-fetch-orchestration.test.d.ts +1 -0
- package/dist/tests/request-schedulling/document-await-fetch.test.d.ts +1 -0
- package/dist/tests/request-schedulling/document-base-coalescing.test.d.ts +1 -0
- package/dist/tests/request-schedulling/document-fetch-orchestration.test.d.ts +1 -0
- package/dist/tests/request-schedulling/document-medium-priority-fetch.test.d.ts +1 -0
- package/dist/tests/request-schedulling/document-realtime-updates.test.d.ts +1 -0
- package/dist/tests/request-schedulling/list-query-item-batch-coalescing.test.d.ts +1 -0
- package/dist/tests/request-schedulling/list-query-item-batch-key-grouping.test.d.ts +1 -0
- package/dist/tests/request-schedulling/list-query-size-coalescing.test.d.ts +1 -0
- package/dist/tests/request-schedulling/medium-vs-realtime.test.d.ts +1 -0
- package/dist/tests/request-schedulling/request-scheduler-cross-tab-sync.test.d.ts +1 -0
- package/dist/tests/request-schedulling/window-focus.test.d.ts +1 -0
- package/dist/tests/store-manager.test.d.ts +1 -0
- package/dist/tests/user-facing-api/collection-offline-usage.test.d.ts +1 -0
- package/dist/tests/user-facing-api/document-offline-usage.test.d.ts +1 -0
- package/dist/tests/user-facing-api/list-query-offline-usage.test.d.ts +1 -0
- package/dist/tests/user-facing-api/result-returning-callbacks.test.d.ts +1 -0
- package/dist/tests/utils/genericTestUtils.d.ts +6 -0
- package/dist/tests/utils/indexedDbPersistentStorageOptimizationTestUtils.d.ts +79 -0
- package/dist/tests/utils/indexedDbPersistentStorageTestStore.d.ts +181 -0
- package/dist/tests/utils/listQueryHooksTestUtils.d.ts +8 -0
- package/dist/tests/utils/networkMock.d.ts +11 -0
- package/dist/tests/utils/opfsPersistentStorageTestStore.d.ts +220 -0
- package/dist/tests/utils/persistentStorageOptimizationTestUtils.d.ts +54 -0
- package/dist/tests/utils/persistentStorageOptimizationTestUtils.test.d.ts +1 -0
- package/dist/tests/utils/persistentStorageTestStore.d.ts +66 -0
- package/dist/tests/utils/resetSessionForTests.d.ts +3 -0
- package/dist/tests/utils/withSuppressedActError.d.ts +4 -0
- package/dist/{types-BlyGC_PO.d.ts → types-D0ttVGmj.d.ts} +3 -3
- package/package.json +2 -2
package/dist/async-storage.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createAsyncStorageAdapter } from "./asyncStorageAdapter-
|
|
1
|
+
import { t as createAsyncStorageAdapter } from "./asyncStorageAdapter-CMohMeKm.js";
|
|
2
2
|
export { createAsyncStorageAdapter };
|
package/dist/async-storage.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as createAsyncStorageAdapter } from "./asyncStorageAdapter-
|
|
1
|
+
import { i as createAsyncStorageAdapter } from "./asyncStorageAdapter-BuGjbXYA.js";
|
|
2
2
|
export { createAsyncStorageAdapter };
|
|
@@ -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
|
|
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
|
|
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 (
|
|
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 ||
|
|
747
|
-
return setOfflineProtectionMetadata(mergedCustomMetadata,
|
|
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
|
-
|
|
1077
|
-
|
|
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
|
|
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 (
|
|
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 (
|
|
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.
|
|
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 &&
|
|
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(
|
|
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((
|
|
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(
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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 =
|
|
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 {
|
|
2114
|
+
export { scheduleIdleCleanup as $, getIsOfflineModeFromStatus as A, createCompactLocalStorageEntry as B, isQuotaExceededError as C, OfflineResolutionConflictParseError as D, serializeJsonForStorage as E, clearSessionProtectedKeysSnapshot as F, getPayloadRecordKey as G, compareMetadata as H, getSessionProtectedKeysSnapshot as I, parseAsyncStorageRecordKey as J, getPersistedNamespaceId as K, setSessionProtectedKeysSnapshot as L, isOfflineModeStatusValue as M, offlineItemEntityRefSchema as N, compactOfflineStatusSnapshotSchema as O, offlineResolutionRecordSchema as P, createIdleCleanupContext as Q, getNavigatorLockManager as R, getSerializedStringSize as S, keepEntriesWithinByteBudgetDuringIdle as T, encodePersistedAsyncNamespaceKind as U, parseCompactLocalStorageEntry as V, getNamespaceId as W, serializeProtectedRef$1 as X, parsePersistedAsyncNamespaceKind as Y, INITIAL_MAINTENANCE_CLEANUP_DELAY_MS as Z, getTSDFDebugTimingMs as _, estimateManagedAsyncStorageEntrySizeBytes as a, createShouldIgnoreItemPredicate as b, readAsyncStorageNamespaceIndexStateUsingDriver as c, unregisterAsyncStartupStoreCleanup as d, parseAsyncStorageNamespaceKind as f, emitTSDFDebugLog as g, logPersistentStorageQuotaCleanup as h, createAsyncStorageAdapter as i, isModeEffectivelyActive as j, defaultOfflineRuntimeConfig as k, registerAsyncStartupStoreCleanup as l, getOfflineSessionStatusStorageKey as m, ASYNC_STORAGE_MAX_AGE_MS as n, getProtectedKeysFromMetadata as o, OFFLINE_SESSION_STATUS_STORE_NAME as p, normalizeStaticPolicy as q, buildPersistedStaticPolicy as r, mergeManagedAsyncStorageCustomMetadata as s, ASYNC_MAINTENANCE_LOCAL_STORAGE_KEY as t, serializeProtectedRef as u, resolveTSDFLogger as v, keepEntriesWithinByteBudget as w, createTimedKeySet as x, getDefaultMaxBytesForScope as y, warnIfNavigatorLockUnavailable as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as AsyncStorageDriver, t as AsyncStorageAdapter } from "./types-
|
|
1
|
+
import { r as AsyncStorageDriver, t as AsyncStorageAdapter } from "./types-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-
|
|
2
|
-
import { n as indexedDbPersistentStorage } from "./indexedDbPersistentStorage-
|
|
1
|
+
import { t as opfsPersistentStorage } from "./opfsPersistentStorage-D_k77Srq.js";
|
|
2
|
+
import { n as indexedDbPersistentStorage } from "./indexedDbPersistentStorage-BSlgLveB.js";
|
|
3
3
|
export { indexedDbPersistentStorage, opfsPersistentStorage };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as AsyncStorageAdapter } from "./types-
|
|
1
|
+
import { t as AsyncStorageAdapter } from "./types-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-
|
|
1
|
+
import { n as indexedDbPersistentStorage, t as createIndexedDbPersistentStorage } from "./indexedDbPersistentStorage-BSlgLveB.js";
|
|
2
2
|
export { createIndexedDbPersistentStorage, indexedDbPersistentStorage };
|
package/dist/{indexedDbPersistentStorage-BameJ4st.js → indexedDbPersistentStorage-BSlgLveB.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as serializeJsonForStorage, G as getPayloadRecordKey, H as compareMetadata, J as parseAsyncStorageRecordKey, K as getPersistedNamespaceId, U as encodePersistedAsyncNamespaceKind, W as getNamespaceId, X as serializeProtectedRef, Y as parsePersistedAsyncNamespaceKind, _ as getTSDFDebugTimingMs, a as estimateManagedAsyncStorageEntrySizeBytes, g as emitTSDFDebugLog, i as createAsyncStorageAdapter, q as normalizeStaticPolicy } from "./asyncStorageAdapter-BuGjbXYA.js";
|
|
2
2
|
import { __LEGIT_CAST__ } from "@ls-stack/utils/saferTyping";
|
|
3
3
|
import { isObject } from "@ls-stack/utils/typeGuards";
|
|
4
4
|
//#region src/persistentStorage/indexedDbAsyncStorageAdapter.ts
|
|
@@ -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");
|