openvideo 0.2.11 → 0.2.12

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.
@@ -1,5 +1,5 @@
1
- import { e as a, A as e, C as i, a as s, E as t, F as n, D as d } from "./index-bXwx7D02.js";
2
- import "./webworkerAll-Bp3Psvud.js";
1
+ import { e as a, A as e, C as i, a as s, E as t, F as n, D as d } from "./index-B_HRuTe7.js";
2
+ import "./webworkerAll-CR5kqsNQ.js";
3
3
  a.add(e);
4
4
  a.mixin(i, s);
5
5
  a.add(t);
@@ -4,11 +4,14 @@ export declare class Placeholder extends BaseClip {
4
4
  type: string;
5
5
  meta: IClipMeta;
6
6
  constructor(src: string, meta?: Partial<IClipMeta>, type?: string);
7
- private placeholderFrame;
7
+ private canvas;
8
+ private ctx;
9
+ private animationRafId;
10
+ private renderPending;
8
11
  tick(time: number): Promise<{
9
12
  video?: ImageBitmap | null;
10
13
  audio?: Float32Array[];
11
- state: 'done' | 'success';
14
+ state: "done" | "success";
12
15
  }>;
13
16
  clone(): Promise<this>;
14
17
  split(time: number): Promise<[this, this]>;
@@ -18385,7 +18385,7 @@ const Lv = (r) => {
18385
18385
  },
18386
18386
  test: () => !0,
18387
18387
  load: async () => {
18388
- await import("./browserAll-BUI5hLdA.js");
18388
+ await import("./browserAll-BMIZWaux.js");
18389
18389
  }
18390
18390
  }, gC = {
18391
18391
  extension: {
@@ -18395,7 +18395,7 @@ const Lv = (r) => {
18395
18395
  },
18396
18396
  test: () => typeof self < "u" && self.WorkerGlobalScope !== void 0,
18397
18397
  load: async () => {
18398
- await import("./webworkerAll-Bp3Psvud.js");
18398
+ await import("./webworkerAll-CR5kqsNQ.js");
18399
18399
  }
18400
18400
  };
18401
18401
  class at {
@@ -71023,17 +71023,36 @@ class Fc extends zn {
71023
71023
  duration: t.duration || 5e6
71024
71024
  }, this.width = this.meta.width, this.height = this.meta.height, this.duration = this.meta.duration, this.trim.to = this.duration, this.display.to = this.display.from + this.duration, this.ready = Promise.resolve(this.meta);
71025
71025
  }
71026
- placeholderFrame = null;
71026
+ canvas = null;
71027
+ ctx = null;
71028
+ animationRafId = null;
71029
+ renderPending = !1;
71027
71030
  async tick(e) {
71028
- if (!this.placeholderFrame) {
71029
- const t = document.createElement("canvas");
71030
- t.width = this.meta.width, t.height = this.meta.height;
71031
- const i = t.getContext("2d");
71032
- i && (i.fillStyle = "#1e1e1e", i.fillRect(0, 0, t.width, t.height), i.fillStyle = "#ffffff", i.font = `${Math.floor(t.height / 10)}px sans-serif`, i.textAlign = "center", i.textBaseline = "middle", i.fillText("Loading...", t.width / 2, t.height / 2), i.strokeStyle = "#333333", i.lineWidth = 10, i.strokeRect(0, 0, t.width, t.height)), this.placeholderFrame = await createImageBitmap(t);
71031
+ this.canvas || (this.canvas = document.createElement("canvas"), this.canvas.width = this.meta.width, this.canvas.height = this.meta.height, this.ctx = this.canvas.getContext("2d"));
71032
+ const { canvas: t, ctx: i } = this;
71033
+ if (i) {
71034
+ const { width: s, height: o } = t;
71035
+ if (s > 0 && o > 0) {
71036
+ i.fillStyle = "#1e1e1e", i.fillRect(0, 0, s, o);
71037
+ const a = s / 2, l = o / 2, u = 100, c = u / 4, h = performance.now() / 2e3 * Math.PI * 2;
71038
+ i.save();
71039
+ const d = i.createConicGradient(h, a, l);
71040
+ d.addColorStop(0, "#ffffff"), d.addColorStop(0.2, "#ffffff"), d.addColorStop(0.5, "rgba(255, 255, 255, 0.4)"), d.addColorStop(0.8, "rgba(255, 255, 255, 0.1)"), d.addColorStop(1, "rgba(255, 255, 255, 0)"), i.strokeStyle = d, i.lineWidth = c, i.lineCap = "round", i.beginPath(), i.arc(a, l, u, h, h + Math.PI * 1.5), i.stroke(), i.restore(), i.strokeStyle = "#333333", i.lineWidth = 10, i.strokeRect(0, 0, s, o);
71041
+ }
71042
+ }
71043
+ if (this.renderPending = !1, this.animationRafId === null) {
71044
+ const s = () => {
71045
+ if (this.destroyed) {
71046
+ this.animationRafId = null;
71047
+ return;
71048
+ }
71049
+ this.renderPending || (this.renderPending = !0, this.emit("request-render")), this.animationRafId = requestAnimationFrame(s);
71050
+ };
71051
+ this.animationRafId = requestAnimationFrame(s);
71033
71052
  }
71034
71053
  return {
71035
- video: this.placeholderFrame,
71036
- state: e >= this.duration ? "done" : "success",
71054
+ video: t.width > 0 && t.height > 0 ? await createImageBitmap(t) : null,
71055
+ state: "success",
71037
71056
  audio: []
71038
71057
  };
71039
71058
  }
@@ -90233,6 +90252,7 @@ class gte {
90233
90252
  this.updatePreviewSelection(u);
90234
90253
  } else
90235
90254
  this.selectedClips.size === 0 && this.destroyTransformer();
90255
+ this.studio.pixiApp?.render();
90236
90256
  }
90237
90257
  }
