@amazon/vinyl 3.2.1 → 3.2.2

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 (32) hide show
  1. package/dist/index.cjs +36 -22
  2. package/dist/index.cjs.map +2 -2
  3. package/dist/index.js +61 -46
  4. package/dist/index.js.map +3 -3
  5. package/dist/test/integ.es5.js +285 -281
  6. package/dist/test/integ.js +69 -22
  7. package/dist/test/integ.js.map +2 -2
  8. package/dist/types/current/drm/DrmControllerImpl.d.ts +6 -0
  9. package/dist/types/current/drm/DrmControllerImpl.d.ts.map +1 -1
  10. package/dist/types/current/drm/DrmControllerImpl.js +11 -1
  11. package/dist/types/current/playback/PlaybackControllerImpl.d.ts +8 -2
  12. package/dist/types/current/playback/PlaybackControllerImpl.d.ts.map +1 -1
  13. package/dist/types/current/playback/PlaybackControllerImpl.js +38 -33
  14. package/dist/types/current/track/mse/MseTrack.d.ts +0 -1
  15. package/dist/types/current/track/mse/MseTrack.d.ts.map +1 -1
  16. package/dist/types/current/track/mse/MseTrack.js +5 -6
  17. package/dist/types/current/tsconfig.tsbuildinfo +1 -1
  18. package/dist/types/ts3.7/drm/DrmControllerImpl.d.ts +6 -0
  19. package/dist/types/ts3.7/playback/PlaybackControllerImpl.d.ts +8 -2
  20. package/dist/types/ts3.7/track/mse/MseTrack.d.ts +0 -1
  21. package/dist/types/ts4.1/drm/DrmControllerImpl.d.ts +6 -0
  22. package/dist/types/ts4.1/playback/PlaybackControllerImpl.d.ts +8 -2
  23. package/dist/types/ts4.1/track/mse/MseTrack.d.ts +0 -1
  24. package/dist/types/ts4.7/drm/DrmControllerImpl.d.ts +6 -0
  25. package/dist/types/ts4.7/playback/PlaybackControllerImpl.d.ts +8 -2
  26. package/dist/types/ts4.7/track/mse/MseTrack.d.ts +0 -1
  27. package/dist/unit/types/current/drm/DrmControllerImpl.test.js +19 -1
  28. package/dist/unit/types/current/playback/PlaybackControllerImpl.test.js +15 -0
  29. package/dist/unit/types/current/streaming/MseTrack.test.js +15 -0
  30. package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
  31. package/dist/vinylTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +10 -10
@@ -14007,6 +14007,7 @@ ${this.lastInitStack}` : "";
14007
14007
  // src/drm/DrmControllerImpl.ts
14008
14008
  var LICENSE_TIMEOUT = 90;
14009
14009
  var LICENSE_TIMEOUT_MESSAGE = "License provider timed out after {time}s";
14010
+ var EXCESSIVE_SESSION_COUNT = 20;
14010
14011
  var DrmControllerImpl = class extends EventHostImpl {
14011
14012
  constructor(deps, options) {
14012
14013
  super();
@@ -14223,6 +14224,13 @@ ${this.lastInitStack}` : "";
14223
14224
  trackUri
14224
14225
  });
14225
14226
  this.sessions.push(newSession);
