@tanstack/query-core 5.101.4 → 5.102.1
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/build/legacy/classPrivateFieldSet2-Bo0ZyOIv.cjs +56 -0
- package/build/legacy/classPrivateFieldSet2-CV7wyte-.js +27 -0
- package/build/legacy/classPrivateMethodInitSpec-CBwa_Y7C.js +7 -0
- package/build/legacy/classPrivateMethodInitSpec-DVhcLejn.cjs +12 -0
- package/build/legacy/environmentManager.cjs +25 -46
- package/build/legacy/environmentManager.cjs.map +1 -1
- package/build/legacy/environmentManager.d.cts +18 -2
- package/build/legacy/environmentManager.d.cts.map +1 -0
- package/build/legacy/environmentManager.d.ts +18 -2
- package/build/legacy/environmentManager.d.ts.map +1 -0
- package/build/legacy/environmentManager.js +23 -22
- package/build/legacy/environmentManager.js.map +1 -1
- package/build/legacy/focusManager.cjs +63 -104
- package/build/legacy/focusManager.cjs.map +1 -1
- package/build/legacy/focusManager.d.cts +18 -2
- package/build/legacy/focusManager.d.cts.map +1 -0
- package/build/legacy/focusManager.d.ts +18 -2
- package/build/legacy/focusManager.d.ts.map +1 -0
- package/build/legacy/focusManager.js +60 -76
- package/build/legacy/focusManager.js.map +1 -1
- package/build/legacy/hydration-BhSbkfZj.d.cts +1374 -0
- package/build/legacy/hydration-BhSbkfZj.d.cts.map +1 -0
- package/build/legacy/hydration-Hebl6yHM.d.ts +1374 -0
- package/build/legacy/hydration-Hebl6yHM.d.ts.map +1 -0
- package/build/legacy/hydration.cjs +111 -194
- package/build/legacy/hydration.cjs.map +1 -1
- package/build/legacy/hydration.d.cts +2 -7
- package/build/legacy/hydration.d.ts +2 -7
- package/build/legacy/hydration.js +105 -167
- package/build/legacy/hydration.js.map +1 -1
- package/build/legacy/index.cjs +59 -111
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +10 -141
- package/build/legacy/index.d.ts +10 -141
- package/build/legacy/index.js +16 -66
- package/build/legacy/index.js.map +1 -1
- package/build/legacy/infiniteQueryBehavior.cjs +92 -135
- package/build/legacy/infiniteQueryBehavior.cjs.map +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +14 -3
- package/build/legacy/infiniteQueryBehavior.d.cts.map +1 -0
- package/build/legacy/infiniteQueryBehavior.d.ts +14 -3
- package/build/legacy/infiniteQueryBehavior.d.ts.map +1 -0
- package/build/legacy/infiniteQueryBehavior.js +89 -115
- package/build/legacy/infiniteQueryBehavior.js.map +1 -1
- package/build/legacy/infiniteQueryObserver.cjs +59 -88
- package/build/legacy/infiniteQueryObserver.cjs.map +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +20 -1
- package/build/legacy/infiniteQueryObserver.d.cts.map +1 -0
- package/build/legacy/infiniteQueryObserver.d.ts +20 -1
- package/build/legacy/infiniteQueryObserver.d.ts.map +1 -0
- package/build/legacy/infiniteQueryObserver.js +57 -64
- package/build/legacy/infiniteQueryObserver.js.map +1 -1
- package/build/legacy/mutation.cjs +236 -329
- package/build/legacy/mutation.cjs.map +1 -1
- package/build/legacy/mutation.d.cts +2 -4
- package/build/legacy/mutation.d.ts +2 -4
- package/build/legacy/mutation.js +231 -299
- package/build/legacy/mutation.js.map +1 -1
- package/build/legacy/mutationCache.cjs +121 -166
- package/build/legacy/mutationCache.cjs.map +1 -1
- package/build/legacy/mutationCache.d.cts +2 -2
- package/build/legacy/mutationCache.d.ts +2 -2
- package/build/legacy/mutationCache.js +117 -130
- package/build/legacy/mutationCache.js.map +1 -1
- package/build/legacy/mutationObserver.cjs +134 -187
- package/build/legacy/mutationObserver.cjs.map +1 -1
- package/build/legacy/mutationObserver.d.cts +2 -1
- package/build/legacy/mutationObserver.d.ts +2 -1
- package/build/legacy/mutationObserver.js +132 -160
- package/build/legacy/mutationObserver.js.map +1 -1
- package/build/legacy/notifyManager.cjs +76 -110
- package/build/legacy/notifyManager.cjs.map +1 -1
- package/build/legacy/notifyManager.d.cts +48 -3
- package/build/legacy/notifyManager.d.cts.map +1 -0
- package/build/legacy/notifyManager.d.ts +48 -3
- package/build/legacy/notifyManager.d.ts.map +1 -0
- package/build/legacy/notifyManager.js +73 -84
- package/build/legacy/notifyManager.js.map +1 -1
- package/build/legacy/onlineManager.cjs +57 -93
- package/build/legacy/onlineManager.cjs.map +1 -1
- package/build/legacy/onlineManager.d.cts +17 -2
- package/build/legacy/onlineManager.d.cts.map +1 -0
- package/build/legacy/onlineManager.d.ts +17 -2
- package/build/legacy/onlineManager.d.ts.map +1 -0
- package/build/legacy/onlineManager.js +54 -65
- package/build/legacy/onlineManager.js.map +1 -1
- package/build/legacy/queriesObserver.cjs +203 -262
- package/build/legacy/queriesObserver.cjs.map +1 -1
- package/build/legacy/queriesObserver.d.cts +23 -2
- package/build/legacy/queriesObserver.d.cts.map +1 -0
- package/build/legacy/queriesObserver.d.ts +23 -2
- package/build/legacy/queriesObserver.d.ts.map +1 -0
- package/build/legacy/queriesObserver.js +199 -233
- package/build/legacy/queriesObserver.js.map +1 -1
- package/build/legacy/query.cjs +409 -491
- package/build/legacy/query.cjs.map +1 -1
- package/build/legacy/query.d.cts +2 -9
- package/build/legacy/query.d.ts +2 -9
- package/build/legacy/query.js +402 -467
- package/build/legacy/query.js.map +1 -1
- package/build/legacy/queryCache.cjs +99 -128
- package/build/legacy/queryCache.cjs.map +1 -1
- package/build/legacy/queryCache.d.cts +2 -3
- package/build/legacy/queryCache.d.ts +2 -3
- package/build/legacy/queryCache.js +96 -100
- package/build/legacy/queryCache.js.map +1 -1
- package/build/legacy/queryClient.cjs +295 -345
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +2 -1
- package/build/legacy/queryClient.d.ts +2 -1
- package/build/legacy/queryClient.js +292 -318
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/queryObserver.cjs +350 -502
- package/build/legacy/queryObserver.cjs.map +1 -1
- package/build/legacy/queryObserver.d.cts +2 -1
- package/build/legacy/queryObserver.d.ts +2 -1
- package/build/legacy/queryObserver.js +345 -480
- package/build/legacy/queryObserver.js.map +1 -1
- package/build/legacy/removable-DeMjhW5M.d.cts +13 -0
- package/build/legacy/removable-DeMjhW5M.d.cts.map +1 -0
- package/build/legacy/removable-DeMjhW5M.d.ts +13 -0
- package/build/legacy/removable-DeMjhW5M.d.ts.map +1 -0
- package/build/legacy/removable.cjs +31 -67
- package/build/legacy/removable.cjs.map +1 -1
- package/build/legacy/removable.d.cts +2 -1
- package/build/legacy/removable.d.ts +2 -1
- package/build/legacy/removable.js +28 -39
- package/build/legacy/removable.js.map +1 -1
- package/build/legacy/retryer.cjs +127 -155
- package/build/legacy/retryer.cjs.map +1 -1
- package/build/legacy/retryer.d.cts +2 -7
- package/build/legacy/retryer.d.ts +2 -7
- package/build/legacy/retryer.js +121 -127
- package/build/legacy/retryer.js.map +1 -1
- package/build/legacy/streamedQuery.cjs +49 -78
- package/build/legacy/streamedQuery.cjs.map +1 -1
- package/build/legacy/streamedQuery.d.cts +33 -1
- package/build/legacy/streamedQuery.d.cts.map +1 -0
- package/build/legacy/streamedQuery.d.ts +33 -1
- package/build/legacy/streamedQuery.d.ts.map +1 -0
- package/build/legacy/streamedQuery.js +47 -54
- package/build/legacy/streamedQuery.js.map +1 -1
- package/build/legacy/subscribable-CbifVTKz.d.cts +12 -0
- package/build/legacy/subscribable-CbifVTKz.d.cts.map +1 -0
- package/build/legacy/subscribable-CbifVTKz.d.ts +12 -0
- package/build/legacy/subscribable-CbifVTKz.d.ts.map +1 -0
- package/build/legacy/subscribable.cjs +22 -48
- package/build/legacy/subscribable.cjs.map +1 -1
- package/build/legacy/subscribable.d.cts +2 -1
- package/build/legacy/subscribable.d.ts +2 -1
- package/build/legacy/subscribable.js +21 -25
- package/build/legacy/subscribable.js.map +1 -1
- package/build/legacy/timeoutManager.cjs +64 -105
- package/build/legacy/timeoutManager.cjs.map +1 -1
- package/build/legacy/timeoutManager.d.cts +60 -7
- package/build/legacy/timeoutManager.d.cts.map +1 -0
- package/build/legacy/timeoutManager.d.ts +60 -7
- package/build/legacy/timeoutManager.d.ts.map +1 -0
- package/build/legacy/timeoutManager.js +60 -76
- package/build/legacy/timeoutManager.js.map +1 -1
- package/build/legacy/types.cjs +10 -35
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +2 -94
- package/build/legacy/types.d.ts +2 -94
- package/build/legacy/types.js +7 -10
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/utils.cjs +175 -300
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +2 -30
- package/build/legacy/utils.d.ts +2 -30
- package/build/legacy/utils.js +149 -252
- package/build/legacy/utils.js.map +1 -1
- package/build/modern/environmentManager.cjs +25 -46
- package/build/modern/environmentManager.cjs.map +1 -1
- package/build/modern/environmentManager.d.cts +18 -2
- package/build/modern/environmentManager.d.cts.map +1 -0
- package/build/modern/environmentManager.d.ts +18 -2
- package/build/modern/environmentManager.d.ts.map +1 -0
- package/build/modern/environmentManager.js +23 -20
- package/build/modern/environmentManager.js.map +1 -1
- package/build/modern/focusManager.cjs +56 -90
- package/build/modern/focusManager.cjs.map +1 -1
- package/build/modern/focusManager.d.cts +18 -2
- package/build/modern/focusManager.d.cts.map +1 -0
- package/build/modern/focusManager.d.ts +18 -2
- package/build/modern/focusManager.d.ts.map +1 -0
- package/build/modern/focusManager.js +53 -63
- package/build/modern/focusManager.js.map +1 -1
- package/build/modern/hydration-BhSbkfZj.d.cts +1374 -0
- package/build/modern/hydration-BhSbkfZj.d.cts.map +1 -0
- package/build/modern/hydration-Hebl6yHM.d.ts +1374 -0
- package/build/modern/hydration-Hebl6yHM.d.ts.map +1 -0
- package/build/modern/hydration.cjs +102 -189
- package/build/modern/hydration.cjs.map +1 -1
- package/build/modern/hydration.d.cts +2 -7
- package/build/modern/hydration.d.ts +2 -7
- package/build/modern/hydration.js +96 -160
- package/build/modern/hydration.js.map +1 -1
- package/build/modern/index.cjs +59 -111
- package/build/modern/index.cjs.map +1 -1
- package/build/modern/index.d.cts +10 -141
- package/build/modern/index.d.ts +10 -141
- package/build/modern/index.js +16 -64
- package/build/modern/index.js.map +1 -1
- package/build/modern/infiniteQueryBehavior.cjs +89 -131
- package/build/modern/infiniteQueryBehavior.cjs.map +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +14 -3
- package/build/modern/infiniteQueryBehavior.d.cts.map +1 -0
- package/build/modern/infiniteQueryBehavior.d.ts +14 -3
- package/build/modern/infiniteQueryBehavior.d.ts.map +1 -0
- package/build/modern/infiniteQueryBehavior.js +86 -109
- package/build/modern/infiniteQueryBehavior.js.map +1 -1
- package/build/modern/infiniteQueryObserver.cjs +58 -87
- package/build/modern/infiniteQueryObserver.cjs.map +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +20 -1
- package/build/modern/infiniteQueryObserver.d.cts.map +1 -0
- package/build/modern/infiniteQueryObserver.d.ts +20 -1
- package/build/modern/infiniteQueryObserver.d.ts.map +1 -0
- package/build/modern/infiniteQueryObserver.js +56 -61
- package/build/modern/infiniteQueryObserver.js.map +1 -1
- package/build/modern/mutation.cjs +221 -303
- package/build/modern/mutation.cjs.map +1 -1
- package/build/modern/mutation.d.cts +2 -4
- package/build/modern/mutation.d.ts +2 -4
- package/build/modern/mutation.js +216 -274
- package/build/modern/mutation.js.map +1 -1
- package/build/modern/mutationCache.cjs +111 -145
- package/build/modern/mutationCache.cjs.map +1 -1
- package/build/modern/mutationCache.d.cts +2 -2
- package/build/modern/mutationCache.d.ts +2 -2
- package/build/modern/mutationCache.js +107 -117
- package/build/modern/mutationCache.js.map +1 -1
- package/build/modern/mutationObserver.cjs +115 -162
- package/build/modern/mutationObserver.cjs.map +1 -1
- package/build/modern/mutationObserver.d.cts +2 -1
- package/build/modern/mutationObserver.d.ts +2 -1
- package/build/modern/mutationObserver.js +113 -136
- package/build/modern/mutationObserver.js.map +1 -1
- package/build/modern/notifyManager.cjs +76 -110
- package/build/modern/notifyManager.cjs.map +1 -1
- package/build/modern/notifyManager.d.cts +48 -3
- package/build/modern/notifyManager.d.cts.map +1 -0
- package/build/modern/notifyManager.d.ts +48 -3
- package/build/modern/notifyManager.d.ts.map +1 -0
- package/build/modern/notifyManager.js +73 -82
- package/build/modern/notifyManager.js.map +1 -1
- package/build/modern/onlineManager.cjs +51 -80
- package/build/modern/onlineManager.cjs.map +1 -1
- package/build/modern/onlineManager.d.cts +17 -2
- package/build/modern/onlineManager.d.cts.map +1 -0
- package/build/modern/onlineManager.d.ts +17 -2
- package/build/modern/onlineManager.d.ts.map +1 -0
- package/build/modern/onlineManager.js +48 -53
- package/build/modern/onlineManager.js.map +1 -1
- package/build/modern/queriesObserver.cjs +185 -237
- package/build/modern/queriesObserver.cjs.map +1 -1
- package/build/modern/queriesObserver.d.cts +23 -2
- package/build/modern/queriesObserver.d.cts.map +1 -0
- package/build/modern/queriesObserver.d.ts +23 -2
- package/build/modern/queriesObserver.d.ts.map +1 -0
- package/build/modern/queriesObserver.js +181 -209
- package/build/modern/queriesObserver.js.map +1 -1
- package/build/modern/query.cjs +384 -464
- package/build/modern/query.cjs.map +1 -1
- package/build/modern/query.d.cts +2 -9
- package/build/modern/query.d.ts +2 -9
- package/build/modern/query.js +377 -441
- package/build/modern/query.js.map +1 -1
- package/build/modern/queryCache.cjs +97 -119
- package/build/modern/queryCache.cjs.map +1 -1
- package/build/modern/queryCache.d.cts +2 -3
- package/build/modern/queryCache.d.ts +2 -3
- package/build/modern/queryCache.js +94 -92
- package/build/modern/queryCache.js.map +1 -1
- package/build/modern/queryClient.cjs +281 -318
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +2 -1
- package/build/modern/queryClient.d.ts +2 -1
- package/build/modern/queryClient.js +278 -299
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/queryObserver.cjs +329 -475
- package/build/modern/queryObserver.cjs.map +1 -1
- package/build/modern/queryObserver.d.cts +2 -1
- package/build/modern/queryObserver.d.ts +2 -1
- package/build/modern/queryObserver.js +324 -454
- package/build/modern/queryObserver.js.map +1 -1
- package/build/modern/removable-DeMjhW5M.d.cts +13 -0
- package/build/modern/removable-DeMjhW5M.d.cts.map +1 -0
- package/build/modern/removable-DeMjhW5M.d.ts +13 -0
- package/build/modern/removable-DeMjhW5M.d.ts.map +1 -0
- package/build/modern/removable.cjs +27 -56
- package/build/modern/removable.cjs.map +1 -1
- package/build/modern/removable.d.cts +2 -1
- package/build/modern/removable.d.ts +2 -1
- package/build/modern/removable.js +24 -29
- package/build/modern/removable.js.map +1 -1
- package/build/modern/retryer.cjs +121 -151
- package/build/modern/retryer.cjs.map +1 -1
- package/build/modern/retryer.d.cts +2 -7
- package/build/modern/retryer.d.ts +2 -7
- package/build/modern/retryer.js +115 -121
- package/build/modern/retryer.js.map +1 -1
- package/build/modern/streamedQuery.cjs +49 -78
- package/build/modern/streamedQuery.cjs.map +1 -1
- package/build/modern/streamedQuery.d.cts +33 -1
- package/build/modern/streamedQuery.d.cts.map +1 -0
- package/build/modern/streamedQuery.d.ts +33 -1
- package/build/modern/streamedQuery.d.ts.map +1 -0
- package/build/modern/streamedQuery.js +47 -52
- package/build/modern/streamedQuery.js.map +1 -1
- package/build/modern/subscribable-CbifVTKz.d.cts +12 -0
- package/build/modern/subscribable-CbifVTKz.d.cts.map +1 -0
- package/build/modern/subscribable-CbifVTKz.d.ts +12 -0
- package/build/modern/subscribable-CbifVTKz.d.ts.map +1 -0
- package/build/modern/subscribable.cjs +22 -48
- package/build/modern/subscribable.cjs.map +1 -1
- package/build/modern/subscribable.d.cts +2 -1
- package/build/modern/subscribable.d.ts +2 -1
- package/build/modern/subscribable.js +21 -23
- package/build/modern/subscribable.js.map +1 -1
- package/build/modern/timeoutManager.cjs +59 -93
- package/build/modern/timeoutManager.cjs.map +1 -1
- package/build/modern/timeoutManager.d.cts +60 -7
- package/build/modern/timeoutManager.d.cts.map +1 -0
- package/build/modern/timeoutManager.d.ts +60 -7
- package/build/modern/timeoutManager.d.ts.map +1 -0
- package/build/modern/timeoutManager.js +55 -65
- package/build/modern/timeoutManager.js.map +1 -1
- package/build/modern/types.cjs +10 -35
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +2 -94
- package/build/modern/types.d.ts +2 -94
- package/build/modern/types.js +8 -9
- package/build/modern/types.js.map +1 -1
- package/build/modern/utils.cjs +175 -300
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +2 -30
- package/build/modern/utils.d.ts +2 -30
- package/build/modern/utils.js +149 -250
- package/build/modern/utils.js.map +1 -1
- package/package.json +3 -5
- package/src/hydration.ts +65 -56
- package/src/index.ts +1 -0
- package/src/mutation.ts +14 -6
- package/src/mutationObserver.ts +8 -0
- package/src/queriesObserver.ts +14 -8
- package/src/query.ts +14 -6
- package/src/queryClient.ts +90 -2
- package/src/queryObserver.ts +41 -64
- package/src/retryer.ts +20 -12
- package/src/types.ts +70 -58
- package/build/legacy/_tsup-dts-rollup.d.cts +0 -2188
- package/build/legacy/_tsup-dts-rollup.d.ts +0 -2188
- package/build/legacy/chunk-PXG64RU4.js +0 -25
- package/build/legacy/chunk-PXG64RU4.js.map +0 -1
- package/build/legacy/thenable.cjs +0 -76
- package/build/legacy/thenable.cjs.map +0 -1
- package/build/legacy/thenable.d.cts +0 -6
- package/build/legacy/thenable.d.ts +0 -6
- package/build/legacy/thenable.js +0 -52
- package/build/legacy/thenable.js.map +0 -1
- package/build/modern/_tsup-dts-rollup.d.cts +0 -2188
- package/build/modern/_tsup-dts-rollup.d.ts +0 -2188
- package/build/modern/thenable.cjs +0 -75
- package/build/modern/thenable.cjs.map +0 -1
- package/build/modern/thenable.d.cts +0 -6
- package/build/modern/thenable.d.ts +0 -6
- package/build/modern/thenable.js +0 -49
- package/build/modern/thenable.js.map +0 -1
- package/src/thenable.ts +0 -111
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/onlineManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (online: boolean) => void\ntype SetupFn = (setOnline: Listener) => (() => void) | undefined\n\nexport class OnlineManager extends Subscribable<Listener> {\n #online = true\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof window !== 'undefined' && window.addEventListener) {\n const onlineListener = () => onOnline(true)\n const offlineListener = () => onOnline(false)\n // Listen to online\n window.addEventListener('online', onlineListener, false)\n window.addEventListener('offline', offlineListener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', onlineListener)\n window.removeEventListener('offline', offlineListener)\n }\n }\n\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup(this.setOnline.bind(this))\n }\n\n setOnline(online: boolean): void {\n const changed = this.#online !== online\n\n if (changed) {\n this.#online = online\n this.listeners.forEach((listener) => {\n listener(online)\n })\n }\n }\n\n isOnline(): boolean {\n return this.#online\n }\n}\n\nexport const onlineManager = new OnlineManager()\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"onlineManager.cjs","names":["Subscribable","#setup","#cleanup","#online"],"sources":["../../src/onlineManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (online: boolean) => void\ntype SetupFn = (setOnline: Listener) => (() => void) | undefined\n\nexport class OnlineManager extends Subscribable<Listener> {\n #online = true\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof window !== 'undefined' && window.addEventListener) {\n const onlineListener = () => onOnline(true)\n const offlineListener = () => onOnline(false)\n // Listen to online\n window.addEventListener('online', onlineListener, false)\n window.addEventListener('offline', offlineListener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', onlineListener)\n window.removeEventListener('offline', offlineListener)\n }\n }\n\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup(this.setOnline.bind(this))\n }\n\n setOnline(online: boolean): void {\n const changed = this.#online !== online\n\n if (changed) {\n this.#online = online\n this.listeners.forEach((listener) => {\n listener(online)\n })\n }\n }\n\n isOnline(): boolean {\n return this.#online\n }\n}\n\nexport const onlineManager = new OnlineManager()\n"],"mappings":";;;AAKA,IAAa,gBAAb,cAAmCA,qBAAAA,aAAuB;CACxD,UAAU;CACV;CAEA;CAEA,cAAc;EACZ,MAAM;EACN,KAAKC,UAAU,aAAa;GAG1B,IAAI,OAAO,WAAW,eAAe,OAAO,kBAAkB;IAC5D,MAAM,uBAAuB,SAAS,IAAI;IAC1C,MAAM,wBAAwB,SAAS,KAAK;IAE5C,OAAO,iBAAiB,UAAU,gBAAgB,KAAK;IACvD,OAAO,iBAAiB,WAAW,iBAAiB,KAAK;IAEzD,aAAa;KAEX,OAAO,oBAAoB,UAAU,cAAc;KACnD,OAAO,oBAAoB,WAAW,eAAe;IACvD;GACF;EAGF;CACF;CAEA,cAA8B;EAC5B,IAAI,CAAC,KAAKC,UACR,KAAK,iBAAiB,KAAKD,MAAM;CAErC;CAEA,gBAA0B;EACxB,IAAI,CAAC,KAAK,aAAa,GAAG;GACxB,KAAKC,WAAW;GAChB,KAAKA,WAAW,KAAA;EAClB;CACF;CAEA,iBAAiB,OAAsB;EACrC,KAAKD,SAAS;EACd,KAAKC,WAAW;EAChB,KAAKA,WAAW,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC;CACjD;CAEA,UAAU,QAAuB;EAG/B,IAFgB,KAAKC,YAAY,QAEpB;GACX,KAAKA,UAAU;GACf,KAAK,UAAU,SAAS,aAAa;IACnC,SAAS,MAAM;GACjB,CAAC;EACH;CACF;CAEA,WAAoB;EAClB,OAAO,KAAKA;CACd;AACF;AAEA,MAAa,gBAAgB,IAAI,cAAc"}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { t as Subscribable } from "./subscribable-CbifVTKz.cjs";
|
|
2
|
+
//#region src/onlineManager.d.ts
|
|
3
|
+
type Listener = (online: boolean) => void;
|
|
4
|
+
type SetupFn = (setOnline: Listener) => (() => void) | undefined;
|
|
5
|
+
declare class OnlineManager extends Subscribable<Listener> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor();
|
|
8
|
+
protected onSubscribe(): void;
|
|
9
|
+
protected onUnsubscribe(): void;
|
|
10
|
+
setEventListener(setup: SetupFn): void;
|
|
11
|
+
setOnline(online: boolean): void;
|
|
12
|
+
isOnline(): boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const onlineManager: OnlineManager;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { OnlineManager, onlineManager };
|
|
17
|
+
//# sourceMappingURL=onlineManager.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onlineManager.d.cts","names":[],"sources":["../../src/onlineManager.ts"],"mappings":";;KAEK,YAAY;KACZ,WAAW,WAAW;cAEd,sBAAsB,aAAa;;;YA6BpC;YAMA;EAOV,iBAAiB,OAAO;EAMxB,UAAU;EAWV;;cAKW,eAAa"}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { t as Subscribable } from "./subscribable-CbifVTKz.js";
|
|
2
|
+
//#region src/onlineManager.d.ts
|
|
3
|
+
type Listener = (online: boolean) => void;
|
|
4
|
+
type SetupFn = (setOnline: Listener) => (() => void) | undefined;
|
|
5
|
+
declare class OnlineManager extends Subscribable<Listener> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor();
|
|
8
|
+
protected onSubscribe(): void;
|
|
9
|
+
protected onUnsubscribe(): void;
|
|
10
|
+
setEventListener(setup: SetupFn): void;
|
|
11
|
+
setOnline(online: boolean): void;
|
|
12
|
+
isOnline(): boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const onlineManager: OnlineManager;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { OnlineManager, onlineManager };
|
|
17
|
+
//# sourceMappingURL=onlineManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onlineManager.d.ts","names":[],"sources":["../../src/onlineManager.ts"],"mappings":";;KAEK,YAAY;KACZ,WAAW,WAAW;cAEd,sBAAsB,aAAa;;;YA6BpC;YAMA;EAOV,iBAAiB,OAAO;EAMxB,UAAU;EAWV;;cAKW,eAAa"}
|
|
@@ -1,57 +1,52 @@
|
|
|
1
|
-
// src/onlineManager.ts
|
|
2
1
|
import { Subscribable } from "./subscribable.js";
|
|
2
|
+
//#region src/onlineManager.ts
|
|
3
3
|
var OnlineManager = class extends Subscribable {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
isOnline() {
|
|
49
|
-
return this.#online;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var onlineManager = new OnlineManager();
|
|
53
|
-
export {
|
|
54
|
-
OnlineManager,
|
|
55
|
-
onlineManager
|
|
4
|
+
#online = true;
|
|
5
|
+
#cleanup;
|
|
6
|
+
#setup;
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.#setup = (onOnline) => {
|
|
10
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
11
|
+
const onlineListener = () => onOnline(true);
|
|
12
|
+
const offlineListener = () => onOnline(false);
|
|
13
|
+
window.addEventListener("online", onlineListener, false);
|
|
14
|
+
window.addEventListener("offline", offlineListener, false);
|
|
15
|
+
return () => {
|
|
16
|
+
window.removeEventListener("online", onlineListener);
|
|
17
|
+
window.removeEventListener("offline", offlineListener);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
onSubscribe() {
|
|
23
|
+
if (!this.#cleanup) this.setEventListener(this.#setup);
|
|
24
|
+
}
|
|
25
|
+
onUnsubscribe() {
|
|
26
|
+
if (!this.hasListeners()) {
|
|
27
|
+
this.#cleanup?.();
|
|
28
|
+
this.#cleanup = void 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
setEventListener(setup) {
|
|
32
|
+
this.#setup = setup;
|
|
33
|
+
this.#cleanup?.();
|
|
34
|
+
this.#cleanup = setup(this.setOnline.bind(this));
|
|
35
|
+
}
|
|
36
|
+
setOnline(online) {
|
|
37
|
+
if (this.#online !== online) {
|
|
38
|
+
this.#online = online;
|
|
39
|
+
this.listeners.forEach((listener) => {
|
|
40
|
+
listener(online);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
isOnline() {
|
|
45
|
+
return this.#online;
|
|
46
|
+
}
|
|
56
47
|
};
|
|
48
|
+
const onlineManager = new OnlineManager();
|
|
49
|
+
//#endregion
|
|
50
|
+
export { OnlineManager, onlineManager };
|
|
51
|
+
|
|
57
52
|
//# sourceMappingURL=onlineManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/onlineManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (online: boolean) => void\ntype SetupFn = (setOnline: Listener) => (() => void) | undefined\n\nexport class OnlineManager extends Subscribable<Listener> {\n #online = true\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof window !== 'undefined' && window.addEventListener) {\n const onlineListener = () => onOnline(true)\n const offlineListener = () => onOnline(false)\n // Listen to online\n window.addEventListener('online', onlineListener, false)\n window.addEventListener('offline', offlineListener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', onlineListener)\n window.removeEventListener('offline', offlineListener)\n }\n }\n\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup(this.setOnline.bind(this))\n }\n\n setOnline(online: boolean): void {\n const changed = this.#online !== online\n\n if (changed) {\n this.#online = online\n this.listeners.forEach((listener) => {\n listener(online)\n })\n }\n }\n\n isOnline(): boolean {\n return this.#online\n }\n}\n\nexport const onlineManager = new OnlineManager()\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"onlineManager.js","names":["#setup","#cleanup","#online"],"sources":["../../src/onlineManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (online: boolean) => void\ntype SetupFn = (setOnline: Listener) => (() => void) | undefined\n\nexport class OnlineManager extends Subscribable<Listener> {\n #online = true\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof window !== 'undefined' && window.addEventListener) {\n const onlineListener = () => onOnline(true)\n const offlineListener = () => onOnline(false)\n // Listen to online\n window.addEventListener('online', onlineListener, false)\n window.addEventListener('offline', offlineListener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', onlineListener)\n window.removeEventListener('offline', offlineListener)\n }\n }\n\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup(this.setOnline.bind(this))\n }\n\n setOnline(online: boolean): void {\n const changed = this.#online !== online\n\n if (changed) {\n this.#online = online\n this.listeners.forEach((listener) => {\n listener(online)\n })\n }\n }\n\n isOnline(): boolean {\n return this.#online\n }\n}\n\nexport const onlineManager = new OnlineManager()\n"],"mappings":";;AAKA,IAAa,gBAAb,cAAmC,aAAuB;CACxD,UAAU;CACV;CAEA;CAEA,cAAc;EACZ,MAAM;EACN,KAAKA,UAAU,aAAa;GAG1B,IAAI,OAAO,WAAW,eAAe,OAAO,kBAAkB;IAC5D,MAAM,uBAAuB,SAAS,IAAI;IAC1C,MAAM,wBAAwB,SAAS,KAAK;IAE5C,OAAO,iBAAiB,UAAU,gBAAgB,KAAK;IACvD,OAAO,iBAAiB,WAAW,iBAAiB,KAAK;IAEzD,aAAa;KAEX,OAAO,oBAAoB,UAAU,cAAc;KACnD,OAAO,oBAAoB,WAAW,eAAe;IACvD;GACF;EAGF;CACF;CAEA,cAA8B;EAC5B,IAAI,CAAC,KAAKC,UACR,KAAK,iBAAiB,KAAKD,MAAM;CAErC;CAEA,gBAA0B;EACxB,IAAI,CAAC,KAAK,aAAa,GAAG;GACxB,KAAKC,WAAW;GAChB,KAAKA,WAAW,KAAA;EAClB;CACF;CAEA,iBAAiB,OAAsB;EACrC,KAAKD,SAAS;EACd,KAAKC,WAAW;EAChB,KAAKA,WAAW,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC;CACjD;CAEA,UAAU,QAAuB;EAG/B,IAFgB,KAAKC,YAAY,QAEpB;GACX,KAAKA,UAAU;GACf,KAAK,UAAU,SAAS,aAAa;IACnC,SAAS,MAAM;GACjB,CAAC;EACH;CACF;CAEA,WAAoB;EAClB,OAAO,KAAKA;CACd;AACF;AAEA,MAAa,gBAAgB,IAAI,cAAc"}
|
|
@@ -1,243 +1,191 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/queriesObserver.ts
|
|
21
|
-
var queriesObserver_exports = {};
|
|
22
|
-
__export(queriesObserver_exports, {
|
|
23
|
-
QueriesObserver: () => QueriesObserver
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(queriesObserver_exports);
|
|
26
|
-
var import_notifyManager = require("./notifyManager.cjs");
|
|
27
|
-
var import_queryObserver = require("./queryObserver.cjs");
|
|
28
|
-
var import_subscribable = require("./subscribable.cjs");
|
|
29
|
-
var import_utils = require("./utils.cjs");
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils = require("./utils.cjs");
|
|
3
|
+
const require_subscribable = require("./subscribable.cjs");
|
|
4
|
+
const require_notifyManager = require("./notifyManager.cjs");
|
|
5
|
+
const require_queryObserver = require("./queryObserver.cjs");
|
|
6
|
+
//#region src/queriesObserver.ts
|
|
30
7
|
function difference(array1, array2) {
|
|
31
|
-
|
|
32
|
-
|
|
8
|
+
const excludeSet = new Set(array2);
|
|
9
|
+
return array1.filter((x) => !excludeSet.has(x));
|
|
33
10
|
}
|
|
34
11
|
function replaceAt(array, index, value) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
12
|
+
const copy = array.slice(0);
|
|
13
|
+
copy[index] = value;
|
|
14
|
+
return copy;
|
|
38
15
|
}
|
|
39
|
-
var QueriesObserver = class extends
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
defaultedQueryOptions: defaultedOptions,
|
|
211
|
-
observer
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
return observers;
|
|
215
|
-
}
|
|
216
|
-
#onUpdate(observer, result) {
|
|
217
|
-
const index = this.#observers.indexOf(observer);
|
|
218
|
-
if (index !== -1) {
|
|
219
|
-
this.#result = replaceAt(this.#result, index, result);
|
|
220
|
-
this.#notify();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
#notify() {
|
|
224
|
-
if (this.hasListeners()) {
|
|
225
|
-
const newTracked = this.#trackResult(this.#result, this.#observerMatches);
|
|
226
|
-
const shouldSkipCombine = this.#shouldSkipCombine();
|
|
227
|
-
const previousResult = this.#combinedResult;
|
|
228
|
-
const newResult = shouldSkipCombine ? previousResult : this.#combineResult(newTracked, this.#options?.combine);
|
|
229
|
-
if (shouldSkipCombine || previousResult !== newResult) {
|
|
230
|
-
import_notifyManager.notifyManager.batch(() => {
|
|
231
|
-
this.listeners.forEach((listener) => {
|
|
232
|
-
listener(this.#result);
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
16
|
+
var QueriesObserver = class extends require_subscribable.Subscribable {
|
|
17
|
+
#client;
|
|
18
|
+
#result;
|
|
19
|
+
#queries;
|
|
20
|
+
#options;
|
|
21
|
+
#observers;
|
|
22
|
+
#combinedResult;
|
|
23
|
+
#lastCombine;
|
|
24
|
+
#lastResult;
|
|
25
|
+
#lastQueryHashes;
|
|
26
|
+
#observerMatches = [];
|
|
27
|
+
constructor(client, queries, options) {
|
|
28
|
+
super();
|
|
29
|
+
this.#client = client;
|
|
30
|
+
this.#options = options;
|
|
31
|
+
this.#queries = [];
|
|
32
|
+
this.#observers = [];
|
|
33
|
+
this.#result = [];
|
|
34
|
+
this.setQueries(queries);
|
|
35
|
+
}
|
|
36
|
+
onSubscribe() {
|
|
37
|
+
if (this.listeners.size === 1) this.#observers.forEach((observer) => {
|
|
38
|
+
observer.subscribe((result) => {
|
|
39
|
+
this.#onUpdate(observer, result);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
onUnsubscribe() {
|
|
44
|
+
if (!this.listeners.size) this.destroy();
|
|
45
|
+
}
|
|
46
|
+
destroy() {
|
|
47
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
48
|
+
this.#observers.forEach((observer) => {
|
|
49
|
+
observer.destroy();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
setQueries(queries, options) {
|
|
53
|
+
this.#queries = queries;
|
|
54
|
+
this.#options = options;
|
|
55
|
+
if (process.env.NODE_ENV !== "production") {
|
|
56
|
+
const queryHashes = queries.map((query) => this.#client.defaultQueryOptions(query).queryHash);
|
|
57
|
+
if (new Set(queryHashes).size !== queryHashes.length) console.warn("[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.");
|
|
58
|
+
}
|
|
59
|
+
require_notifyManager.notifyManager.batch(() => {
|
|
60
|
+
const prevObservers = this.#observers;
|
|
61
|
+
const newObserverMatches = this.#findMatchingObservers(this.#queries);
|
|
62
|
+
newObserverMatches.forEach((match) => match.observer.setOptions(match.defaultedQueryOptions));
|
|
63
|
+
const newObservers = newObserverMatches.map((match) => match.observer);
|
|
64
|
+
const newResult = newObservers.map((observer) => observer.getCurrentResult());
|
|
65
|
+
const hasLengthChange = prevObservers.length !== newObservers.length;
|
|
66
|
+
const hasIndexChange = newObservers.some((observer, index) => observer !== prevObservers[index]);
|
|
67
|
+
const hasStructuralChange = hasLengthChange || hasIndexChange;
|
|
68
|
+
const hasResultChange = hasStructuralChange ? true : newResult.some((result, index) => {
|
|
69
|
+
const prev = this.#result[index];
|
|
70
|
+
return !prev || !require_utils.shallowEqualObjects(result, prev);
|
|
71
|
+
});
|
|
72
|
+
if (!hasStructuralChange && !hasResultChange) return;
|
|
73
|
+
if (hasStructuralChange) {
|
|
74
|
+
this.#observerMatches = newObserverMatches;
|
|
75
|
+
this.#observers = newObservers;
|
|
76
|
+
}
|
|
77
|
+
this.#result = newResult;
|
|
78
|
+
if (!this.hasListeners()) return;
|
|
79
|
+
if (hasStructuralChange) {
|
|
80
|
+
difference(prevObservers, newObservers).forEach((observer) => {
|
|
81
|
+
observer.destroy();
|
|
82
|
+
});
|
|
83
|
+
difference(newObservers, prevObservers).forEach((observer) => {
|
|
84
|
+
observer.subscribe((result) => {
|
|
85
|
+
this.#onUpdate(observer, result);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
this.#notify();
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
getCurrentResult() {
|
|
93
|
+
return this.#result;
|
|
94
|
+
}
|
|
95
|
+
getQueries() {
|
|
96
|
+
return this.#observers.map((observer) => observer.getCurrentQuery());
|
|
97
|
+
}
|
|
98
|
+
getObservers() {
|
|
99
|
+
return this.#observers;
|
|
100
|
+
}
|
|
101
|
+
getOptimisticResult(queries, combine) {
|
|
102
|
+
const matches = this.#findMatchingObservers(queries);
|
|
103
|
+
const result = matches.map((match) => match.observer.getOptimisticResult(match.defaultedQueryOptions));
|
|
104
|
+
const queryHashes = matches.map((match) => match.defaultedQueryOptions.queryHash);
|
|
105
|
+
return [
|
|
106
|
+
result,
|
|
107
|
+
(r) => {
|
|
108
|
+
return this.#combineResult(r ?? result, combine, queryHashes);
|
|
109
|
+
},
|
|
110
|
+
() => {
|
|
111
|
+
return this.#trackResult(result, matches);
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
#trackResult(result, matches) {
|
|
116
|
+
const trackedProps = /* @__PURE__ */ new Set();
|
|
117
|
+
return matches.map((match, index) => {
|
|
118
|
+
const observerResult = result[index];
|
|
119
|
+
return !match.defaultedQueryOptions.notifyOnChangeProps ? match.observer.trackResult(observerResult, (accessedProp) => {
|
|
120
|
+
if (!trackedProps.has(accessedProp)) {
|
|
121
|
+
trackedProps.add(accessedProp);
|
|
122
|
+
matches.forEach((m) => {
|
|
123
|
+
m.observer.trackProp(accessedProp);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}) : observerResult;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
#combineResult(input, combine, queryHashes) {
|
|
130
|
+
if (combine) {
|
|
131
|
+
const lastHashes = this.#lastQueryHashes;
|
|
132
|
+
const queryHashesChanged = queryHashes !== void 0 && lastHashes !== void 0 && (lastHashes.length !== queryHashes.length || queryHashes.some((hash, i) => hash !== lastHashes[i]));
|
|
133
|
+
if (this.#result !== this.#lastResult || queryHashesChanged || combine !== this.#lastCombine) {
|
|
134
|
+
this.#lastCombine = combine;
|
|
135
|
+
this.#lastResult = this.#result;
|
|
136
|
+
if (queryHashes !== void 0) this.#lastQueryHashes = queryHashes;
|
|
137
|
+
this.#combinedResult = require_utils.replaceEqualDeep(this.#combinedResult, combine(input));
|
|
138
|
+
}
|
|
139
|
+
return this.#combinedResult;
|
|
140
|
+
}
|
|
141
|
+
return input;
|
|
142
|
+
}
|
|
143
|
+
#shouldSkipCombine() {
|
|
144
|
+
return !this.#options?.combine || this.#observers.some((observer, index) => {
|
|
145
|
+
return observer.options.suspense && this.#result[index]?.data === void 0;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
#findMatchingObservers(queries) {
|
|
149
|
+
const prevObserversMap = /* @__PURE__ */ new Map();
|
|
150
|
+
this.#observers.forEach((observer) => {
|
|
151
|
+
const key = observer.options.queryHash;
|
|
152
|
+
if (!key) return;
|
|
153
|
+
const previousObservers = prevObserversMap.get(key);
|
|
154
|
+
if (previousObservers) previousObservers.push(observer);
|
|
155
|
+
else prevObserversMap.set(key, [observer]);
|
|
156
|
+
});
|
|
157
|
+
const observers = [];
|
|
158
|
+
queries.forEach((options) => {
|
|
159
|
+
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
160
|
+
const observer = prevObserversMap.get(defaultedOptions.queryHash)?.shift() ?? new require_queryObserver.QueryObserver(this.#client, defaultedOptions);
|
|
161
|
+
observers.push({
|
|
162
|
+
defaultedQueryOptions: defaultedOptions,
|
|
163
|
+
observer
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
return observers;
|
|
167
|
+
}
|
|
168
|
+
#onUpdate(observer, result) {
|
|
169
|
+
const index = this.#observers.indexOf(observer);
|
|
170
|
+
if (index !== -1) {
|
|
171
|
+
this.#result = replaceAt(this.#result, index, result);
|
|
172
|
+
this.#notify();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
#notify() {
|
|
176
|
+
if (this.hasListeners()) {
|
|
177
|
+
const shouldSkipCombine = this.#shouldSkipCombine();
|
|
178
|
+
const previousResult = this.#combinedResult;
|
|
179
|
+
const newResult = shouldSkipCombine ? previousResult : this.#combineResult(this.#trackResult(this.#result, this.#observerMatches), this.#options?.combine);
|
|
180
|
+
if (shouldSkipCombine || previousResult !== newResult) require_notifyManager.notifyManager.batch(() => {
|
|
181
|
+
this.listeners.forEach((listener) => {
|
|
182
|
+
listener(this.#result);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
238
187
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
});
|
|
188
|
+
//#endregion
|
|
189
|
+
exports.QueriesObserver = QueriesObserver;
|
|
190
|
+
|
|
243
191
|
//# sourceMappingURL=queriesObserver.cjs.map
|