@rpcbase/client 0.455.0 → 0.457.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.js CHANGED
@@ -6,8 +6,8 @@ import { getNavigationGuards, createRoutesFromElements, createBrowserRouter, Rou
6
6
  import { hydrateRoot } from "react-dom/client";
7
7
  import { r as reportClientException } from "./errorReporting-CVoUUKxW.js";
8
8
  import { s } from "./errorReporting-CVoUUKxW.js";
9
- import { h as hydrateRtsFromWindow, u as useQuery } from "./useQuery-BOjtIBwv.js";
10
- import { R, S, c as c2, a, p, b, d, e } from "./useQuery-BOjtIBwv.js";
9
+ import { h as hydrateRtsFromWindow, u as useQuery } from "./useQuery-DZqYIJog.js";
10
+ import { R, S, c as c2, a, p, b, d, e } from "./useQuery-DZqYIJog.js";
11
11
  import { r as requireToString, g as getDefaultExportFromCjs, t as throttle$1 } from "./throttle-CXOc9Dto.js";
12
12
  const emptyUnsubscribe = () => {
13
13
  };
@@ -2835,7 +2835,31 @@ const claimNotificationDeliveries = async (items, userId, appName, mode) => {
2835
2835
  return claim();
2836
2836
  }
2837
2837
  };
