@pucp-gidis-hiisc/esm-fua-app 1.0.0

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 (95) hide show
  1. package/.turbo/turbo-extract-translations.log +11 -0
  2. package/.turbo/turbo-lint.log +0 -0
  3. package/.turbo/turbo-test.log +1 -0
  4. package/.turbo/turbo-typescript.log +0 -0
  5. package/README.md +9 -0
  6. package/dist/@pucp-gidis-hiisc/esm-dyaku-app.3156ff9f6a47f657.hot-update.js +11 -0
  7. package/dist/@pucp-gidis-hiisc/esm-dyaku-app.3156ff9f6a47f657.hot-update.js.map +1 -0
  8. package/dist/@pucp-gidis-hiisc/esm-dyaku-app.52df2f9ab9342568.hot-update.js +11 -0
  9. package/dist/@pucp-gidis-hiisc/esm-dyaku-app.52df2f9ab9342568.hot-update.js.map +1 -0
  10. package/dist/@pucp-gidis-hiisc/esm-dyaku-app.670ae221c7eb0597.hot-update.js +11 -0
  11. package/dist/@pucp-gidis-hiisc/esm-dyaku-app.670ae221c7eb0597.hot-update.js.map +1 -0
  12. package/dist/_pucp-gidis-hiisc_esm-dyaku-app.3156ff9f6a47f657.hot-update.json +1 -0
  13. package/dist/_pucp-gidis-hiisc_esm-dyaku-app.52df2f9ab9342568.hot-update.json +1 -0
  14. package/dist/_pucp-gidis-hiisc_esm-dyaku-app.670ae221c7eb0597.hot-update.json +1 -0
  15. package/dist/main.3156ff9f6a47f657.hot-update.js +11 -0
  16. package/dist/main.3156ff9f6a47f657.hot-update.js.map +1 -0
  17. package/dist/main.3156ff9f6a47f657.hot-update.json +1 -0
  18. package/dist/main.52df2f9ab9342568.hot-update.js +11 -0
  19. package/dist/main.52df2f9ab9342568.hot-update.js.map +1 -0
  20. package/dist/main.52df2f9ab9342568.hot-update.json +1 -0
  21. package/dist/main.670ae221c7eb0597.hot-update.js +11 -0
  22. package/dist/main.670ae221c7eb0597.hot-update.js.map +1 -0
  23. package/dist/main.670ae221c7eb0597.hot-update.json +1 -0
  24. package/dist/main.js +5012 -0
  25. package/dist/main.js.map +1 -0
  26. package/dist/node_modules_babel_runtime_helpers_esm_objectWithoutPropertiesLoose_js.js +28 -0
  27. package/dist/node_modules_babel_runtime_helpers_esm_objectWithoutPropertiesLoose_js.js.map +1 -0
  28. package/dist/node_modules_client-only_index_js-node_modules_use-sync-external-store_shim_index_js-_e121-_afc40.js +137 -0
  29. package/dist/node_modules_client-only_index_js-node_modules_use-sync-external-store_shim_index_js-_e121-_afc40.js.map +1 -0
  30. package/dist/node_modules_client-only_index_js-node_modules_use-sync-external-store_shim_index_js-_e121-_afc41.js +137 -0
  31. package/dist/node_modules_client-only_index_js-node_modules_use-sync-external-store_shim_index_js-_e121-_afc41.js.map +1 -0
  32. package/dist/node_modules_dayjs_dayjs_min_js.js +14 -0
  33. package/dist/node_modules_dayjs_dayjs_min_js.js.map +1 -0
  34. package/dist/pucp-gidis-hiisc-esm-dyaku-app.js +4902 -0
  35. package/dist/pucp-gidis-hiisc-esm-dyaku-app.js.buildmanifest.json +705 -0
  36. package/dist/pucp-gidis-hiisc-esm-dyaku-app.js.map +1 -0
  37. package/dist/routes.json +1 -0
  38. package/dist/src_dyaku-patients_dyaku-patients-link_component_tsx.js +46 -0
  39. package/dist/src_dyaku-patients_dyaku-patients-link_component_tsx.js.map +1 -0
  40. package/dist/src_dyaku-patients_dyaku_main_component_tsx.3156ff9f6a47f657.hot-update.js +309 -0
  41. package/dist/src_dyaku-patients_dyaku_main_component_tsx.3156ff9f6a47f657.hot-update.js.map +1 -0
  42. package/dist/src_dyaku-patients_dyaku_main_component_tsx.52df2f9ab9342568.hot-update.js +309 -0
  43. package/dist/src_dyaku-patients_dyaku_main_component_tsx.52df2f9ab9342568.hot-update.js.map +1 -0
  44. package/dist/src_dyaku-patients_dyaku_main_component_tsx.670ae221c7eb0597.hot-update.js +309 -0
  45. package/dist/src_dyaku-patients_dyaku_main_component_tsx.670ae221c7eb0597.hot-update.js.map +1 -0
  46. package/dist/src_dyaku-patients_dyaku_main_component_tsx.js +2520 -0
  47. package/dist/src_dyaku-patients_dyaku_main_component_tsx.js.map +1 -0
  48. package/dist/src_index_ts.js +146 -0
  49. package/dist/src_index_ts.js.map +1 -0
  50. package/dist/translations_en_json.js +14 -0
  51. package/dist/translations_es_json.js +14 -0
  52. package/dist/vendors-node_modules_carbon_react_es_index_js.js +121758 -0
  53. package/dist/vendors-node_modules_carbon_react_es_index_js.js.map +1 -0
  54. package/dist/vendors-node_modules_openmrs_esm-framework_src_internal_ts.js +4256 -0
  55. package/dist/vendors-node_modules_openmrs_esm-framework_src_internal_ts.js.map +1 -0
  56. package/dist/vendors-node_modules_openmrs_esm-patient-common-lib_src_index_ts.js +4200 -0
  57. package/dist/vendors-node_modules_openmrs_esm-patient-common-lib_src_index_ts.js.map +1 -0
  58. package/dist/vendors-node_modules_openmrs_esm-styleguide_src_internal_ts.js +119007 -0
  59. package/dist/vendors-node_modules_openmrs_esm-styleguide_src_internal_ts.js.map +1 -0
  60. package/dist/vendors-node_modules_react-dom_index_js.js +30632 -0
  61. package/dist/vendors-node_modules_react-dom_index_js.js.map +1 -0
  62. package/dist/vendors-node_modules_react-i18next_dist_es_index_js.js +1392 -0
  63. package/dist/vendors-node_modules_react-i18next_dist_es_index_js.js.map +1 -0
  64. package/dist/vendors-node_modules_react-router-dom_dist_index_js.js +8221 -0
  65. package/dist/vendors-node_modules_react-router-dom_dist_index_js.js.map +1 -0
  66. package/dist/vendors-node_modules_react_index_js.js +2772 -0
  67. package/dist/vendors-node_modules_react_index_js.js.map +1 -0
  68. package/dist/vendors-node_modules_rxjs__esm5_index_js.js +6245 -0
  69. package/dist/vendors-node_modules_rxjs__esm5_index_js.js.map +1 -0
  70. package/dist/vendors-node_modules_swr_dist__internal_index_mjs.js +732 -0
  71. package/dist/vendors-node_modules_swr_dist__internal_index_mjs.js.map +1 -0
  72. package/dist/vendors-node_modules_swr_dist_immutable_index_mjs.js +572 -0
  73. package/dist/vendors-node_modules_swr_dist_immutable_index_mjs.js.map +1 -0
  74. package/dist/vendors-node_modules_swr_dist_infinite_index_mjs.js +815 -0
  75. package/dist/vendors-node_modules_swr_dist_infinite_index_mjs.js.map +1 -0
  76. package/jest.config.js +3 -0
  77. package/package.json +68 -0
  78. package/src/config-schema.ts +61 -0
  79. package/src/constant.ts +1 -0
  80. package/src/dashboard.meta.tsx +8 -0
  81. package/src/declarations.d.ts +6 -0
  82. package/src/fua/case-management-header.tsx +37 -0
  83. package/src/fua/case-management-illustration.tsx +13 -0
  84. package/src/fua/fua-request-table.scss +173 -0
  85. package/src/fua/fuaRequestTable.tsx +147 -0
  86. package/src/fua/solicitudes/.gitkeep +0 -0
  87. package/src/hooks/useFuaRequests.ts +48 -0
  88. package/src/index.ts +27 -0
  89. package/src/left-panel-link.component.tsx +42 -0
  90. package/src/root.scss +102 -0
  91. package/src/routes.json +28 -0
  92. package/translations/en.json +0 -0
  93. package/translations/es.json +0 -0
  94. package/tsconfig.json +5 -0
  95. package/webpack.config.js +1 -0
