@mattebox/player-ads 1.0.0 → 1.1.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.
Files changed (31) hide show
  1. package/dist/ad-info.js.map +1 -1
  2. package/dist/ad-link.js.map +1 -1
  3. package/dist/ad-progress.js.map +1 -1
  4. package/dist/ad-skip-button.js.map +1 -1
  5. package/dist/beacons.js.map +1 -1
  6. package/dist/cdn/mattebox-player-ads.min.js +1 -1
  7. package/dist/component.js +2 -2
  8. package/dist/component.js.map +1 -1
  9. package/dist/controller.d.ts +22 -0
  10. package/dist/controller.d.ts.map +1 -1
  11. package/dist/controller.js +48 -17
  12. package/dist/controller.js.map +1 -1
  13. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/asyncToGenerator.js +1 -1
  14. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/defineProperty.js +1 -1
  15. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/objectSpread2.js +1 -1
  16. package/dist/es2015/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
  17. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/toPropertyKey.js +1 -1
  18. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/typeof.js +1 -1
  19. package/dist/es2015/component.js +2 -2
  20. package/dist/es2015/controller.js +49 -21
  21. package/dist/es2015/index.js +4 -3
  22. package/dist/es2015/vast.js +2 -2
  23. package/dist/host.d.ts +1 -1
  24. package/dist/host.js.map +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +4 -3
  28. package/dist/index.js.map +1 -1
  29. package/dist/shared.js.map +1 -1
  30. package/package.json +2 -2
  31. package/dist/es2015/_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/toPrimitive.js +0 -13
@@ -1,8 +1,8 @@
1
1
  import { expand, send } from "./beacons.js";
2
- import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/objectSpread2.js";
3
- import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/asyncToGenerator.js";
4
2
  import { fetchText, resolveVast } from "./vast.js";
5
3
  import { offsetTime, parseVmap } from "./vmap.js";
4
+ import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
5
+ import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/asyncToGenerator.js";
6
6
  // src/controller.ts
7
7
  /** Seconds before a break at which its VAST is fetched: fresh, and in time for the preload. */
8
8
  const LOOKAHEAD = 10;
