@rpcbase/client 0.381.0 → 0.383.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.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -17
- package/dist/index.js.map +1 -1
- package/dist/initWithRoutes.d.ts.map +1 -1
- package/dist/rts/index.d.ts +2 -2
- package/dist/rts/index.d.ts.map +1 -1
- package/dist/rts/index.js +8 -7
- package/dist/rts/queryKey.d.ts.map +1 -1
- package/dist/rts/ssrHydration.d.ts +6 -6
- package/dist/rts/ssrHydration.d.ts.map +1 -1
- package/dist/rts/useQuery.d.ts +5 -0
- package/dist/rts/useQuery.d.ts.map +1 -1
- package/dist/rts/wsClient.d.ts +13 -0
- package/dist/rts/wsClient.d.ts.map +1 -1
- package/dist/{useQuery-n0OatV-X.js → useQuery-Ce_EmI2F.js} +369 -62
- package/dist/useQuery-Ce_EmI2F.js.map +1 -0
- package/package.json +1 -1
- package/dist/useQuery-n0OatV-X.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export * from './components/RouteErrorBoundary';
|
|
|
11
11
|
export * from './notifications';
|
|
12
12
|
export * from './notificationsRealtime';
|
|
13
13
|
export * from './errorReporting';
|
|
14
|
-
export { STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY, RtsSsrRuntimeProvider, clearHydratedRtsQueryData, hydrateRtsFromWindow, peekHydratedRtsQueryData,
|
|
14
|
+
export { STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY, RtsSsrRuntimeProvider, clearHydratedRtsQueryData, hydrateRtsFromWindow, peekHydratedRtsQueryData, peekHydratedRtsQueryPageInfo, type RtsSsrHydrationQueryData, type RtsSsrQueryRegistration, type RtsSsrRuntime, type StaticRpcbaseRtsHydrationData, } from './rts/ssrHydration';
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA;AACvB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,+BAA+B,CAAA;AAC7C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,qCAAqC,EACrC,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA;AACvB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,+BAA+B,CAAA;AAC7C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,qCAAqC,EACrC,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,6BAA6B,GACnC,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import { getNavigationGuards, createRoutesFromElements, createBrowserRouter, Rou
|
|
|
5
5
|
import { hydrateRoot } from "react-dom/client";
|
|
6
6
|
import { r as reportClientException } from "./errorReporting-CVoUUKxW.js";
|
|
7
7
|
import { s } from "./errorReporting-CVoUUKxW.js";
|
|
8
|
-
import {
|
|
9
|
-
import { R, S,
|
|
8
|
+
import { n as hydrateRtsFromWindow, v as useQuery } from "./useQuery-Ce_EmI2F.js";
|
|
9
|
+
import { R, S, p, q, t } from "./useQuery-Ce_EmI2F.js";
|
|
10
10
|
const emptyUnsubscribe = () => {
|
|
11
11
|
};
|
|
12
12
|
const useMediaQuery = (query) => {
|
|
@@ -570,6 +570,9 @@ const handleServerErrors = () => {
|
|
|
570
570
|
});
|
|
571
571
|
}
|
|
572
572
|
};
|
|
573
|
+
const clearStaticRouterHydrationData = () => {
|
|
574
|
+
delete window.__staticRouterHydrationData;
|
|
575
|
+
};
|
|
573
576
|
const wrapLoaderWithTimeout = (loader, routeId) => async (...args) => new Promise((resolve, reject) => {
|
|
574
577
|
const timer = setTimeout(() => {
|
|
575
578
|
console.error("[rpcbase timeout][client loader]", { routeId, ms: LOADER_TIMEOUT_MS, url: window.location.href });
|
|
@@ -639,10 +642,11 @@ const initWithRoutes = async (routesElement, opts) => {
|
|
|
639
642
|
await initApiClient();
|
|
640
643
|
cleanupURL();
|
|
641
644
|
handleServerErrors();
|
|
642
|
-
hydrateRtsFromWindow(
|
|
645
|
+
hydrateRtsFromWindow();
|
|
643
646
|
const routes = createRoutesFromElements(routesElement);
|
|
644
647
|
applyLoaderTimeouts(routes);
|
|
645
648
|
const router = createBrowserRouter(routes, {});
|
|
649
|
+
clearStaticRouterHydrationData();
|
|
646
650
|
installGlobalNavigationGuard(router);
|
|
647
651
|
const toError = (error) => error instanceof Error ? error : new Error(String(error));
|
|
648
652
|
const mentionsHydration = (value, depth = 0) => {
|
|
@@ -2263,10 +2267,10 @@ function NotificationsRealtimeProvider({
|
|
|
2263
2267
|
const notifications = useMemo(() => {
|
|
2264
2268
|
const raw = notificationsQuery.data;
|
|
2265
2269
|
if (!Array.isArray(raw)) return [];
|
|
2266
|
-
return raw.map((doc) => toNotificationItem(doc)).filter((
|
|
2270
|
+
return raw.map((doc) => toNotificationItem(doc)).filter((n) => Boolean(n));
|
|
2267
2271
|
}, [notificationsQuery.data]);
|
|
2268
|
-
const unreadCount = useMemo(() => notifications.reduce((acc,
|
|
2269
|
-
const unseenCount = useMemo(() => notifications.reduce((acc,
|
|
2272
|
+
const unreadCount = useMemo(() => notifications.reduce((acc, n) => acc + (n.readAt ? 0 : 1), 0), [notifications]);
|
|
2273
|
+
const unseenCount = useMemo(() => notifications.reduce((acc, n) => acc + (n.seenAt ? 0 : 1), 0), [notifications]);
|
|
2270
2274
|
const lastToastIds = useRef(/* @__PURE__ */ new Set());
|
|
2271
2275
|
const hasSeededToastIds = useRef(false);
|
|
2272
2276
|
const toastStartMs = useRef(Date.now());
|
|
@@ -2281,18 +2285,18 @@ function NotificationsRealtimeProvider({
|
|
|
2281
2285
|
if (notificationsQuery.loading) return;
|
|
2282
2286
|
if (!hasSeededToastIds.current) {
|
|
2283
2287
|
hasSeededToastIds.current = true;
|
|
2284
|
-
lastToastIds.current = new Set(notifications.map((
|
|
2288
|
+
lastToastIds.current = new Set(notifications.map((n) => n.id));
|
|
2285
2289
|
return;
|
|
2286
2290
|
}
|
|
2287
|
-
const nextNew = notifications.filter((
|
|
2291
|
+
const nextNew = notifications.filter((n) => !lastToastIds.current.has(n.id));
|
|
2288
2292
|
if (!nextNew.length) return;
|
|
2289
|
-
for (const
|
|
2290
|
-
lastToastIds.current.add(
|
|
2293
|
+
for (const n of nextNew) {
|
|
2294
|
+
lastToastIds.current.add(n.id);
|
|
2291
2295
|
}
|
|
2292
2296
|
const isTabActive = typeof document !== "undefined" && document.visibilityState === "visible";
|
|
2293
2297
|
if (!isTabActive) return;
|
|
2294
|
-
const eligible = nextNew.filter((
|
|
2295
|
-
const createdAtMs = Date.parse(
|
|
2298
|
+
const eligible = nextNew.filter((n) => {
|
|
2299
|
+
const createdAtMs = Date.parse(n.createdAt);
|
|
2296
2300
|
if (!Number.isFinite(createdAtMs)) return true;
|
|
2297
2301
|
return createdAtMs >= toastStartMs.current;
|
|
2298
2302
|
});
|
|
@@ -2301,8 +2305,8 @@ function NotificationsRealtimeProvider({
|
|
|
2301
2305
|
toast(`${eligible.length} new notifications`, { description: "Open the notifications drawer to view them." });
|
|
2302
2306
|
return;
|
|
2303
2307
|
}
|
|
2304
|
-
for (const
|
|
2305
|
-
toast(
|
|
2308
|
+
for (const n of eligible) {
|
|
2309
|
+
toast(n.title || "New notification", { description: n.body });
|
|
2306
2310
|
}
|
|
2307
2311
|
}, [canUseRts, notifications, notificationsQuery.loading, toastOnNew]);
|
|
2308
2312
|
const value = useMemo(() => ({
|
|
@@ -2328,7 +2332,7 @@ export {
|
|
|
2328
2332
|
SsrErrorFallback,
|
|
2329
2333
|
apiClient,
|
|
2330
2334
|
archiveNotification,
|
|
2331
|
-
|
|
2335
|
+
p as clearHydratedRtsQueryData,
|
|
2332
2336
|
consumeClientSsrErrorState,
|
|
2333
2337
|
getFeatureFlag,
|
|
2334
2338
|
getNotificationSettings,
|
|
@@ -2339,9 +2343,9 @@ export {
|
|
|
2339
2343
|
markAllNotificationsRead,
|
|
2340
2344
|
markNotificationRead,
|
|
2341
2345
|
peekClientSsrErrorState,
|
|
2342
|
-
|
|
2346
|
+
q as peekHydratedRtsQueryData,
|
|
2347
|
+
t as peekHydratedRtsQueryPageInfo,
|
|
2343
2348
|
reportClientException,
|
|
2344
|
-
resolveRtsHydrationIdentityFromStaticRouterData,
|
|
2345
2349
|
runNotificationDigest,
|
|
2346
2350
|
serializeSsrErrorState,
|
|
2347
2351
|
s as setClientExceptionReporter,
|