@ventlio/tanstack-query 0.5.6 → 0.5.8

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 (105) hide show
  1. package/dist/_virtual/index.js +8 -0
  2. package/dist/{index.js.map → _virtual/index.js.map} +1 -1
  3. package/dist/_virtual/use-sync-external-store-shim.development.js +4 -0
  4. package/dist/_virtual/use-sync-external-store-shim.development.js.map +1 -0
  5. package/dist/_virtual/use-sync-external-store-shim.production.js +4 -0
  6. package/dist/_virtual/use-sync-external-store-shim.production.js.map +1 -0
  7. package/dist/_virtual/with-selector.development.js +4 -0
  8. package/dist/_virtual/with-selector.development.js.map +1 -0
  9. package/dist/_virtual/with-selector.js +8 -0
  10. package/dist/_virtual/with-selector.js.map +1 -0
  11. package/dist/_virtual/with-selector.production.js +4 -0
  12. package/dist/_virtual/with-selector.production.js.map +1 -0
  13. package/dist/config/bootStore.d.ts +3 -0
  14. package/dist/config/bootstrapQueryRequest.d.ts +1 -1
  15. package/dist/config/index.d.ts +0 -1
  16. package/dist/index.mjs +724 -49
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/node_modules/@tanstack/react-store/dist/esm/index.js +48 -0
  19. package/dist/node_modules/@tanstack/react-store/dist/esm/index.js.map +1 -0
  20. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +110 -0
  21. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -0
  22. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +98 -0
  23. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js.map +1 -0
  24. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +107 -0
  25. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
  26. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +78 -0
  27. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +1 -0
  28. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/shim/index.js +22 -0
  29. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/shim/index.js.map +1 -0
  30. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/shim/with-selector.js +13 -0
  31. package/dist/node_modules/@tanstack/react-store/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -0
  32. package/dist/node_modules/@tanstack/store/dist/esm/derived.js +119 -0
  33. package/dist/node_modules/@tanstack/store/dist/esm/derived.js.map +1 -0
  34. package/dist/node_modules/@tanstack/store/dist/esm/scheduler.js +88 -0
  35. package/dist/node_modules/@tanstack/store/dist/esm/scheduler.js.map +1 -0
  36. package/dist/node_modules/@tanstack/store/dist/esm/store.js +29 -0
  37. package/dist/node_modules/@tanstack/store/dist/esm/store.js.map +1 -0
  38. package/dist/src/config/bootStore.js +16 -0
  39. package/dist/src/config/bootStore.js.map +1 -0
  40. package/dist/src/config/bootstrapQueryRequest.js +11 -0
  41. package/dist/{config → src/config}/bootstrapQueryRequest.js.map +1 -1
  42. package/dist/src/config/useReactNativeEnv.js +13 -0
  43. package/dist/{config → src/config}/useReactNativeEnv.js.map +1 -1
  44. package/dist/{index.js → src/index.js} +0 -1
  45. package/dist/src/index.js.map +1 -0
  46. package/dist/{model → src/model}/useQueryModel.js +4 -7
  47. package/dist/{model → src/model}/useQueryModel.js.map +1 -1
  48. package/dist/{queries → src/queries}/useDeleteRequest.js +5 -4
  49. package/dist/{queries → src/queries}/useDeleteRequest.js.map +1 -1
  50. package/dist/{queries → src/queries}/useGetInfiniteRequest.js +5 -4
  51. package/dist/{queries → src/queries}/useGetInfiniteRequest.js.map +1 -1
  52. package/dist/{queries → src/queries}/useGetRequest.js +5 -4
  53. package/dist/{queries → src/queries}/useGetRequest.js.map +1 -1
  54. package/dist/{queries → src/queries}/usePatchRequest.js +7 -6
  55. package/dist/{queries → src/queries}/usePatchRequest.js.map +1 -1
  56. package/dist/{queries → src/queries}/usePostRequest.js +7 -6
  57. package/dist/{queries → src/queries}/usePostRequest.js.map +1 -1
  58. package/dist/types/index.d.ts +14 -3
  59. package/package.json +2 -1
  60. package/src/config/bootStore.ts +14 -0
  61. package/src/config/bootstrapQueryRequest.ts +4 -15
  62. package/src/config/index.ts +0 -1
  63. package/src/config/useReactNativeEnv.ts +6 -5
  64. package/src/model/useQueryModel.ts +4 -4
  65. package/src/queries/useDeleteRequest.ts +16 -7
  66. package/src/queries/useGetInfiniteRequest.ts +16 -7
  67. package/src/queries/useGetRequest.ts +16 -7
  68. package/src/queries/usePatchRequest.ts +9 -8
  69. package/src/queries/usePostRequest.ts +15 -10
  70. package/src/queries/usePutRequest.ts +15 -10
  71. package/src/types/index.ts +15 -3
  72. package/dist/config/bootstrapQueryRequest.js +0 -21
  73. package/dist/config/useQueryConfig.d.ts +0 -2
  74. package/dist/config/useQueryConfig.js +0 -11
  75. package/dist/config/useQueryConfig.js.map +0 -1
  76. package/dist/config/useReactNativeEnv.js +0 -12
  77. package/src/config/useQueryConfig.ts +0 -11
  78. /package/dist/{config → src/config}/useEnvironmentVariables.js +0 -0
  79. /package/dist/{config → src/config}/useEnvironmentVariables.js.map +0 -0
  80. /package/dist/{config → src/config}/useQueryHeaders.js +0 -0
  81. /package/dist/{config → src/config}/useQueryHeaders.js.map +0 -0
  82. /package/dist/{helpers → src/helpers}/scrollToTop.js +0 -0
  83. /package/dist/{helpers → src/helpers}/scrollToTop.js.map +0 -0
  84. /package/dist/{helpers → src/helpers}/timeFuncs.js +0 -0
  85. /package/dist/{helpers → src/helpers}/timeFuncs.js.map +0 -0
  86. /package/dist/{hooks → src/hooks}/useUploadProgress.js +0 -0
  87. /package/dist/{hooks → src/hooks}/useUploadProgress.js.map +0 -0
  88. /package/dist/{model → src/model}/useKeyTrackerModel.js +0 -0
  89. /package/dist/{model → src/model}/useKeyTrackerModel.js.map +0 -0
  90. /package/dist/{model → src/model}/useRefetchQuery.js +0 -0
  91. /package/dist/{model → src/model}/useRefetchQuery.js.map +0 -0
  92. /package/dist/{request → src/request}/axios-instance.js +0 -0
  93. /package/dist/{request → src/request}/axios-instance.js.map +0 -0
  94. /package/dist/{request → src/request}/buildFormData.js +0 -0
  95. /package/dist/{request → src/request}/buildFormData.js.map +0 -0
  96. /package/dist/{request → src/request}/make-request.js +0 -0
  97. /package/dist/{request → src/request}/make-request.js.map +0 -0
  98. /package/dist/{request → src/request}/request.enum.js +0 -0
  99. /package/dist/{request → src/request}/request.enum.js.map +0 -0
  100. /package/dist/{request → src/request}/transformer.js +0 -0
  101. /package/dist/{request → src/request}/transformer.js.map +0 -0
  102. /package/dist/{stores → src/stores}/useHeaderStore.js +0 -0
  103. /package/dist/{stores → src/stores}/useHeaderStore.js.map +0 -0
  104. /package/dist/{stores → src/stores}/usePauseFutureRequests.js +0 -0
  105. /package/dist/{stores → src/stores}/usePauseFutureRequests.js.map +0 -0
