@gcorevideo/player 2.28.25 → 2.28.26

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 (143) hide show
  1. package/dist/core.js +38 -32
  2. package/dist/index.css +223 -223
  3. package/dist/index.embed.js +95 -38
  4. package/dist/index.js +227 -122
  5. package/lib/Player.d.ts.map +1 -1
  6. package/lib/index.core.d.ts +1 -1
  7. package/lib/index.core.d.ts.map +1 -1
  8. package/lib/index.core.js +1 -1
  9. package/lib/index.plugins.d.ts +34 -34
  10. package/lib/index.plugins.d.ts.map +1 -1
  11. package/lib/index.plugins.js +34 -34
  12. package/lib/playback/types.d.ts.map +1 -1
  13. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  14. package/lib/plugins/bottom-gear/BottomGear.js +3 -1
  15. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -1
  16. package/lib/plugins/clappr-nerd-stats/speedtest/index.js +9 -5
  17. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -1
  18. package/lib/plugins/clappr-nerd-stats/utils.d.ts +2 -2
  19. package/lib/plugins/clips/utils.d.ts.map +1 -1
  20. package/lib/plugins/cmcd-config/CmcdConfig.js +1 -1
  21. package/lib/plugins/favicon/Favicon.d.ts.map +1 -1
  22. package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -1
  23. package/lib/plugins/google-analytics/GoogleAnalytics.js +10 -3
  24. package/lib/plugins/kibo/index.d.ts.map +1 -1
  25. package/lib/plugins/kibo/index.js +69 -20
  26. package/lib/plugins/level-selector/QualityLevels.js +2 -2
  27. package/lib/plugins/logo/Logo.d.ts.map +1 -1
  28. package/lib/plugins/logo/Logo.js +19 -15
  29. package/lib/plugins/logo/utils/index.d.ts.map +1 -1
  30. package/lib/plugins/logo/utils/index.js +11 -7
  31. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  32. package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -1
  33. package/lib/plugins/multi-camera/MultiCamera.js +42 -20
  34. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
  35. package/lib/plugins/picture-in-picture/PictureInPicture.js +3 -2
  36. package/lib/plugins/share/Share.d.ts.map +1 -1
  37. package/lib/plugins/share/Share.js +17 -12
  38. package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -1
  39. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -1
  40. package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -1
  41. package/lib/plugins/subtitles/ClosedCaptions.js +4 -3
  42. package/lib/plugins/thumbnails/Thumbnails.js +2 -3
  43. package/lib/plugins/thumbnails/utils.d.ts.map +1 -1
  44. package/lib/plugins/utils/fullscreen.d.ts.map +1 -1
  45. package/lib/plugins/utils.d.ts.map +1 -1
  46. package/lib/plugins/utils.js +1 -1
  47. package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -1
  48. package/lib/plugins/vast-ads/VastAds.js +2 -1
  49. package/lib/plugins/vast-ads/loaderxml.d.ts.map +1 -1
  50. package/lib/plugins/vast-ads/loaderxml.js +8 -5
  51. package/lib/plugins/vast-ads/roll.d.ts +2 -2
  52. package/lib/plugins/vast-ads/roll.d.ts.map +1 -1
  53. package/lib/plugins/vast-ads/roll.js +16 -10
  54. package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -1
  55. package/lib/plugins/vast-ads/rollmanager.js +17 -7
  56. package/lib/plugins/vast-ads/sctemanager.d.ts +1 -1
  57. package/lib/plugins/vast-ads/sctemanager.d.ts.map +1 -1
  58. package/lib/plugins/vast-ads/sctemanager.js +6 -5
  59. package/lib/plugins/vast-ads/types.d.ts.map +1 -1
  60. package/lib/plugins/vast-ads/urlhandler.d.ts.map +1 -1
  61. package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +1 -1
  62. package/lib/plugins/vast-ads/xmlhttprequest.js +3 -2
  63. package/lib/plugins/vast-ads/xmlmerge.d.ts.map +1 -1
  64. package/lib/plugins/vast-ads/xmlmerge.js +4 -3
  65. package/lib/types.d.ts +1 -1
  66. package/lib/types.d.ts.map +1 -1
  67. package/lib/utils/clickaway.d.ts.map +1 -1
  68. package/lib/utils/mediaSources.d.ts.map +1 -1
  69. package/lib/utils/mediaSources.js +1 -3
  70. package/lib/utils/types.d.ts.map +1 -1
  71. package/lib/version.js +2 -2
  72. package/package.json +2 -2
  73. package/src/Player.ts +10 -10
  74. package/src/__tests__/Player.test.ts +33 -10
  75. package/src/index.core.ts +9 -1
  76. package/src/index.plugins.ts +35 -35
  77. package/src/playback/BasePlayback.ts +1 -1
  78. package/src/playback/__tests__/HTML5Video.test.ts +10 -4
  79. package/src/playback/dash-playback/__tests__/DashPlayback.test.ts +10 -38
  80. package/src/playback/hls-playback/__tests__/HlsPlayback.test.ts +12 -45
  81. package/src/playback/types.ts +0 -1
  82. package/src/playback.types.ts +1 -2
  83. package/src/plugins/audio-selector/AudioTracks.ts +1 -1
  84. package/src/plugins/audio-selector/__tests__/AudioTracks.test.ts +30 -11
  85. package/src/plugins/bottom-gear/BottomGear.ts +3 -2
  86. package/src/plugins/clappr-nerd-stats/NerdStats.ts +1 -1
  87. package/src/plugins/clappr-nerd-stats/speedtest/index.ts +104 -82
  88. package/src/plugins/clappr-nerd-stats/speedtest/types.ts +3 -3
  89. package/src/plugins/clappr-nerd-stats/utils.ts +2 -2
  90. package/src/plugins/clappr-stats/__tests__/ClapprStats.test.ts +30 -18
  91. package/src/plugins/clips/utils.ts +5 -1
  92. package/src/plugins/cmcd-config/CmcdConfig.ts +1 -1
  93. package/src/plugins/error-screen/__tests__/ErrorScreen.test.ts +21 -15
  94. package/src/plugins/favicon/Favicon.ts +73 -49
  95. package/src/plugins/google-analytics/GoogleAnalytics.ts +93 -58
  96. package/src/plugins/kibo/index.ts +183 -109
  97. package/src/plugins/level-selector/QualityLevels.ts +2 -2
  98. package/src/plugins/logo/Logo.ts +134 -105
  99. package/src/plugins/logo/utils/index.ts +27 -20
  100. package/src/plugins/media-control/MediaControl.ts +12 -6
  101. package/src/plugins/multi-camera/MultiCamera.ts +218 -157
  102. package/src/plugins/picture-in-picture/PictureInPicture.ts +41 -37
  103. package/src/plugins/playback-rate/__tests__/PlaybackRate.test.ts +25 -11
  104. package/src/plugins/poster/__tests__/Poster.test.ts +8 -9
  105. package/src/plugins/share/Share.ts +85 -60
  106. package/src/plugins/skip-time/SkipTime.ts +5 -1
  107. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +8 -5
  108. package/src/plugins/subtitles/ClosedCaptions.ts +7 -5
  109. package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +0 -1
  110. package/src/plugins/thumbnails/Thumbnails.ts +22 -21
  111. package/src/plugins/thumbnails/__tests__/Thumbnails.test.ts +14 -7
  112. package/src/plugins/thumbnails/utils.ts +3 -1
  113. package/src/plugins/typings/globals.d.ts +7 -7
  114. package/src/plugins/typings/workers.d.ts +3 -3
  115. package/src/plugins/utils/fullscreen.ts +2 -2
  116. package/src/plugins/utils.ts +17 -13
  117. package/src/plugins/vast-ads/VastAds.ts +4 -5
  118. package/src/plugins/vast-ads/loaderxml.ts +142 -101
  119. package/src/plugins/vast-ads/roll.ts +381 -284
  120. package/src/plugins/vast-ads/rollmanager.ts +214 -170
  121. package/src/plugins/vast-ads/sctemanager.ts +66 -48
  122. package/src/plugins/vast-ads/types.ts +15 -9
  123. package/src/plugins/vast-ads/urlhandler.ts +18 -13
  124. package/src/plugins/vast-ads/xmlhttprequest.ts +25 -20
  125. package/src/plugins/vast-ads/xmlmerge.ts +42 -32
  126. package/src/plugins/video360/VRControls.js +50 -42
  127. package/src/plugins/video360/VREffect.js +298 -206
  128. package/src/plugins/video360/Video360.js +553 -423
  129. package/src/plugins/video360/orbit-oriention-controls.js +526 -421
  130. package/src/plugins/video360/utils.js +18 -18
  131. package/src/types.ts +5 -3
  132. package/src/typings/@clappr/core/error_mixin.d.ts +9 -9
  133. package/src/typings/@clappr/core/index.d.ts +1 -3
  134. package/src/typings/@clappr/core/playback.d.ts +3 -3
  135. package/src/typings/@clappr/index.d.ts +1 -1
  136. package/src/typings/globals.d.ts +15 -15
  137. package/src/utils/__tests__/mediaSources.test.ts +42 -26
  138. package/src/utils/clickaway.ts +24 -24
  139. package/src/utils/errors.ts +2 -2
  140. package/src/utils/mediaSources.ts +5 -4
  141. package/src/utils/types.ts +1 -1
  142. package/src/version.ts +2 -2
  143. package/tsconfig.tsbuildinfo +1 -1
