openvideo 0.2.11 → 0.2.13

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-CFp3iXGD.js";
2
+ import "./webworkerAll-CY-_3YK7.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-DG5bDuMQ.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-CY-_3YK7.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
  }
@@ -90208,6 +90227,9 @@ class gte {
90208
90227
  textClipResizeHandle = null;
90209
90228
  textClipResizedSx = null;
90210
90229
  textClipResizedSy = null;
90230
+ // Double-click detection state
90231
+ lastPointerDownTime = 0;
90232
+ lastPointerDownClip = null;
90211
90233
  init(e, t) {
90212
90234
  this.selectionGraphics = new Ke(), this.selectionGraphics.visible = !1, this.selectionGraphics.zIndex = 1e3, t.addChild(this.selectionGraphics), e.stage.eventMode = "static", e.stage.hitArea = e.screen, e.stage.on("pointerdown", (i) => this.onStagePointerDown(i)), e.stage.on("globalpointermove", (i) => this.onStagePointerMove(i)), e.stage.on("pointerup", () => this.onStagePointerUp()), e.stage.on("pointerupoutside", () => this.onStagePointerUp());
90213
90235
  }
@@ -90233,6 +90255,7 @@ class gte {
90233
90255
  this.updatePreviewSelection(u);
90234
90256
  } else
90235
90257
  this.selectedClips.size === 0 && this.destroyTransformer();
90258
+ this.studio.pixiApp?.render();
90236
90259
  }
90237
90260
  }
