@f8team/reel-core 1.1.0 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @f8team/reel-core
2
2
 
3
+ ## 1.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - e6d5243: Stop a replaced source from loading anyway.
8
+
9
+ The YouTube and HLS loaders cleared their `aborted` flag in `detach()`, so a source switch
10
+ (abort, then detach) let an attach that was still waiting for the YouTube or hls.js runtime carry
11
+ on: YouTube mounted a second iframe that stayed in the page, and HLS bound a stale hls.js instance
12
+ to the `<video>`. Each attach now remembers which abort/detach generation it started in and stops
13
+ when a newer one has happened.
14
+
15
+ `<Root>` (React) and `<reel-player>` (Lit) no longer call `setSource` again for the source the
16
+ player was created with in `options.source`. That second call aborted the first load on mount
17
+ (an extra media request) and was how the duplicate YouTube iframe was reached.
18
+
3
19
  ## 1.1.0
4
20
 
5
21
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -400,6 +400,12 @@ var HlsLoader = class {
400
400
  this.rejectAttach = null;
401
401
  this.manifestTimeout = null;
402
402
  this.aborted = false;
403
+ /**
404
+ * Bumped by every abort/detach. `detach()` clears `aborted` so the loader can be reused, so a
405
+ * source switch (abort, then detach) used to let an attach that was still awaiting the runtime
406
+ * carry on and bind a stale hls.js instance to the <video>. Each attach keeps its own value.
407
+ */
408
+ this.generation = 0;
403
409
  this.lastLoadingFragmentKey = null;
404
410
  this.repeatedFragmentLoadCount = 0;
405
411
  this.repeatedFragmentErrorFired = false;
@@ -418,11 +424,12 @@ var HlsLoader = class {
418
424
  async attach(video, source) {
419
425
  this.detach();
420
426
  this.aborted = false;
427
+ const generation = this.generation;
421
428
  this.video = video;
422
429
  this.currentSource = source;
423
430
  this.unauthorizedFired = false;
424
431
  const Hls = await (this.options.loadRuntime ?? defaultLoad)();
425
- if (this.aborted) {
432
+ if (this.aborted || generation !== this.generation) {
426
433
  throw makeAbortError();
427
434
  }
428
435
  if (!Hls.isSupported()) {
@@ -733,6 +740,7 @@ var HlsLoader = class {
733
740
  this.abortLiveXhrs();
734
741
  }
735
742
  abort() {
743
+ this.generation += 1;
736
744
  if (this.aborted) return;
737
745
  this.aborted = true;
738
746
  this.clearManifestTimeout();
@@ -1066,17 +1074,24 @@ var YouTubeLoader = class {
1066
1074
  this.duration = 0;
1067
1075
  this.rejectAttach = null;
1068
1076
  this.aborted = false;
1077
+ /**
1078
+ * Bumped by every abort/detach. `detach()` clears `aborted` so the loader can be reused, so a
1079
+ * source switch (abort, then detach) used to let an attach that was still awaiting the runtime
1080
+ * carry on and mount a second iframe. Each attach keeps the value it started with instead.
1081
+ */
1082
+ this.generation = 0;
1069
1083
  }
1070
1084
  async attach(video, source) {
1071
1085
  this.detach();
1072
1086
  this.aborted = false;
1087
+ const generation = this.generation;
1073
1088
  const id = extractYouTubeId(source.src);
1074
1089
  if (!id) {
1075
1090
  throw new Error(`Cannot extract YouTube videoId from "${source.src}"`);
1076
1091
  }
1077
1092
  this.video = video;
1078
1093
  const YT = await (this.options.loadRuntime ?? defaultLoad2)();
1079
- if (this.aborted) {
1094
+ if (this.aborted || generation !== this.generation) {
1080
1095
  throw makeYtAbortError();
1081
1096
  }
1082
1097
  const parent = video.parentElement;
@@ -1172,6 +1187,7 @@ var YouTubeLoader = class {
1172
1187
  });
1173
1188
  }
1174
1189
  abort() {
1190
+ this.generation += 1;
1175
1191
  if (this.aborted) return;
1176
1192
  this.aborted = true;
1177
1193
  const reject = this.rejectAttach;