@24i/bigscreen-sdk 1.0.34-beta.1 → 1.0.34
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/package.json +2 -2
- package/packages/analytics/src/clients/TealiumAnalytics/TealiumAnalytics.ts +24 -15
- package/packages/analytics/src/clients/TealiumAnalytics/constants.ts +13 -12
- package/packages/analytics/src/clients/TealiumAnalytics/index.ts +1 -0
- package/packages/analytics/src/clients/TealiumAnalytics/interface.ts +2 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/__mocks__/mediaPayload.ts +40 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/helper.ts +21 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapAppError.ts +14 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerClose.ts +9 -24
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerOpen.ts +9 -24
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearch.ts +18 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchFailed.ts +2 -7
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchSuccess.ts +2 -7
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoPause.ts +9 -24
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoProgress.ts +6 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoResume.ts +9 -24
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStart.ts +9 -24
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStop.ts +9 -24
- package/packages/analytics/src/clients/TealiumAnalytics/types.ts +43 -26
- package/packages/driver-base/src/DeviceBase.ts +55 -0
- package/packages/player-ui/src/PauseButton.tsx +8 -0
- package/packages/router/src/utils.ts +1 -1
- package/.vscode/settings.json +0 -5
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapBase.ts +0 -1
- package/packages/create-package/dist/createPackage.js +0 -66
- package/packages/create-package/dist/createPackage.js.map +0 -1
- package/packages/create-package/dist/index.js +0 -5
- package/packages/create-package/dist/index.js.map +0 -1
- package/packages/create-package/dist/questionnaire/questions.js +0 -35
- package/packages/create-package/dist/questionnaire/questions.js.map +0 -1
- package/packages/create-package/dist/settings/Settings.js +0 -10
- package/packages/create-package/dist/settings/Settings.js.map +0 -1
- package/packages/create-package/dist/types.js +0 -3
- package/packages/create-package/dist/types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/bigscreen-sdk",
|
|
3
|
-
"version": "1.0.34
|
|
3
|
+
"version": "1.0.34",
|
|
4
4
|
"description": "SmartApps BIGscreen SDK monorepo",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/24i/smartapps-bigscreen-sdk#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@24i/appstage-shared-analytics": "1.0.
|
|
40
|
+
"@24i/appstage-shared-analytics": "1.0.20-alpha.70",
|
|
41
41
|
"@24i/appstage-shared-events-manager": "1.0.11",
|
|
42
42
|
"@24i/appstage-shared-perf-utils": "1.0.11",
|
|
43
43
|
"@24i/bigscreen-players-engine-base": "3.0.2",
|
|
@@ -14,9 +14,12 @@ import type { AnalyticsClient, AnyPayload } from '../../interface';
|
|
|
14
14
|
import type {
|
|
15
15
|
BaseResult,
|
|
16
16
|
Payload,
|
|
17
|
-
|
|
17
|
+
TealiumAnalyticsOptions,
|
|
18
|
+
UtagWindow,
|
|
18
19
|
} from './types';
|
|
19
20
|
|
|
21
|
+
declare const window: Window & UtagWindow;
|
|
22
|
+
|
|
20
23
|
// eslint-disable-next-line no-magic-numbers
|
|
21
24
|
const SESSION_TIMEOUT = 30 * MINUTE_IN_MS;
|
|
22
25
|
|
|
@@ -40,28 +43,26 @@ export class TealiumAnalytics implements AnalyticsClient {
|
|
|
40
43
|
|
|
41
44
|
constantPayload: BaseResult = DEFAULT_PAYLOAD;
|
|
42
45
|
|
|
43
|
-
baseURL = '';
|
|
44
|
-
|
|
45
46
|
sessionTimeout = createTimeout();
|
|
46
47
|
|
|
47
48
|
isSessionActive = false;
|
|
48
49
|
|
|
49
50
|
sessionStartSent = false;
|
|
50
51
|
|
|
51
|
-
constructor(private config:
|
|
52
|
+
constructor(private config: TealiumAnalyticsOptions, private appVersion: string = '') {
|
|
52
53
|
this.init();
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
async init() {
|
|
56
57
|
// Typically set "noview" flag to true for Single Page Apps (SPAs)
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
window.utag_cfg_ovrd = { noview: true };
|
|
59
|
+
window.utag_data = {};
|
|
59
60
|
this.loadScript();
|
|
60
61
|
this.prepareDatasetPayload();
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
prepareDatasetPayload() {
|
|
64
|
-
const { entity, language } = this.config
|
|
65
|
+
const { entity, language } = this.config;
|
|
65
66
|
this.constantPayload = {
|
|
66
67
|
language,
|
|
67
68
|
language_service: `${entity} ${language}`,
|
|
@@ -93,7 +94,7 @@ export class TealiumAnalytics implements AnalyticsClient {
|
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
loadScript() {
|
|
96
|
-
const { account, profile, environment } = this.config
|
|
97
|
+
const { account, profile, environment } = this.config;
|
|
97
98
|
const url = `//tags.tiqcdn.com/utag/${account}/${profile}/${environment}/utag.js`;
|
|
98
99
|
|
|
99
100
|
const script = document.createElement('script');
|
|
@@ -104,16 +105,22 @@ export class TealiumAnalytics implements AnalyticsClient {
|
|
|
104
105
|
console.log('Tealium was loaded.');
|
|
105
106
|
await this.startSession();
|
|
106
107
|
}, false);
|
|
107
|
-
const
|
|
108
|
-
|
|
108
|
+
const scriptElements = document.getElementsByTagName('script');
|
|
109
|
+
if (scriptElements.length > 0) {
|
|
110
|
+
const scriptElement = scriptElements[0];
|
|
111
|
+
scriptElement.parentNode!.insertBefore(script, scriptElement);
|
|
112
|
+
} else {
|
|
113
|
+
document.body.appendChild(script);
|
|
114
|
+
}
|
|
109
115
|
}
|
|
110
116
|
|
|
111
|
-
track(tealiumEvent: string,
|
|
112
|
-
if (
|
|
117
|
+
track(tealiumEvent: string, payload?: AnyPayload) {
|
|
118
|
+
if (window.utag === undefined) {
|
|
113
119
|
console.warn('Tealium is not available');
|
|
114
120
|
return;
|
|
115
121
|
}
|
|
116
|
-
|
|
122
|
+
window.utag_data = this.constantPayload;
|
|
123
|
+
window.utag!.track(tealiumEvent, payload);
|
|
117
124
|
}
|
|
118
125
|
|
|
119
126
|
view(payload?: AnyPayload) {
|
|
@@ -140,8 +147,10 @@ export class TealiumAnalytics implements AnalyticsClient {
|
|
|
140
147
|
...this.constantPayload,
|
|
141
148
|
...payload,
|
|
142
149
|
} as unknown as Payload);
|
|
143
|
-
if (eventBody) {
|
|
144
|
-
(
|
|
150
|
+
if ((eventBody as unknown as AnyPayload).track_event_type === 'view') {
|
|
151
|
+
this.view(eventBody as Payload);
|
|
152
|
+
} else {
|
|
153
|
+
this.link(eventBody as Payload);
|
|
145
154
|
}
|
|
146
155
|
} catch (e) {
|
|
147
156
|
console.warn(`[${this.name}] Error onEvent: `, e);
|
|
@@ -16,15 +16,15 @@ export const TEALIUM_TRIGGERS = [
|
|
|
16
16
|
// Scenes
|
|
17
17
|
AnalyticsTriggers.SCENE_VIEW,
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
AnalyticsTriggers.
|
|
21
|
-
AnalyticsTriggers.BUFFERING_STOP,
|
|
19
|
+
// Search
|
|
20
|
+
AnalyticsTriggers.SEARCH,
|
|
22
21
|
|
|
23
22
|
// Playback
|
|
24
23
|
AnalyticsTriggers.PLAYBACK_10,
|
|
25
24
|
AnalyticsTriggers.PLAYBACK_50,
|
|
26
25
|
AnalyticsTriggers.PLAYBACK_90,
|
|
27
26
|
AnalyticsTriggers.PLAYBACK_PAUSE,
|
|
27
|
+
AnalyticsTriggers.PLAYBACK_UNPAUSE,
|
|
28
28
|
AnalyticsTriggers.PLAYBACK_START,
|
|
29
29
|
AnalyticsTriggers.PLAYBACK_STOP,
|
|
30
30
|
|
|
@@ -32,26 +32,22 @@ export const TEALIUM_TRIGGERS = [
|
|
|
32
32
|
AnalyticsTriggers.PLAYER_CLOSE,
|
|
33
33
|
AnalyticsTriggers.PLAYER_OPEN,
|
|
34
34
|
|
|
35
|
-
// Scrolling in scene
|
|
36
|
-
AnalyticsTriggers.SCROLL_25,
|
|
37
|
-
AnalyticsTriggers.SCROLL_50,
|
|
38
|
-
AnalyticsTriggers.SCROLL_75,
|
|
39
|
-
AnalyticsTriggers.SCROLL_90,
|
|
40
|
-
|
|
41
35
|
// Favorites
|
|
42
36
|
AnalyticsTriggers.FAVORITE_ADD,
|
|
43
37
|
AnalyticsTriggers.FAVORITE_REMOVE,
|
|
44
38
|
|
|
45
39
|
AnalyticsTriggers.SELECT_CONTENT,
|
|
46
|
-
|
|
40
|
+
AnalyticsTriggers.SEARCH_SUCCESS,
|
|
41
|
+
AnalyticsTriggers.SEARCH_FAILED,
|
|
47
42
|
];
|
|
48
43
|
|
|
49
|
-
export const AppEvents = {
|
|
44
|
+
export const AppEvents: { [key: string]: string } = {
|
|
50
45
|
[AnalyticsTriggers.PLAYBACK_10]: 'media_milestone_10_video',
|
|
51
46
|
[AnalyticsTriggers.PLAYBACK_50]: 'media_milestone_50_video',
|
|
52
47
|
[AnalyticsTriggers.PLAYBACK_90]: 'media_milestone_90_video',
|
|
53
48
|
[AnalyticsTriggers.PLAYBACK_STOP]: 'video_stop',
|
|
54
49
|
[AnalyticsTriggers.PLAYBACK_PAUSE]: 'video_pause',
|
|
50
|
+
[AnalyticsTriggers.PLAYBACK_UNPAUSE]: 'video_resume',
|
|
55
51
|
[AnalyticsTriggers.PLAYBACK_START]: 'video_play',
|
|
56
52
|
[AnalyticsTriggers.PLAYER_OPEN]: 'player_x',
|
|
57
53
|
[AnalyticsTriggers.PLAYER_CLOSE]: 'player_x',
|
|
@@ -59,7 +55,9 @@ export const AppEvents = {
|
|
|
59
55
|
[AnalyticsTriggers.FAVORITE_REMOVE]: 'subscribe_to_fav',
|
|
60
56
|
[AnalyticsTriggers.APP_ERROR]: 'app_events',
|
|
61
57
|
[AnalyticsTriggers.SELECT_CONTENT]: 'app_events',
|
|
62
|
-
[AnalyticsTriggers.
|
|
58
|
+
[AnalyticsTriggers.SEARCH_SUCCESS]: 'search_success',
|
|
59
|
+
[AnalyticsTriggers.SEARCH_FAILED]: 'search_fail',
|
|
60
|
+
unpause: 'video_resume',
|
|
63
61
|
};
|
|
64
62
|
|
|
65
63
|
export enum EVENTS {
|
|
@@ -75,6 +73,7 @@ export enum EVENTS {
|
|
|
75
73
|
SEARCH_FAILED = 'search_failed',
|
|
76
74
|
FAVORITE_ADD = 'favorite_add',
|
|
77
75
|
FAVORITE_REMOVE = 'favorite_remove',
|
|
76
|
+
APP_ERROR = 'app_error',
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
export enum TrackEventType {
|
|
@@ -88,11 +87,13 @@ export const TRIGGER_NAME_TO_TEALIUM_EVENTS: { [K in AnalyticsTriggers]?: EVENTS
|
|
|
88
87
|
[AnalyticsTriggers.PLAYBACK_50]: [EVENTS.VIDEO_PROGRESS],
|
|
89
88
|
[AnalyticsTriggers.PLAYBACK_90]: [EVENTS.VIDEO_PROGRESS],
|
|
90
89
|
[AnalyticsTriggers.PLAYBACK_PAUSE]: [EVENTS.VIDEO_PAUSE],
|
|
90
|
+
[AnalyticsTriggers.PLAYBACK_UNPAUSE]: [EVENTS.VIDEO_UNPAUSE],
|
|
91
91
|
[AnalyticsTriggers.PLAYBACK_START]: [EVENTS.VIDEO_START],
|
|
92
92
|
[AnalyticsTriggers.PLAYBACK_STOP]: [EVENTS.VIDEO_STOP],
|
|
93
93
|
[AnalyticsTriggers.PLAYER_CLOSE]: [EVENTS.PLAYER_CLOSE],
|
|
94
94
|
[AnalyticsTriggers.PLAYER_OPEN]: [EVENTS.PLAYER_OPEN],
|
|
95
95
|
[AnalyticsTriggers.APP_CLOSE]: [EVENTS.VIDEO_STOP, EVENTS.PLAYER_CLOSE],
|
|
96
|
+
[AnalyticsTriggers.APP_ERROR]: [EVENTS.APP_ERROR],
|
|
96
97
|
[AnalyticsTriggers.FAVORITE_ADD]: [EVENTS.FAVORITE_ADD],
|
|
97
98
|
[AnalyticsTriggers.FAVORITE_REMOVE]: [EVENTS.FAVORITE_REMOVE],
|
|
98
99
|
[AnalyticsTriggers.SEARCH]: [EVENTS.SEARCH_SUCCESS, EVENTS.SEARCH_FAILED],
|
|
@@ -14,6 +14,7 @@ import { mapVideoResume } from './mappers/mapVideoResume';
|
|
|
14
14
|
import { mapSearchSuccess } from './mappers/mapSearchSuccess';
|
|
15
15
|
import { mapSearchFailed } from './mappers/mapSearchFailed';
|
|
16
16
|
import { EventMappingFunction } from './types';
|
|
17
|
+
import { mapAppError } from './mappers/mapAppError';
|
|
17
18
|
|
|
18
19
|
export const EVENTS_MAPPING: Record<EVENTS, EventMappingFunction> = {
|
|
19
20
|
[EVENTS.SCENE_VIEW]: mapSceneView,
|
|
@@ -28,4 +29,5 @@ export const EVENTS_MAPPING: Record<EVENTS, EventMappingFunction> = {
|
|
|
28
29
|
[EVENTS.VIDEO_UNPAUSE]: mapVideoResume,
|
|
29
30
|
[EVENTS.SEARCH_SUCCESS]: mapSearchSuccess,
|
|
30
31
|
[EVENTS.SEARCH_FAILED]: mapSearchFailed,
|
|
32
|
+
[EVENTS.APP_ERROR]: mapAppError,
|
|
31
33
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Payload } from '../../types';
|
|
2
|
+
|
|
3
|
+
export const MEDIA_PAYLOAD: Payload = {
|
|
4
|
+
duration: 120,
|
|
5
|
+
currentTime: 60,
|
|
6
|
+
title: 'Test Video',
|
|
7
|
+
url: 'https://example.com/video',
|
|
8
|
+
contentType: 'video/mp4',
|
|
9
|
+
externalId: '',
|
|
10
|
+
percent: 2,
|
|
11
|
+
provider: 'provider',
|
|
12
|
+
assetId: '12345',
|
|
13
|
+
app_id: 'app_id',
|
|
14
|
+
app_type: 'app_type',
|
|
15
|
+
sceneName: '',
|
|
16
|
+
sceneId: '',
|
|
17
|
+
sceneType: '',
|
|
18
|
+
sessionId: 1,
|
|
19
|
+
sessionNumber: 1,
|
|
20
|
+
userId: '10',
|
|
21
|
+
userProfileId: 'a1',
|
|
22
|
+
applicationId: 'app',
|
|
23
|
+
appVersion: 'v1.0',
|
|
24
|
+
deviceId: 'ott',
|
|
25
|
+
deviceType: 'smarttv',
|
|
26
|
+
searchTerm: '',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const TEALIUM_MEDIA_PAYLOAD = {
|
|
30
|
+
article_uid: '12345',
|
|
31
|
+
byline: 'N/A',
|
|
32
|
+
canonical_url: 'https://example.com/video',
|
|
33
|
+
media_type: 'video/mp4',
|
|
34
|
+
pub_date: '',
|
|
35
|
+
tags: '',
|
|
36
|
+
video_length: 120,
|
|
37
|
+
video_name: 'Test Video',
|
|
38
|
+
video_position: 60,
|
|
39
|
+
video_series_title: '',
|
|
40
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Payload, MediaResult } from '../types';
|
|
2
|
+
|
|
3
|
+
export const mapMediaPayload = (
|
|
4
|
+
payload: Payload,
|
|
5
|
+
): MediaResult => {
|
|
6
|
+
const {
|
|
7
|
+
duration, currentTime, title, url, contentType, assetId,
|
|
8
|
+
} = payload;
|
|
9
|
+
return {
|
|
10
|
+
video_name: title || '',
|
|
11
|
+
video_length: duration,
|
|
12
|
+
video_position: currentTime,
|
|
13
|
+
media_type: contentType,
|
|
14
|
+
canonical_url: url,
|
|
15
|
+
video_series_title: '',
|
|
16
|
+
byline: 'N/A',
|
|
17
|
+
pub_date: '',
|
|
18
|
+
article_uid: assetId,
|
|
19
|
+
tags: '',
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
|
+
import { CoreResult, Payload } from '../types';
|
|
3
|
+
import { AppEvents, TrackEventType } from '../constants';
|
|
4
|
+
|
|
5
|
+
export const mapAppError = (
|
|
6
|
+
triggerName: AnalyticsTriggers,
|
|
7
|
+
payload: Payload,
|
|
8
|
+
): CoreResult => ({
|
|
9
|
+
app_events: AppEvents.app_error,
|
|
10
|
+
event_trigger: triggerName,
|
|
11
|
+
track_event_type: TrackEventType.ACTIVITY,
|
|
12
|
+
video_event: AppEvents.app_error,
|
|
13
|
+
message: payload.message,
|
|
14
|
+
});
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
|
-
import { SECOND_IN_MS } from '@24i/bigscreen-sdk/utils';
|
|
3
2
|
import { Payload, VideoResult } from '../types';
|
|
4
|
-
import { AppEvents,
|
|
3
|
+
import { AppEvents, TrackEventType } from '../constants';
|
|
4
|
+
import { mapMediaPayload } from './helper';
|
|
5
5
|
|
|
6
6
|
export const mapPlayerClose = (
|
|
7
7
|
triggerName: AnalyticsTriggers,
|
|
8
8
|
payload: Payload,
|
|
9
|
-
): VideoResult => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
event_trigger: triggerName,
|
|
17
|
-
track_event_type: TrackEventType.ACTIVITY,
|
|
18
|
-
video_name: asset?.label || '',
|
|
19
|
-
video_length: assetDuration,
|
|
20
|
-
video_event: AppEvents.playback_start,
|
|
21
|
-
video_position: progressInSeconds,
|
|
22
|
-
media_type: 'vod',
|
|
23
|
-
canonical_url: '',
|
|
24
|
-
video_series_title: '',
|
|
25
|
-
byline: 'N/A',
|
|
26
|
-
pub_date: asset?.year || '',
|
|
27
|
-
article_uid: '',
|
|
28
|
-
tags: '',
|
|
29
|
-
};
|
|
30
|
-
};
|
|
9
|
+
): VideoResult => ({
|
|
10
|
+
app_events: AppEvents.player_close,
|
|
11
|
+
event_trigger: triggerName,
|
|
12
|
+
track_event_type: TrackEventType.ACTIVITY,
|
|
13
|
+
video_event: AppEvents.player_close,
|
|
14
|
+
...(mapMediaPayload(payload)),
|
|
15
|
+
});
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
|
-
import { SECOND_IN_MS } from '@24i/bigscreen-sdk/utils';
|
|
3
2
|
import { Payload, VideoResult } from '../types';
|
|
4
|
-
import { AppEvents,
|
|
3
|
+
import { AppEvents, TrackEventType } from '../constants';
|
|
4
|
+
import { mapMediaPayload } from './helper';
|
|
5
5
|
|
|
6
6
|
export const mapPlayerOpen = (
|
|
7
7
|
triggerName: AnalyticsTriggers,
|
|
8
8
|
payload: Payload,
|
|
9
|
-
): VideoResult => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
event_trigger: triggerName,
|
|
17
|
-
track_event_type: TrackEventType.ACTIVITY,
|
|
18
|
-
video_name: asset?.label || '',
|
|
19
|
-
video_length: assetDuration,
|
|
20
|
-
video_event: AppEvents.playback_start,
|
|
21
|
-
video_position: progressInSeconds,
|
|
22
|
-
media_type: 'vod',
|
|
23
|
-
canonical_url: '',
|
|
24
|
-
video_series_title: '',
|
|
25
|
-
byline: 'N/A',
|
|
26
|
-
pub_date: asset?.year || '',
|
|
27
|
-
article_uid: '',
|
|
28
|
-
tags: '',
|
|
29
|
-
};
|
|
30
|
-
};
|
|
9
|
+
): VideoResult => ({
|
|
10
|
+
app_events: AppEvents.player_open,
|
|
11
|
+
event_trigger: triggerName,
|
|
12
|
+
track_event_type: TrackEventType.ACTIVITY,
|
|
13
|
+
video_event: AppEvents.player_open,
|
|
14
|
+
...(mapMediaPayload(payload)),
|
|
15
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
|
+
import { Payload, SearchResult } from '../types';
|
|
3
|
+
import { AppEvents, TrackEventType } from '../constants';
|
|
4
|
+
|
|
5
|
+
export const mapSearch = (
|
|
6
|
+
triggerName: AnalyticsTriggers,
|
|
7
|
+
payload: Payload,
|
|
8
|
+
): SearchResult => {
|
|
9
|
+
const searchEventName = payload.searchSuccess
|
|
10
|
+
? AnalyticsTriggers.SEARCH_SUCCESS
|
|
11
|
+
: AnalyticsTriggers.SEARCH_FAILED;
|
|
12
|
+
return {
|
|
13
|
+
app_events: AppEvents[searchEventName],
|
|
14
|
+
event_trigger: searchEventName,
|
|
15
|
+
track_event_type: TrackEventType.ACTIVITY,
|
|
16
|
+
search_keyword: payload.searchTerm,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
2
|
import { Payload, SearchResult } from '../types';
|
|
3
|
-
import {
|
|
3
|
+
import { mapSearch } from './mapSearch';
|
|
4
4
|
|
|
5
5
|
export const mapSearchFailed = (
|
|
6
6
|
triggerName: AnalyticsTriggers,
|
|
7
7
|
payload: Payload,
|
|
8
|
-
): SearchResult => (
|
|
9
|
-
app_events: AppEvents.search,
|
|
10
|
-
event_trigger: triggerName,
|
|
11
|
-
track_event_type: TrackEventType.ACTIVITY,
|
|
12
|
-
search_keyword: payload.search,
|
|
13
|
-
});
|
|
8
|
+
): SearchResult => (mapSearch(triggerName, payload));
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
2
|
import { Payload, SearchResult } from '../types';
|
|
3
|
-
import {
|
|
3
|
+
import { mapSearch } from './mapSearch';
|
|
4
4
|
|
|
5
5
|
export const mapSearchSuccess = (
|
|
6
6
|
triggerName: AnalyticsTriggers,
|
|
7
7
|
payload: Payload,
|
|
8
|
-
): SearchResult => (
|
|
9
|
-
app_events: AppEvents.search,
|
|
10
|
-
event_trigger: triggerName,
|
|
11
|
-
track_event_type: TrackEventType.ACTIVITY,
|
|
12
|
-
search_keyword: payload.search,
|
|
13
|
-
});
|
|
8
|
+
): SearchResult => (mapSearch(triggerName, payload));
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
|
-
import { SECOND_IN_MS } from '@24i/bigscreen-sdk/utils';
|
|
3
2
|
import { Payload, VideoResult } from '../types';
|
|
4
|
-
import { AppEvents,
|
|
3
|
+
import { AppEvents, TrackEventType } from '../constants';
|
|
4
|
+
import { mapMediaPayload } from './helper';
|
|
5
5
|
|
|
6
6
|
export const mapVideoPause = (
|
|
7
7
|
triggerName: AnalyticsTriggers,
|
|
8
8
|
payload: Payload,
|
|
9
|
-
): VideoResult => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
event_trigger: triggerName,
|
|
17
|
-
track_event_type: TrackEventType.ACTIVITY,
|
|
18
|
-
video_name: asset?.label || '',
|
|
19
|
-
video_length: assetDuration,
|
|
20
|
-
video_event: AppEvents.playback_pause,
|
|
21
|
-
video_position: progressInSeconds,
|
|
22
|
-
media_type: 'vod',
|
|
23
|
-
canonical_url: '',
|
|
24
|
-
video_series_title: '',
|
|
25
|
-
byline: 'N/A',
|
|
26
|
-
pub_date: asset?.year || '',
|
|
27
|
-
article_uid: '',
|
|
28
|
-
tags: '',
|
|
29
|
-
};
|
|
30
|
-
};
|
|
9
|
+
): VideoResult => ({
|
|
10
|
+
app_events: AppEvents.playback_pause,
|
|
11
|
+
event_trigger: triggerName,
|
|
12
|
+
track_event_type: TrackEventType.ACTIVITY,
|
|
13
|
+
video_event: AppEvents.playback_pause,
|
|
14
|
+
...(mapMediaPayload(payload)),
|
|
15
|
+
});
|
|
@@ -1,30 +1,18 @@
|
|
|
1
1
|
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
|
-
import { SECOND_IN_MS } from '@24i/bigscreen-sdk/utils';
|
|
3
2
|
import { Payload, VideoResult } from '../types';
|
|
4
|
-
import { AppEvents,
|
|
3
|
+
import { AppEvents, TrackEventType } from '../constants';
|
|
4
|
+
import { mapMediaPayload } from './helper';
|
|
5
5
|
|
|
6
6
|
export const mapVideoProgress = (
|
|
7
7
|
triggerName: AnalyticsTriggers,
|
|
8
8
|
payload: Payload,
|
|
9
9
|
): VideoResult => {
|
|
10
|
-
const
|
|
11
|
-
const progressPercent = Number(triggerName.split('_')[1]);
|
|
12
|
-
const assetDuration = duration / SECOND_IN_MS || asset?.duration || 0;
|
|
13
|
-
const progressInSeconds = Math.round((assetDuration * progressPercent) / HUNDRED_PERCENT);
|
|
10
|
+
const appEvent = AppEvents[triggerName.toLowerCase()];
|
|
14
11
|
return {
|
|
15
|
-
app_events:
|
|
12
|
+
app_events: appEvent,
|
|
16
13
|
event_trigger: triggerName,
|
|
17
14
|
track_event_type: TrackEventType.ACTIVITY,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
video_event: AppEvents.playback_10,
|
|
21
|
-
video_position: progressInSeconds,
|
|
22
|
-
media_type: 'vod',
|
|
23
|
-
canonical_url: '',
|
|
24
|
-
video_series_title: '',
|
|
25
|
-
byline: 'N/A',
|
|
26
|
-
pub_date: asset?.year || '',
|
|
27
|
-
article_uid: '',
|
|
28
|
-
tags: '',
|
|
15
|
+
video_event: appEvent,
|
|
16
|
+
...(mapMediaPayload(payload)),
|
|
29
17
|
};
|
|
30
18
|
};
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
|
-
import { SECOND_IN_MS } from '@24i/bigscreen-sdk/utils';
|
|
3
2
|
import { Payload, VideoResult } from '../types';
|
|
4
|
-
import { AppEvents,
|
|
3
|
+
import { AppEvents, TrackEventType } from '../constants';
|
|
4
|
+
import { mapMediaPayload } from './helper';
|
|
5
5
|
|
|
6
6
|
export const mapVideoResume = (
|
|
7
7
|
triggerName: AnalyticsTriggers,
|
|
8
8
|
payload: Payload,
|
|
9
|
-
): VideoResult => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
event_trigger: triggerName,
|
|
17
|
-
track_event_type: TrackEventType.ACTIVITY,
|
|
18
|
-
video_name: asset?.label || '',
|
|
19
|
-
video_length: assetDuration,
|
|
20
|
-
video_event: AppEvents.playback_pause,
|
|
21
|
-
video_position: progressInSeconds,
|
|
22
|
-
media_type: 'vod',
|
|
23
|
-
canonical_url: '',
|
|
24
|
-
video_series_title: '',
|
|
25
|
-
byline: 'N/A',
|
|
26
|
-
pub_date: asset?.year || '',
|
|
27
|
-
article_uid: '',
|
|
28
|
-
tags: '',
|
|
29
|
-
};
|
|
30
|
-
};
|
|
9
|
+
): VideoResult => ({
|
|
10
|
+
app_events: AppEvents.unpause,
|
|
11
|
+
event_trigger: triggerName,
|
|
12
|
+
track_event_type: TrackEventType.ACTIVITY,
|
|
13
|
+
video_event: AppEvents.unpause,
|
|
14
|
+
...(mapMediaPayload(payload)),
|
|
15
|
+
});
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
|
-
import { SECOND_IN_MS } from '@24i/bigscreen-sdk/utils';
|
|
3
2
|
import { Payload, VideoResult } from '../types';
|
|
4
|
-
import { AppEvents,
|
|
3
|
+
import { AppEvents, TrackEventType } from '../constants';
|
|
4
|
+
import { mapMediaPayload } from './helper';
|
|
5
5
|
|
|
6
6
|
export const mapVideoStart = (
|
|
7
7
|
triggerName: AnalyticsTriggers,
|
|
8
8
|
payload: Payload,
|
|
9
|
-
): VideoResult => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
event_trigger: triggerName,
|
|
17
|
-
track_event_type: TrackEventType.ACTIVITY,
|
|
18
|
-
video_name: asset?.label || '',
|
|
19
|
-
video_length: assetDuration,
|
|
20
|
-
video_event: AppEvents.playback_start,
|
|
21
|
-
video_position: progressInSeconds,
|
|
22
|
-
media_type: 'vod',
|
|
23
|
-
canonical_url: '',
|
|
24
|
-
video_series_title: '',
|
|
25
|
-
byline: 'N/A',
|
|
26
|
-
pub_date: asset?.year || '',
|
|
27
|
-
article_uid: '',
|
|
28
|
-
tags: '',
|
|
29
|
-
};
|
|
30
|
-
};
|
|
9
|
+
): VideoResult => ({
|
|
10
|
+
app_events: AppEvents.playback_start,
|
|
11
|
+
event_trigger: triggerName,
|
|
12
|
+
track_event_type: TrackEventType.ACTIVITY,
|
|
13
|
+
video_event: AppEvents.playback_start,
|
|
14
|
+
...(mapMediaPayload(payload)),
|
|
15
|
+
});
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
2
|
-
import { SECOND_IN_MS } from '@24i/bigscreen-sdk/utils';
|
|
3
2
|
import { Payload, VideoResult } from '../types';
|
|
4
|
-
import { AppEvents,
|
|
3
|
+
import { AppEvents, TrackEventType } from '../constants';
|
|
4
|
+
import { mapMediaPayload } from './helper';
|
|
5
5
|
|
|
6
6
|
export const mapVideoStop = (
|
|
7
7
|
triggerName: AnalyticsTriggers,
|
|
8
8
|
payload: Payload,
|
|
9
|
-
): VideoResult => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
event_trigger: triggerName,
|
|
17
|
-
track_event_type: TrackEventType.ACTIVITY,
|
|
18
|
-
video_name: asset?.label || '',
|
|
19
|
-
video_length: assetDuration,
|
|
20
|
-
video_event: AppEvents.playback_stop,
|
|
21
|
-
video_position: progressInSeconds,
|
|
22
|
-
media_type: 'vod',
|
|
23
|
-
canonical_url: '',
|
|
24
|
-
video_series_title: '',
|
|
25
|
-
byline: 'N/A',
|
|
26
|
-
pub_date: asset?.year || '',
|
|
27
|
-
article_uid: '',
|
|
28
|
-
tags: '',
|
|
29
|
-
};
|
|
30
|
-
};
|
|
9
|
+
): VideoResult => ({
|
|
10
|
+
app_events: AppEvents.playback_stop,
|
|
11
|
+
event_trigger: triggerName,
|
|
12
|
+
track_event_type: TrackEventType.ACTIVITY,
|
|
13
|
+
video_event: AppEvents.playback_stop,
|
|
14
|
+
...(mapMediaPayload(payload)),
|
|
15
|
+
});
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import { Asset } from '@24i/smartapps-datalayer/models';
|
|
2
1
|
import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
|
|
3
2
|
import type { AnyPayload, UserInfo, AppInfo } from '../../interface';
|
|
4
3
|
|
|
4
|
+
export interface UtagWindow {
|
|
5
|
+
utag_cfg_ovrd?: {
|
|
6
|
+
noview: boolean;
|
|
7
|
+
};
|
|
8
|
+
utag_data?: {};
|
|
9
|
+
utag?: {
|
|
10
|
+
track: (eventName: string, payload?: AnyPayload) => {};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
export type TealiumAnalyticsOptions = {
|
|
6
15
|
account: string, // e.g: 'bbg'
|
|
7
16
|
profile: string, // e.g: 'main'
|
|
@@ -20,20 +29,21 @@ export type TealiumAnalyticsConfiguration = {
|
|
|
20
29
|
options: TealiumAnalyticsOptions,
|
|
21
30
|
};
|
|
22
31
|
|
|
23
|
-
interface ScreenParams {
|
|
24
|
-
screen: string;
|
|
25
|
-
screenName: string;
|
|
26
|
-
id: string;
|
|
27
|
-
asset: Asset;
|
|
28
|
-
}
|
|
29
32
|
export interface CorePayload {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
app_id: string;
|
|
34
|
+
app_type: string;
|
|
35
|
+
message?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface MediaPayload {
|
|
38
|
+
title: string;
|
|
39
|
+
externalId: string;
|
|
40
|
+
contentType: string;
|
|
41
|
+
currentTime: number;
|
|
42
|
+
duration: number;
|
|
43
|
+
percent: number;
|
|
44
|
+
assetId: string;
|
|
45
|
+
provider: string,
|
|
46
|
+
url: string;
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
export interface SessionInfo {
|
|
@@ -56,10 +66,17 @@ export interface SceneInfo {
|
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
export interface SearchInfo {
|
|
59
|
-
|
|
69
|
+
searchTerm?: string,
|
|
70
|
+
searchSuccess?: boolean,
|
|
60
71
|
}
|
|
61
72
|
|
|
62
|
-
export type Payload = CorePayload &
|
|
73
|
+
export type Payload = CorePayload &
|
|
74
|
+
SceneInfo &
|
|
75
|
+
SessionInfo &
|
|
76
|
+
MediaPayload &
|
|
77
|
+
UserInfo &
|
|
78
|
+
AppInfo &
|
|
79
|
+
SearchInfo;
|
|
63
80
|
|
|
64
81
|
export type EventBody = AnyPayload;
|
|
65
82
|
|
|
@@ -85,6 +102,8 @@ export type CoreResult = {
|
|
|
85
102
|
event_trigger: string,
|
|
86
103
|
track_event_type: string,
|
|
87
104
|
app_events?: string,
|
|
105
|
+
video_event?: string,
|
|
106
|
+
message?: string,
|
|
88
107
|
};
|
|
89
108
|
|
|
90
109
|
export type SceneViewResult = CoreResult & {
|
|
@@ -94,20 +113,21 @@ export type SceneViewResult = CoreResult & {
|
|
|
94
113
|
categories: string,
|
|
95
114
|
};
|
|
96
115
|
|
|
97
|
-
export type
|
|
116
|
+
export type MediaResult = {
|
|
98
117
|
video_name: string,
|
|
99
118
|
video_length: number,
|
|
100
|
-
video_event: string,
|
|
101
119
|
video_position: number,
|
|
102
120
|
media_type: string,
|
|
103
121
|
canonical_url: string,
|
|
104
|
-
video_series_title
|
|
105
|
-
byline
|
|
106
|
-
pub_date
|
|
107
|
-
article_uid
|
|
108
|
-
tags
|
|
122
|
+
video_series_title?: string,
|
|
123
|
+
byline?: string,
|
|
124
|
+
pub_date?: string,
|
|
125
|
+
article_uid?: string,
|
|
126
|
+
tags?: string,
|
|
109
127
|
};
|
|
110
128
|
|
|
129
|
+
export type VideoResult = CoreResult & MediaResult;
|
|
130
|
+
|
|
111
131
|
export type PlayerOpenResult = CoreResult & {
|
|
112
132
|
thing_id: string;
|
|
113
133
|
source_page: string;
|
|
@@ -117,6 +137,3 @@ export type PlayerOpenResult = CoreResult & {
|
|
|
117
137
|
export type SearchResult = CoreResult & {
|
|
118
138
|
search_keyword?: string;
|
|
119
139
|
};
|
|
120
|
-
|
|
121
|
-
export type VideoStopResult = VideoResult;
|
|
122
|
-
export type PlayerCloseResult = VideoResult;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Storage } from '@24i/bigscreen-sdk/storage';
|
|
2
|
+
import { config } from '@24i/bigscreen-sdk/runtime-config';
|
|
2
3
|
import { generateUuid } from '@24i/bigscreen-sdk/utils/generateUuid';
|
|
3
4
|
import { EventsManager, IEvents, EventMapType } from '@24i/bigscreen-sdk/events-manager';
|
|
4
5
|
import { isRtl } from '@24i/bigscreen-sdk/i18n';
|
|
@@ -16,6 +17,11 @@ import { LEFT, RIGHT, UP, DOWN, ENTER, BACK, ESC } from './KeyMap';
|
|
|
16
17
|
|
|
17
18
|
export const STORAGE_UUID_KEY = '__UUID__';
|
|
18
19
|
|
|
20
|
+
const DEFAULT_POLLING_INTERVAL = 15000;
|
|
21
|
+
const DEFAULT_POLLING_TIMEOUT = 15000;
|
|
22
|
+
|
|
23
|
+
const CHECKED_URL = '//www.google-analytics.com/__utm.gif';
|
|
24
|
+
|
|
19
25
|
export abstract class DeviceBase<
|
|
20
26
|
CustomEventMap extends EventMapType = {},
|
|
21
27
|
EventMap extends EventMapType = DeviceEventMap & CustomEventMap,
|
|
@@ -41,6 +47,14 @@ export abstract class DeviceBase<
|
|
|
41
47
|
|
|
42
48
|
screenSize: ScreenSize = 'unknown';
|
|
43
49
|
|
|
50
|
+
pollingInterval: number = DEFAULT_POLLING_INTERVAL;
|
|
51
|
+
|
|
52
|
+
pollingTimeout: number = DEFAULT_POLLING_TIMEOUT;
|
|
53
|
+
|
|
54
|
+
imageTimeout: number = 0;
|
|
55
|
+
|
|
56
|
+
isOffline: boolean = false;
|
|
57
|
+
|
|
44
58
|
// MARK: Initialization
|
|
45
59
|
|
|
46
60
|
/**
|
|
@@ -52,6 +66,7 @@ export abstract class DeviceBase<
|
|
|
52
66
|
if (!this.isInitialized) {
|
|
53
67
|
this.bindPreventDefaultEvents(rootElement);
|
|
54
68
|
const initializer = await this.internalInit();
|
|
69
|
+
this.checkNetworkConnection();
|
|
55
70
|
this.isInitialized = true;
|
|
56
71
|
return initializer;
|
|
57
72
|
}
|
|
@@ -71,6 +86,46 @@ export abstract class DeviceBase<
|
|
|
71
86
|
return this.initializer;
|
|
72
87
|
}
|
|
73
88
|
|
|
89
|
+
doOnlineCheck = () => {
|
|
90
|
+
const protocol = window.location.protocol === 'http:' ? 'http:' : 'https:';
|
|
91
|
+
const tester = new Image();
|
|
92
|
+
this.imageTimeout = window.setTimeout(() => {
|
|
93
|
+
this.connectionNotFound();
|
|
94
|
+
}, this.pollingTimeout || DEFAULT_POLLING_TIMEOUT);
|
|
95
|
+
tester.onload = this.connectionFound;
|
|
96
|
+
tester.onerror = this.connectionNotFound;
|
|
97
|
+
tester.src = `${protocol}${CHECKED_URL}?ts=${Date.now()}`;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
connectionFound = () => {
|
|
101
|
+
window.clearTimeout(this.imageTimeout);
|
|
102
|
+
if (!this.isOffline) return;
|
|
103
|
+
this.triggerEvent('networkchange',
|
|
104
|
+
{ isConnected: true } as any);
|
|
105
|
+
this.isOffline = false;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
connectionNotFound = () => {
|
|
109
|
+
window.clearTimeout(this.imageTimeout);
|
|
110
|
+
if (this.isOffline) return;
|
|
111
|
+
this.triggerEvent('networkchange',
|
|
112
|
+
{ isConnected: false } as any);
|
|
113
|
+
this.isOffline = true;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
checkNetworkConnection() {
|
|
117
|
+
const networkConfig: any = config.get('network.checkConnection');
|
|
118
|
+
this.pollingInterval = Number(networkConfig?.pollingInterval);
|
|
119
|
+
this.pollingTimeout = Number(networkConfig?.pollingTimeout);
|
|
120
|
+
const enableCheckNetwork: any = Boolean(networkConfig?.enableCheckNetwork) ?? false;
|
|
121
|
+
if (enableCheckNetwork) {
|
|
122
|
+
window.setInterval(
|
|
123
|
+
this.doOnlineCheck,
|
|
124
|
+
this.pollingInterval || DEFAULT_POLLING_INTERVAL,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
74
129
|
// MARK: Interface implemented by individual platform-specific drivers
|
|
75
130
|
|
|
76
131
|
abstract initDevice(): Promise<void>;
|
|
@@ -8,6 +8,8 @@ type Props = PlayerUICommonProps;
|
|
|
8
8
|
export class PauseButton extends Component<Props> implements IFocusable {
|
|
9
9
|
button = createRef<PlayerInteractable>();
|
|
10
10
|
|
|
11
|
+
isPaused = false;
|
|
12
|
+
|
|
11
13
|
static defaultProps = {
|
|
12
14
|
className: '',
|
|
13
15
|
};
|
|
@@ -31,10 +33,16 @@ export class PauseButton extends Component<Props> implements IFocusable {
|
|
|
31
33
|
|
|
32
34
|
onPlaying = () => {
|
|
33
35
|
this.button.current!.show();
|
|
36
|
+
if (this.isPaused) {
|
|
37
|
+
const { ui } = this.props;
|
|
38
|
+
ui.getPlayer().triggerEvent('unpause');
|
|
39
|
+
}
|
|
40
|
+
this.isPaused = false;
|
|
34
41
|
};
|
|
35
42
|
|
|
36
43
|
onPause = () => {
|
|
37
44
|
this.button.current!.hide();
|
|
45
|
+
this.isPaused = true;
|
|
38
46
|
};
|
|
39
47
|
|
|
40
48
|
focus(options?: FocusOptions) {
|
|
@@ -6,7 +6,7 @@ export const isPathVisible = (hash: string, regexpPath?: RegExp) => (
|
|
|
6
6
|
|
|
7
7
|
export const getCurrentHash = () => window.location.href.split('#')[1] || '';
|
|
8
8
|
|
|
9
|
-
const PARAM = '([a-zA-Z0-9
|
|
9
|
+
const PARAM = '([a-zA-Z0-9+-=.:%_()\\[\\]{}]+)';
|
|
10
10
|
|
|
11
11
|
export const pathToRegExp = (path: string) => {
|
|
12
12
|
const regexpParts: string[] = [];
|
package/.vscode/settings.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const mapBase = () => ({});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.main = void 0;
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const fse = require("fs-extra");
|
|
8
|
-
const chalk = require("chalk");
|
|
9
|
-
const minimist = require("minimist");
|
|
10
|
-
const questions_1 = require("./questionnaire/questions");
|
|
11
|
-
const Settings_1 = require("./settings/Settings");
|
|
12
|
-
async function isDirectoryEmpty(dirPath) {
|
|
13
|
-
const files = await fs.promises.readdir(dirPath);
|
|
14
|
-
return !files.length;
|
|
15
|
-
}
|
|
16
|
-
async function copyTemplateFiles(templateDir, targetDir) {
|
|
17
|
-
return fse.copy(templateDir, targetDir);
|
|
18
|
-
}
|
|
19
|
-
function updatePackageJsonFile(filePath, options) {
|
|
20
|
-
let data = fs.readFileSync(filePath, 'utf8');
|
|
21
|
-
const keywords = options.keywords.map((word) => `"${word}"`).join(', ');
|
|
22
|
-
data = data.replace(/("name": ")(.*)(")/, `$1${options.name}$3`);
|
|
23
|
-
data = data.replace(/("version": ")(.*)(")/, `$1${options.version}$3`);
|
|
24
|
-
data = data.replace(/("description": ")(.*)(")/, `$1${options.description}$3`);
|
|
25
|
-
data = data.replace(/("keywords": \[)(.*)(\])/, `$1${keywords}$3`);
|
|
26
|
-
data = data.replace(/("author": ")(.*)(")/, `$1${options.author}$3`);
|
|
27
|
-
fs.writeFileSync(filePath, data);
|
|
28
|
-
}
|
|
29
|
-
function parseArguments(rawArgv) {
|
|
30
|
-
const argv = minimist(rawArgv.slice(2));
|
|
31
|
-
const dirName = argv._[0];
|
|
32
|
-
if (!dirName) {
|
|
33
|
-
console.error('Error: Missing package name');
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
dirName,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
async function main() {
|
|
41
|
-
const { dirName: destDirName } = parseArguments(process.argv);
|
|
42
|
-
const destDir = path.join(process.cwd(), 'packages/', destDirName);
|
|
43
|
-
if (fs.existsSync(destDir)) {
|
|
44
|
-
console.error(`Error: Target directory "${destDir}" already exists`);
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
48
|
-
const isDirEmpty = await isDirectoryEmpty(destDir);
|
|
49
|
-
if (!isDirEmpty) {
|
|
50
|
-
console.error(`Error: Target directory "${destDir}" is not empty.`);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
const settings = Object.assign({}, Settings_1.Settings);
|
|
54
|
-
settings.name = `${Settings_1.Settings.name}${destDirName}`.toLowerCase();
|
|
55
|
-
const details = await (0, questions_1.promptPackageDetails)(settings);
|
|
56
|
-
const templateDir = path.join(__dirname, '..', 'templates/typescript');
|
|
57
|
-
await copyTemplateFiles(templateDir, destDir);
|
|
58
|
-
const packageJsonFile = path.join(destDir, 'package.json');
|
|
59
|
-
updatePackageJsonFile(packageJsonFile, details);
|
|
60
|
-
const docsSymlinkTarget = path.join('../../../packages/', destDirName, '/README.md');
|
|
61
|
-
const docsSymlinkPath = path.join(process.cwd(), 'docs/packages/', destDirName, '/README.md');
|
|
62
|
-
await fse.ensureSymlink(docsSymlinkTarget, docsSymlinkPath);
|
|
63
|
-
console.log(`${chalk.green('Success')}, package has been initialized!`);
|
|
64
|
-
}
|
|
65
|
-
exports.main = main;
|
|
66
|
-
//# sourceMappingURL=createPackage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createPackage.js","sourceRoot":"","sources":["../src/createPackage.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,mDAAuC;AAEvC,IAAA,oBAAI,GAAE,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.promptPackageDetails = void 0;
|
|
4
|
-
const inquirer = require("inquirer");
|
|
5
|
-
async function promptPackageDetails(defaultValues) {
|
|
6
|
-
return inquirer.prompt([
|
|
7
|
-
{
|
|
8
|
-
type: 'input',
|
|
9
|
-
name: 'name',
|
|
10
|
-
message: 'Package name:',
|
|
11
|
-
default: defaultValues.name,
|
|
12
|
-
}, {
|
|
13
|
-
type: 'input',
|
|
14
|
-
name: 'version',
|
|
15
|
-
message: 'Version:',
|
|
16
|
-
default: defaultValues.version,
|
|
17
|
-
}, {
|
|
18
|
-
type: 'input',
|
|
19
|
-
name: 'description',
|
|
20
|
-
message: 'Description:',
|
|
21
|
-
}, {
|
|
22
|
-
type: 'input',
|
|
23
|
-
name: 'keywords',
|
|
24
|
-
message: 'Keywords:',
|
|
25
|
-
filter: (ans) => ans.split(/[\s,]+/),
|
|
26
|
-
}, {
|
|
27
|
-
type: 'input',
|
|
28
|
-
name: 'author',
|
|
29
|
-
message: 'Author:',
|
|
30
|
-
default: defaultValues.author,
|
|
31
|
-
},
|
|
32
|
-
]);
|
|
33
|
-
}
|
|
34
|
-
exports.promptPackageDetails = promptPackageDetails;
|
|
35
|
-
//# sourceMappingURL=questions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"questions.js","sourceRoot":"","sources":["../../src/questionnaire/questions.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AAWrC,KAAK,UAAU,oBAAoB,CAAC,aAA4C;IAC5E,OAAO,QAAQ,CAAC,MAAM,CAAC;QACnB;YACI,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,eAAe;YACxB,OAAO,EAAE,aAAa,CAAC,IAAI;SAC9B,EAAE;YACC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,UAAU;YACnB,OAAO,EAAE,aAAa,CAAC,OAAO;SACjC,EAAE;YACC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,cAAc;SAC1B,EAAE;YACC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC;SACvC,EAAE;YACC,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,aAAa,CAAC,MAAM;SAChC;KACJ,CAAC,CAAC;AACP,CAAC;AAEQ,oDAAoB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Settings = void 0;
|
|
4
|
-
const Settings = {
|
|
5
|
-
name: '@24i/smartapps-bigscreen-',
|
|
6
|
-
version: '0.0.1',
|
|
7
|
-
author: '24i',
|
|
8
|
-
};
|
|
9
|
-
exports.Settings = Settings;
|
|
10
|
-
//# sourceMappingURL=Settings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.js","sourceRoot":"","sources":["../../src/settings/Settings.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAG;IACb,IAAI,EAAE,2BAA2B;IACjC,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,KAAK;CAChB,CAAC;AAEO,4BAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|