@shotstack/shotstack-studio 2.19.3 → 2.19.5

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 GI = "2.19.2", qI = {
14
+ const GI = "2.19.4", qI = {
15
15
  version: GI
16
16
  };
17
17
  function av(e, t, i) {
@@ -42502,11 +42502,13 @@ class _K extends Mi {
42502
42502
  this.volumeKeyframeBuilder = new ia(r.volume ?? 1, this.getLength()), this.syncTimer = 0, this.activeSyncTimer = 0, this.skipVideoUpdate = !1;
42503
42503
  }
42504
42504
  async load() {
42505
- await super.load();
42505
+ this.skipVideoUpdate = !0, await super.load();
42506
42506
  try {
42507
42507
  await this.loadVideo(), this.configureKeyframes();
42508
42508
  } catch (t) {
42509
42509
  console.warn(`[VideoPlayer.load] FAILED clipId=${this.clipId}:`, t), this.createFallbackGraphic();
42510
+ } finally {
42511
+ this.skipVideoUpdate = !1;
42510
42512
  }
42511
42513
  }
42512
42514
  createFallbackGraphic() {
@@ -42516,10 +42518,10 @@ class _K extends Mi {
42516
42518
  update(t, i) {
42517
42519
  if (super.update(t, i), this.skipVideoUpdate || (this.syncTimer += i, !this.texture))
42518
42520
  return;
42519
- const r = this.getAssetSpeed(), n = this.getSourceTime(), s = this.edit.isPlaying && this.isActive() && r > 0;
42520
- s && (this.isPlaying || (this.isPlaying = !0, this.activeSyncTimer = 0, this.texture.source.resource.volume = this.getVolume(), this.texture.source.resource.currentTime = n, this.texture.source.resource.play().catch(console.error)), this.texture.source.resource.volume !== this.getVolume() && (this.texture.source.resource.volume = this.getVolume()), this.texture.source.resource.playbackRate !== r && (this.texture.source.resource.playbackRate = r), this.activeSyncTimer += i, this.activeSyncTimer > 1e3 && (this.activeSyncTimer = 0, Math.abs(this.texture.source.resource.currentTime - n) > 0.3 && (this.texture.source.resource.currentTime = n))), !s && this.isPlaying && (this.isPlaying = !1, this.texture.source.resource.pause());
42521
- const a = this.syncTimer > 100;
42522
- (!this.edit.isPlaying || r === 0) && this.isActive() && a && (this.syncTimer = 0, this.texture.source.resource.currentTime = n);
42521
+ const r = this.getAssetSpeed(), n = this.getSourceTime(), s = this.edit.isPlaying && this.isActive() && r > 0, a = 0.3;
42522
+ s && (this.isPlaying || (this.isPlaying = !0, this.activeSyncTimer = 0, this.texture.source.resource.volume = this.getVolume(), Math.abs(this.texture.source.resource.currentTime - n) > a && (this.texture.source.resource.currentTime = n), this.texture.source.resource.play().catch(console.error)), this.texture.source.resource.volume !== this.getVolume() && (this.texture.source.resource.volume = this.getVolume()), this.texture.source.resource.playbackRate !== r && (this.texture.source.resource.playbackRate = r), this.activeSyncTimer += i, this.activeSyncTimer > 1e3 && (this.activeSyncTimer = 0, Math.abs(this.texture.source.resource.currentTime - n) > a && (this.texture.source.resource.currentTime = n))), !s && this.isPlaying && (this.isPlaying = !1, this.texture.source.resource.pause());
42523
+ const o = this.syncTimer > 100;
42524
+ (this.edit.playbackTime < this.getStart() || (!this.edit.isPlaying || r === 0) && this.isActive() && o) && (this.syncTimer = 0, Math.abs(this.texture.source.resource.currentTime - n) > 0.01 && (this.texture.source.resource.currentTime = n));
42523
42525
  }
42524
42526
  dispose() {
42525
42527
  this.disposeVideo(), this.clearPlaceholder(), super.dispose();
@@ -42560,12 +42562,27 @@ class _K extends Mi {
42560
42562
  throw new Error(`Invalid video source '${i}'.`);
42561
42563
  this.clearPlaceholder(), s.source.alphaMode = "no-premultiply-alpha", this.texture = this.createCroppedTexture(s);
42562
42564
  const a = this.texture.source.resource;
42563
- a instanceof HTMLVideoElement && a.readyState < 2 && await new Promise((o) => {
42565
+ if (a instanceof HTMLVideoElement && a.readyState < 2 && await new Promise((o) => {
42564
42566
  const l = () => {
42565
42567
  a.removeEventListener("loadeddata", l), o();
42566
42568
  };
42567
42569
  a.addEventListener("loadeddata", l), a.readyState >= 2 && o();
42568
- }), this.sprite = new X.Sprite(this.texture), this.contentContainer.addChild(this.sprite), this.texture.source.resource.volume = this.getVolume(), this.texture.source.resource.preservesPitch = !1;
42570
+ }), a instanceof HTMLVideoElement) {
42571
+ const o = this.getSourceTime();
42572
+ if (Math.abs(a.currentTime - o) > 0.01) {
42573
+ const l = await new Promise((u) => {
42574
+ const c = ["seeked", "abort", "emptied", "error"], d = (f) => {
42575
+ for (const h of c) a.removeEventListener(h, d);
42576
+ u(f?.type);
42577
+ };
42578
+ for (const f of c) a.addEventListener(f, d);
42579
+ a.currentTime = o, a.seeking || d();
42580
+ });
42581
+ if (this.texture?.source.resource !== a || l === "abort" || l === "emptied") return;
42582
+ if (l === "error") throw new Error("Video seeking failed.");
42583
+ }
42584
+ }
42585
+ this.sprite = new X.Sprite(this.texture), this.contentContainer.addChild(this.sprite), this.texture.source.resource.volume = this.getVolume(), this.texture.source.resource.preservesPitch = !1;
42569
42586
  }
42570
42587
  disposeVideo() {
42571
42588
  this.texture?.source?.resource && (this.texture.source.resource.pause(), this.texture.source.resource.src = "", this.texture.source.resource.load()), this.sprite && (this.contentContainer.removeChild(this.sprite), this.sprite.destroy(), this.sprite = null), this.texture && (this.texture.destroy(!0), this.texture = null);
@@ -45286,7 +45303,7 @@ class GX {
45286
45303
  if (d) {
45287
45304
  const f = this.updatePlayer(d, u, a);
45288
45305
  f === "recreate" ? (this.disposePlayer(c), i.push(this.createPlayer(u, c, a, l)), r.disposed.push(c), r.created.push(c)) : f && r.updated.push(c);
45289
- } else this.enableCreation && (this.createPlayer(u, c, a, l), r.created.push(c));
45306
+ } else this.enableCreation && (i.push(this.createPlayer(u, c, a, l)), r.created.push(c));
45290
45307
  }
45291
45308
  }
45292
45309
  }
@@ -46450,12 +46467,16 @@ class Ko {
46450
46467
  console.warn(`commitClipUpdate: clip ${t} not found in document`);
46451
46468
  return;
46452
46469
  }
46453
- Wd.parse(r);
46454
- const s = new kd(i, structuredClone(r), {
46470
+ const s = Wd.safeParse(r);
46471
+ if (!s.success) {
46472
+ console.warn(`commitClipUpdate: skipping invalid clip ${t}`, s.error);
46473
+ return;
46474
+ }
46475
+ const a = new kd(i, structuredClone(r), {
46455
46476
  trackIndex: n.trackIndex,
46456
46477
  clipIndex: n.clipIndex
46457
46478
  });
46458
- this.addCommandToHistory(s);
46479
+ this.addCommandToHistory(a);
46459
46480
  }
46460
46481
  /**
46461
46482
  * Manage command history: dispose redo stack, add command, prune old entries.
@@ -47635,7 +47656,7 @@ class Bn {
47635
47656
  * @internal
47636
47657
  */
47637
47658
  getContentBounds() {
47638
- const t = this.edit.size.width * this.currentZoom, i = this.edit.size.height * this.currentZoom, r = this.viewportContainer?.position.x ?? 0, n = this.viewportContainer?.position.y ?? 0;
47659
+ const t = this.edit.size.width * this.currentZoom, i = this.edit.size.height * this.currentZoom, r = this.viewportContainer?.position?.x ?? 0, n = this.viewportContainer?.position?.y ?? 0;
47639
47660
  return {
47640
47661
  left: r,
47641
47662
  right: r + t,
@@ -67155,8 +67176,8 @@ class Irt extends wa {
67155
67176
  const t = this.edit.getResolvedClip(this.selectedTrackIdx, this.selectedClipIdx);
67156
67177
  if (!t) return;
67157
67178
  const i = dv(t.asset), r = `asset.${i}`, n = this.promptInput?.value ?? "", s = n.trim() === "", a = this.edit.resolveMergeFields(n), o = this.edit.getDocument(), l = this.getSelectedClipId();
67158
- l && o && (!s && Hd.test(n) ? o.setClipBinding(l, r, { placeholder: n, resolvedValue: a }) : o.removeClipBinding(l, r)), this.edit.updateClip(this.selectedTrackIdx, this.selectedClipIdx, {
67159
- asset: { ...t.asset, [i]: s ? void 0 : a }
67179
+ l && o && (!s && Hd.test(n) ? o.setClipBinding(l, r, { placeholder: n, resolvedValue: a }) : o.removeClipBinding(l, r)), !s && this.edit.updateClip(this.selectedTrackIdx, this.selectedClipIdx, {
67180
+ asset: { ...t.asset, [i]: a }
67160
67181
  });
67161
67182
  }
67162
67183
  selectModel(t) {
@@ -71530,9 +71551,18 @@ class Xa extends wa {
71530
71551
  }, r = this.verticalAlignIcon.querySelector("path");
71531
71552
  r && r.setAttribute("d", i[t]);
71532
71553
  }
71554
+ assetSupportsStyle(t) {
71555
+ return t?.type === "rich-text" || t?.type === "rich-caption";
71556
+ }
71533
71557
  cycleTransform(t) {
71558
+ if (!this.assetSupportsStyle(t)) return;
71534
71559
  const i = t.style?.textTransform ?? "none", r = ["none", "uppercase", "lowercase"], s = (r.indexOf(i) + 1) % r.length;
71535
- this.updateClipProperty({ style: { textTransform: r[s] } });
71560
+ this.updateClipProperty({
71561
+ style: {
71562
+ ...t.style ?? {},
71563
+ textTransform: r[s]
71564
+ }
71565
+ });
71536
71566
  }
71537
71567
  toggleUnderline(t) {
71538
71568
  const r = (t.style?.textDecoration ?? "none") === "underline" ? "none" : "underline";
@@ -71622,6 +71652,8 @@ class Xa extends wa {
71622
71652
  });
71623
71653
  }
71624
71654
  updateClipProperty(t) {
71655
+ if ("style" in t && !this.assetSupportsStyle(this.getCurrentAsset()))
71656
+ return;
71625
71657
  const i = { asset: t };
71626
71658
  this.edit.updateClip(this.selectedTrackIdx, this.selectedClipIdx, i), this.syncState();
71627
71659
  }