@notificationapi/react 0.0.34 → 0.0.36

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 +211 -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 F } from "react/jsx-runtime";
2
- import { createContext as z, useState as N, useCallback as m, useMemo as G, useRef as y, useEffect as M, useContext as J } from "react";
3
- const _ = async (e, c, i, a, f, I, h) => {
4
- const g = q(a, f, I), l = await fetch(
5
- `https://${c}/${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 S, 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 ${g}`
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
- }, q = (e, c, i) => btoa(i ? e + ":" + c + ":" + i : e + ":" + c), E = {
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 _ = async (e, c, i, a, f, I, h) => {
31
31
  onNewInAppNotifications: void 0,
32
32
  keepWebSocketAliveForSeconds: 86400
33
33
  // 24 hours
34
- }, n = {
35
- config: E,
34
+ }, i = {
35
+ config: H,
36
36
  init: function(e) {
37
- return this.config = { ...E, ...e }, {
37
+ return this.config = { ...H, ...e }, {
38
38
  ...this
39
39
  };
40
40
  },
41
41
  rest: {
42
- generic: function(e, c, i) {
43
- return _(
42
+ generic: function(e, r, o) {
43
+ return Z(
44
44
  e,
45
- n.config.host,
46
- c,
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, c) {
57
- return n.rest.generic(
56
+ getNotifications: function(e, r) {
57
+ return i.rest.generic(
58
58
  "GET",
59
- `notifications/INAPP_WEB?count=${c}&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 = (c) => {
88
- const i = JSON.parse(c.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 c;
99
- n.websocket.object && ((c = n.websocket.object) == null || c.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,201 +118,253 @@ const _ = async (e, c, i, a, f, I, 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 c = e.maxCountNeeded || n.config.getInAppDefaultCount, i = e.oldestNeeded || n.config.getInAppDefaultOldest;
119
- let a = [], f = e.before, I = !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 g = (await n.rest.getNotifications(
124
+ const l = (await i.rest.getNotifications(
122
125
  f,
123
- c
126
+ r
124
127
  )).notifications.filter(
125
- (l) => !a.find((w) => w.id === l.id)
128
+ (g) => !a.find((w) => w.id === g.id)
126
129
  );
127
- f = g.reduce(
128
- (l, w) => l < w.date ? l : w.date,
130
+ f = l.reduce(
131
+ (g, w) => g < w.date ? g : w.date,
129
132
  e.before
130
- ), a = [...a, ...g], I = g.length > 0, h = !0, (!I || a.length >= c || 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: I,
137
+ hasMore: b,
135
138
  oldestReceived: f
136
139
  };
137
140
  },
138
141
  updateInAppNotifications: async (e) => {
139
- const c = {
142
+ const r = {
140
143
  trackingIds: e.ids
141
144
  };
142
- return e.archived === !0 ? c.archived = (/* @__PURE__ */ new Date()).toISOString() : e.archived === !1 && (c.archived = null), e.clicked === !0 ? c.clicked = (/* @__PURE__ */ new Date()).toISOString() : e.clicked === !1 && (c.clicked = null), e.opened === !0 ? c.opened = (/* @__PURE__ */ new Date()).toISOString() : e.opened === !1 && (c.opened = null), n.rest.patchNotifications(c);
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
- }, R = z(
154
+ return i.rest.postUser(e);
155
+ },
156
+ getUserAccountMetadata: async () => i.rest.getUserAccountMetadata()
157
+ }, F = Q(
154
158
  void 0
155
- ), K = (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(), [I, h] = N(), [g, l] = N(!1), [w, D] = N((/* @__PURE__ */ new Date()).toISOString()), [b, P] = N(!0), O = m(() => {
168
- i.playSoundOnNewNotification && new Audio(i.newNotificationSoundPath).play().catch((s) => {
173
+ }, [a, f] = I(), [b, h] = I(), [l, g] = I(), [w, P] = 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) => {
169
175
  console.log("Failed to play new notification sound:", s);
170
176
  });
171
- }, [i.newNotificationSoundPath, i.playSoundOnNewNotification]), S = m((o) => {
177
+ }, [o.newNotificationSoundPath, o.playSoundOnNewNotification]), y = m((t) => {
172
178
  const s = (/* @__PURE__ */ new Date()).toISOString();
173
- f((t) => (o = o.filter((d) => {
174
- const p = d.expDate && new Date(d.expDate * 1e3).toISOString() < s, k = new Date(d.date).getTime() > new Date(s).getTime() + 1e3;
175
- return !p && !k;
176
- }), t ? [
177
- ...o.filter((d) => !t.find((k) => k.id === d.id)),
178
- ...t
179
- ] : o));
180
- }, []), u = G(() => {
181
- const o = e.client ? e.client : n.init({
182
- clientId: i.clientId,
183
- userId: i.user.id,
184
- hashedUserId: i.hashedUserId,
179
+ f((n) => (t = Array.isArray(t) ? t : [], 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
+ }), Array.isArray(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,
185
191
  onNewInAppNotifications: (s) => {
186
- O(), S(s);
192
+ W(), y(s);
187
193
  }
188
194
  });
189
- return o.identify({
190
- email: i.user.email,
191
- number: i.user.number
192
- }), o;
195
+ return t.identify({
196
+ email: o.user.email,
197
+ number: o.user.number
198
+ }), t;
193
199
  }, [
194
- i.clientId,
195
- i.user.id,
196
- i.user.email,
197
- i.user.number,
198
- i.hashedUserId,
199
- S,
200
- O,
200
+ o.clientId,
201
+ o.user.id,
202
+ o.user.email,
203
+ o.user.number,
204
+ o.hashedUserId,
205
+ y,
206
+ W,
201
207
  e.client
202
- ]), v = m(
203
- async (o, s) => {
204
- const t = await u.rest.getNotifications(o, s);
205
- D(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), y(n.notifications);
206
212
  },
207
- [S, u.rest]
208
- ), C = y(b), x = y(g), L = y(w);
209
- M(() => {
210
- C.current = b, x.current = g, L.current = w;
211
- }, [b, g, w]);
212
- const A = m(
213
- async (o) => {
214
- if (!(!o && (!C.current || x.current))) {
215
- l(!0);
213
+ [y, u.rest]
214
+ ), E = T(A), R = T(w), $ = T(k);
215
+ S(() => {
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
+ P(!0);
216
222
  try {
217
- await v(
218
- o ? (/* @__PURE__ */ new Date()).toISOString() : L.current,
219
- o ? i.initialLoadMaxCount : 1e3
223
+ await L(
224
+ t ? (/* @__PURE__ */ new Date()).toISOString() : $.current,
225
+ t ? o.initialLoadMaxCount : 1e3
220
226
  );
221
227
  } finally {
222
- l(!1);
228
+ P(!1);
223
229
  }
224
230
  }
225
231
  },
226
- [i.initialLoadMaxCount, v]
227
- ), $ = async (o) => {
232
+ [o.initialLoadMaxCount, L]
233
+ ), q = async (t) => {
228
234
  if (!a) return;
229
- const s = (/* @__PURE__ */ new Date()).toISOString(), t = a.filter((r) => o.includes(r.id) && !r.clicked).map((r) => r.id);
230
- u.updateInAppNotifications({ ids: t, clicked: !0 }), f((r) => {
231
- if (!r) return [];
232
- const d = [...r];
233
- return d.filter((p) => t.includes(p.id)).forEach((p) => {
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) => {
237
+ if (!c) return [];
238
+ const d = [...c];
239
+ return d.filter((p) => n.includes(p.id)).forEach((p) => {
234
240
  p.clicked = s;
235
241
  }), d;
236
242
  });
237
- }, T = async () => {
243
+ }, B = async () => {
238
244
  if (!a) return;
239
- const o = (/* @__PURE__ */ new Date()).toISOString(), s = a.filter((t) => !t.opened || !t.seen).map((t) => t.id);
245
+ const t = (/* @__PURE__ */ new Date()).toISOString(), s = a.filter((n) => !n.opened || !n.seen).map((n) => n.id);
240
246
  s.length !== 0 && (u.updateInAppNotifications({
241
247
  ids: s,
242
248
  opened: !0
243
- }), f((t) => {
244
- if (!t) return [];
245
- const r = [...t];
246
- return r.filter((d) => s.includes(d.id)).forEach((d) => {
247
- d.opened = o, d.seen = !0;
248
- }), r;
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;
254
+ }), c;
249
255
  }));
250
- }, j = async (o) => {
256
+ }, G = async (t) => {
251
257
  if (!a) return;
252
- const s = a.filter((t) => t.archived && (o === "ALL" || o.includes(t.id))).map((t) => t.id);
258
+ const s = a.filter((n) => n.archived && (t === "ALL" || t.includes(n.id))).map((n) => n.id);
253
259
  s.length !== 0 && (u.updateInAppNotifications({
254
260
  ids: s,
255
261
  archived: !1
256
- }), f((t) => {
257
- if (!t) return [];
258
- const r = [...t];
259
- return r.filter((d) => s.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) => {
260
266
  d.archived = void 0;
261
- }), r;
267
+ }), c;
262
268
  }));
263
- }, W = async (o) => {
269
+ }, K = async (t) => {
264
270
  if (!a) return;
265
- const s = (/* @__PURE__ */ new Date()).toISOString(), t = a.filter((r) => !r.archived && (o === "ALL" || o.includes(r.id))).map((r) => r.id);
266
- t.length !== 0 && (u.updateInAppNotifications({ ids: t, archived: !0 }), f((r) => {
267
- if (!r) return [];
268
- const d = [...r];
269
- return d.filter((p) => t.includes(p.id)).forEach((p) => {
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) => {
273
+ if (!c) return [];
274
+ const d = [...c];
275
+ return d.filter((p) => n.includes(p.id)).forEach((p) => {
270
276
  p.archived = s;
271
277
  }), d;
272
278
  }));
273
- }, H = (o, s, t, r) => U([
279
+ }, V = (t, s, n, c) => j([
274
280
  {
275
- notificationId: o,
281
+ notificationId: t,
276
282
  channel: s,
277
- delivery: t,
278
- subNotificationId: r
283
+ delivery: n,
284
+ subNotificationId: c
279
285
  }
280
- ]), U = (o) => {
281
- u.rest.postPreferences(o).then(() => {
286
+ ]), j = (t) => {
287
+ u.rest.postPreferences(t).then(() => {
282
288
  u.getPreferences().then((s) => {
283
289
  h(s);
284
290
  });
285
291
  });
286
- };
287
- M(() => {
288
- f([]), l(!1), h(void 0), D((/* @__PURE__ */ new Date()).toISOString()), P(!0), A(!0), u.openWebSocket(), u.getPreferences().then((o) => {
289
- 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
+ S(() => {
331
+ f([]), P(!1), h(void 0), C((/* @__PURE__ */ new Date()).toISOString()), U(!0), O(!0), u.openWebSocket(), u.getPreferences().then((t) => {
332
+ h(t);
290
333
  });
291
- }, [u, A]);
292
- const B = {
334
+ }, [u, O, M]), S(() => {
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]), S(() => {
341
+ x && M();
342
+ }, [x, M]);
343
+ const _ = {
293
344
  notifications: a,
294
- preferences: I,
295
- loadNotifications: A,
296
- markAsOpened: T,
297
- markAsArchived: W,
298
- markAsUnarchived: j,
299
- markAsClicked: $,
300
- updateDelivery: H,
301
- updateDeliveries: U,
302
- 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
303
358
  };
304
- return /* @__PURE__ */ F(R.Provider, { value: B, children: e.children });
305
- }, Q = () => {
306
- const e = J(R);
359
+ return /* @__PURE__ */ z(F.Provider, { value: _, children: e.children });
360
+ }, ne = () => {
361
+ const e = Y(F);
307
362
  if (!e)
308
363
  throw new Error("useMyContext must be used within a MyProvider");
309
364
  return e;
310
365
  };
311
- K.useNotificationAPIContext = Q;
366
+ te.useNotificationAPIContext = ne;
312
367
  export {
313
- R as NotificationAPIContext,
314
- K as NotificationAPIProvider
368
+ F as NotificationAPIContext,
369
+ te as NotificationAPIProvider
315
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.34",
4
+ "version": "0.0.36",
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",