90238
90258
  onStagePointerUp() {
@@ -91745,10 +91765,22 @@ class Yte extends vy {
91745
91765
  ...e
91746
91766
  }, this.selection = new gte(this), this.transport = new vte(this), this.timeline = new yte(this), this.history = new _te(), this.resourceManager = new Do(), this.ready = this.initPixiApp().then(() => {
91747
91767
  this.history.init(this.exportToJSON());
91748
- }), this.on("clip:removed", this.handleClipRemoved), this.on("clips:removed", this.handleClipsRemoved), this.on("clip:updated", this.handleTimelineChange), this.on("clip:added", this.handleTimelineChange), this.on("clips:added", this.handleTimelineChange), this.on("track:removed", this.handleTimelineChange), this.on("track:added", this.handleTimelineChange);
91768
+ }), this.on("clip:added", (t) => this.handleTimelineChange(t)), this.on("clips:added", (t) => this.handleTimelineChange(t)), this.on(
91769
+ "clip:replaced",
91770
+ (t) => this.handleTimelineChange({ clip: t.newClip })
91771
+ ), this.on("studio:restored", (t) => {
91772
+ t.clips.forEach((i) => this.attachClipEvents(i)), this.handleTimelineChange();
91773
+ }), this.on("clip:removed", this.handleClipRemoved), this.on("clips:removed", this.handleClipsRemoved), this.on("clip:updated", this.handleTimelineChange), this.on("track:removed", () => this.handleTimelineChange()), this.on("track:added", () => this.handleTimelineChange());
91774
+ }
91775
+ attachClipEvents(e) {
91776
+ if (this.clipListeners.has(e)) return;
91777
+ const t = () => {
91778
+ this.updateFrame(this.currentTime);
91779
+ };
91780
+ e.on("request-render", t), this.clipListeners.set(e, t);
91749
91781
  }