90238
90261
  onStagePointerUp() {
@@ -90307,8 +90330,8 @@ class gte {
90307
90330
  if (t == null) return;
90308
90331
  const i = t.getRoot();
90309
90332
  i != null && (i.eventMode = "static", i.cursor = "pointer", i.on("pointerdown", (n) => {
90310
- const s = this.getTopmostClipAtPoint(n.global);
90311
- s && this.selectClip(s, n.shiftKey);
90333
+ const s = Date.now(), o = this.getTopmostClipAtPoint(n.global);
90334
+ o === e && o === this.lastPointerDownClip && s - this.lastPointerDownTime < 350 && (o.type === "Text" || o.type === "Caption") && this.studio.emit("clip:dblclick", { clip: o }), this.lastPointerDownTime = s, this.lastPointerDownClip = o, o && this.selectClip(o, n.shiftKey);
90312
90335
  }), this.interactiveClips.add(e));
90313
90336
  }
90314
90337
  /**
@@ -90434,8 +90457,8 @@ class gte {
90434
90457
  this.studio.emit("transform:start", {
90435
90458
  transformer: this.activeTransformer
90436
90459
  });
90437
- const o = this.getTopmostClipAtPoint(s.global);
90438
- o && !this.selectedClips.has(o) && (this.selectClip(o, s.shiftKey), s.stopPropagation());
90460
+ const o = this.getTopmostClipAtPoint(s.global), a = Date.now();
90461
+ o && o === this.lastPointerDownClip && a - this.lastPointerDownTime < 350 && (o.type === "Text" || o.type === "Caption") && this.studio.emit("clip:dblclick", { clip: o }), this.lastPointerDownTime = a, this.lastPointerDownClip = o, o && !this.selectedClips.has(o) && (this.selectClip(o, s.shiftKey), s.stopPropagation());
90439
90462
  }), this.studio.artboard.addChild(this.activeTransformer), this.activeTransformer.showImmediate(), this.studio.pixiApp?.render();
90440
90463
  }
90441
90464
  // Copied Sync Logic
@@ -91745,10 +91768,22 @@ class Yte extends vy {
91745
91768
  ...e
91746
91769
  }, 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
91770
  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);
91771
+ }), this.on("clip:added", (t) => this.handleTimelineChange(t)), this.on("clips:added", (t) => this.handleTimelineChange(t)), this.on(
91772
+ "clip:replaced",
91773
+ (t) => this.handleTimelineChange({ clip: t.newClip })
91774
+ ), this.on("studio:restored", (t) => {
91775
+ t.clips.forEach((i) => this.attachClipEvents(i)), this.handleTimelineChange();
91776
+ }), 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());
91777
+ }
91778
+ attachClipEvents(e) {
91779
+ if (this.clipListeners.has(e)) return;
91780
+ const t = () => {
91781
+ this.updateFrame(this.currentTime);
91782
+ };
91783
+ e.on("request-render", t), this.clipListeners.set(e, t);
91749
91784
  }
91750
- handleTimelineChange = () => {
91751
- this.updateFrame(this.currentTime), this.saveHistory();
91785
+ handleTimelineChange = (e) => {
91786
+ e?.clip && this.attachClipEvents(e.clip), e?.clips && e.clips.forEach((t) => this.attachClipEvents(t)), this.updateFrame(this.currentTime), this.saveHistory();
91752
91787
  };
91753
91788
  saveHistory() {
91754
91789
  this.historyPaused || this.processingHistory || (this.history.push(this.exportToJSON()), this.emit("history:changed", {
@@ -91797,7 +91832,7 @@ class Yte extends vy {
91797
91832
  }
91798
91833
  for (const [a, l] of s) {
91799
91834
  let u = this.clipCache.get(a);
91800
- u || (u = await Va(l), this.clipCache.set(a, u));
91835
+ u || (u = await Va(l), this.clipCache.set(a, u), this.attachClipEvents(u));
91801
91836
  let c;
91802
91837
  for (const h of t.tracks)
91803
91838
  if (h.clipIds.includes(a)) {
@@ -91843,24 +91878,24 @@ class Yte extends vy {
91843
91878
  }
91844
91879
  }
91845
91880
  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);
91881
+ for (const [s, o] of this.spriteRenderers)
91882
+ if (s.id === e) {
91883
+ const a = o.getRoot();
91884
+ a && a.parent && a.parent.removeChild(a), o.destroy(), this.spriteRenderers.delete(s);
91850
91885
  break;
91851
91886
  }
91852
91887
  const t = this.transitionSprites.get(e);
91853
91888
  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);
91889
+ for (const [s, o] of this.videoSprites)
91890
+ if (s.id === e) {
91891
+ o.parent && o.parent.removeChild(o), o.destroy(), this.videoSprites.delete(s);
91862
91892
  break;
91863
91893
  }
91894
+ const n = this.timeline.getClipById(e);
91895
+ if (n) {
91896
+ const s = this.clipListeners.get(n);
91897
+ s && (n.off("request-render", s), this.clipListeners.delete(n));
91898
+ }
91864
91899
  };
91865
91900
  handleClipRemoved = ({ clipId: e }) => {
91866
91901
  this.cleanupClipVisuals(e), this.updateFrame(this.currentTime), this.saveHistory();
@@ -91972,9 +92007,11 @@ class Yte extends vy {
91972
92007
  * @param options Options for addition (trackId, etc.)
91973
92008
  */
91974
92009
  async addClip(e, t) {
91975
- (Array.isArray(e) ? e : [e]).forEach((n) => this.clipCache.set(n.id, n)), this.beginHistoryGroup();
92010
+ const i = Array.isArray(e) ? e : [e];
92011
+ i.forEach((n) => this.clipCache.set(n.id, n)), this.beginHistoryGroup();
91976
92012
  try {
91977
- return await this.timeline.addClip(e, t);
92013
+ const n = await this.timeline.addClip(e, t);
92014
+ return i.forEach((s) => this.attachClipEvents(s)), n;
91978
92015
  } finally {
91979
92016
  this.endHistoryGroup();
91980
92017
  }
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-CFp3iXGD.js";
2
2
  export {
3
3
  t as ANIMATABLE_PROPERTIES,
4
4
  e as Audio,