gemi 0.54.1 → 0.54.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-h6xsczr8.js → chunk-05edp1zf.js} +2 -2
- package/dist/{chunk-h6xsczr8.js.map → chunk-05edp1zf.js.map} +1 -1
- package/dist/{chunk-03f4fkh5.js → chunk-3xa807p3.js} +1 -1
- package/dist/{chunk-qwbzd5w8.js → chunk-qq2yhtpp.js} +1 -1
- package/dist/chunks/{ThemeProvider-Bk1eZymb.js → ThemeProvider-li1J_igh.js} +26 -2
- package/dist/chunks/ThemeProvider-li1J_igh.js.map +1 -0
- package/dist/client/QueryManagerContext.d.ts +10 -0
- package/dist/client/QueryManagerContext.d.ts.map +1 -1
- package/dist/client/QueryResource.d.ts +12 -0
- package/dist/client/QueryResource.d.ts.map +1 -1
- package/dist/client/index.js +41 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/useQuery.d.ts +15 -0
- package/dist/client/useQuery.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/testing/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/ThemeProvider-Bk1eZymb.js.map +0 -1
- /package/dist/{chunk-03f4fkh5.js.map → chunk-3xa807p3.js.map} +0 -0
- /package/dist/{chunk-qwbzd5w8.js.map → chunk-qq2yhtpp.js.map} +0 -0
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as QueryError, C as I18nContext, D as useLocation, E as ServerDataProvider, F as applyParams$1, I as QueryConfigContext, L as QueryManagerContext, M as RouteStateContext, N as RouteStateProvider, P as toVariantKey, R as QueryManagerProvider, S as useNavigate, T as ServerDataContext, V as Subject, _ as setActiveLocale, a as m, b as useRoute, c as ClientRouterContext, d as ComponentsProvider, f as loadViewModule, g as registerDictionary, h as loadDictionaryForRender, i as WebSocketContextProvider, j as useParams, k as Action, l as ClientRouterProvider, m as loadDictionary, n as useTheme, o as RouteTransitionProvider, p as subscribeViewModules, r as WebSocketContext, s as useRouteTransition, t as ThemeProvider, u as ComponentsContext, v as readRoutePayload, w as I18nProvider, x as useSearchParams, y as routeDataUrl, z as DEFAULT_STALE_TIME } from "../chunks/ThemeProvider-
|
|
1
|
+
import { B as QueryError, C as I18nContext, D as useLocation, E as ServerDataProvider, F as applyParams$1, I as QueryConfigContext, L as QueryManagerContext, M as RouteStateContext, N as RouteStateProvider, P as toVariantKey, R as QueryManagerProvider, S as useNavigate, T as ServerDataContext, V as Subject, _ as setActiveLocale, a as m, b as useRoute, c as ClientRouterContext, d as ComponentsProvider, f as loadViewModule, g as registerDictionary, h as loadDictionaryForRender, i as WebSocketContextProvider, j as useParams, k as Action, l as ClientRouterProvider, m as loadDictionary, n as useTheme, o as RouteTransitionProvider, p as subscribeViewModules, r as WebSocketContext, s as useRouteTransition, t as ThemeProvider, u as ComponentsContext, v as readRoutePayload, w as I18nProvider, x as useSearchParams, y as routeDataUrl, z as DEFAULT_STALE_TIME } from "../chunks/ThemeProvider-li1J_igh.js";
|
|
2
2
|
import { Fragment, StrictMode, Suspense, createContext, createElement, isValidElement, memo, use, useCallback, useContext, useDeferredValue, useEffect, useMemo, useRef, useState, useSyncExternalStore, useTransition } from "react";
|
|
3
3
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { createRoot as createRoot$1, hydrateRoot } from "react-dom/client";
|
|
@@ -32,6 +32,8 @@ var defaultConfig = {
|
|
|
32
32
|
keepPreviousData: true,
|
|
33
33
|
retryIntervalOnError: 1e4,
|
|
34
34
|
refreshInterval: 999999,
|
|
35
|
+
revalidateOnFocus: false,
|
|
36
|
+
focusThrottleInterval: 5e3,
|
|
35
37
|
staleTime: DEFAULT_STALE_TIME,
|
|
36
38
|
debug: false,
|
|
37
39
|
lazy: false,
|
|
@@ -95,6 +97,9 @@ function useFrameworkQuery(url, ...args) {
|
|
|
95
97
|
const refetchUntilTimerRef = useRef(null);
|
|
96
98
|
const refetchUntilDurationRef = useRef(0);
|
|
97
99
|
const prefetchedRef = useRef(false);
|
|
100
|
+
const focusEligibleRef = useRef(!lazy);
|
|
101
|
+
const wasAwayRef = useRef(false);
|
|
102
|
+
const lastFocusRevalidationRef = useRef(0);
|
|
98
103
|
const subscribe = useCallback((onStoreChange) => resource.store.subscribe(onStoreChange), [resource]);
|
|
99
104
|
const getSnapshot = useCallback(() => resource.peek(variantKey), [resource, variantKey]);
|
|
100
105
|
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
@@ -188,6 +193,38 @@ function useFrameworkQuery(url, ...args) {
|
|
|
188
193
|
if (refreshIntervalRef.current) clearInterval(refreshIntervalRef.current);
|
|
189
194
|
};
|
|
190
195
|
}, [config.refreshInterval, handleReload]);
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
if (!config.revalidateOnFocus) return;
|
|
198
|
+
const markAway = () => {
|
|
199
|
+
wasAwayRef.current = true;
|
|
200
|
+
};
|
|
201
|
+
const revalidate = () => {
|
|
202
|
+
if (!focusEligibleRef.current) return;
|
|
203
|
+
if (document.visibilityState === "hidden") return;
|
|
204
|
+
if (!wasAwayRef.current) return;
|
|
205
|
+
const now = Date.now();
|
|
206
|
+
if (now - lastFocusRevalidationRef.current < configRef.current.focusThrottleInterval) return;
|
|
207
|
+
wasAwayRef.current = false;
|
|
208
|
+
lastFocusRevalidationRef.current = now;
|
|
209
|
+
resource.revalidate(variantKey, configRef.current.staleTime);
|
|
210
|
+
};
|
|
211
|
+
const onVisibilityChange = () => {
|
|
212
|
+
if (document.visibilityState === "hidden") markAway();
|
|
213
|
+
else revalidate();
|
|
214
|
+
};
|
|
215
|
+
window.addEventListener("blur", markAway);
|
|
216
|
+
window.addEventListener("focus", revalidate);
|
|
217
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
218
|
+
return () => {
|
|
219
|
+
window.removeEventListener("blur", markAway);
|
|
220
|
+
window.removeEventListener("focus", revalidate);
|
|
221
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
222
|
+
};
|
|
223
|
+
}, [
|
|
224
|
+
config.revalidateOnFocus,
|
|
225
|
+
resource,
|
|
226
|
+
variantKey
|
|
227
|
+
]);
|
|
191
228
|
useEffect(() => {
|
|
192
229
|
if (typeof import.meta.hot?.on === "function") import.meta.hot.on("http-reload", handleReload);
|
|
193
230
|
return () => {
|
|
@@ -196,6 +233,7 @@ function useFrameworkQuery(url, ...args) {
|
|
|
196
233
|
}, [handleReload]);
|
|
197
234
|
const trigger = useCallback(() => {
|
|
198
235
|
fetchedRef.current = true;
|
|
236
|
+
focusEligibleRef.current = true;
|
|
199
237
|
const variant = resource.store.getValue().get(variantKey);
|
|
200
238
|
if (!variant || !variant.loading && !variant.hasData) resource.refetch(variantKey);
|
|
201
239
|
}, [resource, variantKey]);
|
|
@@ -207,9 +245,11 @@ function useFrameworkQuery(url, ...args) {
|
|
|
207
245
|
}, [resource, variantKey]);
|
|
208
246
|
const refetch = useCallback(() => {
|
|
209
247
|
fetchedRef.current = true;
|
|
248
|
+
focusEligibleRef.current = true;
|
|
210
249
|
resource.refetch(variantKey);
|
|
211
250
|
}, [resource, variantKey]);
|
|
212
251
|
function mutate(fn) {
|
|
252
|
+
focusEligibleRef.current = true;
|
|
213
253
|
if (!fn) {
|
|
214
254
|
fetchedRef.current = true;
|
|
215
255
|
resource.refetch(variantKey);
|