@video-editor/ui 0.0.1-beta.7 → 0.0.1-beta.9

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.
@@ -5,19 +5,10 @@ import { ITrackType } from '@video-editor/shared';
5
5
  import { IVideoProtocol } from '@video-editor/shared';
6
6
  import { PublicProps } from 'vue';
7
7
  import { SegmentUnion } from '@video-editor/shared';
8
+ import { TimelineTick } from '..';
8
9
  import { TrackUnion } from '@video-editor/shared';
9
10
 
10
- declare type __VLS_Props = {
11
- protocol?: IVideoProtocol | null;
12
- currentTime: number;
13
- zoom?: number;
14
- snapStep?: number;
15
- selectedSegmentId?: string | null;
16
- trackTypes?: ITrackType[];
17
- disableInteraction?: boolean;
18
- };
19
-
20
- declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
11
+ declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
21
12
  "update:currentTime": (value: number) => any;
22
13
  "update:zoom": (value: number) => any;
23
14
  segmentClick: (payload: {
@@ -44,6 +35,52 @@ selectedSegmentId: string | null;
44
35
  protocol: IVideoProtocol | null;
45
36
  trackTypes: ITrackType[];
46
37
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
38
+
39
+ declare type __VLS_Props = {
40
+ protocol?: IVideoProtocol | null;
41
+ currentTime: number;
42
+ zoom?: number;
43
+ snapStep?: number;
44
+ selectedSegmentId?: string | null;
45
+ trackTypes?: ITrackType[];
46
+ disableInteraction?: boolean;
47
+ };
48
+
49
+ declare function __VLS_template(): {
50
+ attrs: Partial<{}>;
51
+ slots: {
52
+ toolbar?(_: {
53
+ zoom: number;
54
+ canZoomIn: boolean;
55
+ canZoomOut: boolean;
56
+ zoomIn: () => void;
57
+ zoomOut: () => void;
58
+ currentTime: number;
59
+ duration: number;
60
+ formatTime: (ms: number) => string;
61
+ }): any;
62
+ ruler?(_: {
63
+ ticks: TimelineTick[];
64
+ pixelsPerMs: number;
65
+ }): any;
66
+ playhead?(_: {
67
+ left: number;
68
+ currentTime: number;
69
+ }): any;
70
+ };
71
+ refs: {};
72
+ rootEl: HTMLDivElement;
73
+ };
74
+
75
+ declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
76
+
77
+ declare type __VLS_WithTemplateSlots<T, S> = T & {
78
+ new (): {
79
+ $slots: S;
80
+ };
81
+ };
82
+
83
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
47
84
  export default _default;
48
85
 
49
86
  declare interface SegmentDragPayload {
@@ -1,66 +1,66 @@
1
- import { defineComponent as C, reactive as N, watch as V, onBeforeUnmount as O, createElementBlock as c, openBlock as r, createCommentVNode as M, normalizeStyle as x, Fragment as S, renderList as D, createElementVNode as y, toDisplayString as _, computed as b, ref as P, createBlock as z, withCtx as H, unref as L } from "vue";
2
- import { _ as U, V as J } from "./index-y5KhRW21.js";
3
- import { generateThumbnails as Y } from "@video-editor/protocol";
4
- import { isVideoFramesSegment as q } from "@video-editor/shared";
5
- const G = { class: "frames-segment" }, K = {
1
+ import { defineComponent as V, reactive as J, watch as P, onBeforeUnmount as Y, createElementBlock as l, openBlock as r, createCommentVNode as x, normalizeStyle as L, Fragment as v, renderList as j, createElementVNode as y, toDisplayString as h, computed as S, ref as q, createBlock as E, createSlots as G, withCtx as _, unref as w, renderSlot as C, normalizeProps as M, guardReactiveProps as U } from "vue";
2
+ import { _ as D, V as K } from "./index-B4a4-K9f.js";
3
+ import { generateThumbnails as Q } from "@video-editor/protocol";
4
+ import { isVideoFramesSegment as W } from "@video-editor/shared";
5
+ const X = { class: "frames-segment" }, Z = {
6
6
  key: 0,
7
7
  class: "frames-segment__video"
8
- }, Q = {
8
+ }, ee = {
9
9
  key: 1,
10
10
  class: "frames-segment__placeholder"
11
- }, W = { key: 0 }, X = { key: 1 }, Z = { key: 2 }, ee = {
11
+ }, te = { key: 0 }, ne = { key: 1 }, se = { key: 2 }, re = {
12
12
  key: 2,
13
13
  class: "frames-segment__placeholder"
14
- }, te = {
14
+ }, ae = {
15
15
  key: 3,
16
16
  class: "frames-segment__badge"
17
- }, ne = /* @__PURE__ */ C({
17
+ }, oe = /* @__PURE__ */ V({
18
18
  name: "FramesSegment",
19
19
  __name: "FramesSegment",
20
20
  props: {
21
21
  segment: {}
22
22
  },
23
23
  setup(o) {
24
- const g = o, t = N({ items: [], loading: !1, error: null });
25
- let l = 0;
26
- V(() => g.segment, (s, i) => {
27
- if (!q(s))
24
+ const g = o, n = J({ items: [], loading: !1, error: null });
25
+ let c = 0;
26
+ P(() => g.segment, (s, i) => {
27
+ if (!W(s))
28
28
  return;
29
- (!i || f(i, s)) && v(s);
30
- }, { immediate: !0, deep: !0 }), O(() => {
31
- h();
29
+ (!i || f(i, s)) && $(s);
30
+ }, { immediate: !0, deep: !0 }), Y(() => {
31
+ b();
32
32
  });
33
33
  function f(s, i) {
34
34
  return s.url !== i.url || s.startTime !== i.startTime || s.endTime !== i.endTime || s.fromTime !== i.fromTime;
35
35
  }
36
- async function v(s) {
36
+ async function $(s) {
37
37
  if (!s.url)
38
38
  return;
39
- const i = ++l;
40
- h(), t.loading = !0, t.error = null;
39
+ const i = ++c;
40
+ b(), n.loading = !0, n.error = null;
41
41
  try {
42
- const m = I(s), u = await Y(s.url, m);
43
- if (l !== i)
42
+ const m = I(s), u = await Q(s.url, m);
43
+ if (c !== i)
44
44
  return;
45
45
  const T = u.map((k) => ({
46
46
  tsMs: Math.round(k.ts / 1e3),
47
47
  url: URL.createObjectURL(k.img)
48
48
  }));
49
- t.items = T, t.loading = !1;
49
+ n.items = T, n.loading = !1;
50
50
  } catch (m) {
51
- if (l !== i)
51
+ if (c !== i)
52
52
  return;
53
- t.error = m instanceof Error ? m.message : String(m), t.loading = !1;
53
+ n.error = m instanceof Error ? m.message : String(m), n.loading = !1;
54
54
  }
55
55
  }
56
56
  function I(s) {
57
57
  const i = Math.max(s.fromTime ?? 0, 0) * 1e3, m = Math.max(s.endTime - s.startTime, 1), u = i + m * 1e3, k = Math.max(Math.floor((u - i) / 8), 2e5);
58
58
  return { start: i, end: u, step: k };
59
59
  }
60
- function h() {
61
- t.items.forEach((s) => URL.revokeObjectURL(s.url)), t.items = [];
60
+ function b() {
61
+ n.items.forEach((s) => URL.revokeObjectURL(s.url)), n.items = [];
62
62
  }
63
- function $() {
63
+ function R() {
64
64
  return {
65
65
  backgroundImage: g.segment.url ? `url(${g.segment.url})` : "",
66
66
  backgroundRepeat: "repeat-x",
@@ -68,31 +68,31 @@ const G = { class: "frames-segment" }, K = {
68
68
  backgroundPosition: "left center"
69
69
  };
70
70
  }
71
- return (s, i) => (r(), c("div", G, [
72
- o.segment.type === "image" ? (r(), c("div", {
71
+ return (s, i) => (r(), l("div", X, [
72
+ o.segment.type === "image" ? (r(), l("div", {
73
73
  key: 0,
74
74
  class: "frames-segment__image",
75
- style: x($())
76
- }, null, 4)) : o.segment.type === "video" ? (r(), c(S, { key: 1 }, [
77
- t.items.length ? (r(), c("div", K, [
78
- (r(!0), c(S, null, D(t.items, (m) => (r(), c("div", {
75
+ style: L(R())
76
+ }, null, 4)) : o.segment.type === "video" ? (r(), l(v, { key: 1 }, [
77
+ n.items.length ? (r(), l("div", Z, [
78
+ (r(!0), l(v, null, j(n.items, (m) => (r(), l("div", {
79
79
  key: `${o.segment.id}-${m.tsMs}`,
80
80
  class: "frames-segment__thumb",
81
- style: x({ backgroundImage: `url(${m.url})` })
81
+ style: L({ backgroundImage: `url(${m.url})` })
82
82
  }, null, 4))), 128))
83
- ])) : (r(), c("div", Q, [
84
- t.loading ? (r(), c("span", W, "抽帧中…")) : t.error ? (r(), c("span", X, "生成失败")) : (r(), c("span", Z, "未生成缩略图"))
83
+ ])) : (r(), l("div", ee, [
84
+ n.loading ? (r(), l("span", te, "抽帧中…")) : n.error ? (r(), l("span", ne, "生成失败")) : (r(), l("span", se, "未生成缩略图"))
85
85
  ]))
86
- ], 64)) : (r(), c("div", ee, [
87
- y("span", null, _(o.segment.type), 1)
86
+ ], 64)) : (r(), l("div", re, [
87
+ y("span", null, h(o.segment.type), 1)
88
88
  ])),
89
- o.segment.extra?.label ? (r(), c("span", te, _(o.segment.extra?.label), 1)) : M("", !0)
89
+ o.segment.extra?.label ? (r(), l("span", ae, h(o.segment.extra?.label), 1)) : x("", !0)
90
90
  ]));
91
91
  }
92
- }), se = /* @__PURE__ */ U(ne, [["__scopeId", "data-v-dd7a5d19"]]), re = { class: "segment-base" }, ae = { class: "segment-base__content" }, oe = { class: "segment-base__pill segment-base__pill--primary" }, ie = { class: "segment-base__pill segment-base__pill--muted" }, ce = {
92
+ }), ie = /* @__PURE__ */ D(oe, [["__scopeId", "data-v-dd7a5d19"]]), le = { class: "segment-base" }, ce = { class: "segment-base__content" }, me = { class: "segment-base__pill segment-base__pill--primary" }, de = { class: "segment-base__pill segment-base__pill--muted" }, ue = {
93
93
  key: 0,
94
94
  class: "segment-base__badge"
95
- }, le = /* @__PURE__ */ C({
95
+ }, ge = /* @__PURE__ */ V({
96
96
  name: "SegmentBase",
97
97
  __name: "SegmentBase",
98
98
  props: {
@@ -101,19 +101,19 @@ const G = { class: "frames-segment" }, K = {
101
101
  accentColor: { default: "#222226" }
102
102
  },
103
103
  setup(o) {
104
- const g = o, t = b(() => {
105
- const l = g.segment?.extra?.label;
106
- return typeof l == "string" ? l : null;
104
+ const g = o, n = S(() => {
105
+ const c = g.segment?.extra?.label;
106
+ return typeof c == "string" ? c : null;
107
107
  });
108
- return (l, f) => (r(), c("div", re, [
109
- y("div", ae, [
110
- y("span", oe, _(o.trackType), 1),
111
- y("span", ie, _(o.segment.segmentType), 1)
108
+ return (c, f) => (r(), l("div", le, [
109
+ y("div", ce, [
110
+ y("span", me, h(o.trackType), 1),
111
+ y("span", de, h(o.segment.segmentType), 1)
112
112
  ]),
113
- t.value ? (r(), c("span", ce, _(t.value), 1)) : M("", !0)
113
+ n.value ? (r(), l("span", ue, h(n.value), 1)) : x("", !0)
114
114
  ]));
115
115
  }
116
- }), me = /* @__PURE__ */ U(le, [["__scopeId", "data-v-d386af72"]]), de = { class: "ve-editor-segment__preview" }, E = "#222226", ue = 0.4, ge = /* @__PURE__ */ C({
116
+ }), pe = /* @__PURE__ */ D(ge, [["__scopeId", "data-v-d386af72"]]), fe = { class: "ve-editor-segment__preview" }, B = "#222226", ke = 0.4, ye = /* @__PURE__ */ V({
117
117
  name: "VideoEditorTimeline",
118
118
  __name: "index",
119
119
  props: {
@@ -127,25 +127,25 @@ const G = { class: "frames-segment" }, K = {
127
127
  },
128
128
  emits: ["update:currentTime", "update:zoom", "update:selectedSegmentId", "segmentClick", "segmentDragEnd", "segmentResizeEnd"],
129
129
  setup(o, { emit: g }) {
130
- const t = o, l = g, f = P(t.selectedSegmentId ?? null);
131
- V(() => t.selectedSegmentId, (e) => {
130
+ const n = o, c = g, f = q(n.selectedSegmentId ?? null);
131
+ P(() => n.selectedSegmentId, (e) => {
132
132
  f.value = e ?? null;
133
133
  });
134
- const v = {
135
- frames: E,
134
+ const $ = {
135
+ frames: B,
136
136
  audio: "#0ea5e9",
137
137
  text: "#16a34a",
138
138
  sticker: "#f97316",
139
139
  effect: "#a855f7",
140
140
  filter: "#64748b"
141
- }, I = b(() => t.protocol?.tracks?.length ? t.trackTypes?.length ? t.protocol.tracks.filter((e) => t.trackTypes?.includes(e.trackType)) : t.protocol.tracks : []), h = b(() => I.value.map((e, a) => {
142
- const n = v[e.trackType] || E, d = s(n, ue), R = e.trackType === "frames" && e.isMain === !0;
141
+ }, I = S(() => n.protocol?.tracks?.length ? n.trackTypes?.length ? n.protocol.tracks.filter((e) => n.trackTypes?.includes(e.trackType)) : n.protocol.tracks : []), b = S(() => I.value.map((e, a) => {
142
+ const t = $[e.trackType] || B, d = s(t, ke), z = e.trackType === "frames" && e.isMain === !0;
143
143
  return {
144
144
  id: e.trackId || `${e.trackType}-${a}`,
145
145
  label: e.trackType,
146
146
  type: e.trackType,
147
- color: n,
148
- isMain: R,
147
+ color: t,
148
+ isMain: z,
149
149
  payload: e,
150
150
  segments: e.children.map((p) => ({
151
151
  id: p.id,
@@ -156,18 +156,18 @@ const G = { class: "frames-segment" }, K = {
156
156
  payload: p
157
157
  }))
158
158
  };
159
- })), $ = b(() => {
160
- if (!t.protocol?.tracks?.length)
159
+ })), R = S(() => {
160
+ if (!n.protocol?.tracks?.length)
161
161
  return 0;
162
- const e = t.protocol.tracks.flatMap((a) => a.children.map((n) => n.endTime));
162
+ const e = n.protocol.tracks.flatMap((a) => a.children.map((t) => t.endTime));
163
163
  return e.length ? Math.max(...e) : 0;
164
164
  });
165
165
  function s(e, a) {
166
- const n = e.replace("#", "");
167
- if (!(n.length === 3 || n.length === 6))
166
+ const t = e.replace("#", "");
167
+ if (!(t.length === 3 || t.length === 6))
168
168
  return e;
169
- const d = n.length === 3 ? n.split("").map((B) => B + B).join("") : n, R = Number.parseInt(d.slice(0, 2), 16), p = Number.parseInt(d.slice(2, 4), 16), A = Number.parseInt(d.slice(4, 6), 16);
170
- return `rgba(${R}, ${p}, ${A}, ${a})`;
169
+ const d = t.length === 3 ? t.split("").map((F) => F + F).join("") : t, z = Number.parseInt(d.slice(0, 2), 16), p = Number.parseInt(d.slice(2, 4), 16), H = Number.parseInt(d.slice(4, 6), 16);
170
+ return `rgba(${z}, ${p}, ${H}, ${a})`;
171
171
  }
172
172
  function i(e) {
173
173
  return e && typeof e == "object" && "segmentType" in e ? e : null;
@@ -176,73 +176,95 @@ const G = { class: "frames-segment" }, K = {
176
176
  const a = e.payload;
177
177
  if (a)
178
178
  return a;
179
- if (t.protocol)
180
- return t.protocol.tracks.find((n) => n.trackId === e.id);
179
+ if (n.protocol)
180
+ return n.protocol.tracks.find((t) => t.trackId === e.id);
181
181
  }
182
182
  function u(e) {
183
- f.value = e, l("update:selectedSegmentId", e);
183
+ f.value = e, c("update:selectedSegmentId", e);
184
184
  }
185
185
  function T(e) {
186
- const a = i(e.segment.payload), n = m(e.track);
187
- a && (u(a.id), n && l("segmentClick", { segment: a, track: n }));
186
+ const a = i(e.segment.payload), t = m(e.track);
187
+ a && (u(a.id), t && c("segmentClick", { segment: a, track: t }));
188
188
  }
189
189
  function k(e) {
190
190
  u(e.segment.id);
191
191
  }
192
- function F(e) {
193
- l("segmentDragEnd", e);
192
+ function A(e) {
193
+ c("segmentDragEnd", e);
194
194
  }
195
- function w(e) {
195
+ function N(e) {
196
196
  u(e.segment.id);
197
197
  }
198
- function j(e) {
199
- l("segmentResizeEnd", e);
198
+ function O(e) {
199
+ c("segmentResizeEnd", e);
200
200
  }
201
- return (e, a) => (r(), z(J, {
202
- tracks: h.value,
203
- duration: $.value,
201
+ return (e, a) => (r(), E(K, {
202
+ tracks: b.value,
203
+ duration: R.value,
204
204
  "current-time": o.currentTime,
205
205
  zoom: o.zoom,
206
206
  fps: o.protocol?.fps || 30,
207
207
  "snap-step": o.snapStep,
208
208
  "selected-segment-id": f.value ?? null,
209
209
  "disable-interaction": o.disableInteraction,
210
- "onUpdate:currentTime": a[0] || (a[0] = (n) => l("update:currentTime", n)),
211
- "onUpdate:zoom": a[1] || (a[1] = (n) => l("update:zoom", n)),
210
+ "onUpdate:currentTime": a[0] || (a[0] = (t) => c("update:currentTime", t)),
211
+ "onUpdate:zoom": a[1] || (a[1] = (t) => c("update:zoom", t)),
212
212
  onSegmentClick: T,
213
213
  onSegmentDragStart: k,
214
- onSegmentDragEnd: F,
215
- onSegmentResizeStart: w,
216
- onSegmentResizeEnd: j,
217
- onBackgroundClick: a[2] || (a[2] = (n) => u(null))
218
- }, {
219
- segment: H(({ layout: n }) => [
220
- (r(!0), c(S, null, D([i(n.segment.payload)], (d) => (r(), c(S, {
221
- key: d?.id || n.segment.id
214
+ onSegmentDragEnd: A,
215
+ onSegmentResizeStart: N,
216
+ onSegmentResizeEnd: O,
217
+ onBackgroundClick: a[2] || (a[2] = (t) => u(null))
218
+ }, G({
219
+ segment: _(({ layout: t }) => [
220
+ (r(!0), l(v, null, j([i(t.segment.payload)], (d) => (r(), l(v, {
221
+ key: d?.id || t.segment.id
222
222
  }, [
223
- d ? (r(), c("div", {
223
+ d ? (r(), l("div", {
224
224
  key: 0,
225
225
  class: "ve-editor-segment",
226
- style: x({ "--ve-segment-accent": n.track.color || E })
226
+ style: L({ "--ve-segment-accent": t.track.color || B })
227
227
  }, [
228
- y("div", de, [
229
- d.segmentType === "frames" ? (r(), z(L(se), {
228
+ y("div", fe, [
229
+ d.segmentType === "frames" ? (r(), E(w(ie), {
230
230
  key: 0,
231
231
  segment: d
232
- }, null, 8, ["segment"])) : (r(), z(L(me), {
232
+ }, null, 8, ["segment"])) : (r(), E(w(pe), {
233
233
  key: 1,
234
234
  segment: d,
235
- "track-type": n.track.type || "unknown",
236
- "accent-color": n.track.color
235
+ "track-type": t.track.type || "unknown",
236
+ "accent-color": t.track.color
237
237
  }, null, 8, ["segment", "track-type", "accent-color"]))
238
238
  ])
239
- ], 4)) : M("", !0)
239
+ ], 4)) : x("", !0)
240
240
  ], 64))), 128))
241
241
  ]),
242
- _: 1
243
- }, 8, ["tracks", "duration", "current-time", "zoom", "fps", "snap-step", "selected-segment-id", "disable-interaction"]));
242
+ _: 2
243
+ }, [
244
+ e.$slots.toolbar ? {
245
+ name: "toolbar",
246
+ fn: _((t) => [
247
+ C(e.$slots, "toolbar", M(U(t)), void 0, !0)
248
+ ]),
249
+ key: "0"
250
+ } : void 0,
251
+ e.$slots.ruler ? {
252
+ name: "ruler",
253
+ fn: _((t) => [
254
+ C(e.$slots, "ruler", M(U(t)), void 0, !0)
255
+ ]),
256
+ key: "1"
257
+ } : void 0,
258
+ e.$slots.playhead ? {
259
+ name: "playhead",
260
+ fn: _((t) => [
261
+ C(e.$slots, "playhead", M(U(t)), void 0, !0)
262
+ ]),
263
+ key: "2"
264
+ } : void 0
265
+ ]), 1032, ["tracks", "duration", "current-time", "zoom", "fps", "snap-step", "selected-segment-id", "disable-interaction"]));
244
266
  }
245
- }), _e = /* @__PURE__ */ U(ge, [["__scopeId", "data-v-4ec48d8d"]]);
267
+ }), Se = /* @__PURE__ */ D(ye, [["__scopeId", "data-v-d5455177"]]);
246
268
  export {
247
- _e as default
269
+ Se as default
248
270
  };
@@ -1,4 +1,4 @@
1
- import { V as f } from "./index-y5KhRW21.js";
1
+ import { V as f } from "./index-B4a4-K9f.js";
2
2
  export {
3
3
  f as default
4
4
  };