@shotstack/shotstack-studio 2.21.0 → 2.21.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.
@@ -11,7 +11,7 @@ import "pixi.js/text-html";
11
11
  import "pixi.js/sprite-tiling";
12
12
  import "pixi.js/filters";
13
13
  import "pixi.js/mesh";
14
- const o8 = "2.20.0", l8 = {
14
+ const o8 = "2.21.0", l8 = {
15
15
  version: o8
16
16
  };
17
17
  function pv(e, t, i) {
@@ -38453,6 +38453,7 @@ class Rf extends Mi {
38453
38453
  staticSprite = null;
38454
38454
  hasTriggeredCapture = !1;
38455
38455
  loadingGraphic = null;
38456
+ fallbackGraphic = null;
38456
38457
  loadingSetProgress = null;
38457
38458
  captureFramesDone = 0;
38458
38459
  captureFramesTotal = 0;
@@ -38560,11 +38561,14 @@ ${t.stack}` : t), this.createFallbackGraphic();
38560
38561
  this.mode = "editing", this.removeLoadingGraphic();
38561
38562
  }
38562
38563
  transitionToStale() {
38563
- this.mode === "stale" || this.mode === "editing" || (this.playbackSprite && (this.contentContainer.removeChild(this.playbackSprite), this.playbackSprite.destroy(), this.playbackSprite = null), this.removeLoadingGraphic(), this.disposeCapturedFrames(), this.mode = "stale");
38564
+ this.mode === "stale" || this.mode === "editing" || (this.playbackSprite && (this.contentContainer.removeChild(this.playbackSprite), this.playbackSprite.destroy(), this.playbackSprite = null), this.removeLoadingGraphic(), this.removeFallbackGraphic(), this.disposeCapturedFrames(), this.mode = "stale");
38564
38565
  }
38565
38566
  transitionToCapturing() {
38566
38567
  this.mode = "capturing", this.parkIframe(), this.mountLoadingGraphic(), this.emitCaptureStarted();
38567
38568
  }
38569
+ transitionToFailed() {
38570
+ this.disposed || (this.mode = "failed", this.parkIframe(), this.removeLoadingGraphic(), this.createFallbackGraphic());
38571
+ }
38568
38572
  // ─── capture pipeline ──────────────────────────────────────────────────────
38569
38573
  async captureFrames() {
38570
38574
  if (this.capturedFrames && this.capturedHash === this.contentHash)
@@ -38617,12 +38621,10 @@ ${t.stack}` : t), this.createFallbackGraphic();
38617
38621
  }
38618
38622
  captureIframeAsForeignObjectSvg(t, i) {
38619
38623
  if (!this.iframe?.contentDocument) throw new Error("iframe not ready");
38620
- const r = this.iframe.contentDocument, n = Array.from(r.querySelectorAll("style")).map((u) => `<style>${u.textContent ?? ""}</style>`).join(""), s = "<style>*,*::before,*::after{animation:none!important;transition:none!important}</style>", a = r.body.cloneNode(!0);
38621
- a.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
38622
- const o = a.getAttribute("style") ?? "";
38623
- a.setAttribute("style", `width:${t}px;height:${i}px;margin:0;overflow:hidden;${o}`);
38624
- const l = new XMLSerializer().serializeToString(a);
38625
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${i}"><foreignObject width="${t}" height="${i}">${n}${s}${l}</foreignObject></svg>`;
38624
+ const r = this.iframe.contentDocument, n = new XMLSerializer(), s = Array.from(r.querySelectorAll("style")).map((c) => n.serializeToString(c)).join(""), a = "<style>*,*::before,*::after{animation:none!important;transition:none!important}</style>", o = r.body.cloneNode(!0), l = o.getAttribute("style") ?? "";
38625
+ o.setAttribute("style", `width:${t}px;height:${i}px;margin:0;overflow:hidden;${l}`);
38626
+ const u = n.serializeToString(o);
38627
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${i}"><foreignObject width="${t}" height="${i}">${s}${a}${u}</foreignObject></svg>`;
38626
38628
  }
38627
38629
  async getDecodedFrame(t) {
38628
38630
  if (!this.capturedFrames) return null;
@@ -38655,7 +38657,7 @@ ${t.stack}` : t), this.createFallbackGraphic();
38655
38657
  */
38656
38658
  async prepareStaticRender() {
38657
38659
  try {
38658
- if (this.disposed || !this.iframe) return;
38660
+ if (this.disposed || !this.iframe || this.mode === "failed") return;
38659
38661
  const t = await this.captureFrames();
38660
38662
  if (this.disposed || !t || t.length === 0) return;
38661
38663
  const i = Math.min(Math.max(0, Math.floor(this.getPlaybackTime() * this.captureFps)), t.length - 1), r = await this.getDecodedFrame(i);
@@ -38679,9 +38681,11 @@ ${t.stack}` : t), this.createFallbackGraphic();
38679
38681
  if (t !== this.contentHash) {
38680
38682
  this.contentHash = t, this.transitionToStale(), this.disposeCapturedFrames(), this.captureInFlight = null, this.hasTriggeredCapture = !1, this.seekErrorReported = !1, this.iframe.srcdoc = Sw(this.asset);
38681
38683
  try {
38682
- await j4(this.iframe, void 0, !0), this.beginCapture();
38684
+ if (await j4(this.iframe, void 0, !0), this.disposed || this.contentHash !== t) return;
38685
+ this.beginCapture();
38683
38686
  } catch (i) {
38684
- console.warn("[Html5Player] reload iframe load failed:", i), this.emitCaptureFailed(i, "static-placeholder");
38687
+ if (this.disposed || this.contentHash !== t) return;
38688
+ console.warn("[Html5Player] reload iframe load failed:", i), this.emitCaptureFailed(i, "static-placeholder"), this.transitionToFailed();
38685
38689
  }
38686
38690
  }
38687
38691
  }