@@ -0,0 +1,815 @@
1
+ "use strict";
2
+ (globalThis["webpackChunk_pucp_gidis_hiisc_esm_dyaku_app"] = globalThis["webpackChunk_pucp_gidis_hiisc_esm_dyaku_app"] || []).push([["vendors-node_modules_swr_dist_infinite_index_mjs"],{
3
+
4
+ /***/ "../../node_modules/swr/dist/infinite/index.mjs":
5
+ /*!******************************************************!*\
6
+ !*** ../../node_modules/swr/dist/infinite/index.mjs ***!
7
+ \******************************************************/
8
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
9
+
10
+ __webpack_require__.r(__webpack_exports__);
11
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12
+ /* harmony export */ "default": () => (/* binding */ useSWRInfinite),
13
+ /* harmony export */ infinite: () => (/* binding */ infinite),
14
+ /* harmony export */ unstable_serialize: () => (/* binding */ unstable_serialize)
15
+ /* harmony export */ });
16
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react/react");
17
+ /* harmony import */ var client_only__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! client-only */ "../../node_modules/client-only/index.js");
18
+ /* harmony import */ var use_sync_external_store_shim_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! use-sync-external-store/shim/index.js */ "../../node_modules/use-sync-external-store/shim/index.js");
19
+ /* harmony import */ var swr_internal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! swr/_internal */ "webpack/sharing/consume/default/swr/_internal/swr/_internal");
20
+
21
+
22
+
23
+
24
+
25
+ /// <reference types="react/experimental" />
26
+ const use = react__WEBPACK_IMPORTED_MODULE_0__.use || ((promise)=>{
27
+ if (promise.status === 'pending') {
28
+ throw promise;
29
+ } else if (promise.status === 'fulfilled') {
30
+ return promise.value;
31
+ } else if (promise.status === 'rejected') {
32
+ throw promise.reason;
33
+ } else {
34
+ promise.status = 'pending';
35
+ promise.then((v)=>{
36
+ promise.status = 'fulfilled';
37
+ promise.value = v;
38
+ }, (e)=>{
39
+ promise.status = 'rejected';
40
+ promise.reason = e;
41
+ });
42
+ throw promise;
43
+ }
44
+ });
45
+ const WITH_DEDUPE = {
46
+ dedupe: true
47
+ };
48
+ const useSWRHandler = (_key, fetcher, config)=>{
49
+ const { cache, compare, suspense, fallbackData, revalidateOnMount, revalidateIfStale, refreshInterval, refreshWhenHidden, refreshWhenOffline, keepPreviousData } = config;
50
+ const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = swr_internal__WEBPACK_IMPORTED_MODULE_3__.SWRGlobalState.get(cache);
51
+ // `key` is the identifier of the SWR internal state,
52
+ // `fnArg` is the argument/arguments parsed from the key, which will be passed
53
+ // to the fetcher.
54
+ // All of them are derived from `_key`.
55
+ const [key, fnArg] = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.serialize)(_key);
56
+ // If it's the initial render of this hook.
57
+ const initialMountedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
58
+ // If the hook is unmounted already. This will be used to prevent some effects
59
+ // to be called after unmounting.
60
+ const unmountedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
61
+ // Refs to keep the key and config.
62
+ const keyRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(key);
63
+ const fetcherRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(fetcher);
64
+ const configRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(config);
65
+ const getConfig = ()=>configRef.current;
66
+ const isActive = ()=>getConfig().isVisible() && getConfig().isOnline();
67
+ const [getCache, setCache, subscribeCache, getInitialCache] = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.createCacheHelper)(cache, key);
68
+ const stateDependencies = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)({}).current;
69
+ const fallback = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(fallbackData) ? config.fallback[key] : fallbackData;
70
+ const isEqual = (prev, current)=>{
71
+ for(const _ in stateDependencies){
72
+ const t = _;
73
+ if (t === 'data') {
74
+ if (!compare(prev[t], current[t])) {
75
+ if (!(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(prev[t])) {
76
+ return false;
77
+ }
78
+ if (!compare(returnedData, current[t])) {
79
+ return false;
80
+ }
81
+ }
82
+ } else {
83
+ if (current[t] !== prev[t]) {
84
+ return false;
85
+ }
86
+ }
87
+ }
88
+ return true;
89
+ };
90
+ const getSnapshot = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(()=>{
91
+ const shouldStartRequest = (()=>{
92
+ if (!key) return false;
93
+ if (!fetcher) return false;
94
+ // If `revalidateOnMount` is set, we take the value directly.
95
+ if (!(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(revalidateOnMount)) return revalidateOnMount;
96
+ // If it's paused, we skip revalidation.
97
+ if (getConfig().isPaused()) return false;
98
+ if (suspense) return false;
99
+ if (!(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(revalidateIfStale)) return revalidateIfStale;
100
+ return true;
101
+ })();
102
+ // Get the cache and merge it with expected states.
103
+ const getSelectedCache = (state)=>{
104
+ // We only select the needed fields from the state.
105
+ const snapshot = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.mergeObjects)(state);
106
+ delete snapshot._k;
107
+ if (!shouldStartRequest) {
108
+ return snapshot;
109
+ }
110
+ return {
111
+ isValidating: true,
112
+ isLoading: true,
113
+ ...snapshot
114
+ };
115
+ };
116
+ const cachedData = getCache();
117
+ const initialData = getInitialCache();
118
+ const clientSnapshot = getSelectedCache(cachedData);
119
+ const serverSnapshot = cachedData === initialData ? clientSnapshot : getSelectedCache(initialData);
120
+ // To make sure that we are returning the same object reference to avoid
121
+ // unnecessary re-renders, we keep the previous snapshot and use deep
122
+ // comparison to check if we need to return a new one.
123
+ let memorizedSnapshot = clientSnapshot;
124
+ return [
125
+ ()=>{
126
+ const newSnapshot = getSelectedCache(getCache());
127
+ const compareResult = isEqual(newSnapshot, memorizedSnapshot);
128
+ if (compareResult) {
129
+ // Mentally, we should always return the `memorizedSnapshot` here
130
+ // as there's no change between the new and old snapshots.
131
+ // However, since the `isEqual` function only compares selected fields,
132
+ // the values of the unselected fields might be changed. That's
133
+ // simply because we didn't track them.
134
+ // To support the case in https://github.com/vercel/swr/pull/2576,
135
+ // we need to update these fields in the `memorizedSnapshot` too
136
+ // with direct mutations to ensure the snapshot is always up-to-date
137
+ // even for the unselected fields, but only trigger re-renders when
138
+ // the selected fields are changed.
139
+ memorizedSnapshot.data = newSnapshot.data;
140
+ memorizedSnapshot.isLoading = newSnapshot.isLoading;
141
+ memorizedSnapshot.isValidating = newSnapshot.isValidating;
142
+ memorizedSnapshot.error = newSnapshot.error;
143
+ return memorizedSnapshot;
144
+ } else {
145
+ memorizedSnapshot = newSnapshot;
146
+ return newSnapshot;
147
+ }
148
+ },
149
+ ()=>serverSnapshot
150
+ ];
151
+ // eslint-disable-next-line react-hooks/exhaustive-deps
152
+ }, [
153
+ cache,
154
+ key
155
+ ]);
156
+ // Get the current state that SWR should return.
157
+ const cached = (0,use_sync_external_store_shim_index_js__WEBPACK_IMPORTED_MODULE_2__.useSyncExternalStore)((0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((callback)=>subscribeCache(key, (current, prev)=>{
158
+ if (!isEqual(prev, current)) callback();
159
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
160
+ [
161
+ cache,
162
+ key
163
+ ]), getSnapshot[0], getSnapshot[1]);
164
+ const isInitialMount = !initialMountedRef.current;
165
+ const hasRevalidator = EVENT_REVALIDATORS[key] && EVENT_REVALIDATORS[key].length > 0;
166
+ const cachedData = cached.data;
167
+ const data = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(cachedData) ? fallback : cachedData;
168
+ const error = cached.error;
169
+ // Use a ref to store previously returned data. Use the initial data as its initial value.
170
+ const laggyDataRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(data);
171
+ const returnedData = keepPreviousData ? (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(cachedData) ? laggyDataRef.current : cachedData : data;
172
+ // - Suspense mode and there's stale data for the initial render.
173
+ // - Not suspense mode and there is no fallback data and `revalidateIfStale` is enabled.
174
+ // - `revalidateIfStale` is enabled but `data` is not defined.
175
+ const shouldDoInitialRevalidation = (()=>{
176
+ // if a key already has revalidators and also has error, we should not trigger revalidation
177
+ if (hasRevalidator && !(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(error)) return false;
178
+ // If `revalidateOnMount` is set, we take the value directly.
179
+ if (isInitialMount && !(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(revalidateOnMount)) return revalidateOnMount;
180
+ // If it's paused, we skip revalidation.
181
+ if (getConfig().isPaused()) return false;
182
+ // Under suspense mode, it will always fetch on render if there is no
183
+ // stale data so no need to revalidate immediately mount it again.
184
+ // If data exists, only revalidate if `revalidateIfStale` is true.
185
+ if (suspense) return (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(data) ? false : revalidateIfStale;
186
+ // If there is no stale data, we need to revalidate when mount;
187
+ // If `revalidateIfStale` is set to true, we will always revalidate.
188
+ return (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(data) || revalidateIfStale;
189
+ })();
190
+ // Resolve the default validating state:
191
+ // If it's able to validate, and it should revalidate when mount, this will be true.
192
+ const defaultValidatingState = !!(key && fetcher && isInitialMount && shouldDoInitialRevalidation);
193
+ const isValidating = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(cached.isValidating) ? defaultValidatingState : cached.isValidating;
194
+ const isLoading = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(cached.isLoading) ? defaultValidatingState : cached.isLoading;
195
+ // The revalidation function is a carefully crafted wrapper of the original
196
+ // `fetcher`, to correctly handle the many edge cases.
197
+ const revalidate = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async (revalidateOpts)=>{
198
+ const currentFetcher = fetcherRef.current;
199
+ if (!key || !currentFetcher || unmountedRef.current || getConfig().isPaused()) {
200
+ return false;
201
+ }
202
+ let newData;
203
+ let startAt;
204
+ let loading = true;
205
+ const opts = revalidateOpts || {};
206
+ // If there is no ongoing concurrent request, or `dedupe` is not set, a
207
+ // new request should be initiated.
208
+ const shouldStartNewRequest = !FETCH[key] || !opts.dedupe;
209
+ /*
210
+ For React 17
211
+ Do unmount check for calls:
212
+ If key has changed during the revalidation, or the component has been
213
+ unmounted, old dispatch and old event callbacks should not take any
214
+ effect
215
+
216
+ For React 18
217
+ only check if key has changed
218
+ https://github.com/reactwg/react-18/discussions/82
219
+ */ const callbackSafeguard = ()=>{
220
+ if (swr_internal__WEBPACK_IMPORTED_MODULE_3__.IS_REACT_LEGACY) {
221
+ return !unmountedRef.current && key === keyRef.current && initialMountedRef.current;
222
+ }
223
+ return key === keyRef.current;
224
+ };
225
+ // The final state object when the request finishes.
226
+ const finalState = {
227
+ isValidating: false,
228
+ isLoading: false
229
+ };
230
+ const finishRequestAndUpdateState = ()=>{
231
+ setCache(finalState);
232
+ };
233
+ const cleanupState = ()=>{
234
+ // Check if it's still the same request before deleting it.
235
+ const requestInfo = FETCH[key];
236
+ if (requestInfo && requestInfo[1] === startAt) {
237
+ delete FETCH[key];
238
+ }
239
+ };
240
+ // Start fetching. Change the `isValidating` state, update the cache.
241
+ const initialState = {
242
+ isValidating: true
243
+ };
244
+ // It is in the `isLoading` state, if and only if there is no cached data.
245
+ // This bypasses fallback data and laggy data.
246
+ if ((0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(getCache().data)) {
247
+ initialState.isLoading = true;
248
+ }
249
+ try {
250
+ if (shouldStartNewRequest) {
251
+ setCache(initialState);
252
+ // If no cache is being rendered currently (it shows a blank page),
253
+ // we trigger the loading slow event.
254
+ if (config.loadingTimeout && (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(getCache().data)) {
255
+ setTimeout(()=>{
256
+ if (loading && callbackSafeguard()) {
257
+ getConfig().onLoadingSlow(key, config);
258
+ }
259
+ }, config.loadingTimeout);
260
+ }
261
+ // Start the request and save the timestamp.
262
+ // Key must be truthy if entering here.
263
+ FETCH[key] = [
264
+ currentFetcher(fnArg),
265
+ (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.getTimestamp)()
266
+ ];
267
+ }
268
+ [newData, startAt] = FETCH[key];
269
+ newData = await newData;
270
+ if (shouldStartNewRequest) {
271
+ // If the request isn't interrupted, clean it up after the
272
+ // deduplication interval.
273
+ setTimeout(cleanupState, config.dedupingInterval);
274
+ }
275
+ // If there're other ongoing request(s), started after the current one,
276
+ // we need to ignore the current one to avoid possible race conditions:
277
+ // req1------------------>res1 (current one)
278
+ // req2---------------->res2
279
+ // the request that fired later will always be kept.
280
+ // The timestamp maybe be `undefined` or a number
281
+ if (!FETCH[key] || FETCH[key][1] !== startAt) {
282
+ if (shouldStartNewRequest) {
283
+ if (callbackSafeguard()) {
284
+ getConfig().onDiscarded(key);
285
+ }
286
+ }
287
+ return false;
288
+ }
289
+ // Clear error.
290
+ finalState.error = swr_internal__WEBPACK_IMPORTED_MODULE_3__.UNDEFINED;
291
+ // If there're other mutations(s), that overlapped with the current revalidation:
292
+ // case 1:
293
+ // req------------------>res
294
+ // mutate------>end
295
+ // case 2:
296
+ // req------------>res
297
+ // mutate------>end
298
+ // case 3:
299
+ // req------------------>res
300
+ // mutate-------...---------->
301
+ // we have to ignore the revalidation result (res) because it's no longer fresh.
302
+ // meanwhile, a new revalidation should be triggered when the mutation ends.
303
+ const mutationInfo = MUTATION[key];
304
+ if (!(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(mutationInfo) && // case 1
305
+ (startAt <= mutationInfo[0] || // case 2
306
+ startAt <= mutationInfo[1] || // case 3
307
+ mutationInfo[1] === 0)) {
308
+ finishRequestAndUpdateState();
309
+ if (shouldStartNewRequest) {
310
+ if (callbackSafeguard()) {
311
+ getConfig().onDiscarded(key);
312
+ }
313
+ }
314
+ return false;
315
+ }
316
+ // Deep compare with the latest state to avoid extra re-renders.
317
+ // For local state, compare and assign.
318
+ const cacheData = getCache().data;
319
+ // Since the compare fn could be custom fn
320
+ // cacheData might be different from newData even when compare fn returns True
321
+ finalState.data = compare(cacheData, newData) ? cacheData : newData;
322
+ // Trigger the successful callback if it's the original request.
323
+ if (shouldStartNewRequest) {
324
+ if (callbackSafeguard()) {
325
+ getConfig().onSuccess(newData, key, config);
326
+ }
327
+ }
328
+ } catch (err) {
329
+ cleanupState();
330
+ const currentConfig = getConfig();
331
+ const { shouldRetryOnError } = currentConfig;
332
+ // Not paused, we continue handling the error. Otherwise, discard it.
333
+ if (!currentConfig.isPaused()) {
334
+ // Get a new error, don't use deep comparison for errors.
335
+ finalState.error = err;
336
+ // Error event and retry logic. Only for the actual request, not
337
+ // deduped ones.
338
+ if (shouldStartNewRequest && callbackSafeguard()) {
339
+ currentConfig.onError(err, key, currentConfig);
340
+ if (shouldRetryOnError === true || (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isFunction)(shouldRetryOnError) && shouldRetryOnError(err)) {
341
+ if (!getConfig().revalidateOnFocus || !getConfig().revalidateOnReconnect || isActive()) {
342
+ // If it's inactive, stop. It will auto-revalidate when
343
+ // refocusing or reconnecting.
344
+ // When retrying, deduplication is always enabled.
345
+ currentConfig.onErrorRetry(err, key, currentConfig, (_opts)=>{
346
+ const revalidators = EVENT_REVALIDATORS[key];
347
+ if (revalidators && revalidators[0]) {
348
+ revalidators[0](swr_internal__WEBPACK_IMPORTED_MODULE_3__.revalidateEvents.ERROR_REVALIDATE_EVENT, _opts);
349
+ }
350
+ }, {
351
+ retryCount: (opts.retryCount || 0) + 1,
352
+ dedupe: true
353
+ });
354
+ }
355
+ }
356
+ }
357
+ }
358
+ }
359
+ // Mark loading as stopped.
360
+ loading = false;
361
+ // Update the current hook's state.
362
+ finishRequestAndUpdateState();
363
+ return true;
364
+ }, // `setState` is immutable, and `eventsCallback`, `fnArg`, and
365
+ // `keyValidating` are depending on `key`, so we can exclude them from
366
+ // the deps array.
367
+ //
368
+ // FIXME:
369
+ // `fn` and `config` might be changed during the lifecycle,
370
+ // but they might be changed every render like this.
371
+ // `useSWR('key', () => fetch('/api/'), { suspense: true })`
372
+ // So we omit the values from the deps array
373
+ // even though it might cause unexpected behaviors.
374
+ // eslint-disable-next-line react-hooks/exhaustive-deps
375
+ [
376
+ key,
377
+ cache
378
+ ]);
379
+ // Similar to the global mutate but bound to the current cache and key.
380
+ // `cache` isn't allowed to change during the lifecycle.
381
+ const boundMutate = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(// Use callback to make sure `keyRef.current` returns latest result every time
382
+ (...args)=>{
383
+ return (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.internalMutate)(cache, keyRef.current, ...args);
384
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
385
+ []);
386
+ // The logic for updating refs.
387
+ (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.useIsomorphicLayoutEffect)(()=>{
388
+ fetcherRef.current = fetcher;
389
+ configRef.current = config;
390
+ // Handle laggy data updates. If there's cached data of the current key,
391
+ // it'll be the correct reference.
392
+ if (!(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(cachedData)) {
393
+ laggyDataRef.current = cachedData;
394
+ }
395
+ });
396
+ // After mounted or key changed.
397
+ (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.useIsomorphicLayoutEffect)(()=>{
398
+ if (!key) return;
399
+ const softRevalidate = revalidate.bind(swr_internal__WEBPACK_IMPORTED_MODULE_3__.UNDEFINED, WITH_DEDUPE);
400
+ // Expose revalidators to global event listeners. So we can trigger
401
+ // revalidation from the outside.
402
+ let nextFocusRevalidatedAt = 0;
403
+ const onRevalidate = (type, opts = {})=>{
404
+ if (type == swr_internal__WEBPACK_IMPORTED_MODULE_3__.revalidateEvents.FOCUS_EVENT) {
405
+ const now = Date.now();
406
+ if (getConfig().revalidateOnFocus && now > nextFocusRevalidatedAt && isActive()) {
407
+ nextFocusRevalidatedAt = now + getConfig().focusThrottleInterval;
408
+ softRevalidate();
409
+ }
410
+ } else if (type == swr_internal__WEBPACK_IMPORTED_MODULE_3__.revalidateEvents.RECONNECT_EVENT) {
411
+ if (getConfig().revalidateOnReconnect && isActive()) {
412
+ softRevalidate();
413
+ }
414
+ } else if (type == swr_internal__WEBPACK_IMPORTED_MODULE_3__.revalidateEvents.MUTATE_EVENT) {
415
+ return revalidate();
416
+ } else if (type == swr_internal__WEBPACK_IMPORTED_MODULE_3__.revalidateEvents.ERROR_REVALIDATE_EVENT) {
417
+ return revalidate(opts);
418
+ }
419
+ return;
420
+ };
421
+ const unsubEvents = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.subscribeCallback)(key, EVENT_REVALIDATORS, onRevalidate);
422
+ // Mark the component as mounted and update corresponding refs.
423
+ unmountedRef.current = false;
424
+ keyRef.current = key;
425
+ initialMountedRef.current = true;
426
+ // Keep the original key in the cache.
427
+ setCache({
428
+ _k: fnArg
429
+ });
430
+ // Trigger a revalidation
431
+ if (shouldDoInitialRevalidation) {
432
+ if ((0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(data) || swr_internal__WEBPACK_IMPORTED_MODULE_3__.IS_SERVER) {
433
+ // Revalidate immediately.
434
+ softRevalidate();
435
+ } else {
436
+ // Delay the revalidate if we have data to return so we won't block
437
+ // rendering.
438
+ (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.rAF)(softRevalidate);
439
+ }
440
+ }
441
+ return ()=>{
442
+ // Mark it as unmounted.
443
+ unmountedRef.current = true;
444
+ unsubEvents();
445
+ };
446
+ }, [
447
+ key
448
+ ]);
449
+ // Polling
450
+ (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.useIsomorphicLayoutEffect)(()=>{
451
+ let timer;
452
+ function next() {
453
+ // Use the passed interval
454
+ // ...or invoke the function with the updated data to get the interval
455
+ const interval = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isFunction)(refreshInterval) ? refreshInterval(getCache().data) : refreshInterval;
456
+ // We only start the next interval if `refreshInterval` is not 0, and:
457
+ // - `force` is true, which is the start of polling
458
+ // - or `timer` is not 0, which means the effect wasn't canceled
459
+ if (interval && timer !== -1) {
460
+ timer = setTimeout(execute, interval);
461
+ }
462
+ }
463
+ function execute() {
464
+ // Check if it's OK to execute:
465
+ // Only revalidate when the page is visible, online, and not errored.
466
+ if (!getCache().error && (refreshWhenHidden || getConfig().isVisible()) && (refreshWhenOffline || getConfig().isOnline())) {
467
+ revalidate(WITH_DEDUPE).then(next);
468
+ } else {
469
+ // Schedule the next interval to check again.
470
+ next();
471
+ }
472
+ }
473
+ next();
474
+ return ()=>{
475
+ if (timer) {
476
+ clearTimeout(timer);
477
+ timer = -1;
478
+ }
479
+ };
480
+ }, [
481
+ refreshInterval,
482
+ refreshWhenHidden,
483
+ refreshWhenOffline,
484
+ key
485
+ ]);
486
+ // Display debug info in React DevTools.
487
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useDebugValue)(returnedData);
488
+ // In Suspense mode, we can't return the empty `data` state.
489
+ // If there is an `error`, the `error` needs to be thrown to the error boundary.
490
+ // If there is no `error`, the `revalidation` promise needs to be thrown to
491
+ // the suspense boundary.
492
+ if (suspense && (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(data) && key) {
493
+ // SWR should throw when trying to use Suspense on the server with React 18,
494
+ // without providing any initial data. See:
495
+ // https://github.com/vercel/swr/issues/1832
496
+ if (!swr_internal__WEBPACK_IMPORTED_MODULE_3__.IS_REACT_LEGACY && swr_internal__WEBPACK_IMPORTED_MODULE_3__.IS_SERVER) {
497
+ throw new Error('Fallback data is required when using suspense in SSR.');
498
+ }
499
+ // Always update fetcher and config refs even with the Suspense mode.
500
+ fetcherRef.current = fetcher;
501
+ configRef.current = config;
502
+ unmountedRef.current = false;
503
+ const req = PRELOAD[key];
504
+ if (!(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(req)) {
505
+ const promise = boundMutate(req);
506
+ use(promise);
507
+ }
508
+ if ((0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(error)) {
509
+ const promise = revalidate(WITH_DEDUPE);
510
+ if (!(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(returnedData)) {
511
+ promise.status = 'fulfilled';
512
+ promise.value = true;
513
+ }
514
+ use(promise);
515
+ } else {
516
+ throw error;
517
+ }
518
+ }
519
+ return {
520
+ mutate: boundMutate,
521
+ get data () {
522
+ stateDependencies.data = true;
523
+ return returnedData;
524
+ },
525
+ get error () {
526
+ stateDependencies.error = true;
527
+ return error;
528
+ },
529
+ get isValidating () {
530
+ stateDependencies.isValidating = true;
531
+ return isValidating;
532
+ },
533
+ get isLoading () {
534
+ stateDependencies.isLoading = true;
535
+ return isLoading;
536
+ }
537
+ };
538
+ };
539
+ swr_internal__WEBPACK_IMPORTED_MODULE_3__.OBJECT.defineProperty(swr_internal__WEBPACK_IMPORTED_MODULE_3__.SWRConfig, 'defaultValue', {
540
+ value: swr_internal__WEBPACK_IMPORTED_MODULE_3__.defaultConfig
541
+ });
542
+ /**
543
+ * A hook to fetch data.
544
+ *
545
+ * @link https://swr.vercel.app
546
+ * @example
547
+ * ```jsx
548
+ * import useSWR from 'swr'
549
+ * function Profile() {
550
+ * const { data, error, isLoading } = useSWR('/api/user', fetcher)
551
+ * if (error) return <div>failed to load</div>
552
+ * if (isLoading) return <div>loading...</div>
553
+ * return <div>hello {data.name}!</div>
554
+ * }
555
+ * ```
556
+ */ const useSWR = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.withArgs)(useSWRHandler);
557
+
558
+ const getFirstPageKey = (getKey)=>{
559
+ return (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.serialize)(getKey ? getKey(0, null) : null)[0];
560
+ };
561
+ const unstable_serialize = (getKey)=>{
562
+ return swr_internal__WEBPACK_IMPORTED_MODULE_3__.INFINITE_PREFIX + getFirstPageKey(getKey);
563
+ };
564
+
565
+ // We have to several type castings here because `useSWRInfinite` is a special
566
+ // hook where `key` and return type are not like the normal `useSWR` types.
567
+ // const INFINITE_PREFIX = '$inf$'
568
+ const EMPTY_PROMISE = Promise.resolve();
569
+ // export const unstable_serialize = (getKey: SWRInfiniteKeyLoader) => {
570
+ // return INFINITE_PREFIX + getFirstPageKey(getKey)
571
+ // }
572
+ const infinite = (useSWRNext)=>(getKey, fn, config)=>{
573
+ const didMountRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
574
+ const { cache: cache$1, initialSize = 1, revalidateAll = false, persistSize = false, revalidateFirstPage = true, revalidateOnMount = false, parallel = false } = config;
575
+ const [, , , PRELOAD] = swr_internal__WEBPACK_IMPORTED_MODULE_3__.SWRGlobalState.get(swr_internal__WEBPACK_IMPORTED_MODULE_3__.cache);
576
+ // The serialized key of the first page. This key will be used to store
577
+ // metadata of this SWR infinite hook.
578
+ let infiniteKey;
579
+ try {
580
+ infiniteKey = getFirstPageKey(getKey);
581
+ if (infiniteKey) infiniteKey = swr_internal__WEBPACK_IMPORTED_MODULE_3__.INFINITE_PREFIX + infiniteKey;
582
+ } catch (err) {
583
+ // Not ready yet.
584
+ }
585
+ const [get, set, subscribeCache] = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.createCacheHelper)(cache$1, infiniteKey);
586
+ const getSnapshot = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(()=>{
587
+ const size = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(get()._l) ? initialSize : get()._l;
588
+ return size;
589
+ // eslint-disable-next-line react-hooks/exhaustive-deps
590
+ }, [
591
+ cache$1,
592
+ infiniteKey,
593
+ initialSize
594
+ ]);
595
+ (0,use_sync_external_store_shim_index_js__WEBPACK_IMPORTED_MODULE_2__.useSyncExternalStore)((0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((callback)=>{
596
+ if (infiniteKey) return subscribeCache(infiniteKey, ()=>{
597
+ callback();
598
+ });
599
+ return ()=>{};
600
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
601
+ [
602
+ cache$1,
603
+ infiniteKey
604
+ ]), getSnapshot, getSnapshot);
605
+ const resolvePageSize = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(()=>{
606
+ const cachedPageSize = get()._l;
607
+ return (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(cachedPageSize) ? initialSize : cachedPageSize;
608
+ // `cache` isn't allowed to change during the lifecycle
609
+ // eslint-disable-next-line react-hooks/exhaustive-deps
610
+ }, [
611
+ infiniteKey,
612
+ initialSize
613
+ ]);
614
+ // keep the last page size to restore it with the persistSize option
615
+ const lastPageSizeRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(resolvePageSize());
616
+ // When the page key changes, we reset the page size if it's not persisted
617
+ (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.useIsomorphicLayoutEffect)(()=>{
618
+ if (!didMountRef.current) {
619
+ didMountRef.current = true;
620
+ return;
621
+ }
622
+ if (infiniteKey) {
623
+ // If the key has been changed, we keep the current page size if persistSize is enabled
624
+ // Otherwise, we reset the page size to cached pageSize
625
+ set({
626
+ _l: persistSize ? lastPageSizeRef.current : resolvePageSize()
627
+ });
628
+ }
629
+ // `initialSize` isn't allowed to change during the lifecycle
630
+ // eslint-disable-next-line react-hooks/exhaustive-deps
631
+ }, [
632
+ infiniteKey,
633
+ cache$1
634
+ ]);
635
+ // Needs to check didMountRef during mounting, not in the fetcher
636
+ const shouldRevalidateOnMount = revalidateOnMount && !didMountRef.current;
637
+ // Actual SWR hook to load all pages in one fetcher.
638
+ const swr = useSWRNext(infiniteKey, async (key)=>{
639
+ // get the revalidate context
640
+ const forceRevalidateAll = get()._i;
641
+ const shouldRevalidatePage = get()._r;
642
+ set({
643
+ _r: swr_internal__WEBPACK_IMPORTED_MODULE_3__.UNDEFINED
644
+ });
645
+ // return an array of page data
646
+ const data = [];
647
+ const pageSize = resolvePageSize();
648
+ const [getCache] = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.createCacheHelper)(cache$1, key);
649
+ const cacheData = getCache().data;
650
+ const revalidators = [];
651
+ let previousPageData = null;
652
+ for(let i = 0; i < pageSize; ++i){
653
+ const [pageKey, pageArg] = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.serialize)(getKey(i, parallel ? null : previousPageData));
654
+ if (!pageKey) {
655
+ break;
656
+ }
657
+ const [getSWRCache, setSWRCache] = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.createCacheHelper)(cache$1, pageKey);
658
+ // Get the cached page data.
659
+ let pageData = getSWRCache().data;
660
+ // should fetch (or revalidate) if:
661
+ // - `revalidateAll` is enabled
662
+ // - `mutate()` called
663
+ // - the cache is missing
664
+ // - it's the first page and it's not the initial render
665
+ // - `revalidateOnMount` is enabled and it's on mount
666
+ // - cache for that page has changed
667
+ const shouldFetchPage = revalidateAll || forceRevalidateAll || (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(pageData) || revalidateFirstPage && !i && !(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(cacheData) || shouldRevalidateOnMount || cacheData && !(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(cacheData[i]) && !config.compare(cacheData[i], pageData);
668
+ if (fn && (typeof shouldRevalidatePage === 'function' ? shouldRevalidatePage(pageData, pageArg) : shouldFetchPage)) {
669
+ const revalidate = async ()=>{
670
+ const hasPreloadedRequest = pageKey in PRELOAD;
671
+ if (!hasPreloadedRequest) {
672
+ pageData = await fn(pageArg);
673
+ } else {
674
+ const req = PRELOAD[pageKey];
675
+ // delete the preload cache key before resolving it
676
+ // in case there's an error
677
+ delete PRELOAD[pageKey];
678
+ // get the page data from the preload cache
679
+ pageData = await req;
680
+ }
681
+ setSWRCache({
682
+ data: pageData,
683
+ _k: pageArg
684
+ });
685
+ data[i] = pageData;
686
+ };
687
+ if (parallel) {
688
+ revalidators.push(revalidate);
689
+ } else {
690
+ await revalidate();
691
+ }
692
+ } else {
693
+ data[i] = pageData;
694
+ }
695
+ if (!parallel) {
696
+ previousPageData = pageData;
697
+ }
698
+ }
699
+ // flush all revalidateions in parallel
700
+ if (parallel) {
701
+ await Promise.all(revalidators.map((r)=>r()));
702
+ }
703
+ // once we executed the data fetching based on the context, clear the context
704
+ set({
705
+ _i: swr_internal__WEBPACK_IMPORTED_MODULE_3__.UNDEFINED
706
+ });
707
+ // return the data
708
+ return data;
709
+ }, config);
710
+ const mutate = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(// eslint-disable-next-line func-names
711
+ function(data, opts) {
712
+ // When passing as a boolean, it's explicitly used to disable/enable
713
+ // revalidation.
714
+ const options = typeof opts === 'boolean' ? {
715
+ revalidate: opts
716
+ } : opts || {};
717
+ // Default to true.
718
+ const shouldRevalidate = options.revalidate !== false;
719
+ // It is possible that the key is still falsy.
720
+ if (!infiniteKey) return EMPTY_PROMISE;
721
+ if (shouldRevalidate) {
722
+ if (!(0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(data)) {
723
+ // We only revalidate the pages that are changed
724
+ set({
725
+ _i: false,
726
+ _r: options.revalidate
727
+ });
728
+ } else {
729
+ // Calling `mutate()`, we revalidate all pages
730
+ set({
731
+ _i: true,
732
+ _r: options.revalidate
733
+ });
734
+ }
735
+ }
736
+ return arguments.length ? swr.mutate(data, {
737
+ ...options,
738
+ revalidate: shouldRevalidate
739
+ }) : swr.mutate();
740
+ }, // swr.mutate is always the same reference
741
+ // eslint-disable-next-line react-hooks/exhaustive-deps
742
+ [
743
+ infiniteKey,
744
+ cache$1
745
+ ]);
746
+ // Extend the SWR API
747
+ const setSize = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((arg)=>{
748
+ // It is possible that the key is still falsy.
749
+ if (!infiniteKey) return EMPTY_PROMISE;
750
+ const [, changeSize] = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.createCacheHelper)(cache$1, infiniteKey);
751
+ let size;
752
+ if ((0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isFunction)(arg)) {
753
+ size = arg(resolvePageSize());
754
+ } else if (typeof arg == 'number') {
755
+ size = arg;
756
+ }
757
+ if (typeof size != 'number') return EMPTY_PROMISE;
758
+ changeSize({
759
+ _l: size
760
+ });
761
+ lastPageSizeRef.current = size;
762
+ // Calculate the page data after the size change.
763
+ const data = [];
764
+ const [getInfiniteCache] = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.createCacheHelper)(cache$1, infiniteKey);
765
+ let previousPageData = null;
766
+ for(let i = 0; i < size; ++i){
767
+ const [pageKey] = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.serialize)(getKey(i, previousPageData));
768
+ const [getCache] = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.createCacheHelper)(cache$1, pageKey);
769
+ // Get the cached page data.
770
+ const pageData = pageKey ? getCache().data : swr_internal__WEBPACK_IMPORTED_MODULE_3__.UNDEFINED;
771
+ // Call `mutate` with infinte cache data if we can't get it from the page cache.
772
+ if ((0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.isUndefined)(pageData)) {
773
+ return mutate(getInfiniteCache().data);
774
+ }
775
+ data.push(pageData);
776
+ previousPageData = pageData;
777
+ }
778
+ return mutate(data);
779
+ }, // exclude getKey from the dependencies, which isn't allowed to change during the lifecycle
780
+ // eslint-disable-next-line react-hooks/exhaustive-deps
781
+ [
782
+ infiniteKey,
783
+ cache$1,
784
+ mutate,
785
+ resolvePageSize
786
+ ]);
787
+ // Use getter functions to avoid unnecessary re-renders caused by triggering
788
+ // all the getters of the returned swr object.
789
+ return {
790
+ size: resolvePageSize(),
791
+ setSize,
792
+ mutate,
793
+ get data () {
794
+ return swr.data;
795
+ },
796
+ get error () {
797
+ return swr.error;
798
+ },
799
+ get isValidating () {
800
+ return swr.isValidating;
801
+ },
802
+ get isLoading () {
803
+ return swr.isLoading;
804
+ }
805
+ };
806
+ };
807
+ const useSWRInfinite = (0,swr_internal__WEBPACK_IMPORTED_MODULE_3__.withMiddleware)(useSWR, infinite);
808
+
809
+
810
+
811
+
812
+ /***/ })
813
+
814
+ }]);
815
+ //# sourceMappingURL=vendors-node_modules_swr_dist_infinite_index_mjs.js.map