@novu/js 2.3.1 → 2.5.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.
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ // src/ui/internal/parseMarkdown.tsx
4
+ var parseMarkdownIntoTokens = (text) => {
5
+ const tokens = [];
6
+ let buffer = "";
7
+ let inBold = false;
8
+ for (let i = 0; i < text.length; i += 1) {
9
+ if (text[i] === "\\" && text[i + 1] === "*") {
10
+ buffer += "*";
11
+ i += 1;
12
+ } else if (text[i] === "*" && text[i + 1] === "*") {
13
+ if (buffer) {
14
+ tokens.push({
15
+ type: inBold ? "bold" : "text",
16
+ content: buffer
17
+ });
18
+ buffer = "";
19
+ }
20
+ inBold = !inBold;
21
+ i += 1;
22
+ } else {
23
+ buffer += text[i];
24
+ }
25
+ }
26
+ if (buffer) {
27
+ tokens.push({
28
+ type: inBold ? "bold" : "text",
29
+ content: buffer
30
+ });
31
+ }
32
+ return tokens;
33
+ };
34
+
35
+ exports.parseMarkdownIntoTokens = parseMarkdownIntoTokens;
@@ -96,6 +96,9 @@ var NovuEventEmitter = class {
96
96
  }
97
97
  on(eventName, listener) {
98
98
  chunk7B52C2XE_js.__privateGet(this, _mittEmitter).on(eventName, listener);
99
+ return () => {
100
+ this.off(eventName, listener);
101
+ };
99
102
  }
100
103
  off(eventName, listener) {
101
104
  chunk7B52C2XE_js.__privateGet(this, _mittEmitter).off(eventName, listener);
@@ -279,8 +282,15 @@ var Notification = class {
279
282
  });
280
283
  }
281
284
  on(eventName, listener) {
282
- chunk7B52C2XE_js.__privateGet(this, _emitter).on(eventName, listener);
285
+ const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter).on(eventName, listener);
286
+ return () => {
287
+ cleanup();
288
+ };
283
289
  }
290
+ /**
291
+ * @deprecated
292
+ * Use the cleanup function returned by the "on" method instead.
293
+ */
284
294
  off(eventName, listener) {
285
295
  chunk7B52C2XE_js.__privateGet(this, _emitter).off(eventName, listener);
286
296
  }
@@ -1425,7 +1435,8 @@ var InboxService = class {
1425
1435
  chunk7B52C2XE_js.__privateAdd(this, _httpClient);
1426
1436
  chunk7B52C2XE_js.__privateSet(this, _httpClient, new client.HttpClient(options));
1427
1437
  chunk7B52C2XE_js.__privateGet(this, _httpClient).updateHeaders({
1428
- "Novu-API-Version": NOVU_API_VERSION
1438
+ "Novu-API-Version": NOVU_API_VERSION,
1439
+ "Novu-User-Agent": options.userAgent || "@novu/js"
1429
1440
  });
1430
1441
  }