91750
- handleTimelineChange = () => {
91751
- this.updateFrame(this.currentTime), this.saveHistory();
91782
+ handleTimelineChange = (e) => {
91783
+ e?.clip && this.attachClipEvents(e.clip), e?.clips && e.clips.forEach((t) => this.attachClipEvents(t)), this.updateFrame(this.currentTime), this.saveHistory();
91752
91784
  };
91753
91785
  saveHistory() {
91754
91786
  this.historyPaused || this.processingHistory || (this.history.push(this.exportToJSON()), this.emit("history:changed", {
@@ -91797,7 +91829,7 @@ class Yte extends vy {
91797
91829
  }
91798
91830
  for (const [a, l] of s) {
91799
91831
  let u = this.clipCache.get(a);
91800
- u || (u = await Va(l), this.clipCache.set(a, u));
91832
+ u || (u = await Va(l), this.clipCache.set(a, u), this.attachClipEvents(u));
91801
91833
  let c;
91802
91834
  for (const h of t.tracks)
91803
91835
  if (h.clipIds.includes(a)) {
@@ -91843,24 +91875,24 @@ class Yte extends vy {
91843
91875
  }
91844
91876
  }
91845
91877
  cleanupClipVisuals = (e) => {
91846
- for (const [n, s] of this.spriteRenderers)
91847
- if (n.id === e) {
91848
- const o = s.getRoot();
91849
- o && o.parent && o.parent.removeChild(o), s.destroy(), this.spriteRenderers.delete(n);
91878
+ for (const [s, o] of this.spriteRenderers)
91879
+ if (s.id === e) {
91880
+ const a = o.getRoot();
91881
+ a && a.parent && a.parent.removeChild(a), o.destroy(), this.spriteRenderers.delete(s);
91850
91882
  break;
91851
91883
  }
91852
91884
  const t = this.transitionSprites.get(e);
91853
91885
  t && (t.parent && t.parent.removeChild(t), t.destroy(), this.transitionSprites.delete(e)), this.transitionRenderers.get(e) && this.transitionRenderers.delete(e);
91854
- for (const [n, s] of this.videoSprites)
91855
- if (n.id === e) {
91856
- s.parent && s.parent.removeChild(s), s.destroy(), this.videoSprites.delete(n);
91857
- break;
91858
- }
91859
- for (const [n] of this.clipListeners)
91860
- if (n.id === e) {
91861
- this.clipListeners.delete(n);
91886
+ for (const [s, o] of this.videoSprites)
91887
+ if (s.id === e) {
91888
+ o.parent && o.parent.removeChild(o), o.destroy(), this.videoSprites.delete(s);
91862
91889
  break;
91863
91890
  }
91891
+ const n = this.timeline.getClipById(e);
91892
+ if (n) {
91893
+ const s = this.clipListeners.get(n);
91894
+ s && (n.off("request-render", s), this.clipListeners.delete(n));
91895
+ }
91864
91896
  };
91865
91897
  handleClipRemoved = ({ clipId: e }) => {
91866
91898
  this.cleanupClipVisuals(e), this.updateFrame(this.currentTime), this.saveHistory();
@@ -91972,9 +92004,11 @@ class Yte extends vy {
91972
92004
  * @param options Options for addition (trackId, etc.)
91973
92005
  */
91974
92006
  async addClip(e, t) {
91975
- (Array.isArray(e) ? e : [e]).forEach((n) => this.clipCache.set(n.id, n)), this.beginHistoryGroup();
92007
+ const i = Array.isArray(e) ? e : [e];
92008
+ i.forEach((n) => this.clipCache.set(n.id, n)), this.beginHistoryGroup();
91976
92009
  try {
91977
- return await this.timeline.addClip(e, t);
92010
+ const n = await this.timeline.addClip(e, t);
92011
+ return i.forEach((s) => this.attachClipEvents(s)), n;
91978
92012
  } finally {
91979
92013
  this.endHistoryGroup();
91980
92014
  }
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a4 as t, p as e, q as i, w as o, v as n, t as r, Y as T, a2 as E, I as m, a9 as f, L as g, V as A, P as I, S as C, s as L, u as P, K as S, O as _, V as l, a8 as O, x as c, o as p, a6 as u, a5 as M, l as d, m as F, z as N, W as x, a0 as R, a7 as U, X as V, a3 as y, a1 as k, y as D, J as h, Z as w, n as B, Q as G, _ as J, r as K, U as j, $ as q } from "./index-bXwx7D02.js";
1
+ import { a4 as t, p as e, q as i, w as o, v as n, t as r, Y as T, a2 as E, I as m, a9 as f, L as g, V as A, P as I, S as C, s as L, u as P, K as S, O as _, V as l, a8 as O, x as c, o as p, a6 as u, a5 as M, l as d, m as F, z as N, W as x, a0 as R, a7 as U, X as V, a3 as y, a1 as k, y as D, J as h, Z as w, n as B, Q as G, _ as J, r as K, U as j, $ as q } from "./index-B_HRuTe7.js";
2
2
  export {
3
3
  t as ANIMATABLE_PROPERTIES,
4
4
  e as Audio,