@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.
- package/dist/cjs/chunk-ERC62PGI.js +35 -0
- package/dist/cjs/{chunk-AALXN67T.js → chunk-RK2WRT5F.js} +27 -7
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +14 -14
- package/dist/cjs/internal/index.d.ts +7 -0
- package/dist/cjs/internal/index.js +11 -0
- package/dist/{esm/novu-psplDV5F.d.mts → cjs/novu-iUKr-1Nj.d.ts} +17 -5
- package/dist/cjs/themes/index.d.ts +2 -2
- package/dist/cjs/{types-yDke_w6U.d.ts → types-G05b9m65.d.ts} +1 -1
- package/dist/cjs/ui/index.d.ts +4 -4
- package/dist/cjs/ui/index.js +275 -374
- package/dist/esm/chunk-GPV65U5R.mjs +33 -0
- package/dist/esm/{chunk-QIWP6QB5.mjs → chunk-YGB4AV4G.mjs} +27 -7
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/index.d.mts +7 -0
- package/dist/esm/internal/index.mjs +2 -0
- package/dist/{cjs/novu-psplDV5F.d.ts → esm/novu-iUKr-1Nj.d.mts} +17 -5
- package/dist/esm/themes/index.d.mts +2 -2
- package/dist/esm/{types-xYLv4vWZ.d.mts → types-fTgZAefu.d.mts} +1 -1
- package/dist/esm/ui/index.d.mts +4 -4
- package/dist/esm/ui/index.mjs +271 -370
- package/dist/index.css +1 -1
- package/dist/novu.min.js +5 -5
- package/dist/novu.min.js.gz +0 -0
- package/internal/package.json +5 -0
- package/package.json +13 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/ui/internal/parseMarkdown.tsx
|
|
2
|
+
var parseMarkdownIntoTokens = (text) => {
|
|
3
|
+
const tokens = [];
|
|
4
|
+
let buffer = "";
|
|
5
|
+
let inBold = false;
|
|
6
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
7
|
+
if (text[i] === "\\" && text[i + 1] === "*") {
|
|
8
|
+
buffer += "*";
|
|
9
|
+
i += 1;
|
|
10
|
+
} else if (text[i] === "*" && text[i + 1] === "*") {
|
|
11
|
+
if (buffer) {
|
|
12
|
+
tokens.push({
|
|
13
|
+
type: inBold ? "bold" : "text",
|
|
14
|
+
content: buffer
|
|
15
|
+
});
|
|
16
|
+
buffer = "";
|
|
17
|
+
}
|
|
18
|
+
inBold = !inBold;
|
|
19
|
+
i += 1;
|
|
20
|
+
} else {
|
|
21
|
+
buffer += text[i];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (buffer) {
|
|
25
|
+
tokens.push({
|
|
26
|
+
type: inBold ? "bold" : "text",
|
|
27
|
+
content: buffer
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return tokens;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { parseMarkdownIntoTokens };
|
|
@@ -89,6 +89,9 @@ var NovuEventEmitter = class {
|
|
|
89
89
|
}
|
|
90
90
|
on(eventName, listener) {
|
|
91
91
|
__privateGet(this, _mittEmitter).on(eventName, listener);
|
|
92
|
+
return () => {
|
|
93
|
+
this.off(eventName, listener);
|
|
94
|
+
};
|
|
92
95
|
}
|
|
93
96
|
off(eventName, listener) {
|
|
94
97
|
__privateGet(this, _mittEmitter).off(eventName, listener);
|
|
@@ -272,8 +275,15 @@ var Notification = class {
|
|
|
272
275
|
});
|
|
273
276
|
}
|
|
274
277
|
on(eventName, listener) {
|
|
275
|
-
__privateGet(this, _emitter).on(eventName, listener);
|
|
278
|
+
const cleanup = __privateGet(this, _emitter).on(eventName, listener);
|
|
279
|
+
return () => {
|
|
280
|
+
cleanup();
|
|
281
|
+
};
|
|
276
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* @deprecated
|
|
285
|
+
* Use the cleanup function returned by the "on" method instead.
|
|
286
|
+
*/
|
|
277
287
|
off(eventName, listener) {
|
|
278
288
|
__privateGet(this, _emitter).off(eventName, listener);
|
|
279
289
|
}
|
|
@@ -1418,7 +1428,8 @@ var InboxService = class {
|
|
|
1418
1428
|
__privateAdd(this, _httpClient);
|
|
1419
1429
|
__privateSet(this, _httpClient, new HttpClient(options));
|
|
1420
1430
|
__privateGet(this, _httpClient).updateHeaders({
|
|
1421
|
-
"Novu-API-Version": NOVU_API_VERSION
|
|
1431
|
+
"Novu-API-Version": NOVU_API_VERSION,
|
|
1432
|
+
"Novu-User-Agent": options.userAgent || "@novu/js"
|
|
1422
1433
|
});
|
|
1423
1434
|
}
|
|
1424
1435
|
initializeSession(_0) {
|
|
@@ -1524,6 +1535,9 @@ var InboxService = class {
|
|
|
1524
1535
|
_httpClient = new WeakMap();
|
|
1525
1536
|
|
|
1526
1537
|
// src/novu.ts
|
|
1538
|
+
var version = "2.5.0";
|
|
1539
|
+
var name = "@novu/js";
|
|
1540
|
+
var userAgent = `${name}@${version}`;
|
|
1527
1541
|
var _emitter7, _session, _socket, _inboxService3;
|
|
1528
1542
|
var Novu = class {
|
|
1529
1543
|
constructor(options) {
|
|
@@ -1531,8 +1545,11 @@ var Novu = class {
|
|
|
1531
1545
|
__privateAdd(this, _session);
|
|
1532
1546
|
__privateAdd(this, _socket);
|
|
1533
1547
|
__privateAdd(this, _inboxService3);
|
|
1534
|
-
var _a, _b, _c;
|
|
1535
|
-
__privateSet(this, _inboxService3, new InboxService({
|
|
1548
|
+
var _a, _b, _c, _d;
|
|
1549
|
+
__privateSet(this, _inboxService3, new InboxService({
|
|
1550
|
+
backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL,
|
|
1551
|
+
userAgent: (_b = options.__userAgent) != null ? _b : userAgent
|
|
1552
|
+
}));
|
|
1536
1553
|
__privateSet(this, _emitter7, new NovuEventEmitter());
|
|
1537
1554
|
__privateSet(this, _session, new Session(
|
|
1538
1555
|
{
|
|
@@ -1545,12 +1562,12 @@ var Novu = class {
|
|
|
1545
1562
|
));
|
|
1546
1563
|
__privateGet(this, _session).initialize();
|
|
1547
1564
|
this.notifications = new Notifications({
|
|
1548
|
-
useCache: (
|
|
1565
|
+
useCache: (_c = options.useCache) != null ? _c : true,
|
|
1549
1566
|
inboxServiceInstance: __privateGet(this, _inboxService3),
|
|
1550
1567
|
eventEmitterInstance: __privateGet(this, _emitter7)
|
|
1551
1568
|
});
|
|
1552
1569
|
this.preferences = new Preferences({
|
|
1553
|
-
useCache: (
|
|
1570
|
+
useCache: (_d = options.useCache) != null ? _d : true,
|
|
1554
1571
|
inboxServiceInstance: __privateGet(this, _inboxService3),
|
|
1555
1572
|
eventEmitterInstance: __privateGet(this, _emitter7)
|
|
1556
1573
|
});
|
|
@@ -1563,7 +1580,10 @@ var Novu = class {
|
|
|
1563
1580
|
if (__privateGet(this, _socket).isSocketEvent(eventName)) {
|
|
1564
1581
|
__privateGet(this, _socket).initialize();
|
|
1565
1582
|
}
|
|
1566
|
-
__privateGet(this, _emitter7).on(eventName, listener);
|
|
1583
|
+
const cleanup = __privateGet(this, _emitter7).on(eventName, listener);
|
|
1584
|
+
return () => {
|
|
1585
|
+
cleanup();
|
|
1586
|
+
};
|
|
1567
1587
|
};
|
|
1568
1588
|
this.off = (eventName, listener) => {
|
|
1569
1589
|
__privateGet(this, _emitter7).off(eventName, listener);
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NotificationFilter } from './novu-
|
|
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-
|
|
1
|
+
import { N as NotificationFilter } from './novu-iUKr-1Nj.mjs';
|
|
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.mjs';
|
|
3
3
|
import '@novu/client';
|
|
4
4
|
|
|
5
5
|
declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ActionTypeEnum, ChannelType, CtaType, NotificationActionStatus, NotificationButton, NotificationStatus, Novu, PreferenceLevel, PreferenceOverrideSource, PreferenceOverrideSourceEnum, WebSocketEvent, areTagsEqual, isSameFilter } from './chunk-
|
|
1
|
+
export { ActionTypeEnum, ChannelType, CtaType, NotificationActionStatus, NotificationButton, NotificationStatus, Novu, PreferenceLevel, PreferenceOverrideSource, PreferenceOverrideSourceEnum, WebSocketEvent, areTagsEqual, isSameFilter } from './chunk-YGB4AV4G.mjs';
|
|
2
2
|
import './chunk-STZMOEWR.mjs';
|
|
@@ -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'
|
|
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'
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-
|
|
1
|
+
import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-iUKr-1Nj.mjs';
|
|
2
2
|
|
|
3
3
|
declare const defaultLocalization: {
|
|
4
4
|
readonly locale: "en-US";
|
package/dist/esm/ui/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as NovuOptions } from '../novu-
|
|
2
|
-
export { t as Notification } from '../novu-
|
|
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-
|
|
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-
|
|
1
|
+
import { s as NovuOptions } from '../novu-iUKr-1Nj.mjs';
|
|
2
|
+
export { t as Notification } from '../novu-iUKr-1Nj.mjs';
|
|
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-fTgZAefu.mjs';
|
|
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-fTgZAefu.mjs';
|
|
5
5
|
import * as solid_js from 'solid-js';
|
|
6
6
|
import { ComponentProps } from 'solid-js';
|
|
7
7
|
import { MountableElement } from 'solid-js/web';
|