@amazon/vinyl 4.0.0 → 4.0.1-next.20261016184530

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 (76) hide show
  1. package/dist/index.cjs +40 -3
  2. package/dist/index.cjs.map +2 -2
  3. package/dist/index.js +41 -3
  4. package/dist/index.js.map +2 -2
  5. package/dist/test/benchmark.es5.js +5 -4
  6. package/dist/test/benchmark.js +11 -2
  7. package/dist/test/benchmark.js.map +3 -3
  8. package/dist/test/errata/mse-changetype-sequence.html +65 -0
  9. package/dist/test/errata/mse-changetype-sequence.js +179 -0
  10. package/dist/test/index.html +2 -2
  11. package/dist/test/integ.es5.js +287 -276
  12. package/dist/test/integ.js +629 -245
  13. package/dist/test/integ.js.map +4 -4
  14. package/dist/test/styles.css +23 -13
  15. package/dist/types/current/playback/PlaybackControllerImpl.d.ts +12 -0
  16. package/dist/types/current/playback/PlaybackControllerImpl.d.ts.map +1 -1
  17. package/dist/types/current/playback/PlaybackControllerImpl.js +42 -1
  18. package/dist/types/current/streaming/buffering/BufferingController.d.ts.map +1 -1
  19. package/dist/types/current/streaming/buffering/BufferingController.js +9 -2
  20. package/dist/types/current/streaming/buffering/MediaSourceController.d.ts.map +1 -1
  21. package/dist/types/current/streaming/buffering/MediaSourceController.js +4 -2
  22. package/dist/types/current/tsconfig.tsbuildinfo +1 -1
  23. package/dist/types/ts3.7/playback/PlaybackControllerImpl.d.ts +12 -0
  24. package/dist/types/ts4.1/playback/PlaybackControllerImpl.d.ts +12 -0
  25. package/dist/types/ts4.7/playback/PlaybackControllerImpl.d.ts +12 -0
  26. package/dist/unit/types/current/playback/PlaybackControllerImpl.test.js +86 -0
  27. package/dist/unit/types/current/setup.js +6 -5
  28. package/dist/unit/types/current/streaming/SegmentControllerImpl.test.js +44 -1
  29. package/dist/unit/types/current/streaming/buffering/BufferingController.test.js +14 -0
  30. package/dist/unit/types/current/streaming/buffering/MediaSourceController.test.js +13 -0
  31. package/dist/unit/types/current/track/dash/createDashFactories.test.js +15 -5
  32. package/dist/unit/types/current/track/hls/createHlsFactories.test.js +36 -12
  33. package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
  34. package/dist/unit/types/current/vinyl/VinylPlayerAdBreaks.test.js +8 -5
  35. package/dist/vinylTestUtil/index.js +92 -60
  36. package/dist/vinylTestUtil/index.js.map +4 -4
  37. package/dist/vinylTestUtil/types/current/media/FrequencyAnalyzer.d.ts +8 -5
  38. package/dist/vinylTestUtil/types/current/media/FrequencyAnalyzer.d.ts.map +1 -1
  39. package/dist/vinylTestUtil/types/current/media/FrequencyAnalyzer.js +23 -29
  40. package/dist/vinylTestUtil/types/current/media/unlockMediaElement.d.ts +10 -1
  41. package/dist/vinylTestUtil/types/current/media/unlockMediaElement.d.ts.map +1 -1
  42. package/dist/vinylTestUtil/types/current/media/unlockMediaElement.js +34 -6
  43. package/dist/vinylTestUtil/types/current/player/createVinylSuite.d.ts.map +1 -1
  44. package/dist/vinylTestUtil/types/current/player/createVinylSuite.js +6 -1
  45. package/dist/vinylTestUtil/types/current/player/mediaRef.d.ts +7 -0
  46. package/dist/vinylTestUtil/types/current/player/mediaRef.d.ts.map +1 -1
  47. package/dist/vinylTestUtil/types/current/player/mediaRef.js +8 -1
  48. package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
  49. package/dist/vinylTestUtil/types/current/ui/requireUserInteraction.d.ts +6 -2
  50. package/dist/vinylTestUtil/types/current/ui/requireUserInteraction.d.ts.map +1 -1
  51. package/dist/vinylTestUtil/types/current/ui/requireUserInteraction.js +31 -15
  52. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlays.d.ts +9 -2
  53. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlays.d.ts.map +1 -1
  54. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlays.js +10 -7
  55. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlaysUntil.d.ts +4 -1
  56. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlaysUntil.d.ts.map +1 -1
  57. package/dist/vinylTestUtil/types/current/util/playback/expectTrackPlaysUntil.js +3 -2
  58. package/dist/vinylTestUtil/types/ts3.7/media/FrequencyAnalyzer.d.ts +8 -5
  59. package/dist/vinylTestUtil/types/ts3.7/media/unlockMediaElement.d.ts +10 -1
  60. package/dist/vinylTestUtil/types/ts3.7/player/mediaRef.d.ts +7 -0
  61. package/dist/vinylTestUtil/types/ts3.7/ui/requireUserInteraction.d.ts +6 -2
  62. package/dist/vinylTestUtil/types/ts3.7/util/playback/expectTrackPlays.d.ts +9 -2
  63. package/dist/vinylTestUtil/types/ts3.7/util/playback/expectTrackPlaysUntil.d.ts +4 -1
  64. package/dist/vinylTestUtil/types/ts4.1/media/FrequencyAnalyzer.d.ts +8 -5
  65. package/dist/vinylTestUtil/types/ts4.1/media/unlockMediaElement.d.ts +10 -1
  66. package/dist/vinylTestUtil/types/ts4.1/player/mediaRef.d.ts +7 -0
  67. package/dist/vinylTestUtil/types/ts4.1/ui/requireUserInteraction.d.ts +6 -2
  68. package/dist/vinylTestUtil/types/ts4.1/util/playback/expectTrackPlays.d.ts +9 -2
  69. package/dist/vinylTestUtil/types/ts4.1/util/playback/expectTrackPlaysUntil.d.ts +4 -1
  70. package/dist/vinylTestUtil/types/ts4.7/media/FrequencyAnalyzer.d.ts +8 -5
  71. package/dist/vinylTestUtil/types/ts4.7/media/unlockMediaElement.d.ts +10 -1
  72. package/dist/vinylTestUtil/types/ts4.7/player/mediaRef.d.ts +7 -0
  73. package/dist/vinylTestUtil/types/ts4.7/ui/requireUserInteraction.d.ts +6 -2
  74. package/dist/vinylTestUtil/types/ts4.7/util/playback/expectTrackPlays.d.ts +9 -2
  75. package/dist/vinylTestUtil/types/ts4.7/util/playback/expectTrackPlaysUntil.d.ts +4 -1
  76. package/package.json +11 -10
