@24i/bigscreen-sdk 1.0.53 → 1.0.54-alpha.2818

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/.vscode/launch.json +25 -0
  2. package/package.json +3 -3
  3. package/packages/analytics/src/clients/GoogleAnalytics/constants.ts +10 -2
  4. package/packages/analytics/src/clients/GoogleAnalytics/interface.ts +5 -1
  5. package/packages/analytics/src/clients/TwentyFourIQ/constants.ts +15 -4
  6. package/packages/analytics/src/clients/TwentyFourIQ/interface.ts +7 -4
  7. package/packages/analytics/src/clients/TwentyFourIQ/mappers/{mapAdSkipped.ts → mapAdEvent.ts} +8 -5
  8. package/packages/analytics/src/clients/TwentyFourIQ/types.ts +21 -12
  9. package/packages/driver-androidtv/src/DeviceAndroidTV.ts +7 -0
  10. package/packages/driver-androidtv/src/__mocks__/javaScriptBridge.ts +4 -0
  11. package/packages/driver-androidtv/src/index.ts +1 -0
  12. package/packages/driver-androidtv/src/types.ts +18 -0
  13. package/packages/driver-base/src/DeviceBase.ts +3 -0
  14. package/packages/driver-base/src/__mocks__/DeviceBase.ts +7 -0
  15. package/packages/driver-base/src/index.ts +3 -0
  16. package/packages/driver-base/src/types/InAppPurchase.ts +12 -0
  17. package/packages/driver-browser/src/DeviceBrowser.ts +7 -0
  18. package/packages/driver-entone/src/DeviceEntone.ts +12 -1
  19. package/packages/driver-firetv/src/DeviceFireTV.ts +47 -1
  20. package/packages/driver-firetv/src/__mocks__/javaScriptBridge.ts +4 -0
  21. package/packages/driver-firetv/src/types.ts +1 -0
  22. package/packages/driver-hbbtv/src/DeviceHbbTV.ts +7 -0
  23. package/packages/driver-kreatv/src/DeviceKreaTV.ts +7 -0
  24. package/packages/driver-saphi/src/DeviceSaphi.ts +7 -0
  25. package/packages/driver-smartcast/src/DeviceSmartCast.ts +7 -0
  26. package/packages/driver-tizen/src/DeviceTizen.ts +7 -0
  27. package/packages/driver-vidaa/src/DeviceVidaa.ts +7 -0
  28. package/packages/driver-webos/src/DeviceWebos.ts +7 -0
  29. package/packages/driver-xbox/src/DeviceXbox.ts +12 -1
  30. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdLoaded.ts +0 -13
@@ -0,0 +1,25 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "Tizen .NET Debug (netcoredbg)",
9
+ "type": "tizen-netcoredbg",
10
+ "request": "launch",
11
+ "projectInfo": "${command:getProjectInfo}",
12
+ "port": 4711
13
+ },
14
+ {
15
+ "name": "Tizen Native Debug: Launch (gdb)",
16
+ "type": "cppdbg",
17
+ "request": "launch",
18
+ "program": "${command:tizen-get-native-exec}",
19
+ "MIMode": "gdb",
20
+ "cwd": "${workspaceRoot}",
21
+ "miDebuggerPath": "${command:tizen-get-gdb-path}",
22
+ "miDebuggerServerAddress": ":1234"
23
+ }
24
+ ]
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.53",
3
+ "version": "1.0.54-alpha.2818",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -38,11 +38,11 @@
38
38
  },
39
39
  "homepage": "https://github.com/24i/smartapps-bigscreen-sdk#readme",