2838
- const showInAppNotifications = (items) => {
2838
+ const showCustomInAppNotification = (item, renderer) => {
2839
+ const action = getNotificationAction(item);
2840
+ let toastId;
2841
+ const controls = {
2842
+ dismiss: () => {
2843
+ if (toastId !== void 0) toast.dismiss(toastId);
2844
+ },
2845
+ open: () => {
2846
+ if (toastId !== void 0) toast.dismiss(toastId);
2847
+ if (action) applyNotificationAction(action);
2848
+ }
2849
+ };
2850
+ try {
2851
+ const content = renderer(item, controls);
2852
+ if (content === null || content === void 0) return false;
2853
+ toastId = toast.custom(() => /* @__PURE__ */ jsx(Fragment, { children: content }), {
2854
+ position: "top-right"
2855
+ });
2856
+ return true;
2857
+ } catch (error) {
2858
+ console.error("Failed to render custom notification toast", error);
2859
+ return false;
2860
+ }
2861
+ };
2862
+ const showInAppNotifications = (items, renderNotificationToast) => {
2839
2863
  if (items.length > 3) {
2840
2864
  toast(`${items.length} new notifications`, {
2841
2865
  ...notificationToastOptions,
@@ -2844,6 +2868,7 @@ const showInAppNotifications = (items) => {
2844
2868
  return;
2845
2869
  }
2846
2870
  for (const item of items) {
2871
+ if (renderNotificationToast && showCustomInAppNotification(item, renderNotificationToast)) continue;
2847
2872
  toast(item.title, {
2848
2873
  ...notificationToastOptions,
2849
2874
  description: item.body
@@ -2905,12 +2930,12 @@ const showNativeNotifications = async (items) => {
2905
2930
  }
2906
2931
  return shownItems;
2907
2932
  };
2908
- const showNotificationsForCurrentFocusState = async (items, userId, appName) => {
2933
+ const showNotificationsForCurrentFocusState = async (items, userId, appName, renderNotificationToast) => {
2909
2934
  writeNotificationTabState(userId, appName);
2910
2935
  if (isDocumentActive()) {
2911
2936
  const claimed2 = await claimNotificationDeliveries(items, userId, appName, "in-app");
2912
2937
  if (claimed2.length > 0) {
2913
- showInAppNotifications(claimed2);
2938
+ showInAppNotifications(claimed2, renderNotificationToast);
2914
2939
  }
2915
2940
  return [];
2916
2941
  }
@@ -2931,30 +2956,31 @@ const showNotificationsForCurrentFocusState = async (items, userId, appName) =>
2931
2956
  }
2932
2957
  return nativeItems;
2933
2958
  };
2934
- const flushPendingInAppToasts = (pendingInAppToastItems, userId, appName) => {
2959
+ const flushPendingInAppToasts = (pendingInAppToastItems, userId, appName, renderNotificationToast) => {
2935
2960
  if (!isDocumentActive()) return;
2936
2961
  const pending = sortNotificationsByCreatedAt(Array.from(pendingInAppToastItems.current.values()));
2937
2962
  pendingInAppToastItems.current.clear();
2938
2963
  if (pending.length === 0) return;
2939
2964
  void claimNotificationDeliveries(pending, userId, appName, "in-app").then((claimed) => {
2940
2965
  if (claimed.length > 0) {
2941
- showInAppNotifications(claimed);
2966
+ showInAppNotifications(claimed, renderNotificationToast);
2942
2967
  }
2943
2968
  });
2944
2969
  };
2945
- const queuePendingInAppToasts = (pendingInAppToastItems, items, userId, appName) => {
2970
+ const queuePendingInAppToasts = (pendingInAppToastItems, items, userId, appName, renderNotificationToast) => {
2946
2971
  for (const item of items) {
2947
2972
  pendingInAppToastItems.current.set(item.id, item);
2948
2973
  }
2949
- flushPendingInAppToasts(pendingInAppToastItems, userId, appName);
2974
+ flushPendingInAppToasts(pendingInAppToastItems, userId, appName, renderNotificationToast);
2950
2975
  };
2951
2976
  function NotificationsRealtimeProvider(t0) {
2952
- const $ = c(64);
2977
+ const $ = c(66);
2953
2978
  const {
2954
2979
  userId,
2955
2980
  appName,
2956
2981
  limit: t1,
2957
2982
  toastOnNew: t2,
2983
+ renderNotificationToast,
2958
2984
  children
2959
2985
  } = t0;
2960
2986
  const limit = t1 === void 0 ? 200 : t1;
@@ -3218,7 +3244,7 @@ function NotificationsRealtimeProvider(t0) {
3218
3244
  useEffect(t19, t20);
3219
3245
  let t21;
3220
3246
  let t22;
3221
- if ($[41] !== canUseRts || $[42] !== normalizedAppName || $[43] !== trimmedUserId) {
3247
+ if ($[41] !== canUseRts || $[42] !== normalizedAppName || $[43] !== renderNotificationToast || $[44] !== trimmedUserId) {
3222
3248
  t21 = () => {
3223
3249
  if (!canUseRts) {
3224
3250
  return;
@@ -3227,7 +3253,7 @@ function NotificationsRealtimeProvider(t0) {
3227
3253
  return;
3228
3254
  }
3229
3255
  const handlePendingInAppToastFlush = () => {
3230
- flushPendingInAppToasts(pendingInAppToastItems, trimmedUserId, normalizedAppName);
3256
+ flushPendingInAppToasts(pendingInAppToastItems, trimmedUserId, normalizedAppName, renderNotificationToast);
3231
3257
  };
3232
3258
  window.addEventListener("focus", handlePendingInAppToastFlush);
3233
3259
  document.addEventListener("visibilitychange", handlePendingInAppToastFlush);
@@ -3236,20 +3262,21 @@ function NotificationsRealtimeProvider(t0) {
3236
3262
  document.removeEventListener("visibilitychange", handlePendingInAppToastFlush);
3237
3263
  };
3238
3264
  };
3239
- t22 = [canUseRts, normalizedAppName, trimmedUserId];
3265
+ t22 = [canUseRts, normalizedAppName, renderNotificationToast, trimmedUserId];
3240
3266
  $[41] = canUseRts;
3241
3267
  $[42] = normalizedAppName;
3242
- $[43] = trimmedUserId;
3243
- $[44] = t21;
3244
- $[45] = t22;
3268
+ $[43] = renderNotificationToast;
3269
+ $[44] = trimmedUserId;
3270
+ $[45] = t21;
3271
+ $[46] = t22;
3245
3272
  } else {
3246
- t21 = $[44];
3247
- t22 = $[45];
3273
+ t21 = $[45];
3274
+ t22 = $[46];
3248
3275
  }
3249
3276
  useEffect(t21, t22);
3250
3277
  let t23;
3251
3278
  let t24;
3252
- if ($[46] !== canUseRts || $[47] !== normalizedAppName || $[48] !== notifications || $[49] !== notificationsQuery.loading || $[50] !== toastOnNew || $[51] !== trimmedUserId) {
3279
+ if ($[47] !== canUseRts || $[48] !== normalizedAppName || $[49] !== notifications || $[50] !== notificationsQuery.loading || $[51] !== renderNotificationToast || $[52] !== toastOnNew || $[53] !== trimmedUserId) {
3253
3280
  t23 = () => {
3254
3281
  if (!toastOnNew) {
3255
3282
  return;
@@ -3271,8 +3298,8 @@ function NotificationsRealtimeProvider(t0) {
3271
3298
  return createdAtMs >= toastStartMs.current - NEW_NOTIFICATION_START_TOLERANCE_MS;
3272
3299
  });
3273
3300
  if (eligible.length) {
3274
- showNotificationsForCurrentFocusState(eligible, trimmedUserId, normalizedAppName).then((pending) => {
3275
- queuePendingInAppToasts(pendingInAppToastItems, pending, trimmedUserId, normalizedAppName);
3301
+ showNotificationsForCurrentFocusState(eligible, trimmedUserId, normalizedAppName, renderNotificationToast).then((pending) => {
3302
+ queuePendingInAppToasts(pendingInAppToastItems, pending, trimmedUserId, normalizedAppName, renderNotificationToast);
3276
3303
  });
3277
3304
  }
3278
3305
  return;
@@ -3294,26 +3321,27 @@ function NotificationsRealtimeProvider(t0) {
3294
3321
  if (!eligible_0.length) {
3295
3322
  return;
3296
3323
  }
3297
- showNotificationsForCurrentFocusState(eligible_0, trimmedUserId, normalizedAppName).then((pending_0) => {
3298
- queuePendingInAppToasts(pendingInAppToastItems, pending_0, trimmedUserId, normalizedAppName);
3324
+ showNotificationsForCurrentFocusState(eligible_0, trimmedUserId, normalizedAppName, renderNotificationToast).then((pending_0) => {
3325
+ queuePendingInAppToasts(pendingInAppToastItems, pending_0, trimmedUserId, normalizedAppName, renderNotificationToast);
3299
3326
  });
3300
3327
  };
3301
- t24 = [canUseRts, normalizedAppName, notifications, notificationsQuery.loading, toastOnNew, trimmedUserId];
3302
- $[46] = canUseRts;
3303
- $[47] = normalizedAppName;
3304
- $[48] = notifications;
3305
- $[49] = notificationsQuery.loading;
3306
- $[50] = toastOnNew;
3307
- $[51] = trimmedUserId;
3308
- $[52] = t23;
3309
- $[53] = t24;
3328
+ t24 = [canUseRts, normalizedAppName, notifications, notificationsQuery.loading, renderNotificationToast, toastOnNew, trimmedUserId];
3329
+ $[47] = canUseRts;
3330
+ $[48] = normalizedAppName;
3331
+ $[49] = notifications;
3332
+ $[50] = notificationsQuery.loading;
3333
+ $[51] = renderNotificationToast;
3334
+ $[52] = toastOnNew;
3335
+ $[53] = trimmedUserId;
3336
+ $[54] = t23;
3337
+ $[55] = t24;
3310
3338
  } else {
3311
- t23 = $[52];
3312
- t24 = $[53];
3339
+ t23 = $[54];
3340
+ t24 = $[55];
3313
3341
  }
3314
3342
  useEffect(t23, t24);
3315
3343
  let t25;
3316
- if ($[54] !== notifications || $[55] !== notificationsQuery.error || $[56] !== notificationsQuery.loading || $[57] !== unreadCount || $[58] !== unseenCount) {
3344
+ if ($[56] !== notifications || $[57] !== notificationsQuery.error || $[58] !== notificationsQuery.loading || $[59] !== unreadCount || $[60] !== unseenCount) {
3317
3345
  t25 = {
3318
3346
  notifications,
3319
3347
  unreadCount,
@@ -3321,35 +3349,35 @@ function NotificationsRealtimeProvider(t0) {
3321
3349
  loading: notificationsQuery.loading,
3322
3350
  error: notificationsQuery.error
3323
3351
  };
3324
- $[54] = notifications;
3325
- $[55] = notificationsQuery.error;
3326
- $[56] = notificationsQuery.loading;
3327
- $[57] = unreadCount;
3328
- $[58] = unseenCount;
3329
- $[59] = t25;
3352
+ $[56] = notifications;
3353
+ $[57] = notificationsQuery.error;
3354
+ $[58] = notificationsQuery.loading;
3355
+ $[59] = unreadCount;
3356
+ $[60] = unseenCount;
3357
+ $[61] = t25;
3330
3358
  } else {
3331
- t25 = $[59];
3359
+ t25 = $[61];
3332
3360
  }
3333
3361
  const value = t25;
3334
3362
  const t26 = canUseRts ? value : null;
3335
3363
  let t27;
3336
- if ($[60] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
3364
+ if ($[62] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
3337
3365
  t27 = /* @__PURE__ */ jsx("style", { children: notificationToastStyles });
3338
- $[60] = t27;
3366
+ $[62] = t27;
3339
3367
  } else {
3340
- t27 = $[60];
3368
+ t27 = $[62];
3341
3369
  }
3342
3370
  let t28;
3343
- if ($[61] !== children || $[62] !== t26) {
3371
+ if ($[63] !== children || $[64] !== t26) {
3344
3372
  t28 = /* @__PURE__ */ jsxs(NotificationsRealtimeContext.Provider, { value: t26, children: [
3345
3373
  t27,
3346
3374
  children
3347
3375
  ] });
3348
- $[61] = children;
3349
- $[62] = t26;
3350
- $[63] = t28;
3376
+ $[63] = children;
3377
+ $[64] = t26;
3378
+ $[65] = t28;
3351
3379
  } else {
3352
- t28 = $[63];
3380
+ t28 = $[65];
3353
3381
  }
3354
3382
  return t28;
3355
3383
  }