@gcorevideo/player 2.30.2 → 2.30.3

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 (47) hide show
  1. package/dist/core.js +1 -1
  2. package/dist/index.css +353 -353
  3. package/dist/index.embed.js +8 -1
  4. package/dist/index.js +9 -2
  5. package/lib/plugins/media-control/MediaControl.d.ts +1 -0
  6. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  7. package/lib/plugins/media-control/MediaControl.js +9 -1
  8. package/package.json +1 -1
  9. package/src/plugins/media-control/MediaControl.ts +10 -1
  10. package/tsconfig.tsbuildinfo +1 -1
  11. package/assets/vast-ads/style.scss +0 -112
  12. package/lib/plugins/vast-ads/VastAds.d.ts +0 -74
  13. package/lib/plugins/vast-ads/VastAds.d.ts.map +0 -1
  14. package/lib/plugins/vast-ads/VastAds.js +0 -693
  15. package/lib/plugins/vast-ads/loaderxml.d.ts +0 -32
  16. package/lib/plugins/vast-ads/loaderxml.d.ts.map +0 -1
  17. package/lib/plugins/vast-ads/loaderxml.js +0 -229
  18. package/lib/plugins/vast-ads/roll.d.ts +0 -60
  19. package/lib/plugins/vast-ads/roll.d.ts.map +0 -1
  20. package/lib/plugins/vast-ads/roll.js +0 -421
  21. package/lib/plugins/vast-ads/rollmanager.d.ts +0 -62
  22. package/lib/plugins/vast-ads/rollmanager.d.ts.map +0 -1
  23. package/lib/plugins/vast-ads/rollmanager.js +0 -357
  24. package/lib/plugins/vast-ads/sctemanager.d.ts +0 -18
  25. package/lib/plugins/vast-ads/sctemanager.d.ts.map +0 -1
  26. package/lib/plugins/vast-ads/sctemanager.js +0 -117
  27. package/lib/plugins/vast-ads/types.d.ts +0 -12
  28. package/lib/plugins/vast-ads/types.d.ts.map +0 -1
  29. package/lib/plugins/vast-ads/types.js +0 -1
  30. package/lib/plugins/vast-ads/urlhandler.d.ts +0 -4
  31. package/lib/plugins/vast-ads/urlhandler.d.ts.map +0 -1
  32. package/lib/plugins/vast-ads/urlhandler.js +0 -30
  33. package/lib/plugins/vast-ads/xmlhttprequest.d.ts +0 -6
  34. package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +0 -1
  35. package/lib/plugins/vast-ads/xmlhttprequest.js +0 -40
  36. package/lib/plugins/vast-ads/xmlmerge.d.ts +0 -12
  37. package/lib/plugins/vast-ads/xmlmerge.d.ts.map +0 -1
  38. package/lib/plugins/vast-ads/xmlmerge.js +0 -83
  39. package/src/plugins/vast-ads/VastAds.ts +0 -919
  40. package/src/plugins/vast-ads/loaderxml.ts +0 -301
  41. package/src/plugins/vast-ads/roll.ts +0 -590
  42. package/src/plugins/vast-ads/rollmanager.ts +0 -447
  43. package/src/plugins/vast-ads/sctemanager.ts +0 -152
  44. package/src/plugins/vast-ads/types.ts +0 -20
  45. package/src/plugins/vast-ads/urlhandler.ts +0 -42
  46. package/src/plugins/vast-ads/xmlhttprequest.ts +0 -49
  47. package/src/plugins/vast-ads/xmlmerge.ts +0 -106