40
40
  "dependencies": {
41
- "@24i/appstage-shared-analytics": "1.0.22",
41
+ "@24i/appstage-shared-analytics": "1.0.24",
42
42
  "@24i/appstage-shared-events-manager": "1.0.11",
43
43
  "@24i/appstage-shared-perf-utils": "1.0.11",
44
44
  "@24i/bigscreen-players-engine-base": "4.1.0",
45
- "@24i/smartapps-datalayer": "3.0.21",
45
+ "@24i/smartapps-datalayer": "3.0.22",
46
46
  "@sentry/browser": "7.35.0",
47
47
  "@sentry/types": "7.35.0",
48
48
  "csstype": "^3.1.3",
@@ -31,8 +31,12 @@ export const GOOGLE_ANALYTICS_TRIGGERS = [
31
31
  AnalyticsTriggers.SEARCH,
32
32
  AnalyticsTriggers.RATE_CONTENT,
33
33
  // ads triggers
34
- AnalyticsTriggers.AD_LOADED,
34
+ AnalyticsTriggers.AD_BUFFERING,
35
+ AnalyticsTriggers.AD_COMPLETE,
36
+ AnalyticsTriggers.AD_ERROR,
35
37
  AnalyticsTriggers.AD_SKIPPED,
38
+ AnalyticsTriggers.AD_START,
39
+ AnalyticsTriggers.AD_STOP,
36
40
  // user triggers
37
41
  AnalyticsTriggers.LOGIN,
38
42
  AnalyticsTriggers.LOGOUT,
@@ -87,8 +91,12 @@ export const TRIGGER_NAME_TO_GA_EVENTS: Record<
87
91
  [AnalyticsTriggers.RATE_CONTENT]: ['rate_content'],
88
92
 
89
93
  // ads triggers
90
- [AnalyticsTriggers.AD_LOADED]: ['ad_loaded'],
94
+ [AnalyticsTriggers.AD_BUFFERING]: ['ad_buffering'],
95
+ [AnalyticsTriggers.AD_COMPLETE]: ['ad_complete'],
96
+ [AnalyticsTriggers.AD_ERROR]: ['ad_error'],
91
97
  [AnalyticsTriggers.AD_SKIPPED]: ['ad_skipped'],
98
+ [AnalyticsTriggers.AD_START]: ['ad_start'],
99
+ [AnalyticsTriggers.AD_STOP]: ['ad_stop'],
92
100
 
93
101
  // user triggers
94
102
  [AnalyticsTriggers.LOGIN]: ['login'],
@@ -17,8 +17,12 @@ export type GAEventsNames = (
17
17
  | 'favorite_add' // When a user add asset to favorites
18
18
  | 'favorite_remove' // When a user remove asset froms favorites
19
19
  | 'user_engagement' // Periodically, while the app is in the foreground
20
- | 'ad_loaded' // When advertisement has been loaded
20
+ | 'ad_buffering' // When advertisement is buffering
21
+ | 'ad_complete' // When advertisement has been completed
22
+ | 'ad_error' // When advertisement has an error
21
23
  | 'ad_skipped' // When user skipped current advertisement
24
+ | 'ad_start' // When advertisement has been started
25
+ | 'ad_stop' // When advertisement has been stopped
22
26
  | 'app_exception' // When application throws an error
23
27
  | 'rate_content' // When user rates an asset
24
28
  );
@@ -54,8 +54,12 @@ export const TWENTY_FOUR_IQ_TRIGGERS = [
54
54
  AnalyticsTriggers.SCROLL_90,
55
55
 
56
56
  // Ads
57
- AnalyticsTriggers.AD_LOADED,
57
+ AnalyticsTriggers.AD_BUFFERING,
58
+ AnalyticsTriggers.AD_COMPLETE,
59
+ AnalyticsTriggers.AD_ERROR,
58
60
  AnalyticsTriggers.AD_SKIPPED,
61
+ AnalyticsTriggers.AD_START,
62
+ AnalyticsTriggers.AD_STOP,
59
63
  ];
60
64
 
61
65
  export enum EVENTS {
@@ -69,8 +73,12 @@ export enum EVENTS {
69
73
  PLAYER_CLOSE = 'player_close',
70
74
  PLAYER_OPEN = 'player_open',
71
75
  SCROLL = 'scroll',
72
- AD_LOADED = 'ad_loaded',
76
+ AD_BUFFERING = 'ad_buffering',
77
+ AD_COMPLETE = 'ad_complete',
78
+ AD_ERROR = 'ad_error',
73
79
  AD_SKIPPED = 'ad_skipped',
80
+ AD_START = 'ad_start',
81
+ AD_STOP = 'ad_stop',
74
82
  }
75
83
 
76
84
  export const TRIGGER_NAME_TO_24IQ_EVENTS: { [K in AnalyticsTriggers]?: EVENTS[]; } = {
@@ -92,9 +100,12 @@ export const TRIGGER_NAME_TO_24IQ_EVENTS: { [K in AnalyticsTriggers]?: EVENTS[];
92
100
  [AnalyticsTriggers.SCROLL_75]: [EVENTS.SCROLL],
93
101
  [AnalyticsTriggers.SCROLL_90]: [EVENTS.SCROLL],
94
102
  [AnalyticsTriggers.APP_CLOSE]: [EVENTS.VIDEO_STOP, EVENTS.PLAYER_CLOSE],
95
- // VERSION 2 ?
96
- [AnalyticsTriggers.AD_LOADED]: [EVENTS.AD_LOADED],
103
+ [AnalyticsTriggers.AD_BUFFERING]: [EVENTS.AD_BUFFERING],
104
+ [AnalyticsTriggers.AD_COMPLETE]: [EVENTS.AD_COMPLETE],
105
+ [AnalyticsTriggers.AD_ERROR]: [EVENTS.AD_ERROR],
97
106
  [AnalyticsTriggers.AD_SKIPPED]: [EVENTS.AD_SKIPPED],
107
+ [AnalyticsTriggers.AD_START]: [EVENTS.AD_START],
108
+ [AnalyticsTriggers.AD_STOP]: [EVENTS.AD_STOP],
98
109
  };
99
110
 
100
111
  export const HUNDRED_PERCENT = 100;
@@ -11,8 +11,7 @@ import { mapPlayerOpen } from './mappers/mapPlayerOpen';
11
11
  import { mapPlayerClose } from './mappers/mapPlayerClose';
12
12
  import { mapVideoStart } from './mappers/mapVideoStart';
13
13
  import { mapVideoPause } from './mappers/mapVideoPause';
14
- import { mapAdLoaded } from './mappers/mapAdLoaded';
15
- import { mapAdSkipped } from './mappers/mapAdSkipped';
14
+ import { mapAdEvent } from './mappers/mapAdEvent';
16
15
  import { EventMappingFunction } from './types';
17
16
 
18
17
  export const EVENTS_MAPPING: Record<EVENTS, EventMappingFunction> = {
@@ -26,6 +25,10 @@ export const EVENTS_MAPPING: Record<EVENTS, EventMappingFunction> = {
26
25
  [EVENTS.VIDEO_PROGRESS]: mapVideoProgress,
27
26
  [EVENTS.VIDEO_COMPLETE]: mapVideoComplete,
28
27
  [EVENTS.VIDEO_PAUSE]: mapVideoPause,
29
- [EVENTS.AD_LOADED]: mapAdLoaded,
30
- [EVENTS.AD_SKIPPED]: mapAdSkipped,
28
+ [EVENTS.AD_BUFFERING]: mapAdEvent,
29
+ [EVENTS.AD_COMPLETE]: mapAdEvent,
30
+ [EVENTS.AD_ERROR]: mapAdEvent,
31
+ [EVENTS.AD_SKIPPED]: mapAdEvent,
32
+ [EVENTS.AD_START]: mapAdEvent,
33
+ [EVENTS.AD_STOP]: mapAdEvent,
31
34
  };
@@ -1,16 +1,19 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, AdSkippedResult } from '../types';
2
+ import { Payload, AdEventResult } from '../types';
3
3
  import { mapBase } from './mapBase';
4
4
 
5
- export const mapAdSkipped = (
5
+ export const mapAdEvent = (
6
6
  triggerName: AnalyticsTriggers,
7
7
  payload: Payload,
8
- ): AdSkippedResult => ({
8
+ ): AdEventResult => ({
9
9
  ...mapBase(payload),
10
10
  action: triggerName,
11
11
  event_trigger: triggerName,
12
+ ad_id: payload.adId || '',
13
+ ad_position: payload.adType || '',
14
+ ad_playback_position: payload.adPosition || '',
15
+ ad_playback_duration: payload.adDuration || '',
12
16
  thing_id: payload.assetId || '',
13
17
  attribution_id: payload.attributionId || '',
14
- player_advertisment_name: '', // TODO: adPayload?.adName,
15
- player_advertisment_position: 0, // TODO: adPayload?.adPosition,
18
+ custom_campaign_url: '',
16
19
  });
@@ -1,6 +1,6 @@
1
1
  import { Asset } from '@24i/smartapps-datalayer/models';
2
2
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
3
- import type { AnyPayload, UserInfo, AppInfo } from '../../interface';
3
+ import type { AnyPayload, UserInfo, AppInfo, AdType } from '../../interface';
4
4
 
5
5
  interface ScreenParams {
6
6
  screen: string;
@@ -37,7 +37,20 @@ export interface SceneInfo {
37
37
  sceneType?: string,
38
38
  }
39
39
 
40
- export type Payload = CorePayload & SceneInfo & SessionInfo & UserInfo & DeviceInfo & AppInfo;
40
+ export interface AdInfo {
41
+ adId: string;
42
+ adType: AdType;
43
+ adDuration: string;
44
+ adPosition: string;
45
+ }
46
+
47
+ export type Payload = CorePayload
48
+ & SceneInfo
49
+ & SessionInfo
50
+ & UserInfo
51
+ & DeviceInfo
52
+ & AppInfo
53
+ & AdInfo;
41
54
 
42
55
  export type EventBody = AnyPayload;
43
56
 
@@ -103,16 +116,12 @@ export type VideoCompleteResult = VideoBaseResult;
103
116
 
104
117
  export type PlayerCloseResult = VideoBaseResult;
105
118
 
106
- export type AdLoadedResult = CoreResult & {
107
- thing_id: string;
108
- attribution_id: string;
109
- player_advertisment_name: string;
110
- player_advertisment_position: number;
111
- };
112
-
113
- export type AdSkippedResult = CoreResult & {
119
+ export type AdEventResult = CoreResult & {
120
+ ad_id: string;
121
+ ad_position: AdType;
122
+ ad_playback_position: string;
123
+ ad_playback_duration: string;
114
124
  thing_id: string;
115
125
  attribution_id: string;
116
- player_advertisment_name: string;
117
- player_advertisment_position: number;
126
+ custom_campaign_url: string;
118
127
  };
@@ -3,6 +3,7 @@ import {
3
3
  ConnectionType,
4
4
  ScreenSaverStatus,
5
5
  VolumeRange,
6
+ IAPSuccessPayload,
6
7
  } from '@24i/bigscreen-sdk/driver-base';
7
8
  import { IJavaScriptBridge, DeviceInfo } from './types';
8
9
  import { getFirmware } from './formatUserAgent';
@@ -245,4 +246,10 @@ export class DeviceAndroidTV extends DeviceBase {
245
246
  // not supported on AndroidTV platform
246
247
  return '';
247
248
  }
249
+
250
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
251
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
252
+ // not supported
253
+ throw new Error('Not supported');
254
+ }
248
255
  }
@@ -36,5 +36,9 @@ export const mockJavaScriptBridge: IJavaScriptBridge = {
36
36
  bridgeJavaScriptToAndroid_SetTrack: (track: string) => {},
37
37
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
38
  bridgeJavaScriptToAndroid_SetAudioTrack: (track: string) => {},
39
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
40
+ bridgeReceiptAmazonIAPValidation: (sku: string) => {},
41
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
+ bridgeReceiptAmazonIAPValidated: (receiptId: string) => {},
39
43
  },
40
44
  };
@@ -1 +1,2 @@
1
1
  export { DeviceAndroidTV } from './DeviceAndroidTV';
2
+ export type { IAPErrorEvent, IAPSuccessEvent } from './types';
@@ -87,6 +87,14 @@ interface JavaScriptBridge {
87
87
  * It sets audio track to be used.
88
88
  */
89
89
  bridgeJavaScriptToAndroid_SetAudioTrack: (track: string) => void;
90
+ /**
91
+ * It launch in app purchase.
92
+ */
93
+ bridgeReceiptAmazonIAPValidation: (sku: string) => void;
94
+ /**
95
+ * It validate purchase.
96
+ */
97
+ bridgeReceiptAmazonIAPValidated: (receiptId: string) => void;
90
98
  }
91
99
 
92
100
  export type DeviceInfo = {
@@ -131,3 +139,13 @@ export type DeviceInfo = {
131
139
  export interface IJavaScriptBridge {
132
140
  JavaScriptBridge: JavaScriptBridge,
133
141
  }
142
+
143
+ export type IAPSuccessEvent = {
144
+ userId: string;
145
+ receipt: string;
146
+ sku: string;
147
+ };
148
+
149
+ export type IAPErrorEvent = {
150
+ message: string;
151
+ };
@@ -15,6 +15,7 @@ import { inRange } from './utils';
15
15
  import { ErrorTemplate } from './errors';
16
16
  import { bindPreventDefaultEvent } from './bindPreventDefaultEvent';
17
17
  import { LEFT, RIGHT, UP, DOWN, ENTER, BACK, ESC } from './KeyMap';
18
+ import { IAPSuccessPayload } from './types/InAppPurchase';
18
19
 
19
20
  export const STORAGE_UUID_KEY = '__UUID__';
20
21
 
@@ -179,6 +180,8 @@ export abstract class DeviceBase<
179
180
 
180
181
  abstract getMacAddress(): Promise<string>;
181
182
 
183
+ abstract purchaseProduct(sku: string): Promise<IAPSuccessPayload>;
184
+
182
185
  // MARK: Private functions
183
186
 
184
187
  private bindPreventDefaultEvents(rootElement: HTMLElement) {
@@ -1,6 +1,7 @@
1
1
  import { DeviceBase as AbstractDeviceBase } from '../DeviceBase';
2
2
  import { ScreenSaverStatus } from '../types/ScreenSaverStatus';
3
3
  import { ConnectionType } from '../ConnectionType';
4
+ import { IAPSuccessPayload } from '../types/InAppPurchase';
4
5
 
5
6
  export class DeviceBase extends AbstractDeviceBase {
6
7
  volume = 0;
@@ -108,4 +109,10 @@ export class DeviceBase extends AbstractDeviceBase {
108
109
  async getMacAddress() {
109
110
  return '00:11:22:33:44:55';
110
111
  }
112
+
113
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
114
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
115
+ // not supported
116
+ throw new Error('Not supported');
117
+ }
111
118
  }
@@ -5,6 +5,9 @@ export { VolumeRange } from './VolumeRange';
5
5
  export type { ScreenSize } from './ScreenSize';
6
6
  export type { KeycodeKeyMap } from './types/KeycodeKeyMap';
7
7
  export type { DeviceEventMap } from './types/DeviceEvent';
8
+ export type {
9
+ IAPSuccessPayload, IAPErrorPayload, IAPPromiseResolve, IAPPromiseReject,
10
+ } from './types/InAppPurchase';
8
11
  export type { ScreenSaverStatus } from './types/ScreenSaverStatus';
9
12
  export type { ExitOptions } from './types/ExitOptions';
10
13
  export * as KeyMap from './KeyMap';
@@ -0,0 +1,12 @@
1
+ import { VendorType } from '@24i/smartapps-datalayer/src/api';
2
+
3
+ export type IAPSuccessPayload = {
4
+ platform: VendorType,
5
+ receiptPayload: object
6
+ };
7
+
8
+ export type IAPErrorPayload = { message: string };
9
+
10
+ export type IAPPromiseResolve = (value: IAPSuccessPayload | PromiseLike<IAPSuccessPayload>) => void;
11
+
12
+ export type IAPPromiseReject = (reason?: unknown) => void;
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  DeviceBase, ConnectionType, ScreenSaverStatus, VolumeRange,
3
+ IAPSuccessPayload,
3
4
  } from '@24i/bigscreen-sdk/driver-base';
4
5
  import { runAsync } from '@24i/bigscreen-sdk/utils/timers';
5
6
  import { generateUuid } from '@24i/bigscreen-sdk/utils';
@@ -179,4 +180,10 @@ export class DeviceBrowser extends DeviceBase {
179
180
  // for development purpose. Correctly, it should return '' for unknown MAC addr.
180
181
  return '00:00:00:00:00:00';
181
182
  }
183
+
184
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
185
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
186
+ // not supported
187
+ throw new Error('Not supported');
188
+ }
182
189
  }
@@ -1,4 +1,9 @@
1
- import { DeviceBase, ScreenSaverStatus, VolumeRange } from '@24i/bigscreen-sdk/driver-base';
1
+ import {
2
+ DeviceBase,
3
+ IAPSuccessPayload,
4
+ ScreenSaverStatus,
5
+ VolumeRange,
6
+ } from '@24i/bigscreen-sdk/driver-base';
2
7
  import { generateUuid } from '@24i/bigscreen-sdk/utils';
3
8
  import { getKeyMap } from './keymap';
4
9
  import { EntoneDeviceModelName } from './constants';
@@ -241,4 +246,10 @@ export class DeviceEntone extends DeviceBase {
241
246
  }
242
247
  return macAddress || '';
243
248
  }
249
+
250
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
251
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
252
+ // not supported
253
+ throw new Error('Not supported');
254
+ }
244
255
  }
@@ -1,4 +1,13 @@
1
- import { DeviceAndroidTV } from '@24i/bigscreen-sdk/driver-androidtv';
1
+ import {
2
+ DeviceAndroidTV,
3
+ IAPErrorEvent,
4
+ IAPSuccessEvent,
5
+ } from '@24i/bigscreen-sdk/driver-androidtv';
6
+ import {
7
+ IAPSuccessPayload, IAPPromiseReject, IAPPromiseResolve,
8
+ } from '@24i/bigscreen-sdk/driver-base';
9
+ import { VendorType } from '@24i/smartapps-datalayer/api';
10
+ import { Receipt } from './types';
2
11
 
3
12
  /**
4
13
  * Fire TV driver implementing API of Android TV Bridge.
@@ -30,4 +39,41 @@ export class DeviceFireTV extends DeviceAndroidTV {
30
39
  }
31
40
  return { adId, type, latEnabled };
32
41
  }
42
+
43
+ onIAPSuccess = (resolve: IAPPromiseResolve, reject: IAPPromiseReject) => (event: unknown) => {
44
+ this.removeIAPListeners(resolve, reject);
45
+ try {
46
+ const { userId, receipt: receiptToParse } = event as IAPSuccessEvent;
47
+ const receipt: Receipt = JSON.parse(receiptToParse);
48
+ window.JavaScriptBridge
49
+ .bridgeReceiptAmazonIAPValidated(receipt.receiptId);
50
+ resolve({
51
+ platform: VendorType.AMAZON,
52
+ receiptPayload: {
53
+ userId,
54
+ receiptId: receipt.receiptId,
55
+ },
56
+ });
57
+ } catch (e) {
58
+ reject(e);
59
+ }
60
+ };
61
+
62
+ onIAPError = (resolve: IAPPromiseResolve, reject: IAPPromiseReject) => (event: unknown) => {
63
+ this.removeIAPListeners(resolve, reject);
64
+ reject(new Error((event as IAPErrorEvent).message));
65
+ };
66
+
67
+ removeIAPListeners(resolve: IAPPromiseResolve, reject: IAPPromiseReject) {
68
+ document.removeEventListener('iapSuccess', this.onIAPSuccess(resolve, reject));
69
+ document.removeEventListener('iapError', this.onIAPError(resolve, reject));
70
+ }
71
+
72
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
73
+ return new Promise((resolve, reject) => {
74
+ document.addEventListener('iapSuccess', this.onIAPSuccess(resolve, reject));
75
+ document.addEventListener('iapError', this.onIAPError(resolve, reject));
76
+ window.JavaScriptBridge.bridgeReceiptAmazonIAPValidation(sku);
77
+ });
78
+ }
33
79
  }
@@ -36,5 +36,9 @@ export const mockJavaScriptBridge: IJavaScriptBridge = {
36
36
  bridgeJavaScriptToAndroid_SetTrack: (track: string) => {},
37
37
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
38
  bridgeJavaScriptToAndroid_SetAudioTrack: (track: string) => {},
39
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
40
+ bridgeReceiptAmazonIAPValidation: (sku: string) => {},
41
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
+ bridgeReceiptAmazonIAPValidated: (receiptId: string) => {},
39
43
  },
40
44
  };
@@ -0,0 +1 @@
1
+ export type Receipt = object & { receiptId: string };
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  DeviceBase, ConnectionType, ScreenSaverStatus, loadObject, VolumeRange,
3
+ IAPSuccessPayload,
3
4
  } from '@24i/bigscreen-sdk/driver-base';
4
5
  import { generateUuid } from '@24i/bigscreen-sdk/utils';
5
6
  import { getKeyMap } from './keymap';
@@ -322,4 +323,10 @@ export class DeviceHbbTV extends DeviceBase {
322
323
  console.warn('[HbbTV] Broadcast tune failed');
323
324
  }
324
325
  }
326
+
327
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
328
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
329
+ // not supported
330
+ throw new Error('Not supported');
331
+ }
325
332
  }
@@ -3,6 +3,7 @@ import {
3
3
  ConnectionType,
4
4
  ScreenSaverStatus,
5
5
  VolumeRange,
6
+ IAPSuccessPayload,
6
7
  } from '@24i/bigscreen-sdk/driver-base';
7
8
  import { generateUuid } from '@24i/bigscreen-sdk/utils';
8
9
  import { getKeyMap } from './keymap';
@@ -280,4 +281,10 @@ export class DeviceKreaTV extends DeviceBase {
280
281
  async getMacAddress(): Promise<string> {
281
282
  return this.toiResolver.getMacAddress();
282
283
  }
284
+
285
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
286
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
287
+ // not supported
288
+ throw new Error('Not supported');
289
+ }
283
290
  }
@@ -3,6 +3,7 @@ import {
3
3
  ConnectionType,
4
4
  ScreenSaverStatus,
5
5
  VolumeRange,
6
+ IAPSuccessPayload,
6
7
  } from '@24i/bigscreen-sdk/driver-base';
7
8
  import { generateUuid } from '@24i/bigscreen-sdk/utils';
8
9
  import { getDeviceInfo, getFirmware, getPlatformInfo } from './formatUserAgent';
@@ -153,4 +154,10 @@ export class DeviceSaphi extends DeviceBase {
153
154
  // not supported on Saphi platform
154
155
  return '';
155
156
  }
157
+
158
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
159
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
160
+ // not supported
161
+ throw new Error('Not supported');
162
+ }
156
163
  }
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  DeviceBase, ConnectionType, ScreenSaverStatus, VolumeRange,
3
+ IAPSuccessPayload,
3
4
  } from '@24i/bigscreen-sdk/driver-base';
4
5
  import { runAsync } from '@24i/bigscreen-sdk/utils/timers';
5
6
  import { ipify } from '@24i/bigscreen-sdk/ipify';
@@ -342,4 +343,10 @@ export class DeviceSmartCast extends DeviceBase {
342
343
  // not supported on SmartCast platform
343
344
  return '';
344
345
  }
346
+
347
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
348
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
349
+ // not supported
350
+ throw new Error('Not supported');
351
+ }
345
352
  }
@@ -4,6 +4,7 @@ import {
4
4
  ScreenSaverStatus,
5
5
  VolumeRange,
6
6
  ExitOptions,
7
+ IAPSuccessPayload,
7
8
  } from '@24i/bigscreen-sdk/driver-base';
8
9
  import { Storage } from '@24i/bigscreen-sdk/storage';
9
10
  import { runAsync } from '@24i/bigscreen-sdk/utils/timers';
@@ -319,4 +320,10 @@ export class DeviceTizen extends DeviceBase {
319
320
  async getMacAddress() {
320
321
  return webapis.network.getMac();
321
322
  }
323
+
324
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
325
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
326
+ // not supported
327
+ throw new Error('Not supported');
328
+ }
322
329
  }
@@ -3,6 +3,7 @@ import {
3
3
  ConnectionType,
4
4
  ScreenSaverStatus,
5
5
  VolumeRange,
6
+ IAPSuccessPayload,
6
7
  } from '@24i/bigscreen-sdk/driver-base';
7
8
  import { generateUuid } from '@24i/bigscreen-sdk/utils';
8
9
  import { NetworkConnectionTypeMap } from './constants';
@@ -150,4 +151,10 @@ export class DeviceVidaa extends DeviceBase {
150
151
  // not supported on Hisense VIDAA platform
151
152
  return '';
152
153
  }
154
+
155
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
156
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
157
+ // not supported
158
+ throw new Error('Not supported');
159
+ }
153
160
  }
@@ -4,6 +4,7 @@ import {
4
4
  ScreenSaverStatus,
5
5
  VolumeRange,
6
6
  ExitOptions,
7
+ IAPSuccessPayload,
7
8
  } from '@24i/bigscreen-sdk/driver-base';
8
9
  import { Storage } from '@24i/bigscreen-sdk/storage';
9
10
  import { initWebOSTVjs } from './webOSTVjs/webOSTVjs';
@@ -343,4 +344,10 @@ export class DeviceWebos extends DeviceBase {
343
344
  // Not supported on LG webOS platform (for date 12.4.2021, latest webOS TV 5.x)
344
345
  return '';
345
346
  }
347
+
348
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
349
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
350
+ // not supported
351
+ throw new Error('Not supported');
352
+ }
346
353
  }
@@ -1,4 +1,9 @@
1
- import { DeviceBase, ScreenSaverStatus, VolumeRange } from '@24i/bigscreen-sdk/driver-base';
1
+ import {
2
+ DeviceBase,
3
+ IAPSuccessPayload,
4
+ ScreenSaverStatus,
5
+ VolumeRange,
6
+ } from '@24i/bigscreen-sdk/driver-base';
2
7
  import { runAsync } from '@24i/bigscreen-sdk/utils/timers';
3
8
  import { generateUuid } from '@24i/bigscreen-sdk/utils/generateUuid';
4
9
  import { find } from '@24i/bigscreen-sdk/perf-utils/array';
@@ -239,4 +244,10 @@ export class DeviceXbox extends DeviceBase {
239
244
  getDeviceClass(): string {
240
245
  return 'xbox';
241
246
  }
247
+
248
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
249
+ async purchaseProduct(sku: string): Promise<IAPSuccessPayload> {
250
+ // not supported
251
+ throw new Error('Not supported');
252
+ }
242
253
  }
@@ -1,13 +0,0 @@
1
- import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, AdLoadedResult } from '../types';
3
- import { mapBase } from './mapBase';
4
-
5
- export const mapAdLoaded = (triggerName: AnalyticsTriggers, payload: Payload): AdLoadedResult => ({
6
- ...mapBase(payload),
7
- action: triggerName,
8
- event_trigger: triggerName,
9
- thing_id: payload.assetId || '',
10
- attribution_id: payload.attributionId || '',
11
- player_advertisment_name: '', // TODO: adPayload?.adName,
12
- player_advertisment_position: 0, // TODO: adPayload?.adPosition,
13
- });