package/dist/index.mjs CHANGED
@@ -1,40 +1,716 @@
1
1
  import 'url-search-params-polyfill';
2
- import { useQueryClient, useQuery, useInfiniteQuery, useMutation } from '@tanstack/react-query';
2
+ import require$$0, { useState, useEffect, useMemo, startTransition } from 'react';
3
3
  import { create } from 'zustand';
4
- import { useState, useEffect, useMemo, startTransition } from 'react';
4
+ import { useQueryClient, useQuery, useInfiniteQuery, useMutation } from '@tanstack/react-query';
5
5
  import result from 'lodash.result';
6
6
  import lodashSet from 'lodash.set';
7
7
  import axios from 'axios';
8
8
 
9
- const bootstrapQueryRequest = (queryClient, options) => {
10
- // make query config doesn't expire
11
- // set default query config
12
- const defaultMeta = {
13
- headers: {
14
- Authorization: ``,
15
- },
16
- options,
17
- };
18
- queryClient.setDefaultOptions({
19
- queries: {
20
- meta: defaultMeta,
21
- },
22
- mutations: { meta: defaultMeta },
23
- });
9
+ var withSelectorExports = {};
10
+ var withSelector = {
11
+ get exports(){ return withSelectorExports; },
12
+ set exports(v){ withSelectorExports = v; },
24
13
  };
25
14
 
26
- const useQueryConfig = () => {
27
- const queryClient = useQueryClient();
28
- const mutationMeta = (queryClient.getDefaultOptions().mutations?.meta ?? {});
29
- const queryMeta = (queryClient.getDefaultOptions().queries?.meta ?? {});
30
- return { ...queryMeta, ...mutationMeta };
15
+ var withSelector_production = {};
16
+
17
+ var shimExports = {};
18
+ var shim = {
19
+ get exports(){ return shimExports; },
20
+ set exports(v){ shimExports = v; },
21
+ };
22
+
23
+ var useSyncExternalStoreShim_production = {};
24
+
25
+ /**
26
+ * @license React
27
+ * use-sync-external-store-shim.production.js
28
+ *
29
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */
34
+
35
+ var hasRequiredUseSyncExternalStoreShim_production;
36
+
37
+ function requireUseSyncExternalStoreShim_production () {
38
+ if (hasRequiredUseSyncExternalStoreShim_production) return useSyncExternalStoreShim_production;
39
+ hasRequiredUseSyncExternalStoreShim_production = 1;
40
+ var React = require$$0;
41
+ function is(x, y) {
42
+ return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
43
+ }
44
+ var objectIs = "function" === typeof Object.is ? Object.is : is,
45
+ useState = React.useState,
46
+ useEffect = React.useEffect,
47
+ useLayoutEffect = React.useLayoutEffect,
48
+ useDebugValue = React.useDebugValue;
49
+ function useSyncExternalStore$2(subscribe, getSnapshot) {
50
+ var value = getSnapshot(),
51
+ _useState = useState({ inst: { value: value, getSnapshot: getSnapshot } }),
52
+ inst = _useState[0].inst,
53
+ forceUpdate = _useState[1];
54
+ useLayoutEffect(
55
+ function () {
56
+ inst.value = value;
57
+ inst.getSnapshot = getSnapshot;
58
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
59
+ },
60
+ [subscribe, value, getSnapshot]
61
+ );
62
+ useEffect(
63
+ function () {
64
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
65
+ return subscribe(function () {
66
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
67
+ });
68
+ },
69
+ [subscribe]
70
+ );
71
+ useDebugValue(value);
72
+ return value;
73
+ }
74
+ function checkIfSnapshotChanged(inst) {
75
+ var latestGetSnapshot = inst.getSnapshot;
76
+ inst = inst.value;
77
+ try {
78
+ var nextValue = latestGetSnapshot();
79
+ return !objectIs(inst, nextValue);
80
+ } catch (error) {
81
+ return !0;
82
+ }
83
+ }
84
+ function useSyncExternalStore$1(subscribe, getSnapshot) {
85
+ return getSnapshot();
86
+ }
87
+ var shim =
88
+ "undefined" === typeof window ||
89
+ "undefined" === typeof window.document ||
90
+ "undefined" === typeof window.document.createElement
91
+ ? useSyncExternalStore$1
92
+ : useSyncExternalStore$2;
93
+ useSyncExternalStoreShim_production.useSyncExternalStore =
94
+ void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
95
+ return useSyncExternalStoreShim_production;
96
+ }
97
+
98
+ var useSyncExternalStoreShim_development = {};
99
+
100
+ /**
101
+ * @license React
102
+ * use-sync-external-store-shim.development.js
103
+ *
104
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
105
+ *
106
+ * This source code is licensed under the MIT license found in the
107
+ * LICENSE file in the root directory of this source tree.
108
+ */
109
+
110
+ var hasRequiredUseSyncExternalStoreShim_development;
111
+
112
+ function requireUseSyncExternalStoreShim_development () {
113
+ if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
114
+ hasRequiredUseSyncExternalStoreShim_development = 1;
115
+ "production" !== process.env.NODE_ENV &&
116
+ (function () {
117
+ function is(x, y) {
118
+ return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
119
+ }
120
+ function useSyncExternalStore$2(subscribe, getSnapshot) {
121
+ didWarnOld18Alpha ||
122
+ void 0 === React.startTransition ||
123
+ ((didWarnOld18Alpha = !0),
124
+ console.error(
125
+ "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
126
+ ));
127
+ var value = getSnapshot();
128
+ if (!didWarnUncachedGetSnapshot) {
129
+ var cachedValue = getSnapshot();
130
+ objectIs(value, cachedValue) ||
131
+ (console.error(
132
+ "The result of getSnapshot should be cached to avoid an infinite loop"
133
+ ),
134
+ (didWarnUncachedGetSnapshot = !0));
135
+ }
136
+ cachedValue = useState({
137
+ inst: { value: value, getSnapshot: getSnapshot }
138
+ });
139
+ var inst = cachedValue[0].inst,
140
+ forceUpdate = cachedValue[1];
141
+ useLayoutEffect(
142
+ function () {
143
+ inst.value = value;
144
+ inst.getSnapshot = getSnapshot;
145
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
146
+ },
147
+ [subscribe, value, getSnapshot]
148
+ );
149
+ useEffect(
150
+ function () {
151
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
152
+ return subscribe(function () {
153
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
154
+ });
155
+ },
156
+ [subscribe]
157
+ );
158
+ useDebugValue(value);
159
+ return value;
160
+ }
161
+ function checkIfSnapshotChanged(inst) {
162
+ var latestGetSnapshot = inst.getSnapshot;
163
+ inst = inst.value;
164
+ try {
165
+ var nextValue = latestGetSnapshot();
166
+ return !objectIs(inst, nextValue);
167
+ } catch (error) {
168
+ return !0;
169
+ }
170
+ }
171
+ function useSyncExternalStore$1(subscribe, getSnapshot) {
172
+ return getSnapshot();
173
+ }
174
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
175
+ "function" ===
176
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
177
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
178
+ var React = require$$0,
179
+ objectIs = "function" === typeof Object.is ? Object.is : is,
180
+ useState = React.useState,
181
+ useEffect = React.useEffect,
182
+ useLayoutEffect = React.useLayoutEffect,
183
+ useDebugValue = React.useDebugValue,
184
+ didWarnOld18Alpha = !1,
185
+ didWarnUncachedGetSnapshot = !1,
186
+ shim =
187
+ "undefined" === typeof window ||
188
+ "undefined" === typeof window.document ||
189
+ "undefined" === typeof window.document.createElement
190
+ ? useSyncExternalStore$1
191
+ : useSyncExternalStore$2;
192
+ useSyncExternalStoreShim_development.useSyncExternalStore =
193
+ void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
194
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
195
+ "function" ===
196
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
197
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
198
+ })();
199
+ return useSyncExternalStoreShim_development;
200
+ }
201
+
202
+ var hasRequiredShim;
203
+
204
+ function requireShim () {
205
+ if (hasRequiredShim) return shimExports;
206
+ hasRequiredShim = 1;
207
+ (function (module) {
208
+
209
+ if (process.env.NODE_ENV === 'production') {
210
+ module.exports = requireUseSyncExternalStoreShim_production();
211
+ } else {
212
+ module.exports = requireUseSyncExternalStoreShim_development();
213
+ }
214
+ } (shim));
215
+ return shimExports;
216
+ }
217
+
218
+ /**
219
+ * @license React
220
+ * use-sync-external-store-shim/with-selector.production.js
221
+ *
222
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
223
+ *
224
+ * This source code is licensed under the MIT license found in the
225
+ * LICENSE file in the root directory of this source tree.
226
+ */
227
+
228
+ var hasRequiredWithSelector_production;
229
+
230
+ function requireWithSelector_production () {
231
+ if (hasRequiredWithSelector_production) return withSelector_production;
232
+ hasRequiredWithSelector_production = 1;
233
+ var React = require$$0,
234
+ shim = requireShim();
235
+ function is(x, y) {
236
+ return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
237
+ }
238
+ var objectIs = "function" === typeof Object.is ? Object.is : is,
239
+ useSyncExternalStore = shim.useSyncExternalStore,
240
+ useRef = React.useRef,
241
+ useEffect = React.useEffect,
242
+ useMemo = React.useMemo,
243
+ useDebugValue = React.useDebugValue;
244
+ withSelector_production.useSyncExternalStoreWithSelector = function (
245
+ subscribe,
246
+ getSnapshot,
247
+ getServerSnapshot,
248
+ selector,
249
+ isEqual
250
+ ) {
251
+ var instRef = useRef(null);
252
+ if (null === instRef.current) {
253
+ var inst = { hasValue: !1, value: null };
254
+ instRef.current = inst;
255
+ } else inst = instRef.current;
256
+ instRef = useMemo(
257
+ function () {
258
+ function memoizedSelector(nextSnapshot) {
259
+ if (!hasMemo) {
260
+ hasMemo = !0;
261
+ memoizedSnapshot = nextSnapshot;
262
+ nextSnapshot = selector(nextSnapshot);
263
+ if (void 0 !== isEqual && inst.hasValue) {
264
+ var currentSelection = inst.value;
265
+ if (isEqual(currentSelection, nextSnapshot))
266
+ return (memoizedSelection = currentSelection);
267
+ }
268
+ return (memoizedSelection = nextSnapshot);
269
+ }
270
+ currentSelection = memoizedSelection;
271
+ if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
272
+ var nextSelection = selector(nextSnapshot);
273
+ if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
274
+ return (memoizedSnapshot = nextSnapshot), currentSelection;
275
+ memoizedSnapshot = nextSnapshot;
276
+ return (memoizedSelection = nextSelection);
277
+ }
278
+ var hasMemo = !1,
279
+ memoizedSnapshot,
280
+ memoizedSelection,
281
+ maybeGetServerSnapshot =
282
+ void 0 === getServerSnapshot ? null : getServerSnapshot;
283
+ return [
284
+ function () {
285
+ return memoizedSelector(getSnapshot());
286
+ },
287
+ null === maybeGetServerSnapshot
288
+ ? void 0
289
+ : function () {
290
+ return memoizedSelector(maybeGetServerSnapshot());
291
+ }
292
+ ];
293
+ },
294
+ [getSnapshot, getServerSnapshot, selector, isEqual]
295
+ );
296
+ var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
297
+ useEffect(
298
+ function () {
299
+ inst.hasValue = !0;
300
+ inst.value = value;
301
+ },
302
+ [value]
303
+ );
304
+ useDebugValue(value);
305
+ return value;
306
+ };
307
+ return withSelector_production;
308
+ }
309
+
310
+ var withSelector_development = {};
311
+
312
+ /**
313
+ * @license React
314
+ * use-sync-external-store-shim/with-selector.development.js
315
+ *
316
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
317
+ *
318
+ * This source code is licensed under the MIT license found in the
319
+ * LICENSE file in the root directory of this source tree.
320
+ */
321
+
322
+ var hasRequiredWithSelector_development;
323
+
324
+ function requireWithSelector_development () {
325
+ if (hasRequiredWithSelector_development) return withSelector_development;
326
+ hasRequiredWithSelector_development = 1;
327
+ "production" !== process.env.NODE_ENV &&
328
+ (function () {
329
+ function is(x, y) {
330
+ return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
331
+ }
332
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
333
+ "function" ===
334
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
335
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
336
+ var React = require$$0,
337
+ shim = requireShim(),
338
+ objectIs = "function" === typeof Object.is ? Object.is : is,
339
+ useSyncExternalStore = shim.useSyncExternalStore,
340
+ useRef = React.useRef,
341
+ useEffect = React.useEffect,
342
+ useMemo = React.useMemo,
343
+ useDebugValue = React.useDebugValue;
344
+ withSelector_development.useSyncExternalStoreWithSelector = function (
345
+ subscribe,
346
+ getSnapshot,
347
+ getServerSnapshot,
348
+ selector,
349
+ isEqual
350
+ ) {
351
+ var instRef = useRef(null);
352
+ if (null === instRef.current) {
353
+ var inst = { hasValue: !1, value: null };
354
+ instRef.current = inst;
355
+ } else inst = instRef.current;
356
+ instRef = useMemo(
357
+ function () {
358
+ function memoizedSelector(nextSnapshot) {
359
+ if (!hasMemo) {
360
+ hasMemo = !0;
361
+ memoizedSnapshot = nextSnapshot;
362
+ nextSnapshot = selector(nextSnapshot);
363
+ if (void 0 !== isEqual && inst.hasValue) {
364
+ var currentSelection = inst.value;
365
+ if (isEqual(currentSelection, nextSnapshot))
366
+ return (memoizedSelection = currentSelection);
367
+ }
368
+ return (memoizedSelection = nextSnapshot);
369
+ }
370
+ currentSelection = memoizedSelection;
371
+ if (objectIs(memoizedSnapshot, nextSnapshot))
372
+ return currentSelection;
373
+ var nextSelection = selector(nextSnapshot);
374
+ if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
375
+ return (memoizedSnapshot = nextSnapshot), currentSelection;
376
+ memoizedSnapshot = nextSnapshot;
377
+ return (memoizedSelection = nextSelection);
378
+ }
379
+ var hasMemo = !1,
380
+ memoizedSnapshot,
381
+ memoizedSelection,
382
+ maybeGetServerSnapshot =
383
+ void 0 === getServerSnapshot ? null : getServerSnapshot;
384
+ return [
385
+ function () {
386
+ return memoizedSelector(getSnapshot());
387
+ },
388
+ null === maybeGetServerSnapshot
389
+ ? void 0
390
+ : function () {
391
+ return memoizedSelector(maybeGetServerSnapshot());
392
+ }
393
+ ];
394
+ },
395
+ [getSnapshot, getServerSnapshot, selector, isEqual]
396
+ );
397
+ var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
398
+ useEffect(
399
+ function () {
400
+ inst.hasValue = !0;
401
+ inst.value = value;
402
+ },
403
+ [value]
404
+ );
405
+ useDebugValue(value);
406
+ return value;
407
+ };
408
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
409
+ "function" ===
410
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
411
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
412
+ })();
413
+ return withSelector_development;
414
+ }
415
+
416
+ (function (module) {
417
+
418
+ if (process.env.NODE_ENV === 'production') {
419
+ module.exports = requireWithSelector_production();
420
+ } else {
421
+ module.exports = requireWithSelector_development();
422
+ }
423
+ } (withSelector));
424
+
425
+ const __storeToDerived = /* @__PURE__ */ new WeakMap();
426
+ const __derivedToStore = /* @__PURE__ */ new WeakMap();
427
+ const __depsThatHaveWrittenThisTick = {
428
+ current: []
429
+ };
430
+ let __isFlushing = false;
431
+ let __batchDepth = 0;
432
+ const __pendingUpdates = /* @__PURE__ */ new Set();
433
+ const __initialBatchValues = /* @__PURE__ */ new Map();
434
+ function __flush_internals(relatedVals) {
435
+ const sorted = Array.from(relatedVals).sort((a, b) => {
436
+ if (a instanceof Derived && a.options.deps.includes(b)) return 1;
437
+ if (b instanceof Derived && b.options.deps.includes(a)) return -1;
438
+ return 0;
439
+ });
440
+ for (const derived of sorted) {
441
+ if (__depsThatHaveWrittenThisTick.current.includes(derived)) {
442
+ continue;
443
+ }
444
+ __depsThatHaveWrittenThisTick.current.push(derived);
445
+ derived.recompute();
446
+ const stores = __derivedToStore.get(derived);
447
+ if (stores) {
448
+ for (const store of stores) {
449
+ const relatedLinkedDerivedVals = __storeToDerived.get(store);
450
+ if (!relatedLinkedDerivedVals) continue;
451
+ __flush_internals(relatedLinkedDerivedVals);
452
+ }
453
+ }
454
+ }
455
+ }
456
+ function __notifyListeners(store) {
457
+ store.listeners.forEach(
458
+ (listener) => listener({
459
+ prevVal: store.prevState,
460
+ currentVal: store.state
461
+ })
462
+ );
463
+ }
464
+ function __notifyDerivedListeners(derived) {
465
+ derived.listeners.forEach(
466
+ (listener) => listener({
467
+ prevVal: derived.prevState,
468
+ currentVal: derived.state
469
+ })
470
+ );
471
+ }
472
+ function __flush(store) {
473
+ if (__batchDepth > 0 && !__initialBatchValues.has(store)) {
474
+ __initialBatchValues.set(store, store.prevState);
475
+ }
476
+ __pendingUpdates.add(store);
477
+ if (__isFlushing) return;
478
+ try {
479
+ __isFlushing = true;
480
+ while (__pendingUpdates.size > 0) {
481
+ const stores = Array.from(__pendingUpdates);
482
+ __pendingUpdates.clear();
483
+ for (const store2 of stores) {
484
+ const prevState = __initialBatchValues.get(store2) ?? store2.prevState;
485
+ store2.prevState = prevState;
486
+ __notifyListeners(store2);
487
+ }
488
+ for (const store2 of stores) {
489
+ const derivedVals = __storeToDerived.get(store2);
490
+ if (!derivedVals) continue;
491
+ __depsThatHaveWrittenThisTick.current.push(store2);
492
+ __flush_internals(derivedVals);
493
+ }
494
+ for (const store2 of stores) {
495
+ const derivedVals = __storeToDerived.get(store2);
496
+ if (!derivedVals) continue;
497
+ for (const derived of derivedVals) {
498
+ __notifyDerivedListeners(derived);
499
+ }
500
+ }
501
+ }
502
+ } finally {
503
+ __isFlushing = false;
504
+ __depsThatHaveWrittenThisTick.current = [];
505
+ __initialBatchValues.clear();
506
+ }
507
+ }
508
+
509
+ class Store {
510
+ constructor(initialState, options) {
511
+ this.listeners = /* @__PURE__ */ new Set();
512
+ this.subscribe = (listener) => {
513
+ var _a, _b;
514
+ this.listeners.add(listener);
515
+ const unsub = (_b = (_a = this.options) == null ? void 0 : _a.onSubscribe) == null ? void 0 : _b.call(_a, listener, this);
516
+ return () => {
517
+ this.listeners.delete(listener);
518
+ unsub == null ? void 0 : unsub();
519
+ };
520
+ };
521
+ this.setState = (updater) => {
522
+ var _a, _b, _c;
523
+ this.prevState = this.state;
524
+ this.state = ((_a = this.options) == null ? void 0 : _a.updateFn) ? this.options.updateFn(this.prevState)(updater) : updater(this.prevState);
525
+ (_c = (_b = this.options) == null ? void 0 : _b.onUpdate) == null ? void 0 : _c.call(_b);
526
+ __flush(this);
527
+ };
528
+ this.prevState = initialState;
529
+ this.state = initialState;
530
+ this.options = options;
531
+ }
532
+ }
533
+
534
+ class Derived {
535
+ constructor(options) {
536
+ this.listeners = /* @__PURE__ */ new Set();
537
+ this._subscriptions = [];
538
+ this.lastSeenDepValues = [];
539
+ this.getDepVals = () => {
540
+ const prevDepVals = [];
541
+ const currDepVals = [];
542
+ for (const dep of this.options.deps) {
543
+ prevDepVals.push(dep.prevState);
544
+ currDepVals.push(dep.state);
545
+ }
546
+ this.lastSeenDepValues = currDepVals;
547
+ return {
548
+ prevDepVals,
549
+ currDepVals,
550
+ prevVal: this.prevState ?? void 0
551
+ };
552
+ };
553
+ this.recompute = () => {
554
+ var _a, _b;
555
+ this.prevState = this.state;
556
+ const { prevDepVals, currDepVals, prevVal } = this.getDepVals();
557
+ this.state = this.options.fn({
558
+ prevDepVals,
559
+ currDepVals,
560
+ prevVal
561
+ });
562
+ (_b = (_a = this.options).onUpdate) == null ? void 0 : _b.call(_a);
563
+ };
564
+ this.checkIfRecalculationNeededDeeply = () => {
565
+ for (const dep of this.options.deps) {
566
+ if (dep instanceof Derived) {
567
+ dep.checkIfRecalculationNeededDeeply();
568
+ }
569
+ }
570
+ let shouldRecompute = false;
571
+ const lastSeenDepValues = this.lastSeenDepValues;
572
+ const { currDepVals } = this.getDepVals();
573
+ for (let i = 0; i < currDepVals.length; i++) {
574
+ if (currDepVals[i] !== lastSeenDepValues[i]) {
575
+ shouldRecompute = true;
576
+ break;
577
+ }
578
+ }
579
+ if (shouldRecompute) {
580
+ this.recompute();
581
+ }
582
+ };
583
+ this.mount = () => {
584
+ this.registerOnGraph();
585
+ this.checkIfRecalculationNeededDeeply();
586
+ return () => {
587
+ this.unregisterFromGraph();
588
+ for (const cleanup of this._subscriptions) {
589
+ cleanup();
590
+ }
591
+ };
592
+ };
593
+ this.subscribe = (listener) => {
594
+ var _a, _b;
595
+ this.listeners.add(listener);
596
+ const unsub = (_b = (_a = this.options).onSubscribe) == null ? void 0 : _b.call(_a, listener, this);
597
+ return () => {
598
+ this.listeners.delete(listener);
599
+ unsub == null ? void 0 : unsub();
600
+ };
601
+ };
602
+ this.options = options;
603
+ this.state = options.fn({
604
+ prevDepVals: void 0,
605
+ prevVal: void 0,
606
+ currDepVals: this.getDepVals().currDepVals
607
+ });
608
+ }
609
+ registerOnGraph(deps = this.options.deps) {
610
+ for (const dep of deps) {
611
+ if (dep instanceof Derived) {
612
+ dep.registerOnGraph();
613
+ this.registerOnGraph(dep.options.deps);
614
+ } else if (dep instanceof Store) {
615
+ let relatedLinkedDerivedVals = __storeToDerived.get(dep);
616
+ if (!relatedLinkedDerivedVals) {
617
+ relatedLinkedDerivedVals = /* @__PURE__ */ new Set();
618
+ __storeToDerived.set(dep, relatedLinkedDerivedVals);
619
+ }
620
+ relatedLinkedDerivedVals.add(this);
621
+ let relatedStores = __derivedToStore.get(this);
622
+ if (!relatedStores) {
623
+ relatedStores = /* @__PURE__ */ new Set();
624
+ __derivedToStore.set(this, relatedStores);
625
+ }
626
+ relatedStores.add(dep);
627
+ }
628
+ }
629
+ }
630
+ unregisterFromGraph(deps = this.options.deps) {
631
+ for (const dep of deps) {
632
+ if (dep instanceof Derived) {
633
+ this.unregisterFromGraph(dep.options.deps);
634
+ } else if (dep instanceof Store) {
635
+ const relatedLinkedDerivedVals = __storeToDerived.get(dep);
636
+ if (relatedLinkedDerivedVals) {
637
+ relatedLinkedDerivedVals.delete(this);
638
+ }
639
+ const relatedStores = __derivedToStore.get(this);
640
+ if (relatedStores) {
641
+ relatedStores.delete(dep);
642
+ }
643
+ }
644
+ }
645
+ }
646
+ }
647
+
648
+ function useStore(store, selector = (d) => d) {
649
+ const slice = withSelectorExports.useSyncExternalStoreWithSelector(
650
+ store.subscribe,
651
+ () => store.state,
652
+ () => store.state,
653
+ selector,
654
+ shallow
655
+ );
656
+ return slice;
657
+ }
658
+ function shallow(objA, objB) {
659
+ if (Object.is(objA, objB)) {
660
+ return true;
661
+ }
662
+ if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
663
+ return false;
664
+ }
665
+ if (objA instanceof Map && objB instanceof Map) {
666
+ if (objA.size !== objB.size) return false;
667
+ for (const [k, v] of objA) {
668
+ if (!objB.has(k) || !Object.is(v, objB.get(k))) return false;
669
+ }
670
+ return true;
671
+ }
672
+ if (objA instanceof Set && objB instanceof Set) {
673
+ if (objA.size !== objB.size) return false;
674
+ for (const v of objA) {
675
+ if (!objB.has(v)) return false;
676
+ }
677
+ return true;
678
+ }
679
+ const keysA = Object.keys(objA);
680
+ if (keysA.length !== Object.keys(objB).length) {
681
+ return false;
682
+ }
683
+ for (let i = 0; i < keysA.length; i++) {
684
+ if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
685
+ return false;
686
+ }
687
+ }
688
+ return true;
689
+ }
690
+
691
+ const bootStore = new Store({
692
+ context: 'web',
693
+ environments: {
694
+ appBaseUrl: undefined,
695
+ appTimeout: 30000,
696
+ },
697
+ middleware: (next) => {
698
+ return next();
699
+ },
700
+ modelConfig: undefined,
701
+ });
702
+
703
+ const bootstrapQueryRequest = async (queryClient, options) => {
704
+ // set default query config
705
+ await queryClient.resumePausedMutations();
706
+ bootStore.setState(() => options);
31
707
  };
