@shopify/shop-minis-react 0.3.4 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/_virtual/index3.js +2 -5
  2. package/dist/_virtual/index3.js.map +1 -1
  3. package/dist/_virtual/index4.js +5 -2
  4. package/dist/_virtual/index4.js.map +1 -1
  5. package/dist/components/MinisContainer.js +11 -10
  6. package/dist/components/MinisContainer.js.map +1 -1
  7. package/dist/hooks/content/useContent.js +12 -18
  8. package/dist/hooks/content/useContent.js.map +1 -1
  9. package/dist/hooks/product/useCuratedProducts.js +9 -11
  10. package/dist/hooks/product/useCuratedProducts.js.map +1 -1
  11. package/dist/hooks/product/usePopularProducts.js +9 -11
  12. package/dist/hooks/product/usePopularProducts.js.map +1 -1
  13. package/dist/hooks/product/useProduct.js +11 -17
  14. package/dist/hooks/product/useProduct.js.map +1 -1
  15. package/dist/hooks/product/useProductList.js +10 -21
  16. package/dist/hooks/product/useProductList.js.map +1 -1
  17. package/dist/hooks/product/useProductLists.js +11 -13
  18. package/dist/hooks/product/useProductLists.js.map +1 -1
  19. package/dist/hooks/product/useProductMedia.js +12 -18
  20. package/dist/hooks/product/useProductMedia.js.map +1 -1
  21. package/dist/hooks/product/useProductSearch.js +34 -27
  22. package/dist/hooks/product/useProductSearch.js.map +1 -1
  23. package/dist/hooks/product/useProductVariants.js +11 -14
  24. package/dist/hooks/product/useProductVariants.js.map +1 -1
  25. package/dist/hooks/product/useProducts.js +12 -11
  26. package/dist/hooks/product/useProducts.js.map +1 -1
  27. package/dist/hooks/product/useRecommendedProducts.js +11 -13
  28. package/dist/hooks/product/useRecommendedProducts.js.map +1 -1
  29. package/dist/hooks/shop/useRecommendedShops.js +11 -13
  30. package/dist/hooks/shop/useRecommendedShops.js.map +1 -1
  31. package/dist/hooks/shop/useShop.js +12 -11
  32. package/dist/hooks/shop/useShop.js.map +1 -1
  33. package/dist/hooks/user/useBuyerAttributes.js +8 -10
  34. package/dist/hooks/user/useBuyerAttributes.js.map +1 -1
  35. package/dist/hooks/user/useCurrentUser.js +7 -9
  36. package/dist/hooks/user/useCurrentUser.js.map +1 -1
  37. package/dist/hooks/user/useFollowedShops.js +11 -14
  38. package/dist/hooks/user/useFollowedShops.js.map +1 -1
  39. package/dist/hooks/user/useOrders.js +7 -9
  40. package/dist/hooks/user/useOrders.js.map +1 -1
  41. package/dist/hooks/user/useRecentProducts.js +11 -13
  42. package/dist/hooks/user/useRecentProducts.js.map +1 -1
  43. package/dist/hooks/user/useRecentShops.js +10 -13
  44. package/dist/hooks/user/useRecentShops.js.map +1 -1
  45. package/dist/hooks/user/useSavedProducts.js +10 -13
  46. package/dist/hooks/user/useSavedProducts.js.map +1 -1
  47. package/dist/hooks/util/useImagePicker.js +13 -6
  48. package/dist/hooks/util/useImagePicker.js.map +1 -1
  49. package/dist/internal/reactQuery/MinisQueryProvider.js +11 -0
  50. package/dist/internal/reactQuery/MinisQueryProvider.js.map +1 -0
  51. package/dist/internal/reactQuery/queryClient.js +33 -0
  52. package/dist/internal/reactQuery/queryClient.js.map +1 -0
  53. package/dist/internal/reactQuery/useShopActionInfiniteQuery.js +52 -0
  54. package/dist/internal/reactQuery/useShopActionInfiniteQuery.js.map +1 -0
  55. package/dist/internal/reactQuery/useShopActionQuery.js +37 -0
  56. package/dist/internal/reactQuery/useShopActionQuery.js.map +1 -0
  57. package/dist/internal/utils/resizeImage.js +61 -0
  58. package/dist/internal/utils/resizeImage.js.map +1 -0
  59. package/dist/providers/ImagePickerProvider.js +123 -102
  60. package/dist/providers/ImagePickerProvider.js.map +1 -1
  61. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/focusManager.js +45 -0
  62. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -0
  63. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js +89 -0
  64. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js.map +1 -0
  65. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js +55 -0
  66. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js.map +1 -0
  67. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutation.js +198 -0
  68. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutation.js.map +1 -0
  69. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js +99 -0
  70. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js.map +1 -0
  71. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js +67 -0
  72. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js.map +1 -0
  73. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js +39 -0
  74. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -0
  75. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/query.js +299 -0
  76. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/query.js.map +1 -0
  77. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryCache.js +80 -0
  78. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryCache.js.map +1 -0
  79. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryClient.js +215 -0
  80. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryClient.js.map +1 -0
  81. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js +300 -0
  82. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -0
  83. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/removable.js +25 -0
  84. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/removable.js.map +1 -0
  85. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/retryer.js +76 -0
  86. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/retryer.js.map +1 -0
  87. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/subscribable.js +21 -0
  88. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/subscribable.js.map +1 -0
  89. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/thenable.js +26 -0
  90. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/thenable.js.map +1 -0
  91. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/utils.js +176 -0
  92. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/utils.js.map +1 -0
  93. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js +7 -0
  94. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js.map +1 -0
  95. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js +17 -0
  96. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js.map +1 -0
  97. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js +19 -0
  98. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js.map +1 -0
  99. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +21 -0
  100. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -0
  101. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/suspense.js +18 -0
  102. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -0
  103. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +64 -0
  104. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -0
  105. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js +13 -0
  106. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js.map +1 -0
  107. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useQuery.js +9 -0
  108. package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useQuery.js.map +1 -0
  109. package/dist/shop-minis-react/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +1 -1
  110. package/dist/shop-minis-react/node_modules/.pnpm/video.js@8.23.3/node_modules/video.js/dist/video.es.js +1 -1
  111. package/package.json +2 -7
  112. package/src/components/MinisContainer.tsx +6 -3
  113. package/src/hooks/content/useContent.ts +6 -17
  114. package/src/hooks/product/useCuratedProducts.ts +4 -6
  115. package/src/hooks/product/usePopularProducts.ts +4 -6
  116. package/src/hooks/product/useProduct.ts +6 -17
  117. package/src/hooks/product/useProductList.ts +4 -19
  118. package/src/hooks/product/useProductLists.ts +4 -6
  119. package/src/hooks/product/useProductMedia.ts +6 -17
  120. package/src/hooks/product/useProductSearch.ts +19 -15
  121. package/src/hooks/product/useProductVariants.ts +5 -13
  122. package/src/hooks/product/useProducts.ts +8 -12
  123. package/src/hooks/product/useRecommendedProducts.ts +4 -6
  124. package/src/hooks/shop/useRecommendedShops.ts +4 -6
  125. package/src/hooks/shop/useShop.ts +8 -12
  126. package/src/hooks/user/useBuyerAttributes.ts +4 -6
  127. package/src/hooks/user/useCurrentUser.ts +4 -6
  128. package/src/hooks/user/useFollowedShops.ts +5 -13
  129. package/src/hooks/user/useOrders.ts +4 -6
  130. package/src/hooks/user/useRecentProducts.ts +4 -6
  131. package/src/hooks/user/useRecentShops.ts +5 -13
  132. package/src/hooks/user/useSavedProducts.ts +5 -13
  133. package/src/hooks/util/useImagePicker.test.tsx +193 -0
  134. package/src/hooks/util/useImagePicker.ts +24 -5
  135. package/src/internal/reactQuery/MinisQueryProvider.test.tsx +38 -0
  136. package/src/internal/reactQuery/MinisQueryProvider.tsx +16 -0
  137. package/src/internal/reactQuery/index.ts +8 -0
  138. package/src/internal/reactQuery/queryClient.test.tsx +91 -0
  139. package/src/internal/reactQuery/queryClient.ts +43 -0
  140. package/src/internal/reactQuery/useShopActionInfiniteQuery.test.tsx +357 -0
  141. package/src/internal/reactQuery/useShopActionInfiniteQuery.ts +129 -0
  142. package/src/internal/reactQuery/useShopActionQuery.test.tsx +184 -0
  143. package/src/internal/reactQuery/useShopActionQuery.ts +74 -0
  144. package/src/internal/utils/resizeImage.test.ts +314 -0
  145. package/src/internal/utils/resizeImage.ts +108 -0
  146. package/src/providers/ImagePickerProvider.test.tsx +32 -1
  147. package/src/providers/ImagePickerProvider.tsx +108 -65
  148. package/dist/internal/useShopActionsDataFetching.js +0 -79
  149. package/dist/internal/useShopActionsDataFetching.js.map +0 -1
  150. package/dist/internal/useShopActionsPaginatedDataFetching.js +0 -96
  151. package/dist/internal/useShopActionsPaginatedDataFetching.js.map +0 -1
  152. package/src/hooks/product/useProductSearch.test.ts +0 -470
  153. package/src/internal/useShopActionsDataFetching.test.ts +0 -465
  154. package/src/internal/useShopActionsDataFetching.ts +0 -150
  155. package/src/internal/useShopActionsPaginatedDataFetching.ts +0 -188
  156. package/src/stories/Accordion.stories.tsx +0 -124
  157. package/src/stories/AddToCart.stories.tsx +0 -251
  158. package/src/stories/Alert.stories.tsx +0 -38
  159. package/src/stories/AlertDialog.stories.tsx +0 -48
  160. package/src/stories/Avatar.stories.tsx +0 -29
  161. package/src/stories/Badge.stories.tsx +0 -46
  162. package/src/stories/Button.stories.tsx +0 -81
  163. package/src/stories/Card.stories.tsx +0 -40
  164. package/src/stories/Checkbox.stories.tsx +0 -44
  165. package/src/stories/FavoriteButton.stories.tsx +0 -58
  166. package/src/stories/IconButton.stories.tsx +0 -68
  167. package/src/stories/ImageContentWrapper.stories.tsx +0 -65
  168. package/src/stories/Input.stories.tsx +0 -44
  169. package/src/stories/Label.stories.tsx +0 -19
  170. package/src/stories/List.stories.tsx +0 -64
  171. package/src/stories/MerchantCard.stories.tsx +0 -127
  172. package/src/stories/ProductCard.stories.tsx +0 -92
  173. package/src/stories/ProductLink.stories.tsx +0 -46
  174. package/src/stories/ProductVariantPrice.stories.tsx +0 -70
  175. package/src/stories/Progress.stories.tsx +0 -30
  176. package/src/stories/PullToRefreshList.stories.tsx +0 -122
  177. package/src/stories/QuantitySelector.stories.tsx +0 -78
  178. package/src/stories/RadioGroup.stories.tsx +0 -51
  179. package/src/stories/Search.stories.tsx +0 -37
  180. package/src/stories/Select.stories.tsx +0 -85
  181. package/src/stories/Skeleton.stories.tsx +0 -19
  182. package/src/stories/TextInput.stories.tsx +0 -26
  183. package/src/stories/Toaster.stories.tsx +0 -46
  184. package/src/stories/Touchable.stories.tsx +0 -40
  185. package/src/stories/VideoPlayer.stories.tsx +0 -129
