@notificationapi/react 0.0.33 → 0.0.35

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.
Files changed (30) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/AntdIcon.js +1 -1
  3. package/dist/assets/CloseOutlined.js +13 -0
  4. package/dist/assets/Notification.js +17 -16
  5. package/dist/assets/PreferenceInput.js +1470 -0
  6. package/dist/assets/PurePanel.js +32 -42
  7. package/dist/assets/WebPushOptInMessage.js +478 -0
  8. package/dist/assets/button.js +50 -50
  9. package/dist/assets/colors.js +25 -20840
  10. package/dist/assets/compact-item.js +860 -0
  11. package/dist/assets/index.js +11 -9
  12. package/dist/assets/index2.js +10 -9
  13. package/dist/assets/index3.js +2303 -3150
  14. package/dist/assets/presets.js +22 -22
  15. package/dist/assets/reactNode.js +20821 -0
  16. package/dist/components/Notifications/Inbox.js +81 -78
  17. package/dist/components/Notifications/NotificationFeed.js +59 -31
  18. package/dist/components/Notifications/NotificationLauncher.js +61 -41
  19. package/dist/components/Notifications/NotificationPopup.js +72 -65
  20. package/dist/components/Preferences/NotificationPreferencesInline.d.ts +1 -1
  21. package/dist/components/Preferences/NotificationPreferencesInline.js +39 -5
  22. package/dist/components/Preferences/NotificationPreferencesPopup.d.ts +1 -1
  23. package/dist/components/Preferences/NotificationPreferencesPopup.js +463 -464
  24. package/dist/components/Preferences/PreferenceInput.js +5 -1466
  25. package/dist/components/Preferences/Preferences.js +24 -23
  26. package/dist/components/Provider/index.d.ts +9 -1
  27. package/dist/components/Provider/index.js +214 -156
  28. package/dist/components/WebPush/WebPushOptInMessage.d.ts +14 -0
  29. package/dist/components/WebPush/WebPushOptInMessage.js +8 -0
  30. package/package.json +2 -2
@@ -1,24 +1,24 @@
1
- import { jsx as B } from "react/jsx-runtime";
2
- import { createContext as z, useState as N, useCallback as m, useMemo as F, useRef as k, useEffect as U, useContext as G } from "react";
3
- const J = async (e, s, i, a, f, w, h) => {
4
- const p = _(a, f, w), l = await fetch(
5
- `https://${s}/${a}/users/${encodeURIComponent(
1
+ import { jsx as z } from "react/jsx-runtime";
2
+ import { createContext as Q, useState as I, useCallback as m, useMemo as X, useRef as T, useEffect as P, useContext as Y } from "react";
3
+ const Z = async (e, r, o, a, f, b, h) => {
4
+ const l = ee(a, f, b), g = await fetch(
5
+ `https://${r}/${a}/users/${encodeURIComponent(
6
6
  f
7
- )}/${i}`,
7
+ )}/${o}`,
8
8
  {
9
9
  method: e,
10
10
  body: JSON.stringify(h),
11
11
  headers: {
12
- Authorization: `Basic ${p}`
12
+ Authorization: `Basic ${l}`
13
13
  }
14
14
  }
15
15
  );
16
16
  try {
17
- return await l.json();
17
+ return await g.json();
18
18
  } catch {
19
19
  return;
20
20
  }
