@novu/react 3.0.3 → 3.2.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/README.md +6 -6
- package/dist/cjs/components/Bell.d.cts +1 -0
- package/dist/cjs/components/Inbox.cjs +20 -4
- package/dist/cjs/components/Inbox.cjs.map +1 -1
- package/dist/cjs/components/Inbox.d.cts +1 -0
- package/dist/cjs/components/InboxContent.d.cts +1 -0
- package/dist/cjs/components/Notifications.d.cts +1 -0
- package/dist/cjs/components/index.d.cts +1 -1
- package/dist/cjs/hooks/NovuProvider.cjs +31 -6
- package/dist/cjs/hooks/NovuProvider.cjs.map +1 -1
- package/dist/cjs/hooks/NovuProvider.d.cts +2 -2
- package/dist/cjs/hooks/internal/useWebsocketEvent.cjs +6 -2
- package/dist/cjs/hooks/internal/useWebsocketEvent.cjs.map +1 -1
- package/dist/cjs/index.cjs +28 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +3 -3
- package/dist/cjs/server/index.cjs +1 -4
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/index.d.cts +6 -3
- package/dist/cjs/utils/types.cjs.map +1 -1
- package/dist/cjs/utils/types.d.cts +9 -3
- package/dist/esm/components/Bell.d.ts +1 -0
- package/dist/esm/components/Inbox.d.ts +1 -0
- package/dist/esm/components/Inbox.js +20 -4
- package/dist/esm/components/Inbox.js.map +1 -1
- package/dist/esm/components/InboxContent.d.ts +1 -0
- package/dist/esm/components/Notifications.d.ts +1 -0
- package/dist/esm/components/index.d.ts +1 -1
- package/dist/esm/hooks/NovuProvider.d.ts +2 -2
- package/dist/esm/hooks/NovuProvider.js +31 -6
- package/dist/esm/hooks/NovuProvider.js.map +1 -1
- package/dist/esm/hooks/internal/useWebsocketEvent.js +6 -2
- package/dist/esm/hooks/internal/useWebsocketEvent.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +14 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/index.d.ts +6 -3
- package/dist/esm/server/index.js +0 -1
- package/dist/esm/server/index.js.map +1 -1
- package/dist/esm/utils/types.d.ts +9 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ function Novu() {
|
|
|
22
22
|
return (
|
|
23
23
|
<Inbox
|
|
24
24
|
options={{
|
|
25
|
-
|
|
25
|
+
subscriber: 'SUBSCRIBER_ID',
|
|
26
26
|
applicationIdentifier: 'APPLICATION_IDENTIFIER',
|
|
27
27
|
}}
|
|
28
28
|
/>
|
|
@@ -43,7 +43,7 @@ function Novu() {
|
|
|
43
43
|
options={{
|
|
44
44
|
backendUrl: 'YOUR_BACKEND_URL',
|
|
45
45
|
socketUrl: 'YOUR_SOCKET_URL',
|
|
46
|
-
|
|
46
|
+
subscriber: 'SUBSCRIBER_ID',
|
|
47
47
|
applicationIdentifier: 'APPLICATION_IDENTIFIER',
|
|
48
48
|
}}
|
|
49
49
|
/>
|
|
@@ -65,7 +65,7 @@ function Novu() {
|
|
|
65
65
|
<div>
|
|
66
66
|
<Inbox
|
|
67
67
|
options={{
|
|
68
|
-
|
|
68
|
+
subscriber: 'SUBSCRIBER_ID',
|
|
69
69
|
applicationIdentifier: 'APPLICATION_IDENTIFIER',
|
|
70
70
|
}}
|
|
71
71
|
open={isOpen}
|
|
@@ -88,7 +88,7 @@ function Novu() {
|
|
|
88
88
|
return (
|
|
89
89
|
<Inbox
|
|
90
90
|
options={{
|
|
91
|
-
|
|
91
|
+
subscriber: 'SUBSCRIBER_ID',
|
|
92
92
|
applicationIdentifier: 'APPLICATION_IDENTIFIER',
|
|
93
93
|
}}
|
|
94
94
|
localization={{
|
|
@@ -109,7 +109,7 @@ function Novu() {
|
|
|
109
109
|
|
|
110
110
|
## HMAC Encryption
|
|
111
111
|
|
|
112
|
-
When Novu's user adds the Inbox to their application
|
|
112
|
+
When Novu's user adds the Inbox component to their application, developers need to provide a subscriber prop with the value of their customer's subscriberId, along with an application identifier that serves as a public key for API communication.
|
|
113
113
|
|
|
114
114
|
A malicious actor can access the user feed by accessing the API and passing another `subscriberId` using the public application identifier.
|
|
115
115
|
|
|
@@ -135,7 +135,7 @@ const hmacHash = createHmac('sha256', process.env.NOVU_API_KEY).update(subscribe
|
|
|
135
135
|
|
|
136
136
|
```jsx
|
|
137
137
|
<Inbox
|
|
138
|
-
|
|
138
|
+
subscriber={'SUBSCRIBER_ID_PLAIN_VALUE'}
|
|
139
139
|
subscriberHash={'SUBSCRIBER_ID_HASH_VALUE'}
|
|
140
140
|
applicationIdentifier={'APPLICATION_IDENTIFIER'}
|
|
141
141
|
/>
|
|
@@ -105,7 +105,7 @@ var _DefaultInbox = (props) => {
|
|
|
105
105
|
};
|
|
106
106
|
var DefaultInbox = (0, import_Renderer.withRenderer)(_DefaultInbox);
|
|
107
107
|
var Inbox = import_react.default.memo((props) => {
|
|
108
|
-
const { applicationIdentifier,
|
|
108
|
+
const { applicationIdentifier, subscriberHash, backendUrl, socketUrl } = props;
|
|
109
109
|
const novu = (0, import_NovuProvider.useUnsafeNovu)();
|
|
110
110
|
if (novu) {
|
|
111
111
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InboxChild, { ...props });
|
|
@@ -114,10 +114,10 @@ var Inbox = import_react.default.memo((props) => {
|
|
|
114
114
|
import_NovuProvider.InternalNovuProvider,
|
|
115
115
|
{
|
|
116
116
|
applicationIdentifier,
|
|
117
|
-
subscriberId,
|
|
118
117
|
subscriberHash,
|
|
119
118
|
backendUrl,
|
|
120
119
|
socketUrl,
|
|
120
|
+
subscriber: buildSubscriber(props),
|
|
121
121
|
userAgentType: "components",
|
|
122
122
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InboxChild, { ...props })
|
|
123
123
|
}
|
|
@@ -144,7 +144,13 @@ var InboxChild = import_react.default.memo((props) => {
|
|
|
144
144
|
tabs,
|
|
145
145
|
preferencesFilter,
|
|
146
146
|
routerPush,
|
|
147
|
-
options: {
|
|
147
|
+
options: {
|
|
148
|
+
applicationIdentifier,
|
|
149
|
+
subscriberHash,
|
|
150
|
+
backendUrl,
|
|
151
|
+
socketUrl,
|
|
152
|
+
subscriber: buildSubscriber(props)
|
|
153
|
+
}
|
|
148
154
|
};
|
|
149
155
|
}, [
|
|
150
156
|
localization,
|
|
@@ -155,7 +161,8 @@ var InboxChild = import_react.default.memo((props) => {
|
|
|
155
161
|
subscriberId,
|
|
156
162
|
subscriberHash,
|
|
157
163
|
backendUrl,
|
|
158
|
-
socketUrl
|
|
164
|
+
socketUrl,
|
|
165
|
+
props.subscriber
|
|
159
166
|
]);
|
|
160
167
|
if (isWithChildrenProps(props)) {
|
|
161
168
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_NovuUI.NovuUI, { options, novu, children: props.children });
|
|
@@ -191,6 +198,15 @@ var InboxChild = import_react.default.memo((props) => {
|
|
|
191
198
|
function isWithChildrenProps(props) {
|
|
192
199
|
return "children" in props;
|
|
193
200
|
}
|
|
201
|
+
function buildSubscriber(options) {
|
|
202
|
+
let subscriberObj;
|
|
203
|
+
if (options.subscriber) {
|
|
204
|
+
subscriberObj = typeof options.subscriber === "string" ? { subscriberId: options.subscriber } : options.subscriber;
|
|
205
|
+
} else {
|
|
206
|
+
subscriberObj = { subscriberId: options.subscriberId };
|
|
207
|
+
}
|
|
208
|
+
return subscriberObj;
|
|
209
|
+
}
|
|
194
210
|
// Annotate the CommonJS export names for ESM import in node:
|
|
195
211
|
0 && (module.exports = {
|
|
196
212
|
Inbox
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Inbox.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { DefaultProps, DefaultInboxProps, WithChildrenProps } from '../utils/types';\nimport { Mounter } from './Mounter';\nimport { useNovuUI } from '../context/NovuUIContext';\nimport { useRenderer } from '../context/RendererContext';\nimport { InternalNovuProvider, useNovu, useUnsafeNovu } from '../hooks/NovuProvider';\nimport { NovuUI } from './NovuUI';\nimport { withRenderer } from './Renderer';\n\nexport type InboxProps = DefaultProps | WithChildrenProps;\n\nconst _DefaultInbox = (props: DefaultInboxProps) => {\n const {\n open,\n renderNotification,\n renderSubject,\n renderBody,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placement,\n placementOffset,\n } = props;\n const { novuUI } = useNovuUI();\n const { mountElement } = useRenderer();\n\n const mount = React.useCallback(\n (element: HTMLElement) => {\n if (renderNotification) {\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderNotification: renderNotification\n ? (el, notification) => mountElement(el, renderNotification(notification))\n : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n }\n\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderSubject: renderSubject\n ? (el, notification) => mountElement(el, renderSubject(notification))\n : undefined,\n renderBody: renderBody ? (el, notification) => mountElement(el, renderBody(notification)) : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n },\n [\n open,\n renderNotification,\n renderSubject,\n renderBody,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n ]\n );\n\n return <Mounter mount={mount} />;\n};\n\nconst DefaultInbox = withRenderer(_DefaultInbox);\n\nexport const Inbox = React.memo((props: InboxProps) => {\n const { applicationIdentifier,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Inbox.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { Subscriber } from '@novu/js';\nimport { DefaultProps, DefaultInboxProps, WithChildrenProps } from '../utils/types';\nimport { Mounter } from './Mounter';\nimport { useNovuUI } from '../context/NovuUIContext';\nimport { useRenderer } from '../context/RendererContext';\nimport { InternalNovuProvider, useNovu, useUnsafeNovu } from '../hooks/NovuProvider';\nimport { NovuUI } from './NovuUI';\nimport { withRenderer } from './Renderer';\n\nexport type InboxProps = DefaultProps | WithChildrenProps;\n\nconst _DefaultInbox = (props: DefaultInboxProps) => {\n const {\n open,\n renderNotification,\n renderSubject,\n renderBody,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placement,\n placementOffset,\n } = props;\n const { novuUI } = useNovuUI();\n const { mountElement } = useRenderer();\n\n const mount = React.useCallback(\n (element: HTMLElement) => {\n if (renderNotification) {\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderNotification: renderNotification\n ? (el, notification) => mountElement(el, renderNotification(notification))\n : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n }\n\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderSubject: renderSubject\n ? (el, notification) => mountElement(el, renderSubject(notification))\n : undefined,\n renderBody: renderBody ? (el, notification) => mountElement(el, renderBody(notification)) : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n },\n [\n open,\n renderNotification,\n renderSubject,\n renderBody,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n ]\n );\n\n return <Mounter mount={mount} />;\n};\n\nconst DefaultInbox = withRenderer(_DefaultInbox);\n\nexport const Inbox = React.memo((props: InboxProps) => {\n const { applicationIdentifier, subscriberHash, backendUrl, socketUrl } = props;\n const novu = useUnsafeNovu();\n\n if (novu) {\n return <InboxChild {...props} />;\n }\n\n return (\n <InternalNovuProvider\n applicationIdentifier={applicationIdentifier}\n subscriberHash={subscriberHash}\n backendUrl={backendUrl}\n socketUrl={socketUrl}\n subscriber={buildSubscriber(props)}\n userAgentType=\"components\"\n >\n <InboxChild {...props} />\n </InternalNovuProvider>\n );\n});\n\nconst InboxChild = React.memo((props: InboxProps) => {\n const {\n localization,\n appearance,\n tabs,\n preferencesFilter,\n routerPush,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n } = props;\n const novu = useNovu();\n\n const options = useMemo(() => {\n return {\n localization,\n appearance,\n tabs,\n preferencesFilter,\n routerPush,\n options: {\n applicationIdentifier,\n subscriberHash,\n backendUrl,\n socketUrl,\n subscriber: buildSubscriber(props),\n },\n };\n }, [\n localization,\n appearance,\n tabs,\n preferencesFilter,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n props.subscriber,\n ]);\n\n if (isWithChildrenProps(props)) {\n return (\n <NovuUI options={options} novu={novu}>\n {props.children}\n </NovuUI>\n );\n }\n\n const {\n open,\n renderNotification,\n renderSubject,\n renderBody,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n } = props;\n\n return (\n <NovuUI options={options} novu={novu}>\n <DefaultInbox\n open={open}\n renderNotification={renderNotification}\n renderSubject={renderSubject}\n renderBody={renderBody}\n renderBell={renderBell}\n onNotificationClick={onNotificationClick}\n onPrimaryActionClick={onPrimaryActionClick}\n onSecondaryActionClick={onSecondaryActionClick}\n placement={placement}\n placementOffset={placementOffset}\n />\n </NovuUI>\n );\n});\n\nfunction isWithChildrenProps(props: InboxProps): props is WithChildrenProps {\n return 'children' in props;\n}\n\nfunction buildSubscriber(options: InboxProps): Subscriber {\n let subscriberObj: Subscriber;\n\n if (options.subscriber) {\n subscriberObj = typeof options.subscriber === 'string' ? { subscriberId: options.subscriber } : options.subscriber;\n } else {\n subscriberObj = { subscriberId: options.subscriberId as string };\n }\n\n return subscriberObj;\n}\n"],"mappings":"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","names":["React"]}
|
|
@@ -2,6 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { DefaultProps, WithChildrenProps } from '../utils/types.cjs';
|
|
4
4
|
import '@novu/js/ui';
|
|
5
|
+
import '@novu/js';
|
|
5
6
|
|
|
6
7
|
type InboxProps = DefaultProps | WithChildrenProps;
|
|
7
8
|
declare const Inbox: React__default.MemoExoticComponent<(props: InboxProps) => react_jsx_runtime.JSX.Element>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { NotificationClickHandler, NotificationActionClickHandler, InboxPage } from '@novu/js/ui';
|
|
3
3
|
import { NotificationRendererProps, SubjectBodyRendererProps, NoRendererProps } from '../utils/types.cjs';
|
|
4
|
+
import '@novu/js';
|
|
4
5
|
|
|
5
6
|
type InboxContentProps = {
|
|
6
7
|
onNotificationClick?: NotificationClickHandler;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { NotificationClickHandler, NotificationActionClickHandler } from '@novu/js/ui';
|
|
3
3
|
import { NotificationRendererProps, SubjectBodyRendererProps, NoRendererProps } from '../utils/types.cjs';
|
|
4
|
+
import '@novu/js';
|
|
4
5
|
|
|
5
6
|
type NotificationProps = {
|
|
6
7
|
onNotificationClick?: NotificationClickHandler;
|
|
@@ -29,7 +29,7 @@ module.exports = __toCommonJS(NovuProvider_exports);
|
|
|
29
29
|
var import_js = require("@novu/js");
|
|
30
30
|
var import_react = require("react");
|
|
31
31
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
-
var version = "3.0
|
|
32
|
+
var version = "3.2.0";
|
|
33
33
|
var name = "@novu/react";
|
|
34
34
|
var baseUserAgent = `${name}@${version}`;
|
|
35
35
|
var NovuContext = (0, import_react.createContext)(void 0);
|
|
@@ -39,19 +39,22 @@ var NovuProvider = ({
|
|
|
39
39
|
subscriberId,
|
|
40
40
|
subscriberHash,
|
|
41
41
|
backendUrl,
|
|
42
|
+
apiUrl,
|
|
42
43
|
socketUrl,
|
|
43
|
-
useCache
|
|
44
|
+
useCache,
|
|
45
|
+
subscriber
|
|
44
46
|
}) => {
|
|
45
47
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
46
48
|
InternalNovuProvider,
|
|
47
49
|
{
|
|
48
50
|
applicationIdentifier,
|
|
49
|
-
subscriberId,
|
|
50
51
|
subscriberHash,
|
|
51
52
|
backendUrl,
|
|
53
|
+
apiUrl,
|
|
52
54
|
socketUrl,
|
|
53
55
|
useCache,
|
|
54
56
|
userAgentType: "hooks",
|
|
57
|
+
subscriber: buildSubscriber(subscriberId, subscriber),
|
|
55
58
|
children
|
|
56
59
|
}
|
|
57
60
|
);
|
|
@@ -62,21 +65,34 @@ var InternalNovuProvider = ({
|
|
|
62
65
|
subscriberId,
|
|
63
66
|
subscriberHash,
|
|
64
67
|
backendUrl,
|
|
68
|
+
apiUrl,
|
|
65
69
|
socketUrl,
|
|
66
70
|
useCache,
|
|
71
|
+
subscriber,
|
|
67
72
|
userAgentType
|
|
68
73
|
}) => {
|
|
69
74
|
const novu = (0, import_react.useMemo)(
|
|
70
75
|
() => new import_js.Novu({
|
|
71
76
|
applicationIdentifier,
|
|
72
|
-
subscriberId,
|
|
73
77
|
subscriberHash,
|
|
74
78
|
backendUrl,
|
|
79
|
+
apiUrl,
|
|
75
80
|
socketUrl,
|
|
76
81
|
useCache,
|
|
77
|
-
__userAgent: `${baseUserAgent} ${userAgentType}
|
|
82
|
+
__userAgent: `${baseUserAgent} ${userAgentType}`,
|
|
83
|
+
...subscriber ? { subscriber } : { subscriberId }
|
|
78
84
|
}),
|
|
79
|
-
[
|
|
85
|
+
[
|
|
86
|
+
applicationIdentifier,
|
|
87
|
+
subscriberId,
|
|
88
|
+
subscriberHash,
|
|
89
|
+
backendUrl,
|
|
90
|
+
apiUrl,
|
|
91
|
+
socketUrl,
|
|
92
|
+
useCache,
|
|
93
|
+
subscriber,
|
|
94
|
+
userAgentType
|
|
95
|
+
]
|
|
80
96
|
);
|
|
81
97
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NovuContext.Provider, { value: novu, children });
|
|
82
98
|
};
|
|
@@ -91,6 +107,15 @@ var useUnsafeNovu = () => {
|
|
|
91
107
|
const context = (0, import_react.useContext)(NovuContext);
|
|
92
108
|
return context;
|
|
93
109
|
};
|
|
110
|
+
function buildSubscriber(subscriberId, subscriber) {
|
|
111
|
+
let subscriberObj;
|
|
112
|
+
if (subscriber) {
|
|
113
|
+
subscriberObj = typeof subscriber === "string" ? { subscriberId: subscriber } : subscriber;
|
|
114
|
+
} else {
|
|
115
|
+
subscriberObj = { subscriberId };
|
|
116
|
+
}
|
|
117
|
+
return subscriberObj;
|
|
118
|
+
}
|
|
94
119
|
// Annotate the CommonJS export names for ESM import in node:
|
|
95
120
|
0 && (module.exports = {
|
|
96
121
|
InternalNovuProvider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/NovuProvider.tsx"],"sourcesContent":["import { Novu, NovuOptions } from '@novu/js';\nimport { ReactNode, createContext, useContext, useMemo } from 'react';\n\n// @ts-ignore\nconst version = PACKAGE_VERSION;\n// @ts-ignore\nconst name = PACKAGE_NAME;\nconst baseUserAgent = `${name}@${version}`;\n\nexport type NovuProviderProps = NovuOptions & {\n children: ReactNode;\n};\n\nconst NovuContext = createContext<Novu | undefined>(undefined);\n\nexport const NovuProvider = ({\n children,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n useCache,\n}: NovuProviderProps) => {\n return (\n <InternalNovuProvider\n applicationIdentifier={applicationIdentifier}\n
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/NovuProvider.tsx"],"sourcesContent":["import { Novu, NovuOptions, Subscriber } from '@novu/js';\nimport { ReactNode, createContext, useContext, useMemo } from 'react';\n\n// @ts-ignore\nconst version = PACKAGE_VERSION;\n// @ts-ignore\nconst name = PACKAGE_NAME;\nconst baseUserAgent = `${name}@${version}`;\n\nexport type NovuProviderProps = NovuOptions & {\n children: ReactNode;\n};\n\nconst NovuContext = createContext<Novu | undefined>(undefined);\n\nexport const NovuProvider = ({\n children,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n subscriber,\n}: NovuProviderProps) => {\n return (\n <InternalNovuProvider\n applicationIdentifier={applicationIdentifier}\n subscriberHash={subscriberHash}\n backendUrl={backendUrl}\n apiUrl={apiUrl}\n socketUrl={socketUrl}\n useCache={useCache}\n userAgentType=\"hooks\"\n subscriber={buildSubscriber(subscriberId, subscriber)}\n >\n {children}\n </InternalNovuProvider>\n );\n};\n\n/**\n * @internal Should be used internally not to be exposed outside of the library\n * This is needed to differentiate between the hooks and components user agents\n * Better to use this internally to avoid confusion.\n */\nexport const InternalNovuProvider = ({\n children,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n subscriber,\n userAgentType,\n}: NovuProviderProps & { userAgentType: 'components' | 'hooks' }) => {\n const novu = useMemo(\n () =>\n new Novu({\n applicationIdentifier,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n __userAgent: `${baseUserAgent} ${userAgentType}`,\n ...(subscriber ? { subscriber } : { subscriberId: subscriberId as string }),\n }),\n [\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n subscriber,\n userAgentType,\n ]\n );\n\n return <NovuContext.Provider value={novu}>{children}</NovuContext.Provider>;\n};\n\nexport const useNovu = () => {\n const context = useContext(NovuContext);\n if (!context) {\n throw new Error('useNovu must be used within a <NovuProvider />');\n }\n\n return context;\n};\n\nexport const useUnsafeNovu = () => {\n const context = useContext(NovuContext);\n\n return context;\n};\n\nfunction buildSubscriber(subscriberId: string | undefined, subscriber: Subscriber | string | undefined): Subscriber {\n let subscriberObj: Subscriber;\n\n if (subscriber) {\n subscriberObj = typeof subscriber === 'string' ? { subscriberId: subscriber } : subscriber;\n } else {\n subscriberObj = { subscriberId: subscriberId as string };\n }\n\n return subscriberObj;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA8C;AAC9C,mBAA8D;AA0B1D;AAvBJ,IAAM,UAAU;AAEhB,IAAM,OAAO;AACb,IAAM,gBAAgB,GAAG,IAAI,IAAI,OAAO;AAMxC,IAAM,kBAAc,4BAAgC,MAAS;AAEtD,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAyB;AACvB,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAc;AAAA,MACd,YAAY,gBAAgB,cAAc,UAAU;AAAA,MAEnD;AAAA;AAAA,EACH;AAEJ;AAOO,IAAM,uBAAuB,CAAC;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAqE;AACnE,QAAM,WAAO;AAAA,IACX,MACE,IAAI,eAAK;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa,GAAG,aAAa,IAAI,aAAa;AAAA,MAC9C,GAAI,aAAa,EAAE,WAAW,IAAI,EAAE,aAAqC;AAAA,IAC3E,CAAC;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,4CAAC,YAAY,UAAZ,EAAqB,OAAO,MAAO,UAAS;AACtD;AAEO,IAAM,UAAU,MAAM;AAC3B,QAAM,cAAU,yBAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AAEA,SAAO;AACT;AAEO,IAAM,gBAAgB,MAAM;AACjC,QAAM,cAAU,yBAAW,WAAW;AAEtC,SAAO;AACT;AAEA,SAAS,gBAAgB,cAAkC,YAAyD;AAClH,MAAI;AAEJ,MAAI,YAAY;AACd,oBAAgB,OAAO,eAAe,WAAW,EAAE,cAAc,WAAW,IAAI;AAAA,EAClF,OAAO;AACL,oBAAgB,EAAE,aAAqC;AAAA,EACzD;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -5,13 +5,13 @@ import { ReactNode } from 'react';
|
|
|
5
5
|
type NovuProviderProps = NovuOptions & {
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
};
|
|
8
|
-
declare const NovuProvider: ({ children, applicationIdentifier, subscriberId, subscriberHash, backendUrl, socketUrl, useCache, }: NovuProviderProps) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
declare const NovuProvider: ({ children, applicationIdentifier, subscriberId, subscriberHash, backendUrl, apiUrl, socketUrl, useCache, subscriber, }: NovuProviderProps) => react_jsx_runtime.JSX.Element;
|
|
9
9
|
/**
|
|
10
10
|
* @internal Should be used internally not to be exposed outside of the library
|
|
11
11
|
* This is needed to differentiate between the hooks and components user agents
|
|
12
12
|
* Better to use this internally to avoid confusion.
|
|
13
13
|
*/
|
|
14
|
-
declare const InternalNovuProvider: ({ children, applicationIdentifier, subscriberId, subscriberHash, backendUrl, socketUrl, useCache, userAgentType, }: NovuProviderProps & {
|
|
14
|
+
declare const InternalNovuProvider: ({ children, applicationIdentifier, subscriberId, subscriberHash, backendUrl, apiUrl, socketUrl, useCache, subscriber, userAgentType, }: NovuProviderProps & {
|
|
15
15
|
userAgentType: "components" | "hooks";
|
|
16
16
|
}) => react_jsx_runtime.JSX.Element;
|
|
17
17
|
declare const useNovu: () => Novu;
|
|
@@ -32,14 +32,18 @@ var useWebSocketEvent = ({
|
|
|
32
32
|
eventHandler: onMessage
|
|
33
33
|
}) => {
|
|
34
34
|
const novu = (0, import_NovuProvider.useNovu)();
|
|
35
|
-
const
|
|
35
|
+
const channelName = `nv_ws_connection:a=${novu.applicationIdentifier}:s=${novu.subscriberId}:e=${webSocketEvent}`;
|
|
36
|
+
const { postMessage } = (0, import_useBrowserTabsChannel.useBrowserTabsChannel)({
|
|
37
|
+
channelName,
|
|
38
|
+
onMessage
|
|
39
|
+
});
|
|
36
40
|
const updateReadCount = (data) => {
|
|
37
41
|
onMessage(data);
|
|
38
42
|
postMessage(data);
|
|
39
43
|
};
|
|
40
44
|
(0, import_react.useEffect)(() => {
|
|
41
45
|
let cleanup;
|
|
42
|
-
const resolveLock = (0, import_requestLock.requestLock)(
|
|
46
|
+
const resolveLock = (0, import_requestLock.requestLock)(channelName, () => {
|
|
43
47
|
cleanup = novu.on(webSocketEvent, updateReadCount);
|
|
44
48
|
});
|
|
45
49
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/internal/useWebsocketEvent.ts"],"sourcesContent":["import { EventHandler, Events, SocketEventNames } from '@novu/js';\nimport { useEffect } from 'react';\nimport { useNovu } from '../NovuProvider';\nimport { requestLock } from '../../utils/requestLock';\nimport { useBrowserTabsChannel } from './useBrowserTabsChannel';\n\nexport const useWebSocketEvent = <E extends SocketEventNames>({\n event: webSocketEvent,\n eventHandler: onMessage,\n}: {\n event: E;\n eventHandler: (args: Events[E]) => void;\n}) => {\n const novu = useNovu();\n const { postMessage } = useBrowserTabsChannel({
|
|
1
|
+
{"version":3,"sources":["../../../../src/hooks/internal/useWebsocketEvent.ts"],"sourcesContent":["import { EventHandler, Events, SocketEventNames } from '@novu/js';\nimport { useEffect } from 'react';\nimport { useNovu } from '../NovuProvider';\nimport { requestLock } from '../../utils/requestLock';\nimport { useBrowserTabsChannel } from './useBrowserTabsChannel';\n\nexport const useWebSocketEvent = <E extends SocketEventNames>({\n event: webSocketEvent,\n eventHandler: onMessage,\n}: {\n event: E;\n eventHandler: (args: Events[E]) => void;\n}) => {\n const novu = useNovu();\n const channelName = `nv_ws_connection:a=${novu.applicationIdentifier}:s=${novu.subscriberId}:e=${webSocketEvent}`;\n\n const { postMessage } = useBrowserTabsChannel({\n channelName,\n onMessage,\n });\n\n const updateReadCount: EventHandler<Events[E]> = (data) => {\n onMessage(data);\n postMessage(data);\n };\n\n useEffect(() => {\n let cleanup: () => void;\n const resolveLock = requestLock(channelName, () => {\n cleanup = novu.on(webSocketEvent, updateReadCount);\n });\n\n return () => {\n if (cleanup) {\n cleanup();\n }\n\n resolveLock();\n };\n }, []);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA0B;AAC1B,0BAAwB;AACxB,yBAA4B;AAC5B,mCAAsC;AAE/B,IAAM,oBAAoB,CAA6B;AAAA,EAC5D,OAAO;AAAA,EACP,cAAc;AAChB,MAGM;AACJ,QAAM,WAAO,6BAAQ;AACrB,QAAM,cAAc,sBAAsB,KAAK,qBAAqB,MAAM,KAAK,YAAY,MAAM,cAAc;AAE/G,QAAM,EAAE,YAAY,QAAI,oDAAsB;AAAA,IAC5C;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,kBAA2C,CAAC,SAAS;AACzD,cAAU,IAAI;AACd,gBAAY,IAAI;AAAA,EAClB;AAEA,8BAAU,MAAM;AACd,QAAI;AACJ,UAAM,kBAAc,gCAAY,aAAa,MAAM;AACjD,gBAAU,KAAK,GAAG,gBAAgB,eAAe;AAAA,IACnD,CAAC;AAED,WAAO,MAAM;AACX,UAAI,SAAS;AACX,gBAAQ;AAAA,MACV;AAEA,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,CAAC;AACP;","names":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -11,17 +15,36 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
11
15
|
}
|
|
12
16
|
return to;
|
|
13
17
|
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
19
|
|
|
17
20
|
// src/index.ts
|
|
18
21
|
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Bell: () => import_components.Bell,
|
|
24
|
+
Inbox: () => import_components.Inbox,
|
|
25
|
+
InboxContent: () => import_components.InboxContent,
|
|
26
|
+
Notifications: () => import_components.Notifications,
|
|
27
|
+
NovuProvider: () => import_components.NovuProvider,
|
|
28
|
+
Preferences: () => import_components.Preferences,
|
|
29
|
+
useCounts: () => import_hooks.useCounts,
|
|
30
|
+
useNotifications: () => import_hooks.useNotifications,
|
|
31
|
+
useNovu: () => import_hooks.useNovu,
|
|
32
|
+
usePreferences: () => import_hooks.usePreferences
|
|
33
|
+
});
|
|
19
34
|
module.exports = __toCommonJS(src_exports);
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
var import_components = require("./components/index.cjs");
|
|
36
|
+
var import_hooks = require("./hooks/index.cjs");
|
|
22
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23
38
|
0 && (module.exports = {
|
|
24
|
-
|
|
25
|
-
|
|
39
|
+
Bell,
|
|
40
|
+
Inbox,
|
|
41
|
+
InboxContent,
|
|
42
|
+
Notifications,
|
|
43
|
+
NovuProvider,
|
|
44
|
+
Preferences,
|
|
45
|
+
useCounts,
|
|
46
|
+
useNotifications,
|
|
47
|
+
useNovu,
|
|
48
|
+
usePreferences
|
|
26
49
|
});
|
|
27
50
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n FiltersCountResponse,\n ListNotificationsResponse,\n NovuError,\n Preference,\n PreferencesResponse,\n ChannelPreference,\n Notification,\n ChannelType,\n InboxNotification,\n NotificationFilter,\n NotificationStatus,\n NovuOptions,\n PreferenceLevel,\n WebSocketEvent,\n EventHandler,\n Events,\n SocketEventNames,\n} from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceKey,\n Elements,\n ElementStyles,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferencesFilter,\n RouterPush,\n Tab,\n Variables,\n} from '@novu/js/ui';\n\nexport { Inbox, Bell, InboxContent, Notifications, NovuProvider, Preferences } from './components';\nexport { useNovu, useCounts, useNotifications, usePreferences } from './hooks';\n\nexport type { InboxProps, BellProps, InboxContentProps, NotificationProps, NovuProviderProps } from './components';\n\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n} from './hooks';\n\nexport type {\n NotificationsRenderer,\n SubjectRenderer,\n BodyRenderer,\n BellRenderer,\n DefaultInboxProps,\n BaseProps,\n NotificationRendererProps,\n SubjectBodyRendererProps,\n NoRendererProps,\n DefaultProps,\n WithChildrenProps,\n} from './utils/types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoCA,wBAAoF;AACpF,mBAAqE;","names":[]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
export { ChannelPreference, ChannelType, EventHandler, Events, FiltersCountResponse, InboxNotification, ListNotificationsResponse, Notification, NotificationFilter, NotificationStatus, NovuError, NovuOptions, Preference, PreferenceLevel, PreferencesResponse, SocketEventNames, WebSocketEvent } from '@novu/js';
|
|
2
|
+
export { Appearance, AppearanceKey, ElementStyles, Elements, Localization, LocalizationKey, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, PreferencesFilter, RouterPush, Tab, Variables } from '@novu/js/ui';
|
|
1
3
|
export { Bell, BellProps } from './components/Bell.cjs';
|
|
2
4
|
export { Inbox, InboxProps } from './components/Inbox.cjs';
|
|
3
5
|
export { Preferences } from './components/Preferences.cjs';
|
|
4
6
|
export { NotificationProps, Notifications } from './components/Notifications.cjs';
|
|
5
7
|
export { InboxContent, InboxContentProps } from './components/InboxContent.cjs';
|
|
6
|
-
export {
|
|
8
|
+
export { NovuProvider, NovuProviderProps, useNovu } from './hooks/NovuProvider.cjs';
|
|
7
9
|
export { UseNotificationsProps, UseNotificationsResult, useNotifications } from './hooks/useNotifications.cjs';
|
|
8
10
|
export { UsePreferencesProps, UsePreferencesResult, usePreferences } from './hooks/usePreferences.cjs';
|
|
9
11
|
export { UseCountsProps, UseCountsResult, useCounts } from './hooks/useCounts.cjs';
|
|
10
12
|
export { BaseProps, BellRenderer, BodyRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer, SubjectBodyRendererProps, SubjectRenderer, WithChildrenProps } from './utils/types.cjs';
|
|
11
|
-
export { Notification } from '@novu/js/ui';
|
|
12
13
|
import 'react';
|
|
13
14
|
import 'react/jsx-runtime';
|
|
14
|
-
import '@novu/js';
|
|
@@ -15,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
19
|
|
|
21
20
|
// src/server/index.tsx
|
|
@@ -33,7 +32,6 @@ __export(server_exports, {
|
|
|
33
32
|
usePreferences: () => usePreferences
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(server_exports);
|
|
36
|
-
__reExport(server_exports, require("../utils/types.cjs"), module.exports);
|
|
37
35
|
function Inbox(props) {
|
|
38
36
|
}
|
|
39
37
|
function InboxContent() {
|
|
@@ -86,7 +84,6 @@ function usePreferences(_) {
|
|
|
86
84
|
useCounts,
|
|
87
85
|
useNotifications,
|
|
88
86
|
useNovu,
|
|
89
|
-
usePreferences
|
|
90
|
-
...require("../utils/types.cjs")
|
|
87
|
+
usePreferences
|
|
91
88
|
});
|
|
92
89
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/index.tsx"],"sourcesContent":["import type {\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n} from '../hooks';\nimport type { UseCountsProps, UseCountsResult } from '../hooks/useCounts';\nimport type { InboxProps } from '../components/Inbox';\nimport type { NovuProviderProps } from '../hooks/NovuProvider';\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/server/index.tsx"],"sourcesContent":["import type {\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n} from '../hooks';\nimport type { UseCountsProps, UseCountsResult } from '../hooks/useCounts';\nimport type { InboxProps } from '../components/Inbox';\nimport type { NovuProviderProps } from '../hooks/NovuProvider';\n\n/**\n * Exporting all components from the components folder\n * as empty functions to fix build errors in SSR\n * This will be replaced with actual components\n * when we implement the SSR components in @novu/js/ui\n */\nexport function Inbox(props: InboxProps) {}\n\nexport function InboxContent() {}\n\nexport function Notifications() {}\n\nexport function Preferences() {}\n\nexport function Bell() {}\n\nexport function NovuProvider(props: NovuProviderProps) {}\n\nexport function useNovu() {\n return null;\n}\n\nexport function useCounts(_: UseCountsProps): UseCountsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useNotifications(_: UseNotificationsProps): UseNotificationsResult {\n return {\n isLoading: false,\n isFetching: false,\n hasMore: false,\n readAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAllRead: () => Promise.resolve({ data: undefined, error: undefined }),\n refetch: () => Promise.resolve(),\n fetchMore: () => Promise.resolve(),\n };\n}\n\nexport function usePreferences(_: UsePreferencesProps): UsePreferencesResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport type {\n FiltersCountResponse,\n ListNotificationsResponse,\n NovuError,\n Preference,\n ChannelPreference,\n Notification,\n ChannelType,\n InboxNotification,\n NotificationFilter,\n NotificationStatus,\n NovuOptions,\n PreferenceLevel,\n} from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceKey,\n Elements,\n ElementStyles,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferencesFilter,\n RouterPush,\n Tab,\n Variables,\n} from '@novu/js/ui';\n\nexport type { InboxProps, BellProps, InboxContentProps, NotificationProps, NovuProviderProps } from '../components';\n\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n} from '../hooks';\n\nexport type {\n NotificationsRenderer,\n SubjectRenderer,\n BodyRenderer,\n BellRenderer,\n DefaultInboxProps,\n BaseProps,\n NotificationRendererProps,\n SubjectBodyRendererProps,\n NoRendererProps,\n DefaultProps,\n WithChildrenProps,\n} from '../utils/types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,MAAM,OAAmB;AAAC;AAEnC,SAAS,eAAe;AAAC;AAEzB,SAAS,gBAAgB;AAAC;AAE1B,SAAS,cAAc;AAAC;AAExB,SAAS,OAAO;AAAC;AAEjB,SAAS,aAAa,OAA0B;AAAC;AAEjD,SAAS,UAAU;AACxB,SAAO;AACT;AAEO,SAAS,UAAU,GAAoC;AAC5D,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;AAEO,SAAS,iBAAiB,GAAkD;AACjF,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IACpE,YAAY,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IACvE,gBAAgB,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IAC3E,SAAS,MAAM,QAAQ,QAAQ;AAAA,IAC/B,WAAW,MAAM,QAAQ,QAAQ;AAAA,EACnC;AACF;AAEO,SAAS,eAAe,GAA8C;AAC3E,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;","names":[]}
|
|
@@ -3,9 +3,12 @@ import { UsePreferencesProps, UsePreferencesResult } from '../hooks/usePreferenc
|
|
|
3
3
|
import { UseCountsProps, UseCountsResult } from '../hooks/useCounts.cjs';
|
|
4
4
|
import { NovuProviderProps } from '../hooks/NovuProvider.cjs';
|
|
5
5
|
import { InboxProps } from '../components/Inbox.cjs';
|
|
6
|
+
export { ChannelPreference, ChannelType, FiltersCountResponse, InboxNotification, ListNotificationsResponse, Notification, NotificationFilter, NotificationStatus, NovuError, NovuOptions, Preference, PreferenceLevel } from '@novu/js';
|
|
7
|
+
export { Appearance, AppearanceKey, ElementStyles, Elements, Localization, LocalizationKey, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, PreferencesFilter, RouterPush, Tab, Variables } from '@novu/js/ui';
|
|
8
|
+
export { BellProps } from '../components/Bell.cjs';
|
|
9
|
+
export { NotificationProps } from '../components/Notifications.cjs';
|
|
10
|
+
export { InboxContentProps } from '../components/InboxContent.cjs';
|
|
6
11
|
export { BaseProps, BellRenderer, BodyRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer, SubjectBodyRendererProps, SubjectRenderer, WithChildrenProps } from '../utils/types.cjs';
|
|
7
|
-
export { Notification } from '@novu/js/ui';
|
|
8
|
-
import '@novu/js';
|
|
9
12
|
import 'react/jsx-runtime';
|
|
10
13
|
import 'react';
|
|
11
14
|
|
|
@@ -26,4 +29,4 @@ declare function useCounts(_: UseCountsProps): UseCountsResult;
|
|
|
26
29
|
declare function useNotifications(_: UseNotificationsProps): UseNotificationsResult;
|
|
27
30
|
declare function usePreferences(_: UsePreferencesProps): UsePreferencesResult;
|
|
28
31
|
|
|
29
|
-
export { Bell, Inbox, InboxContent, Notifications, NovuProvider, Preferences, useCounts, useNotifications, useNovu, usePreferences };
|
|
32
|
+
export { Bell, Inbox, InboxContent, InboxProps, Notifications, NovuProvider, NovuProviderProps, Preferences, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UsePreferencesProps, UsePreferencesResult, useCounts, useNotifications, useNovu, usePreferences };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/types.ts"],"sourcesContent":["import type {\n Notification,\n NotificationClickHandler,\n NotificationActionClickHandler,\n Tab,\n Appearance,\n Localization,\n RouterPush,\n PreferencesFilter,\n InboxProps,\n} from '@novu/js/ui';\n\nexport type NotificationsRenderer = (notification: Notification) => React.ReactNode;\nexport type SubjectRenderer = (notification: Notification) => React.ReactNode;\nexport type BodyRenderer = (notification: Notification) => React.ReactNode;\nexport type BellRenderer = (unreadCount: number) => React.ReactNode;\n\nexport type DefaultInboxProps = {\n open?: boolean;\n renderNotification?: NotificationsRenderer;\n renderSubject?: SubjectRenderer;\n renderBody?: BodyRenderer;\n renderBell?: BellRenderer;\n onNotificationClick?: NotificationClickHandler;\n onPrimaryActionClick?: NotificationActionClickHandler;\n onSecondaryActionClick?: NotificationActionClickHandler;\n placement?: InboxProps['placement'];\n placementOffset?: InboxProps['placementOffset'];\n};\n\nexport type BaseProps = {\n applicationIdentifier: string;\n
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/types.ts"],"sourcesContent":["import type {\n Notification,\n NotificationClickHandler,\n NotificationActionClickHandler,\n Tab,\n Appearance,\n Localization,\n RouterPush,\n PreferencesFilter,\n InboxProps,\n} from '@novu/js/ui';\nimport type { Subscriber } from '@novu/js';\n\nexport type NotificationsRenderer = (notification: Notification) => React.ReactNode;\nexport type SubjectRenderer = (notification: Notification) => React.ReactNode;\nexport type BodyRenderer = (notification: Notification) => React.ReactNode;\nexport type BellRenderer = (unreadCount: number) => React.ReactNode;\n\nexport type DefaultInboxProps = {\n open?: boolean;\n renderNotification?: NotificationsRenderer;\n renderSubject?: SubjectRenderer;\n renderBody?: BodyRenderer;\n renderBell?: BellRenderer;\n onNotificationClick?: NotificationClickHandler;\n onPrimaryActionClick?: NotificationActionClickHandler;\n onSecondaryActionClick?: NotificationActionClickHandler;\n placement?: InboxProps['placement'];\n placementOffset?: InboxProps['placementOffset'];\n};\n\nexport type BaseProps = {\n applicationIdentifier: string;\n subscriberHash?: string;\n backendUrl?: string;\n socketUrl?: string;\n appearance?: Appearance;\n localization?: Localization;\n tabs?: Array<Tab>;\n preferencesFilter?: PreferencesFilter;\n routerPush?: RouterPush;\n} & (\n | {\n // TODO: Backward compatibility support - remove in future versions (see NV-5801)\n /** @deprecated Use subscriber prop instead */\n subscriberId: string;\n subscriber?: never;\n }\n | {\n subscriber: Subscriber | string;\n subscriberId?: never;\n }\n);\n\nexport type NotificationRendererProps = {\n renderNotification: NotificationsRenderer;\n renderSubject?: never;\n renderBody?: never;\n};\n\nexport type SubjectBodyRendererProps = {\n renderNotification?: never;\n renderSubject?: SubjectRenderer;\n renderBody?: BodyRenderer;\n};\n\nexport type NoRendererProps = {\n renderNotification?: undefined;\n renderSubject?: undefined;\n renderBody?: undefined;\n};\n\nexport type DefaultProps = BaseProps &\n DefaultInboxProps & {\n children?: never;\n } & (NotificationRendererProps | SubjectBodyRendererProps | NoRendererProps);\n\nexport type WithChildrenProps = BaseProps & {\n children: React.ReactNode;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Notification, NotificationClickHandler, NotificationActionClickHandler, InboxProps, Appearance, Localization, Tab, PreferencesFilter, RouterPush } from '@novu/js/ui';
|
|
2
|
-
|
|
2
|
+
import { Subscriber } from '@novu/js';
|
|
3
3
|
|
|
4
4
|
type NotificationsRenderer = (notification: Notification) => React.ReactNode;
|
|
5
5
|
type SubjectRenderer = (notification: Notification) => React.ReactNode;
|
|
@@ -19,7 +19,6 @@ type DefaultInboxProps = {
|
|
|
19
19
|
};
|
|
20
20
|
type BaseProps = {
|
|
21
21
|
applicationIdentifier: string;
|
|
22
|
-
subscriberId: string;
|
|
23
22
|
subscriberHash?: string;
|
|
24
23
|
backendUrl?: string;
|
|
25
24
|
socketUrl?: string;
|
|
@@ -28,7 +27,14 @@ type BaseProps = {
|
|
|
28
27
|
tabs?: Array<Tab>;
|
|
29
28
|
preferencesFilter?: PreferencesFilter;
|
|
30
29
|
routerPush?: RouterPush;
|
|
31
|
-
}
|
|
30
|
+
} & ({
|
|
31
|
+
/** @deprecated Use subscriber prop instead */
|
|
32
|
+
subscriberId: string;
|
|
33
|
+
subscriber?: never;
|
|
34
|
+
} | {
|
|
35
|
+
subscriber: Subscriber | string;
|
|
36
|
+
subscriberId?: never;
|
|
37
|
+
});
|
|
32
38
|
type NotificationRendererProps = {
|
|
33
39
|
renderNotification: NotificationsRenderer;
|
|
34
40
|
renderSubject?: never;
|
|
@@ -2,6 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { DefaultProps, WithChildrenProps } from '../utils/types.js';
|
|
4
4
|
import '@novu/js/ui';
|
|
5
|
+
import '@novu/js';
|
|
5
6
|
|
|
6
7
|
type InboxProps = DefaultProps | WithChildrenProps;
|
|
7
8
|
declare const Inbox: React__default.MemoExoticComponent<(props: InboxProps) => react_jsx_runtime.JSX.Element>;
|
|
@@ -71,7 +71,7 @@ var _DefaultInbox = (props) => {
|
|
|
71
71
|
};
|
|
72
72
|
var DefaultInbox = withRenderer(_DefaultInbox);
|
|
73
73
|
var Inbox = React.memo((props) => {
|
|
74
|
-
const { applicationIdentifier,
|
|
74
|
+
const { applicationIdentifier, subscriberHash, backendUrl, socketUrl } = props;
|
|
75
75
|
const novu = useUnsafeNovu();
|
|
76
76
|
if (novu) {
|
|
77
77
|
return /* @__PURE__ */ jsx(InboxChild, { ...props });
|
|
@@ -80,10 +80,10 @@ var Inbox = React.memo((props) => {
|
|
|
80
80
|
InternalNovuProvider,
|
|
81
81
|
{
|
|
82
82
|
applicationIdentifier,
|
|
83
|
-
subscriberId,
|
|
84
83
|
subscriberHash,
|
|
85
84
|
backendUrl,
|
|
86
85
|
socketUrl,
|
|
86
|
+
subscriber: buildSubscriber(props),
|
|
87
87
|
userAgentType: "components",
|
|
88
88
|
children: /* @__PURE__ */ jsx(InboxChild, { ...props })
|
|
89
89
|
}
|
|
@@ -110,7 +110,13 @@ var InboxChild = React.memo((props) => {
|
|
|
110
110
|
tabs,
|
|
111
111
|
preferencesFilter,
|
|
112
112
|
routerPush,
|
|
113
|
-
options: {
|
|
113
|
+
options: {
|
|
114
|
+
applicationIdentifier,
|
|
115
|
+
subscriberHash,
|
|
116
|
+
backendUrl,
|
|
117
|
+
socketUrl,
|
|
118
|
+
subscriber: buildSubscriber(props)
|
|
119
|
+
}
|
|
114
120
|
};
|
|
115
121
|
}, [
|
|
116
122
|
localization,
|
|
@@ -121,7 +127,8 @@ var InboxChild = React.memo((props) => {
|
|
|
121
127
|
subscriberId,
|
|
122
128
|
subscriberHash,
|
|
123
129
|
backendUrl,
|
|
124
|
-
socketUrl
|
|
130
|
+
socketUrl,
|
|
131
|
+
props.subscriber
|
|
125
132
|
]);
|
|
126
133
|
if (isWithChildrenProps(props)) {
|
|
127
134
|
return /* @__PURE__ */ jsx(NovuUI, { options, novu, children: props.children });
|
|
@@ -157,6 +164,15 @@ var InboxChild = React.memo((props) => {
|
|
|
157
164
|
function isWithChildrenProps(props) {
|
|
158
165
|
return "children" in props;
|
|
159
166
|
}
|
|
167
|
+
function buildSubscriber(options) {
|
|
168
|
+
let subscriberObj;
|
|
169
|
+
if (options.subscriber) {
|
|
170
|
+
subscriberObj = typeof options.subscriber === "string" ? { subscriberId: options.subscriber } : options.subscriber;
|
|
171
|
+
} else {
|
|
172
|
+
subscriberObj = { subscriberId: options.subscriberId };
|
|
173
|
+
}
|
|
174
|
+
return subscriberObj;
|
|
175
|
+
}
|
|
160
176
|
export {
|
|
161
177
|
Inbox
|
|
162
178
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Inbox.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { DefaultProps, DefaultInboxProps, WithChildrenProps } from '../utils/types';\nimport { Mounter } from './Mounter';\nimport { useNovuUI } from '../context/NovuUIContext';\nimport { useRenderer } from '../context/RendererContext';\nimport { InternalNovuProvider, useNovu, useUnsafeNovu } from '../hooks/NovuProvider';\nimport { NovuUI } from './NovuUI';\nimport { withRenderer } from './Renderer';\n\nexport type InboxProps = DefaultProps | WithChildrenProps;\n\nconst _DefaultInbox = (props: DefaultInboxProps) => {\n const {\n open,\n renderNotification,\n renderSubject,\n renderBody,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placement,\n placementOffset,\n } = props;\n const { novuUI } = useNovuUI();\n const { mountElement } = useRenderer();\n\n const mount = React.useCallback(\n (element: HTMLElement) => {\n if (renderNotification) {\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderNotification: renderNotification\n ? (el, notification) => mountElement(el, renderNotification(notification))\n : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n }\n\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderSubject: renderSubject\n ? (el, notification) => mountElement(el, renderSubject(notification))\n : undefined,\n renderBody: renderBody ? (el, notification) => mountElement(el, renderBody(notification)) : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n },\n [\n open,\n renderNotification,\n renderSubject,\n renderBody,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n ]\n );\n\n return <Mounter mount={mount} />;\n};\n\nconst DefaultInbox = withRenderer(_DefaultInbox);\n\nexport const Inbox = React.memo((props: InboxProps) => {\n const { applicationIdentifier,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Inbox.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { Subscriber } from '@novu/js';\nimport { DefaultProps, DefaultInboxProps, WithChildrenProps } from '../utils/types';\nimport { Mounter } from './Mounter';\nimport { useNovuUI } from '../context/NovuUIContext';\nimport { useRenderer } from '../context/RendererContext';\nimport { InternalNovuProvider, useNovu, useUnsafeNovu } from '../hooks/NovuProvider';\nimport { NovuUI } from './NovuUI';\nimport { withRenderer } from './Renderer';\n\nexport type InboxProps = DefaultProps | WithChildrenProps;\n\nconst _DefaultInbox = (props: DefaultInboxProps) => {\n const {\n open,\n renderNotification,\n renderSubject,\n renderBody,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placement,\n placementOffset,\n } = props;\n const { novuUI } = useNovuUI();\n const { mountElement } = useRenderer();\n\n const mount = React.useCallback(\n (element: HTMLElement) => {\n if (renderNotification) {\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderNotification: renderNotification\n ? (el, notification) => mountElement(el, renderNotification(notification))\n : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n }\n\n return novuUI.mountComponent({\n name: 'Inbox',\n props: {\n open,\n renderSubject: renderSubject\n ? (el, notification) => mountElement(el, renderSubject(notification))\n : undefined,\n renderBody: renderBody ? (el, notification) => mountElement(el, renderBody(notification)) : undefined,\n renderBell: renderBell ? (el, unreadCount) => mountElement(el, renderBell(unreadCount)) : undefined,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n },\n element,\n });\n },\n [\n open,\n renderNotification,\n renderSubject,\n renderBody,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n ]\n );\n\n return <Mounter mount={mount} />;\n};\n\nconst DefaultInbox = withRenderer(_DefaultInbox);\n\nexport const Inbox = React.memo((props: InboxProps) => {\n const { applicationIdentifier, subscriberHash, backendUrl, socketUrl } = props;\n const novu = useUnsafeNovu();\n\n if (novu) {\n return <InboxChild {...props} />;\n }\n\n return (\n <InternalNovuProvider\n applicationIdentifier={applicationIdentifier}\n subscriberHash={subscriberHash}\n backendUrl={backendUrl}\n socketUrl={socketUrl}\n subscriber={buildSubscriber(props)}\n userAgentType=\"components\"\n >\n <InboxChild {...props} />\n </InternalNovuProvider>\n );\n});\n\nconst InboxChild = React.memo((props: InboxProps) => {\n const {\n localization,\n appearance,\n tabs,\n preferencesFilter,\n routerPush,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n } = props;\n const novu = useNovu();\n\n const options = useMemo(() => {\n return {\n localization,\n appearance,\n tabs,\n preferencesFilter,\n routerPush,\n options: {\n applicationIdentifier,\n subscriberHash,\n backendUrl,\n socketUrl,\n subscriber: buildSubscriber(props),\n },\n };\n }, [\n localization,\n appearance,\n tabs,\n preferencesFilter,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n props.subscriber,\n ]);\n\n if (isWithChildrenProps(props)) {\n return (\n <NovuUI options={options} novu={novu}>\n {props.children}\n </NovuUI>\n );\n }\n\n const {\n open,\n renderNotification,\n renderSubject,\n renderBody,\n renderBell,\n onNotificationClick,\n onPrimaryActionClick,\n onSecondaryActionClick,\n placementOffset,\n placement,\n } = props;\n\n return (\n <NovuUI options={options} novu={novu}>\n <DefaultInbox\n open={open}\n renderNotification={renderNotification}\n renderSubject={renderSubject}\n renderBody={renderBody}\n renderBell={renderBell}\n onNotificationClick={onNotificationClick}\n onPrimaryActionClick={onPrimaryActionClick}\n onSecondaryActionClick={onSecondaryActionClick}\n placement={placement}\n placementOffset={placementOffset}\n />\n </NovuUI>\n );\n});\n\nfunction isWithChildrenProps(props: InboxProps): props is WithChildrenProps {\n return 'children' in props;\n}\n\nfunction buildSubscriber(options: InboxProps): Subscriber {\n let subscriberObj: Subscriber;\n\n if (options.subscriber) {\n subscriberObj = typeof options.subscriber === 'string' ? { subscriberId: options.subscriber } : options.subscriber;\n } else {\n subscriberObj = { subscriberId: options.subscriberId as string };\n }\n\n return subscriberObj;\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { NotificationClickHandler, NotificationActionClickHandler, InboxPage } from '@novu/js/ui';
|
|
3
3
|
import { NotificationRendererProps, SubjectBodyRendererProps, NoRendererProps } from '../utils/types.js';
|
|
4
|
+
import '@novu/js';
|
|
4
5
|
|
|
5
6
|
type InboxContentProps = {
|
|
6
7
|
onNotificationClick?: NotificationClickHandler;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { NotificationClickHandler, NotificationActionClickHandler } from '@novu/js/ui';
|
|
3
3
|
import { NotificationRendererProps, SubjectBodyRendererProps, NoRendererProps } from '../utils/types.js';
|
|
4
|
+
import '@novu/js';
|
|
4
5
|
|
|
5
6
|
type NotificationProps = {
|
|
6
7
|
onNotificationClick?: NotificationClickHandler;
|
|
@@ -5,13 +5,13 @@ import { ReactNode } from 'react';
|
|
|
5
5
|
type NovuProviderProps = NovuOptions & {
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
};
|
|
8
|
-
declare const NovuProvider: ({ children, applicationIdentifier, subscriberId, subscriberHash, backendUrl, socketUrl, useCache, }: NovuProviderProps) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
declare const NovuProvider: ({ children, applicationIdentifier, subscriberId, subscriberHash, backendUrl, apiUrl, socketUrl, useCache, subscriber, }: NovuProviderProps) => react_jsx_runtime.JSX.Element;
|
|
9
9
|
/**
|
|
10
10
|
* @internal Should be used internally not to be exposed outside of the library
|
|
11
11
|
* This is needed to differentiate between the hooks and components user agents
|
|
12
12
|
* Better to use this internally to avoid confusion.
|
|
13
13
|
*/
|
|
14
|
-
declare const InternalNovuProvider: ({ children, applicationIdentifier, subscriberId, subscriberHash, backendUrl, socketUrl, useCache, userAgentType, }: NovuProviderProps & {
|
|
14
|
+
declare const InternalNovuProvider: ({ children, applicationIdentifier, subscriberId, subscriberHash, backendUrl, apiUrl, socketUrl, useCache, subscriber, userAgentType, }: NovuProviderProps & {
|
|
15
15
|
userAgentType: "components" | "hooks";
|
|
16
16
|
}) => react_jsx_runtime.JSX.Element;
|
|
17
17
|
declare const useNovu: () => Novu;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Novu } from "@novu/js";
|
|
3
3
|
import { createContext, useContext, useMemo } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
var version = "3.0
|
|
5
|
+
var version = "3.2.0";
|
|
6
6
|
var name = "@novu/react";
|
|
7
7
|
var baseUserAgent = `${name}@${version}`;
|
|
8
8
|
var NovuContext = createContext(void 0);
|
|
@@ -12,19 +12,22 @@ var NovuProvider = ({
|
|
|
12
12
|
subscriberId,
|
|
13
13
|
subscriberHash,
|
|
14
14
|
backendUrl,
|
|
15
|
+
apiUrl,
|
|
15
16
|
socketUrl,
|
|
16
|
-
useCache
|
|
17
|
+
useCache,
|
|
18
|
+
subscriber
|
|
17
19
|
}) => {
|
|
18
20
|
return /* @__PURE__ */ jsx(
|
|
19
21
|
InternalNovuProvider,
|
|
20
22
|
{
|
|
21
23
|
applicationIdentifier,
|
|
22
|
-
subscriberId,
|
|
23
24
|
subscriberHash,
|
|
24
25
|
backendUrl,
|
|
26
|
+
apiUrl,
|
|
25
27
|
socketUrl,
|
|
26
28
|
useCache,
|
|
27
29
|
userAgentType: "hooks",
|
|
30
|
+
subscriber: buildSubscriber(subscriberId, subscriber),
|
|
28
31
|
children
|
|
29
32
|
}
|
|
30
33
|
);
|
|
@@ -35,21 +38,34 @@ var InternalNovuProvider = ({
|
|
|
35
38
|
subscriberId,
|
|
36
39
|
subscriberHash,
|
|
37
40
|
backendUrl,
|
|
41
|
+
apiUrl,
|
|
38
42
|
socketUrl,
|
|
39
43
|
useCache,
|
|
44
|
+
subscriber,
|
|
40
45
|
userAgentType
|
|
41
46
|
}) => {
|
|
42
47
|
const novu = useMemo(
|
|
43
48
|
() => new Novu({
|
|
44
49
|
applicationIdentifier,
|
|
45
|
-
subscriberId,
|
|
46
50
|
subscriberHash,
|
|
47
51
|
backendUrl,
|
|
52
|
+
apiUrl,
|
|
48
53
|
socketUrl,
|
|
49
54
|
useCache,
|
|
50
|
-
__userAgent: `${baseUserAgent} ${userAgentType}
|
|
55
|
+
__userAgent: `${baseUserAgent} ${userAgentType}`,
|
|
56
|
+
...subscriber ? { subscriber } : { subscriberId }
|
|
51
57
|
}),
|
|
52
|
-
[
|
|
58
|
+
[
|
|
59
|
+
applicationIdentifier,
|
|
60
|
+
subscriberId,
|
|
61
|
+
subscriberHash,
|
|
62
|
+
backendUrl,
|
|
63
|
+
apiUrl,
|
|
64
|
+
socketUrl,
|
|
65
|
+
useCache,
|
|
66
|
+
subscriber,
|
|
67
|
+
userAgentType
|
|
68
|
+
]
|
|
53
69
|
);
|
|
54
70
|
return /* @__PURE__ */ jsx(NovuContext.Provider, { value: novu, children });
|
|
55
71
|
};
|
|
@@ -64,6 +80,15 @@ var useUnsafeNovu = () => {
|
|
|
64
80
|
const context = useContext(NovuContext);
|
|
65
81
|
return context;
|
|
66
82
|
};
|
|
83
|
+
function buildSubscriber(subscriberId, subscriber) {
|
|
84
|
+
let subscriberObj;
|
|
85
|
+
if (subscriber) {
|
|
86
|
+
subscriberObj = typeof subscriber === "string" ? { subscriberId: subscriber } : subscriber;
|
|
87
|
+
} else {
|
|
88
|
+
subscriberObj = { subscriberId };
|
|
89
|
+
}
|
|
90
|
+
return subscriberObj;
|
|
91
|
+
}
|
|
67
92
|
export {
|
|
68
93
|
InternalNovuProvider,
|
|
69
94
|
NovuProvider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/NovuProvider.tsx"],"sourcesContent":["import { Novu, NovuOptions } from '@novu/js';\nimport { ReactNode, createContext, useContext, useMemo } from 'react';\n\n// @ts-ignore\nconst version = PACKAGE_VERSION;\n// @ts-ignore\nconst name = PACKAGE_NAME;\nconst baseUserAgent = `${name}@${version}`;\n\nexport type NovuProviderProps = NovuOptions & {\n children: ReactNode;\n};\n\nconst NovuContext = createContext<Novu | undefined>(undefined);\n\nexport const NovuProvider = ({\n children,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n socketUrl,\n useCache,\n}: NovuProviderProps) => {\n return (\n <InternalNovuProvider\n applicationIdentifier={applicationIdentifier}\n
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/NovuProvider.tsx"],"sourcesContent":["import { Novu, NovuOptions, Subscriber } from '@novu/js';\nimport { ReactNode, createContext, useContext, useMemo } from 'react';\n\n// @ts-ignore\nconst version = PACKAGE_VERSION;\n// @ts-ignore\nconst name = PACKAGE_NAME;\nconst baseUserAgent = `${name}@${version}`;\n\nexport type NovuProviderProps = NovuOptions & {\n children: ReactNode;\n};\n\nconst NovuContext = createContext<Novu | undefined>(undefined);\n\nexport const NovuProvider = ({\n children,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n subscriber,\n}: NovuProviderProps) => {\n return (\n <InternalNovuProvider\n applicationIdentifier={applicationIdentifier}\n subscriberHash={subscriberHash}\n backendUrl={backendUrl}\n apiUrl={apiUrl}\n socketUrl={socketUrl}\n useCache={useCache}\n userAgentType=\"hooks\"\n subscriber={buildSubscriber(subscriberId, subscriber)}\n >\n {children}\n </InternalNovuProvider>\n );\n};\n\n/**\n * @internal Should be used internally not to be exposed outside of the library\n * This is needed to differentiate between the hooks and components user agents\n * Better to use this internally to avoid confusion.\n */\nexport const InternalNovuProvider = ({\n children,\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n subscriber,\n userAgentType,\n}: NovuProviderProps & { userAgentType: 'components' | 'hooks' }) => {\n const novu = useMemo(\n () =>\n new Novu({\n applicationIdentifier,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n __userAgent: `${baseUserAgent} ${userAgentType}`,\n ...(subscriber ? { subscriber } : { subscriberId: subscriberId as string }),\n }),\n [\n applicationIdentifier,\n subscriberId,\n subscriberHash,\n backendUrl,\n apiUrl,\n socketUrl,\n useCache,\n subscriber,\n userAgentType,\n ]\n );\n\n return <NovuContext.Provider value={novu}>{children}</NovuContext.Provider>;\n};\n\nexport const useNovu = () => {\n const context = useContext(NovuContext);\n if (!context) {\n throw new Error('useNovu must be used within a <NovuProvider />');\n }\n\n return context;\n};\n\nexport const useUnsafeNovu = () => {\n const context = useContext(NovuContext);\n\n return context;\n};\n\nfunction buildSubscriber(subscriberId: string | undefined, subscriber: Subscriber | string | undefined): Subscriber {\n let subscriberObj: Subscriber;\n\n if (subscriber) {\n subscriberObj = typeof subscriber === 'string' ? { subscriberId: subscriber } : subscriber;\n } else {\n subscriberObj = { subscriberId: subscriberId as string };\n }\n\n return subscriberObj;\n}\n"],"mappings":";AAAA,SAAS,YAAqC;AAC9C,SAAoB,eAAe,YAAY,eAAe;AA0B1D;AAvBJ,IAAM,UAAU;AAEhB,IAAM,OAAO;AACb,IAAM,gBAAgB,GAAG,IAAI,IAAI,OAAO;AAMxC,IAAM,cAAc,cAAgC,MAAS;AAEtD,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAyB;AACvB,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAc;AAAA,MACd,YAAY,gBAAgB,cAAc,UAAU;AAAA,MAEnD;AAAA;AAAA,EACH;AAEJ;AAOO,IAAM,uBAAuB,CAAC;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAqE;AACnE,QAAM,OAAO;AAAA,IACX,MACE,IAAI,KAAK;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa,GAAG,aAAa,IAAI,aAAa;AAAA,MAC9C,GAAI,aAAa,EAAE,WAAW,IAAI,EAAE,aAAqC;AAAA,IAC3E,CAAC;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAO,MAAO,UAAS;AACtD;AAEO,IAAM,UAAU,MAAM;AAC3B,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AAEA,SAAO;AACT;AAEO,IAAM,gBAAgB,MAAM;AACjC,QAAM,UAAU,WAAW,WAAW;AAEtC,SAAO;AACT;AAEA,SAAS,gBAAgB,cAAkC,YAAyD;AAClH,MAAI;AAEJ,MAAI,YAAY;AACd,oBAAgB,OAAO,eAAe,WAAW,EAAE,cAAc,WAAW,IAAI;AAAA,EAClF,OAAO;AACL,oBAAgB,EAAE,aAAqC;AAAA,EACzD;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -8,14 +8,18 @@ var useWebSocketEvent = ({
|
|
|
8
8
|
eventHandler: onMessage
|
|
9
9
|
}) => {
|
|
10
10
|
const novu = useNovu();
|
|
11
|
-
const
|
|
11
|
+
const channelName = `nv_ws_connection:a=${novu.applicationIdentifier}:s=${novu.subscriberId}:e=${webSocketEvent}`;
|
|
12
|
+
const { postMessage } = useBrowserTabsChannel({
|
|
13
|
+
channelName,
|
|
14
|
+
onMessage
|
|
15
|
+
});
|
|
12
16
|
const updateReadCount = (data) => {
|
|
13
17
|
onMessage(data);
|
|
14
18
|
postMessage(data);
|
|
15
19
|
};
|
|
16
20
|
useEffect(() => {
|
|
17
21
|
let cleanup;
|
|
18
|
-
const resolveLock = requestLock(
|
|
22
|
+
const resolveLock = requestLock(channelName, () => {
|
|
19
23
|
cleanup = novu.on(webSocketEvent, updateReadCount);
|
|
20
24
|
});
|
|
21
25
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/hooks/internal/useWebsocketEvent.ts"],"sourcesContent":["import { EventHandler, Events, SocketEventNames } from '@novu/js';\nimport { useEffect } from 'react';\nimport { useNovu } from '../NovuProvider';\nimport { requestLock } from '../../utils/requestLock';\nimport { useBrowserTabsChannel } from './useBrowserTabsChannel';\n\nexport const useWebSocketEvent = <E extends SocketEventNames>({\n event: webSocketEvent,\n eventHandler: onMessage,\n}: {\n event: E;\n eventHandler: (args: Events[E]) => void;\n}) => {\n const novu = useNovu();\n const { postMessage } = useBrowserTabsChannel({
|
|
1
|
+
{"version":3,"sources":["../../../../src/hooks/internal/useWebsocketEvent.ts"],"sourcesContent":["import { EventHandler, Events, SocketEventNames } from '@novu/js';\nimport { useEffect } from 'react';\nimport { useNovu } from '../NovuProvider';\nimport { requestLock } from '../../utils/requestLock';\nimport { useBrowserTabsChannel } from './useBrowserTabsChannel';\n\nexport const useWebSocketEvent = <E extends SocketEventNames>({\n event: webSocketEvent,\n eventHandler: onMessage,\n}: {\n event: E;\n eventHandler: (args: Events[E]) => void;\n}) => {\n const novu = useNovu();\n const channelName = `nv_ws_connection:a=${novu.applicationIdentifier}:s=${novu.subscriberId}:e=${webSocketEvent}`;\n\n const { postMessage } = useBrowserTabsChannel({\n channelName,\n onMessage,\n });\n\n const updateReadCount: EventHandler<Events[E]> = (data) => {\n onMessage(data);\n postMessage(data);\n };\n\n useEffect(() => {\n let cleanup: () => void;\n const resolveLock = requestLock(channelName, () => {\n cleanup = novu.on(webSocketEvent, updateReadCount);\n });\n\n return () => {\n if (cleanup) {\n cleanup();\n }\n\n resolveLock();\n };\n }, []);\n};\n"],"mappings":";AACA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,IAAM,oBAAoB,CAA6B;AAAA,EAC5D,OAAO;AAAA,EACP,cAAc;AAChB,MAGM;AACJ,QAAM,OAAO,QAAQ;AACrB,QAAM,cAAc,sBAAsB,KAAK,qBAAqB,MAAM,KAAK,YAAY,MAAM,cAAc;AAE/G,QAAM,EAAE,YAAY,IAAI,sBAAsB;AAAA,IAC5C;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,kBAA2C,CAAC,SAAS;AACzD,cAAU,IAAI;AACd,gBAAY,IAAI;AAAA,EAClB;AAEA,YAAU,MAAM;AACd,QAAI;AACJ,UAAM,cAAc,YAAY,aAAa,MAAM;AACjD,gBAAU,KAAK,GAAG,gBAAgB,eAAe;AAAA,IACnD,CAAC;AAED,WAAO,MAAM;AACX,UAAI,SAAS;AACX,gBAAQ;AAAA,MACV;AAEA,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,CAAC;AACP;","names":[]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
export { ChannelPreference, ChannelType, EventHandler, Events, FiltersCountResponse, InboxNotification, ListNotificationsResponse, Notification, NotificationFilter, NotificationStatus, NovuError, NovuOptions, Preference, PreferenceLevel, PreferencesResponse, SocketEventNames, WebSocketEvent } from '@novu/js';
|
|
2
|
+
export { Appearance, AppearanceKey, ElementStyles, Elements, Localization, LocalizationKey, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, PreferencesFilter, RouterPush, Tab, Variables } from '@novu/js/ui';
|
|
1
3
|
export { Bell, BellProps } from './components/Bell.js';
|
|
2
4
|
export { Inbox, InboxProps } from './components/Inbox.js';
|
|
3
5
|
export { Preferences } from './components/Preferences.js';
|
|
4
6
|
export { NotificationProps, Notifications } from './components/Notifications.js';
|
|
5
7
|
export { InboxContent, InboxContentProps } from './components/InboxContent.js';
|
|
6
|
-
export {
|
|
8
|
+
export { NovuProvider, NovuProviderProps, useNovu } from './hooks/NovuProvider.js';
|
|
7
9
|
export { UseNotificationsProps, UseNotificationsResult, useNotifications } from './hooks/useNotifications.js';
|
|
8
10
|
export { UsePreferencesProps, UsePreferencesResult, usePreferences } from './hooks/usePreferences.js';
|
|
9
11
|
export { UseCountsProps, UseCountsResult, useCounts } from './hooks/useCounts.js';
|
|
10
12
|
export { BaseProps, BellRenderer, BodyRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer, SubjectBodyRendererProps, SubjectRenderer, WithChildrenProps } from './utils/types.js';
|
|
11
|
-
export { Notification } from '@novu/js/ui';
|
|
12
13
|
import 'react';
|
|
13
14
|
import 'react/jsx-runtime';
|
|
14
|
-
import '@novu/js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { Inbox, Bell, InboxContent, Notifications, NovuProvider, Preferences } from "./components/index.js";
|
|
3
|
+
import { useNovu, useCounts, useNotifications, usePreferences } from "./hooks/index.js";
|
|
4
|
+
export {
|
|
5
|
+
Bell,
|
|
6
|
+
Inbox,
|
|
7
|
+
InboxContent,
|
|
8
|
+
Notifications,
|
|
9
|
+
NovuProvider,
|
|
10
|
+
Preferences,
|
|
11
|
+
useCounts,
|
|
12
|
+
useNotifications,
|
|
13
|
+
useNovu,
|
|
14
|
+
usePreferences
|
|
15
|
+
};
|
|
4
16
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n FiltersCountResponse,\n ListNotificationsResponse,\n NovuError,\n Preference,\n PreferencesResponse,\n ChannelPreference,\n Notification,\n ChannelType,\n InboxNotification,\n NotificationFilter,\n NotificationStatus,\n NovuOptions,\n PreferenceLevel,\n WebSocketEvent,\n EventHandler,\n Events,\n SocketEventNames,\n} from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceKey,\n Elements,\n ElementStyles,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferencesFilter,\n RouterPush,\n Tab,\n Variables,\n} from '@novu/js/ui';\n\nexport { Inbox, Bell, InboxContent, Notifications, NovuProvider, Preferences } from './components';\nexport { useNovu, useCounts, useNotifications, usePreferences } from './hooks';\n\nexport type { InboxProps, BellProps, InboxContentProps, NotificationProps, NovuProviderProps } from './components';\n\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n} from './hooks';\n\nexport type {\n NotificationsRenderer,\n SubjectRenderer,\n BodyRenderer,\n BellRenderer,\n DefaultInboxProps,\n BaseProps,\n NotificationRendererProps,\n SubjectBodyRendererProps,\n NoRendererProps,\n DefaultProps,\n WithChildrenProps,\n} from './utils/types';\n"],"mappings":";AAoCA,SAAS,OAAO,MAAM,cAAc,eAAe,cAAc,mBAAmB;AACpF,SAAS,SAAS,WAAW,kBAAkB,sBAAsB;","names":[]}
|
|
@@ -3,9 +3,12 @@ import { UsePreferencesProps, UsePreferencesResult } from '../hooks/usePreferenc
|
|
|
3
3
|
import { UseCountsProps, UseCountsResult } from '../hooks/useCounts.js';
|
|
4
4
|
import { NovuProviderProps } from '../hooks/NovuProvider.js';
|
|
5
5
|
import { InboxProps } from '../components/Inbox.js';
|
|
6
|
+
export { ChannelPreference, ChannelType, FiltersCountResponse, InboxNotification, ListNotificationsResponse, Notification, NotificationFilter, NotificationStatus, NovuError, NovuOptions, Preference, PreferenceLevel } from '@novu/js';
|
|
7
|
+
export { Appearance, AppearanceKey, ElementStyles, Elements, Localization, LocalizationKey, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, PreferencesFilter, RouterPush, Tab, Variables } from '@novu/js/ui';
|
|
8
|
+
export { BellProps } from '../components/Bell.js';
|
|
9
|
+
export { NotificationProps } from '../components/Notifications.js';
|
|
10
|
+
export { InboxContentProps } from '../components/InboxContent.js';
|
|
6
11
|
export { BaseProps, BellRenderer, BodyRenderer, DefaultInboxProps, DefaultProps, NoRendererProps, NotificationRendererProps, NotificationsRenderer, SubjectBodyRendererProps, SubjectRenderer, WithChildrenProps } from '../utils/types.js';
|
|
7
|
-
export { Notification } from '@novu/js/ui';
|
|
8
|
-
import '@novu/js';
|
|
9
12
|
import 'react/jsx-runtime';
|
|
10
13
|
import 'react';
|
|
11
14
|
|
|
@@ -26,4 +29,4 @@ declare function useCounts(_: UseCountsProps): UseCountsResult;
|
|
|
26
29
|
declare function useNotifications(_: UseNotificationsProps): UseNotificationsResult;
|
|
27
30
|
declare function usePreferences(_: UsePreferencesProps): UsePreferencesResult;
|
|
28
31
|
|
|
29
|
-
export { Bell, Inbox, InboxContent, Notifications, NovuProvider, Preferences, useCounts, useNotifications, useNovu, usePreferences };
|
|
32
|
+
export { Bell, Inbox, InboxContent, InboxProps, Notifications, NovuProvider, NovuProviderProps, Preferences, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UsePreferencesProps, UsePreferencesResult, useCounts, useNotifications, useNovu, usePreferences };
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/index.tsx"],"sourcesContent":["import type {\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n} from '../hooks';\nimport type { UseCountsProps, UseCountsResult } from '../hooks/useCounts';\nimport type { InboxProps } from '../components/Inbox';\nimport type { NovuProviderProps } from '../hooks/NovuProvider';\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/server/index.tsx"],"sourcesContent":["import type {\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n} from '../hooks';\nimport type { UseCountsProps, UseCountsResult } from '../hooks/useCounts';\nimport type { InboxProps } from '../components/Inbox';\nimport type { NovuProviderProps } from '../hooks/NovuProvider';\n\n/**\n * Exporting all components from the components folder\n * as empty functions to fix build errors in SSR\n * This will be replaced with actual components\n * when we implement the SSR components in @novu/js/ui\n */\nexport function Inbox(props: InboxProps) {}\n\nexport function InboxContent() {}\n\nexport function Notifications() {}\n\nexport function Preferences() {}\n\nexport function Bell() {}\n\nexport function NovuProvider(props: NovuProviderProps) {}\n\nexport function useNovu() {\n return null;\n}\n\nexport function useCounts(_: UseCountsProps): UseCountsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useNotifications(_: UseNotificationsProps): UseNotificationsResult {\n return {\n isLoading: false,\n isFetching: false,\n hasMore: false,\n readAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAllRead: () => Promise.resolve({ data: undefined, error: undefined }),\n refetch: () => Promise.resolve(),\n fetchMore: () => Promise.resolve(),\n };\n}\n\nexport function usePreferences(_: UsePreferencesProps): UsePreferencesResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport type {\n FiltersCountResponse,\n ListNotificationsResponse,\n NovuError,\n Preference,\n ChannelPreference,\n Notification,\n ChannelType,\n InboxNotification,\n NotificationFilter,\n NotificationStatus,\n NovuOptions,\n PreferenceLevel,\n} from '@novu/js';\n\nexport type {\n Appearance,\n AppearanceKey,\n Elements,\n ElementStyles,\n Localization,\n LocalizationKey,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferencesFilter,\n RouterPush,\n Tab,\n Variables,\n} from '@novu/js/ui';\n\nexport type { InboxProps, BellProps, InboxContentProps, NotificationProps, NovuProviderProps } from '../components';\n\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n} from '../hooks';\n\nexport type {\n NotificationsRenderer,\n SubjectRenderer,\n BodyRenderer,\n BellRenderer,\n DefaultInboxProps,\n BaseProps,\n NotificationRendererProps,\n SubjectBodyRendererProps,\n NoRendererProps,\n DefaultProps,\n WithChildrenProps,\n} from '../utils/types';\n"],"mappings":";AAgBO,SAAS,MAAM,OAAmB;AAAC;AAEnC,SAAS,eAAe;AAAC;AAEzB,SAAS,gBAAgB;AAAC;AAE1B,SAAS,cAAc;AAAC;AAExB,SAAS,OAAO;AAAC;AAEjB,SAAS,aAAa,OAA0B;AAAC;AAEjD,SAAS,UAAU;AACxB,SAAO;AACT;AAEO,SAAS,UAAU,GAAoC;AAC5D,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;AAEO,SAAS,iBAAiB,GAAkD;AACjF,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IACpE,YAAY,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IACvE,gBAAgB,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,IAC3E,SAAS,MAAM,QAAQ,QAAQ;AAAA,IAC/B,WAAW,MAAM,QAAQ,QAAQ;AAAA,EACnC;AACF;AAEO,SAAS,eAAe,GAA8C;AAC3E,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Notification, NotificationClickHandler, NotificationActionClickHandler, InboxProps, Appearance, Localization, Tab, PreferencesFilter, RouterPush } from '@novu/js/ui';
|
|
2
|
-
|
|
2
|
+
import { Subscriber } from '@novu/js';
|
|
3
3
|
|
|
4
4
|
type NotificationsRenderer = (notification: Notification) => React.ReactNode;
|
|
5
5
|
type SubjectRenderer = (notification: Notification) => React.ReactNode;
|
|
@@ -19,7 +19,6 @@ type DefaultInboxProps = {
|
|
|
19
19
|
};
|
|
20
20
|
type BaseProps = {
|
|
21
21
|
applicationIdentifier: string;
|
|
22
|
-
subscriberId: string;
|
|
23
22
|
subscriberHash?: string;
|
|
24
23
|
backendUrl?: string;
|
|
25
24
|
socketUrl?: string;
|
|
@@ -28,7 +27,14 @@ type BaseProps = {
|
|
|
28
27
|
tabs?: Array<Tab>;
|
|
29
28
|
preferencesFilter?: PreferencesFilter;
|
|
30
29
|
routerPush?: RouterPush;
|
|
31
|
-
}
|
|
30
|
+
} & ({
|
|
31
|
+
/** @deprecated Use subscriber prop instead */
|
|
32
|
+
subscriberId: string;
|
|
33
|
+
subscriber?: never;
|
|
34
|
+
} | {
|
|
35
|
+
subscriber: Subscriber | string;
|
|
36
|
+
subscriberId?: never;
|
|
37
|
+
});
|
|
32
38
|
type NotificationRendererProps = {
|
|
33
39
|
renderNotification: NotificationsRenderer;
|
|
34
40
|
renderSubject?: never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novu/react",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/novuhq/novu",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
112
|
"dependencies": {
|
|
113
|
-
"@novu/js": "3.0
|
|
113
|
+
"@novu/js": "3.2.0"
|
|
114
114
|
},
|
|
115
115
|
"nx": {
|
|
116
116
|
"tags": [
|