@rogieking/figui3 8.9.25 → 8.9.27

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/fig-editor.js CHANGED
@@ -1706,6 +1706,7 @@ class FigFillPicker extends HTMLElement {
1706
1706
  #rafIds = new Set();
1707
1707
  #ownedBlobUrls = new Set();
1708
1708
  #videoPosterCapturing = null;
1709
+ #videoPosterSrc = null;
1709
1710
 
1710
1711
  constructor() {
1711
1712
  super();
@@ -2134,8 +2135,12 @@ class FigFillPicker extends HTMLElement {
2134
2135
  const prevUrl = this.#video.url;
2135
2136
  this.#video = { ...this.#video, ...parsed.video };
2136
2137
  this.#video.missing = !this.#video.url;
2137
- if (this.#video.url !== prevUrl && parsed.video.poster == null) {
2138
+ if (parsed.video.poster != null && parsed.video.poster !== "") {
2139
+ this.#videoPosterSrc = this.#video.url;
2140
+ } else if (this.#video.url !== prevUrl) {
2138
2141
  this.#revokeVideoPoster();
2142
+ } else {
2143
+ this.#discardStaleVideoPoster();
2139
2144
  }
2140
2145
  }
2141
2146
  this.#applyParsedWebcam(parsed);
@@ -2157,6 +2162,7 @@ class FigFillPicker extends HTMLElement {
2157
2162
  this.#video.url = valueAttr.trim();
2158
2163
  this.#video.missing = false;
2159
2164
  if (this.#video.url !== prevUrl) this.#revokeVideoPoster();
2165
+ else this.#discardStaleVideoPoster();
2160
2166
  }
2161
2167
  }
2162
2168
  }
@@ -4477,12 +4483,28 @@ class FigFillPicker extends HTMLElement {
4477
4483
  this.#ownedBlobUrls.delete(this.#video.poster);
4478
4484
  }
4479
4485
  this.#video.poster = null;
4486
+ this.#videoPosterSrc = null;
4487
+ }
4488
+
4489
+ #discardStaleVideoPoster() {
4490
+ if (!this.#video.poster) return;
4491
+ if (this.#videoPosterSrc && this.#videoPosterSrc === this.#video.url) return;
4492
+ this.#revokeVideoPoster();
4493
+ }
4494
+
4495
+ #syncVideoPreview() {
4496
+ const preview = this.#dialog?.querySelector(
4497
+ ".fig-fill-picker-video-preview",
4498
+ );
4499
+ if (preview) this.#updateVideoPreviewStyle(preview);
4480
4500
  }
4481
4501
 
4482
4502
  #applyDefaultVideo({ emit = false } = {}) {
4483
4503
  if (this.#video.url) {
4484
4504
  this.#video.missing = false;
4505
+ this.#discardStaleVideoPoster();
4485
4506
  if (!this.#video.poster) this.#captureVideoPoster(this.#video.url);
4507
+ else this.#syncVideoPreview();
4486
4508
  return;
4487
4509
  }
4488
4510
  const fallback = this.getAttribute("default-video");
@@ -4492,10 +4514,7 @@ class FigFillPicker extends HTMLElement {
4492
4514
  }
4493
4515
  this.#video.url = fallback;
4494
4516
  this.#video.missing = false;
4495
- const preview = this.#dialog?.querySelector(
4496
- ".fig-fill-picker-video-preview",
4497
- );
4498
- if (preview) this.#updateVideoPreviewStyle(preview);
4517
+ this.#syncVideoPreview();
4499
4518
  this.#captureVideoPoster(fallback);
4500
4519
  if (emit) this.#emitInput();
4501
4520
  }
@@ -4503,7 +4522,9 @@ class FigFillPicker extends HTMLElement {
4503
4522
  #ensureVideoPoster() {
4504
4523
  if (this.#fillType !== "video") return;
4505
4524
  const src = this.#video.url;
4506
- if (!src || this.#video.poster) return;
4525
+ if (!src) return;
4526
+ this.#discardStaleVideoPoster();
4527
+ if (this.#video.poster) return;
4507
4528
  this.#captureVideoPoster(src);
4508
4529
  }
4509
4530
 
@@ -4578,8 +4599,10 @@ class FigFillPicker extends HTMLElement {
4578
4599
  if (!blob || this.#video.url !== src) return;
4579
4600
  this.#revokeVideoPoster();
4580
4601
  this.#video.poster = URL.createObjectURL(blob);
4602
+ this.#videoPosterSrc = src;
4581
4603
  this.#ownedBlobUrls.add(this.#video.poster);
4582
4604
  this.#updateSwatch();
4605
+ this.#syncVideoPreview();
4583
4606
  if (emit) this.#emitInput();
4584
4607
  } catch {
4585
4608
  // Cross-origin or decode failures leave the swatch empty until a poster exists.
@@ -4610,6 +4633,7 @@ class FigFillPicker extends HTMLElement {
4610
4633
  const src = e.detail?.src || preview.src;
4611
4634
  if (!src) return;
4612
4635
  const changed = src !== this.#video.url;
4636
+ if (changed) this.#revokeVideoPoster();
4613
4637
  this.#video.url = src;
4614
4638
  this.#video.missing = false;
4615
4639
  this.#updateVideoPreviewStyle(preview);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "8.9.25",
3
+ "version": "8.9.27",
4
4
  "description": "A lightweight web components library for building Figma plugin and widget UIs with native look and feel",
5
5
  "author": "Rogie King",
6
6
  "license": "SEE LICENSE IN LICENSE",