@@ -2,7 +2,6 @@ import { describe, it, expect, beforeEach, vi } from 'vitest'
2
2
 
3
3
  import { Events } from '@clappr/core'
4
4
 
5
-
6
5
  import { createMockCore, createMockMediaControl } from '../../../testUtils'
7
6
 
8
7
  import { Thumbnails } from '../Thumbnails'
@@ -108,13 +107,13 @@ describe('Thumbnails', () => {
108
107
  case 'media_control':
109
108
  return mediaControl
110
109
  }
111
- });
110
+ })
112
111
  thumbnails = new Thumbnails(core)
113
112
  })
114
113
  describe('loading', () => {
115
114
  beforeEach(async () => {
116
115
  core.emit(Events.CORE_READY)
117
- await new Promise(resolve => setTimeout(resolve, 1))
116
+ await new Promise((resolve) => setTimeout(resolve, 1))
118
117
  })
119
118
  it('should render', () => {
120
119
  expect(thumbnails.$el.html()).toMatchSnapshot()
@@ -123,10 +122,14 @@ describe('Thumbnails', () => {
123
122
  expect(core.$el.find('.scrub-thumbnails')).toHaveLength(1)
124
123
  })
125
124
  it('should load image dimensions', () => {
126
- expect(loadImageDimensions).toHaveBeenCalledWith('https://example.com/sprite.png')
125
+ expect(loadImageDimensions).toHaveBeenCalledWith(
126
+ 'https://example.com/sprite.png',
127
+ )
127
128
  })
128
129
  it('should parse sprite sheet and create thumbnails', () => {
129
- const thumbs = thumbnails.$el.find('#thumbnails-carousel .thumbnail-container')
130
+ const thumbs = thumbnails.$el.find(
131
+ '#thumbnails-carousel .thumbnail-container',
132
+ )
130
133
  expect(thumbs).toHaveLength(2)
131
134
  })
132
135
  it('should hide', () => {
@@ -137,7 +140,7 @@ describe('Thumbnails', () => {
137
140
  describe('when mouse pointer is over the scrubber', () => {
138
141
  beforeEach(async () => {
139
142
  core.emit(Events.CORE_READY)
140
- await new Promise(resolve => setTimeout(resolve, 1))
143
+ await new Promise((resolve) => setTimeout(resolve, 1))
141
144
  mediaControl.container.getDuration.mockReturnValue(5)
142
145
  vi.spyOn(thumbnails.$el, 'width').mockReturnValue(300)
143
146
  mediaControl.trigger(Events.MEDIACONTROL_MOUSEMOVE_SEEKBAR, {}, 0.5)
@@ -146,7 +149,11 @@ describe('Thumbnails', () => {
146
149
  expect(thumbnails.$el.hasClass('hidden')).toBe(false)
147
150
  })
148
151
  it('should show the matching spotlight thumbnail', () => {
149
- expect(thumbnails.$el.find('#thumbnails-spotlight .thumbnail-container').css('background-position')).toBe('-100px 0px')
152
+ expect(
153
+ thumbnails.$el
154
+ .find('#thumbnails-spotlight .thumbnail-container')
155
+ .css('background-position'),
156
+ ).toBe('-100px 0px')
150
157
  })
151
158
  })
152
159
  })
@@ -1,4 +1,6 @@
1
- export function loadImageDimensions(url: string): Promise<{ width: number, height: number }> {
1
+ export function loadImageDimensions(
2
+ url: string,
3
+ ): Promise<{ width: number; height: number }> {
2
4
  return new Promise((resolve, reject) => {
3
5
  const img = new Image()
4
6
  img.src = url
@@ -1,10 +1,10 @@
1
1
  declare interface HTMLVideoElement {
2
- webkitDisplayingFullscreen?: boolean;
2
+ webkitDisplayingFullscreen?: boolean
3
3
  }
4
4
 
5
- declare module "*.css";
6
- declare module "*.ejs";
7
- declare module "*.ejs?raw";
8
- declare module "*.html";
9
- declare module "*.scss";
10
- declare module "*.svg";
5
+ declare module '*.css'
6
+ declare module '*.ejs'
7
+ declare module '*.ejs?raw'
8
+ declare module '*.html'
9
+ declare module '*.scss'
10
+ declare module '*.svg'
@@ -1,3 +1,3 @@
1
- declare module "*.worker.js" {
2
- export default string;
3
- }
1
+ declare module '*.worker.js' {
2
+ export default string
3
+ }
@@ -1,5 +1,5 @@
1
- import { Browser, Utils } from '@clappr/core';
2
- import { reportError } from '@gcorevideo/utils';
1
+ import { Browser, Utils } from '@clappr/core'
2
+ import { reportError } from '@gcorevideo/utils'
3
3
 
4
4
  export const fullscreenEnabled = Utils.Fullscreen.fullscreenEnabled
5
5
 
@@ -1,9 +1,9 @@
1
1
  export function getLocation(href: string) {
2
- const l = document.createElement('a');
2
+ const l = document.createElement('a')
3
3
 
4
- l.href = href;
4
+ l.href = href
5
5
 
6
- return l;
6
+ return l
7
7
  }
8
8
 
9
9
  /**
@@ -16,33 +16,37 @@ export function getLocation(href: string) {
16
16
  */
17
17
  export function parseClipTime(str: string): number {
18
18
  if (!str) {
19
- return 0;
19
+ return 0
20
20
  }
21
- const arr = str.split(/:/);
22
- let h = 0, m = 0, s = 0;
21
+ const arr = str.split(/:/)
22
+ let h = 0,
23
+ m = 0,
24
+ s = 0
23
25
 
24
26
  if (arr.length >= 3) {
25
- h = parseInt(arr[arr.length - 3]) * 60 * 60;
27
+ h = parseInt(arr[arr.length - 3]) * 60 * 60
26
28
  }
27
29
  if (arr.length >= 2) {
28
- m = parseInt(arr[arr.length - 2]) * 60;
30
+ m = parseInt(arr[arr.length - 2]) * 60
29
31
  }
30
32
 
31
33
  if (arr.length >= 1) {
32
- s = parseInt(arr[arr.length - 1]);
34
+ s = parseInt(arr[arr.length - 1])
33
35
  }
34
36
 
35
- return (h + m + s);
37
+ return h + m + s
36
38
  }
37
39
 
38
40
  export function getPageX(event: MouseEvent | TouchEvent): number {
39
41
  if ((event as MouseEvent).pageX) {
40
- return (event as MouseEvent).pageX;
42
+ return (event as MouseEvent).pageX
41
43
  }
42
44
 
43
45
  if ((event as TouchEvent).changedTouches) {
44
- return (event as TouchEvent).changedTouches[(event as TouchEvent).changedTouches.length - 1].pageX;
46
+ return (event as TouchEvent).changedTouches[
47
+ (event as TouchEvent).changedTouches.length - 1
48
+ ].pageX
45
49
  }
46
50
 
47
- return 0;
51
+ return 0
48
52
  }
@@ -223,7 +223,7 @@ export class VastAds extends UICorePlugin {
223
223
  )
224
224
  } else {
225
225
  this.countRepeatableRoll = this.findCloserAdvertisement(
226
- this.options.vastAds.repeatableroll,
226
+ this.options.vastAds.repeatableroll,
227
227
  'startTime',
228
228
  this.countRepeatableRoll,
229
229
  e,
@@ -626,9 +626,7 @@ export class VastAds extends UICorePlugin {
626
626
  this._posterPlugin = this._container?.getPlugin('poster')
627
627
 
628
628
  // Attempt to get click-to-pause plugin. (May interfere with advert click handling)
629
- this._clickToPausePlugin = this._container?.getPlugin(
630
- 'click_to_pause',
631
- )
629
+ this._clickToPausePlugin = this._container?.getPlugin('click_to_pause')
632
630
 
633
631
  assert(this.playback, 'playback is not defined')
634
632
  this._contentElement = this.playback.el
@@ -790,7 +788,8 @@ export class VastAds extends UICorePlugin {
790
788
 
791
789
  this.currentState = ''
792
790
  this.$el.hide()
793
- if (!this.options.disableClickOnPause) { // TODO sort out
791
+ if (!this.options.disableClickOnPause) {
792
+ // TODO sort out
794
793
  this._clickToPausePlugin?.enable()
795
794
  }
796
795
 
@@ -1,260 +1,301 @@
1
- import { reportError } from '@gcorevideo/utils';
2
- import assert from 'assert';
3
- import URLHandler from './urlhandler.js';
4
- import MergeVast from './xmlmerge.js';
5
- import { parseClipTime } from '../utils.js';
1
+ import { reportError } from '@gcorevideo/utils'
2
+ import assert from 'assert'
3
+ import URLHandler from './urlhandler.js'
4
+ import MergeVast from './xmlmerge.js'
5
+ import { parseClipTime } from '../utils.js'
6
6
 
7
7
  export default class LoaderXML {
8
- private config: string = '';
8
+ private config: string = ''
9
9
 
10
10
  constructor(private url: string) {}
11
11
 
12
12
  async startLoad() {
13
13
  return new Promise<{ url: string }>((resolve, reject) => {
14
14
  if (this._isGoogle(this.url)) {
15
- resolve({ url: this.url });
15
+ resolve({ url: this.url })
16
16
  } else {
17
17
  this.parse(this.url, null, {}, (response: any, err: any) => {
18
18
  if (err) {
19
- reject(err);
19
+ reject(err)
20
20
  } else {
21
- resolve(response);
21
+ resolve(response)
22
22
  }
23
- });
23
+ })
24
24
  }
25
- });
25
+ })
26
26
  }
27
27
 
28
- parse(url: string, parentURLs: string | string[] | null, options: any, cb?: (response: any | null, err: any) => void) {
28
+ parse(
29
+ url: string,
30
+ parentURLs: string | string[] | null,
31
+ options: any,
32
+ cb?: (response: any | null, err: any) => void,
33
+ ) {
29
34
  // Options param can be skipped
30
35
  if (!cb) {
31
36
  if (typeof options === 'function') {
32
- cb = options;
37
+ cb = options
33
38
  }
34
- options = {};
39
+ options = {}
35
40
  }
36
41
 
37
- options.withCredentials = !this._isGoogle(url);
38
- options.timeout = 2000;
42
+ options.withCredentials = !this._isGoogle(url)
43
+ options.timeout = 2000
39
44
 
40
45
  assert(cb)
41
46
 
42
47
  URLHandler.get(url, options, (err: any, xml: any) => {
43
48
  if (err) {
44
- return cb(null, err);
49
+ return cb(null, err)
45
50
  }
46
51
 
47
- return this.parseXmlDocument(url, parentURLs, options, xml, cb);
48
- });
52
+ return this.parseXmlDocument(url, parentURLs, options, xml, cb)
53
+ })
49
54
  }
50
55
 
51
56
  _isGoogle(url: string) {
52
- return url.indexOf('g.doubleclick.net') > -1 ||
57
+ return (
58
+ url.indexOf('g.doubleclick.net') > -1 ||
53
59
  url.indexOf('ima3vpaid.appspot') > -1 ||
54
- url.indexOf('an.facebook.com') > -1;
60
+ url.indexOf('an.facebook.com') > -1
61
+ )
55
62
  }
56
63
 
57
- parseXmlDocument(url: string, parentURLs: string | string[] | null, options: any, xml: any, cb: (response: any, err?: any) => void) {
64
+ parseXmlDocument(
65
+ url: string,
66
+ parentURLs: string | string[] | null,
67
+ options: any,
68
+ xml: any,
69
+ cb: (response: any, err?: any) => void,
70
+ ) {
58
71
  if (xml.indexOf('Wrapper')) {
59
- xml = xml.replace(/Wrapper/g, 'InLine');
72
+ xml = xml.replace(/Wrapper/g, 'InLine')
60
73
  }
61
74
 
62
- this.extendXML(xml);
63
- const vastAdTagUri = this.getWrapperUrl();
75
+ this.extendXML(xml)
76
+ const vastAdTagUri = this.getWrapperUrl()
64
77
 
65
78
  if (vastAdTagUri) {
66
- this.parse(vastAdTagUri, url, options, cb);
79
+ this.parse(vastAdTagUri, url, options, cb)
67
80
  } else {
68
- const ext = this.getExtension();
69
- const skipTime = this.timeSkipOffset();
70
- const clickUrls = this.clickUrls();
71
- const url = { config: this.config };
81
+ const ext = this.getExtension()
82
+ const skipTime = this.timeSkipOffset()
83
+ const clickUrls = this.clickUrls()
84
+ const url = { config: this.config }
72
85
 
73
86
  if (this.config.indexOf('<MediaFile') > -1) {
74
- cb(Object.assign(url, ext, skipTime, clickUrls));
87
+ cb(Object.assign(url, ext, skipTime, clickUrls))
75
88
  } else {
76
- cb(null, { error: 'nobanner' });
89
+ cb(null, { error: 'nobanner' })
77
90
  }
78
91
  }
79
92
  }
80
93
 
81
94
  clickUrls() {
82
- const clickTrackings = this.getUrls('ClickTracking') || [];
83
- const clickThrough = this.getUrls('ClickThrough').length > 0 ? this.getUrls('ClickThrough')[0] : '';
95
+ const clickTrackings = this.getUrls('ClickTracking') || []
96
+ const clickThrough =
97
+ this.getUrls('ClickThrough').length > 0
98
+ ? this.getUrls('ClickThrough')[0]
99
+ : ''
84
100
 
85
- this.removeTag('ClickThrough');
101
+ this.removeTag('ClickThrough')
86
102
 
87
- return { clickTrackings, clickThrough };
103
+ return { clickTrackings, clickThrough }
88
104
  }
89
105
 
90
106
  timeSkipOffset() {
91
- const skipEvents = this.getUrls('Tracking', 'event="skip"');
92
- const progressEvents = this.getUrls('Tracking', 'event="progress"');
93
- const linearSkipOffset = this.config.match(/skipoffset="(\d+:\d+:\d+){1}"/);
94
- let timeOffset = -1;
107
+ const skipEvents = this.getUrls('Tracking', 'event="skip"')
108
+ const progressEvents = this.getUrls('Tracking', 'event="progress"')
109
+ const linearSkipOffset = this.config.match(/skipoffset="(\d+:\d+:\d+){1}"/)
110
+ let timeOffset = -1
95
111
 
96
112
  if (skipEvents.length > 0) {
97
- timeOffset = 5;
98
- this.removeTag('Tracking', 'event="skip"');
113
+ timeOffset = 5
114
+ this.removeTag('Tracking', 'event="skip"')
99
115
  }
100
116
 
101
117
  if (progressEvents.length > 0) {
102
- timeOffset = 5;
103
- this.removeTag('Tracking', 'event="progress"');
118
+ timeOffset = 5
119
+ this.removeTag('Tracking', 'event="progress"')
104
120
  }
105
121
 
106
122
  if (linearSkipOffset && linearSkipOffset.length > 1) {
107
- timeOffset = parseClipTime(linearSkipOffset[1]);
108
- this.config = this.config.replace(/<Linear skipoffset="(\d+:\d+:\d+)".*?>/g, '<Linear>');
123
+ timeOffset = parseClipTime(linearSkipOffset[1])
124
+ this.config = this.config.replace(
125
+ /<Linear skipoffset="(\d+:\d+:\d+)".*?>/g,
126
+ '<Linear>',
127
+ )
109
128
  }
110
129
 
111
- return { skipEvents, progressEvents, timeOffset };
130
+ return { skipEvents, progressEvents, timeOffset }
112
131
  }
113
132
 
114
133
  getExtension() {
115
- const extensions = this.getTag('Extensions');
134
+ const extensions = this.getTag('Extensions')
116
135
 
117
136
  if (!extensions) {
118
- return {};
137
+ return {}
119
138
  }
120
- const xml = this.parseXML(extensions[0]);
121
- assert(xml, 'xml is null');
122
- const items = xml.getElementsByTagName('Extension');
123
- const extObj: { controls?: string; isClickable?: string; } & Record<string, string> = {};
139
+ const xml = this.parseXML(extensions[0])
140
+ assert(xml, 'xml is null')
141
+ const items = xml.getElementsByTagName('Extension')
142
+ const extObj: { controls?: string; isClickable?: string } & Record<
143
+ string,
144
+ string
145
+ > = {}
124
146
 
125
- extObj.controls === '1';
147
+ extObj.controls === '1'
126
148
 
127
149
  for (let i = 0; i < items.length; i++) {
128
150
  try {
129
- const eventName = items[i].getAttribute('type');
130
- let trackingURLTemplate = '';
151
+ const eventName = items[i].getAttribute('type')
152
+ let trackingURLTemplate = ''
131
153
 
132
154
  if (items[i].children && items[i].children.length > 0) {
133
- trackingURLTemplate = String(items[i]); // TODO or textContent
155
+ trackingURLTemplate = String(items[i]) // TODO or textContent
134
156
  } else {
135
- trackingURLTemplate = this.getExtensionNode(items[i]);
157
+ trackingURLTemplate = this.getExtensionNode(items[i])
136
158
  }
137
159
  if (eventName && trackingURLTemplate) {
138
160
  try {
139
- extObj[eventName] = trackingURLTemplate;
161
+ extObj[eventName] = trackingURLTemplate
140
162
  } catch (error) {
141
163
  // LogManager.exception(error);
142
- reportError(error);
164
+ reportError(error)
143
165
  }
144
166
  }
145
167
  } catch (error) {
146
168
  // LogManager.exception(error);
147
- reportError(error);
148
- continue;
169
+ reportError(error)
170
+ continue
149
171
  }
150
172
  }
151
173
  if (!extObj.isClickable) {
152
- extObj.isClickable = '1';
174
+ extObj.isClickable = '1'
153
175
  }
154
176
  //может оно и не надо
155
177
  if (extObj.isClickable === '0') {
156
- this.removeTag('VideoClicks');
178
+ this.removeTag('VideoClicks')
157
179
  }
158
180
  if (extObj.skipTime2) {
159
181
  if (extObj.skipTime2.split(':').length === 2) {
160
- extObj.skipTime2 = '00:' + extObj.skipTime2;
182
+ extObj.skipTime2 = '00:' + extObj.skipTime2
161
183
  }
162
184
  if (this.config.indexOf('Linear') > -1) {
163
- this.config = this.config.replace(/<Linear.*?>/g, '<Linear skipoffset="' + extObj.skipTime2 + '">');
185
+ this.config = this.config.replace(
186
+ /<Linear.*?>/g,
187
+ '<Linear skipoffset="' + extObj.skipTime2 + '">',
188
+ )
164
189
  }
165
190
  }
166
191
 
167
- return extObj;
192
+ return extObj
168
193
  }
169
194
 
170
195
  getExtensionNode(node: Element): string {
171
196
  if (!node) {
172
- return '';
197
+ return ''
173
198
  }
174
- const result = (node.textContent || (node as any).text || '').trim();
199
+ const result = (node.textContent || (node as any).text || '').trim()
175
200
 
176
- return result;
201
+ return result
177
202
  }
178
203
 
179
204
  getWrapperUrl() {
180
- const vastAdTagUri = this.getUrls('VASTAdTagURI')[0];
205
+ const vastAdTagUri = this.getUrls('VASTAdTagURI')[0]
181
206
 
182
- this.removeTag('VASTAdTagURI');
207
+ this.removeTag('VASTAdTagURI')
183
208
 
184
- return vastAdTagUri;
209
+ return vastAdTagUri
185
210
  }
186
211
 
187
212
  getTag(name: string, attr?: string): string[] | null {
188
- let tag = '<' + name + '.*?>';
213
+ let tag = '<' + name + '.*?>'
189
214
 
190
215
  if (attr) {
191
- tag = '<' + name + ' ' + attr + '.*?>';
216
+ tag = '<' + name + ' ' + attr + '.*?>'
192
217
  }
193
- const matchString = new RegExp(tag + '(.|\n|\r)*?' + '<\\/' + name + '>', 'g');
218
+ const matchString = new RegExp(
219
+ tag + '(.|\n|\r)*?' + '<\\/' + name + '>',
220
+ 'g',
221
+ )
194
222
 
195
- return this.config.match(matchString);
223
+ return this.config.match(matchString)
196
224
  }
197
225
 
198
226
  getUrls(tag: string, attr?: string): string[] {
199
- const matched = this.getTag(tag, attr);
200
- const res: string[] = [];
227
+ const matched = this.getTag(tag, attr)
228
+ const res: string[] = []
201
229
 
202
230
  if (matched) {
203
231
  for (let i = 0; i < matched.length; i++) {
204
232
  if (matched[i].indexOf('<![CDATA[') > -1) {
205
- const lengthCDATA = 9;
206
-
207
- res.push(matched[i].substring(matched[i].indexOf('<![CDATA[') + lengthCDATA, matched[i].indexOf(']]>')));
233
+ const lengthCDATA = 9
234
+
235
+ res.push(
236
+ matched[i].substring(
237
+ matched[i].indexOf('<![CDATA[') + lengthCDATA,
238
+ matched[i].indexOf(']]>'),
239
+ ),
240
+ )
208
241
  } else {
209
242
  if (matched[i].indexOf('https://') > -1) {
210
- res.push(matched[i].substring(matched[i].indexOf('https://'), matched[i].length - 1));
243
+ res.push(
244
+ matched[i].substring(
245
+ matched[i].indexOf('https://'),
246
+ matched[i].length - 1,
247
+ ),
248
+ )
211
249
  }
212
250
  }
213
251
  }
214
252
  }
215
253
 
216
- return res;
254
+ return res
217
255
  }
218
256
 
219
257
  parseXML(val: string): XMLDocument | null {
220
- let xmlDoc = null;
258
+ let xmlDoc = null
221
259
 
222
- if (document.implementation && (document.implementation as any).createDocument) {
223
- xmlDoc = (new DOMParser()).parseFromString(val, 'application/xml');
260
+ if (
261
+ document.implementation &&
262
+ (document.implementation as any).createDocument
263
+ ) {
264
+ xmlDoc = new DOMParser().parseFromString(val, 'application/xml')
224
265
  } else if ('ActiveXObject' in window) {
225
- xmlDoc = new (window.ActiveXObject as any)('Microsoft.XMLDOM');
226
- xmlDoc.loadXML(val);
266
+ xmlDoc = new (window.ActiveXObject as any)('Microsoft.XMLDOM')
267
+ xmlDoc.loadXML(val)
227
268
  } else {
228
- return null;
269
+ return null
229
270
  }
230
271
 
231
- return xmlDoc;
272
+ return xmlDoc
232
273
  }
233
274
 
234
275
  removeTag(name: string, attr?: string) {
235
- let tag = '<'+name+'.*?>';
276
+ let tag = '<' + name + '.*?>'
236
277
 
237
278
  if (attr) {
238
- tag = '<'+name+' ' + attr + '.*?>';
279
+ tag = '<' + name + ' ' + attr + '.*?>'
239
280
  }
240
- const filter = new RegExp(tag + '(.|\n|\r)*?' + '<\\/' + name + '>', 'g');
281
+ const filter = new RegExp(tag + '(.|\n|\r)*?' + '<\\/' + name + '>', 'g')
241
282
 
242
- this.config = this.config.replace(filter, '');
283
+ this.config = this.config.replace(filter, '')
243
284
  }
244
285
 
245
286
  extendXML(xml: string) {
246
287
  if (xml.indexOf('<?xml') < 0) {
247
- xml = '<?xml version="1.0" encoding="utf-8"?>' + xml;
288
+ xml = '<?xml version="1.0" encoding="utf-8"?>' + xml
248
289
  }
249
290
  if (!this.config) {
250
- this.config = xml;
291
+ this.config = xml
251
292
 
252
- return;
293
+ return
253
294
  } else {
254
- const xmlMerge = new MergeVast(this.config, xml);
295
+ const xmlMerge = new MergeVast(this.config, xml)
255
296
 
256
- this.config = xmlMerge.merge();
257
- this.config = this.config.replace(/<\?xml.+\?>/g, '');
297
+ this.config = xmlMerge.merge()
298
+ this.config = this.config.replace(/<\?xml.+\?>/g, '')
258
299
  }
259
300
  }
260
301
  }