32
708
 
33
709
  const useReactNativeEnv = () => {
34
- const config = useQueryConfig();
35
- const appUrl = config.options?.environments?.appBaseUrl;
36
- const appTimeout = config.options?.environments?.appTimeout;
37
- const isApp = config.options?.context === 'app';
710
+ const { environments, context } = useStore(bootStore);
711
+ const appUrl = environments?.appBaseUrl;
712
+ const appTimeout = environments?.appTimeout;
713
+ const isApp = context === 'app';
38
714
  return { appUrl, appTimeout, isApp };
39
715
  };
40
716
 
@@ -127,7 +803,7 @@ const useQueryModel = (keyTracker) => {
127
803
  const queryClient = useQueryClient();
128
804
  const { getQueryKey } = useKeyTrackerModel(keyTracker);
129
805
  const queryKey = getQueryKey();
130
- const config = useQueryConfig();
806
+ const config = useStore(bootStore);
131
807
  const add = (data, position, path) => {
132
808
  let records = (findAll(path) ?? []);
133
809
  if (!position || position === 'end') {
@@ -183,8 +859,7 @@ const useQueryModel = (keyTracker) => {
183
859
  return queryClient.setQueryData(queryKey, () => newData);
184
860
  };
185
861
  const getModelConfig = () => {
186
- const { options } = config;
187
- const { modelConfig } = options ?? {};
862
+ const { modelConfig } = config;
188
863
  return modelConfig;
189
864
  };
190
865
  const update = (id, data, path) => {
@@ -422,7 +1097,7 @@ const useDeleteRequest = (deleteOptions) => {
422
1097
  const { baseUrl, headers } = deleteOptions ?? {};
423
1098
  const [requestPath, setRequestPath] = useState('');
424
1099
  const [options, setOptions] = useState();
425
- const { options: queryConfigOptions } = useQueryConfig();
1100
+ const { middleware } = useStore(bootStore);
426
1101
  const [requestPayload, setRequestPayload] = useState();
427
1102
  const isFutureQueriesPaused = usePauseFutureRequests((state) => state.isFutureQueriesPaused);
428
1103
  const { API_URL, TIMEOUT } = useEnvironmentVariables();
@@ -438,9 +1113,9 @@ const useDeleteRequest = (deleteOptions) => {
438
1113
  timeout: TIMEOUT,
439
1114
  };
440
1115
  let deleteResponse;
441
- if (queryConfigOptions?.middleware) {
1116
+ if (middleware) {
442
1117
  // perform global middleware
443
- deleteResponse = await queryConfigOptions.middleware(async () => await makeRequest(requestOptions), {
1118
+ deleteResponse = await middleware(async (middlewareOptions) => await makeRequest(middlewareOptions ? { ...requestOptions, ...middlewareOptions } : requestOptions), {
444
1119
  path: requestUrl,
445
1120
  baseUrl: baseUrl ?? API_URL,
446
1121
  });
@@ -497,7 +1172,7 @@ const useGetInfiniteRequest = ({ path, load = false, queryOptions, keyTracker, b
497
1172
  const globalHeaders = useHeaderStore((state) => state.headers);
498
1173
  const [requestPath, setRequestPath] = useState(path);
499
1174
  const [options, setOptions] = useState(queryOptions);
500
- const { options: queryConfigOptions } = useQueryConfig();
1175
+ const { middleware } = useStore(bootStore);
501
1176
  const [requestPayload, setRequestPayload] = useState();
502
1177
  const isFutureQueriesPaused = usePauseFutureRequests((state) => state.isFutureQueriesPaused);
503
1178
  let queryClient = useQueryClient();
@@ -513,9 +1188,9 @@ const useGetInfiniteRequest = ({ path, load = false, queryOptions, keyTracker, b
513
1188
  timeout: TIMEOUT,
514
1189
  };
515
1190
  let getResponse;
516
- if (queryConfigOptions?.middleware) {
1191
+ if (middleware) {
517
1192
  // perform global middleware
518
- getResponse = await queryConfigOptions.middleware(async () => await makeRequest(requestOptions), {
1193
+ getResponse = await middleware(async (middlewareOptions) => await makeRequest(middlewareOptions ? { ...requestOptions, ...middlewareOptions } : requestOptions), {
519
1194
  path,
520
1195
  baseUrl: baseUrl ?? API_URL,
521
1196
  });
@@ -602,8 +1277,8 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl,
602
1277
  const [options, setOptions] = useState(queryOptions);
603
1278
  const [page, setPage] = useState(1);
604
1279
  const { API_URL, TIMEOUT } = useEnvironmentVariables();
1280
+ const { middleware } = useStore(bootStore);
605
1281
  const globalHeaders = useHeaderStore((state) => state.headers);
606
- const { options: queryConfigOptions } = useQueryConfig();
607
1282
  const [requestPayload, setRequestPayload] = useState();
608
1283
  const isFutureQueriesPaused = usePauseFutureRequests((state) => state.isFutureQueriesPaused);
609
1284
  let queryClient = useQueryClient();
@@ -619,9 +1294,9 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl,
619
1294
  timeout: TIMEOUT,
620
1295
  };
621
1296
  let getResponse;
622
- if (queryConfigOptions?.middleware) {
1297
+ if (middleware) {
623
1298
  // perform global middleware
624
- getResponse = await queryConfigOptions.middleware(async () => await makeRequest(requestOptions), {
1299
+ getResponse = await middleware(async (middlewareOptions) => await makeRequest(middlewareOptions ? { ...requestOptions, ...middlewareOptions } : requestOptions), {
625
1300
  path,
626
1301
  baseUrl: baseUrl ?? API_URL,
627
1302
  });
@@ -734,7 +1409,7 @@ const usePatchRequest = ({ path, baseUrl, headers }) => {
734
1409
  const globalHeaders = useHeaderStore((state) => state.headers);
735
1410
  const [requestPayload, setRequestPayload] = useState();
736
1411
  const isFutureMutationsPaused = usePauseFutureRequests((state) => state.isFutureMutationsPaused);
737
- const config = useQueryConfig();
1412
+ const { middleware, context } = useStore(bootStore);
738
1413
  const sendRequest = async (res, rej, data) => {
739
1414
  // get request headers
740
1415
  const requestOptions = {
@@ -747,9 +1422,9 @@ const usePatchRequest = ({ path, baseUrl, headers }) => {
747
1422
  onUploadProgress,
748
1423
  };
749
1424
  let patchResponse;
750
- if (config.options?.middleware) {
1425
+ if (middleware) {
751
1426
  // perform global middleware
752
- const middlewareResponse = await config.options.middleware(async () => await makeRequest(requestOptions), {
1427
+ const middlewareResponse = await middleware(async (options) => await makeRequest(options ? { ...requestOptions, ...options } : requestOptions), {
753
1428
  path,
754
1429
  baseUrl: baseUrl ?? API_URL,
755
1430
  body: data,
@@ -761,14 +1436,14 @@ const usePatchRequest = ({ path, baseUrl, headers }) => {
761
1436
  }
762
1437
  if (patchResponse.status) {
763
1438
  // scroll to top after success
764
- if (config.options?.context !== 'app') {
1439
+ if (context !== 'app') {
765
1440
  scrollToTop();
766
1441
  }
767
1442
  res(patchResponse);
768
1443
  }
769
1444
  else {
770
1445
  // scroll to top after error
771
- if (config.options?.context !== 'app') {
1446
+ if (context !== 'app') {
772
1447
  scrollToTop();
773
1448
  }
774
1449
  rej(patchResponse);
@@ -802,7 +1477,7 @@ const usePatchRequest = ({ path, baseUrl, headers }) => {
802
1477
 
803
1478
  const usePostRequest = ({ path, isFormData = false, baseUrl, headers, fileSelectors, }) => {
804
1479
  const { API_URL, TIMEOUT } = useEnvironmentVariables();
805
- const config = useQueryConfig();
1480
+ const { middleware, context } = useStore(bootStore);
806
1481
  const globalHeaders = useHeaderStore((state) => state.headers);
807
1482
  const { isApp } = useReactNativeEnv();
808
1483
  const { uploadProgressPercent, onUploadProgress } = useUploadProgress();
@@ -828,9 +1503,9 @@ const usePostRequest = ({ path, isFormData = false, baseUrl, headers, fileSelect
828
1503
  ...requestConfig,
829
1504
  };
830
1505
  let postResponse;
831
- if (config.options?.middleware) {
1506
+ if (middleware) {
832
1507
  // perform global middleware
833
- postResponse = await config.options.middleware(async () => await makeRequest(requestOptions), {
1508
+ postResponse = await middleware(async (options) => await makeRequest(options ? { ...requestOptions, ...options } : requestOptions), {
834
1509
  path,
835
1510
  baseUrl: baseUrl ?? API_URL,
836
1511
  body: data,
@@ -841,14 +1516,14 @@ const usePostRequest = ({ path, isFormData = false, baseUrl, headers, fileSelect
841
1516
  }
842
1517
  if (postResponse.status) {
843
1518
  // scroll to top after success
844
- if (config.options?.context !== 'app') {
1519
+ if (context !== 'app') {
845
1520
  scrollToTop();
846
1521
  }
847
1522
  res(postResponse);
848
1523
  }
849
1524
  else {
850
1525
  // scroll to top after error
851
- if (config.options?.context !== 'app') {
1526
+ if (context !== 'app') {
852
1527
  scrollToTop();
853
1528
  }
854
1529
  rej(postResponse);
@@ -879,5 +1554,5 @@ const usePostRequest = ({ path, isFormData = false, baseUrl, headers, fileSelect
879
1554
  return { post, uploadProgressPercent, ...mutation, isLoading: mutation.isPending || isFutureMutationsPaused };
880
1555
  };
881
1556
 
882
- export { ContentType, HttpMethod, axiosInstance, bootstrapQueryRequest, buildFormData, errorTransformer, getDateInFuture, makeRequest, scrollToTop, successTransformer, useDeleteRequest, useEnvironmentVariables, useGetInfiniteRequest, useGetRequest, useHeaderStore, useKeyTrackerModel, usePatchRequest, usePauseFutureRequests, usePostRequest, useQueryConfig, useQueryHeaders, useQueryModel, useReactNativeEnv, useRefetchQuery, useUploadProgress };
1557
+ export { ContentType, HttpMethod, axiosInstance, bootstrapQueryRequest, buildFormData, errorTransformer, getDateInFuture, makeRequest, scrollToTop, successTransformer, useDeleteRequest, useEnvironmentVariables, useGetInfiniteRequest, useGetRequest, useHeaderStore, useKeyTrackerModel, usePatchRequest, usePauseFutureRequests, usePostRequest, useQueryHeaders, useQueryModel, useReactNativeEnv, useRefetchQuery, useUploadProgress };
883
1558
  //# sourceMappingURL=index.mjs.map