@@ -1,357 +0,0 @@
1
- import { $, Browser, Events, HTML5Video, Log, Utils, } from '@clappr/core';
2
- import { reportError } from '@gcorevideo/utils';
3
- import assert from 'assert';
4
- import LoaderXML from './loaderxml.js';
5
- import Roll from './roll.js';
6
- export default class RollManager extends Events {
7
- core;
8
- options;
9
- $skipAd;
10
- $muteIcon;
11
- $areaClick;
12
- _adContainer;
13
- type;
14
- countRoll;
15
- volume;
16
- prevVolume;
17
- _allURLRequest = false;
18
- _container;
19
- container;
20
- _options;
21
- vastAdsOptions;
22
- _playback;
23
- _contentElement;
24
- _posterPlugin;
25
- _clickToPausePlugin;
26
- adTemplates = null;
27
- // private _adDisplayContainer: HTMLElement | null = null;
28
- extension = null;
29
- firstRemaininTime = 0;
30
- _imaContainer = null;
31
- isPlaying = false;
32
- loadXML = null;
33
- _pr;
34
- roll = null;
35
- constructor(core, options, $skipAd, $muteIcon, $areaClick, _adContainer, type, countRoll, volume, prevVolume) {
36
- super();
37
- this.core = core;
38
- this.options = options;
39
- this.$skipAd = $skipAd;
40
- this.$muteIcon = $muteIcon;
41
- this.$areaClick = $areaClick;
42
- this._adContainer = _adContainer;
43
- this.type = type;
44
- this.countRoll = countRoll;
45
- this.volume = volume;
46
- this.prevVolume = prevVolume;
47
- this._options = options;
48
- this.vastAdsOptions = this._options.vastAds;
49
- this.container = this.core.activeContainer;
50
- this._container = this.container;
51
- // this.countRoll = countRoll || 0;
52
- this.$skipAd = $skipAd;
53
- this.type = type;
54
- this.$muteIcon = $muteIcon;
55
- this.$areaClick = $areaClick;
56
- this._playback = this.core.activePlayback;
57
- this._contentElement = this._playback.el;
58
- this._posterPlugin = this._container.getPlugin('poster');
59
- this._clickToPausePlugin = this._container.getPlugin('click_to_pause');
60
- this._adContainer = _adContainer;
61
- this._events = {};
62
- this._pr = Math.floor(Math.random() * 1000000);
63
- }
64
- initializeRoll({ xml, url, extension, }) {
65
- try {
66
- this.roll = new Roll({
67
- core: this.core,
68
- $skipAd: this.$skipAd,
69
- $muteIcon: this.$muteIcon,
70
- $areaClick: this.$areaClick,
71
- mute: !!this.options.mute,
72
- volume: this.volume,
73
- prevVolume: this.prevVolume,
74
- });
75
- // @ts-ignore
76
- this.roll.on('volume', this.changeVolume.bind(this));
77
- // @ts-ignore
78
- this.roll.on('advertisement_started', this.onAdStarted.bind(this));
79
- // @ts-ignore
80
- this.roll.on('advertisement_played', this.onAdPlayed.bind(this));
81
- // @ts-ignore
82
- this.roll.on('continue_ad', this._cleverContinueAd.bind(this));
83
- // @ts-ignore
84
- this.roll.on('advertisement_finish', this._playVideoContent.bind(this));
85
- this.roll._requestAd({ xml, url, extension });
86
- }
87
- catch (error) {
88
- // LogManager.exception(error);
89
- reportError(error);
90
- }
91
- }
92
- playerResize(_) {
93
- if (this.roll) {
94
- this.roll.playerResize();
95
- }
96
- }
97
- onAdStarted(_) {
98
- this.removeContainer();
99
- }
100
- onAdPlayed() {
101
- this.isPlaying = true;
102
- }
103
- removeContainer() {
104
- this.trigger('advertisement_started');
105
- }
106
- changeVolume(obj) {
107
- this.trigger('volume', obj);
108
- }
109
- // private _createAdDisplayContainer() {
110
- // this._createImaContainer();
111
- // assert('google' in window, 'google not found');
112
- // this._adDisplayContainer = new (window.google as any).ima.AdDisplayContainer(this._imaContainer, this._contentElement);
113
- // }
114
- _createImaContainer() {
115
- this._destroyImaContainer();
116
- // IMA does not clean ad container when finished
117
- // For the sake of simplicity, wrap into a <div> element
118
- if (this._adContainer) {
119
- this._imaContainer = document.createElement('div');
120
- this._adContainer.appendChild(this._imaContainer);
121
- }
122
- }
123
- _destroyImaContainer() {
124
- if (this._imaContainer && this._adContainer) {
125
- this._adContainer.removeChild(this._imaContainer);
126
- this._imaContainer = null;
127
- }
128
- }
129
- async setupRoll() {
130
- // TODO: check if this is correct
131
- const dataAd = this.vastAdsOptions[this.type] || { data: [] };
132
- const { oneByOne = false } = dataAd;
133
- let rollList = dataAd.data;
134
- if (this.type === 'middleroll') {
135
- const currentStartTime = dataAd.data[this.countRoll].startTimePercent;
136
- rollList = dataAd.data.filter((el) => {
137
- if (el.startTimePercent === currentStartTime) {
138
- return true;
139
- }
140
- });
141
- }
142
- if (this.type === 'repeatableroll') {
143
- const currentStartTime = dataAd.data[this.countRoll].startTime;
144
- rollList = dataAd.data.filter((el) => {
145
- if (el.startTime === currentStartTime) {
146
- return true;
147
- }
148
- });
149
- }
150
- if (this.type === 'middleroll' || this.type === 'repeatableroll') {
151
- this.trigger('change_counter', {
152
- type: this.type,
153
- value: this.countRoll + rollList.length,
154
- });
155
- }
156
- await this.startAd(this.type, { data: rollList, oneByOne });
157
- }
158
- async startAd(type, roll) {
159
- // TODO
160
- // Player.player.trigger('advertisementWasStarted');
161
- this.core.trigger('core:advertisement:start');
162
- this.container.trigger('container:advertisement:start');
163
- this.container.advertisement = { type: type };
164
- if (type !== 'middleroll' && type !== 'repeatableroll') {
165
- console.warn('disableControls');
166
- setTimeout(() => this._disableControls(), 0);
167
- }
168
- if (!this.adTemplates && roll) {
169
- this.adTemplates = this.parseAdUrl(roll.data);
170
- if (!this.adTemplates) {
171
- this.trigger('disable_plugin', { type: this.type });
172
- return;
173
- }
174
- }
175
- if (type === 'preroll') {
176
- if (Browser.isMobile) {
177
- this._playback.consent(() => { });
178
- }
179
- }
180
- //чтобы реклама шла одна за другой
181
- this._allURLRequest = !!roll.oneByOne;
182
- try {
183
- const customPosterPlugin = this.container.getPlugin('poster');
184
- customPosterPlugin.hidePlayButton();
185
- }
186
- catch (error) {
187
- // LogManager.exception(error);
188
- reportError(error);
189
- }
190
- if (!this.adTemplates?.length) {
191
- this.trigger('advertisement_dont_play', { type: this.type });
192
- return;
193
- }
194
- Log.debug('Advertisement', 'advertisement will start');
195
- try {
196
- const adTemplate = this.adTemplates.shift();
197
- // @ts-ignore
198
- await this.loadAd(adTemplate.url);
199
- }
200
- catch (error) {
201
- // LogManager.exception(error);
202
- reportError(error);
203
- }
204
- }
205
- _disableControls() {
206
- this.container.disableMediaControl();
207
- this._clickToPausePlugin?.disable();
208
- // @ts-ignore
209
- this._posterPlugin?.$playWrapper.hide();
210
- }
211
- parseAdUrl(arr) {
212
- if (!Array.isArray(arr)) {
213
- return null;
214
- }
215
- return arr.filter((el) => el.url);
216
- }
217
- paramsUrl(url) {
218
- try {
219
- url = url.replace(/\{width\}/g, this.container.$el.width());
220
- url = url.replace(/\{height\}/g, this.container.$el.height());
221
- url = url.replace(/\{pr\}/g, String(this._pr));
222
- url = url.replace(/\{random\}/g, String(Math.floor(Math.random() * 1000000)));
223
- url = url.replace(/\{session_id\}/g, Utils.uniqueId(''));
224
- url = url.replace(/\{start_delay\}/g, '0');
225
- if (this.options.referer) {
226
- url = url.replace(new RegExp(/\{referer\}/g, 'g'), String(this.options.referer ?? ''));
227
- }
228
- let playback = 1;
229
- if (this.options.autoPlay && this.options.mute) {
230
- playback = 2;
231
- }
232
- if (!this.options.autoPlay) {
233
- playback = 3;
234
- }
235
- url = url.replace(/\{playback\}/g, String(playback));
236
- }
237
- catch (error) {
238
- // LogManager.exception(error);
239
- reportError(error);
240
- }
241
- return url;
242
- }
243
- async loadAd(url) {
244
- if (!url) {
245
- return;
246
- }
247
- try {
248
- if (!['middleroll', 'repeatableroll'].includes(this.container.advertisement.type)) {
249
- const spinnerPlugin = this.container.getPlugin('spinner');
250
- spinnerPlugin?.show();
251
- }
252
- }
253
- catch (error) {
254
- // LogManager.exception(error);
255
- reportError(error);
256
- }
257
- url = this.paramsUrl(url);
258
- Roll._adContainer = this._adContainer;
259
- Roll._contentElement = this._contentElement;
260
- Roll.createAdDisplayContainer();
261
- this.loadXML = new LoaderXML(url);
262
- let data;
263
- try {
264
- data = await this.loadXML.startLoad();
265
- }
266
- catch (error) {
267
- // LogManager.exception(error);
268
- reportError(error);
269
- if (this.adTemplates && this.adTemplates.length > 0) {
270
- const adTemplate = this.adTemplates.shift();
271
- // @ts-ignore
272
- await this.loadAd(adTemplate.url);
273
- }
274
- else {
275
- const spinnerPlugin = this.container.getPlugin('spinner');
276
- spinnerPlugin?.hide();
277
- this.trigger('advertisement_dont_play', { type: this.type });
278
- }
279
- return;
280
- }
281
- try {
282
- this.firstRemaininTime = 0;
283
- this.$muteIcon.hide();
284
- this.$skipAd.hide();
285
- // this.volume = this._playback.volume;
286
- assert(this._playback instanceof HTML5Video);
287
- this.volume = this._playback.el.volume;
288
- }
289
- catch (error) {
290
- // LogManager.exception(error);
291
- reportError(error);
292
- }
293
- this.extension = data;
294
- this.initializeRoll({
295
- xml: data.config,
296
- url: String(data.url || url),
297
- extension: data,
298
- });
299
- }
300
- _onAdError(adErrorEvent) {
301
- try {
302
- const googleError = adErrorEvent.getError();
303
- const error = new Error(googleError.getMessage() + ' ' + googleError.getErrorCode());
304
- error.name = googleError.getType();
305
- // LogManager.exception(error);
306
- reportError(error);
307
- }
308
- catch (error) {
309
- // LogManager.exception(error);
310
- reportError(error);
311
- }
312
- Log.debug('Advertisement', 'advertisement error');
313
- this._cleverContinueAd(true);
314
- }
315
- _imaEvent(eventName, e) {
316
- $.isFunction(this._events[eventName]) &&
317
- this._events[eventName](e);
318
- }
319
- /**
320
- * определяет, что дальше будет запускаться реклама или контент
321
- *
322
- */
323
- async _cleverContinueAd(data) {
324
- this.destroyRoll();
325
- const error = data.error;
326
- if ((this._allURLRequest || error) &&
327
- this.adTemplates &&
328
- this.adTemplates.length > 0) {
329
- const adTemplate = this.adTemplates.shift();
330
- // @ts-ignore
331
- await this.loadAd(adTemplate.url);
332
- return;
333
- }
334
- this._playVideoContent();
335
- }
336
- _playVideoContent() {
337
- this.destroyRoll();
338
- Roll.destroyImaContainer();
339
- const spinnerPlugin = this.container.getPlugin('spinner');
340
- spinnerPlugin?.hide();
341
- if (this.isPlaying) {
342
- this.trigger('advertisement_finish', { type: this.type });
343
- }
344
- else {
345
- this.trigger('advertisement_dont_play', { type: this.type });
346
- }
347
- }
348
- destroyRoll() {
349
- if (!this.roll) {
350
- return;
351
- }
352
- // @ts-ignore
353
- this.roll.off();
354
- this.roll.destroy();
355
- this.roll = null;
356
- }
357
- }
@@ -1,18 +0,0 @@
1
- import { Events, Playback } from '@clappr/core';
2
- import { Events as HlsEvents, FragChangedData } from 'hls.js';
3
- type CueResult = {
4
- kind?: 'in' | 'out' | 'out_cont';
5
- duration?: number;
6
- };
7
- export default class SCTEManager extends Events {
8
- private _playback;
9
- private _scteIsStarted;
10
- set playback(value: Playback);
11
- get playback(): Playback | null;
12
- _subscribedHlsEvents(): void;
13
- _onHlsFragChanged(_: HlsEvents.FRAG_CHANGED, data: FragChangedData): void;
14
- _stopScte(): void;
15
- _getCue(tagList: string[][]): CueResult;
16
- }
17
- export {};
18
- //# sourceMappingURL=sctemanager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sctemanager.d.ts","sourceRoot":"","sources":["../../../src/plugins/vast-ads/sctemanager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAM7D,KAAK,SAAS,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAExE,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,MAAM;IAC7C,OAAO,CAAC,SAAS,CAAwB;IAEzC,OAAO,CAAC,cAAc,CAAQ;IAE9B,IAAI,QAAQ,CAAC,KAAK,EAAE,QAAQ,EA6B3B;IAED,IAAI,QAAQ,IAAI,QAAQ,GAAG,IAAI,CAE9B;IAED,oBAAoB;IAgBpB,iBAAiB,CAAC,CAAC,EAAE,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,eAAe;IA2BlE,SAAS;IAOT,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS;CAoDxC"}
@@ -1,117 +0,0 @@
1
- import { Events } from '@clappr/core';
2
- import { Events as HlsEvents } from 'hls.js';
3
- const OUT = 'out', IN = 'in', OUT_CONT = 'out_cont';
4
- export default class SCTEManager extends Events {
5
- _playback = null;
6
- _scteIsStarted = false;
7
- set playback(value) {
8
- if (this._playback) {
9
- //удалить все подписанные евенты
10
- // @ts-ignore
11
- if (this._playback._hls) {
12
- // @ts-ignore
13
- this._playback._hls.off(HlsEvents.FRAG_CHANGED, this._onHlsFragChanged.bind(this));
14
- }
15
- this._playback.off(Events.PLAYBACK_PLAY_INTENT, this._subscribedHlsEvents, this);
16
- }
17
- this._playback = value;
18
- // @ts-ignore
19
- if (!this._playback._hls) {
20
- this._playback.once(Events.PLAYBACK_PLAY_INTENT, this._subscribedHlsEvents, this);
21
- }
22
- else {
23
- this._subscribedHlsEvents();
24
- }
25
- }
26
- get playback() {
27
- return this._playback;
28
- }
29
- _subscribedHlsEvents() {
30
- // @ts-ignore
31
- if (this._playback._hls) {
32
- // @ts-ignore
33
- this._playback._hls.off(HlsEvents.FRAG_CHANGED, this._onHlsFragChanged.bind(this));
34
- // @ts-ignore
35
- this._playback._hls.on(HlsEvents.FRAG_CHANGED, this._onHlsFragChanged.bind(this));
36
- }
37
- }
38
- _onHlsFragChanged(_, data) {
39
- const { tagList } = data.frag;
40
- if (tagList) {
41
- const cue = this._getCue(tagList);
42
- if (Object.keys(cue).length > 0) {
43
- if (!this._scteIsStarted) {
44
- if (cue.kind === OUT || cue.kind === OUT_CONT) {
45
- this._scteIsStarted = true;
46
- console.warn('scteroll will be started');
47
- this.trigger('startSCTERoll', {
48
- duration: cue.duration,
49
- });
50
- }
51
- }
52
- else {
53
- if (cue.kind === IN) {
54
- console.warn('scteroll will be stopped');
55
- this._stopScte();
56
- }
57
- }
58
- }
59
- else {
60
- this._stopScte();
61
- }
62
- }
63
- }
64
- _stopScte() {
65
- if (this._scteIsStarted) {
66
- this.trigger('stopSCTERoll');
67
- this._scteIsStarted = false;
68
- }
69
- }
70
- _getCue(tagList) {
71
- let cueResult = {
72
- kind: undefined,
73
- duration: undefined,
74
- };
75
- for (let i = 0; i < tagList.length; i++) {
76
- const infoSegment = tagList[i];
77
- let kind;
78
- let duration;
79
- infoSegment.forEach((info) => {
80
- if (kind) {
81
- if (kind === OUT) {
82
- const dur = parseInt(info);
83
- !isNaN(dur) && (duration = dur);
84
- }
85
- if (kind === OUT_CONT) {
86
- const durString = info.match(/Duration=\d+/g);
87
- if (durString) {
88
- const durNumb = durString[0].match(/\d+/g);
89
- if (durNumb) {
90
- duration = parseInt(durNumb[0]);
91
- }
92
- }
93
- }
94
- }
95
- else {
96
- switch (info) {
97
- case 'EXT-X-CUE-OUT':
98
- kind = OUT;
99
- break;
100
- case 'EXT-X-CUE-OUT-CONT':
101
- kind = OUT_CONT;
102
- break;
103
- case 'EXT-X-CUE-IN':
104
- kind = IN;
105
- break;
106
- }
107
- }
108
- });
109
- kind &&
110
- (cueResult = {
111
- kind,
112
- duration,
113
- });
114
- }
115
- return cueResult;
116
- }
117
- }
@@ -1,12 +0,0 @@
1
- export type AdRollType = 'preroll' | 'middleroll' | 'repeatableroll' | 'pauseroll' | 'postroll' | 'scteroll';
2
- export type AdRollItem = {
3
- startTime: number;
4
- startTimePercent: number;
5
- tag: string;
6
- };
7
- export type AdRollDesc = {
8
- data: AdRollItem[];
9
- oneByOne?: boolean;
10
- };
11
- export type VastAdsOptions = Partial<Record<AdRollType, AdRollDesc>>;
12
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/vast-ads/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,YAAY,GACZ,gBAAgB,GAChB,WAAW,GACX,UAAU,GACV,UAAU,CAAA;AAEd,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;IACxB,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,UAAU,EAAE,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export default class URLHandler {
2
- static get(url: string, options: any, cb?: (err: any | null, response?: any) => void): any;
3
- }
4
- //# sourceMappingURL=urlhandler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"urlhandler.d.ts","sourceRoot":"","sources":["../../../src/plugins/vast-ads/urlhandler.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,MAAM,CAAC,GAAG,CACR,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,GAAG,EACZ,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,GAAG,KAAK,IAAI;CA8BjD"}
@@ -1,30 +0,0 @@
1
- import assert from 'assert';
2
- import XHRURLHandler from './xmlhttprequest.js';
3
- // eslint-disable-next-line max-len
4
- const ERROR_MESSAGE = 'Current context is not supported by any of the default URLHandlers. Please provide a custom URLHandler';
5
- export default class URLHandler {
6
- static get(url, options, cb) {
7
- // Allow skip of the options param
8
- if (!cb) {
9
- if (typeof options === 'function') {
10
- cb = options;
11
- }
12
- options = {};
13
- }
14
- assert(cb, 'URLHandler.get: callback is required');
15
- if (options.response) {
16
- // Trick: the VAST response XML document is passed as an option
17
- const { response } = options;
18
- delete options.response;
19
- return cb(null, response);
20
- }
21
- if (options.urlhandler?.supported()) {
22
- // explicitly supply your own URLHandler object
23
- return options.urlhandler.get(url, options, cb);
24
- }
25
- if (XHRURLHandler.supported()) {
26
- return XHRURLHandler.get(url, options, cb);
27
- }
28
- return cb(new Error(ERROR_MESSAGE));
29
- }
30
- }
@@ -1,6 +0,0 @@
1
- export default class XHRURLHandler {
2
- static xhrCreate(): XMLHttpRequest | false;
3
- static supported(): boolean;
4
- static get(url: string, options: any, cb: (err: Error | null, response?: any) => void): void;
5
- }
6
- //# sourceMappingURL=xmlhttprequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"xmlhttprequest.d.ts","sourceRoot":"","sources":["../../../src/plugins/vast-ads/xmlhttprequest.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,MAAM,CAAC,SAAS,IAAI,cAAc,GAAG,KAAK;IAW1C,MAAM,CAAC,SAAS;IAIhB,MAAM,CAAC,GAAG,CACR,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,GAAG,EACZ,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,GAAG,KAAK,IAAI;CA0BlD"}
@@ -1,40 +0,0 @@
1
- import { reportError } from '@gcorevideo/utils';
2
- import assert from 'assert';
3
- export default class XHRURLHandler {
4
- static xhrCreate() {
5
- const xhr = new window.XMLHttpRequest();
6
- if ('withCredentials' in xhr) {
7
- // check CORS support
8
- return xhr;
9
- }
10
- return false;
11
- }
12
- static supported() {
13
- return !!this.xhrCreate();
14
- }
15
- static get(url, options, cb) {
16
- try {
17
- const xhr = this.xhrCreate();
18
- assert(xhr, 'XHRURLHandler: XMLHttpRequest is not supported');
19
- xhr.open('GET', url);
20
- xhr.timeout = options.timeout || 0;
21
- xhr.withCredentials = options.withCredentials || false;
22
- xhr.onreadystatechange = function () {
23
- if (xhr.readyState === 4) {
24
- if (xhr.status === 200) {
25
- return cb(null, xhr.response);
26
- }
27
- else {
28
- return cb(new Error(`XHRURLHandler: ${xhr.statusText}`));
29
- }
30
- }
31
- };
32
- return xhr.send();
33
- }
34
- catch (error) {
35
- // LogManager.exception(error);
36
- reportError(error);
37
- return cb(new Error('XHRURLHandler: Unexpected error'));
38
- }
39
- }
40
- }
@@ -1,12 +0,0 @@
1
- export default class MergeVast {
2
- private firstXML;
3
- private secondXML;
4
- private firstVAST;
5
- private secondVAST;
6
- constructor(xml1: string, xml2: string);
7
- merge(): string;
8
- _mergeXML(first: HTMLCollectionOf<Element>, second: HTMLCollectionOf<Element>, parent?: Element): HTMLCollectionOf<Element>;
9
- _getPieceTree(nodeName: string, xml: HTMLCollectionOf<Element>): Element | null;
10
- _stringToXML(val: string): Document;
11
- }
12
- //# sourceMappingURL=xmlmerge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"xmlmerge.d.ts","sourceRoot":"","sources":["../../../src/plugins/vast-ads/xmlmerge.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,SAAS,CAAU;IAE3B,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,UAAU,CAA2B;gBAEjC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAOtC,KAAK;IAaL,SAAS,CACP,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAChC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,EACjC,MAAM,CAAC,EAAE,OAAO,GACf,gBAAgB,CAAC,OAAO,CAAC;IAsC5B,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAC7B,OAAO,GAAG,IAAI;IAcjB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;CAgBpC"}