@streamlayer/sdk-web-core 1.3.0 → 1.4.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/ui/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { StreamLayerContext } from '@streamlayer/sdk-web-interfaces';
2
+ import { QuestionType } from '@streamlayer/sdk-web-types';
2
3
  export type UIData = {
3
4
  stage: 'activate' | 'deactivate';
4
5
  id: string;
5
- isShowed?: boolean;
6
+ isViewed?: boolean;
6
7
  hasNotification?: boolean;
7
- type: 'advertisement';
8
+ type: 'advertisement' | 'insight' | 'poll' | 'trivia' | 'prediction' | 'tweet' | 'question';
8
9
  };
9
10
  export type OnContentActivateCallback = (renderData: UIData) => void;
10
11
  export interface UIContext {
@@ -17,6 +18,10 @@ declare module '@streamlayer/sdk-web-interfaces' {
17
18
  }
18
19
  interface StreamLayerSDK {
19
20
  onAdvertisementActivate: (params: Omit<UIData, 'type'>) => void;
21
+ onQuestionActivate: (params: Omit<UIData, 'type'> & {
22
+ type?: string;
23
+ questionType?: QuestionType;
24
+ }) => void;
20
25
  }
21
26
  }
22
27
  export declare const ui: (instance: StreamLayerContext, opts: {
package/lib/ui/index.js CHANGED
@@ -1,3 +1,11 @@
1
+ import { QuestionType } from '@streamlayer/sdk-web-types';
2
+ const questionTypes = {
3
+ [QuestionType.FACTOID]: 'insight',
4
+ [QuestionType.POLL]: 'poll',
5
+ [QuestionType.TRIVIA]: 'trivia',
6
+ [QuestionType.PREDICTION]: 'prediction',
7
+ [QuestionType.TWEET]: 'tweet',
8
+ };
1
9
  export const ui = (instance, opts, done) => {
2
10
  instance.ui = {
3
11
  state: new Set(),
@@ -10,5 +18,14 @@ export const ui = (instance, opts, done) => {
10
18
  instance.ui.onContentActivate({ ...params, type: 'advertisement' });
11
19
  }
12
20
  };
21
+ instance.sdk.onQuestionActivate = ({ questionType, ...params }) => {
22
+ if (instance.ui.onContentActivate) {
23
+ const type = params.type || (questionType && questionTypes[questionType]) || 'question';
24
+ // temporary skip other question types
25
+ if (type === 'insight') {
26
+ instance.ui.onContentActivate({ ...params, type });
27
+ }
28
+ }
29
+ };
13
30
  done();
14
31
  };
package/package.json CHANGED
@@ -5,13 +5,13 @@
5
5
  },
6
6
  "peerDependencies": {
7
7
  "@nanostores/query": "^0.2.10",
8
- "@streamlayer/sl-eslib": "^5.122.0",
8
+ "@streamlayer/sl-eslib": "^5.123.1",
9
9
  "nanostores": "^0.10.3",
10
- "@streamlayer/sdk-web-api": "^1.4.0",
11
- "@streamlayer/sdk-web-interfaces": "^1.1.10",
12
- "@streamlayer/sdk-web-logger": "^1.0.15",
13
- "@streamlayer/sdk-web-storage": "^1.0.15",
14
- "@streamlayer/sdk-web-types": "^1.5.0"
10
+ "@streamlayer/sdk-web-api": "^1.5.0",
11
+ "@streamlayer/sdk-web-interfaces": "^1.1.12",
12
+ "@streamlayer/sdk-web-storage": "^1.0.17",
13
+ "@streamlayer/sdk-web-logger": "^1.0.17",
14
+ "@streamlayer/sdk-web-types": "^1.6.0"
15
15
  },
16
16
  "exports": {
17
17
  ".": {
@@ -40,7 +40,7 @@
40
40
  "default": "./lib/auth/index.js"
41
41
  }
42
42
  },
43
- "version": "1.3.0",
43
+ "version": "1.4.0",
44
44
  "type": "module",
45
45
  "main": "./lib/index.js",
46
46
  "module": "./lib/index.js",