@streamlayer/sdk-web-notifications 0.15.1 → 0.16.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/lib/index.js CHANGED
@@ -8,7 +8,7 @@ export const notifications = (instance, opts, done) => {
8
8
  instance.addNotification = instance.notifications.add;
9
9
  instance.sdk.getNotificationsStore = () => instance.notifications.getQueueStore();
10
10
  instance.sdk.getActiveNotification = () => instance.notifications.getActiveNotification();
11
- instance.sdk.onMount(() => {
11
+ instance.sdk.onMount({ name: 'notifications' }, () => {
12
12
  return () => {
13
13
  instance.notifications.queue.drain();
14
14
  };
@@ -46,6 +46,10 @@ export type Notification<M extends Record<string, Function> = never> = {
46
46
  id: string;
47
47
  persistent?: boolean;
48
48
  };
49
+ export type NotificationCloseOptions = {
50
+ markAsViewed?: boolean;
51
+ animateHiding?: boolean;
52
+ };
49
53
  /**
50
54
  * @description app notifications (inapp)
51
55
  */
@@ -54,7 +58,7 @@ export declare class Notifications {
54
58
  private storage;
55
59
  constructor(options?: Partial<NotificationsQueueOptions>);
56
60
  add: (notification: Notification) => void;
57
- close: (notificationId: string, markAsViewed?: boolean) => void;
61
+ close: (notificationId: string, { markAsViewed, animateHiding }?: NotificationCloseOptions) => void;
58
62
  getActiveNotification: () => Notification | null;
59
63
  getQueueStore: () => import("nanostores").WritableAtom<Map<string, Notification> | undefined>;
60
64
  markAsViewed: (notificationId: string) => void;
@@ -38,8 +38,8 @@ export class Notifications {
38
38
  this.queue.addToQueue(notification);
39
39
  }
40
40
  };
41
- close = (notificationId, markAsViewed = true) => {
42
- this.queue.closeNotification(notificationId);
41
+ close = (notificationId, { markAsViewed = true, animateHiding } = {}) => {
42
+ this.queue.closeNotification(notificationId, { animateHiding });
43
43
  if (markAsViewed) {
44
44
  this.markAsViewed(notificationId);
45
45
  }
@@ -17,6 +17,8 @@ export declare class NotificationsQueue {
17
17
  addToQueue: (notification: Notification) => void;
18
18
  tickWaitingQueue: () => void;
19
19
  tickActiveQueue: (notificationId: string) => void;
20
- closeNotification: (notificationId: string) => Notification | undefined;
20
+ closeNotification: (notificationId: string, { animateHiding }?: {
21
+ animateHiding?: boolean | undefined;
22
+ }) => Notification | undefined;
21
23
  drain: () => void;
22
24
  }
@@ -36,7 +36,7 @@ export class NotificationsQueue {
36
36
  if (action) {
37
37
  action(...args);
38
38
  }
39
- this.closeNotification(notification.id);
39
+ this.closeNotification(notification.id, { animateHiding: false });
40
40
  },
41
41
  });
42
42
  this.waitingQueue.add(notification.id);
@@ -102,13 +102,13 @@ export class NotificationsQueue {
102
102
  this.logger.debug({ notificationId }, 'active queue tick completed');
103
103
  this.tickWaitingQueue();
104
104
  };
105
- closeNotification = (notificationId) => {
105
+ closeNotification = (notificationId, { animateHiding = true } = {}) => {
106
106
  const prevQueue = new Map(this.notificationsList.get());
107
107
  const notification = prevQueue.get(notificationId);
108
108
  if (notification) {
109
109
  // do not hide notification if we have more than one notification in waiting queue,
110
110
  // because we need to show next notification immediately
111
- notification.hiding = !(this.waitingQueue.size >= this.options.concurrency);
111
+ notification.hiding = !(this.waitingQueue.size >= this.options.concurrency) && animateHiding;
112
112
  this.notificationsList.set(prevQueue);
113
113
  const timeout = setTimeout(() => {
114
114
  const prevQueue = new Map(this.notificationsList.get());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/sdk-web-notifications",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "type": "module",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",
@@ -9,10 +9,10 @@
9
9
  "package.json"
10
10
  ],
11
11
  "peerDependencies": {
12
- "@streamlayer/sdk-web-interfaces": "^0.21.0",
13
- "@streamlayer/sdk-web-logger": "^0.5.18",
14
- "@streamlayer/sdk-web-storage": "^0.4.5",
15
- "@streamlayer/sdk-web-types": "^0.23.0"
12
+ "@streamlayer/sdk-web-interfaces": "^0.22.0",
13
+ "@streamlayer/sdk-web-logger": "^0.5.20",
14
+ "@streamlayer/sdk-web-storage": "^0.4.7",
15
+ "@streamlayer/sdk-web-types": "^0.23.2"
16
16
  },
17
17
  "exports": {
18
18
  ".": {
@@ -22,10 +22,10 @@
22
22
  }
23
23
  },
24
24
  "devDependencies": {
25
- "@nx/playwright": "17.3.0",
26
- "@nx/webpack": "17.3.0",
27
- "@playwright/test": "^1.41.1",
25
+ "@nx/playwright": "18.1.2",
26
+ "@nx/webpack": "18.1.2",
27
+ "@playwright/test": "^1.42.1",
28
28
  "tslib": "^2.6.2",
29
- "webpack": "^5.90.0"
29
+ "webpack": "^5.90.3"
30
30
  }
31
31
  }