1431
1442
  initializeSession(_0) {
@@ -1531,6 +1542,9 @@ var InboxService = class {
1531
1542
  _httpClient = new WeakMap();
1532
1543
 
1533
1544
  // src/novu.ts
1545
+ var version = "2.5.0";
1546
+ var name = "@novu/js";
1547
+ var userAgent = `${name}@${version}`;
1534
1548
  var _emitter7, _session, _socket, _inboxService3;
1535
1549
  var Novu = class {
1536
1550
  constructor(options) {
@@ -1538,8 +1552,11 @@ var Novu = class {
1538
1552
  chunk7B52C2XE_js.__privateAdd(this, _session);
1539
1553
  chunk7B52C2XE_js.__privateAdd(this, _socket);
1540
1554
  chunk7B52C2XE_js.__privateAdd(this, _inboxService3);
1541
- var _a, _b, _c;
1542
- chunk7B52C2XE_js.__privateSet(this, _inboxService3, new InboxService({ backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL }));
1555
+ var _a, _b, _c, _d;
1556
+ chunk7B52C2XE_js.__privateSet(this, _inboxService3, new InboxService({
1557
+ backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL,
1558
+ userAgent: (_b = options.__userAgent) != null ? _b : userAgent
1559
+ }));
1543
1560
  chunk7B52C2XE_js.__privateSet(this, _emitter7, new NovuEventEmitter());
1544
1561
  chunk7B52C2XE_js.__privateSet(this, _session, new Session(
1545
1562
  {
@@ -1552,12 +1569,12 @@ var Novu = class {
1552
1569
  ));
1553
1570
  chunk7B52C2XE_js.__privateGet(this, _session).initialize();
1554
1571
  this.notifications = new Notifications({
1555
- useCache: (_b = options.useCache) != null ? _b : true,
1572
+ useCache: (_c = options.useCache) != null ? _c : true,
1556
1573
  inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3),
1557
1574
  eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter7)
1558
1575
  });
1559
1576
  this.preferences = new Preferences({
1560
- useCache: (_c = options.useCache) != null ? _c : true,
1577
+ useCache: (_d = options.useCache) != null ? _d : true,
1561
1578
  inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3),
1562
1579
  eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter7)
1563
1580
  });
@@ -1570,7 +1587,10 @@ var Novu = class {
1570
1587
  if (chunk7B52C2XE_js.__privateGet(this, _socket).isSocketEvent(eventName)) {
1571
1588
  chunk7B52C2XE_js.__privateGet(this, _socket).initialize();
1572
1589
  }
1573
- chunk7B52C2XE_js.__privateGet(this, _emitter7).on(eventName, listener);
1590
+ const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter7).on(eventName, listener);
1591
+ return () => {
1592
+ cleanup();
1593
+ };
1574
1594
  };
1575
1595
  this.off = (eventName, listener) => {
1576
1596
  chunk7B52C2XE_js.__privateGet(this, _emitter7).off(eventName, listener);
@@ -1,5 +1,5 @@
1
- import { N as NotificationFilter } from './novu-psplDV5F.js';
2
- export { k as Action, A as ActionTypeEnum, m as ChannelPreference, f as ChannelType, C as CtaType, E as EventHandler, a as Events, F as FiltersCountResponse, q as IPreferenceOverride, I as InboxNotification, L as ListNotificationsResponse, i as MessageAction, M as MessageButton, t as Notification, e as NotificationActionStatus, d as NotificationButton, c as NotificationStatus, b as Novu, v as NovuError, s as NovuOptions, n as PaginatedResponse, u as Preference, P as PreferenceLevel, g as PreferenceOverrideSource, p as PreferenceOverrideSourceEnum, o as PreferencesResponse, R as Redirect, r as Result, h as Session, S as SocketEventNames, j as Subscriber, T as TODO, W as WebSocketEvent, l as Workflow } from './novu-psplDV5F.js';
1
+ import { N as NotificationFilter } from './novu-iUKr-1Nj.js';
2
+ export { k as Action, A as ActionTypeEnum, m as ChannelPreference, f as ChannelType, C as CtaType, E as EventHandler, a as Events, F as FiltersCountResponse, q as IPreferenceOverride, I as InboxNotification, L as ListNotificationsResponse, i as MessageAction, M as MessageButton, t as Notification, e as NotificationActionStatus, d as NotificationButton, c as NotificationStatus, b as Novu, v as NovuError, s as NovuOptions, n as PaginatedResponse, u as Preference, P as PreferenceLevel, g as PreferenceOverrideSource, p as PreferenceOverrideSourceEnum, o as PreferencesResponse, R as Redirect, r as Result, h as Session, S as SocketEventNames, j as Subscriber, T as TODO, W as WebSocketEvent, l as Workflow } from './novu-iUKr-1Nj.js';
3
3
  import '@novu/client';
4
4
 
5
5
  declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
package/dist/cjs/index.js CHANGED
@@ -1,59 +1,59 @@
1
1
  'use strict';
2
2
 
3
- var chunkAALXN67T_js = require('./chunk-AALXN67T.js');
3
+ var chunkRK2WRT5F_js = require('./chunk-RK2WRT5F.js');
4
4
  require('./chunk-7B52C2XE.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "ActionTypeEnum", {
9
9
  enumerable: true,
10
- get: function () { return chunkAALXN67T_js.ActionTypeEnum; }
10
+ get: function () { return chunkRK2WRT5F_js.ActionTypeEnum; }
11
11
  });
12
12
  Object.defineProperty(exports, "ChannelType", {
13
13
  enumerable: true,
14
- get: function () { return chunkAALXN67T_js.ChannelType; }
14
+ get: function () { return chunkRK2WRT5F_js.ChannelType; }
15
15
  });
16
16
  Object.defineProperty(exports, "CtaType", {
17
17
  enumerable: true,
18
- get: function () { return chunkAALXN67T_js.CtaType; }
18
+ get: function () { return chunkRK2WRT5F_js.CtaType; }
19
19
  });
20
20
  Object.defineProperty(exports, "NotificationActionStatus", {
21
21
  enumerable: true,
22
- get: function () { return chunkAALXN67T_js.NotificationActionStatus; }
22
+ get: function () { return chunkRK2WRT5F_js.NotificationActionStatus; }
23
23
  });
24
24
  Object.defineProperty(exports, "NotificationButton", {
25
25
  enumerable: true,
26
- get: function () { return chunkAALXN67T_js.NotificationButton; }
26
+ get: function () { return chunkRK2WRT5F_js.NotificationButton; }
27
27
  });
28
28
  Object.defineProperty(exports, "NotificationStatus", {
29
29
  enumerable: true,
30
- get: function () { return chunkAALXN67T_js.NotificationStatus; }
30
+ get: function () { return chunkRK2WRT5F_js.NotificationStatus; }
31
31
  });
32
32
  Object.defineProperty(exports, "Novu", {
33
33
  enumerable: true,
34
- get: function () { return chunkAALXN67T_js.Novu; }
34
+ get: function () { return chunkRK2WRT5F_js.Novu; }
35
35
  });
36
36
  Object.defineProperty(exports, "PreferenceLevel", {
37
37
  enumerable: true,
38
- get: function () { return chunkAALXN67T_js.PreferenceLevel; }
38
+ get: function () { return chunkRK2WRT5F_js.PreferenceLevel; }
39
39
  });
40
40
  Object.defineProperty(exports, "PreferenceOverrideSource", {
41
41
  enumerable: true,
42
- get: function () { return chunkAALXN67T_js.PreferenceOverrideSource; }
42
+ get: function () { return chunkRK2WRT5F_js.PreferenceOverrideSource; }
43
43
  });
44
44
  Object.defineProperty(exports, "PreferenceOverrideSourceEnum", {
45
45
  enumerable: true,
46
- get: function () { return chunkAALXN67T_js.PreferenceOverrideSourceEnum; }
46
+ get: function () { return chunkRK2WRT5F_js.PreferenceOverrideSourceEnum; }
47
47
  });
48
48
  Object.defineProperty(exports, "WebSocketEvent", {
49
49
  enumerable: true,
50
- get: function () { return chunkAALXN67T_js.WebSocketEvent; }
50
+ get: function () { return chunkRK2WRT5F_js.WebSocketEvent; }
51
51
  });
52
52
  Object.defineProperty(exports, "areTagsEqual", {
53
53
  enumerable: true,
54
- get: function () { return chunkAALXN67T_js.areTagsEqual; }
54
+ get: function () { return chunkRK2WRT5F_js.areTagsEqual; }
55
55
  });
56
56
  Object.defineProperty(exports, "isSameFilter", {
57
57
  enumerable: true,
58
- get: function () { return chunkAALXN67T_js.isSameFilter; }
58
+ get: function () { return chunkRK2WRT5F_js.isSameFilter; }
59
59
  });
@@ -0,0 +1,7 @@
1
+ interface Token {
2
+ type: 'bold' | 'text';
3
+ content: string;
4
+ }
5
+ declare const parseMarkdownIntoTokens: (text: string) => Token[];
6
+
7
+ export { type Token, parseMarkdownIntoTokens };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var chunkERC62PGI_js = require('../chunk-ERC62PGI.js');
4
+ require('../chunk-7B52C2XE.js');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "parseMarkdownIntoTokens", {
9
+ enumerable: true,
10
+ get: function () { return chunkERC62PGI_js.parseMarkdownIntoTokens; }
11
+ });
@@ -169,6 +169,10 @@ type NovuOptions = {
169
169
  backendUrl?: string;
170
170
  socketUrl?: string;
171
171
  useCache?: boolean;
172
+ /**
173
+ * @internal Should be used internally
174
+ */
175
+ __userAgent?: string;
172
176
  };
173
177
 
174
178
  type InboxServiceOptions = ApiOptions;
@@ -247,7 +251,7 @@ declare class BaseModule {
247
251
  callWithSession<T>(fn: () => Result<T>): Result<T>;
248
252
  }
249
253
 
250
- declare class Notification implements Pick<NovuEventEmitter, 'on' | 'off'>, InboxNotification {
254
+ declare class Notification implements Pick<NovuEventEmitter, 'on'>, InboxNotification {
251
255
  #private;
252
256
  readonly id: InboxNotification['id'];
253
257
  readonly subject?: InboxNotification['subject'];
@@ -274,7 +278,11 @@ declare class Notification implements Pick<NovuEventEmitter, 'on' | 'off'>, Inbo
274
278
  completeSecondary(): Result<Notification>;
275
279
  revertPrimary(): Result<Notification>;
276
280
  revertSecondary(): Result<Notification>;
277
- on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): void;
281
+ on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): () => void;
282
+ /**
283
+ * @deprecated
284
+ * Use the cleanup function returned by the "on" method instead.
285
+ */
278
286
  off<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): void;