@@ -75,6 +75,10 @@ var Controller = class {
75
75
  this.own = /* @__PURE__ */ new Set();
76
76
  this.configure(options);
77
77
  this.plans = /* @__PURE__ */ new Map();
78
+ this.given = {
79
+ urls: [],
80
+ breaks: []
81
+ };
78
82
  this.current = null;
79
83
  this.watchers = /* @__PURE__ */ new Set();
80
84
  this.offEngine = null;
@@ -96,7 +100,7 @@ var Controller = class {
96
100
  /** Follows the player until `detach`. */
97
101
  attach() {
98
102
  const player = this.player;
99
- const video = player.video;
103
+ const video = player.media;
100
104
  const onSource = () => {
101
105
  this.reset();
102
106
  this.bindEngine();
@@ -109,6 +113,7 @@ var Controller = class {
109
113
  this.tick();
110
114
  };
111
115
  const onPlay = () => {
116
+ if (this.away()) return;
112
117
  if (this.current === null && this.pending("start")) {
113
118
  this.holding = true;
114
119
  video.pause();
@@ -123,6 +128,7 @@ var Controller = class {
123
128
  };
124
129
  const onEnded = () => {
125
130
  var _this$current, _this$engineBreaks;
131
+ if (this.away() && this.current === null) return;
126
132
  if (((_this$current = this.current) === null || _this$current === void 0 ? void 0 : _this$current.interrupt) === true) {
127
133
  this.nextProgressive();
128
134
  return;
@@ -208,11 +214,11 @@ var Controller = class {
208
214
  var _current$plan$ads, _current$plan2, _current$entry$assets, _current$entry, _current$entry$start, _current$entry2, _current$entry$covers, _current$entry3, _ref, _current$ad$duration, _current$ad, _assets$current$index, _ref2, _current$ad$skipOffse, _current$ad2, _current$creative, _current$entry4, _current$ad$clickThro, _current$ad3, _current$creative2, _ref3, _current$plan$id, _current$plan3, _current$entry5, _current$entry6;
209
215
  const current = this.current;
210
216
  if (current === null) return null;
211
- const media = this.player.video;
217
+ const media = this.player.media;
212
218
  const ads = (_current$plan$ads = (_current$plan2 = current.plan) === null || _current$plan2 === void 0 ? void 0 : _current$plan2.ads) !== null && _current$plan$ads !== void 0 ? _current$plan$ads : [];
213
219
  const assets = (_current$entry$assets = (_current$entry = current.entry) === null || _current$entry === void 0 ? void 0 : _current$entry.assets) !== null && _current$entry$assets !== void 0 ? _current$entry$assets : [];
214
220
  const total = Math.max(1, ads.length || assets.length);
215
- const time = current.stitched ? this.player.video.currentTime - ((_current$entry$start = (_current$entry2 = current.entry) === null || _current$entry2 === void 0 ? void 0 : _current$entry2.start) !== null && _current$entry$start !== void 0 ? _current$entry$start : 0) : media.currentTime;
221
+ const time = current.stitched ? this.player.media.currentTime - ((_current$entry$start = (_current$entry2 = current.entry) === null || _current$entry2 === void 0 ? void 0 : _current$entry2.start) !== null && _current$entry$start !== void 0 ? _current$entry$start : 0) : media.currentTime;
216
222
  const duration = current.stitched ? (_current$entry$covers = (_current$entry3 = current.entry) === null || _current$entry3 === void 0 ? void 0 : _current$entry3.covers) !== null && _current$entry$covers !== void 0 ? _current$entry$covers : NaN : Number.isFinite(media.duration) ? media.duration : (_ref = (_current$ad$duration = (_current$ad = current.ad) === null || _current$ad === void 0 ? void 0 : _current$ad.duration) !== null && _current$ad$duration !== void 0 ? _current$ad$duration : (_assets$current$index = assets[current.index]) === null || _assets$current$index === void 0 ? void 0 : _assets$current$index.duration) !== null && _ref !== void 0 ? _ref : NaN;
217
223
  const later = (ads.length > 0 ? ads.map((ad) => ad.duration) : assets.map((asset) => {
218
224
  var _asset$duration;
@@ -247,10 +253,26 @@ var Controller = class {
247
253
  this.watchers.delete(fn);
248
254
  };
249
255
  }
256
+ /** The schedule the page gave, for the page of a device. Undefined without one. */
257
+ remoteData() {
258
+ const { urls, breaks } = this.given;
259
+ if (urls.length === 0 && breaks.length === 0) return void 0;
260
+ return _objectSpread2(_objectSpread2({}, urls.length === 0 ? {} : { urls: [...urls] }), breaks.length === 0 ? {} : { breaks: [...breaks] });
261
+ }
262
+ /**
263
+ * A device plays in the video's place, and it is not the video itself as
264
+ * under AirPlay. The device's own page plays the ads then, so nothing
265
+ * starts here: the same break would play twice.
266
+ */
267
+ away() {
268
+ const target = this.player.casting;
269
+ return target !== null && target.kind !== "airplay";
270
+ }
250
271
  load(source) {
251
272
  var _this = this;
252
273
  return _asyncToGenerator(function* () {
253
274
  const url = new URL(source, location.href).href;
275
+ _this.given.urls.push(url);
254
276
  let text;
255
277
  _this.fetching += 1;
256
278
  try {
@@ -278,6 +300,7 @@ var Controller = class {
278
300
  })();
279
301
  }
280
302
  schedule(breaks) {
303
+ this.given.breaks.push(...breaks);
281
304
  for (const entry of breaks) {
282
305
  var _entry$id;
283
306
  this.seq += 1;
@@ -306,7 +329,7 @@ var Controller = class {
306
329
  this.track(current, "skip");
307
330
  this.emit("adskip", this.detail());
308
331
  if (current.stitched && current.entry !== null) {
309
- this.player.video.currentTime = current.entry.start + current.entry.covers;
332
+ this.player.media.currentTime = current.entry.start + current.entry.covers;
310
333
  return;
311
334
  }
312
335
  (_this$engineBreaks2 = this.engineBreaks()) === null || _this$engineBreaks2 === void 0 || _this$engineBreaks2.skip();
@@ -319,7 +342,7 @@ var Controller = class {
319
342
  for (const url of (_current$ad$clickTrac = (_current$ad5 = current.ad) === null || _current$ad5 === void 0 ? void 0 : _current$ad5.clickTracking) !== null && _current$ad$clickTrac !== void 0 ? _current$ad$clickTrac : []) this.send(expand(url, this.macros(current)));
320
343
  this.track(current, "clickTracking");
321
344
  window.open(target, "_blank", "noopener");
322
- this.player.video.pause();
345
+ this.player.media.pause();
323
346
  this.emit("adclick", this.detail());
324
347
  }
325
348
  add(entry) {
@@ -394,11 +417,11 @@ var Controller = class {
394
417
  /** The programme's own time, through a break. */
395
418
  programmeTime() {
396
419
  var _this$engineBreaks$pr, _this$engineBreaks4;
397
- return (_this$engineBreaks$pr = (_this$engineBreaks4 = this.engineBreaks()) === null || _this$engineBreaks4 === void 0 ? void 0 : _this$engineBreaks4.primary.currentTime) !== null && _this$engineBreaks$pr !== void 0 ? _this$engineBreaks$pr : this.player.video.currentTime;
420
+ return (_this$engineBreaks$pr = (_this$engineBreaks4 = this.engineBreaks()) === null || _this$engineBreaks4 === void 0 ? void 0 : _this$engineBreaks4.primary.currentTime) !== null && _this$engineBreaks$pr !== void 0 ? _this$engineBreaks$pr : this.player.media.currentTime;
398
421
  }
399
422
  programmeDuration() {
400
423
  var _this$engineBreaks$pr2, _this$engineBreaks5;
401
- return (_this$engineBreaks$pr2 = (_this$engineBreaks5 = this.engineBreaks()) === null || _this$engineBreaks5 === void 0 ? void 0 : _this$engineBreaks5.primary.duration) !== null && _this$engineBreaks$pr2 !== void 0 ? _this$engineBreaks$pr2 : this.player.video.duration;
424
+ return (_this$engineBreaks$pr2 = (_this$engineBreaks5 = this.engineBreaks()) === null || _this$engineBreaks5 === void 0 ? void 0 : _this$engineBreaks5.primary.duration) !== null && _this$engineBreaks$pr2 !== void 0 ? _this$engineBreaks$pr2 : this.player.media.duration;
402
425
  }
403
426
  /** Fetches the VAST of each break as it comes near, and starts the progressive ones on time. */
404
427
  tick() {
@@ -407,6 +430,7 @@ var Controller = class {
407
430
  this.followAd(this.current);
408
431
  return;
409
432
  }
433
+ if (this.away()) return;
410
434
  const time = this.programmeTime();
411
435
  const duration = this.programmeDuration();
412
436
  const seeked = Math.abs(time - this.lastTime) > 2;
@@ -432,7 +456,7 @@ var Controller = class {
432
456
  const playable = [];
433
457
  const files = [];
434
458
  for (const ad of result.ads) {
435
- const file = pick(ad, engine, _this2.player.video, height);
459
+ const file = pick(ad, engine, _this2.player.media, height);
436
460
  if (file === void 0 || !STREAMING.test(file.type) && _this2.progressive === "skip") {
437
461
  for (const url of ad.errors) _this2.send(expand(url, { errorCode: 403 }));
438
462
  continue;
@@ -464,9 +488,9 @@ var Controller = class {
464
488
  plan.status = "stream";
465
489
  const offsets = playable.flatMap((ad) => ad.skipOffset === void 0 ? [] : [ad.skipOffset]);
466
490
  if (_this2.holding) {
467
- var _this$player$video$pl;
491
+ var _this$player$media$pl;
468
492
  _this2.holding = false;
469
- (_this$player$video$pl = _this2.player.video.play()) === null || _this$player$video$pl === void 0 || _this$player$video$pl.catch(() => {});
493
+ (_this$player$media$pl = _this2.player.media.play()) === null || _this$player$media$pl === void 0 || _this$player$media$pl.catch(() => {});
470
494
  }
471
495
  (_this$engineBreaks6 = _this2.engineBreaks()) === null || _this$engineBreaks6 === void 0 || _this$engineBreaks6.schedule(_objectSpread2(_objectSpread2(_objectSpread2({
472
496
  id: plan.id,
@@ -487,19 +511,19 @@ var Controller = class {
487
511
  return;
488
512
  }
489
513
  plan.status = "progressive";
490
- if (plan.offset === "start" && (_this2.holding || !_this2.player.video.paused)) {
514
+ if (plan.offset === "start" && (_this2.holding || !_this2.player.media.paused)) {
491
515
  _this2.holding = false;
492
- _this2.player.video.pause();
516
+ _this2.player.media.pause();
493
517
  _this2.startProgressive(plan);
494
518
  }
495
519
  })();
496
520
  }
497
521
  /** Lets the programme play once no pre-roll holds it. */
498
522
  release() {
499
- var _this$player$video$pl2;
523
+ var _this$player$media$pl2;
500
524
  if (!this.holding || this.pending("start")) return;
501
525
  this.holding = false;
502
- (_this$player$video$pl2 = this.player.video.play()) === null || _this$player$video$pl2 === void 0 || _this$player$video$pl2.catch(() => {});
526
+ (_this$player$media$pl2 = this.player.media.play()) === null || _this$player$media$pl2 === void 0 || _this$player$media$pl2.catch(() => {});
503
527
  }
504
528
  bindEngine() {
505
529
  var _this$offEngine2;
@@ -540,7 +564,7 @@ var Controller = class {
540
564
  /** After a drag: in an ad the stream plays, it starts; out of it, the ad that showed ends. */
541
565
  landed() {
542
566
  var _this$engineBreaks$br2, _this$engineBreaks7, _current$entry7;
543
- const time = this.player.video.currentTime;
567
+ const time = this.player.media.currentTime;
544
568
  const inside = ((_this$engineBreaks$br2 = (_this$engineBreaks7 = this.engineBreaks()) === null || _this$engineBreaks7 === void 0 ? void 0 : _this$engineBreaks7.breaks) !== null && _this$engineBreaks$br2 !== void 0 ? _this$engineBreaks$br2 : []).find((entry) => entry.assets.length === 0 && entry.assetList === void 0 && time >= entry.start && time < entry.start + Math.max(entry.covers, .001));
545
569
  const current = this.current;
546
570
  if ((current === null || current === void 0 ? void 0 : current.stitched) === true && ((_current$entry7 = current.entry) === null || _current$entry7 === void 0 ? void 0 : _current$entry7.id) !== (inside === null || inside === void 0 ? void 0 : inside.id)) this.breakEnd();
@@ -692,8 +716,8 @@ var Controller = class {
692
716
  /** The ad's own time: progressive quartiles, progress beacons, the stream's callbacks, viewability. */
693
717
  followAd(current) {
694
718
  var _current$entry$start2, _current$entry10, _current$ad$tracking, _current$ad6, _current$entry$assets2, _current$entry11;
695
- const media = this.player.video;
696
- const time = current.stitched ? this.player.video.currentTime - ((_current$entry$start2 = (_current$entry10 = current.entry) === null || _current$entry10 === void 0 ? void 0 : _current$entry10.start) !== null && _current$entry$start2 !== void 0 ? _current$entry$start2 : 0) : media.currentTime;
719
+ const media = this.player.media;
720
+ const time = current.stitched ? this.player.media.currentTime - ((_current$entry$start2 = (_current$entry10 = current.entry) === null || _current$entry10 === void 0 ? void 0 : _current$entry10.start) !== null && _current$entry$start2 !== void 0 ? _current$entry$start2 : 0) : media.currentTime;
697
721
  if (current.interrupt && !media.seeking) current.last = time;
698
722
  if (current.interrupt && Number.isFinite(media.duration) && media.duration > 0) {
699
723
  const reached = Math.floor(time / media.duration * 4);
@@ -720,7 +744,7 @@ var Controller = class {
720
744
  }
721
745
  adResumed(media) {
722
746
  const current = this.current;
723
- if (current === null || !current.paused || media !== this.player.video) return;
747
+ if (current === null || !current.paused || media !== this.player.media) return;
724
748
  current.paused = false;
725
749
  this.track(current, "resume");
726
750
  }
@@ -775,7 +799,7 @@ var Controller = class {
775
799
  }
776
800
  macros(current) {
777
801
  var _current$plan8;
778
- const media = this.player.video;
802
+ const media = this.player.media;
779
803
  const offset = (_current$plan8 = current.plan) === null || _current$plan8 === void 0 ? void 0 : _current$plan8.offset;
780
804
  return _objectSpread2(_objectSpread2({
781
805
  mediaPlayhead: current.at,
@@ -813,6 +837,10 @@ var Controller = class {
813
837
  if (this.current !== null) this.player.removeAttribute("ad");
814
838
  this.current = null;
815
839
  this.plans = /* @__PURE__ */ new Map();
840
+ this.given = {
841
+ urls: [],
842
+ breaks: []
843
+ };
816
844
  this.done = /* @__PURE__ */ new Set();
817
845
  this.own = /* @__PURE__ */ new Set();
818
846
  this.player.breaks.set("ads", []);
@@ -1,9 +1,9 @@
1
- import { resolveVast } from "./vast.js";
2
- import { controllerFor } from "./controller.js";
3
1
  import { MbxAdInfo } from "./ad-info.js";
4
2
  import { MbxAdLink } from "./ad-link.js";
5
3
  import { MbxAdProgress } from "./ad-progress.js";
6
4
  import { MbxAdSkipButton } from "./ad-skip-button.js";
5
+ import { controllerFor } from "./controller.js";
6
+ import { resolveVast } from "./vast.js";
7
7
  import interstitials from "mattebox/stages/interstitials";
8
8
  // src/index.ts
9
9
  const AD_INFO = "mbx-ad-info";
@@ -57,7 +57,8 @@ function ads(options = {}) {
57
57
  attach(player) {
58
58
  addStyle();
59
59
  return controllerFor(player, options).attach();
60
- }
60
+ },
61
+ remoteData: (player) => controllerFor(player).remoteData()
61
62
  };
62
63
  }
63
64
  /** The ads of `player`: its schedule, the ad that plays, skip and click. */
@@ -1,5 +1,5 @@
1
- import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/objectSpread2.js";
2
- import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/asyncToGenerator.js";
1
+ import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js";
2
+ import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/asyncToGenerator.js";
3
3
  /** Milliseconds a VAST request may take before error 301. */
4
4
  const TIMEOUT = 5e3;
5
5
  const children = (parent, name) => Array.from(parent.children).filter((child) => child.localName === name);
package/dist/host.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The contract of a control of the page's own, as guide chapter 03 of the
3
3
  * player states it: the nearest <mattebox-player> above, through shadow
4
- * hosts, then read for `video`, `engine`, `player` and `error`, with
4
+ * hosts, then read for `media`, `engine`, `player` and `error`, with
5
5
  * `sourcechange` heard on it. This package implements the contract from
6
6
  * outside, on purpose: the player exports no base class, and a control that
7
7
  * needs more than this surface has found a gap in the player's API.
package/dist/host.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","names":[],"sources":["../src/host.ts"],"sourcesContent":["/**\n * The contract of a control of the page's own, as guide chapter 03 of the\n * player states it: the nearest <mattebox-player> above, through shadow\n * hosts, then read for `video`, `engine`, `player` and `error`, with\n * `sourcechange` heard on it. This package implements the contract from\n * outside, on purpose: the player exports no base class, and a control that\n * needs more than this surface has found a gap in the player's API.\n */\nimport type { PlayerHost } from '@mattebox/player';\n\nexport type { PlayerHost };\n\nexport const PLAYER = 'mattebox-player';\n\n/** The parent, or the host of the shadow root `node` sits in, or null at the document. */\nfunction above(node: Node): Node | null {\n const parent = node.parentNode;\n if (parent !== null) return parent;\n return node instanceof ShadowRoot ? node.host : null;\n}\n\n/** The nearest player above `node`, or null outside one. It may not be upgraded yet. */\nexport function findPlayer(node: Node): HTMLElement | null {\n let current: Node | null = node;\n while (current !== null) {\n if (current instanceof HTMLElement && current.localName === PLAYER) return current;\n current = above(current);\n }\n return null;\n}\n"],"mappings":";AAYA,MAAa,SAAS;;AAGtB,SAAS,MAAM,MAAyB;CACtC,MAAM,SAAS,KAAK;CACpB,IAAI,WAAW,MAAM,OAAO;CAC5B,OAAO,gBAAgB,aAAa,KAAK,OAAO;AAClD;;AAGA,SAAgB,WAAW,MAAgC;CACzD,IAAI,UAAuB;CAC3B,OAAO,YAAY,MAAM;EACvB,IAAI,mBAAmB,eAAe,QAAQ,cAAA,mBAAsB,OAAO;EAC3E,UAAU,MAAM,OAAO;CACzB;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"host.js","names":[],"sources":["../src/host.ts"],"sourcesContent":["/**\n * The contract of a control of the page's own, as guide chapter 03 of the\n * player states it: the nearest <mattebox-player> above, through shadow\n * hosts, then read for `media`, `engine`, `player` and `error`, with\n * `sourcechange` heard on it. This package implements the contract from\n * outside, on purpose: the player exports no base class, and a control that\n * needs more than this surface has found a gap in the player's API.\n */\nimport type { PlayerHost } from '@mattebox/player';\n\nexport type { PlayerHost };\n\nexport const PLAYER = 'mattebox-player';\n\n/** The parent, or the host of the shadow root `node` sits in, or null at the document. */\nfunction above(node: Node): Node | null {\n const parent = node.parentNode;\n if (parent !== null) return parent;\n return node instanceof ShadowRoot ? node.host : null;\n}\n\n/** The nearest player above `node`, or null outside one. It may not be upgraded yet. */\nexport function findPlayer(node: Node): HTMLElement | null {\n let current: Node | null = node;\n while (current !== null) {\n if (current instanceof HTMLElement && current.localName === PLAYER) return current;\n current = above(current);\n }\n return null;\n}\n"],"mappings":";AAYA,MAAa,SAAS;;AAGtB,SAAS,MAAM,MAAyB;CACtC,MAAM,SAAS,KAAK;CACpB,IAAI,WAAW,MAAM,OAAO;CAC5B,OAAO,gBAAgB,aAAa,KAAK,OAAO;AAClD;;AAGA,SAAgB,WAAW,MAAgC;CACzD,IAAI,UAAuB;CAC3B,OAAO,YAAY,MAAM;EACvB,IAAI,mBAAmB,eAAe,QAAQ,cAAA,mBAAsB,OAAO;EAC3E,UAAU,MAAM,OAAO;CACzB;CACA,OAAO;AACT"}
package/dist/index.d.ts CHANGED
@@ -17,7 +17,7 @@ export { MbxAdInfo } from './ad-info.js';
17
17
  export { MbxAdLink } from './ad-link.js';
18
18
  export { MbxAdProgress } from './ad-progress.js';
19
19
  export { MbxAdSkipButton } from './ad-skip-button.js';
20
- export type { AdBreakInput, AdOpportunity, AdState, AdsApi, AdsOptions, } from './controller.js';
20
+ export type { AdBreakInput, AdOpportunity, AdState, AdsApi, AdsOptions, AdsRemoteData, } from './controller.js';
21
21
  export type { AdsMessages } from './messages.js';
22
22
  export type { VastAd, VastCompanion, VastMediaFile, VastResult, VastTracking, VastVerification, } from './vast.js';
23
23
  export { resolveVast } from './vast.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAiB,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EACV,YAAY,EACZ,aAAa,EACb,OAAO,EACP,MAAM,EACN,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,YAAY,EACZ,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,eAAO,MAAM,OAAO,gBAAgB,CAAC;AACrC,eAAO,MAAM,cAAc,uBAAuB,CAAC;AACnD,eAAO,MAAM,OAAO,gBAAgB,CAAC;AACrC,eAAO,MAAM,WAAW,oBAAoB,CAAC;AA0C7C,uCAAuC;AACvC,wBAAgB,GAAG,CAAC,OAAO,GAAE,UAAe,GAAG,WAAW,CAWzD;AAED,4EAA4E;AAC5E,wBAAgB,KAAK,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAEhD;AASD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,SAAS,CAAC;QACzB,oBAAoB,EAAE,eAAe,CAAC;QACtC,aAAa,EAAE,SAAS,CAAC;QACzB,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAiB,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EACV,YAAY,EACZ,aAAa,EACb,OAAO,EACP,MAAM,EACN,UAAU,EACV,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,YAAY,EACZ,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,eAAO,MAAM,OAAO,gBAAgB,CAAC;AACrC,eAAO,MAAM,cAAc,uBAAuB,CAAC;AACnD,eAAO,MAAM,OAAO,gBAAgB,CAAC;AACrC,eAAO,MAAM,WAAW,oBAAoB,CAAC;AA0C7C,uCAAuC;AACvC,wBAAgB,GAAG,CAAC,OAAO,GAAE,UAAe,GAAG,WAAW,CAYzD;AAED,4EAA4E;AAC5E,wBAAgB,KAAK,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAEhD;AASD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,SAAS,CAAC;QACzB,oBAAoB,EAAE,eAAe,CAAC;QACtC,aAAa,EAAE,SAAS,CAAC;QACzB,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { resolveVast } from "./vast.js";
2
- import { controllerFor } from "./controller.js";
3
1
  import { MbxAdInfo } from "./ad-info.js";
4
2
  import { MbxAdLink } from "./ad-link.js";
5
3
  import { MbxAdProgress } from "./ad-progress.js";
6
4
  import { MbxAdSkipButton } from "./ad-skip-button.js";
5
+ import { controllerFor } from "./controller.js";
6
+ import { resolveVast } from "./vast.js";
7
7
  import interstitials from "mattebox/stages/interstitials";
8
8
  // src/index.ts
9
9
  const AD_INFO = "mbx-ad-info";
@@ -57,7 +57,8 @@ function ads(options = {}) {
57
57
  attach(player) {
58
58
  addStyle();
59
59
  return controllerFor(player, options).attach();
60
- }
60
+ },
61
+ remoteData: (player) => controllerFor(player).remoteData()
61
62
  };
62
63
  }
63
64
  /** The ads of `player`: its schedule, the ad that plays, skip and click. */
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @mattebox/player-ads: ads in <mattebox-player>. `ads()` is an add-on for\n * `MatteboxPlayerElement.define({ addons: [ads()] })`: it adds the engine's\n * interstitials stage to every player, follows each player's breaks, reads\n * VAST and VMAP, sends the beacons, and hides the programme's own controls\n * while an ad plays. <mbx-ad-info>, <mbx-ad-skip-button> and <mbx-ad-link>\n * draw the ad. Importing this module registers the three elements; that is\n * the package's one side effect.\n */\nimport type { PlayerAddon, PlayerHost } from '@mattebox/player';\nimport interstitials from 'mattebox/stages/interstitials';\nimport { MbxAdInfo } from './ad-info.js';\nimport { MbxAdLink } from './ad-link.js';\nimport { MbxAdProgress } from './ad-progress.js';\nimport { MbxAdSkipButton } from './ad-skip-button.js';\nimport { type AdsApi, type AdsOptions, controllerFor } from './controller.js';\n\nexport { MbxAdInfo } from './ad-info.js';\nexport { MbxAdLink } from './ad-link.js';\nexport { MbxAdProgress } from './ad-progress.js';\nexport { MbxAdSkipButton } from './ad-skip-button.js';\nexport type {\n AdBreakInput,\n AdOpportunity,\n AdState,\n AdsApi,\n AdsOptions,\n} from './controller.js';\nexport type { AdsMessages } from './messages.js';\nexport type {\n VastAd,\n VastCompanion,\n VastMediaFile,\n VastResult,\n VastTracking,\n VastVerification,\n} from './vast.js';\nexport { resolveVast } from './vast.js';\n\nexport const AD_INFO = 'mbx-ad-info';\nexport const AD_SKIP_BUTTON = 'mbx-ad-skip-button';\nexport const AD_LINK = 'mbx-ad-link';\nexport const AD_PROGRESS = 'mbx-ad-progress';\n\n/**\n * While an ad plays the player carries `ad`: the seek bar, the times, the\n * menus and the programme's title would describe what does not play. Play,\n * pause, volume and fullscreen stay, and drive the ad. Plain selectors, not\n * `:is()`, which a 2021 TV lacks.\n */\nconst DURING_AD = [\n 'mbx-seek-bar',\n 'mbx-current-time',\n 'mbx-duration',\n 'mbx-remaining-time',\n 'mbx-chapters-menu',\n 'mbx-marker-button',\n 'mbx-quality-menu',\n 'mbx-audio-menu',\n 'mbx-subtitles-menu',\n 'mbx-video-menu',\n 'mbx-speed-menu',\n 'mbx-live-button',\n 'mbx-scan-button',\n 'mbx-skip-button',\n 'mbx-title',\n 'mbx-up-next',\n];\nconst AD_ELEMENTS = ['mbx-ad-info', 'mbx-ad-skip-button', 'mbx-ad-link', 'mbx-ad-progress'];\nconst HIDDEN = `${[\n // Not during a drag: the seek bar that drags must stay under the pointer.\n // Not for a break the stream plays with the controls kept, `ad=\"stitched\"`.\n ...DURING_AD.map((name) => `mattebox-player[ad]:not([ad=\"stitched\"]):not([scrubbing]) ${name}`),\n ...AD_ELEMENTS.map((name) => `mattebox-player:not([ad]) ${name}`),\n].join(',')}{display:none}`;\n\nfunction addStyle(): void {\n if (document.getElementById('mbx-ads-style') !== null) return;\n const node = document.createElement('style');\n node.id = 'mbx-ads-style';\n node.textContent = HIDDEN;\n document.head.append(node);\n}\n\n/** The add-on: pass it in `addons`. */\nexport function ads(options: AdsOptions = {}): PlayerAddon {\n return {\n name: 'ads',\n stages: () => [interstitials()],\n // Safari's own HLS plays interstitials itself and reports nothing.\n engine: true,\n attach(player) {\n addStyle();\n return controllerFor(player, options).attach();\n },\n };\n}\n\n/** The ads of `player`: its schedule, the ad that plays, skip and click. */\nexport function adsOf(player: PlayerHost): AdsApi {\n return controllerFor(player);\n}\n\nif (customElements.get(AD_INFO) === undefined) customElements.define(AD_INFO, MbxAdInfo);\nif (customElements.get(AD_SKIP_BUTTON) === undefined)\n customElements.define(AD_SKIP_BUTTON, MbxAdSkipButton);\nif (customElements.get(AD_LINK) === undefined) customElements.define(AD_LINK, MbxAdLink);\nif (customElements.get(AD_PROGRESS) === undefined)\n customElements.define(AD_PROGRESS, MbxAdProgress);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mbx-ad-info': MbxAdInfo;\n 'mbx-ad-skip-button': MbxAdSkipButton;\n 'mbx-ad-link': MbxAdLink;\n 'mbx-ad-progress': MbxAdProgress;\n }\n}\n"],"mappings":";;;;;;;;AAuCA,MAAa,UAAU;AACvB,MAAa,iBAAiB;AAC9B,MAAa,UAAU;AACvB,MAAa,cAAc;;;;;;;AAQ3B,MAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,cAAc;CAAC;CAAe;CAAsB;CAAe;AAAiB;AAC1F,MAAM,SAAS,GAAG,CAGhB,GAAG,UAAU,KAAK,SAAS,6DAA6D,MAAM,GAC9F,GAAG,YAAY,KAAK,SAAS,6BAA6B,MAAM,CAClE,CAAC,CAAC,KAAK,GAAG,EAAE;AAEZ,SAAS,WAAiB;CACxB,IAAI,SAAS,eAAe,eAAe,MAAM,MAAM;CACvD,MAAM,OAAO,SAAS,cAAc,OAAO;CAC3C,KAAK,KAAK;CACV,KAAK,cAAc;CACnB,SAAS,KAAK,OAAO,IAAI;AAC3B;;AAGA,SAAgB,IAAI,UAAsB,CAAC,GAAgB;CACzD,OAAO;EACL,MAAM;EACN,cAAc,CAAC,cAAc,CAAC;EAE9B,QAAQ;EACR,OAAO,QAAQ;GACb,SAAS;GACT,OAAO,cAAc,QAAQ,OAAO,CAAC,CAAC,OAAO;EAC/C;CACF;AACF;;AAGA,SAAgB,MAAM,QAA4B;CAChD,OAAO,cAAc,MAAM;AAC7B;AAEA,IAAI,eAAe,IAAA,aAAW,MAAM,KAAA,GAAW,eAAe,OAAO,SAAS,SAAS;AACvF,IAAI,eAAe,IAAA,oBAAkB,MAAM,KAAA,GACzC,eAAe,OAAO,gBAAgB,eAAe;AACvD,IAAI,eAAe,IAAA,aAAW,MAAM,KAAA,GAAW,eAAe,OAAO,SAAS,SAAS;AACvF,IAAI,eAAe,IAAA,iBAAe,MAAM,KAAA,GACtC,eAAe,OAAO,aAAa,aAAa"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @mattebox/player-ads: ads in <mattebox-player>. `ads()` is an add-on for\n * `MatteboxPlayerElement.define({ addons: [ads()] })`: it adds the engine's\n * interstitials stage to every player, follows each player's breaks, reads\n * VAST and VMAP, sends the beacons, and hides the programme's own controls\n * while an ad plays. <mbx-ad-info>, <mbx-ad-skip-button> and <mbx-ad-link>\n * draw the ad. Importing this module registers the three elements; that is\n * the package's one side effect.\n */\nimport type { PlayerAddon, PlayerHost } from '@mattebox/player';\nimport interstitials from 'mattebox/stages/interstitials';\nimport { MbxAdInfo } from './ad-info.js';\nimport { MbxAdLink } from './ad-link.js';\nimport { MbxAdProgress } from './ad-progress.js';\nimport { MbxAdSkipButton } from './ad-skip-button.js';\nimport { type AdsApi, type AdsOptions, controllerFor } from './controller.js';\n\nexport { MbxAdInfo } from './ad-info.js';\nexport { MbxAdLink } from './ad-link.js';\nexport { MbxAdProgress } from './ad-progress.js';\nexport { MbxAdSkipButton } from './ad-skip-button.js';\nexport type {\n AdBreakInput,\n AdOpportunity,\n AdState,\n AdsApi,\n AdsOptions,\n AdsRemoteData,\n} from './controller.js';\nexport type { AdsMessages } from './messages.js';\nexport type {\n VastAd,\n VastCompanion,\n VastMediaFile,\n VastResult,\n VastTracking,\n VastVerification,\n} from './vast.js';\nexport { resolveVast } from './vast.js';\n\nexport const AD_INFO = 'mbx-ad-info';\nexport const AD_SKIP_BUTTON = 'mbx-ad-skip-button';\nexport const AD_LINK = 'mbx-ad-link';\nexport const AD_PROGRESS = 'mbx-ad-progress';\n\n/**\n * While an ad plays the player carries `ad`: the seek bar, the times, the\n * menus and the programme's title would describe what does not play. Play,\n * pause, volume and fullscreen stay, and drive the ad. Plain selectors, not\n * `:is()`, which a 2021 TV lacks.\n */\nconst DURING_AD = [\n 'mbx-seek-bar',\n 'mbx-current-time',\n 'mbx-duration',\n 'mbx-remaining-time',\n 'mbx-chapters-menu',\n 'mbx-marker-button',\n 'mbx-quality-menu',\n 'mbx-audio-menu',\n 'mbx-subtitles-menu',\n 'mbx-video-menu',\n 'mbx-speed-menu',\n 'mbx-live-button',\n 'mbx-scan-button',\n 'mbx-skip-button',\n 'mbx-title',\n 'mbx-up-next',\n];\nconst AD_ELEMENTS = ['mbx-ad-info', 'mbx-ad-skip-button', 'mbx-ad-link', 'mbx-ad-progress'];\nconst HIDDEN = `${[\n // Not during a drag: the seek bar that drags must stay under the pointer.\n // Not for a break the stream plays with the controls kept, `ad=\"stitched\"`.\n ...DURING_AD.map((name) => `mattebox-player[ad]:not([ad=\"stitched\"]):not([scrubbing]) ${name}`),\n ...AD_ELEMENTS.map((name) => `mattebox-player:not([ad]) ${name}`),\n].join(',')}{display:none}`;\n\nfunction addStyle(): void {\n if (document.getElementById('mbx-ads-style') !== null) return;\n const node = document.createElement('style');\n node.id = 'mbx-ads-style';\n node.textContent = HIDDEN;\n document.head.append(node);\n}\n\n/** The add-on: pass it in `addons`. */\nexport function ads(options: AdsOptions = {}): PlayerAddon {\n return {\n name: 'ads',\n stages: () => [interstitials()],\n // Safari's own HLS plays interstitials itself and reports nothing.\n engine: true,\n attach(player) {\n addStyle();\n return controllerFor(player, options).attach();\n },\n remoteData: (player) => controllerFor(player).remoteData(),\n };\n}\n\n/** The ads of `player`: its schedule, the ad that plays, skip and click. */\nexport function adsOf(player: PlayerHost): AdsApi {\n return controllerFor(player);\n}\n\nif (customElements.get(AD_INFO) === undefined) customElements.define(AD_INFO, MbxAdInfo);\nif (customElements.get(AD_SKIP_BUTTON) === undefined)\n customElements.define(AD_SKIP_BUTTON, MbxAdSkipButton);\nif (customElements.get(AD_LINK) === undefined) customElements.define(AD_LINK, MbxAdLink);\nif (customElements.get(AD_PROGRESS) === undefined)\n customElements.define(AD_PROGRESS, MbxAdProgress);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mbx-ad-info': MbxAdInfo;\n 'mbx-ad-skip-button': MbxAdSkipButton;\n 'mbx-ad-link': MbxAdLink;\n 'mbx-ad-progress': MbxAdProgress;\n }\n}\n"],"mappings":";;;;;;;;AAwCA,MAAa,UAAU;AACvB,MAAa,iBAAiB;AAC9B,MAAa,UAAU;AACvB,MAAa,cAAc;;;;;;;AAQ3B,MAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,cAAc;CAAC;CAAe;CAAsB;CAAe;AAAiB;AAC1F,MAAM,SAAS,GAAG,CAGhB,GAAG,UAAU,KAAK,SAAS,6DAA6D,MAAM,GAC9F,GAAG,YAAY,KAAK,SAAS,6BAA6B,MAAM,CAClE,CAAC,CAAC,KAAK,GAAG,EAAE;AAEZ,SAAS,WAAiB;CACxB,IAAI,SAAS,eAAe,eAAe,MAAM,MAAM;CACvD,MAAM,OAAO,SAAS,cAAc,OAAO;CAC3C,KAAK,KAAK;CACV,KAAK,cAAc;CACnB,SAAS,KAAK,OAAO,IAAI;AAC3B;;AAGA,SAAgB,IAAI,UAAsB,CAAC,GAAgB;CACzD,OAAO;EACL,MAAM;EACN,cAAc,CAAC,cAAc,CAAC;EAE9B,QAAQ;EACR,OAAO,QAAQ;GACb,SAAS;GACT,OAAO,cAAc,QAAQ,OAAO,CAAC,CAAC,OAAO;EAC/C;EACA,aAAa,WAAW,cAAc,MAAM,CAAC,CAAC,WAAW;CAC3D;AACF;;AAGA,SAAgB,MAAM,QAA4B;CAChD,OAAO,cAAc,MAAM;AAC7B;AAEA,IAAI,eAAe,IAAA,aAAW,MAAM,KAAA,GAAW,eAAe,OAAO,SAAS,SAAS;AACvF,IAAI,eAAe,IAAA,oBAAkB,MAAM,KAAA,GACzC,eAAe,OAAO,gBAAgB,eAAe;AACvD,IAAI,eAAe,IAAA,aAAW,MAAM,KAAA,GAAW,eAAe,OAAO,SAAS,SAAS;AACvF,IAAI,eAAe,IAAA,iBAAe,MAAM,KAAA,GACtC,eAAe,OAAO,aAAa,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","names":[],"sources":["../src/shared.ts"],"sourcesContent":["/**\n * What the ad elements share: their style, the text of a template, and the\n * time of the ad. The tokens come through the `--mbx-*` custom properties\n * the player sets, which inherit into every control.\n */\nimport AD_CSS from './ad.css?inline';\n\n/** A `<style>` with the ad elements' style and the element's own placement. */\nexport function style(placement: string): HTMLStyleElement {\n const node = document.createElement('style');\n node.textContent = `${AD_CSS}:host{${placement}}`;\n return node;\n}\n\n/** `text` with each `{name}` replaced by its value. */\nexport function fill(text: string, values: Readonly<Record<string, string | number>>): string {\n return text.replace(/\\{(\\w+)\\}/g, (match, name: string) => String(values[name] ?? match));\n}\n\n/** `m:ss`, the time an ad counts down in. */\nexport function clock(seconds: number): string {\n const whole = Math.max(0, Math.ceil(seconds));\n return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, '0')}`;\n}\n"],"mappings":";;;;;;AAKA,MAAA,SAAA;;AAGA,SAAA,MAAA,WAAA;CACA,MAAA,OAAA,SAAA,cAAA,OAAA;CACA,KAAA,cAAA,GAAA,OAAA,QAAA,UAAA;CACA,OAAA;AACA;;AAGA,SAAA,KAAA,MAAA,QAAA;CACA,OAAA,KAAA,QAAA,eAAA,OAAA,SAAA,OAAA,OAAA,SAAA,KAAA,CAAA;AACA;;AAGA,SAAA,MAAA,SAAA;CACA,MAAA,QAAA,KAAA,IAAA,GAAA,KAAA,KAAA,OAAA,CAAA;CACA,OAAA,GAAA,KAAA,MAAA,QAAA,EAAA,EAAA,GAAA,OAAA,QAAA,EAAA,CAAA,CAAA,SAAA,GAAA,GAAA;AACA"}
1
+ {"version":3,"file":"shared.js","names":[],"sources":["../src/shared.ts"],"sourcesContent":["/**\n * What the ad elements share: their style, the text of a template, and the\n * time of the ad. The tokens come through the `--mbx-*` custom properties\n * the player sets, which inherit into every control.\n */\nimport AD_CSS from './ad.css?inline';\n\n/** A `<style>` with the ad elements' style and the element's own placement. */\nexport function style(placement: string): HTMLStyleElement {\n const node = document.createElement('style');\n node.textContent = `${AD_CSS}:host{${placement}}`;\n return node;\n}\n\n/** `text` with each `{name}` replaced by its value. */\nexport function fill(text: string, values: Readonly<Record<string, string | number>>): string {\n return text.replace(/\\{(\\w+)\\}/g, (match, name: string) => String(values[name] ?? match));\n}\n\n/** `m:ss`, the time an ad counts down in. */\nexport function clock(seconds: number): string {\n const whole = Math.max(0, Math.ceil(seconds));\n return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, '0')}`;\n}\n"],"mappings":";;;;;;AAKA,MAAA,SAAA;;AAGA,SAAgB,MAAM,WAAqC;CACzD,MAAM,OAAO,SAAS,cAAc,OAAO;CAC3C,KAAK,cAAc,GAAG,OAAO,QAAQ,UAAU;CAC/C,OAAO;AACT;;AAGA,SAAgB,KAAK,MAAc,QAA2D;CAC5F,OAAO,KAAK,QAAQ,eAAe,OAAO,SAAiB,OAAO,OAAO,SAAS,KAAK,CAAC;AAC1F;;AAGA,SAAgB,MAAM,SAAyB;CAC7C,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,KAAK,OAAO,CAAC;CAC5C,OAAO,GAAG,KAAK,MAAM,QAAQ,EAAE,EAAE,GAAG,OAAO,QAAQ,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;AACxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mattebox/player-ads",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Ads in <mattebox-player>: HLS interstitials, DASH alternative MPD, SCTE-35 cue-outs, VAST 4 and VMAP, with the ad controls and the beacons.",
5
5
  "author": "Josep Boix Requesens",
6
6
  "repository": {
@@ -56,7 +56,7 @@
56
56
  "release:ci": "semantic-release"
57
57
  },
58
58
  "peerDependencies": {
59
- "@mattebox/player": ">=0.13.0",
59
+ "@mattebox/player": ">=0.15.0",
60
60
  "mattebox": "^0.17.0"
61
61
  }
62
62
  }
@@ -1,13 +0,0 @@
1
- import _typeof from "./typeof.js";
2
- // \0@oxc-project+runtime@0.155.0/helpers/esm/toPrimitive.js
3
- function toPrimitive(t, r) {
4
- if ("object" != _typeof(t) || !t) return t;
5
- var e = t[Symbol.toPrimitive];
6
- if (void 0 !== e) {
7
- var i = e.call(t, r || "default");
8
- if ("object" != _typeof(i)) return i;
9
- throw new TypeError("@@toPrimitive must return a primitive value.");
10
- }
11
- return ("string" === r ? String : Number)(t);
12
- }
13
- export { toPrimitive as default };