@@ -0,0 +1,299 @@
1
+ import { replaceData as d, noop as c, resolveEnabled as f, skipToken as p, resolveStaleTime as y, timeUntilStale as v, ensureQueryFn as m } from "./utils.js";
2
+ import { notifyManager as b } from "./notifyManager.js";
3
+ import { createRetryer as C, CancelledError as l, canFetch as F } from "./retryer.js";
4
+ import { Removable as S } from "./removable.js";
5
+ var w = class extends S {
6
+ #a;
7
+ #n;
8
+ #e;
9
+ #r;
10
+ #t;
11
+ #o;
12
+ #i;
13
+ constructor(t) {
14
+ super(), this.#i = !1, this.#o = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#r = t.client, this.#e = this.#r.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#a = q(this.options), this.state = t.state ?? this.#a, this.scheduleGc();
15
+ }
16
+ get meta() {
17
+ return this.options.meta;
18
+ }
19
+ get promise() {
20
+ return this.#t?.promise;
21
+ }
22
+ setOptions(t) {
23
+ this.options = { ...this.#o, ...t }, this.updateGcTime(this.options.gcTime);
24
+ }
25
+ optionalRemove() {
26
+ !this.observers.length && this.state.fetchStatus === "idle" && this.#e.remove(this);
27
+ }
28
+ setData(t, s) {
29
+ const r = d(this.state.data, t, this.options);
30
+ return this.#s({
31
+ data: r,
32
+ type: "success",
33
+ dataUpdatedAt: s?.updatedAt,
34
+ manual: s?.manual
35
+ }), r;
36
+ }
37
+ setState(t, s) {
38
+ this.#s({ type: "setState", state: t, setStateOptions: s });
39
+ }
40
+ cancel(t) {
41
+ const s = this.#t?.promise;
42
+ return this.#t?.cancel(t), s ? s.then(c).catch(c) : Promise.resolve();
43
+ }
44
+ destroy() {
45
+ super.destroy(), this.cancel({ silent: !0 });
46
+ }
47
+ reset() {
48
+ this.destroy(), this.setState(this.#a);
49
+ }
50
+ isActive() {
51
+ return this.observers.some(
52
+ (t) => f(t.options.enabled, this) !== !1
53
+ );
54
+ }
55
+ isDisabled() {
56
+ return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === p || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
57
+ }
58
+ isStatic() {
59
+ return this.getObserversCount() > 0 ? this.observers.some(
60
+ (t) => y(t.options.staleTime, this) === "static"
61
+ ) : !1;
62
+ }
63
+ isStale() {
64
+ return this.getObserversCount() > 0 ? this.observers.some(
65
+ (t) => t.getCurrentResult().isStale
66
+ ) : this.state.data === void 0 || this.state.isInvalidated;
67
+ }
68
+ isStaleByTime(t = 0) {
69
+ return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !v(this.state.dataUpdatedAt, t);
70
+ }
71
+ onFocus() {
72
+ this.observers.find((s) => s.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
73
+ }
74
+ onOnline() {
75
+ this.observers.find((s) => s.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#t?.continue();
76
+ }
77
+ addObserver(t) {
78
+ this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), this.#e.notify({ type: "observerAdded", query: this, observer: t }));
79
+ }
80
+ removeObserver(t) {
81
+ this.observers.includes(t) && (this.observers = this.observers.filter((s) => s !== t), this.observers.length || (this.#t && (this.#i ? this.#t.cancel({ revert: !0 }) : this.#t.cancelRetry()), this.scheduleGc()), this.#e.notify({ type: "observerRemoved", query: this, observer: t }));
82
+ }
83
+ getObserversCount() {
84
+ return this.observers.length;
85
+ }
86
+ invalidate() {
87
+ this.state.isInvalidated || this.#s({ type: "invalidate" });
88
+ }
89
+ async fetch(t, s) {
90
+ if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
91
+ // re-start the fetch; there is a chance that the query is still in a
92
+ // pending state when that happens
93
+ this.#t?.status() !== "rejected") {
94
+ if (this.state.data !== void 0 && s?.cancelRefetch)
95
+ this.cancel({ silent: !0 });
96
+ else if (this.#t)
97
+ return this.#t.continueRetry(), this.#t.promise;
98
+ }
99
+ if (t && this.setOptions(t), !this.options.queryFn) {
100
+ const e = this.observers.find((o) => o.options.queryFn);
101
+ e && this.setOptions(e.options);
102
+ }
103
+ process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
104
+ "As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"
105
+ ));
106
+ const r = new AbortController(), i = (e) => {
107
+ Object.defineProperty(e, "signal", {
108
+ enumerable: !0,
109
+ get: () => (this.#i = !0, r.signal)
110
+ });
111
+ }, n = () => {
112
+ const e = m(this.options, s), h = (() => {
113
+ const u = {
114
+ client: this.#r,
115
+ queryKey: this.queryKey,
116
+ meta: this.meta
117
+ };
118
+ return i(u), u;
119
+ })();
120
+ return this.#i = !1, this.options.persister ? this.options.persister(
121
+ e,
122
+ h,
123
+ this
124
+ ) : e(h);
125
+ }, a = (() => {
126
+ const e = {
127
+ fetchOptions: s,
128
+ options: this.options,
129
+ queryKey: this.queryKey,
130
+ client: this.#r,
131
+ state: this.state,
132
+ fetchFn: n
133
+ };
134
+ return i(e), e;
135
+ })();
136
+ this.options.behavior?.onFetch(a, this), this.#n = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== a.fetchOptions?.meta) && this.#s({ type: "fetch", meta: a.fetchOptions?.meta }), this.#t = C({
137
+ initialPromise: s?.initialPromise,
138
+ fn: a.fetchFn,
139
+ onCancel: (e) => {
140
+ e instanceof l && e.revert && this.setState({
141
+ ...this.#n,
142
+ fetchStatus: "idle"
143
+ }), r.abort();
144
+ },
145
+ onFail: (e, o) => {
146
+ this.#s({ type: "failed", failureCount: e, error: o });
147
+ },
148
+ onPause: () => {
149
+ this.#s({ type: "pause" });
150
+ },
151
+ onContinue: () => {
152
+ this.#s({ type: "continue" });
153
+ },
154
+ retry: a.options.retry,
155
+ retryDelay: a.options.retryDelay,
156
+ networkMode: a.options.networkMode,
157
+ canRun: () => !0
158
+ });
159
+ try {
160
+ const e = await this.#t.start();
161
+ if (e === void 0)
162
+ throw process.env.NODE_ENV !== "production" && console.error(
163
+ `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
164
+ ), new Error(`${this.queryHash} data is undefined`);
165
+ return this.setData(e), this.#e.config.onSuccess?.(e, this), this.#e.config.onSettled?.(
166
+ e,
167
+ this.state.error,
168
+ this
169
+ ), e;
170
+ } catch (e) {
171
+ if (e instanceof l) {
172
+ if (e.silent)
173
+ return this.#t.promise;
174
+ if (e.revert) {
175
+ if (this.state.data === void 0)
176
+ throw e;
177
+ return this.state.data;
178
+ }
179
+ }
180
+ throw this.#s({
181
+ type: "error",
182
+ error: e
183
+ }), this.#e.config.onError?.(
184
+ e,
185
+ this
186
+ ), this.#e.config.onSettled?.(
187
+ this.state.data,
188
+ e,
189
+ this
190
+ ), e;
191
+ } finally {
192
+ this.scheduleGc();
193
+ }
194
+ }
195
+ #s(t) {
196
+ const s = (r) => {
197
+ switch (t.type) {
198
+ case "failed":
199
+ return {
200
+ ...r,
201
+ fetchFailureCount: t.failureCount,
202
+ fetchFailureReason: t.error
203
+ };
204
+ case "pause":
205
+ return {
206
+ ...r,
207
+ fetchStatus: "paused"
208
+ };
209
+ case "continue":
210
+ return {
211
+ ...r,
212
+ fetchStatus: "fetching"
213
+ };
214
+ case "fetch":
215
+ return {
216
+ ...r,
217
+ ...g(r.data, this.options),
218
+ fetchMeta: t.meta ?? null
219
+ };
220
+ case "success":
221
+ const i = {
222
+ ...r,
223
+ data: t.data,
224
+ dataUpdateCount: r.dataUpdateCount + 1,
225
+ dataUpdatedAt: t.dataUpdatedAt ?? Date.now(),
226
+ error: null,
227
+ isInvalidated: !1,
228
+ status: "success",
229
+ ...!t.manual && {
230
+ fetchStatus: "idle",
231
+ fetchFailureCount: 0,
232
+ fetchFailureReason: null
233
+ }
234
+ };
235
+ return this.#n = t.manual ? i : void 0, i;
236
+ case "error":
237
+ const n = t.error;
238
+ return {
239
+ ...r,
240
+ error: n,
241
+ errorUpdateCount: r.errorUpdateCount + 1,
242
+ errorUpdatedAt: Date.now(),
243
+ fetchFailureCount: r.fetchFailureCount + 1,
244
+ fetchFailureReason: n,
245
+ fetchStatus: "idle",
246
+ status: "error"
247
+ };
248
+ case "invalidate":
249
+ return {
250
+ ...r,
251
+ isInvalidated: !0
252
+ };
253
+ case "setState":
254
+ return {
255
+ ...r,
256
+ ...t.state
257
+ };
258
+ }
259
+ };
260
+ this.state = s(this.state), b.batch(() => {
261
+ this.observers.forEach((r) => {
262
+ r.onQueryUpdate();
263
+ }), this.#e.notify({ query: this, type: "updated", action: t });
264
+ });
265
+ }
266
+ };
267
+ function g(t, s) {
268
+ return {
269
+ fetchFailureCount: 0,
270
+ fetchFailureReason: null,
271
+ fetchStatus: F(s.networkMode) ? "fetching" : "paused",
272
+ ...t === void 0 && {
273
+ error: null,
274
+ status: "pending"
275
+ }
276
+ };
277
+ }
278
+ function q(t) {
279
+ const s = typeof t.initialData == "function" ? t.initialData() : t.initialData, r = s !== void 0, i = r ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
280
+ return {
281
+ data: s,
282
+ dataUpdateCount: 0,
283
+ dataUpdatedAt: r ? i ?? Date.now() : 0,
284
+ error: null,
285
+ errorUpdateCount: 0,
286
+ errorUpdatedAt: 0,
287
+ fetchFailureCount: 0,
288
+ fetchFailureReason: null,
289
+ fetchMeta: null,
290
+ isInvalidated: !1,
291
+ status: r ? "success" : "pending",
292
+ fetchStatus: "idle"
293
+ };
294
+ }
295
+ export {
296
+ w as Query,
297
+ g as fetchState
298
+ };
299
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sources":["../../../../../../../../../../node_modules/.pnpm/@tanstack+query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/query.js"],"sourcesContent":["// src/query.ts\nimport {\n ensureQueryFn,\n noop,\n replaceData,\n resolveEnabled,\n resolveStaleTime,\n skipToken,\n timeUntilStale\n} from \"./utils.js\";\nimport { notifyManager } from \"./notifyManager.js\";\nimport { CancelledError, canFetch, createRetryer } from \"./retryer.js\";\nimport { Removable } from \"./removable.js\";\nvar Query = class extends Removable {\n #initialState;\n #revertState;\n #cache;\n #client;\n #retryer;\n #defaultOptions;\n #abortSignalConsumed;\n constructor(config) {\n super();\n this.#abortSignalConsumed = false;\n this.#defaultOptions = config.defaultOptions;\n this.setOptions(config.options);\n this.observers = [];\n this.#client = config.client;\n this.#cache = this.#client.getQueryCache();\n this.queryKey = config.queryKey;\n this.queryHash = config.queryHash;\n this.#initialState = getDefaultState(this.options);\n this.state = config.state ?? this.#initialState;\n this.scheduleGc();\n }\n get meta() {\n return this.options.meta;\n }\n get promise() {\n return this.#retryer?.promise;\n }\n setOptions(options) {\n this.options = { ...this.#defaultOptions, ...options };\n this.updateGcTime(this.options.gcTime);\n }\n optionalRemove() {\n if (!this.observers.length && this.state.fetchStatus === \"idle\") {\n this.#cache.remove(this);\n }\n }\n setData(newData, options) {\n const data = replaceData(this.state.data, newData, this.options);\n this.#dispatch({\n data,\n type: \"success\",\n dataUpdatedAt: options?.updatedAt,\n manual: options?.manual\n });\n return data;\n }\n setState(state, setStateOptions) {\n this.#dispatch({ type: \"setState\", state, setStateOptions });\n }\n cancel(options) {\n const promise = this.#retryer?.promise;\n this.#retryer?.cancel(options);\n return promise ? promise.then(noop).catch(noop) : Promise.resolve();\n }\n destroy() {\n super.destroy();\n this.cancel({ silent: true });\n }\n reset() {\n this.destroy();\n this.setState(this.#initialState);\n }\n isActive() {\n return this.observers.some(\n (observer) => resolveEnabled(observer.options.enabled, this) !== false\n );\n }\n isDisabled() {\n if (this.getObserversCount() > 0) {\n return !this.isActive();\n }\n return this.options.queryFn === skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;\n }\n isStatic() {\n if (this.getObserversCount() > 0) {\n return this.observers.some(\n (observer) => resolveStaleTime(observer.options.staleTime, this) === \"static\"\n );\n }\n return false;\n }\n isStale() {\n if (this.getObserversCount() > 0) {\n return this.observers.some(\n (observer) => observer.getCurrentResult().isStale\n );\n }\n return this.state.data === void 0 || this.state.isInvalidated;\n }\n isStaleByTime(staleTime = 0) {\n if (this.state.data === void 0) {\n return true;\n }\n if (staleTime === \"static\") {\n return false;\n }\n if (this.state.isInvalidated) {\n return true;\n }\n return !timeUntilStale(this.state.dataUpdatedAt, staleTime);\n }\n onFocus() {\n const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());\n observer?.refetch({ cancelRefetch: false });\n this.#retryer?.continue();\n }\n onOnline() {\n const observer = this.observers.find((x) => x.shouldFetchOnReconnect());\n observer?.refetch({ cancelRefetch: false });\n this.#retryer?.continue();\n }\n addObserver(observer) {\n if (!this.observers.includes(observer)) {\n this.observers.push(observer);\n this.clearGcTimeout();\n this.#cache.notify({ type: \"observerAdded\", query: this, observer });\n }\n }\n removeObserver(observer) {\n if (this.observers.includes(observer)) {\n this.observers = this.observers.filter((x) => x !== observer);\n if (!this.observers.length) {\n if (this.#retryer) {\n if (this.#abortSignalConsumed) {\n this.#retryer.cancel({ revert: true });\n } else {\n this.#retryer.cancelRetry();\n }\n }\n this.scheduleGc();\n }\n this.#cache.notify({ type: \"observerRemoved\", query: this, observer });\n }\n }\n getObserversCount() {\n return this.observers.length;\n }\n invalidate() {\n if (!this.state.isInvalidated) {\n this.#dispatch({ type: \"invalidate\" });\n }\n }\n async fetch(options, fetchOptions) {\n if (this.state.fetchStatus !== \"idle\" && // If the promise in the retyer is already rejected, we have to definitely\n // re-start the fetch; there is a chance that the query is still in a\n // pending state when that happens\n this.#retryer?.status() !== \"rejected\") {\n if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {\n this.cancel({ silent: true });\n } else if (this.#retryer) {\n this.#retryer.continueRetry();\n return this.#retryer.promise;\n }\n }\n if (options) {\n this.setOptions(options);\n }\n if (!this.options.queryFn) {\n const observer = this.observers.find((x) => x.options.queryFn);\n if (observer) {\n this.setOptions(observer.options);\n }\n }\n if (process.env.NODE_ENV !== \"production\") {\n if (!Array.isArray(this.options.queryKey)) {\n console.error(\n `As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`\n );\n }\n }\n const abortController = new AbortController();\n const addSignalProperty = (object) => {\n Object.defineProperty(object, \"signal\", {\n enumerable: true,\n get: () => {\n this.#abortSignalConsumed = true;\n return abortController.signal;\n }\n });\n };\n const fetchFn = () => {\n const queryFn = ensureQueryFn(this.options, fetchOptions);\n const createQueryFnContext = () => {\n const queryFnContext2 = {\n client: this.#client,\n queryKey: this.queryKey,\n meta: this.meta\n };\n addSignalProperty(queryFnContext2);\n return queryFnContext2;\n };\n const queryFnContext = createQueryFnContext();\n this.#abortSignalConsumed = false;\n if (this.options.persister) {\n return this.options.persister(\n queryFn,\n queryFnContext,\n this\n );\n }\n return queryFn(queryFnContext);\n };\n const createFetchContext = () => {\n const context2 = {\n fetchOptions,\n options: this.options,\n queryKey: this.queryKey,\n client: this.#client,\n state: this.state,\n fetchFn\n };\n addSignalProperty(context2);\n return context2;\n };\n const context = createFetchContext();\n this.options.behavior?.onFetch(context, this);\n this.#revertState = this.state;\n if (this.state.fetchStatus === \"idle\" || this.state.fetchMeta !== context.fetchOptions?.meta) {\n this.#dispatch({ type: \"fetch\", meta: context.fetchOptions?.meta });\n }\n this.#retryer = createRetryer({\n initialPromise: fetchOptions?.initialPromise,\n fn: context.fetchFn,\n onCancel: (error) => {\n if (error instanceof CancelledError && error.revert) {\n this.setState({\n ...this.#revertState,\n fetchStatus: \"idle\"\n });\n }\n abortController.abort();\n },\n onFail: (failureCount, error) => {\n this.#dispatch({ type: \"failed\", failureCount, error });\n },\n onPause: () => {\n this.#dispatch({ type: \"pause\" });\n },\n onContinue: () => {\n this.#dispatch({ type: \"continue\" });\n },\n retry: context.options.retry,\n retryDelay: context.options.retryDelay,\n networkMode: context.options.networkMode,\n canRun: () => true\n });\n try {\n const data = await this.#retryer.start();\n if (data === void 0) {\n if (process.env.NODE_ENV !== \"production\") {\n console.error(\n `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`\n );\n }\n throw new Error(`${this.queryHash} data is undefined`);\n }\n this.setData(data);\n this.#cache.config.onSuccess?.(data, this);\n this.#cache.config.onSettled?.(\n data,\n this.state.error,\n this\n );\n return data;\n } catch (error) {\n if (error instanceof CancelledError) {\n if (error.silent) {\n return this.#retryer.promise;\n } else if (error.revert) {\n if (this.state.data === void 0) {\n throw error;\n }\n return this.state.data;\n }\n }\n this.#dispatch({\n type: \"error\",\n error\n });\n this.#cache.config.onError?.(\n error,\n this\n );\n this.#cache.config.onSettled?.(\n this.state.data,\n error,\n this\n );\n throw error;\n } finally {\n this.scheduleGc();\n }\n }\n #dispatch(action) {\n const reducer = (state) => {\n switch (action.type) {\n case \"failed\":\n return {\n ...state,\n fetchFailureCount: action.failureCount,\n fetchFailureReason: action.error\n };\n case \"pause\":\n return {\n ...state,\n fetchStatus: \"paused\"\n };\n case \"continue\":\n return {\n ...state,\n fetchStatus: \"fetching\"\n };\n case \"fetch\":\n return {\n ...state,\n ...fetchState(state.data, this.options),\n fetchMeta: action.meta ?? null\n };\n case \"success\":\n const newState = {\n ...state,\n data: action.data,\n dataUpdateCount: state.dataUpdateCount + 1,\n dataUpdatedAt: action.dataUpdatedAt ?? Date.now(),\n error: null,\n isInvalidated: false,\n status: \"success\",\n ...!action.manual && {\n fetchStatus: \"idle\",\n fetchFailureCount: 0,\n fetchFailureReason: null\n }\n };\n this.#revertState = action.manual ? newState : void 0;\n return newState;\n case \"error\":\n const error = action.error;\n return {\n ...state,\n error,\n errorUpdateCount: state.errorUpdateCount + 1,\n errorUpdatedAt: Date.now(),\n fetchFailureCount: state.fetchFailureCount + 1,\n fetchFailureReason: error,\n fetchStatus: \"idle\",\n status: \"error\"\n };\n case \"invalidate\":\n return {\n ...state,\n isInvalidated: true\n };\n case \"setState\":\n return {\n ...state,\n ...action.state\n };\n }\n };\n this.state = reducer(this.state);\n notifyManager.batch(() => {\n this.observers.forEach((observer) => {\n observer.onQueryUpdate();\n });\n this.#cache.notify({ query: this, type: \"updated\", action });\n });\n }\n};\nfunction fetchState(data, options) {\n return {\n fetchFailureCount: 0,\n fetchFailureReason: null,\n fetchStatus: canFetch(options.networkMode) ? \"fetching\" : \"paused\",\n ...data === void 0 && {\n error: null,\n status: \"pending\"\n }\n };\n}\nfunction getDefaultState(options) {\n const data = typeof options.initialData === \"function\" ? options.initialData() : options.initialData;\n const hasData = data !== void 0;\n const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === \"function\" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;\n return {\n data,\n dataUpdateCount: 0,\n dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,\n error: null,\n errorUpdateCount: 0,\n errorUpdatedAt: 0,\n fetchFailureCount: 0,\n fetchFailureReason: null,\n fetchMeta: null,\n isInvalidated: false,\n status: hasData ? \"success\" : \"pending\",\n fetchStatus: \"idle\"\n };\n}\nexport {\n Query,\n fetchState\n};\n//# sourceMappingURL=query.js.map"],"names":["Query","Removable","#initialState","#revertState","#cache","#client","#retryer","#defaultOptions","#abortSignalConsumed","config","getDefaultState","options","newData","data","replaceData","#dispatch","state","setStateOptions","promise","noop","observer","resolveEnabled","skipToken","resolveStaleTime","staleTime","timeUntilStale","x","fetchOptions","abortController","addSignalProperty","object","fetchFn","queryFn","ensureQueryFn","queryFnContext","queryFnContext2","context","context2","createRetryer","error","CancelledError","failureCount","action","reducer","fetchState","newState","notifyManager","canFetch","hasData","initialDataUpdatedAt"],"mappings":";;;;AAaG,IAACA,IAAQ,cAAcC,EAAU;AAAA,EAClCC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACAC;AAAA,EACA,YAAYC,GAAQ;AAClB,UAAO,GACP,KAAKD,KAAuB,IAC5B,KAAKD,KAAkBE,EAAO,gBAC9B,KAAK,WAAWA,EAAO,OAAO,GAC9B,KAAK,YAAY,CAAE,GACnB,KAAKJ,KAAUI,EAAO,QACtB,KAAKL,KAAS,KAAKC,GAAQ,cAAe,GAC1C,KAAK,WAAWI,EAAO,UACvB,KAAK,YAAYA,EAAO,WACxB,KAAKP,KAAgBQ,EAAgB,KAAK,OAAO,GACjD,KAAK,QAAQD,EAAO,SAAS,KAAKP,IAClC,KAAK,WAAY;AAAA,EACrB;AAAA,EACE,IAAI,OAAO;AACT,WA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MAAM;AACxB,WAAK,UAAU,QAAQ,CAAC1B,MAAa;AACnC,QAAAA,EAAS,cAAe;AAAA,MAChC,CAAO,GACD,KAAKhB,GAAO,OAAO,EAAE,OAAO,MAAM,MAAM,WAAW,QAAAsC,GAAQ;AAAA,IACjE,CAAK;AAAA,EACL;AACA;AACA,SAASE,EAAW/B,GAAMF,GAAS;AACjC,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,aAAaoC,EAASpC,EAAQ,WAAW,IAAI,aAAa;AAAA,IAC1D,GAAGE,MAAS,UAAU;AAAA,MACpB,OAAO;AAAA,MACP,QAAQ;AAAA,IACd;AAAA,EACG;AACH;AACA,SAASH,EAAgBC,GAAS;AAChC,QAAME,IAAO,OAAOF,EAAQ,eAAgB,aAAaA,EAAQ,gBAAgBA,EAAQ,aACnFqC,IAAUnC,MAAS,QACnBoC,IAAuBD,IAAU,OAAOrC,EAAQ,wBAAyB,aAAaA,EAAQ,qBAAoB,IAAKA,EAAQ,uBAAuB;AAC5J,SAAO;AAAA,IACL,MAAAE;AAAA,IACA,iBAAiB;AAAA,IACjB,eAAemC,IAAUC,KAAwB,KAAK,IAAK,IAAG;AAAA,IAC9D,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,WAAW;AAAA,IACX,eAAe;AAAA,IACf,QAAQD,IAAU,YAAY;AAAA,IAC9B,aAAa;AAAA,EACd;AACH;","x_google_ignoreList":[0]}
@@ -0,0 +1,80 @@
1
+ import { hashQueryKeyByOptions as n, matchQuery as o } from "./utils.js";
2
+ import { Query as l } from "./query.js";
3
+ import { notifyManager as i } from "./notifyManager.js";
4
+ import { Subscribable as u } from "./subscribable.js";
5
+ var g = class extends u {
6
+ constructor(t = {}) {
7
+ super(), this.config = t, this.#t = /* @__PURE__ */ new Map();
8
+ }
9
+ #t;
10
+ build(t, e, s) {
11
+ const h = e.queryKey, a = e.queryHash ?? n(h, e);
12
+ let r = this.get(a);
13
+ return r || (r = new l({
14
+ client: t,
15
+ queryKey: h,
16
+ queryHash: a,
17
+ options: t.defaultQueryOptions(e),
18
+ state: s,
19
+ defaultOptions: t.getQueryDefaults(h)
20
+ }), this.add(r)), r;
21
+ }
22
+ add(t) {
23
+ this.#t.has(t.queryHash) || (this.#t.set(t.queryHash, t), this.notify({
24
+ type: "added",
25
+ query: t
26
+ }));
27
+ }
28
+ remove(t) {
29
+ const e = this.#t.get(t.queryHash);
30
+ e && (t.destroy(), e === t && this.#t.delete(t.queryHash), this.notify({ type: "removed", query: t }));
31
+ }
32
+ clear() {
33
+ i.batch(() => {
34
+ this.getAll().forEach((t) => {
35
+ this.remove(t);
36
+ });
37
+ });
38
+ }
39
+ get(t) {
40
+ return this.#t.get(t);
41
+ }
42
+ getAll() {
43
+ return [...this.#t.values()];
44
+ }
45
+ find(t) {
46
+ const e = { exact: !0, ...t };
47
+ return this.getAll().find(
48
+ (s) => o(e, s)
49
+ );
50
+ }
51
+ findAll(t = {}) {
52
+ const e = this.getAll();
53
+ return Object.keys(t).length > 0 ? e.filter((s) => o(t, s)) : e;
54
+ }
55
+ notify(t) {
56
+ i.batch(() => {
57
+ this.listeners.forEach((e) => {
58
+ e(t);
59
+ });
60
+ });
61
+ }
62
+ onFocus() {
63
+ i.batch(() => {
64
+ this.getAll().forEach((t) => {
65
+ t.onFocus();
66
+ });
67
+ });
68
+ }
69
+ onOnline() {
70
+ i.batch(() => {
71
+ this.getAll().forEach((t) => {
72
+ t.onOnline();
73
+ });
74
+ });
75
+ }
76
+ };
77
+ export {
78
+ g as QueryCache
79
+ };
80
+ //# sourceMappingURL=queryCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryCache.js","sources":["../../../../../../../../../../node_modules/.pnpm/@tanstack+query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryCache.js"],"sourcesContent":["// src/queryCache.ts\nimport { hashQueryKeyByOptions, matchQuery } from \"./utils.js\";\nimport { Query } from \"./query.js\";\nimport { notifyManager } from \"./notifyManager.js\";\nimport { Subscribable } from \"./subscribable.js\";\nvar QueryCache = class extends Subscribable {\n constructor(config = {}) {\n super();\n this.config = config;\n this.#queries = /* @__PURE__ */ new Map();\n }\n #queries;\n build(client, options, state) {\n const queryKey = options.queryKey;\n const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);\n let query = this.get(queryHash);\n if (!query) {\n query = new Query({\n client,\n queryKey,\n queryHash,\n options: client.defaultQueryOptions(options),\n state,\n defaultOptions: client.getQueryDefaults(queryKey)\n });\n this.add(query);\n }\n return query;\n }\n add(query) {\n if (!this.#queries.has(query.queryHash)) {\n this.#queries.set(query.queryHash, query);\n this.notify({\n type: \"added\",\n query\n });\n }\n }\n remove(query) {\n const queryInMap = this.#queries.get(query.queryHash);\n if (queryInMap) {\n query.destroy();\n if (queryInMap === query) {\n this.#queries.delete(query.queryHash);\n }\n this.notify({ type: \"removed\", query });\n }\n }\n clear() {\n notifyManager.batch(() => {\n this.getAll().forEach((query) => {\n this.remove(query);\n });\n });\n }\n get(queryHash) {\n return this.#queries.get(queryHash);\n }\n getAll() {\n return [...this.#queries.values()];\n }\n find(filters) {\n const defaultedFilters = { exact: true, ...filters };\n return this.getAll().find(\n (query) => matchQuery(defaultedFilters, query)\n );\n }\n findAll(filters = {}) {\n const queries = this.getAll();\n return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;\n }\n notify(event) {\n notifyManager.batch(() => {\n this.listeners.forEach((listener) => {\n listener(event);\n });\n });\n }\n onFocus() {\n notifyManager.batch(() => {\n this.getAll().forEach((query) => {\n query.onFocus();\n });\n });\n }\n onOnline() {\n notifyManager.batch(() => {\n this.getAll().forEach((query) => {\n query.onOnline();\n });\n });\n }\n};\nexport {\n QueryCache\n};\n//# sourceMappingURL=queryCache.js.map"],"names":["QueryCache","Subscribable","config","#queries","client","options","state","queryKey","queryHash","hashQueryKeyByOptions","query","Query","queryInMap","notifyManager","filters","defaultedFilters","matchQuery","queries","event","listener"],"mappings":";;;;AAKG,IAACA,IAAa,cAAcC,EAAa;AAAA,EAC1C,YAAYC,IAAS,IAAI;AACvB,UAAO,GACP,KAAK,SAASA,GACd,KAAKC,KAA2B,oBAAI,IAAK;AAAA,EAC7C;AAAA,EACEA;AAAA,EACA,MAAMC,GAAQC,GAASC,GAAO;AAC5B,UAAMC,IAAWF,EAAQ,UACnBG,IAAYH,EAAQ,aAAaI,EAAsBF,GAAUF,CAAO;AAC9E,QAAIK,IAAQ,KAAK,IAAIF,CAAS;AAC9B,WAAKE,MACHA,IAAQ,IAAIC,EAAM;AAAA,MAChB,QAAAP;AAAA,MACA,UAAAG;AAAA,MACA,WAAAC;AAAA,MACA,SAASJ,EAAO,oBAAoBC,CAAO;AAAA,MAC3C,OAAAC;AAAA,MACA,gBAAgBF,EAAO,iBAAiBG,CAAQ;AAAA,IACxD,CAAO,GACD,KAAK,IAAIG,CAAK,IAETA;AAAA,EACX;AAAA,EACE,IAAIA,GAAO;AACT,IAAK,KAAKP,GAAS,IAAIO,EAAM,SAAS,MACpC,KAAKP,GAAS,IAAIO,EAAM,WAAWA,CAAK,GACxC,KAAK,OAAO;AAAA,MACV,MAAM;AAAA,MACN,OAAAA;AAAA,IACR,CAAO;AAAA,EAEP;AAAA,EACE,OAAOA,GAAO;AACZ,UAAME,IAAa,KAAKT,GAAS,IAAIO,EAAM,SAAS;AACpD,IAAIE,MACFF,EAAM,QAAS,GACXE,MAAeF,KACjB,KAAKP,GAAS,OAAOO,EAAM,SAAS,GAEtC,KAAK,OAAO,EAAE,MAAM,WAAW,OAAAA,EAAK,CAAE;AAAA,EAE5C;AAAA,EACE,QAAQ;AACN,IAAAG,EAAc,MAAM,MAAM;AACxB,WAAK,OAAM,EAAG,QAAQ,CAACH,MAAU;AAC/B,aAAK,OAAOA,CAAK;AAAA,MACzB,CAAO;AAAA,IACP,CAAK;AAAA,EACL;AAAA,EACE,IAAIF,GAAW;AACb,WAAO,KAAKL,GAAS,IAAIK,CAAS;AAAA,EACtC;AAAA,EACE,SAAS;AACP,WAAO,CAAC,GAAG,KAAKL,GAAS,OAAM,CAAE;AAAA,EACrC;AAAA,EACE,KAAKW,GAAS;AACZ,UAAMC,IAAmB,EAAE,OAAO,IAAM,GAAGD,EAAS;AACpD,WAAO,KAAK,OAAM,EAAG;AAAA,MACnB,CAACJ,MAAUM,EAAWD,GAAkBL,CAAK;AAAA,IAC9C;AAAA,EACL;AAAA,EACE,QAAQI,IAAU,IAAI;AACpB,UAAMG,IAAU,KAAK,OAAQ;AAC7B,WAAO,OAAO,KAAKH,CAAO,EAAE,SAAS,IAAIG,EAAQ,OAAO,CAACP,MAAUM,EAAWF,GAASJ,CAAK,CAAC,IAAIO;AAAA,EACrG;AAAA,EACE,OAAOC,GAAO;AACZ,IAAAL,EAAc,MAAM,MAAM;AACxB,WAAK,UAAU,QAAQ,CAACM,MAAa;AACnC,QAAAA,EAASD,CAAK;AAAA,MACtB,CAAO;AAAA,IACP,CAAK;AAAA,EACL;AAAA,EACE,UAAU;AACR,IAAAL,EAAc,MAAM,MAAM;AACxB,WAAK,OAAM,EAAG,QAAQ,CAACH,MAAU;AAC/B,QAAAA,EAAM,QAAS;AAAA,MACvB,CAAO;AAAA,IACP,CAAK;AAAA,EACL;AAAA,EACE,WAAW;AACT,IAAAG,EAAc,MAAM,MAAM;AACxB,WAAK,OAAM,EAAG,QAAQ,CAACH,MAAU;AAC/B,QAAAA,EAAM,SAAU;AAAA,MACxB,CAAO;AAAA,IACP,CAAK;AAAA,EACL;AACA;","x_google_ignoreList":[0]}
@@ -0,0 +1,215 @@
1
+ import { resolveStaleTime as o, functionalUpdate as y, noop as a, hashKey as c, partialMatchKey as f, hashQueryKeyByOptions as m, skipToken as p } from "./utils.js";
2
+ import { QueryCache as Q } from "./queryCache.js";
3
+ import { MutationCache as O } from "./mutationCache.js";
4
+ import { focusManager as v } from "./focusManager.js";
5
+ import { onlineManager as l } from "./onlineManager.js";
6
+ import { notifyManager as u } from "./notifyManager.js";
7
+ import { infiniteQueryBehavior as d } from "./infiniteQueryBehavior.js";
8
+ var P = class {
9
+ #e;
10
+ #t;
11
+ #r;
12
+ #i;
13
+ #a;
14
+ #s;
15
+ #u;
16
+ #n;
17
+ constructor(e = {}) {
18
+ this.#e = e.queryCache || new Q(), this.#t = e.mutationCache || new O(), this.#r = e.defaultOptions || {}, this.#i = /* @__PURE__ */ new Map(), this.#a = /* @__PURE__ */ new Map(), this.#s = 0;
19
+ }
20
+ mount() {
21
+ this.#s++, this.#s === 1 && (this.#u = v.subscribe(async (e) => {
22
+ e && (await this.resumePausedMutations(), this.#e.onFocus());
23
+ }), this.#n = l.subscribe(async (e) => {
24
+ e && (await this.resumePausedMutations(), this.#e.onOnline());
25
+ }));
26
+ }
27
+ unmount() {
28
+ this.#s--, this.#s === 0 && (this.#u?.(), this.#u = void 0, this.#n?.(), this.#n = void 0);
29
+ }
30
+ isFetching(e) {
31
+ return this.#e.findAll({ ...e, fetchStatus: "fetching" }).length;
32
+ }
33
+ isMutating(e) {
34
+ return this.#t.findAll({ ...e, status: "pending" }).length;
35
+ }
36
+ /**
37
+ * Imperative (non-reactive) way to retrieve data for a QueryKey.
38
+ * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
39
+ *
40
+ * Hint: Do not use this function inside a component, because it won't receive updates.
41
+ * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
42
+ */
43
+ getQueryData(e) {
44
+ const t = this.defaultQueryOptions({ queryKey: e });
45
+ return this.#e.get(t.queryHash)?.state.data;
46
+ }
47
+ ensureQueryData(e) {
48
+ const t = this.defaultQueryOptions(e), r = this.#e.build(this, t), s = r.state.data;
49
+ return s === void 0 ? this.fetchQuery(e) : (e.revalidateIfStale && r.isStaleByTime(o(t.staleTime, r)) && this.prefetchQuery(t), Promise.resolve(s));
50
+ }
51
+ getQueriesData(e) {
52
+ return this.#e.findAll(e).map(({ queryKey: t, state: r }) => {
53
+ const s = r.data;
54
+ return [t, s];
55
+ });
56
+ }
57
+ setQueryData(e, t, r) {
58
+ const s = this.defaultQueryOptions({ queryKey: e }), n = this.#e.get(
59
+ s.queryHash
60
+ )?.state.data, h = y(t, n);
61
+ if (h !== void 0)
62
+ return this.#e.build(this, s).setData(h, { ...r, manual: !0 });
63
+ }
64
+ setQueriesData(e, t, r) {
65
+ return u.batch(
66
+ () => this.#e.findAll(e).map(({ queryKey: s }) => [
67
+ s,
68
+ this.setQueryData(s, t, r)
69
+ ])
70
+ );
71
+ }
72
+ getQueryState(e) {
73
+ const t = this.defaultQueryOptions({ queryKey: e });
74
+ return this.#e.get(
75
+ t.queryHash
76
+ )?.state;
77
+ }
78
+ removeQueries(e) {
79
+ const t = this.#e;
80
+ u.batch(() => {
81
+ t.findAll(e).forEach((r) => {
82
+ t.remove(r);
83
+ });
84
+ });
85
+ }
86
+ resetQueries(e, t) {
87
+ const r = this.#e;
88
+ return u.batch(() => (r.findAll(e).forEach((s) => {
89
+ s.reset();
90
+ }), this.refetchQueries(
91
+ {
92
+ type: "active",
93
+ ...e
94
+ },
95
+ t
96
+ )));
97
+ }
98
+ cancelQueries(e, t = {}) {
99
+ const r = { revert: !0, ...t }, s = u.batch(
100
+ () => this.#e.findAll(e).map((i) => i.cancel(r))
101
+ );
102
+ return Promise.all(s).then(a).catch(a);
103
+ }
104
+ invalidateQueries(e, t = {}) {
105
+ return u.batch(() => (this.#e.findAll(e).forEach((r) => {
106
+ r.invalidate();
107
+ }), e?.refetchType === "none" ? Promise.resolve() : this.refetchQueries(
108
+ {
109
+ ...e,
110
+ type: e?.refetchType ?? e?.type ?? "active"
111
+ },
112
+ t
113
+ )));
114
+ }
115
+ refetchQueries(e, t = {}) {
116
+ const r = {
117
+ ...t,
118
+ cancelRefetch: t.cancelRefetch ?? !0
119
+ }, s = u.batch(
120
+ () => this.#e.findAll(e).filter((i) => !i.isDisabled() && !i.isStatic()).map((i) => {
121
+ let n = i.fetch(void 0, r);
122
+ return r.throwOnError || (n = n.catch(a)), i.state.fetchStatus === "paused" ? Promise.resolve() : n;
123
+ })
124
+ );
125
+ return Promise.all(s).then(a);
126
+ }
127
+ fetchQuery(e) {
128
+ const t = this.defaultQueryOptions(e);
129
+ t.retry === void 0 && (t.retry = !1);
130
+ const r = this.#e.build(this, t);
131
+ return r.isStaleByTime(
132
+ o(t.staleTime, r)
133
+ ) ? r.fetch(t) : Promise.resolve(r.state.data);
134
+ }
135
+ prefetchQuery(e) {
136
+ return this.fetchQuery(e).then(a).catch(a);
137
+ }
138
+ fetchInfiniteQuery(e) {
139
+ return e.behavior = d(e.pages), this.fetchQuery(e);
140
+ }
141
+ prefetchInfiniteQuery(e) {
142
+ return this.fetchInfiniteQuery(e).then(a).catch(a);
143
+ }
144
+ ensureInfiniteQueryData(e) {
145
+ return e.behavior = d(e.pages), this.ensureQueryData(e);
146
+ }
147
+ resumePausedMutations() {
148
+ return l.isOnline() ? this.#t.resumePausedMutations() : Promise.resolve();
149
+ }
150
+ getQueryCache() {
151
+ return this.#e;
152
+ }
153
+ getMutationCache() {
154
+ return this.#t;
155
+ }
156
+ getDefaultOptions() {
157
+ return this.#r;
158
+ }
159
+ setDefaultOptions(e) {
160
+ this.#r = e;
161
+ }
162
+ setQueryDefaults(e, t) {
163
+ this.#i.set(c(e), {
164
+ queryKey: e,
165
+ defaultOptions: t
166
+ });
167
+ }
168
+ getQueryDefaults(e) {
169
+ const t = [...this.#i.values()], r = {};
170
+ return t.forEach((s) => {
171
+ f(e, s.queryKey) && Object.assign(r, s.defaultOptions);
172
+ }), r;
173
+ }
174
+ setMutationDefaults(e, t) {
175
+ this.#a.set(c(e), {
176
+ mutationKey: e,
177
+ defaultOptions: t
178
+ });
179
+ }
180
+ getMutationDefaults(e) {
181
+ const t = [...this.#a.values()], r = {};
182
+ return t.forEach((s) => {
183
+ f(e, s.mutationKey) && Object.assign(r, s.defaultOptions);
184
+ }), r;
185
+ }
186
+ defaultQueryOptions(e) {
187
+ if (e._defaulted)
188
+ return e;
189
+ const t = {
190
+ ...this.#r.queries,
191
+ ...this.getQueryDefaults(e.queryKey),
192
+ ...e,
193
+ _defaulted: !0
194
+ };
195
+ return t.queryHash || (t.queryHash = m(
196
+ t.queryKey,
197
+ t
198
+ )), t.refetchOnReconnect === void 0 && (t.refetchOnReconnect = t.networkMode !== "always"), t.throwOnError === void 0 && (t.throwOnError = !!t.suspense), !t.networkMode && t.persister && (t.networkMode = "offlineFirst"), t.queryFn === p && (t.enabled = !1), t;
199
+ }
200
+ defaultMutationOptions(e) {
201
+ return e?._defaulted ? e : {
202
+ ...this.#r.mutations,
203
+ ...e?.mutationKey && this.getMutationDefaults(e.mutationKey),
204
+ ...e,
205
+ _defaulted: !0
206
+ };
207
+ }
208
+ clear() {
209
+ this.#e.clear(), this.#t.clear();
210
+ }
211
+ };
212
+ export {
213
+ P as QueryClient
214
+ };
215
+ //# sourceMappingURL=queryClient.js.map