@@ -38690,31 +38694,34 @@ ${t.stack}` : t), this.createFallbackGraphic();
38690
38694
  this.decodedFrames.clear(), this.capturedFrames = null, this.capturedHash = null, this.lastFrameIdx = -1, this.decodeInFlight = null;
38691
38695
  }
38692
38696
  createFallbackGraphic() {
38697
+ if (this.fallbackGraphic) return;
38693
38698
  const t = this.clipConfiguration.width || this.edit.size.width, i = this.clipConfiguration.height || this.edit.size.height, r = $c(t, i);
38694
- this.renderedWidth = t, this.renderedHeight = i, this.contentContainer.addChild(r), this.configureKeyframes();
38699
+ this.fallbackGraphic = r, this.renderedWidth = t, this.renderedHeight = i, this.contentContainer.addChild(r), this.configureKeyframes();
38700
+ }
38701
+ removeFallbackGraphic() {
38702
+ this.fallbackGraphic && (this.contentContainer.removeChild(this.fallbackGraphic), this.fallbackGraphic.destroy(), this.fallbackGraphic = null);
38695
38703
  }
38696
38704
  update(t, i) {
38697
- super.update(t, i), this.triggerCaptureIfNeeded(), this.mode === "playback" ? this.driveSpriteTextureSwap() : this.mode === "capturing" ? this.loadingSetProgress && this.captureFramesTotal > 0 && this.loadingSetProgress(this.captureFramesDone / this.captureFramesTotal) : this.iframe && (this.syncIframePosition(), this.isActive() && this.seekHarness(this.getPlaybackTime()));
38705
+ super.update(t, i), this.triggerCaptureIfNeeded(), this.mode === "playback" ? this.driveSpriteTextureSwap() : this.mode === "capturing" ? this.loadingSetProgress && this.captureFramesTotal > 0 && this.loadingSetProgress(this.captureFramesDone / this.captureFramesTotal) : this.iframe && this.mode !== "failed" && (this.syncIframePosition(), this.isActive() && this.seekHarness(this.getPlaybackTime()));
38698
38706
  }
38699
38707
  beginCapture() {
38700
38708
  if (this.disposed || !this.iframe || this.mode === "capturing" || this.mode === "playback" || this.captureInFlight) return;
38709
+ const t = this.contentHash;
38701
38710
  if (this.capturedFrames && this.capturedHash === this.contentHash) {
38702
38711
  this.transitionToPlayback().catch((i) => {
38703
- console.warn("[Html5Player] transitionToPlayback failed:", i), this.transitionToEditing();
38712
+ this.disposed || this.contentHash !== t || (console.warn("[Html5Player] transitionToPlayback failed:", i), this.emitCaptureFailed(i, "static-placeholder"), this.transitionToFailed());
38704
38713
  });
38705
38714
  return;
38706
38715
  }
38707
- this.transitionToCapturing();
38708
- const t = this.contentHash;
38709
- this.captureFrames().then(async (i) => {
38710
- if (this.disposed) return;
38711
- if (!(!!i && i.length > 0 && this.capturedHash === t && this.contentHash === t)) {
38712
- this.mode === "capturing" && this.transitionToEditing();
38716
+ this.transitionToCapturing(), this.captureFrames().then(async (i) => {
38717
+ if (this.disposed || this.contentHash !== t) return;
38718
+ if (!(!!i && i.length > 0 && this.capturedHash === t)) {
38719
+ this.mode === "capturing" && this.transitionToFailed();
38713
38720
  return;
38714
38721
  }
38715
38722
  await this.transitionToPlayback();
38716
38723
  }).catch((i) => {
38717
- console.warn("[Html5Player] capture failed:", i), this.emitCaptureFailed(i, "live-iframe"), this.mode === "capturing" && this.transitionToEditing();
38724
+ this.disposed || this.contentHash !== t || (console.warn("[Html5Player] capture failed:", i), this.emitCaptureFailed(i, "static-placeholder"), this.mode === "capturing" && this.transitionToFailed());
38718
38725
  });
38719
38726
  }
38720
38727
  triggerCaptureIfNeeded() {
@@ -38759,7 +38766,7 @@ ${t.stack}` : t), this.createFallbackGraphic();
38759
38766
  S.left = `${y}px`, S.top = `${v}px`, S.width = `${r}px`, S.height = `${n}px`, S.transform = `scale(${C / r}, ${x / n})`, S.opacity = `${this.getOpacity()}`;
38760
38767
  }
38761
38768
  dispose() {
38762
- this.disposed = !0, super.dispose(), this.iframe?.remove(), this.iframe = null, this.playbackSprite?.destroy(), this.playbackSprite = null, this.staticSprite?.destroy(), this.staticSprite = null, this.removeLoadingGraphic(), this.disposeCapturedFrames();
38769
+ this.disposed = !0, this.removeFallbackGraphic(), super.dispose(), this.iframe?.remove(), this.iframe = null, this.playbackSprite?.destroy(), this.playbackSprite = null, this.staticSprite?.destroy(), this.staticSprite = null, this.removeLoadingGraphic(), this.disposeCapturedFrames();
38763
38770
  }
38764
38771
  getSize() {
38765
38772
  return this.clipConfiguration.width && this.clipConfiguration.height ? { width: this.clipConfiguration.width, height: this.clipConfiguration.height } : this.getContentSize();