279
287
  }
280
288
 
@@ -491,7 +499,7 @@ type EventHandler<T = unknown> = (event: T) => void;
491
499
  declare class NovuEventEmitter {
492
500
  #private;
493
501
  constructor();
494
- on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): void;
502
+ on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): () => void;
495
503
  off<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): void;
496
504
  emit<Key extends EventNames>(type: Key, event?: Events[Key]): void;
497
505
  }
@@ -521,11 +529,15 @@ declare class Preferences extends BaseModule {
521
529
  update(args: UpdatePreferencesArgs): Result<Preference>;
522
530
  }
523
531
 
524
- declare class Novu implements Pick<NovuEventEmitter, 'on' | 'off'> {
532
+ declare class Novu implements Pick<NovuEventEmitter, 'on'> {
525
533
  #private;
526
534
  readonly notifications: Notifications;
527
535
  readonly preferences: Preferences;
528
- on: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => void;
536
+ on: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => () => void;
537
+ /**
538
+ * @deprecated
539
+ * Use the cleanup function returned by the "on" method instead.
540
+ */
529
541
  off: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => void;
530
542
  constructor(options: NovuOptions);
531
543
  }
@@ -1,5 +1,5 @@
1
- import { g as Theme } from '../types-yDke_w6U.js';
2
- import '../novu-psplDV5F.js';
1
+ import { g as Theme } from '../types-G05b9m65.js';
2
+ import '../novu-iUKr-1Nj.js';
3
3
  import '@novu/client';
4
4
 
5
5
  declare const dark: Theme;
@@ -1,4 +1,4 @@
1
- import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-psplDV5F.js';
1
+ import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-iUKr-1Nj.js';
2
2
 
3
3
  declare const defaultLocalization: {
4
4
  readonly locale: "en-US";
@@ -1,7 +1,7 @@
1
- import { s as NovuOptions } from '../novu-psplDV5F.js';
2
- export { t as Notification } from '../novu-psplDV5F.js';
3
- import { N as NotificationRenderer, B as BellRenderer, a as NotificationClickHandler, b as NotificationActionClickHandler, c as NovuProviderProps, d as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, R as RouterPush } from '../types-yDke_w6U.js';
4
- export { e as AppearanceKey, C as CSSProperties, E as ElementStyles, f as Elements, i as LocalizationKey, h as NotificationStatus, g as Theme, V as Variables } from '../types-yDke_w6U.js';
1
+ import { s as NovuOptions } from '../novu-iUKr-1Nj.js';
2
+ export { t as Notification } from '../novu-iUKr-1Nj.js';
3
+ import { N as NotificationRenderer, B as BellRenderer, a as NotificationClickHandler, b as NotificationActionClickHandler, c as NovuProviderProps, d as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, R as RouterPush } from '../types-G05b9m65.js';
4
+ export { e as AppearanceKey, C as CSSProperties, E as ElementStyles, f as Elements, i as LocalizationKey, h as NotificationStatus, g as Theme, V as Variables } from '../types-G05b9m65.js';
5
5
  import * as solid_js from 'solid-js';
6
6
  import { ComponentProps } from 'solid-js';
7
7
  import { MountableElement } from 'solid-js/web';