package/dist/index.js CHANGED
@@ -4780,6 +4780,8 @@ var PlaybackControllerImpl = class extends EventHostImpl7 {
4780
4780
  this.initializeMutedEvent();
4781
4781
  this.initializeLoopedEvent();
4782
4782
  this.initializeReadyStateChangeEvent();
4783
+ this.initializeSeekWaitingEvent();
4784
+ this.initializeSeekPlayingEvent();
4783
4785
  }
4784
4786
  /**
4785
4787
  * Re-dispatches the plain DOM events without extra information.
@@ -4804,7 +4806,11 @@ var PlaybackControllerImpl = class extends EventHostImpl7 {
4804
4806
  "waiting",
4805
4807
  "waitingForKey"
4806
4808
  ]) {
4807
- this.domEvents.on(toLowerCase(key), () => this.dispatch(key, {}));
4809
+ this.domEvents.on(toLowerCase(key), () => {
4810
+ if (key === "waiting" && this._waiting) return;
4811
+ if (key === "playing" && this._playing) return;
4812
+ this.dispatch(key, {});
4813
+ });
4808
4814
  }
4809
4815
  this.domEvents.on("progress", (e) => {
4810
4816
  this.dispatch("progress", { loaded: e.loaded, total: e.total });
@@ -5215,6 +5221,34 @@ var PlaybackControllerImpl = class extends EventHostImpl7 {
5215
5221
  if (!this.paused && !seekAbort.aborted()) this.startStallDetection();
5216
5222
  }
5217
5223
  }
5224
+ /**
5225
+ * Dispatches `waiting` when a seek while playing targets an unbuffered position and the media element did not.
5226
+ * Safari 27 keeps its readyState while seeking, so it never fires `waiting` for the seek.
5227
+ * @private
5228
+ */
5229
+ initializeSeekWaitingEvent() {
5230
+ const timeoutSlot = this.disposer.add(new TimeoutSlot());
5231
+ this.domEvents.on("seeking", () => {
5232
+ timeoutSlot.set(() => {
5233
+ const media = this.media;
5234
+ if (this._waiting || !media.seeking || media.paused) return;
5235
+ const range = this.buffered.getRangeAt(media.currentTime);
5236
+ if (range && range[1] > media.currentTime) return;
5237
+ this.dispatch("waiting", {});
5238
+ }, 0);
5239
+ });
5240
+ }
5241
+ /**
5242
+ * Dispatches `playing` when a seek while playing completes and the media element did not. A seek ends `playing`,
5243
+ * but WebKit only fires `playing` again if its readyState dropped, which it doesn't for a buffered position.
5244
+ * @private
5245
+ */
5246
+ initializeSeekPlayingEvent() {
5247
+ this.domEvents.on("seeked", () => {
5248
+ if (this._playing || this.media.paused || !this.canPlay) return;
5249
+ this.dispatch("playing", {});
5250
+ });
5251
+ }
5218
5252
  /**
5219
5253
  * Dispatches a readyStateChange event when {@link readyState} changes.
5220
5254
  * @private
@@ -5785,7 +5819,8 @@ var BufferingControllerImpl = class extends EventHostImpl8 {
5785
5819
  return;
5786
5820
  }
5787
5821
  this.bufferingQuality = streamingSegment.quality;
5788
- if (this.decoderId !== streamingSegment.quality.decoderId) {
5822
+ const reinitialized = this.decoderId !== streamingSegment.quality.decoderId;
5823
+ if (reinitialized) {
5789
5824
  this.decoderId = null;
5790
5825
  await sourceBufferController.appendInit(
5791
5826
  streamingSegment.initData,
@@ -5797,6 +5832,8 @@ var BufferingControllerImpl = class extends EventHostImpl8 {
5797
5832
  await sourceBufferController.setTimestampOffset(
5798
5833
  streamingSegment.timestampOffset
5799
5834
  );
5835
+ } else if (reinitialized) {
5836
+ await sourceBufferController.setTimestampOffset(tail.endTime);
5800
5837
  }
5801
5838
  const maxAppendSize = this.getMaxAppendSize(
5802
5839
  streamingSegment.quality.contentType
@@ -6011,6 +6048,7 @@ import {
6011
6048
  ErrorOrigin as ErrorOrigin15,
6012
6049
  EventHostImpl as EventHostImpl9,
6013
6050
  IllegalStateError as IllegalStateError2,
6051
+ indexOf,
6014
6052
  isSilentError as isSilentError3,
6015
6053
  logDebug as logDebug9,
6016
6054
  logWarn as logWarn7,
@@ -6202,7 +6240,7 @@ var MediaSourceControllerImpl = class extends EventHostImpl9 {
6202
6240
  "removing source buffer from media source",
6203
6241
  mediaSource.readyState
6204
6242
  );
6205
- if (mediaSource.readyState !== "closed") {
6243
+ if (mediaSource.readyState !== "closed" && indexOf(mediaSource.sourceBuffers, sourceBuffer) !== -1) {
6206
6244
  mediaSource.removeSourceBuffer(sourceBuffer);
6207
6245
  }
6208
6246
  this.sourceBuffers.delete(sourceBuffer);