@novu/react 2.2.0 → 2.3.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.
@@ -32,7 +32,7 @@ var src_exports = {};
32
32
  __export(src_exports, {
33
33
  Bell: () => Bell,
34
34
  Inbox: () => Inbox,
35
- InboxChild: () => InboxChild,
35
+ InboxContent: () => InboxContent,
36
36
  Notifications: () => Notifications,
37
37
  NovuProvider: () => NovuProvider,
38
38
  Preferences: () => Preferences,
@@ -45,10 +45,36 @@ __export(src_exports, {
45
45
  module.exports = __toCommonJS(src_exports);
46
46
 
47
47
  // src/components/Bell.tsx
48
- var import_react3 = __toESM(require("react"));
48
+ var import_react4 = __toESM(require("react"));
49
+
50
+ // src/components/Mounter.tsx
51
+ var import_react = require("react");
52
+ var import_jsx_runtime = require("react/jsx-runtime");
53
+ function Mounter({ mount }) {
54
+ const ref = (0, import_react.useRef)(null);
55
+ (0, import_react.useEffect)(() => {
56
+ let unmount;
57
+ const element = ref.current;
58
+ if (element && mount) {
59
+ const possibleUnmount = mount(element);
60
+ if (possibleUnmount) {
61
+ unmount = possibleUnmount;
62
+ }
63
+ }
64
+ return () => {
65
+ if (element && unmount) {
66
+ unmount(element);
67
+ }
68
+ };
69
+ }, [ref, mount]);
70
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref });
71
+ }
72
+
73
+ // src/components/Renderer.tsx
74
+ var import_react3 = require("react");
49
75
 
50
76
  // src/utils/createContextAndHook.ts
51
- var import_react = __toESM(require("react"));
77
+ var import_react2 = __toESM(require("react"));
52
78
  function assertContextExists(contextVal, msgOrCtx) {
53
79
  if (!contextVal) {
54
80
  throw typeof msgOrCtx === "string" ? new Error(msgOrCtx) : new Error(`${msgOrCtx.displayName} not found`);
@@ -56,56 +82,79 @@ function assertContextExists(contextVal, msgOrCtx) {
56
82
  }
57
83
  var createContextAndHook = (displayName, options) => {
58
84
  const { assertCtxFn = assertContextExists } = options || {};
59
- const Ctx = import_react.default.createContext(void 0);
85
+ const Ctx = import_react2.default.createContext(void 0);
60
86
  Ctx.displayName = displayName;
61
87
  const useCtx = () => {
62
- const ctx = import_react.default.useContext(Ctx);
63
- assertCtxFn(ctx, `Component must be wrapped with the <Inbox /> Component`);
88
+ const ctx = import_react2.default.useContext(Ctx);
89
+ assertCtxFn(ctx, `Component must be wrapped with ${Ctx.displayName}`);
64
90
  return ctx.value;
65
91
  };
66
92
  const useCtxWithoutGuarantee = () => {
67
- const ctx = import_react.default.useContext(Ctx);
93
+ const ctx = import_react2.default.useContext(Ctx);
68
94
  return ctx ? ctx.value : {};
69
95
  };
70
96
  return [Ctx, useCtx, useCtxWithoutGuarantee];
71
97
  };
72
98
 
73
- // src/context/RenderContext.tsx
74
- var import_jsx_runtime = require("react/jsx-runtime");
75
- var [RendererContext, useRendererContext] = createContextAndHook("RendererContext");
99
+ // src/context/RendererContext.tsx
100
+ var import_jsx_runtime2 = require("react/jsx-runtime");
101
+ var [RendererContext, useRendererContext, useUnsafeRendererContext] = createContextAndHook("RendererContext");
76
102
  var RendererProvider = (props) => {
77
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RendererContext.Provider, { value: { value: props.value }, children: props.children });
103
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RendererContext.Provider, { value: { value: props.value }, children: props.children });
78
104
  };
79
105
 
80
- // src/components/Mounter.tsx
81
- var import_react2 = __toESM(require("react"));
82
- var import_jsx_runtime2 = require("react/jsx-runtime");
83
- function Mounter({ mount }) {
84
- const ref = import_react2.default.useRef(null);
85
- import_react2.default.useEffect(() => {
86
- let unmount;
87
- const element = ref.current;
88
- if (element && mount) {
89
- const possibleUnmount = mount(element);
90
- if (possibleUnmount) {
91
- unmount = possibleUnmount;
92
- }
93
- }
94
- return () => {
95
- if (element && unmount) {
96
- unmount(element);
97
- }
98
- };
99
- }, [ref, mount]);
100
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref });
101
- }
106
+ // src/components/Renderer.tsx
107
+ var import_react_dom = require("react-dom");
108
+ var import_jsx_runtime3 = require("react/jsx-runtime");
109
+ var Renderer = (props) => {
110
+ const { children } = props;
111
+ const [mountedElements, setMountedElements] = (0, import_react3.useState)(/* @__PURE__ */ new Map());
112
+ const mountElement = (0, import_react3.useCallback)(
113
+ (el, mountedElement) => {
114
+ setMountedElements((prev) => {
115
+ const newMountedElements = new Map(prev);
116
+ newMountedElements.set(el, mountedElement);
117
+ return newMountedElements;
118
+ });
119
+ return () => {
120
+ setMountedElements((prev) => {
121
+ const newMountedElements = new Map(prev);
122
+ newMountedElements.delete(el);
123
+ return newMountedElements;
124
+ });
125
+ };
126
+ },
127
+ [setMountedElements]
128
+ );
129
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(RendererProvider, { value: { mountElement }, children: [
130
+ [...mountedElements].map(([element, mountedElement]) => {
131
+ return (0, import_react_dom.createPortal)(mountedElement, element);
132
+ }),
133
+ children
134
+ ] });
135
+ };
136
+ var withRenderer = (WrappedComponent) => {
137
+ const HOC = (props) => {
138
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Renderer, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WrappedComponent, { ...props }) });
139
+ };
140
+ HOC.displayName = `WithRenderer(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
141
+ return HOC;
142
+ };
143
+
144
+ // src/context/NovuUIContext.tsx
145
+ var import_jsx_runtime4 = require("react/jsx-runtime");
146
+ var [NovuUIContext, useNovuUIContext, useUnsafeNovuUIContext] = createContextAndHook("NovuUIContext");
147
+ var NovuUIProvider = (props) => {
148
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NovuUIContext.Provider, { value: { value: props.value }, children: props.children });
149
+ };
102
150
 
103
151
  // src/components/Bell.tsx
104
- var import_jsx_runtime3 = require("react/jsx-runtime");
105
- var Bell = import_react3.default.memo((props) => {
152
+ var import_jsx_runtime5 = require("react/jsx-runtime");
153
+ var _Bell = import_react4.default.memo((props) => {
106
154
  const { renderBell } = props;
107
- const { novuUI, mountElement } = useRendererContext();
108
- const mount = import_react3.default.useCallback(
155
+ const { novuUI } = useNovuUIContext();
156
+ const { mountElement } = useRendererContext();
157
+ const mount = import_react4.default.useCallback(
109
158
  (element) => {
110
159
  return novuUI.mountComponent({
111
160
  name: "Bell",
@@ -115,56 +164,70 @@ var Bell = import_react3.default.memo((props) => {
115
164
  },
116
165
  [renderBell]
117
166
  );
118
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Mounter, { mount });
167
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Mounter, { mount });
119
168
  });
169
+ var Bell = withRenderer(_Bell);
120
170
 
121
171
  // src/components/Inbox.tsx
122
- var import_react6 = __toESM(require("react"));
172
+ var import_react8 = __toESM(require("react"));
123
173
 
124
- // src/components/Renderer.tsx
174
+ // src/hooks/NovuProvider.tsx
175
+ var import_js = require("@novu/js");
125
176
  var import_react5 = require("react");
126
- var import_react_dom = __toESM(require("react-dom"));
177
+ var import_jsx_runtime6 = require("react/jsx-runtime");
178
+ var NovuContext = (0, import_react5.createContext)(void 0);
179
+ var NovuProvider = ({
180
+ children,
181
+ applicationIdentifier,
182
+ subscriberId,
183
+ subscriberHash,
184
+ backendUrl,
185
+ socketUrl,
186
+ useCache
187
+ }) => {
188
+ const novu = (0, import_react5.useMemo)(
189
+ () => new import_js.Novu({ applicationIdentifier, subscriberId, subscriberHash, backendUrl, socketUrl, useCache }),
190
+ [applicationIdentifier, subscriberId, subscriberHash, backendUrl, socketUrl, useCache]
191
+ );
192
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(NovuContext.Provider, { value: novu, children });
193
+ };
194
+ var useNovu = () => {
195
+ const context = (0, import_react5.useContext)(NovuContext);
196
+ if (!context) {
197
+ throw new Error("useNovu must be used within a <NovuProvider />");
198
+ }
199
+ return context;
200
+ };
201
+ var useUnsafeNovu = () => {
202
+ const context = (0, import_react5.useContext)(NovuContext);
203
+ return context;
204
+ };
205
+
206
+ // src/components/NovuUI.tsx
127
207
  var import_ui = require("@novu/js/ui");
208
+ var import_react7 = require("react");
128
209
 
129
210
  // src/hooks/internal/useDataRef.ts
130
- var import_react4 = require("react");
211
+ var import_react6 = require("react");
131
212
  var useDataRef = (data) => {
132
- const ref = (0, import_react4.useRef)(data);
213
+ const ref = (0, import_react6.useRef)(data);
133
214
  ref.current = data;
134
215
  return ref;
135
216
  };
136
217
 
137
- // src/components/Renderer.tsx
138
- var import_jsx_runtime4 = require("react/jsx-runtime");
139
- var Renderer = ({ options, novu, children }) => {
218
+ // src/components/NovuUI.tsx
219
+ var import_jsx_runtime7 = require("react/jsx-runtime");
220
+ var NovuUI = ({ options, novu, children }) => {
140
221
  const optionsRef = useDataRef({ ...options, novu });
141
- const [novuUI, setNovuUI] = (0, import_react5.useState)();
142
- const [mountedElements, setMountedElements] = (0, import_react5.useState)(/* @__PURE__ */ new Map());
143
- const mountElement = (0, import_react5.useCallback)(
144
- (el, mountedElement) => {
145
- setMountedElements((prev) => {
146
- const newMountedElements = new Map(prev);
147
- newMountedElements.set(el, mountedElement);
148
- return newMountedElements;
149
- });
150
- return () => {
151
- setMountedElements((prev) => {
152
- const newMountedElements = new Map(prev);
153
- newMountedElements.delete(el);
154
- return newMountedElements;
155
- });
156
- };
157
- },
158
- [setMountedElements]
159
- );
160
- (0, import_react5.useEffect)(() => {
222
+ const [novuUI, setNovuUI] = (0, import_react7.useState)();
223
+ (0, import_react7.useEffect)(() => {
161
224
  const novu2 = new import_ui.NovuUI(optionsRef.current);
162
225
  setNovuUI(novu2);
163
226
  return () => {
164
227
  novu2.unmount();
165
228
  };
166
229
  }, []);
167
- (0, import_react5.useEffect)(() => {
230
+ (0, import_react7.useEffect)(() => {
168
231
  if (!novuUI) {
169
232
  return;
170
233
  }
@@ -173,25 +236,20 @@ var Renderer = ({ options, novu, children }) => {
173
236
  novuUI.updateTabs(options.tabs);
174
237
  novuUI.updateOptions(options.options);
175
238
  novuUI.updateRouterPush(options.routerPush);
176
- novuUI.updatePreferencesFilter(options.preferencesFilter);
177
239
  }, [options]);
178
240
  if (!novuUI) {
179
241
  return null;
180
242
  }
181
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(RendererProvider, { value: { mountElement, novuUI }, children: [
182
- [...mountedElements].map(([element, mountedElement]) => {
183
- return import_react_dom.default.createPortal(mountedElement, element);
184
- }),
185
- children
186
- ] });
243
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(NovuUIProvider, { value: { novuUI }, children });
187
244
  };
188
245
 
189
246
  // src/components/Inbox.tsx
190
- var import_jsx_runtime5 = require("react/jsx-runtime");
191
- var DefaultInbox = (props) => {
247
+ var import_jsx_runtime8 = require("react/jsx-runtime");
248
+ var _DefaultInbox = (props) => {
192
249
  const { open, renderNotification, renderBell, onNotificationClick, onPrimaryActionClick, onSecondaryActionClick } = props;
193
- const { novuUI, mountElement } = useRendererContext();
194
- const mount = import_react6.default.useCallback(
250
+ const { novuUI } = useNovuUIContext();
251
+ const { mountElement } = useRendererContext();
252
+ const mount = import_react8.default.useCallback(
195
253
  (element) => {
196
254
  return novuUI.mountComponent({
197
255
  name: "Inbox",
@@ -208,15 +266,16 @@ var DefaultInbox = (props) => {
208
266
  },
209
267
  [open, renderNotification, renderBell, onNotificationClick, onPrimaryActionClick, onSecondaryActionClick]
210
268
  );
211
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Mounter, { mount });
269
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Mounter, { mount });
212
270
  };
213
- var Inbox = import_react6.default.memo((props) => {
271
+ var DefaultInbox = withRenderer(_DefaultInbox);
272
+ var Inbox = import_react8.default.memo((props) => {
214
273
  const { applicationIdentifier, subscriberId, subscriberHash, backendUrl, socketUrl } = props;
215
274
  const novu = useUnsafeNovu();
216
275
  if (novu) {
217
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(InboxChild, { ...props });
276
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(InboxChild, { ...props });
218
277
  }
219
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
278
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
220
279
  NovuProvider,
221
280
  {
222
281
  applicationIdentifier,
@@ -224,11 +283,11 @@ var Inbox = import_react6.default.memo((props) => {
224
283
  subscriberHash,
225
284
  backendUrl,
226
285
  socketUrl,
227
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(InboxChild, { ...props })
286
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(InboxChild, { ...props })
228
287
  }
229
288
  );
230
289
  });
231
- var InboxChild = import_react6.default.memo((props) => {
290
+ var InboxChild = import_react8.default.memo((props) => {
232
291
  const {
233
292
  localization,
234
293
  appearance,
@@ -242,7 +301,7 @@ var InboxChild = import_react6.default.memo((props) => {
242
301
  socketUrl
243
302
  } = props;
244
303
  const novu = useNovu();
245
- const options = (0, import_react6.useMemo)(() => {
304
+ const options = (0, import_react8.useMemo)(() => {
246
305
  return {
247
306
  localization,
248
307
  appearance,
@@ -263,10 +322,10 @@ var InboxChild = import_react6.default.memo((props) => {
263
322
  socketUrl
264
323
  ]);
265
324
  if (isWithChildrenProps(props)) {
266
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Renderer, { options, novu, children: props.children });
325
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NovuUI, { options, novu, children: props.children });
267
326
  }
268
327
  const { open, renderNotification, renderBell, onNotificationClick, onPrimaryActionClick, onSecondaryActionClick } = props;
269
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Renderer, { options, novu, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
328
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NovuUI, { options, novu, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
270
329
  DefaultInbox,
271
330
  {
272
331
  open,
@@ -283,26 +342,27 @@ function isWithChildrenProps(props) {
283
342
  }
284
343
 
285
344
  // src/components/Preferences.tsx
286
- var import_react7 = __toESM(require("react"));
287
- var import_jsx_runtime6 = require("react/jsx-runtime");
345
+ var import_react9 = __toESM(require("react"));
346
+ var import_jsx_runtime9 = require("react/jsx-runtime");
288
347
  var Preferences = () => {
289
- const { novuUI } = useRendererContext();
290
- const mount = import_react7.default.useCallback((element) => {
348
+ const { novuUI } = useNovuUIContext();
349
+ const mount = import_react9.default.useCallback((element) => {
291
350
  return novuUI.mountComponent({
292
351
  name: "Preferences",
293
352
  element
294
353
  });
295
354
  }, []);
296
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Mounter, { mount });
355
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Mounter, { mount });
297
356
  };
298
357
 
299
358
  // src/components/Notifications.tsx
300
- var import_react8 = __toESM(require("react"));
301
- var import_jsx_runtime7 = require("react/jsx-runtime");
302
- var Notifications = import_react8.default.memo((props) => {
359
+ var import_react10 = __toESM(require("react"));
360
+ var import_jsx_runtime10 = require("react/jsx-runtime");
361
+ var _Notifications = import_react10.default.memo((props) => {
303
362
  const { onNotificationClick, onPrimaryActionClick, renderNotification, onSecondaryActionClick } = props;
304
- const { novuUI, mountElement } = useRendererContext();
305
- const mount = import_react8.default.useCallback(
363
+ const { novuUI } = useNovuUIContext();
364
+ const { mountElement } = useRendererContext();
365
+ const mount = import_react10.default.useCallback(
306
366
  (element) => {
307
367
  return novuUI.mountComponent({
308
368
  name: "Notifications",
@@ -317,53 +377,57 @@ var Notifications = import_react8.default.memo((props) => {
317
377
  },
318
378
  [renderNotification, onNotificationClick, onPrimaryActionClick, onSecondaryActionClick]
319
379
  );
320
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Mounter, { mount });
380
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Mounter, { mount });
321
381
  });
382
+ var Notifications = withRenderer(_Notifications);
322
383
 
323
- // src/hooks/NovuProvider.tsx
324
- var import_js = require("@novu/js");
325
- var import_react9 = require("react");
326
- var import_jsx_runtime8 = require("react/jsx-runtime");
327
- var NovuContext = (0, import_react9.createContext)(void 0);
328
- var NovuProvider = ({
329
- children,
330
- applicationIdentifier,
331
- subscriberId,
332
- subscriberHash,
333
- backendUrl,
334
- socketUrl,
335
- useCache
336
- }) => {
337
- const novu = (0, import_react9.useMemo)(
338
- () => new import_js.Novu({ applicationIdentifier, subscriberId, subscriberHash, backendUrl, socketUrl, useCache }),
339
- [applicationIdentifier, subscriberId, subscriberHash, backendUrl, socketUrl, useCache]
384
+ // src/components/InboxContent.tsx
385
+ var import_react11 = __toESM(require("react"));
386
+ var import_jsx_runtime11 = require("react/jsx-runtime");
387
+ var _InboxContent = import_react11.default.memo((props) => {
388
+ const {
389
+ onNotificationClick,
390
+ onPrimaryActionClick,
391
+ renderNotification,
392
+ onSecondaryActionClick,
393
+ initialPage,
394
+ hideNav
395
+ } = props;
396
+ const { novuUI } = useNovuUIContext();
397
+ const { mountElement } = useRendererContext();
398
+ const mount = import_react11.default.useCallback(
399
+ (element) => {
400
+ return novuUI.mountComponent({
401
+ name: "InboxContent",
402
+ element,
403
+ props: {
404
+ renderNotification: renderNotification ? (el, notification) => mountElement(el, renderNotification(notification)) : void 0,
405
+ onNotificationClick,
406
+ onPrimaryActionClick,
407
+ onSecondaryActionClick,
408
+ initialPage,
409
+ hideNav
410
+ }
411
+ });
412
+ },
413
+ [renderNotification, onNotificationClick, onPrimaryActionClick, onSecondaryActionClick]
340
414
  );
341
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NovuContext.Provider, { value: novu, children });
342
- };
343
- var useNovu = () => {
344
- const context = (0, import_react9.useContext)(NovuContext);
345
- if (!context) {
346
- throw new Error("useNovu must be used within a <NovuProvider />");
347
- }
348
- return context;
349
- };
350
- var useUnsafeNovu = () => {
351
- const context = (0, import_react9.useContext)(NovuContext);
352
- return context;
353
- };
415
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Mounter, { mount });
416
+ });
417
+ var InboxContent = withRenderer(_InboxContent);
354
418
 
355
419
  // src/hooks/useNotifications.ts
356
- var import_react10 = require("react");
420
+ var import_react12 = require("react");
357
421
  var import_js2 = require("@novu/js");
358
422
  var useNotifications = (props) => {
359
423
  const { tags, read, archived = false, limit, onSuccess, onError } = props || {};
360
- const filterRef = (0, import_react10.useRef)(void 0);
424
+ const filterRef = (0, import_react12.useRef)(void 0);
361
425
  const { notifications, on, off } = useNovu();
362
- const [data, setData] = (0, import_react10.useState)();
363
- const [error, setError] = (0, import_react10.useState)();
364
- const [isLoading, setIsLoading] = (0, import_react10.useState)(true);
365
- const [isFetching, setIsFetching] = (0, import_react10.useState)(false);
366
- const [hasMore, setHasMore] = (0, import_react10.useState)(false);
426
+ const [data, setData] = (0, import_react12.useState)();
427
+ const [error, setError] = (0, import_react12.useState)();
428
+ const [isLoading, setIsLoading] = (0, import_react12.useState)(true);
429
+ const [isFetching, setIsFetching] = (0, import_react12.useState)(false);
430
+ const [hasMore, setHasMore] = (0, import_react12.useState)(false);
367
431
  const length = data?.length;
368
432
  const after = length ? data[length - 1].id : void 0;
369
433
  const sync = (event) => {
@@ -373,13 +437,13 @@ var useNotifications = (props) => {
373
437
  setData(event.data.notifications);
374
438
  setHasMore(event.data.hasMore);
375
439
  };
376
- (0, import_react10.useEffect)(() => {
440
+ (0, import_react12.useEffect)(() => {
377
441
  on("notifications.list.updated", sync);
378
442
  return () => {
379
443
  off("notifications.list.updated", sync);
380
444
  };
381
445
  }, []);
382
- (0, import_react10.useEffect)(() => {
446
+ (0, import_react12.useEffect)(() => {
383
447
  const newFilter = { tags, read, archived };
384
448
  if (filterRef.current && (0, import_js2.isSameFilter)(filterRef.current, newFilter)) {
385
449
  return;
@@ -445,21 +509,21 @@ var useNotifications = (props) => {
445
509
  };
446
510
 
447
511
  // src/hooks/usePreferences.ts
448
- var import_react11 = require("react");
512
+ var import_react13 = require("react");
449
513
  var usePreferences = (props) => {
450
514
  const { onSuccess, onError } = props || {};
451
- const [data, setData] = (0, import_react11.useState)();
515
+ const [data, setData] = (0, import_react13.useState)();
452
516
  const { preferences, on, off } = useNovu();
453
- const [error, setError] = (0, import_react11.useState)();
454
- const [isLoading, setIsLoading] = (0, import_react11.useState)(true);
455
- const [isFetching, setIsFetching] = (0, import_react11.useState)(false);
517
+ const [error, setError] = (0, import_react13.useState)();
518
+ const [isLoading, setIsLoading] = (0, import_react13.useState)(true);
519
+ const [isFetching, setIsFetching] = (0, import_react13.useState)(false);
456
520
  const sync = (event) => {
457
521
  if (!event.data) {
458
522
  return;
459
523
  }
460
524
  setData(event.data);
461
525
  };
462
- (0, import_react11.useEffect)(() => {
526
+ (0, import_react13.useEffect)(() => {
463
527
  fetchPreferences();
464
528
  on("preferences.list.updated", sync);
465
529
  on("preferences.list.pending", sync);
@@ -496,11 +560,11 @@ var usePreferences = (props) => {
496
560
  };
497
561
 
498
562
  // src/hooks/useCounts.ts
499
- var import_react14 = require("react");
563
+ var import_react16 = require("react");
500
564
  var import_js3 = require("@novu/js");
501
565
 
502
566
  // src/hooks/internal/useWebsocketEvent.ts
503
- var import_react13 = require("react");
567
+ var import_react15 = require("react");
504
568
 
505
569
  // src/utils/requestLock.ts
506
570
  function requestLock(id, cb) {
@@ -527,18 +591,18 @@ function requestLock(id, cb) {
527
591
  }
528
592
 
529
593
  // src/hooks/internal/useBrowserTabsChannel.ts
530
- var import_react12 = require("react");
594
+ var import_react14 = require("react");
531
595
  var useBrowserTabsChannel = ({
532
596
  channelName,
533
597
  onMessage
534
598
  }) => {
535
- const [tabsChannel] = (0, import_react12.useState)(
599
+ const [tabsChannel] = (0, import_react14.useState)(
536
600
  typeof BroadcastChannel !== "undefined" ? new BroadcastChannel(channelName) : void 0
537
601
  );
538
602
  const postMessage = (data) => {
539
603
  tabsChannel?.postMessage(data);
540
604
  };
541
- (0, import_react12.useEffect)(() => {
605
+ (0, import_react14.useEffect)(() => {
542
606
  const listener = (event) => {
543
607
  onMessage(event.data);
544
608
  };
@@ -561,7 +625,7 @@ var useWebSocketEvent = ({
561
625
  onMessage(data);
562
626
  postMessage(data);
563
627
  };
564
- (0, import_react13.useEffect)(() => {
628
+ (0, import_react15.useEffect)(() => {
565
629
  const resolveLock = requestLock(`nv.${webSocketEvent}`, () => {
566
630
  novu.on(webSocketEvent, updateReadCount);
567
631
  });
@@ -576,10 +640,10 @@ var useWebSocketEvent = ({
576
640
  var useCounts = (props) => {
577
641
  const { filters, onSuccess, onError } = props;
578
642
  const { notifications } = useNovu();
579
- const [error, setError] = (0, import_react14.useState)();
580
- const [counts, setCounts] = (0, import_react14.useState)();
581
- const [isLoading, setIsLoading] = (0, import_react14.useState)(true);
582
- const [isFetching, setIsFetching] = (0, import_react14.useState)(false);
643
+ const [error, setError] = (0, import_react16.useState)();
644
+ const [counts, setCounts] = (0, import_react16.useState)();
645
+ const [isLoading, setIsLoading] = (0, import_react16.useState)(true);
646
+ const [isFetching, setIsFetching] = (0, import_react16.useState)(false);
583
647
  const sync = async (notification) => {
584
648
  const existingCounts = counts ?? new Array(filters.length).fill(void 0);
585
649
  let countFiltersToFetch = [];
@@ -629,7 +693,7 @@ var useCounts = (props) => {
629
693
  sync();
630
694
  }
631
695
  });
632
- (0, import_react14.useEffect)(() => {
696
+ (0, import_react16.useEffect)(() => {
633
697
  setError(void 0);
634
698
  setIsLoading(true);
635
699
  setIsFetching(false);