@amazon/vinyl 4.0.1-next.20261017024550 → 4.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.
- package/dist/index.cjs +14 -7
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +14 -7
- package/dist/index.js.map +2 -2
- package/dist/test/integ.es5.js +131 -131
- package/dist/test/integ.js +54 -8
- package/dist/test/integ.js.map +2 -2
- package/dist/types/current/playback/createStallMonitor.d.ts +11 -6
- package/dist/types/current/playback/createStallMonitor.d.ts.map +1 -1
- package/dist/types/current/playback/createStallMonitor.js +29 -11
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ts3.7/playback/createStallMonitor.d.ts +11 -6
- package/dist/types/ts4.1/playback/createStallMonitor.d.ts +11 -6
- package/dist/types/ts4.7/playback/createStallMonitor.d.ts +11 -6
- package/dist/unit/types/current/playback/createStallMonitor.test.js +43 -1
- package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
package/dist/test/integ.js
CHANGED
|
@@ -16858,7 +16858,7 @@ ${this.lastInitStack}` : "";
|
|
|
16858
16858
|
// src/global/environment.ts
|
|
16859
16859
|
var vinylVersion = parseVersion(
|
|
16860
16860
|
/* istanbul ignore next */
|
|
16861
|
-
"4.
|
|
16861
|
+
"4.1.0"
|
|
16862
16862
|
);
|
|
16863
16863
|
|
|
16864
16864
|
// src/global/globalRef.ts
|
|
@@ -17020,8 +17020,8 @@ ${this.lastInitStack}` : "";
|
|
|
17020
17020
|
var _a3, _b;
|
|
17021
17021
|
const stallThresholdMs = ((_a3 = options2.stallThreshold) != null ? _a3 : 1) * 1e3;
|
|
17022
17022
|
const pollIntervalMs = ((_b = options2.pollInterval) != null ? _b : 0.25) * 1e3;
|
|
17023
|
-
let observedPlaying = false;
|
|
17024
17023
|
let lastProgressAt = Date.now();
|
|
17024
|
+
let lastProgressPosition = controller.currentTime;
|
|
17025
17025
|
let inStall = false;
|
|
17026
17026
|
let pollId = null;
|
|
17027
17027
|
const { add, dispose } = createDisposer();
|
|
@@ -17042,10 +17042,19 @@ ${this.lastInitStack}` : "";
|
|
|
17042
17042
|
pollId = null;
|
|
17043
17043
|
};
|
|
17044
17044
|
add(stopPoll);
|
|
17045
|
+
const markProgress = () => {
|
|
17046
|
+
lastProgressAt = Date.now();
|
|
17047
|
+
lastProgressPosition = controller.currentTime;
|
|
17048
|
+
};
|
|
17045
17049
|
const startPoll = () => {
|
|
17046
17050
|
if (pollId != null) return;
|
|
17047
17051
|
pollId = setInterval(() => {
|
|
17048
|
-
if (
|
|
17052
|
+
if (controller.currentTime - lastProgressPosition > PROGRESS_EPSILON) {
|
|
17053
|
+
if (inStall) endStall("playing" /* PLAYING */);
|
|
17054
|
+
markProgress();
|
|
17055
|
+
return;
|
|
17056
|
+
}
|
|
17057
|
+
if (inStall) return;
|
|
17049
17058
|
if (Date.now() - lastProgressAt >= stallThresholdMs) {
|
|
17050
17059
|
inStall = true;
|
|
17051
17060
|
callbacks.onStallEntered();
|
|
@@ -17054,14 +17063,12 @@ ${this.lastInitStack}` : "";
|
|
|
17054
17063
|
};
|
|
17055
17064
|
const suspend = (reason) => {
|
|
17056
17065
|
endStall(reason);
|
|
17057
|
-
observedPlaying = false;
|
|
17058
17066
|
stopPoll();
|
|
17059
17067
|
};
|
|
17060
17068
|
add(
|
|
17061
17069
|
controller.on("playing", () => {
|
|
17062
17070
|
if (inStall) endStall("playing" /* PLAYING */);
|
|
17063
|
-
|
|
17064
|
-
observedPlaying = true;
|
|
17071
|
+
markProgress();
|
|
17065
17072
|
startPoll();
|
|
17066
17073
|
})
|
|
17067
17074
|
);
|
|
@@ -17070,7 +17077,7 @@ ${this.lastInitStack}` : "";
|
|
|
17070
17077
|
if (previous != null && current - previous <= PROGRESS_EPSILON)
|
|
17071
17078
|
return;
|
|
17072
17079
|
if (inStall) endStall("playing" /* PLAYING */);
|
|
17073
|
-
|
|
17080
|
+
markProgress();
|
|
17074
17081
|
})
|
|
17075
17082
|
);
|
|
17076
17083
|
add(controller.on("pause", () => suspend("pause" /* PAUSE */)));
|
|
@@ -37644,6 +37651,12 @@ ${(_a3 = this.failedResult.failedExpectations[0]) == null ? void 0 : _a3.message
|
|
|
37644
37651
|
});
|
|
37645
37652
|
|
|
37646
37653
|
// test/unit/playback/createStallMonitor.test.ts
|
|
37654
|
+
var MockController = class extends EventHostImpl {
|
|
37655
|
+
constructor() {
|
|
37656
|
+
super(...arguments);
|
|
37657
|
+
__publicField(this, "currentTime", 0);
|
|
37658
|
+
}
|
|
37659
|
+
};
|
|
37647
37660
|
describe("createStallMonitor", () => {
|
|
37648
37661
|
const clock = useMockTime();
|
|
37649
37662
|
let host;
|
|
@@ -37651,7 +37664,7 @@ ${(_a3 = this.failedResult.failedExpectations[0]) == null ? void 0 : _a3.message
|
|
|
37651
37664
|
let onStallEnded;
|
|
37652
37665
|
let stop;
|
|
37653
37666
|
beforeEach(() => {
|
|
37654
|
-
host = new
|
|
37667
|
+
host = new MockController();
|
|
37655
37668
|
onStallEntered = jasmine.createSpy("onStallEntered");
|
|
37656
37669
|
onStallEnded = jasmine.createSpy("onStallEnded");
|
|
37657
37670
|
});
|
|
@@ -37782,6 +37795,39 @@ ${(_a3 = this.failedResult.failedExpectations[0]) == null ? void 0 : _a3.message
|
|
|
37782
37795
|
await poll2(3);
|
|
37783
37796
|
expect(onStallEntered).toHaveBeenCalledTimes(1);
|
|
37784
37797
|
});
|
|
37798
|
+
it("does not report a stall when the play head advances but timeUpdates are delayed", async () => {
|
|
37799
|
+
monitor();
|
|
37800
|
+
host.dispatch("playing", {});
|
|
37801
|
+
for (let i = 0; i < 12; i++) {
|
|
37802
|
+
host.currentTime += 0.25;
|
|
37803
|
+
await poll2(1);
|
|
37804
|
+
}
|
|
37805
|
+
expect(onStallEntered).not.toHaveBeenCalled();
|
|
37806
|
+
expect(onStallEnded).not.toHaveBeenCalled();
|
|
37807
|
+
});
|
|
37808
|
+
it("still reports a stall when the play head is frozen and no timeUpdate arrives", async () => {
|
|
37809
|
+
monitor();
|
|
37810
|
+
host.currentTime = 3;
|
|
37811
|
+
host.dispatch("playing", {});
|
|
37812
|
+
await poll2(4);
|
|
37813
|
+
expect(onStallEntered).toHaveBeenCalledTimes(1);
|
|
37814
|
+
});
|
|
37815
|
+
it("ends a stall when the play head advances before a timeUpdate is delivered", async () => {
|
|
37816
|
+
monitor();
|
|
37817
|
+
host.dispatch("playing", {});
|
|
37818
|
+
await poll2(4);
|
|
37819
|
+
expect(onStallEntered).toHaveBeenCalledTimes(1);
|
|
37820
|
+
await poll2(4);
|
|
37821
|
+
host.currentTime = 0.25;
|
|
37822
|
+
await poll2(1);
|
|
37823
|
+
expect(onStallEnded).toHaveBeenCalledTimes(1);
|
|
37824
|
+
const info = onStallEnded.calls.mostRecent().args[0];
|
|
37825
|
+
expect(info.reason).toBe("playing" /* PLAYING */);
|
|
37826
|
+
expect(info.duration).toBeCloseTo(2.25, 1);
|
|
37827
|
+
host.dispatch("timeUpdate", { previous: 0, current: 0.25 });
|
|
37828
|
+
expect(onStallEnded).toHaveBeenCalledTimes(1);
|
|
37829
|
+
expect(onStallEntered).toHaveBeenCalledTimes(1);
|
|
37830
|
+
});
|
|
37785
37831
|
it("stops reporting after disposal", async () => {
|
|
37786
37832
|
monitor();
|
|
37787
37833
|
host.dispatch("playing", {});
|