@tanstack/query-core 5.91.2 → 5.94.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/package.json +1 -1
  2. package/build/legacy/_tsup-dts-rollup.d.cts +0 -2229
  3. package/build/legacy/_tsup-dts-rollup.d.ts +0 -2229
  4. package/build/legacy/chunk-PXG64RU4.js +0 -25
  5. package/build/legacy/chunk-PXG64RU4.js.map +0 -1
  6. package/build/legacy/environmentManager.cjs +0 -48
  7. package/build/legacy/environmentManager.cjs.map +0 -1
  8. package/build/legacy/environmentManager.d.cts +0 -2
  9. package/build/legacy/environmentManager.d.ts +0 -2
  10. package/build/legacy/environmentManager.js +0 -25
  11. package/build/legacy/environmentManager.js.map +0 -1
  12. package/build/legacy/focusManager.cjs +0 -107
  13. package/build/legacy/focusManager.cjs.map +0 -1
  14. package/build/legacy/focusManager.d.cts +0 -2
  15. package/build/legacy/focusManager.d.ts +0 -2
  16. package/build/legacy/focusManager.js +0 -80
  17. package/build/legacy/focusManager.js.map +0 -1
  18. package/build/legacy/hydration.cjs +0 -178
  19. package/build/legacy/hydration.cjs.map +0 -1
  20. package/build/legacy/hydration.d.cts +0 -7
  21. package/build/legacy/hydration.d.ts +0 -7
  22. package/build/legacy/hydration.js +0 -152
  23. package/build/legacy/hydration.js.map +0 -1
  24. package/build/legacy/index.cjs +0 -113
  25. package/build/legacy/index.cjs.map +0 -1
  26. package/build/legacy/index.d.cts +0 -142
  27. package/build/legacy/index.d.ts +0 -142
  28. package/build/legacy/index.js +0 -75
  29. package/build/legacy/index.js.map +0 -1
  30. package/build/legacy/infiniteQueryBehavior.cjs +0 -146
  31. package/build/legacy/infiniteQueryBehavior.cjs.map +0 -1
  32. package/build/legacy/infiniteQueryBehavior.d.cts +0 -3
  33. package/build/legacy/infiniteQueryBehavior.d.ts +0 -3
  34. package/build/legacy/infiniteQueryBehavior.js +0 -126
  35. package/build/legacy/infiniteQueryBehavior.js.map +0 -1
  36. package/build/legacy/infiniteQueryObserver.cjs +0 -93
  37. package/build/legacy/infiniteQueryObserver.cjs.map +0 -1
  38. package/build/legacy/infiniteQueryObserver.d.cts +0 -1
  39. package/build/legacy/infiniteQueryObserver.d.ts +0 -1
  40. package/build/legacy/infiniteQueryObserver.js +0 -74
  41. package/build/legacy/infiniteQueryObserver.js.map +0 -1
  42. package/build/legacy/mutation.cjs +0 -333
  43. package/build/legacy/mutation.cjs.map +0 -1
  44. package/build/legacy/mutation.d.cts +0 -4
  45. package/build/legacy/mutation.d.ts +0 -4
  46. package/build/legacy/mutation.js +0 -306
  47. package/build/legacy/mutation.js.map +0 -1
  48. package/build/legacy/mutationCache.cjs +0 -170
  49. package/build/legacy/mutationCache.cjs.map +0 -1
  50. package/build/legacy/mutationCache.d.cts +0 -2
  51. package/build/legacy/mutationCache.d.ts +0 -2
  52. package/build/legacy/mutationCache.js +0 -137
  53. package/build/legacy/mutationCache.js.map +0 -1
  54. package/build/legacy/mutationObserver.cjs +0 -190
  55. package/build/legacy/mutationObserver.cjs.map +0 -1
  56. package/build/legacy/mutationObserver.d.cts +0 -1
  57. package/build/legacy/mutationObserver.d.ts +0 -1
  58. package/build/legacy/mutationObserver.js +0 -164
  59. package/build/legacy/mutationObserver.js.map +0 -1
  60. package/build/legacy/notifyManager.cjs +0 -113
  61. package/build/legacy/notifyManager.cjs.map +0 -1
  62. package/build/legacy/notifyManager.d.cts +0 -3
  63. package/build/legacy/notifyManager.d.ts +0 -3
  64. package/build/legacy/notifyManager.js +0 -88
  65. package/build/legacy/notifyManager.js.map +0 -1
  66. package/build/legacy/onlineManager.cjs +0 -96
  67. package/build/legacy/onlineManager.cjs.map +0 -1
  68. package/build/legacy/onlineManager.d.cts +0 -2
  69. package/build/legacy/onlineManager.d.ts +0 -2
  70. package/build/legacy/onlineManager.js +0 -69
  71. package/build/legacy/onlineManager.js.map +0 -1
  72. package/build/legacy/queriesObserver.cjs +0 -260
  73. package/build/legacy/queriesObserver.cjs.map +0 -1
  74. package/build/legacy/queriesObserver.d.cts +0 -2
  75. package/build/legacy/queriesObserver.d.ts +0 -2
  76. package/build/legacy/queriesObserver.js +0 -234
  77. package/build/legacy/queriesObserver.js.map +0 -1
  78. package/build/legacy/query.cjs +0 -487
  79. package/build/legacy/query.cjs.map +0 -1
  80. package/build/legacy/query.d.cts +0 -10
  81. package/build/legacy/query.d.ts +0 -10
  82. package/build/legacy/query.js +0 -468
  83. package/build/legacy/query.js.map +0 -1
  84. package/build/legacy/queryCache.cjs +0 -131
  85. package/build/legacy/queryCache.cjs.map +0 -1
  86. package/build/legacy/queryCache.d.cts +0 -3
  87. package/build/legacy/queryCache.d.ts +0 -3
  88. package/build/legacy/queryCache.js +0 -105
  89. package/build/legacy/queryCache.js.map +0 -1
  90. package/build/legacy/queryClient.cjs +0 -349
  91. package/build/legacy/queryClient.cjs.map +0 -1
  92. package/build/legacy/queryClient.d.cts +0 -1
  93. package/build/legacy/queryClient.d.ts +0 -1
  94. package/build/legacy/queryClient.js +0 -324
  95. package/build/legacy/queryClient.js.map +0 -1
  96. package/build/legacy/queryObserver.cjs +0 -516
  97. package/build/legacy/queryObserver.cjs.map +0 -1
  98. package/build/legacy/queryObserver.d.cts +0 -1
  99. package/build/legacy/queryObserver.d.ts +0 -1
  100. package/build/legacy/queryObserver.js +0 -498
  101. package/build/legacy/queryObserver.js.map +0 -1
  102. package/build/legacy/removable.cjs +0 -70
  103. package/build/legacy/removable.cjs.map +0 -1
  104. package/build/legacy/removable.d.cts +0 -1
  105. package/build/legacy/removable.d.ts +0 -1
  106. package/build/legacy/removable.js +0 -44
  107. package/build/legacy/removable.js.map +0 -1
  108. package/build/legacy/retryer.cjs +0 -166
  109. package/build/legacy/retryer.cjs.map +0 -1
  110. package/build/legacy/retryer.d.cts +0 -7
  111. package/build/legacy/retryer.d.ts +0 -7
  112. package/build/legacy/retryer.js +0 -140
  113. package/build/legacy/retryer.js.map +0 -1
  114. package/build/legacy/streamedQuery.cjs +0 -80
  115. package/build/legacy/streamedQuery.cjs.map +0 -1
  116. package/build/legacy/streamedQuery.d.cts +0 -1
  117. package/build/legacy/streamedQuery.d.ts +0 -1
  118. package/build/legacy/streamedQuery.js +0 -57
  119. package/build/legacy/streamedQuery.js.map +0 -1
  120. package/build/legacy/subscribable.cjs +0 -51
  121. package/build/legacy/subscribable.cjs.map +0 -1
  122. package/build/legacy/subscribable.d.cts +0 -1
  123. package/build/legacy/subscribable.d.ts +0 -1
  124. package/build/legacy/subscribable.js +0 -28
  125. package/build/legacy/subscribable.js.map +0 -1
  126. package/build/legacy/thenable.cjs +0 -76
  127. package/build/legacy/thenable.cjs.map +0 -1
  128. package/build/legacy/thenable.d.cts +0 -6
  129. package/build/legacy/thenable.d.ts +0 -6
  130. package/build/legacy/thenable.js +0 -52
  131. package/build/legacy/thenable.js.map +0 -1
  132. package/build/legacy/timeoutManager.cjs +0 -110
  133. package/build/legacy/timeoutManager.cjs.map +0 -1
  134. package/build/legacy/timeoutManager.d.cts +0 -7
  135. package/build/legacy/timeoutManager.d.ts +0 -7
  136. package/build/legacy/timeoutManager.js +0 -81
  137. package/build/legacy/timeoutManager.js.map +0 -1
  138. package/build/legacy/types.cjs +0 -37
  139. package/build/legacy/types.cjs.map +0 -1
  140. package/build/legacy/types.d.cts +0 -95
  141. package/build/legacy/types.d.ts +0 -95
  142. package/build/legacy/types.js +0 -12
  143. package/build/legacy/types.js.map +0 -1
  144. package/build/legacy/utils.cjs +0 -330
  145. package/build/legacy/utils.cjs.map +0 -1
  146. package/build/legacy/utils.d.cts +0 -30
  147. package/build/legacy/utils.d.ts +0 -30
  148. package/build/legacy/utils.js +0 -283
  149. package/build/legacy/utils.js.map +0 -1
  150. package/build/modern/_tsup-dts-rollup.d.cts +0 -2229
  151. package/build/modern/_tsup-dts-rollup.d.ts +0 -2229
  152. package/build/modern/environmentManager.cjs +0 -48
  153. package/build/modern/environmentManager.cjs.map +0 -1
  154. package/build/modern/environmentManager.d.cts +0 -2
  155. package/build/modern/environmentManager.d.ts +0 -2
  156. package/build/modern/environmentManager.js +0 -23
  157. package/build/modern/environmentManager.js.map +0 -1
  158. package/build/modern/focusManager.cjs +0 -93
  159. package/build/modern/focusManager.cjs.map +0 -1
  160. package/build/modern/focusManager.d.cts +0 -2
  161. package/build/modern/focusManager.d.ts +0 -2
  162. package/build/modern/focusManager.js +0 -67
  163. package/build/modern/focusManager.js.map +0 -1
  164. package/build/modern/hydration.cjs +0 -173
  165. package/build/modern/hydration.cjs.map +0 -1
  166. package/build/modern/hydration.d.cts +0 -7
  167. package/build/modern/hydration.d.ts +0 -7
  168. package/build/modern/hydration.js +0 -145
  169. package/build/modern/hydration.js.map +0 -1
  170. package/build/modern/index.cjs +0 -113
  171. package/build/modern/index.cjs.map +0 -1
  172. package/build/modern/index.d.cts +0 -142
  173. package/build/modern/index.d.ts +0 -142
  174. package/build/modern/index.js +0 -73
  175. package/build/modern/index.js.map +0 -1
  176. package/build/modern/infiniteQueryBehavior.cjs +0 -142
  177. package/build/modern/infiniteQueryBehavior.cjs.map +0 -1
  178. package/build/modern/infiniteQueryBehavior.d.cts +0 -3
  179. package/build/modern/infiniteQueryBehavior.d.ts +0 -3
  180. package/build/modern/infiniteQueryBehavior.js +0 -120
  181. package/build/modern/infiniteQueryBehavior.js.map +0 -1
  182. package/build/modern/infiniteQueryObserver.cjs +0 -92
  183. package/build/modern/infiniteQueryObserver.cjs.map +0 -1
  184. package/build/modern/infiniteQueryObserver.d.cts +0 -1
  185. package/build/modern/infiniteQueryObserver.d.ts +0 -1
  186. package/build/modern/infiniteQueryObserver.js +0 -71
  187. package/build/modern/infiniteQueryObserver.js.map +0 -1
  188. package/build/modern/mutation.cjs +0 -307
  189. package/build/modern/mutation.cjs.map +0 -1
  190. package/build/modern/mutation.d.cts +0 -4
  191. package/build/modern/mutation.d.ts +0 -4
  192. package/build/modern/mutation.js +0 -281
  193. package/build/modern/mutation.js.map +0 -1
  194. package/build/modern/mutationCache.cjs +0 -149
  195. package/build/modern/mutationCache.cjs.map +0 -1
  196. package/build/modern/mutationCache.d.cts +0 -2
  197. package/build/modern/mutationCache.d.ts +0 -2
  198. package/build/modern/mutationCache.js +0 -124
  199. package/build/modern/mutationCache.js.map +0 -1
  200. package/build/modern/mutationObserver.cjs +0 -165
  201. package/build/modern/mutationObserver.cjs.map +0 -1
  202. package/build/modern/mutationObserver.d.cts +0 -1
  203. package/build/modern/mutationObserver.d.ts +0 -1
  204. package/build/modern/mutationObserver.js +0 -140
  205. package/build/modern/mutationObserver.js.map +0 -1
  206. package/build/modern/notifyManager.cjs +0 -113
  207. package/build/modern/notifyManager.cjs.map +0 -1
  208. package/build/modern/notifyManager.d.cts +0 -3
  209. package/build/modern/notifyManager.d.ts +0 -3
  210. package/build/modern/notifyManager.js +0 -86
  211. package/build/modern/notifyManager.js.map +0 -1
  212. package/build/modern/onlineManager.cjs +0 -83
  213. package/build/modern/onlineManager.cjs.map +0 -1
  214. package/build/modern/onlineManager.d.cts +0 -2
  215. package/build/modern/onlineManager.d.ts +0 -2
  216. package/build/modern/onlineManager.js +0 -57
  217. package/build/modern/onlineManager.js.map +0 -1
  218. package/build/modern/queriesObserver.cjs +0 -237
  219. package/build/modern/queriesObserver.cjs.map +0 -1
  220. package/build/modern/queriesObserver.d.cts +0 -2
  221. package/build/modern/queriesObserver.d.ts +0 -2
  222. package/build/modern/queriesObserver.js +0 -212
  223. package/build/modern/queriesObserver.js.map +0 -1
  224. package/build/modern/query.cjs +0 -461
  225. package/build/modern/query.cjs.map +0 -1
  226. package/build/modern/query.d.cts +0 -10
  227. package/build/modern/query.d.ts +0 -10
  228. package/build/modern/query.js +0 -443
  229. package/build/modern/query.js.map +0 -1
  230. package/build/modern/queryCache.cjs +0 -122
  231. package/build/modern/queryCache.cjs.map +0 -1
  232. package/build/modern/queryCache.d.cts +0 -3
  233. package/build/modern/queryCache.d.ts +0 -3
  234. package/build/modern/queryCache.js +0 -97
  235. package/build/modern/queryCache.js.map +0 -1
  236. package/build/modern/queryClient.cjs +0 -322
  237. package/build/modern/queryClient.cjs.map +0 -1
  238. package/build/modern/queryClient.d.cts +0 -1
  239. package/build/modern/queryClient.d.ts +0 -1
  240. package/build/modern/queryClient.js +0 -305
  241. package/build/modern/queryClient.js.map +0 -1
  242. package/build/modern/queryObserver.cjs +0 -489
  243. package/build/modern/queryObserver.cjs.map +0 -1
  244. package/build/modern/queryObserver.d.cts +0 -1
  245. package/build/modern/queryObserver.d.ts +0 -1
  246. package/build/modern/queryObserver.js +0 -472
  247. package/build/modern/queryObserver.js.map +0 -1
  248. package/build/modern/removable.cjs +0 -59
  249. package/build/modern/removable.cjs.map +0 -1
  250. package/build/modern/removable.d.cts +0 -1
  251. package/build/modern/removable.d.ts +0 -1
  252. package/build/modern/removable.js +0 -34
  253. package/build/modern/removable.js.map +0 -1
  254. package/build/modern/retryer.cjs +0 -162
  255. package/build/modern/retryer.cjs.map +0 -1
  256. package/build/modern/retryer.d.cts +0 -7
  257. package/build/modern/retryer.d.ts +0 -7
  258. package/build/modern/retryer.js +0 -134
  259. package/build/modern/retryer.js.map +0 -1
  260. package/build/modern/streamedQuery.cjs +0 -80
  261. package/build/modern/streamedQuery.cjs.map +0 -1
  262. package/build/modern/streamedQuery.d.cts +0 -1
  263. package/build/modern/streamedQuery.d.ts +0 -1
  264. package/build/modern/streamedQuery.js +0 -55
  265. package/build/modern/streamedQuery.js.map +0 -1
  266. package/build/modern/subscribable.cjs +0 -51
  267. package/build/modern/subscribable.cjs.map +0 -1
  268. package/build/modern/subscribable.d.cts +0 -1
  269. package/build/modern/subscribable.d.ts +0 -1
  270. package/build/modern/subscribable.js +0 -26
  271. package/build/modern/subscribable.js.map +0 -1
  272. package/build/modern/thenable.cjs +0 -75
  273. package/build/modern/thenable.cjs.map +0 -1
  274. package/build/modern/thenable.d.cts +0 -6
  275. package/build/modern/thenable.d.ts +0 -6
  276. package/build/modern/thenable.js +0 -49
  277. package/build/modern/thenable.js.map +0 -1
  278. package/build/modern/timeoutManager.cjs +0 -98
  279. package/build/modern/timeoutManager.cjs.map +0 -1
  280. package/build/modern/timeoutManager.d.cts +0 -7
  281. package/build/modern/timeoutManager.d.ts +0 -7
  282. package/build/modern/timeoutManager.js +0 -70
  283. package/build/modern/timeoutManager.js.map +0 -1
  284. package/build/modern/types.cjs +0 -37
  285. package/build/modern/types.cjs.map +0 -1
  286. package/build/modern/types.d.cts +0 -95
  287. package/build/modern/types.d.ts +0 -95
  288. package/build/modern/types.js +0 -10
  289. package/build/modern/types.js.map +0 -1
  290. package/build/modern/utils.cjs +0 -330
  291. package/build/modern/utils.cjs.map +0 -1
  292. package/build/modern/utils.d.cts +0 -30
  293. package/build/modern/utils.d.ts +0 -30
  294. package/build/modern/utils.js +0 -281
  295. package/build/modern/utils.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/mutationObserver.ts"],"sourcesContent":["import { getDefaultState } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport { Subscribable } from './subscribable'\nimport { hashKey, shallowEqualObjects } from './utils'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n MutateOptions,\n MutationFunctionContext,\n MutationObserverOptions,\n MutationObserverResult,\n} from './types'\nimport type { Action, Mutation } from './mutation'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TOnMutateResult> = (\n result: MutationObserverResult<TData, TError, TVariables, TOnMutateResult>,\n) => void\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> extends Subscribable<\n MutationObserverListener<TData, TError, TVariables, TOnMutateResult>\n> {\n options!: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>\n\n #client: QueryClient\n #currentResult: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n > = undefined!\n #currentMutation?: Mutation<TData, TError, TVariables, TOnMutateResult>\n #mutateOptions?: MutateOptions<TData, TError, TVariables, TOnMutateResult>\n\n constructor(\n client: QueryClient,\n options: MutationObserverOptions<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >,\n ) {\n super()\n\n this.#client = client\n this.setOptions(options)\n this.bindMethods()\n this.#updateResult()\n }\n\n protected bindMethods(): void {\n this.mutate = this.mutate.bind(this)\n this.reset = this.reset.bind(this)\n }\n\n setOptions(\n options: MutationObserverOptions<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >,\n ) {\n const prevOptions = this.options as\n | MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>\n | undefined\n this.options = this.#client.defaultMutationOptions(options)\n if (!shallowEqualObjects(this.options, prevOptions)) {\n this.#client.getMutationCache().notify({\n type: 'observerOptionsUpdated',\n mutation: this.#currentMutation,\n observer: this,\n })\n }\n\n if (\n prevOptions?.mutationKey &&\n this.options.mutationKey &&\n hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)\n ) {\n this.reset()\n } else if (this.#currentMutation?.state.status === 'pending') {\n this.#currentMutation.setOptions(this.options)\n }\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.#currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(\n action: Action<TData, TError, TVariables, TOnMutateResult>,\n ): void {\n this.#updateResult()\n\n this.#notify(action)\n }\n\n getCurrentResult(): MutationObserverResult<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n > {\n return this.#currentResult\n }\n\n reset(): void {\n // reset needs to remove the observer from the mutation because there is no way to \"get it back\"\n // another mutate call will yield a new mutation!\n this.#currentMutation?.removeObserver(this)\n this.#currentMutation = undefined\n this.#updateResult()\n this.#notify()\n }\n\n mutate(\n variables: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>,\n ): Promise<TData> {\n this.#mutateOptions = options\n\n this.#currentMutation?.removeObserver(this)\n\n this.#currentMutation = this.#client\n .getMutationCache()\n .build(this.#client, this.options)\n\n this.#currentMutation.addObserver(this)\n\n return this.#currentMutation.execute(variables)\n }\n\n #updateResult(): void {\n const state =\n this.#currentMutation?.state ??\n getDefaultState<TData, TError, TVariables, TOnMutateResult>()\n\n this.#currentResult = {\n ...state,\n isPending: state.status === 'pending',\n isSuccess: state.status === 'success',\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n mutate: this.mutate,\n reset: this.reset,\n } as MutationObserverResult<TData, TError, TVariables, TOnMutateResult>\n }\n\n #notify(action?: Action<TData, TError, TVariables, TOnMutateResult>): void {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.#mutateOptions && this.hasListeners()) {\n const variables = this.#currentResult.variables!\n const onMutateResult = this.#currentResult.context\n\n const context = {\n client: this.#client,\n meta: this.options.meta,\n mutationKey: this.options.mutationKey,\n } satisfies MutationFunctionContext\n\n if (action?.type === 'success') {\n try {\n this.#mutateOptions.onSuccess?.(\n action.data,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n try {\n this.#mutateOptions.onSettled?.(\n action.data,\n null,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n } else if (action?.type === 'error') {\n try {\n this.#mutateOptions.onError?.(\n action.error,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n try {\n this.#mutateOptions.onSettled?.(\n undefined,\n action.error,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n }\n }\n\n // Then trigger the listeners\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n })\n }\n}\n"],"mappings":"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","names":[]}
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
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/notifyManager.ts
21
- var notifyManager_exports = {};
22
- __export(notifyManager_exports, {
23
- createNotifyManager: () => createNotifyManager,
24
- defaultScheduler: () => defaultScheduler,
25
- notifyManager: () => notifyManager
26
- });
27
- module.exports = __toCommonJS(notifyManager_exports);
28
- var import_timeoutManager = require("./timeoutManager.cjs");
29
- var defaultScheduler = import_timeoutManager.systemSetTimeoutZero;
30
- function createNotifyManager() {
31
- let queue = [];
32
- let transactions = 0;
33
- let notifyFn = (callback) => {
34
- callback();
35
- };
36
- let batchNotifyFn = (callback) => {
37
- callback();
38
- };
39
- let scheduleFn = defaultScheduler;
40
- const schedule = (callback) => {
41
- if (transactions) {
42
- queue.push(callback);
43
- } else {
44
- scheduleFn(() => {
45
- notifyFn(callback);
46
- });
47
- }
48
- };
49
- const flush = () => {
50
- const originalQueue = queue;
51
- queue = [];
52
- if (originalQueue.length) {
53
- scheduleFn(() => {
54
- batchNotifyFn(() => {
55
- originalQueue.forEach((callback) => {
56
- notifyFn(callback);
57
- });
58
- });
59
- });
60
- }
61
- };
62
- return {
63
- batch: (callback) => {
64
- let result;
65
- transactions++;
66
- try {
67
- result = callback();
68
- } finally {
69
- transactions--;
70
- if (!transactions) {
71
- flush();
72
- }
73
- }
74
- return result;
75
- },
76
- /**
77
- * All calls to the wrapped function will be batched.
78
- */
79
- batchCalls: (callback) => {
80
- return (...args) => {
81
- schedule(() => {
82
- callback(...args);
83
- });
84
- };
85
- },
86
- schedule,
87
- /**
88
- * Use this method to set a custom notify function.
89
- * This can be used to for example wrap notifications with `React.act` while running tests.
90
- */
91
- setNotifyFunction: (fn) => {
92
- notifyFn = fn;
93
- },
94
- /**
95
- * Use this method to set a custom function to batch notifications together into a single tick.
96
- * By default React Query will use the batch function provided by ReactDOM or React Native.
97
- */
98
- setBatchNotifyFunction: (fn) => {
99
- batchNotifyFn = fn;
100
- },
101
- setScheduler: (fn) => {
102
- scheduleFn = fn;
103
- }
104
- };
105
- }
106
- var notifyManager = createNotifyManager();
107
- // Annotate the CommonJS export names for ESM import in node:
108
- 0 && (module.exports = {
109
- createNotifyManager,
110
- defaultScheduler,
111
- notifyManager
112
- });
113
- //# sourceMappingURL=notifyManager.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\nimport { systemSetTimeoutZero } from './timeoutManager'\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport const defaultScheduler: ScheduleFunction = systemSetTimeoutZero\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn = defaultScheduler\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,4BAAqC;AAY9B,IAAM,mBAAqC;AAE3C,SAAS,sBAAsB;AACpC,MAAI,QAA+B,CAAC;AACpC,MAAI,eAAe;AACnB,MAAI,WAA2B,CAAC,aAAa;AAC3C,aAAS;AAAA,EACX;AACA,MAAI,gBAAqC,CAAC,aAAyB;AACjE,aAAS;AAAA,EACX;AACA,MAAI,aAAa;AAEjB,QAAM,WAAW,CAAC,aAAmC;AACnD,QAAI,cAAc;AAChB,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AACL,iBAAW,MAAM;AACf,iBAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AACA,QAAM,QAAQ,MAAY;AACxB,UAAM,gBAAgB;AACtB,YAAQ,CAAC;AACT,QAAI,cAAc,QAAQ;AACxB,iBAAW,MAAM;AACf,sBAAc,MAAM;AAClB,wBAAc,QAAQ,CAAC,aAAa;AAClC,qBAAS,QAAQ;AAAA,UACnB,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,CAAI,aAAyB;AAClC,UAAI;AACJ;AACA,UAAI;AACF,iBAAS,SAAS;AAAA,MACpB,UAAE;AACA;AACA,YAAI,CAAC,cAAc;AACjB,gBAAM;AAAA,QACR;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAIA,YAAY,CACV,aAC0B;AAC1B,aAAO,IAAI,SAAS;AAClB,iBAAS,MAAM;AACb,mBAAS,GAAG,IAAI;AAAA,QAClB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,mBAAmB,CAAC,OAAuB;AACzC,iBAAW;AAAA,IACb;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,wBAAwB,CAAC,OAA4B;AACnD,sBAAgB;AAAA,IAClB;AAAA,IACA,cAAc,CAAC,OAAyB;AACtC,mBAAa;AAAA,IACf;AAAA,EACF;AACF;AAGO,IAAM,gBAAgB,oBAAoB;","names":[]}
@@ -1,3 +0,0 @@
1
- export { createNotifyManager } from './_tsup-dts-rollup.cjs';
2
- export { defaultScheduler_alias_1 as defaultScheduler } from './_tsup-dts-rollup.cjs';
3
- export { notifyManager_alias_1 as notifyManager } from './_tsup-dts-rollup.cjs';
@@ -1,3 +0,0 @@
1
- export { createNotifyManager } from './_tsup-dts-rollup.js';
2
- export { defaultScheduler_alias_1 as defaultScheduler } from './_tsup-dts-rollup.js';
3
- export { notifyManager_alias_1 as notifyManager } from './_tsup-dts-rollup.js';
@@ -1,86 +0,0 @@
1
- // src/notifyManager.ts
2
- import { systemSetTimeoutZero } from "./timeoutManager.js";
3
- var defaultScheduler = systemSetTimeoutZero;
4
- function createNotifyManager() {
5
- let queue = [];
6
- let transactions = 0;
7
- let notifyFn = (callback) => {
8
- callback();
9
- };
10
- let batchNotifyFn = (callback) => {
11
- callback();
12
- };
13
- let scheduleFn = defaultScheduler;
14
- const schedule = (callback) => {
15
- if (transactions) {
16
- queue.push(callback);
17
- } else {
18
- scheduleFn(() => {
19
- notifyFn(callback);
20
- });
21
- }
22
- };
23
- const flush = () => {
24
- const originalQueue = queue;
25
- queue = [];
26
- if (originalQueue.length) {
27
- scheduleFn(() => {
28
- batchNotifyFn(() => {
29
- originalQueue.forEach((callback) => {
30
- notifyFn(callback);
31
- });
32
- });
33
- });
34
- }
35
- };
36
- return {
37
- batch: (callback) => {
38
- let result;
39
- transactions++;
40
- try {
41
- result = callback();
42
- } finally {
43
- transactions--;
44
- if (!transactions) {
45
- flush();
46
- }
47
- }
48
- return result;
49
- },
50
- /**
51
- * All calls to the wrapped function will be batched.
52
- */
53
- batchCalls: (callback) => {
54
- return (...args) => {
55
- schedule(() => {
56
- callback(...args);
57
- });
58
- };
59
- },
60
- schedule,
61
- /**
62
- * Use this method to set a custom notify function.
63
- * This can be used to for example wrap notifications with `React.act` while running tests.
64
- */
65
- setNotifyFunction: (fn) => {
66
- notifyFn = fn;
67
- },
68
- /**
69
- * Use this method to set a custom function to batch notifications together into a single tick.
70
- * By default React Query will use the batch function provided by ReactDOM or React Native.
71
- */
72
- setBatchNotifyFunction: (fn) => {
73
- batchNotifyFn = fn;
74
- },
75
- setScheduler: (fn) => {
76
- scheduleFn = fn;
77
- }
78
- };
79
- }
80
- var notifyManager = createNotifyManager();
81
- export {
82
- createNotifyManager,
83
- defaultScheduler,
84
- notifyManager
85
- };
86
- //# sourceMappingURL=notifyManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\nimport { systemSetTimeoutZero } from './timeoutManager'\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport const defaultScheduler: ScheduleFunction = systemSetTimeoutZero\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn = defaultScheduler\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";AAEA,SAAS,4BAA4B;AAY9B,IAAM,mBAAqC;AAE3C,SAAS,sBAAsB;AACpC,MAAI,QAA+B,CAAC;AACpC,MAAI,eAAe;AACnB,MAAI,WAA2B,CAAC,aAAa;AAC3C,aAAS;AAAA,EACX;AACA,MAAI,gBAAqC,CAAC,aAAyB;AACjE,aAAS;AAAA,EACX;AACA,MAAI,aAAa;AAEjB,QAAM,WAAW,CAAC,aAAmC;AACnD,QAAI,cAAc;AAChB,YAAM,KAAK,QAAQ;AAAA,IACrB,OAAO;AACL,iBAAW,MAAM;AACf,iBAAS,QAAQ;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AACA,QAAM,QAAQ,MAAY;AACxB,UAAM,gBAAgB;AACtB,YAAQ,CAAC;AACT,QAAI,cAAc,QAAQ;AACxB,iBAAW,MAAM;AACf,sBAAc,MAAM;AAClB,wBAAc,QAAQ,CAAC,aAAa;AAClC,qBAAS,QAAQ;AAAA,UACnB,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,CAAI,aAAyB;AAClC,UAAI;AACJ;AACA,UAAI;AACF,iBAAS,SAAS;AAAA,MACpB,UAAE;AACA;AACA,YAAI,CAAC,cAAc;AACjB,gBAAM;AAAA,QACR;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAIA,YAAY,CACV,aAC0B;AAC1B,aAAO,IAAI,SAAS;AAClB,iBAAS,MAAM;AACb,mBAAS,GAAG,IAAI;AAAA,QAClB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,mBAAmB,CAAC,OAAuB;AACzC,iBAAW;AAAA,IACb;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,wBAAwB,CAAC,OAA4B;AACnD,sBAAgB;AAAA,IAClB;AAAA,IACA,cAAc,CAAC,OAAyB;AACtC,mBAAa;AAAA,IACf;AAAA,EACF;AACF;AAGO,IAAM,gBAAgB,oBAAoB;","names":[]}
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
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/onlineManager.ts
21
- var onlineManager_exports = {};
22
- __export(onlineManager_exports, {
23
- OnlineManager: () => OnlineManager,
24
- onlineManager: () => onlineManager
25
- });
26
- module.exports = __toCommonJS(onlineManager_exports);
27
- var import_subscribable = require("./subscribable.cjs");
28
- var OnlineManager = class extends import_subscribable.Subscribable {
29
- #online = true;
30
- #cleanup;
31
- #setup;
32
- constructor() {
33
- super();
34
- this.#setup = (onOnline) => {
35
- if (typeof window !== "undefined" && window.addEventListener) {
36
- const onlineListener = () => onOnline(true);
37
- const offlineListener = () => onOnline(false);
38
- window.addEventListener("online", onlineListener, false);
39
- window.addEventListener("offline", offlineListener, false);
40
- return () => {
41
- window.removeEventListener("online", onlineListener);
42
- window.removeEventListener("offline", offlineListener);
43
- };
44
- }
45
- return;
46
- };
47
- }
48
- onSubscribe() {
49
- if (!this.#cleanup) {
50
- this.setEventListener(this.#setup);
51
- }
52
- }
53
- onUnsubscribe() {
54
- if (!this.hasListeners()) {
55
- this.#cleanup?.();
56
- this.#cleanup = void 0;
57
- }
58
- }
59
- setEventListener(setup) {
60
- this.#setup = setup;
61
- this.#cleanup?.();
62
- this.#cleanup = setup(this.setOnline.bind(this));
63
- }
64
- setOnline(online) {
65
- const changed = this.#online !== online;
66
- if (changed) {
67
- this.#online = online;
68
- this.listeners.forEach((listener) => {
69
- listener(online);
70
- });
71
- }
72
- }
73
- isOnline() {
74
- return this.#online;
75
- }
76
- };
77
- var onlineManager = new OnlineManager();
78
- // Annotate the CommonJS export names for ESM import in node:
79
- 0 && (module.exports = {
80
- OnlineManager,
81
- onlineManager
82
- });
83
- //# sourceMappingURL=onlineManager.cjs.map
@@ -1 +0,0 @@
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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAKtB,IAAM,gBAAN,cAA4B,iCAAuB;AAAA,EACxD,UAAU;AAAA,EACV;AAAA,EAEA;AAAA,EAEA,cAAc;AACZ,UAAM;AACN,SAAK,SAAS,CAAC,aAAa;AAG1B,UAAI,OAAO,WAAW,eAAe,OAAO,kBAAkB;AAC5D,cAAM,iBAAiB,MAAM,SAAS,IAAI;AAC1C,cAAM,kBAAkB,MAAM,SAAS,KAAK;AAE5C,eAAO,iBAAiB,UAAU,gBAAgB,KAAK;AACvD,eAAO,iBAAiB,WAAW,iBAAiB,KAAK;AAEzD,eAAO,MAAM;AAEX,iBAAO,oBAAoB,UAAU,cAAc;AACnD,iBAAO,oBAAoB,WAAW,eAAe;AAAA,QACvD;AAAA,MACF;AAEA;AAAA,IACF;AAAA,EACF;AAAA,EAEU,cAAoB;AAC5B,QAAI,CAAC,KAAK,UAAU;AAClB,WAAK,iBAAiB,KAAK,MAAM;AAAA,IACnC;AAAA,EACF;AAAA,EAEU,gBAAgB;AACxB,QAAI,CAAC,KAAK,aAAa,GAAG;AACxB,WAAK,WAAW;AAChB,WAAK,WAAW;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,iBAAiB,OAAsB;AACrC,SAAK,SAAS;AACd,SAAK,WAAW;AAChB,SAAK,WAAW,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC;AAAA,EACjD;AAAA,EAEA,UAAU,QAAuB;AAC/B,UAAM,UAAU,KAAK,YAAY;AAEjC,QAAI,SAAS;AACX,WAAK,UAAU;AACf,WAAK,UAAU,QAAQ,CAAC,aAAa;AACnC,iBAAS,MAAM;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,WAAoB;AAClB,WAAO,KAAK;AAAA,EACd;AACF;AAEO,IAAM,gBAAgB,IAAI,cAAc;","names":[]}
@@ -1,2 +0,0 @@
1
- export { OnlineManager } from './_tsup-dts-rollup.cjs';
2
- export { onlineManager_alias_1 as onlineManager } from './_tsup-dts-rollup.cjs';
@@ -1,2 +0,0 @@
1
- export { OnlineManager } from './_tsup-dts-rollup.js';
2
- export { onlineManager_alias_1 as onlineManager } from './_tsup-dts-rollup.js';
@@ -1,57 +0,0 @@
1
- // src/onlineManager.ts
2
- import { Subscribable } from "./subscribable.js";
3
- var OnlineManager = class extends Subscribable {
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
- return;
21
- };
22
- }
23
- onSubscribe() {
24
- if (!this.#cleanup) {
25
- this.setEventListener(this.#setup);
26
- }
27
- }
28
- onUnsubscribe() {
29
- if (!this.hasListeners()) {
30
- this.#cleanup?.();
31
- this.#cleanup = void 0;
32
- }
33
- }
34
- setEventListener(setup) {
35
- this.#setup = setup;
36
- this.#cleanup?.();
37
- this.#cleanup = setup(this.setOnline.bind(this));
38
- }
39
- setOnline(online) {
40
- const changed = this.#online !== online;
41
- if (changed) {
42
- this.#online = online;
43
- this.listeners.forEach((listener) => {
44
- listener(online);
45
- });
46
- }
47
- }
48
- isOnline() {
49
- return this.#online;
50
- }
51
- };
52
- var onlineManager = new OnlineManager();
53
- export {
54
- OnlineManager,
55
- onlineManager
56
- };
57
- //# sourceMappingURL=onlineManager.js.map
@@ -1 +0,0 @@
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":";AAAA,SAAS,oBAAoB;AAKtB,IAAM,gBAAN,cAA4B,aAAuB;AAAA,EACxD,UAAU;AAAA,EACV;AAAA,EAEA;AAAA,EAEA,cAAc;AACZ,UAAM;AACN,SAAK,SAAS,CAAC,aAAa;AAG1B,UAAI,OAAO,WAAW,eAAe,OAAO,kBAAkB;AAC5D,cAAM,iBAAiB,MAAM,SAAS,IAAI;AAC1C,cAAM,kBAAkB,MAAM,SAAS,KAAK;AAE5C,eAAO,iBAAiB,UAAU,gBAAgB,KAAK;AACvD,eAAO,iBAAiB,WAAW,iBAAiB,KAAK;AAEzD,eAAO,MAAM;AAEX,iBAAO,oBAAoB,UAAU,cAAc;AACnD,iBAAO,oBAAoB,WAAW,eAAe;AAAA,QACvD;AAAA,MACF;AAEA;AAAA,IACF;AAAA,EACF;AAAA,EAEU,cAAoB;AAC5B,QAAI,CAAC,KAAK,UAAU;AAClB,WAAK,iBAAiB,KAAK,MAAM;AAAA,IACnC;AAAA,EACF;AAAA,EAEU,gBAAgB;AACxB,QAAI,CAAC,KAAK,aAAa,GAAG;AACxB,WAAK,WAAW;AAChB,WAAK,WAAW;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,iBAAiB,OAAsB;AACrC,SAAK,SAAS;AACd,SAAK,WAAW;AAChB,SAAK,WAAW,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC;AAAA,EACjD;AAAA,EAEA,UAAU,QAAuB;AAC/B,UAAM,UAAU,KAAK,YAAY;AAEjC,QAAI,SAAS;AACX,WAAK,UAAU;AACf,WAAK,UAAU,QAAQ,CAAC,aAAa;AACnC,iBAAS,MAAM;AAAA,MACjB,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,WAAoB;AAClB,WAAO,KAAK;AAAA,EACd;AACF;AAEO,IAAM,gBAAgB,IAAI,cAAc;","names":[]}
@@ -1,237 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
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");
30
- function difference(array1, array2) {
31
- const excludeSet = new Set(array2);
32
- return array1.filter((x) => !excludeSet.has(x));
33
- }
34
- function replaceAt(array, index, value) {
35
- const copy = array.slice(0);
36
- copy[index] = value;
37
- return copy;
38
- }
39
- var QueriesObserver = class extends import_subscribable.Subscribable {
40
- #client;
41
- #result;
42
- #queries;
43
- #options;
44
- #observers;
45
- #combinedResult;
46
- #lastCombine;
47
- #lastResult;
48
- #lastQueryHashes;
49
- #observerMatches = [];
50
- constructor(client, queries, options) {
51
- super();
52
- this.#client = client;
53
- this.#options = options;
54
- this.#queries = [];
55
- this.#observers = [];
56
- this.#result = [];
57
- this.setQueries(queries);
58
- }
59
- onSubscribe() {
60
- if (this.listeners.size === 1) {
61
- this.#observers.forEach((observer) => {
62
- observer.subscribe((result) => {
63
- this.#onUpdate(observer, result);
64
- });
65
- });
66
- }
67
- }
68
- onUnsubscribe() {
69
- if (!this.listeners.size) {
70
- this.destroy();
71
- }
72
- }
73
- destroy() {
74
- this.listeners = /* @__PURE__ */ new Set();
75
- this.#observers.forEach((observer) => {
76
- observer.destroy();
77
- });
78
- }
79
- setQueries(queries, options) {
80
- this.#queries = queries;
81
- this.#options = options;
82
- if (process.env.NODE_ENV !== "production") {
83
- const queryHashes = queries.map(
84
- (query) => this.#client.defaultQueryOptions(query).queryHash
85
- );
86
- if (new Set(queryHashes).size !== queryHashes.length) {
87
- console.warn(
88
- "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
89
- );
90
- }
91
- }
92
- import_notifyManager.notifyManager.batch(() => {
93
- const prevObservers = this.#observers;
94
- const newObserverMatches = this.#findMatchingObservers(this.#queries);
95
- newObserverMatches.forEach(
96
- (match) => match.observer.setOptions(match.defaultedQueryOptions)
97
- );
98
- const newObservers = newObserverMatches.map((match) => match.observer);
99
- const newResult = newObservers.map(
100
- (observer) => observer.getCurrentResult()
101
- );
102
- const hasLengthChange = prevObservers.length !== newObservers.length;
103
- const hasIndexChange = newObservers.some(
104
- (observer, index) => observer !== prevObservers[index]
105
- );
106
- const hasStructuralChange = hasLengthChange || hasIndexChange;
107
- const hasResultChange = hasStructuralChange ? true : newResult.some((result, index) => {
108
- const prev = this.#result[index];
109
- return !prev || !(0, import_utils.shallowEqualObjects)(result, prev);
110
- });
111
- if (!hasStructuralChange && !hasResultChange) return;
112
- if (hasStructuralChange) {
113
- this.#observerMatches = newObserverMatches;
114
- this.#observers = newObservers;
115
- }
116
- this.#result = newResult;
117
- if (!this.hasListeners()) return;
118
- if (hasStructuralChange) {
119
- difference(prevObservers, newObservers).forEach((observer) => {
120
- observer.destroy();
121
- });
122
- difference(newObservers, prevObservers).forEach((observer) => {
123
- observer.subscribe((result) => {
124
- this.#onUpdate(observer, result);
125
- });
126
- });
127
- }
128
- this.#notify();
129
- });
130
- }
131
- getCurrentResult() {
132
- return this.#result;
133
- }
134
- getQueries() {
135
- return this.#observers.map((observer) => observer.getCurrentQuery());
136
- }
137
- getObservers() {
138
- return this.#observers;
139
- }
140
- getOptimisticResult(queries, combine) {
141
- const matches = this.#findMatchingObservers(queries);
142
- const result = matches.map(
143
- (match) => match.observer.getOptimisticResult(match.defaultedQueryOptions)
144
- );
145
- const queryHashes = matches.map(
146
- (match) => match.defaultedQueryOptions.queryHash
147
- );
148
- return [
149
- result,
150
- (r) => {
151
- return this.#combineResult(r ?? result, combine, queryHashes);
152
- },
153
- () => {
154
- return this.#trackResult(result, matches);
155
- }
156
- ];
157
- }
158
- #trackResult(result, matches) {
159
- return matches.map((match, index) => {
160
- const observerResult = result[index];
161
- return !match.defaultedQueryOptions.notifyOnChangeProps ? match.observer.trackResult(observerResult, (accessedProp) => {
162
- matches.forEach((m) => {
163
- m.observer.trackProp(accessedProp);
164
- });
165
- }) : observerResult;
166
- });
167
- }
168
- #combineResult(input, combine, queryHashes) {
169
- if (combine) {
170
- const lastHashes = this.#lastQueryHashes;
171
- const queryHashesChanged = queryHashes !== void 0 && lastHashes !== void 0 && (lastHashes.length !== queryHashes.length || queryHashes.some((hash, i) => hash !== lastHashes[i]));
172
- if (!this.#combinedResult || this.#result !== this.#lastResult || queryHashesChanged || combine !== this.#lastCombine) {
173
- this.#lastCombine = combine;
174
- this.#lastResult = this.#result;
175
- if (queryHashes !== void 0) {
176
- this.#lastQueryHashes = queryHashes;
177
- }
178
- this.#combinedResult = (0, import_utils.replaceEqualDeep)(
179
- this.#combinedResult,
180
- combine(input)
181
- );
182
- }
183
- return this.#combinedResult;
184
- }
185
- return input;
186
- }
187
- #findMatchingObservers(queries) {
188
- const prevObserversMap = /* @__PURE__ */ new Map();
189
- this.#observers.forEach((observer) => {
190
- const key = observer.options.queryHash;
191
- if (!key) return;
192
- const previousObservers = prevObserversMap.get(key);
193
- if (previousObservers) {
194
- previousObservers.push(observer);
195
- } else {
196
- prevObserversMap.set(key, [observer]);
197
- }
198
- });
199
- const observers = [];
200
- queries.forEach((options) => {
201
- const defaultedOptions = this.#client.defaultQueryOptions(options);
202
- const match = prevObserversMap.get(defaultedOptions.queryHash)?.shift();
203
- const observer = match ?? new import_queryObserver.QueryObserver(this.#client, defaultedOptions);
204
- observers.push({
205
- defaultedQueryOptions: defaultedOptions,
206
- observer
207
- });
208
- });
209
- return observers;
210
- }
211
- #onUpdate(observer, result) {
212
- const index = this.#observers.indexOf(observer);
213
- if (index !== -1) {
214
- this.#result = replaceAt(this.#result, index, result);
215
- this.#notify();
216
- }
217
- }
218
- #notify() {
219
- if (this.hasListeners()) {
220
- const previousResult = this.#combinedResult;
221
- const newTracked = this.#trackResult(this.#result, this.#observerMatches);
222
- const newResult = this.#combineResult(newTracked, this.#options?.combine);
223
- if (previousResult !== newResult) {
224
- import_notifyManager.notifyManager.batch(() => {
225
- this.listeners.forEach((listener) => {
226
- listener(this.#result);
227
- });
228
- });
229
- }
230
- }
231
- }
232
- };
233
- // Annotate the CommonJS export names for ESM import in node:
234
- 0 && (module.exports = {
235
- QueriesObserver
236
- });
237
- //# sourceMappingURL=queriesObserver.cjs.map