@streamlayer/sdk-web-notifications 0.15.2 → 0.16.1
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 +1 -1
- package/lib/notifications.d.ts +5 -1
- package/lib/notifications.js +2 -2
- package/lib/queue/index.d.ts +3 -1
- package/lib/queue/index.js +3 -3
- package/package.json +8 -8
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
|
};
|
package/lib/notifications.d.ts
CHANGED
|
@@ -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?:
|
|
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;
|
package/lib/notifications.js
CHANGED
|
@@ -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
|
}
|
package/lib/queue/index.d.ts
CHANGED
|
@@ -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
|
|
20
|
+
closeNotification: (notificationId: string, { animateHiding }?: {
|
|
21
|
+
animateHiding?: boolean | undefined;
|
|
22
|
+
}) => Notification | undefined;
|
|
21
23
|
drain: () => void;
|
|
22
24
|
}
|
package/lib/queue/index.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.16.1",
|
|
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.
|
|
13
|
-
"@streamlayer/sdk-web-logger": "^0.5.
|
|
14
|
-
"@streamlayer/sdk-web-
|
|
15
|
-
"@streamlayer/sdk-web-
|
|
12
|
+
"@streamlayer/sdk-web-interfaces": "^0.22.1",
|
|
13
|
+
"@streamlayer/sdk-web-logger": "^0.5.21",
|
|
14
|
+
"@streamlayer/sdk-web-storage": "^0.4.8",
|
|
15
|
+
"@streamlayer/sdk-web-types": "^0.23.3"
|
|
16
16
|
},
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@nx/playwright": "18.
|
|
26
|
-
"@nx/webpack": "18.
|
|
25
|
+
"@nx/playwright": "18.1.2",
|
|
26
|
+
"@nx/webpack": "18.1.2",
|
|
27
27
|
"@playwright/test": "^1.42.1",
|
|
28
28
|
"tslib": "^2.6.2",
|
|
29
|
-
"webpack": "^5.
|
|
29
|
+
"webpack": "^5.91.0"
|
|
30
30
|
}
|
|
31
31
|
}
|