14227
+ logVerbose(this, `total sessions: ${this.sessions.length}`);
14228
+ if (this.sessions.length === EXCESSIVE_SESSION_COUNT + 1) {
14229
+ logWarn(
14230
+ this,
14231
+ `${this.sessions.length} open key sessions exceeds ${EXCESSIVE_SESSION_COUNT}; sessions may be leaking (not closing on track deactivation)`
14232
+ );
14233
+ }
14226
14234
  this.dispatch("sessionCreate", {
14227
14235
  initDataType: newSession.initDataType,
14228
14236
  mimeType: newSession.mimeType
@@ -15221,7 +15229,7 @@ ${this.lastInitStack}` : "";
15221
15229
  // src/global/environment.ts
15222
15230
  var vinylVersion = parseVersion(
15223
15231
  /* istanbul ignore next */
15224
- "3.2.1"
15232
+ "3.2.2"
15225
15233
  );
15226
15234
 
15227
15235
  // src/global/globalRef.ts
@@ -15715,15 +15723,13 @@ ${this.lastInitStack}` : "";
15715
15723
  __publicField(this, "_playing", false);
15716
15724
  __publicField(this, "_seeking", false);
15717
15725
  __publicField(this, "_waiting", false);
15718
- // Monotonic counter identifying the most recent seekTo call.
15719
- __publicField(this, "_seekId", 0);
15726
+ __publicField(this, "seekAbortSlot", createAbortSlot());
15720
15727
  // Stops the stall detector started after the last seek, if any.
15721
15728
  __publicField(this, "stopStallDetection", null);
15722
15729
  // default user volume (0.0 to 1.0 scale)
15723
15730
  __publicField(this, "userVolume", 1);
15724
15731
  __publicField(this, "_pendingPlay", null);
15725
15732
  __publicField(this, "playAbort", null);
15726
- __publicField(this, "disposeAbort", new Abort());
15727
15733
  __publicField(this, "options");
15728
15734
  this.options = __spreadValues(__spreadProps(__spreadValues({}, defaultPlaybackControllerImplOptions), {
15729
15735
  minSeekableBuffer: getMinSeekableBufferDefault()
@@ -15734,8 +15740,7 @@ ${this.lastInitStack}` : "";
15734
15740
  const { add } = this.disposer;
15735
15741
  add(() => {
15736
15742
  var _a3;
15737
- this.disposeAbort.abort();
15738
- this.disposeAbort.dispose();
15743
+ this.seekAbortSlot.abort();
15739
15744
  (_a3 = this.stopStallDetection) == null ? void 0 : _a3.call(this);
15740
15745
  });
15741
15746
  this.domEvents = add(
@@ -16148,14 +16153,10 @@ ${this.lastInitStack}` : "";
16148
16153
  async seekTo(time, tolerance = 0.5) {
16149
16154
  var _a3;
16150
16155
  logDebug(this, `seekTo: ${time}`);
16151
- const seekId = ++this._seekId;
16152
16156
  (_a3 = this.stopStallDetection) == null ? void 0 : _a3.call(this);
16153
16157
  this.stopStallDetection = null;
16154
- const superseded = () => {
16155
- if (this._seekId === seekId) return false;
16156
- logDebug(this, `seekTo: ${time} superseded by a newer seek`);
16157
- return true;
16158
- };
16158
+ this.seekAbortSlot.abort();
16159
+ const seekAbort = this.seekAbortSlot.value;
16159
16160
  const nextEvent = (type, options) => {
16160
16161
  var _a4;
16161
16162
  return nextEventAsPromise(this, type, {
@@ -16163,12 +16164,25 @@ ${this.lastInitStack}` : "";
16163
16164
  timeoutMessage: `seek timed out on ${type} event after {time}s`,
16164
16165
  timeoutOrigin: ErrorOrigin.INTERNAL,
16165
16166
  timeoutLevel: "warn" /* WARN */,
16166
- abort: this.disposeAbort
16167
+ abort: seekAbort
16167
16168
  });
16168
16169
  };
16170
+ try {
16171
+ await this.doSeek(time, tolerance, seekAbort, nextEvent);
16172
+ } catch (error) {
16173
+ if (seekAbort.aborted() && !this.disposed) return;
16174
+ throw error;
16175
+ }
16176
+ }
16177
+ /**
16178
+ * The body of a single {@link seekTo} attempt. Extracted so {@link seekTo}
16179
+ * can wrap it with per-seek abort/supersession handling. `seekAbort` is
16180
+ * aborted when a newer seek supersedes this one (or on dispose).
16181
+ * @private
16182
+ */
16183
+ async doSeek(time, tolerance, seekAbort, nextEvent) {
16169
16184
  if (!this.hasMetadata) {
16170
16185
  await nextEvent("loadedMetadata");
16171
- if (superseded()) return;
16172
16186
  }
16173
16187
  const seekable = this.seekable;
16174
16188
  const range = seekable.getRangeAt(
@@ -16199,7 +16213,7 @@ ${this.lastInitStack}` : "";
16199
16213
  );
16200
16214
  } else {
16201
16215
  const nullIfStuck = (error) => {
16202
- if (this.disposeAbort.aborted()) throw error;
16216
+ if (this.disposed) throw error;
16203
16217
  return null;
16204
16218
  };
16205
16219
  const seekOnce = async (reSeeking) => {
@@ -16213,7 +16227,7 @@ ${this.lastInitStack}` : "";
16213
16227
  }).catch(nullIfStuck);
16214
16228
  };
16215
16229
  let seekedEvent = await seekOnce(false);
16216
- for (let attempt = 0; !superseded() && attempt < SEEK_RETRY_LIMIT && (seekedEvent === null || seekedEvent.reason === "seeked" && !closeTo(clampedTime, this.currentTime, tolerance)); attempt++) {
16230
+ for (let attempt = 0; !seekAbort.aborted() && attempt < SEEK_RETRY_LIMIT && (seekedEvent === null || seekedEvent.reason === "seeked" && !closeTo(clampedTime, this.currentTime, tolerance)); attempt++) {
16217
16231
  if (seekedEvent === null) void this.media.play().catch(noop);
16218
16232
  logDebug(this, `seekTo: re-seeking to ${clampedTime}`);
16219
16233
  seekedEvent = await seekOnce(true);
@@ -16221,7 +16235,7 @@ ${this.lastInitStack}` : "";
16221
16235
  if ((seekedEvent == null ? void 0 : seekedEvent.reason) === "emptied") {
16222
16236
  throw new AbortError();
16223
16237
  }
16224
- if (!this.paused) this.startStallDetection();
16238
+ if (!this.paused && !seekAbort.aborted()) this.startStallDetection();
16225
16239
  }
16226
16240
  }
16227
16241
  /**
@@ -20561,7 +20575,6 @@ ${this.lastInitStack}` : "";
20561
20575
  const deps = depsContainer.dependencies;
20562
20576
  super(uri, type, deps);
20563
20577
  __publicField(this, "streams", []);
20564
- __publicField(this, "disposeAbort", new Abort());
20565
20578
  __publicField(this, "lastPreloadOptions", null);
20566
20579
  __publicField(this, "allFetchedRanges", []);
20567
20580
  __publicField(this, "_fetchedRanges", new IntersectionRanges(
@@ -20586,7 +20599,7 @@ ${this.lastInitStack}` : "";
20586
20599
  if (this.active) {
20587
20600
  this.deps.drmController.initializeForPlayback(event.current, {
20588
20601
  trackUri: this.uri,
20589
- abort: this.disposeAbort
20602
+ abort: this.drmSessionAbort.value
20590
20603
  });
20591
20604
  }
20592
20605
  });
@@ -20594,7 +20607,7 @@ ${this.lastInitStack}` : "";
20594
20607
  if (event.current == null) return;
20595
20608
  this.deps.drmController.setBufferingDrmInfo(event.current, {
20596
20609
  trackUri: this.uri,
20597
- abort: this.disposeAbort
20610
+ abort: this.drmSessionAbort.value
20598
20611
  });
20599
20612
  });
20600
20613
  add(
@@ -20832,7 +20845,7 @@ ${this.lastInitStack}` : "";
20832
20845
  this.streams.forEach((stream) => {
20833
20846
  this.deps.drmController.initializeForPlayback(
20834
20847
  stream.streamingQuality,
20835
- { trackUri: this.uri, abort: this.disposeAbort }
20848
+ { trackUri: this.uri, abort: this.drmSessionAbort.value }
20836
20849
  );
20837
20850
  });
20838
20851
  this.deps.playbackSource.src = this.deps.mediaSourceController.activate();
@@ -20858,7 +20871,7 @@ ${this.lastInitStack}` : "";
20858
20871
  this.callOnStreams("deactivate");
20859
20872
  this.deps.drmController.setBufferingDrmInfo(null, {
20860
20873
  trackUri: this.uri,
20861
- abort: this.disposeAbort
20874
+ abort: this.drmSessionAbort.value
20862
20875
  });
20863
20876
  (_b = this.deps.textTrackController) == null ? void 0 : _b.deactivate();
20864
20877
  this.deps.playbackSource.src = null;
@@ -32139,6 +32152,23 @@ ${(_a3 = this.failedResult.failedExpectations[0]) == null ? void 0 : _a3.message
32139
32152
  expect(drmController.isEmeSupported()).toBeFalse();
32140
32153
  });
32141
32154
  });
32155
+ describe("excessive sessions", () => {
32156
+ it("warns once when the open session count exceeds the threshold", async () => {
32157
+ drmController.setBufferingDrmInfo(drmInfo);
32158
+ for (let i = 0; i < EXCESSIVE_SESSION_COUNT; i++) {
32159
+ await emitEncrypted(new Uint8Array([i]));
32160
+ }
32161
+ expect(drmController.activeSessions).toBe(EXCESSIVE_SESSION_COUNT);
32162
+ expect(logger.value.warn).not.toHaveBeenCalled();
32163
+ await emitEncrypted(new Uint8Array([EXCESSIVE_SESSION_COUNT]));
32164
+ expect(drmController.activeSessions).toBe(
32165
+ EXCESSIVE_SESSION_COUNT + 1
32166
+ );
32167
+ expect(logger.value.warn).toHaveBeenCalledTimes(1);
32168
+ await emitEncrypted(new Uint8Array([EXCESSIVE_SESSION_COUNT + 1]));
32169
+ expect(logger.value.warn).toHaveBeenCalledTimes(1);
32170
+ });
32171
+ });
32142
32172
  describe("closeSessions", () => {
32143
32173
  it("clears active sessions", async () => {
32144
32174
  const sessionCloseSpy = createEventSpy(
@@ -34107,6 +34137,13 @@ ${(_a3 = this.failedResult.failedExpectations[0]) == null ? void 0 : _a3.message
34107
34137
  await clock.tick(controller.options.seekTimeout);
34108
34138
  await seekExpectation;
34109
34139
  });
34140
+ it("resolves a superseded seek at once when its seeking event never fires", async () => {
34141
+ setSeekable([[0, 100]]);
34142
+ const first2 = controller.seekTo(50);
34143
+ const second = controller.seekTo(60);
34144
+ await expectAsync(first2).toBeResolved();
34145
+ second.catch(() => void 0);
34146
+ });
34110
34147
  it("times out pending seeks after seekTimeout", async () => {
34111
34148
  const pendingSeekExpectation = expectAsync(
34112
34149
  controller.seekTo(60)
@@ -39217,6 +39254,16 @@ ${(_a3 = this.failedResult.failedExpectations[0]) == null ? void 0 : _a3.message
39217
39254
  abort: any14(Abort)
39218
39255
  });
39219
39256
  });
39257
+ it("aborts the drm session abort so key sessions close", async () => {
39258
+ track2 = createTrack();
39259
+ await awaitContentTypes();
39260
+ getAudioStream().streamingQuality = createEmptyMediaQualityMetadata();
39261
+ track2.activate({});
39262
+ const { abort } = deps.drmController.initializeForPlayback.calls.mostRecent().args[1];
39263
+ expect(abort.aborted()).toBeFalse();
39264
+ track2.deactivate();
39265
+ expect(abort.aborted()).toBeTrue();
39266
+ });
39220
39267
  });
39221
39268
  describe("error", () => {
39222
39269
  it("returns the first emitted error", async () => {