@streamlayer/feature-advertisement 1.1.1-rc.9.p3f19ebd7 → 1.2.0
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/lib/advertisement.d.ts +6 -6
- package/lib/advertisement.js +9 -9
- package/lib/index.d.ts +14 -15
- package/lib/index.js +9 -9
- package/lib/units/external-ad.d.ts +2 -2
- package/lib/units/external-ad.js +3 -3
- package/lib/units/external-pause-ad.js +1 -1
- package/lib/units/gam.js +1 -1
- package/lib/units/pause-ad.d.ts +1 -1
- package/lib/units/pause-ad.js +1 -1
- package/lib/units/sponsor-logo.d.ts +4 -12
- package/lib/units/sponsor-logo.js +3 -4
- package/lib/units/ssai-ad-break.d.ts +1 -1
- package/lib/units/ssai-creative.d.ts +1 -1
- package/lib/units/ssai-creative.js +1 -1
- package/lib/units/ssai-detector.d.ts +1 -1
- package/lib/units/ssai-detector.js +1 -1
- package/lib/units/ssai-preload.d.ts +1 -1
- package/lib/units/ssai-providers.d.ts +1 -1
- package/lib/units/ssai-providers.js +1 -1
- package/lib/units/vast-tracker.d.ts +1 -1
- package/package.json +9 -42
- package/classic/package.json +0 -5
- package/lib/cjs/advertisement.d.ts +0 -64
- package/lib/cjs/advertisement.js +0 -322
- package/lib/cjs/index.d.ts +0 -21
- package/lib/cjs/index.js +0 -41
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/units/ad-macros.d.ts +0 -7
- package/lib/cjs/units/ad-macros.js +0 -91
- package/lib/cjs/units/external-ad.d.ts +0 -127
- package/lib/cjs/units/external-ad.js +0 -421
- package/lib/cjs/units/external-pause-ad.d.ts +0 -50
- package/lib/cjs/units/external-pause-ad.js +0 -259
- package/lib/cjs/units/gam.d.ts +0 -26
- package/lib/cjs/units/gam.js +0 -152
- package/lib/cjs/units/parse-vast-extensions.d.ts +0 -26
- package/lib/cjs/units/parse-vast-extensions.js +0 -56
- package/lib/cjs/units/pause-ad-card.d.ts +0 -49
- package/lib/cjs/units/pause-ad-card.js +0 -136
- package/lib/cjs/units/pause-ad.d.ts +0 -16
- package/lib/cjs/units/pause-ad.js +0 -52
- package/lib/cjs/units/sponsor-logo.d.ts +0 -78
- package/lib/cjs/units/sponsor-logo.js +0 -194
- package/lib/cjs/units/ssai-ad-break.d.ts +0 -21
- package/lib/cjs/units/ssai-ad-break.js +0 -11
- package/lib/cjs/units/ssai-creative.d.ts +0 -89
- package/lib/cjs/units/ssai-creative.js +0 -136
- package/lib/cjs/units/ssai-detector.d.ts +0 -180
- package/lib/cjs/units/ssai-detector.js +0 -1172
- package/lib/cjs/units/ssai-log.d.ts +0 -16
- package/lib/cjs/units/ssai-log.js +0 -23
- package/lib/cjs/units/ssai-preload.d.ts +0 -20
- package/lib/cjs/units/ssai-preload.js +0 -62
- package/lib/cjs/units/ssai-providers.d.ts +0 -117
- package/lib/cjs/units/ssai-providers.js +0 -300
- package/lib/cjs/units/vast-tracker.d.ts +0 -45
- package/lib/cjs/units/vast-tracker.js +0 -64
- package/lib/classic/_virtual/_rollupPluginBabelHelpers.js +0 -71
- package/lib/classic/advertisement.js +0 -348
- package/lib/classic/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -77
- package/lib/classic/cjs/advertisement.js +0 -350
- package/lib/classic/cjs/index.js +0 -49
- package/lib/classic/cjs/package.json +0 -1
- package/lib/classic/cjs/units/ad-macros.js +0 -115
- package/lib/classic/cjs/units/external-ad.js +0 -500
- package/lib/classic/cjs/units/external-pause-ad.js +0 -278
- package/lib/classic/cjs/units/gam.js +0 -173
- package/lib/classic/cjs/units/parse-vast-extensions.js +0 -60
- package/lib/classic/cjs/units/pause-ad-card.js +0 -134
- package/lib/classic/cjs/units/pause-ad.js +0 -72
- package/lib/classic/cjs/units/sponsor-logo.js +0 -201
- package/lib/classic/cjs/units/ssai-ad-break.js +0 -11
- package/lib/classic/cjs/units/ssai-creative.js +0 -142
- package/lib/classic/cjs/units/ssai-detector.js +0 -1195
- package/lib/classic/cjs/units/ssai-log.js +0 -23
- package/lib/classic/cjs/units/ssai-preload.js +0 -72
- package/lib/classic/cjs/units/ssai-providers.js +0 -361
- package/lib/classic/cjs/units/vast-tracker.js +0 -81
- package/lib/classic/index.js +0 -29
- package/lib/classic/units/ad-macros.js +0 -113
- package/lib/classic/units/external-ad.js +0 -491
- package/lib/classic/units/external-pause-ad.js +0 -275
- package/lib/classic/units/gam.js +0 -171
- package/lib/classic/units/parse-vast-extensions.js +0 -58
- package/lib/classic/units/pause-ad-card.js +0 -131
- package/lib/classic/units/pause-ad.js +0 -70
- package/lib/classic/units/sponsor-logo.js +0 -197
- package/lib/classic/units/ssai-ad-break.js +0 -9
- package/lib/classic/units/ssai-creative.js +0 -140
- package/lib/classic/units/ssai-detector.js +0 -1192
- package/lib/classic/units/ssai-log.js +0 -21
- package/lib/classic/units/ssai-preload.js +0 -68
- package/lib/classic/units/ssai-providers.js +0 -351
- package/lib/classic/units/vast-tracker.js +0 -77
- package/lib/vast-client.d.ts +0 -9
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
2
|
-
try {
|
|
3
|
-
var i = n[a](c),
|
|
4
|
-
u = i.value;
|
|
5
|
-
} catch (n) {
|
|
6
|
-
return void e(n);
|
|
7
|
-
}
|
|
8
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
9
|
-
}
|
|
10
|
-
function _asyncToGenerator(n) {
|
|
11
|
-
return function () {
|
|
12
|
-
var t = this,
|
|
13
|
-
e = arguments;
|
|
14
|
-
return new Promise(function (r, o) {
|
|
15
|
-
var a = n.apply(t, e);
|
|
16
|
-
function _next(n) {
|
|
17
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
18
|
-
}
|
|
19
|
-
function _throw(n) {
|
|
20
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
21
|
-
}
|
|
22
|
-
_next(void 0);
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function _defineProperty(e, r, t) {
|
|
27
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
28
|
-
value: t,
|
|
29
|
-
enumerable: true,
|
|
30
|
-
configurable: true,
|
|
31
|
-
writable: true
|
|
32
|
-
}) : e[r] = t, e;
|
|
33
|
-
}
|
|
34
|
-
function ownKeys(e, r) {
|
|
35
|
-
var t = Object.keys(e);
|
|
36
|
-
if (Object.getOwnPropertySymbols) {
|
|
37
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
38
|
-
r && (o = o.filter(function (r) {
|
|
39
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
40
|
-
})), t.push.apply(t, o);
|
|
41
|
-
}
|
|
42
|
-
return t;
|
|
43
|
-
}
|
|
44
|
-
function _objectSpread2(e) {
|
|
45
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
46
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
47
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
48
|
-
_defineProperty(e, r, t[r]);
|
|
49
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
50
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return e;
|
|
54
|
-
}
|
|
55
|
-
function _toPrimitive(t, r) {
|
|
56
|
-
if ("object" != typeof t || !t) return t;
|
|
57
|
-
if (typeof Symbol === "function" && t instanceof Symbol) return t;
|
|
58
|
-
var e = t[Symbol.toPrimitive];
|
|
59
|
-
if (void 0 !== e) {
|
|
60
|
-
var i = e.call(t, r);
|
|
61
|
-
if ("object" != typeof i) return i;
|
|
62
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
63
|
-
}
|
|
64
|
-
return ("string" === r ? String : Number)(t);
|
|
65
|
-
}
|
|
66
|
-
function _toPropertyKey(t) {
|
|
67
|
-
var i = _toPrimitive(t, "string");
|
|
68
|
-
return "symbol" == typeof i ? i : i + "";
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { _asyncToGenerator as asyncToGenerator, _defineProperty as defineProperty, _objectSpread2 as objectSpread2, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey };
|
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import { defineProperty as _defineProperty, objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import 'core-js/modules/es.array.iterator.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
-
import 'core-js/modules/esnext.iterator.find.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import 'core-js/modules/esnext.set.difference.v2.js';
|
|
7
|
-
import 'core-js/modules/esnext.set.intersection.v2.js';
|
|
8
|
-
import 'core-js/modules/esnext.set.is-disjoint-from.v2.js';
|
|
9
|
-
import 'core-js/modules/esnext.set.is-subset-of.v2.js';
|
|
10
|
-
import 'core-js/modules/esnext.set.is-superset-of.v2.js';
|
|
11
|
-
import 'core-js/modules/esnext.set.symmetric-difference.v2.js';
|
|
12
|
-
import 'core-js/modules/esnext.set.union.v2.js';
|
|
13
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
14
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
15
|
-
import { AbstractFeatureUnit, createSingleStore, eventBus } from '@streamlayer/sdk-web-interfaces/classic';
|
|
16
|
-
import { createLogger } from '@streamlayer/sdk-web-logger/classic';
|
|
17
|
-
import { externalAd } from './units/external-ad.js';
|
|
18
|
-
import { externalPauseAd } from './units/external-pause-ad.js';
|
|
19
|
-
import { pauseAdListStore } from './units/pause-ad.js';
|
|
20
|
-
import { SsaiCreativeCache } from './units/ssai-creative.js';
|
|
21
|
-
import { resolveProvider } from './units/ssai-providers.js';
|
|
22
|
-
import { createSsaiDetector } from './units/ssai-detector.js';
|
|
23
|
-
import { createSsaiAdBreakStore } from './units/ssai-ad-break.js';
|
|
24
|
-
import { ssaiq } from './units/ssai-log.js';
|
|
25
|
-
import { preloadCreativeAssets } from './units/ssai-preload.js';
|
|
26
|
-
|
|
27
|
-
class Advertisement extends AbstractFeatureUnit {
|
|
28
|
-
constructor(instance) {
|
|
29
|
-
super();
|
|
30
|
-
_defineProperty(this, "getExternalAd", void 0);
|
|
31
|
-
_defineProperty(this, "getExternalPauseAd", void 0);
|
|
32
|
-
_defineProperty(this, "getPauseAdList", void 0);
|
|
33
|
-
_defineProperty(this, "ssaiAdBreak", createSsaiAdBreakStore());
|
|
34
|
-
_defineProperty(this, "startSsaiMonitoring", void 0);
|
|
35
|
-
_defineProperty(this, "stopSsaiMonitoring", void 0);
|
|
36
|
-
/**
|
|
37
|
-
* Fire the impression tracking pixel for a creative. Called by the UI the
|
|
38
|
-
* moment the bar actually renders the creative, so "impression" means the
|
|
39
|
-
* viewer saw it (not merely that metadata resolved).
|
|
40
|
-
*/
|
|
41
|
-
_defineProperty(this, "fireSsaiImpression", void 0);
|
|
42
|
-
/**
|
|
43
|
-
* Fire a named tracking beacon for a creative (`clickThrough`, or any event
|
|
44
|
-
* the creative carries). Lifecycle beacons — `start`, the quartiles and
|
|
45
|
-
* `complete` — are fired automatically by the detector as playback crosses
|
|
46
|
-
* them; this is for the ones only the UI knows about.
|
|
47
|
-
*/
|
|
48
|
-
_defineProperty(this, "fireSsaiTracking", void 0);
|
|
49
|
-
/**
|
|
50
|
-
* Fire the companion's `clickTracking` beacons. Exposed for hosts that render
|
|
51
|
-
* the companion banner themselves — the TV overlay has no companion surface,
|
|
52
|
-
* so nothing in this SDK calls it.
|
|
53
|
-
*/
|
|
54
|
-
_defineProperty(this, "fireSsaiCompanionClick", void 0);
|
|
55
|
-
/**
|
|
56
|
-
* User-dismissed the current break: hide the bar now and keep it hidden for
|
|
57
|
-
* the rest of this break (a later break/creative shows again).
|
|
58
|
-
*/
|
|
59
|
-
_defineProperty(this, "dismissSsaiBreak", void 0);
|
|
60
|
-
/**
|
|
61
|
-
* Read-only timing introspection of the running SSAI monitor (null while no
|
|
62
|
-
* monitor runs). Feeds the demo app's SSAI debug window; safe to poll.
|
|
63
|
-
*/
|
|
64
|
-
_defineProperty(this, "getSsaiDebugSnapshot", void 0);
|
|
65
|
-
_defineProperty(this, "externalAdStores", new Map());
|
|
66
|
-
_defineProperty(this, "externalPauseAdStores", new Map());
|
|
67
|
-
_defineProperty(this, "externalPauseAdEnabled", new Map());
|
|
68
|
-
_defineProperty(this, "pauseAdStore", null);
|
|
69
|
-
_defineProperty(this, "pauseAdEnabled", null);
|
|
70
|
-
_defineProperty(this, "ssaiDetector", null);
|
|
71
|
-
_defineProperty(this, "ssaiCache", null);
|
|
72
|
-
_defineProperty(this, "log", void 0);
|
|
73
|
-
_defineProperty(this, "connect", () => {
|
|
74
|
-
this.log.debug('connect');
|
|
75
|
-
});
|
|
76
|
-
_defineProperty(this, "disconnect", () => {
|
|
77
|
-
this.log.debug('disconnect');
|
|
78
|
-
this.stopSsaiMonitoring();
|
|
79
|
-
this.externalAdStores.forEach(store => {
|
|
80
|
-
store.off();
|
|
81
|
-
});
|
|
82
|
-
this.externalAdStores.clear();
|
|
83
|
-
this.externalPauseAdStores.forEach(store => {
|
|
84
|
-
store.off();
|
|
85
|
-
});
|
|
86
|
-
this.externalPauseAdEnabled.forEach(enabled => {
|
|
87
|
-
enabled.off();
|
|
88
|
-
});
|
|
89
|
-
this.externalPauseAdEnabled.clear();
|
|
90
|
-
this.externalPauseAdStores.clear();
|
|
91
|
-
if (this.pauseAdStore) {
|
|
92
|
-
var _this$pauseAdEnabled;
|
|
93
|
-
this.pauseAdStore.$list.off();
|
|
94
|
-
this.pauseAdStore.$index.off();
|
|
95
|
-
(_this$pauseAdEnabled = this.pauseAdEnabled) === null || _this$pauseAdEnabled === void 0 || _this$pauseAdEnabled.off();
|
|
96
|
-
this.pauseAdStore = null;
|
|
97
|
-
this.pauseAdEnabled = null;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
this.log = createLogger('advertisement');
|
|
101
|
-
const externalAdGenerator = externalAd(instance);
|
|
102
|
-
const externalPauseAdGenerator = externalPauseAd(instance);
|
|
103
|
-
const pauseAdGenerator = pauseAdListStore(instance);
|
|
104
|
-
this.fireSsaiImpression = () => undefined;
|
|
105
|
-
this.fireSsaiTracking = () => undefined;
|
|
106
|
-
this.fireSsaiCompanionClick = () => undefined;
|
|
107
|
-
this.dismissSsaiBreak = () => undefined;
|
|
108
|
-
// Stable across start/stop cycles — always answers from the CURRENT detector.
|
|
109
|
-
this.getSsaiDebugSnapshot = () => {
|
|
110
|
-
var _this$ssaiDetector$ge, _this$ssaiDetector;
|
|
111
|
-
return (_this$ssaiDetector$ge = (_this$ssaiDetector = this.ssaiDetector) === null || _this$ssaiDetector === void 0 ? void 0 : _this$ssaiDetector.getDebugSnapshot()) !== null && _this$ssaiDetector$ge !== void 0 ? _this$ssaiDetector$ge : null;
|
|
112
|
-
};
|
|
113
|
-
this.getPauseAdList = options => {
|
|
114
|
-
if (this.pauseAdStore) {
|
|
115
|
-
const $enabled = this.pauseAdEnabled;
|
|
116
|
-
const wasDisabled = $enabled.get() === false;
|
|
117
|
-
$enabled.set(options.$enabled);
|
|
118
|
-
if (wasDisabled && options.$enabled) {
|
|
119
|
-
window.requestAnimationFrame(() => {
|
|
120
|
-
if (this.pauseAdStore) this.pauseAdStore.$list.revalidate();
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return this.pauseAdStore;
|
|
124
|
-
}
|
|
125
|
-
const $enabled = createSingleStore(options.$enabled);
|
|
126
|
-
this.pauseAdEnabled = $enabled;
|
|
127
|
-
this.pauseAdStore = pauseAdGenerator($enabled, options);
|
|
128
|
-
return this.pauseAdStore;
|
|
129
|
-
};
|
|
130
|
-
this.getExternalAd = (adUrl = '') => {
|
|
131
|
-
if (this.externalAdStores.has(adUrl)) {
|
|
132
|
-
const $store = this.externalAdStores.get(adUrl);
|
|
133
|
-
return [$store, adUrl];
|
|
134
|
-
}
|
|
135
|
-
const store = externalAdGenerator(adUrl);
|
|
136
|
-
this.externalAdStores.set(adUrl, store);
|
|
137
|
-
return [store, adUrl];
|
|
138
|
-
};
|
|
139
|
-
this.getExternalPauseAd = (adUrl, options) => {
|
|
140
|
-
var _options$template;
|
|
141
|
-
// Store identity is (template, url): the template selects a DIFFERENT creative
|
|
142
|
-
// from the SAME tag, so the two must not share a store. Required because the
|
|
143
|
-
// cache-hit branch below applies only `$enabled` and drops the rest of `options`.
|
|
144
|
-
const storeKey = `${(_options$template = options.template) !== null && _options$template !== void 0 ? _options$template : 'default'}::${adUrl}`;
|
|
145
|
-
if (this.externalPauseAdStores.has(storeKey)) {
|
|
146
|
-
const $enabled = this.externalPauseAdEnabled.get(storeKey);
|
|
147
|
-
const $store = this.externalPauseAdStores.get(storeKey);
|
|
148
|
-
const shouldRevalidate = $enabled.get() === false && options.$enabled === true;
|
|
149
|
-
$enabled.set(options.$enabled);
|
|
150
|
-
if (shouldRevalidate) {
|
|
151
|
-
window.requestAnimationFrame(() => {
|
|
152
|
-
$store.revalidate();
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
// The 2nd element MUST stay the BARE url — `ExposedPauseAd` compares it to
|
|
156
|
-
// `vastUrlRef.current` (index.tsx:121) to scope store errors to the selected tag.
|
|
157
|
-
return [$store, adUrl];
|
|
158
|
-
}
|
|
159
|
-
const $enabled = createSingleStore(options.$enabled);
|
|
160
|
-
const store = externalPauseAdGenerator(adUrl, $enabled, options);
|
|
161
|
-
this.externalPauseAdEnabled.set(storeKey, $enabled);
|
|
162
|
-
this.externalPauseAdStores.set(storeKey, store);
|
|
163
|
-
return [store, adUrl];
|
|
164
|
-
};
|
|
165
|
-
this.startSsaiMonitoring = options => {
|
|
166
|
-
this.stopSsaiMonitoring();
|
|
167
|
-
const provider = resolveProvider(options.provider);
|
|
168
|
-
const cache = new SsaiCreativeCache(provider);
|
|
169
|
-
this.ssaiCache = cache;
|
|
170
|
-
/**
|
|
171
|
-
* Every beacon the SDK fires gets a line, with the URL it was fired at.
|
|
172
|
-
* The narrative log is read as a live trace of one ad, and "we called the
|
|
173
|
-
* ad server's own tracking URL" is as much of the story as the request
|
|
174
|
-
* that fetched the creative in the first place.
|
|
175
|
-
*/
|
|
176
|
-
const logBeacon = (creativeId, event) => {
|
|
177
|
-
var _cache$peek;
|
|
178
|
-
const url = (_cache$peek = cache.peek(creativeId)) === null || _cache$peek === void 0 || (_cache$peek = _cache$peek.trackingEvents) === null || _cache$peek === void 0 || (_cache$peek = _cache$peek.find(entry => entry.event === event)) === null || _cache$peek === void 0 ? void 0 : _cache$peek.url;
|
|
179
|
-
ssaiq.info({
|
|
180
|
-
creativeId,
|
|
181
|
-
event,
|
|
182
|
-
url
|
|
183
|
-
}, `[beacon] ${event} fired — ${creativeId}`);
|
|
184
|
-
};
|
|
185
|
-
this.fireSsaiImpression = creativeId => {
|
|
186
|
-
var _cache$peek2;
|
|
187
|
-
// The UI only calls this once the bar is actually rendered, so this is
|
|
188
|
-
// the moment the viewer saw the ad — not the moment it resolved.
|
|
189
|
-
ssaiq.info({
|
|
190
|
-
creativeId
|
|
191
|
-
}, `[ad] ad on screen — ${((_cache$peek2 = cache.peek(creativeId)) === null || _cache$peek2 === void 0 ? void 0 : _cache$peek2.advertiser) || creativeId}`);
|
|
192
|
-
logBeacon(creativeId, 'impression');
|
|
193
|
-
cache.fireImpressionById(creativeId);
|
|
194
|
-
};
|
|
195
|
-
this.fireSsaiTracking = (creativeId, event) => {
|
|
196
|
-
logBeacon(creativeId, event);
|
|
197
|
-
cache.fireTrackingById(creativeId, event);
|
|
198
|
-
};
|
|
199
|
-
this.fireSsaiCompanionClick = creativeId => {
|
|
200
|
-
cache.fireCompanionClickById(creativeId);
|
|
201
|
-
};
|
|
202
|
-
// Creative ids whose artwork preload has completed. Tracked apart from the
|
|
203
|
-
// cache: `peek` alone would let the bar show with a logo still in flight.
|
|
204
|
-
const preloadedIds = new Set();
|
|
205
|
-
/**
|
|
206
|
-
* Resolve + warm a creative the moment its id shows up in the manifest —
|
|
207
|
-
* typically seconds before its break starts, since the playhead trails the
|
|
208
|
-
* live edge. By break start the sync fast-path in `loadCreative` then flips
|
|
209
|
-
* the store straight to 'ready'. Failure here is only a debug note: the
|
|
210
|
-
* break may still be minutes away, and `loadCreative` retries (and warns)
|
|
211
|
-
* when the ad actually starts.
|
|
212
|
-
*/
|
|
213
|
-
const prefetchCreative = creativeId => {
|
|
214
|
-
cache.resolve(creativeId).then(creative => preloadCreativeAssets(creative).then(() => creative)).then(creative => {
|
|
215
|
-
preloadedIds.add(creativeId);
|
|
216
|
-
ssaiq.info({
|
|
217
|
-
creativeId
|
|
218
|
-
}, `[ad] creative ready — ${creative.advertiser} (artwork preloaded)`);
|
|
219
|
-
}).catch(() => {
|
|
220
|
-
// Already on `ssaiq` from the provider; the break may still be
|
|
221
|
-
// minutes away, and `loadCreative` retries when it actually starts.
|
|
222
|
-
});
|
|
223
|
-
};
|
|
224
|
-
const publishReady = (range, creative) => {
|
|
225
|
-
this.ssaiAdBreak.set({
|
|
226
|
-
creativeId: range.creativeId,
|
|
227
|
-
creative,
|
|
228
|
-
status: 'ready',
|
|
229
|
-
startMs: range.startMs,
|
|
230
|
-
durationSec: range.durationSec
|
|
231
|
-
});
|
|
232
|
-
// "loaded" = metadata resolved. Impression (eventBus + pixel) fires
|
|
233
|
-
// from the UI when the bar is actually rendered, not here.
|
|
234
|
-
eventBus.emit('ssaiAdBreak', {
|
|
235
|
-
action: 'vastLoaded',
|
|
236
|
-
payload: {
|
|
237
|
-
creativeId: creative.creativeId,
|
|
238
|
-
advertiser: creative.advertiser,
|
|
239
|
-
clickThroughUrl: creative.clickThroughUrl
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
const loadCreative = range => {
|
|
244
|
-
// Fast path: prefetched at discovery, artwork warm — go straight to
|
|
245
|
-
// 'ready'. Skipping the 'detecting' hop matters for pods in particular:
|
|
246
|
-
// it momentarily empties the store, which the UI renders as the bar
|
|
247
|
-
// starting to close between two back-to-back ads.
|
|
248
|
-
const prefetched = cache.peek(range.creativeId);
|
|
249
|
-
if (prefetched && preloadedIds.has(range.creativeId)) {
|
|
250
|
-
publishReady(range, prefetched);
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
this.ssaiAdBreak.set({
|
|
254
|
-
creativeId: range.creativeId,
|
|
255
|
-
status: 'detecting',
|
|
256
|
-
startMs: range.startMs,
|
|
257
|
-
durationSec: range.durationSec
|
|
258
|
-
});
|
|
259
|
-
cache.resolve(range.creativeId)
|
|
260
|
-
// Warm the artwork BEFORE flipping to 'ready', so the bar fades in with
|
|
261
|
-
// its logo already decoded instead of popping it in mid-animation. Capped
|
|
262
|
-
// internally, so a slow image host delays nothing.
|
|
263
|
-
.then(creative => preloadCreativeAssets(creative).then(() => {
|
|
264
|
-
preloadedIds.add(range.creativeId);
|
|
265
|
-
return creative;
|
|
266
|
-
})).then(creative => {
|
|
267
|
-
const current = this.ssaiAdBreak.get();
|
|
268
|
-
// Re-checked after the preload as well as the fetch: the break can end
|
|
269
|
-
// while either is in flight.
|
|
270
|
-
if (!current || current.creativeId !== range.creativeId) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
publishReady(range, creative);
|
|
274
|
-
}).catch(error => {
|
|
275
|
-
this.log.warn(error, 'ssai creative resolution failed');
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
this.ssaiDetector = createSsaiDetector({
|
|
279
|
-
player: options.player,
|
|
280
|
-
videoRef: options.videoRef,
|
|
281
|
-
manifestUrl: options.manifestUrl,
|
|
282
|
-
onAdDiscovered: creativeId => {
|
|
283
|
-
prefetchCreative(creativeId);
|
|
284
|
-
},
|
|
285
|
-
onBreakStart: range => {
|
|
286
|
-
eventBus.emit('ssaiAdBreak', {
|
|
287
|
-
action: 'breakStart',
|
|
288
|
-
payload: {
|
|
289
|
-
creativeId: range.creativeId
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
loadCreative(range);
|
|
293
|
-
},
|
|
294
|
-
onCreativeChange: range => {
|
|
295
|
-
loadCreative(range);
|
|
296
|
-
},
|
|
297
|
-
onAdEnding: range => {
|
|
298
|
-
const current = this.ssaiAdBreak.get();
|
|
299
|
-
// Only a bar currently showing this creative has anything to wind
|
|
300
|
-
// down — a dismissed or still-resolving break stays as it is.
|
|
301
|
-
if (!current || current.creativeId !== range.creativeId || current.status !== 'ready') {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
this.ssaiAdBreak.set(_objectSpread2(_objectSpread2({}, current), {}, {
|
|
305
|
-
status: 'ending'
|
|
306
|
-
}));
|
|
307
|
-
},
|
|
308
|
-
onProgress: (range, event) => {
|
|
309
|
-
// Logged by the detector as `progress:<event>` at the moment playback
|
|
310
|
-
// crosses the marker; nothing to add here.
|
|
311
|
-
cache.fireTrackingById(range.creativeId, event);
|
|
312
|
-
},
|
|
313
|
-
onBreakEnd: () => {
|
|
314
|
-
const current = this.ssaiAdBreak.get();
|
|
315
|
-
eventBus.emit('ssaiAdBreak', {
|
|
316
|
-
action: 'breakEnd',
|
|
317
|
-
payload: {
|
|
318
|
-
creativeId: current === null || current === void 0 ? void 0 : current.creativeId
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
this.ssaiAdBreak.set(null);
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
this.dismissSsaiBreak = () => {
|
|
325
|
-
var _this$ssaiDetector2;
|
|
326
|
-
(_this$ssaiDetector2 = this.ssaiDetector) === null || _this$ssaiDetector2 === void 0 || _this$ssaiDetector2.dismissActiveBreak();
|
|
327
|
-
this.ssaiAdBreak.set(null);
|
|
328
|
-
};
|
|
329
|
-
};
|
|
330
|
-
this.stopSsaiMonitoring = () => {
|
|
331
|
-
if (this.ssaiDetector) {
|
|
332
|
-
this.ssaiDetector.destroy();
|
|
333
|
-
this.ssaiDetector = null;
|
|
334
|
-
}
|
|
335
|
-
if (this.ssaiCache) {
|
|
336
|
-
this.ssaiCache.destroy();
|
|
337
|
-
this.ssaiCache = null;
|
|
338
|
-
}
|
|
339
|
-
this.fireSsaiImpression = () => undefined;
|
|
340
|
-
this.fireSsaiTracking = () => undefined;
|
|
341
|
-
this.fireSsaiCompanionClick = () => undefined;
|
|
342
|
-
this.dismissSsaiBreak = () => undefined;
|
|
343
|
-
this.ssaiAdBreak.set(null);
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
export { Advertisement };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
4
|
-
try {
|
|
5
|
-
var i = n[a](c),
|
|
6
|
-
u = i.value;
|
|
7
|
-
} catch (n) {
|
|
8
|
-
return void e(n);
|
|
9
|
-
}
|
|
10
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
11
|
-
}
|
|
12
|
-
function _asyncToGenerator(n) {
|
|
13
|
-
return function () {
|
|
14
|
-
var t = this,
|
|
15
|
-
e = arguments;
|
|
16
|
-
return new Promise(function (r, o) {
|
|
17
|
-
var a = n.apply(t, e);
|
|
18
|
-
function _next(n) {
|
|
19
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
20
|
-
}
|
|
21
|
-
function _throw(n) {
|
|
22
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
23
|
-
}
|
|
24
|
-
_next(void 0);
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function _defineProperty(e, r, t) {
|
|
29
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
30
|
-
value: t,
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true
|
|
34
|
-
}) : e[r] = t, e;
|
|
35
|
-
}
|
|
36
|
-
function ownKeys(e, r) {
|
|
37
|
-
var t = Object.keys(e);
|
|
38
|
-
if (Object.getOwnPropertySymbols) {
|
|
39
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
40
|
-
r && (o = o.filter(function (r) {
|
|
41
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
42
|
-
})), t.push.apply(t, o);
|
|
43
|
-
}
|
|
44
|
-
return t;
|
|
45
|
-
}
|
|
46
|
-
function _objectSpread2(e) {
|
|
47
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
48
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
49
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
50
|
-
_defineProperty(e, r, t[r]);
|
|
51
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
52
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return e;
|
|
56
|
-
}
|
|
57
|
-
function _toPrimitive(t, r) {
|
|
58
|
-
if ("object" != typeof t || !t) return t;
|
|
59
|
-
if (typeof Symbol === "function" && t instanceof Symbol) return t;
|
|
60
|
-
var e = t[Symbol.toPrimitive];
|
|
61
|
-
if (void 0 !== e) {
|
|
62
|
-
var i = e.call(t, r);
|
|
63
|
-
if ("object" != typeof i) return i;
|
|
64
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
65
|
-
}
|
|
66
|
-
return ("string" === r ? String : Number)(t);
|
|
67
|
-
}
|
|
68
|
-
function _toPropertyKey(t) {
|
|
69
|
-
var i = _toPrimitive(t, "string");
|
|
70
|
-
return "symbol" == typeof i ? i : i + "";
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
exports.asyncToGenerator = _asyncToGenerator;
|
|
74
|
-
exports.defineProperty = _defineProperty;
|
|
75
|
-
exports.objectSpread2 = _objectSpread2;
|
|
76
|
-
exports.toPrimitive = _toPrimitive;
|
|
77
|
-
exports.toPropertyKey = _toPropertyKey;
|