@streamlayer/sdk-web-notifications 0.10.10 → 0.11.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.
@@ -1,22 +1,19 @@
1
- import { QuestionImages, ImagePosition } from '@streamlayer/sdk-web-types';
1
+ import { InstantView, QuestionType } from '@streamlayer/sdk-web-types';
2
2
  import { NotificationsQueue, NotificationsQueueOptions } from './queue';
3
3
  export type NotificationData = {
4
- color?: string;
5
- icon?: string;
6
- sponsorLogo?: string;
7
- graphicBg?: string;
8
- title?: string;
9
- header?: string;
10
- subtitle?: string;
11
- primaryColor?: string;
12
- imageMode?: QuestionImages;
13
- imagePosition?: ImagePosition;
4
+ questionType: QuestionType;
5
+ question?: {
6
+ title: string;
7
+ };
8
+ insight?: InstantView;
9
+ onboarding?: unknown;
14
10
  };
15
11
  export declare enum NotificationType {
16
12
  ONBOARDING = 1,
17
- QUESTION = 2
13
+ QUESTION = 2,
14
+ QUESTION_RESOLVED = 3
18
15
  }
19
- export type Notification<T extends Record<string, unknown> = any, M extends Record<string, Function> = never> = {
16
+ export type Notification<M extends Record<string, Function> = never> = {
20
17
  autoHideDuration: number;
21
18
  delay?: number;
22
19
  hiding?: boolean;
@@ -26,7 +23,6 @@ export type Notification<T extends Record<string, unknown> = any, M extends Reco
26
23
  methods?: M;
27
24
  data: NotificationData;
28
25
  id: string;
29
- meta?: T;
30
26
  };
31
27
  /**
32
28
  * @description app notifications (inapp)
@@ -37,6 +33,6 @@ export declare class Notifications {
37
33
  constructor(options?: Partial<NotificationsQueueOptions>);
38
34
  add: (notification: Notification) => void;
39
35
  close: (notificationId: string) => void;
40
- getQueueStore: () => import("nanostores").ReadableAtom<Notification[]>;
36
+ getQueueStore: () => import("nanostores").WritableAtom<Map<string, Notification> | undefined>;
41
37
  markAsViewed: (notificationId: string) => void;
42
38
  }
@@ -4,6 +4,7 @@ export var NotificationType;
4
4
  (function (NotificationType) {
5
5
  NotificationType[NotificationType["ONBOARDING"] = 1] = "ONBOARDING";
6
6
  NotificationType[NotificationType["QUESTION"] = 2] = "QUESTION";
7
+ NotificationType[NotificationType["QUESTION_RESOLVED"] = 3] = "QUESTION_RESOLVED";
7
8
  })(NotificationType || (NotificationType = {}));
8
9
  /**
9
10
  * @description app notifications (inapp)
@@ -13,7 +14,7 @@ export class Notifications {
13
14
  storage;
14
15
  constructor(options = {}) {
15
16
  this.storage = new NotificationStorage();
16
- this.queue = new NotificationsQueue({ concurrency: 1, animationDelay: 300, ...options });
17
+ this.queue = new NotificationsQueue({ concurrency: 1, animationDelay: 1600, ...options });
17
18
  }
18
19
  add = (notification) => {
19
20
  const isViewed = this.storage.isOpened(notification.id);
@@ -1,4 +1,4 @@
1
- import { createComputedStore } from '@streamlayer/sdk-web-interfaces';
1
+ import { SingleStore, createComputedStore } from '@streamlayer/sdk-web-interfaces';
2
2
  import { Notification } from '..';
3
3
  export type NotificationsQueueOptions = {
4
4
  concurrency: number;
@@ -6,7 +6,7 @@ export type NotificationsQueueOptions = {
6
6
  };
7
7
  export type NotificationsList = ReturnType<typeof createComputedStore<Notification[]>>;
8
8
  export declare class NotificationsQueue {
9
- notificationsList: NotificationsList;
9
+ notificationsList: ReturnType<SingleStore<Map<Notification['id'], Notification>>['getStore']>;
10
10
  private notifications;
11
11
  private store;
12
12
  private timeouts;
@@ -1,4 +1,4 @@
1
- import { SingleStore, createSingleStore, createComputedStore } from '@streamlayer/sdk-web-interfaces';
1
+ import { SingleStore, createSingleStore } from '@streamlayer/sdk-web-interfaces';
2
2
  import { createLogger } from '@streamlayer/sdk-web-logger';
3
3
  export class NotificationsQueue {
4
4
  notificationsList;
@@ -17,7 +17,7 @@ export class NotificationsQueue {
17
17
  this.waitingQueue = new Set();
18
18
  this.activeQueue = new Set();
19
19
  this.notifications = new SingleStore(createSingleStore(new Map()), 'notifications-queue');
20
- this.notificationsList = createComputedStore(this.notifications.getStore(), (notifications) => notifications ? [...notifications.values()] : []);
20
+ this.notificationsList = this.notifications.getStore();
21
21
  }
22
22
  addToQueue = (notification) => {
23
23
  if (this.store.has(notification.id)) {
@@ -75,7 +75,7 @@ export class NotificationsQueue {
75
75
  prevQueue.set(notification.id, notification);
76
76
  this.notifications.setValue(prevQueue);
77
77
  const timeout = setTimeout(() => {
78
- this.logger.debug({ notificationId: closureId }, 'notification hiding by autoHideDuration');
78
+ this.logger.debug({ notificationId: closureId, delay: notification.autoHideDuration || 5000 }, 'notification hiding by autoHideDuration');
79
79
  this.closeNotification(closureId);
80
80
  }, notification.autoHideDuration || 5000);
81
81
  this.timeouts.set(closureId, timeout);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/sdk-web-notifications",
3
- "version": "0.10.10",
3
+ "version": "0.11.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.18.11",
13
- "@streamlayer/sdk-web-types": "^0.18.1",
14
- "@streamlayer/sdk-web-logger": "^0.0.1",
15
- "@streamlayer/sdk-web-storage": "^0.0.1"
12
+ "@streamlayer/sdk-web-interfaces": "^0.18.13",
13
+ "@streamlayer/sdk-web-types": "^0.19.0",
14
+ "@streamlayer/sdk-web-logger": "^0.0.2",
15
+ "@streamlayer/sdk-web-storage": "^0.0.2"
16
16
  },
17
17
  "exports": {
18
18
  ".": {