@amazon/vinyl 3.2.0 → 3.2.1
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/dist/index.cjs +30 -24
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +30 -24
- package/dist/index.js.map +2 -2
- package/dist/test/integ.es5.js +167 -155
- package/dist/test/integ.js +260 -50
- package/dist/test/integ.js.map +2 -2
- package/dist/types/current/ad/AdControllerImpl.d.ts +18 -2
- package/dist/types/current/ad/AdControllerImpl.d.ts.map +1 -1
- package/dist/types/current/ad/AdControllerImpl.js +42 -20
- package/dist/types/current/playback/createStallMonitor.d.ts.map +1 -1
- package/dist/types/current/playback/createStallMonitor.js +19 -14
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ts3.7/ad/AdControllerImpl.d.ts +18 -2
- package/dist/types/ts4.1/ad/AdControllerImpl.d.ts +18 -2
- package/dist/types/ts4.7/ad/AdControllerImpl.d.ts +18 -2
- package/dist/unit/types/current/ad/AdControllerImpl.test.js +110 -4
- package/dist/unit/types/current/playback/createStallMonitor.test.js +38 -0
- package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/vinylTestUtil/index.js +10 -1
- package/dist/vinylTestUtil/index.js.map +2 -2
- package/dist/vinylTestUtil/types/current/assets/vinylTestAssets.d.ts +5 -0
- package/dist/vinylTestUtil/types/current/assets/vinylTestAssets.d.ts.map +1 -1
- package/dist/vinylTestUtil/types/current/assets/vinylTestAssets.js +9 -0
- package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/vinylTestUtil/types/ts3.7/assets/vinylTestAssets.d.ts +5 -0
- package/dist/vinylTestUtil/types/ts4.1/assets/vinylTestAssets.d.ts +5 -0
- package/dist/vinylTestUtil/types/ts4.7/assets/vinylTestAssets.d.ts +5 -0
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -68,6 +68,7 @@ var AdError = class _AdError extends ReportableError {
|
|
|
68
68
|
|
|
69
69
|
// src/ad/AdControllerImpl.ts
|
|
70
70
|
var AD_START_TOLERANCE = 0.05;
|
|
71
|
+
var PLAYOUT_LIMIT_TOLERANCE = 1;
|
|
71
72
|
var defaultAdControllerImplOptions = {
|
|
72
73
|
adLoadTimeout: 15,
|
|
73
74
|
preloadAheadTime: 10
|
|
@@ -558,23 +559,29 @@ var AdControllerImpl = class extends EventHostImpl {
|
|
|
558
559
|
});
|
|
559
560
|
}
|
|
560
561
|
/**
|
|
561
|
-
*
|
|
562
|
-
*
|
|
562
|
+
* Enforces the break-level playout limit (X-PLAYOUT-LIMIT): a budget shared
|
|
563
|
+
* across all of the break's ads. When cumulative playout reaches it, the
|
|
564
|
+
* whole break ends, dropping any ads that have not started.
|
|
565
|
+
*
|
|
566
|
+
* This is deliberately NOT a per-ad cap. Each ad asset is its own source and
|
|
567
|
+
* ends on its media `ended` (see the 'ended' handler), which is what advances
|
|
568
|
+
* a multi-ad break. Ending an ad at its declared per-ad DURATION instead would
|
|
569
|
+
* truncate the real asset whenever a packager under-declares it — e.g. rounds
|
|
570
|
+
* a 6.732s asset down to a whole-second 6 — cutting off the fractional tail.
|
|
563
571
|
*/
|
|
564
572
|
enforcePlayoutLimits(adState) {
|
|
573
|
+
if (!adState.started) return;
|
|
574
|
+
const { parentBreak } = adState;
|
|
575
|
+
const limit = parentBreak.adBreak.playoutLimit;
|
|
576
|
+
if (limit == null) return;
|
|
565
577
|
const pC = this.deps.playbackController;
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const limit = adBreak.playoutLimit;
|
|
571
|
-
if (limit != null && parentBreak.playoutElapsed + elapsed >= limit) {
|
|
572
|
-
parentBreak.clear();
|
|
573
|
-
this.endAd(adState);
|
|
574
|
-
} else if (ad.duration != null && elapsed >= ad.duration) {
|
|
575
|
-
this.endAd(adState);
|
|
576
|
-
}
|
|
578
|
+
const elapsed = Math.max(0, pC.currentTime - adState.timeStart);
|
|
579
|
+
if (parentBreak.playoutElapsed + elapsed < limit) return;
|
|
580
|
+
if (isFinite(pC.duration) && pC.duration > 0 && pC.duration - pC.currentTime <= PLAYOUT_LIMIT_TOLERANCE) {
|
|
581
|
+
return;
|
|
577
582
|
}
|
|
583
|
+
parentBreak.clear();
|
|
584
|
+
this.endAd(adState);
|
|
578
585
|
}
|
|
579
586
|
setPendingBreaks(newPending) {
|
|
580
587
|
this.pendingAdBreaks = newPending.filter(
|
|
@@ -2621,7 +2628,7 @@ function configureVinylGlobal(options) {
|
|
|
2621
2628
|
import { parseVersion } from "@amazon/vinyl-util";
|
|
2622
2629
|
var vinylVersion = /* @__PURE__ */ parseVersion(
|
|
2623
2630
|
/* istanbul ignore next */
|
|
2624
|
-
"3.2.
|
|
2631
|
+
"3.2.1"
|
|
2625
2632
|
);
|
|
2626
2633
|
|
|
2627
2634
|
// src/global/globalRef.ts
|
|
@@ -2826,6 +2833,7 @@ var PlaybackNetworkState = /* @__PURE__ */ ((PlaybackNetworkState2) => {
|
|
|
2826
2833
|
})(PlaybackNetworkState || {});
|
|
2827
2834
|
|
|
2828
2835
|
// src/playback/createStallMonitor.ts
|
|
2836
|
+
var PROGRESS_EPSILON = 1e-6;
|
|
2829
2837
|
function createStallMonitor(controller, callbacks, options = {}) {
|
|
2830
2838
|
var _a, _b;
|
|
2831
2839
|
const stallThresholdMs = ((_a = options.stallThreshold) != null ? _a : 1) * 1e3;
|
|
@@ -2834,6 +2842,7 @@ function createStallMonitor(controller, callbacks, options = {}) {
|
|
|
2834
2842
|
let lastProgressAt = Date.now();
|
|
2835
2843
|
let inStall = false;
|
|
2836
2844
|
let pollId = null;
|
|
2845
|
+
const { add, dispose } = createDisposer3();
|
|
2837
2846
|
const endStall = (reason) => {
|
|
2838
2847
|
if (!inStall) return;
|
|
2839
2848
|
inStall = false;
|
|
@@ -2850,6 +2859,7 @@ function createStallMonitor(controller, callbacks, options = {}) {
|
|
|
2850
2859
|
clearInterval(pollId);
|
|
2851
2860
|
pollId = null;
|
|
2852
2861
|
};
|
|
2862
|
+
add(stopPoll);
|
|
2853
2863
|
const startPoll = () => {
|
|
2854
2864
|
if (pollId != null) return;
|
|
2855
2865
|
pollId = setInterval(() => {
|
|
@@ -2865,17 +2875,18 @@ function createStallMonitor(controller, callbacks, options = {}) {
|
|
|
2865
2875
|
observedPlaying = false;
|
|
2866
2876
|
stopPoll();
|
|
2867
2877
|
};
|
|
2868
|
-
const { add, dispose } = createDisposer3();
|
|
2869
2878
|
add(
|
|
2870
2879
|
controller.on("playing", () => {
|
|
2871
2880
|
if (inStall) endStall("playing" /* PLAYING */);
|
|
2872
|
-
|
|
2881
|
+
lastProgressAt = Date.now();
|
|
2873
2882
|
observedPlaying = true;
|
|
2874
2883
|
startPoll();
|
|
2875
2884
|
})
|
|
2876
2885
|
);
|
|
2877
2886
|
add(
|
|
2878
|
-
controller.on("timeUpdate", () => {
|
|
2887
|
+
controller.on("timeUpdate", ({ previous, current }) => {
|
|
2888
|
+
if (previous != null && current - previous <= PROGRESS_EPSILON)
|
|
2889
|
+
return;
|
|
2879
2890
|
if (inStall) endStall("playing" /* PLAYING */);
|
|
2880
2891
|
lastProgressAt = Date.now();
|
|
2881
2892
|
})
|
|
@@ -2883,13 +2894,7 @@ function createStallMonitor(controller, callbacks, options = {}) {
|
|
|
2883
2894
|
add(controller.on("pause", () => suspend("pause" /* PAUSE */)));
|
|
2884
2895
|
add(controller.on("seeking", () => suspend("seeking" /* SEEKING */)));
|
|
2885
2896
|
add(controller.on("emptied", () => suspend("emptied" /* EMPTIED */)));
|
|
2886
|
-
|
|
2887
|
-
return () => {
|
|
2888
|
-
if (stopped) return;
|
|
2889
|
-
stopped = true;
|
|
2890
|
-
stopPoll();
|
|
2891
|
-
dispose();
|
|
2892
|
-
};
|
|
2897
|
+
return dispose;
|
|
2893
2898
|
}
|
|
2894
2899
|
|
|
2895
2900
|
// src/playback/error/InvalidSeekError.ts
|
|
@@ -11265,6 +11270,7 @@ export {
|
|
|
11265
11270
|
MsCommonMediaKeySystemAccess,
|
|
11266
11271
|
MsCommonMediaKeys,
|
|
11267
11272
|
MseTrack,
|
|
11273
|
+
PLAYOUT_LIMIT_TOLERANCE,
|
|
11268
11274
|
PLAY_READY_KEY_SYSTEMS,
|
|
11269
11275
|
POLL_BUFFER_THROTTLE,
|
|
11270
11276
|
PREFETCH_POLL_THROTTLE,
|