@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,301 +0,0 @@
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
-
7
- export default class LoaderXML {
8
- private config: string = ''
9
-
10
- constructor(private url: string) {}
11
-
12
- async startLoad() {
13
- return new Promise<{ url: string }>((resolve, reject) => {
14
- if (this._isGoogle(this.url)) {
15
- resolve({ url: this.url })
16
- } else {
17
- this.parse(this.url, null, {}, (response: any, err: any) => {
18
- if (err) {
19
- reject(err)
20
- } else {
21
- resolve(response)
22
- }
23
- })
24
- }
25
- })
26
- }
27
-
28
- parse(
29
- url: string,
30
- parentURLs: string | string[] | null,
31
- options: any,
32
- cb?: (response: any | null, err: any) => void,
33
- ) {
34
- // Options param can be skipped
35
- if (!cb) {
36
- if (typeof options === 'function') {
37
- cb = options
38
- }
39
- options = {}
40
- }
41
-
42
- options.withCredentials = !this._isGoogle(url)
43
- options.timeout = 2000
44
-
45
- assert(cb)
46
-
47
- URLHandler.get(url, options, (err: any, xml: any) => {
48
- if (err) {
49
- return cb(null, err)
50
- }
51
-
52
- return this.parseXmlDocument(url, parentURLs, options, xml, cb)
53
- })
54
- }
55
-
56
- _isGoogle(url: string) {
57
- return (
58
- url.indexOf('g.doubleclick.net') > -1 ||
59
- url.indexOf('ima3vpaid.appspot') > -1 ||
60
- url.indexOf('an.facebook.com') > -1
61
- )
62
- }
63
-
64
- parseXmlDocument(
65
- url: string,
66
- parentURLs: string | string[] | null,
67
- options: any,
68
- xml: any,
69
- cb: (response: any, err?: any) => void,
70
- ) {
71
- if (xml.indexOf('Wrapper')) {
72
- xml = xml.replace(/Wrapper/g, 'InLine')
73
- }
74
-
75
- this.extendXML(xml)
76
- const vastAdTagUri = this.getWrapperUrl()
77
-
78
- if (vastAdTagUri) {
79
- this.parse(vastAdTagUri, url, options, cb)
80
- } else {
81
- const ext = this.getExtension()
82
- const skipTime = this.timeSkipOffset()
83
- const clickUrls = this.clickUrls()
84
- const url = { config: this.config }
85
-
86
- if (this.config.indexOf('<MediaFile') > -1) {
87
- cb(Object.assign(url, ext, skipTime, clickUrls))
88
- } else {
89
- cb(null, { error: 'nobanner' })
90
- }
91
- }
92
- }
93
-
94
- clickUrls() {
95
- const clickTrackings = this.getUrls('ClickTracking') || []
96
- const clickThrough =
97
- this.getUrls('ClickThrough').length > 0
98
- ? this.getUrls('ClickThrough')[0]
99
- : ''
100
-
101
- this.removeTag('ClickThrough')
102
-
103
- return { clickTrackings, clickThrough }
104
- }
105
-
106
- timeSkipOffset() {
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
111
-
112
- if (skipEvents.length > 0) {
113
- timeOffset = 5
114
- this.removeTag('Tracking', 'event="skip"')
115
- }
116
-
117
- if (progressEvents.length > 0) {
118
- timeOffset = 5
119
- this.removeTag('Tracking', 'event="progress"')
120
- }
121
-
122
- if (linearSkipOffset && linearSkipOffset.length > 1) {
123
- timeOffset = parseClipTime(linearSkipOffset[1])
124
- this.config = this.config.replace(
125
- /<Linear skipoffset="(\d+:\d+:\d+)".*?>/g,
126
- '<Linear>',
127
- )
128
- }
129
-
130
- return { skipEvents, progressEvents, timeOffset }
131
- }
132
-
133
- getExtension() {
134
- const extensions = this.getTag('Extensions')
135
-
136
- if (!extensions) {
137
- return {}
138
- }
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
- > = {}
146
-
147
- extObj.controls === '1'
148
-
149
- for (let i = 0; i < items.length; i++) {
150
- try {
151
- const eventName = items[i].getAttribute('type')
152
- let trackingURLTemplate = ''
153
-
154
- if (items[i].children && items[i].children.length > 0) {
155
- trackingURLTemplate = String(items[i]) // TODO or textContent
156
- } else {
157
- trackingURLTemplate = this.getExtensionNode(items[i])
158
- }
159
- if (eventName && trackingURLTemplate) {
160
- try {
161
- extObj[eventName] = trackingURLTemplate
162
- } catch (error) {
163
- // LogManager.exception(error);
164
- reportError(error)
165
- }
166
- }
167
- } catch (error) {
168
- // LogManager.exception(error);
169
- reportError(error)
170
- continue
171
- }
172
- }
173
- if (!extObj.isClickable) {
174
- extObj.isClickable = '1'
175
- }
176
- //может оно и не надо
177
- if (extObj.isClickable === '0') {
178
- this.removeTag('VideoClicks')
179
- }
180
- if (extObj.skipTime2) {
181
- if (extObj.skipTime2.split(':').length === 2) {
182
- extObj.skipTime2 = '00:' + extObj.skipTime2
183
- }
184
- if (this.config.indexOf('Linear') > -1) {
185
- this.config = this.config.replace(
186
- /<Linear.*?>/g,
187
- '<Linear skipoffset="' + extObj.skipTime2 + '">',
188
- )
189
- }
190
- }
191
-
192
- return extObj
193
- }
194
-
195
- getExtensionNode(node: Element): string {
196
- if (!node) {
197
- return ''
198
- }
199
- const result = (node.textContent || (node as any).text || '').trim()
200
-
201
- return result
202
- }
203
-
204
- getWrapperUrl() {
205
- const vastAdTagUri = this.getUrls('VASTAdTagURI')[0]
206
-
207
- this.removeTag('VASTAdTagURI')
208
-
209
- return vastAdTagUri
210
- }
211
-
212
- getTag(name: string, attr?: string): string[] | null {
213
- let tag = '<' + name + '.*?>'
214
-
215
- if (attr) {
216
- tag = '<' + name + ' ' + attr + '.*?>'
217
- }
218
- const matchString = new RegExp(
219
- tag + '(.|\n|\r)*?' + '<\\/' + name + '>',
220
- 'g',
221
- )
222
-
223
- return this.config.match(matchString)
224
- }
225
-
226
- getUrls(tag: string, attr?: string): string[] {
227
- const matched = this.getTag(tag, attr)
228
- const res: string[] = []
229
-
230
- if (matched) {
231
- for (let i = 0; i < matched.length; i++) {
232
- if (matched[i].indexOf('<![CDATA[') > -1) {
233
- const lengthCDATA = 9
234
-
235
- res.push(
236
- matched[i].substring(
237
- matched[i].indexOf('<![CDATA[') + lengthCDATA,
238
- matched[i].indexOf(']]>'),
239
- ),
240
- )
241
- } else {
242
- if (matched[i].indexOf('https://') > -1) {
243
- res.push(
244
- matched[i].substring(
245
- matched[i].indexOf('https://'),
246
- matched[i].length - 1,
247
- ),
248
- )
249
- }
250
- }
251
- }
252
- }
253
-
254
- return res
255
- }
256
-
257
- parseXML(val: string): XMLDocument | null {
258
- let xmlDoc = null
259
-
260
- if (
261
- document.implementation &&
262
- (document.implementation as any).createDocument
263
- ) {
264
- xmlDoc = new DOMParser().parseFromString(val, 'application/xml')
265
- } else if ('ActiveXObject' in window) {
266
- xmlDoc = new (window.ActiveXObject as any)('Microsoft.XMLDOM')
267
- xmlDoc.loadXML(val)
268
- } else {
269
- return null
270
- }
271
-
272
- return xmlDoc
273
- }
274
-
275
- removeTag(name: string, attr?: string) {
276
- let tag = '<' + name + '.*?>'
277
-
278
- if (attr) {
279
- tag = '<' + name + ' ' + attr + '.*?>'
280
- }
281
- const filter = new RegExp(tag + '(.|\n|\r)*?' + '<\\/' + name + '>', 'g')
282
-
283
- this.config = this.config.replace(filter, '')
284
- }
285
-
286
- extendXML(xml: string) {
287
- if (xml.indexOf('<?xml') < 0) {
288
- xml = '<?xml version="1.0" encoding="utf-8"?>' + xml
289
- }
290
- if (!this.config) {
291
- this.config = xml
292
-
293
- return
294
- } else {
295
- const xmlMerge = new MergeVast(this.config, xml)
296
-
297
- this.config = xmlMerge.merge()
298
- this.config = this.config.replace(/<\?xml.+\?>/g, '')
299
- }
300
- }
301
- }