21
- }, _ = (e, s, i) => btoa(i ? e + ":" + s + ":" + i : e + ":" + s), M = {
21
+ }, ee = (e, r, o) => btoa(o ? e + ":" + r + ":" + o : e + ":" + r), H = {
22
22
  host: "api.notificationapi.com",
23
23
  websocketHost: "ws.notificationapi.com",
24
24
  userId: "",
@@ -31,76 +31,79 @@ const J = async (e, s, i, a, f, w, h) => {
31
31
  onNewInAppNotifications: void 0,
32
32
  keepWebSocketAliveForSeconds: 86400
33
33
  // 24 hours
34
- }, n = {
35
- config: M,
34
+ }, i = {
35
+ config: H,
36
36
  init: function(e) {
37
- return this.config = { ...M, ...e }, {
37
+ return this.config = { ...H, ...e }, {
38
38
  ...this
39
39
  };
40
40
  },
41
41
  rest: {
42
- generic: function(e, s, i) {
43
- return J(
42
+ generic: function(e, r, o) {
43
+ return Z(
44
44
  e,
45
- n.config.host,
46
- s,
47
- n.config.clientId,
48
- n.config.userId,
49
- n.config.hashedUserId,
50
- i
45
+ i.config.host,
46
+ r,
47
+ i.config.clientId,
48
+ i.config.userId,
49
+ i.config.hashedUserId,
50
+ o
51
51
  );
52
52
  },
53
53
  // The functions below are nice wrappers over the generic
54
54
  // rest api function above. They must follow REST API naming:
55
55
  // Method + Resource, representing the end-point.
56
- getNotifications: function(e, s) {
57
- return n.rest.generic(
56
+ getNotifications: function(e, r) {
57
+ return i.rest.generic(
58
58
  "GET",
59
- `notifications/INAPP_WEB?count=${s}&before=${e}`
59
+ `notifications/INAPP_WEB?count=${r}&before=${e}`
60
60
  );
61
61
  },
62
62
  patchNotifications: function(e) {
63
- return n.rest.generic(
63
+ return i.rest.generic(
64
64
  "PATCH",
65
65
  "notifications/INAPP_WEB",
66
66
  e
67
67
  );
68
68
  },
69
69
  getPreferences: function() {
70
- return n.rest.generic("GET", "preferences");
70
+ return i.rest.generic("GET", "preferences");
71
71
  },
72
72
  postPreferences: function(e) {
73
- return n.rest.generic(
73
+ return i.rest.generic(
74
74
  "POST",
75
75
  "preferences",
76
76
  e
77
77
  );
78
78
  },
79
79
  postUser: function(e) {
80
- return n.rest.generic("POST", "", e);
80
+ return i.rest.generic("POST", "", e);
81
+ },
82
+ getUserAccountMetadata: function() {
83
+ return i.rest.generic("GET", "account_metadata");
81
84
  }
82
85
  },
83
86
  websocket: {
84
87
  object: void 0,
85
88
  connect: function() {
86
- let e = `wss://${n.config.websocketHost}?userId=${encodeURIComponent(n.config.userId)}&envId=${n.config.clientId}`;
87
- return n.config.hashedUserId && (e += `&userIdHash=${encodeURIComponent(n.config.hashedUserId)}`), n.websocket.object = new WebSocket(e), n.websocket.object.onmessage = (s) => {
88
- const i = JSON.parse(s.data);
89
- if (!(!i || !i.route) && i.route === "inapp_web/new_notifications") {
90
- const a = i;
91
- n.config.onNewInAppNotifications && n.config.onNewInAppNotifications(
89
+ let e = `wss://${i.config.websocketHost}?userId=${encodeURIComponent(i.config.userId)}&envId=${i.config.clientId}`;
90
+ return i.config.hashedUserId && (e += `&userIdHash=${encodeURIComponent(i.config.hashedUserId)}`), i.websocket.object = new WebSocket(e), i.websocket.object.onmessage = (r) => {
91
+ const o = JSON.parse(r.data);
92
+ if (!(!o || !o.route) && o.route === "inapp_web/new_notifications") {
93
+ const a = o;
94
+ i.config.onNewInAppNotifications && i.config.onNewInAppNotifications(
92
95
  a.payload.notifications
93
96
  );
94
97
  }
95
- }, n.websocket.object;
98
+ }, i.websocket.object;
96
99
  },
97
100
  disconnect: function(e) {
98
- var s;
99
- n.websocket.object && ((s = n.websocket.object) == null || s.close(), e && e(n.websocket.object));
101
+ var r;
102
+ i.websocket.object && ((r = i.websocket.object) == null || r.close(), e && e(i.websocket.object));
100
103
  }
101
104
  },
102
105
  openWebSocket: function() {
103
- return n.websocket.connect(() => {
106
+ return i.websocket.connect(() => {
104
107
  setTimeout(
105
108
  () => {
106
109
  this.websocket.disconnect(() => {
@@ -115,198 +118,253 @@ const J = async (e, s, i, a, f, w, h) => {
115
118
  // They may or may not do additional tasks.
116
119
  // e.g. identify simply maps to postUsers
117
120
  getInAppNotifications: async (e) => {
118
- const s = e.maxCountNeeded || n.config.getInAppDefaultCount, i = e.oldestNeeded || n.config.getInAppDefaultOldest;
119
- let a = [], f = e.before, w = !0, h = !0;
121
+ const r = e.maxCountNeeded || i.config.getInAppDefaultCount, o = e.oldestNeeded || i.config.getInAppDefaultOldest;
122
+ let a = [], f = e.before, b = !0, h = !0;
120
123
  for (; h; ) {
121
- const p = (await n.rest.getNotifications(
124
+ const l = (await i.rest.getNotifications(
122
125
  f,
123
- s
126
+ r
124
127
  )).notifications.filter(
125
- (l) => !a.find((g) => g.id === l.id)
128
+ (g) => !a.find((w) => w.id === g.id)
126
129
  );
127
- f = p.reduce(
128
- (l, g) => l < g.date ? l : g.date,
130
+ f = l.reduce(
131
+ (g, w) => g < w.date ? g : w.date,
129
132
  e.before
130
- ), a = [...a, ...p], w = p.length > 0, h = !0, (!w || a.length >= s || f < i) && (h = !1);
133
+ ), a = [...a, ...l], b = l.length > 0, h = !0, (!b || a.length >= r || f < o) && (h = !1);
131
134
  }
132
135
  return {
133
136
  items: a,
134
- hasMore: w,
137
+ hasMore: b,
135
138
  oldestReceived: f
136
139
  };
137
140
  },
138
141
  updateInAppNotifications: async (e) => {
139
- const s = {
142
+ const r = {
140
143
  trackingIds: e.ids
141
144
  };
142
- return e.archived === !0 ? s.archived = (/* @__PURE__ */ new Date()).toISOString() : e.archived === !1 && (s.archived = null), e.clicked === !0 ? s.clicked = (/* @__PURE__ */ new Date()).toISOString() : e.clicked === !1 && (s.clicked = null), e.opened === !0 ? s.opened = (/* @__PURE__ */ new Date()).toISOString() : e.opened === !1 && (s.opened = null), n.rest.patchNotifications(s);
145
+ return e.archived === !0 ? r.archived = (/* @__PURE__ */ new Date()).toISOString() : e.archived === !1 && (r.archived = null), e.clicked === !0 ? r.clicked = (/* @__PURE__ */ new Date()).toISOString() : e.clicked === !1 && (r.clicked = null), e.opened === !0 ? r.opened = (/* @__PURE__ */ new Date()).toISOString() : e.opened === !1 && (r.opened = null), i.rest.patchNotifications(r);
143
146
  },
144
- getPreferences: async () => n.rest.getPreferences(),
145
- updateDeliveryOption: async (e) => n.rest.postPreferences([e]),
147
+ getPreferences: async () => i.rest.getPreferences(),
148
+ updateDeliveryOption: async (e) => i.rest.postPreferences([e]),
146
149
  identify: async (e) => {
147
- if (e.id && e.id !== n.config.userId)
150
+ if (e.id && e.id !== i.config.userId)
148
151
  throw new Error(
149
152
  "The id in the parameters does not match the initialized userId."
150
153
  );
151
- return n.rest.postUser(e);
152
- }
153
- }, E = z(
154
+ return i.rest.postUser(e);
155
+ },
156
+ getUserAccountMetadata: async () => i.rest.getUserAccountMetadata()
157
+ }, F = Q(
154
158
  void 0
155
- ), q = (e) => {
156
- const i = {
159
+ ), te = (e) => {
160
+ const o = {
157
161
  ...{
158
162
  apiURL: "https://api.notificationapi.com",
159
163
  wsURL: "wss://ws.notificationapi.com",
160
164
  initialLoadMaxCount: 1e3,
161
165
  initialLoadMaxAge: new Date((/* @__PURE__ */ new Date()).setMonth((/* @__PURE__ */ new Date()).getMonth() - 3)),
162
166
  playSoundOnNewNotification: !1,
163
- newNotificationSoundPath: "https://proxy.notificationsounds.com/notification-sounds/elegant-notification-sound/download/file-sounds-1233-elegant.mp3"
167
+ newNotificationSoundPath: "https://proxy.notificationsounds.com/notification-sounds/elegant-notification-sound/download/file-sounds-1233-elegant.mp3",
168
+ webPushOptInMessage: "AUTOMATIC",
169
+ customServiceWorkerPath: "/notificationapi-service-worker.js"
164
170
  },
165
171
  ...e,
166
172
  user: "userId" in e ? { id: e.userId } : e.user
167
- }, [a, f] = N(), [w, h] = N(), [p, l] = N(!1), [g, y] = N((/* @__PURE__ */ new Date()).toISOString()), [b, P] = N(!0), D = m(() => {
168
- i.playSoundOnNewNotification && new Audio(i.newNotificationSoundPath).play().catch((r) => {
169
- console.log("Failed to play new notification sound:", r);
173
+ }, [a, f] = I(), [b, h] = I(), [l, g] = I(), [w, y] = I(!1), [k, C] = I((/* @__PURE__ */ new Date()).toISOString()), [A, U] = I(!0), [v, N] = I(o.webPushOptInMessage), [x, J] = I(!1), W = m(() => {
174
+ o.playSoundOnNewNotification && new Audio(o.newNotificationSoundPath).play().catch((s) => {
175
+ console.log("Failed to play new notification sound:", s);
170
176
  });
171
- }, [i.newNotificationSoundPath, i.playSoundOnNewNotification]), S = m((o) => {
172
- const r = (/* @__PURE__ */ new Date()).toISOString();
173
- f((t) => (o = o.filter((c) => !(c.expDate && new Date(c.expDate * 1e3).toISOString() > r || c.date > r)), t ? [
174
- ...o.filter((c) => !t.find((d) => d.id === c.id)),
175
- ...t
176
- ] : o));
177
- }, []), u = F(() => {
178
- const o = e.client ? e.client : n.init({
179
- clientId: i.clientId,
180
- userId: i.user.id,
181
- hashedUserId: i.hashedUserId,
182
- onNewInAppNotifications: (r) => {
183
- D(), S(r);
177
+ }, [o.newNotificationSoundPath, o.playSoundOnNewNotification]), S = m((t) => {
178
+ const s = (/* @__PURE__ */ new Date()).toISOString();
179
+ f((n) => (t = t.filter((d) => {
180
+ const p = d.expDate && new Date(d.expDate * 1e3).toISOString() < s, D = new Date(d.date).getTime() > new Date(s).getTime() + 1e3;
181
+ return !p && !D;
182
+ }), n ? [
183
+ ...t.filter((d) => !n.find((D) => D.id === d.id)),
184
+ ...n
185
+ ] : t));
186
+ }, []), u = X(() => {
187
+ const t = e.client ? e.client : i.init({
188
+ clientId: o.clientId,
189
+ userId: o.user.id,
190
+ hashedUserId: o.hashedUserId,
191
+ onNewInAppNotifications: (s) => {
192
+ W(), S(s);
184
193
  }
185
194
  });
186
- return o.identify({
187
- email: i.user.email,
188
- number: i.user.number
189
- }), o;
195
+ return t.identify({
196
+ email: o.user.email,
197
+ number: o.user.number
198
+ }), t;
190
199
  }, [
191
- i.clientId,
192
- i.user.id,
193
- i.user.email,
194
- i.user.number,
195
- i.hashedUserId,
200
+ o.clientId,
201
+ o.user.id,
202
+ o.user.email,
203
+ o.user.number,
204
+ o.hashedUserId,
196
205
  S,
197
- D,
206
+ W,
198
207
  e.client
199
- ]), O = m(
200
- async (o, r) => {
201
- const t = await u.rest.getNotifications(o, r);
202
- y(t.oldestReceived), P(t.couldLoadMore), S(t.notifications);
208
+ ]), L = m(
209
+ async (t, s) => {
210
+ const n = await u.rest.getNotifications(t, s);
211
+ C(n.oldestReceived), U(n.couldLoadMore), S(n.notifications);
203
212
  },
204
213
  [S, u.rest]
205
- ), v = k(b), C = k(p), x = k(g);
206
- U(() => {
207
- v.current = b, C.current = p, x.current = g;
208
- }, [b, p, g]);
209
- const A = m(
210
- async (o) => {
211
- if (!(!o && (!v.current || C.current))) {
212
- l(!0);
214
+ ), E = T(A), R = T(w), $ = T(k);
215
+ P(() => {
216
+ E.current = A, R.current = w, $.current = k;
217
+ }, [A, w, k]);
218
+ const O = m(
219
+ async (t) => {
220
+ if (!(!t && (!E.current || R.current))) {
221
+ y(!0);
213
222
  try {
214
- await O(
215
- o ? (/* @__PURE__ */ new Date()).toISOString() : x.current,
216
- o ? i.initialLoadMaxCount : 1e3
223
+ await L(
224
+ t ? (/* @__PURE__ */ new Date()).toISOString() : $.current,
225
+ t ? o.initialLoadMaxCount : 1e3
217
226
  );
218
227
  } finally {
219
- l(!1);
228
+ y(!1);
220
229
  }
221
230
  }
222
231
  },
223
- [i.initialLoadMaxCount, O]
224
- ), R = async (o) => {
232
+ [o.initialLoadMaxCount, L]
233
+ ), q = async (t) => {
225
234
  if (!a) return;
226
- const r = (/* @__PURE__ */ new Date()).toISOString(), t = a.filter((c) => o.includes(c.id) && !c.clicked).map((c) => c.id);
227
- u.updateInAppNotifications({ ids: t, clicked: !0 }), f((c) => {
235
+ const s = (/* @__PURE__ */ new Date()).toISOString(), n = a.filter((c) => t.includes(c.id) && !c.clicked).map((c) => c.id);
236
+ u.updateInAppNotifications({ ids: n, clicked: !0 }), f((c) => {
228
237
  if (!c) return [];
229
238
  const d = [...c];
230
- return d.filter((I) => t.includes(I.id)).forEach((I) => {
231
- I.clicked = r;
239
+ return d.filter((p) => n.includes(p.id)).forEach((p) => {
240
+ p.clicked = s;
232
241
  }), d;
233
242
  });
234
- }, $ = async () => {
243
+ }, B = async () => {
235
244
  if (!a) return;
236
- const o = (/* @__PURE__ */ new Date()).toISOString(), r = a.filter((t) => !t.opened || !t.seen).map((t) => t.id);
237
- r.length !== 0 && (u.updateInAppNotifications({
238
- ids: r,
245
+ const t = (/* @__PURE__ */ new Date()).toISOString(), s = a.filter((n) => !n.opened || !n.seen).map((n) => n.id);
246
+ s.length !== 0 && (u.updateInAppNotifications({
247
+ ids: s,
239
248
  opened: !0
240
- }), f((t) => {
241
- if (!t) return [];
242
- const c = [...t];
243
- return c.filter((d) => r.includes(d.id)).forEach((d) => {
244
- d.opened = o, d.seen = !0;
249
+ }), f((n) => {
250
+ if (!n) return [];
251
+ const c = [...n];
252
+ return c.filter((d) => s.includes(d.id)).forEach((d) => {
253
+ d.opened = t, d.seen = !0;
245
254
  }), c;
246
255
  }));
247
- }, j = async (o) => {
256
+ }, G = async (t) => {
248
257
  if (!a) return;
249
- const r = a.filter((t) => t.archived && (o === "ALL" || o.includes(t.id))).map((t) => t.id);
250
- r.length !== 0 && (u.updateInAppNotifications({
251
- ids: r,
258
+ const s = a.filter((n) => n.archived && (t === "ALL" || t.includes(n.id))).map((n) => n.id);
259
+ s.length !== 0 && (u.updateInAppNotifications({
260
+ ids: s,
252
261
  archived: !1
253
- }), f((t) => {
254
- if (!t) return [];
255
- const c = [...t];
256
- return c.filter((d) => r.includes(d.id)).forEach((d) => {
262
+ }), f((n) => {
263
+ if (!n) return [];
264
+ const c = [...n];
265
+ return c.filter((d) => s.includes(d.id)).forEach((d) => {
257
266
  d.archived = void 0;
258
267
  }), c;
259
268
  }));
260
- }, T = async (o) => {
269
+ }, K = async (t) => {
261
270
  if (!a) return;
262
- const r = (/* @__PURE__ */ new Date()).toISOString(), t = a.filter((c) => !c.archived && (o === "ALL" || o.includes(c.id))).map((c) => c.id);
263
- t.length !== 0 && (u.updateInAppNotifications({ ids: t, archived: !0 }), f((c) => {
271
+ const s = (/* @__PURE__ */ new Date()).toISOString(), n = a.filter((c) => !c.archived && (t === "ALL" || t.includes(c.id))).map((c) => c.id);
272
+ n.length !== 0 && (u.updateInAppNotifications({ ids: n, archived: !0 }), f((c) => {
264
273
  if (!c) return [];
265
274
  const d = [...c];
266
- return d.filter((I) => t.includes(I.id)).forEach((I) => {
267
- I.archived = r;
275
+ return d.filter((p) => n.includes(p.id)).forEach((p) => {
276
+ p.archived = s;
268
277
  }), d;
269
278
  }));
270
- }, W = (o, r, t, c) => L([
279
+ }, V = (t, s, n, c) => j([
271
280
  {
272
- notificationId: o,
273
- channel: r,
274
- delivery: t,
281
+ notificationId: t,
282
+ channel: s,
283
+ delivery: n,
275
284
  subNotificationId: c
276
285
  }
277
- ]), L = (o) => {
278
- u.rest.postPreferences(o).then(() => {
279
- u.getPreferences().then((r) => {
280
- h(r);
286
+ ]), j = (t) => {
287
+ u.rest.postPreferences(t).then(() => {
288
+ u.getPreferences().then((s) => {
289
+ h(s);
281
290
  });
282
291
  });
283
- };
284
- U(() => {
285
- f([]), l(!1), h(void 0), y((/* @__PURE__ */ new Date()).toISOString()), P(!0), A(!0), u.openWebSocket(), u.getPreferences().then((o) => {
286
- h(o);
292
+ }, M = m(() => {
293
+ "serviceWorker" in navigator && navigator.serviceWorker.register(o.customServiceWorkerPath).then(async (t) => {
294
+ N(!1), Notification.requestPermission().then(async (s) => {
295
+ s === "granted" ? await t.pushManager.subscribe({
296
+ userVisibleOnly: !0,
297
+ applicationServerKey: l == null ? void 0 : l.userAccountMetadata.environmentVapidPublicKey
298
+ }).then(async (n) => {
299
+ const c = {
300
+ webPushTokens: [
301
+ {
302
+ sub: {
303
+ endpoint: n.toJSON().endpoint,
304
+ keys: n.toJSON().keys
305
+ }
306
+ }
307
+ ]
308
+ };
309
+ await u.identify(c), console.log("index"), localStorage.setItem("hideWebPushOptInMessage", "true");
310
+ }) : s === "denied" && console.log("Permission for notifications was denied");
311
+ });
312
+ }).catch((t) => {
313
+ t.code === 18 ? console.error(
314
+ "NotificationAPI guide: Probably you are not setup the service worker correctly. Please check the documentation at https://docs.notificationapi.com/guides/web-push#step-by-step-implementation Step 3: Service Worker Setup."
315
+ ) : t.code === 19 ? console.error(
316
+ "The operation is aborted. This can happen if the user denies the permission request."
317
+ ) : t.code === 20 ? console.error(
318
+ "The operation is invalid. This can occur if the provided application server key is invalid. Please contact NotificationAPI support."
319
+ ) : t.code === 21 ? console.error(
320
+ "The operation is not allowed. This can happen if the user has blocked notifications for the site. Please check your browser site settings Notifications part."
321
+ ) : t.code === 22 ? console.error(
322
+ "The operation is not supported. This can occur if the browser does not support the required features."
323
+ ) : console.error(t);
324
+ });
325
+ }, [
326
+ u,
327
+ o.customServiceWorkerPath,
328
+ l == null ? void 0 : l.userAccountMetadata.environmentVapidPublicKey
329
+ ]);
330
+ P(() => {
331
+ f([]), y(!1), h(void 0), C((/* @__PURE__ */ new Date()).toISOString()), U(!0), O(!0), u.openWebSocket(), u.getPreferences().then((t) => {
332
+ h(t);
287
333
  });
288
- }, [u, A]);
289
- const H = {
334
+ }, [u, O, M]), P(() => {
335
+ Notification.permission !== "default" && N(!1), v === "AUTOMATIC" && (N(
336
+ localStorage.getItem("hideWebPushOptInMessage") !== "true"
337
+ ), u.getUserAccountMetadata().then((t) => {
338
+ g(t), N(t.userAccountMetadata.hasWebPushEnabled);
339
+ }));
340
+ }, [u, v]), P(() => {
341
+ x && M();
342
+ }, [x, M]);
343
+ const _ = {
290
344
  notifications: a,
291
- preferences: w,
292
- loadNotifications: A,
293
- markAsOpened: $,
294
- markAsArchived: T,
295
- markAsUnarchived: j,
296
- markAsClicked: R,
297
- updateDelivery: W,
298
- updateDeliveries: L,
299
- getClient: () => u
345
+ preferences: b,
346
+ userAccountMetaData: l,
347
+ webPushOptInMessage: v,
348
+ loadNotifications: O,
349
+ markAsOpened: B,
350
+ markAsArchived: K,
351
+ markAsUnarchived: G,
352
+ markAsClicked: q,
353
+ updateDelivery: V,
354
+ updateDeliveries: j,
355
+ getClient: () => u,
356
+ setWebPushOptInMessage: N,
357
+ setWebPushOptIn: J
300
358
  };
301
- return /* @__PURE__ */ B(E.Provider, { value: H, children: e.children });
302
- }, K = () => {
303
- const e = G(E);
359
+ return /* @__PURE__ */ z(F.Provider, { value: _, children: e.children });
360
+ }, ne = () => {
361
+ const e = Y(F);
304
362
  if (!e)
305
363
  throw new Error("useMyContext must be used within a MyProvider");
306
364
  return e;
307
365
  };
308
- q.useNotificationAPIContext = K;
366
+ te.useNotificationAPIContext = ne;
309
367
  export {
310
- E as NotificationAPIContext,
311
- q as NotificationAPIProvider
368
+ F as NotificationAPIContext,
369
+ te as NotificationAPIProvider
312
370
  };
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+
3
+ interface WebPushOptInMessageProps {
4
+ hideAfterInteraction?: boolean;
5
+ alertContainerStyle?: React.CSSProperties;
6
+ descriptionStyle?: React.CSSProperties;
7
+ buttonContainerStyle?: React.CSSProperties;
8
+ yesButtonStyle?: React.CSSProperties;
9
+ cancelButtonStyle?: React.CSSProperties;
10
+ description?: string;
11
+ icon?: React.ReactNode;
12
+ }
13
+ declare const WebPushOptInMessage: React.FC<WebPushOptInMessageProps>;
14
+ export default WebPushOptInMessage;
@@ -0,0 +1,8 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import "../Provider/index.js";
4
+ import { W as a } from "../../assets/WebPushOptInMessage.js";
5
+ import "../../assets/button.js";
6
+ export {
7
+ a as default
8
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@notificationapi/react",
3
3
  "private": false,
4
- "version": "0.0.33",
4
+ "version": "0.0.35",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -43,7 +43,7 @@
43
43
  "**/*.css"
44
44
  ],
45
45
  "dependencies": {
46
- "@notificationapi/core": "^0.0.10",
46
+ "@notificationapi/core": "^0.0.12",
47
47
  "antd": "^5.17.4",
48
48
  "javascript-time-ago": "^2.5.10",
49
49
  "liquidjs": "^10.14.0",