@video-editor/ui 0.0.1-beta.30 → 0.0.1-beta.32
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/dist/VideoEditorTimeline.d.ts +11 -0
- package/dist/VideoEditorTimeline.js +1 -1
- package/dist/index-txPw7MRQ.js +782 -0
- package/dist/index.d.ts +26 -1
- package/dist/index.js +2 -2
- package/dist/ui.css +1 -1
- package/package.json +3 -3
- package/dist/index-BEEVxCQj.js +0 -716
package/dist/index-BEEVxCQj.js
DELETED
|
@@ -1,716 +0,0 @@
|
|
|
1
|
-
import { defineComponent as L, ref as P, onMounted as re, onBeforeUnmount as se, watch as F, nextTick as fe, createElementBlock as T, openBlock as y, createElementVNode as S, reactive as q, computed as U, renderSlot as p, normalizeStyle as N, createVNode as E, createCommentVNode as j, toDisplayString as O, Fragment as K, renderList as ae, watchEffect as ge, createBlock as he, createSlots as ve, withCtx as X, unref as D, normalizeProps as ee, guardReactiveProps as te } from "vue";
|
|
2
|
-
import { extractWaveform as le, generateThumbnails as pe, getMp4Meta as ke } from "@video-editor/protocol";
|
|
3
|
-
import { isVideoFramesSegment as V, isAudioSegment as ye } from "@video-editor/shared";
|
|
4
|
-
import { _ as G, V as be } from "./index-C0eQjJkj.js";
|
|
5
|
-
const Me = /* @__PURE__ */ L({
|
|
6
|
-
name: "WaveformCanvasStrip",
|
|
7
|
-
__name: "WaveformCanvasStrip",
|
|
8
|
-
props: {
|
|
9
|
-
peaks: {},
|
|
10
|
-
barColor: { default: "#2B2B2B" },
|
|
11
|
-
minBarHeight: { default: 3 },
|
|
12
|
-
maxBarWidth: { default: 4 },
|
|
13
|
-
barGap: { default: 1 },
|
|
14
|
-
maxBufferWidth: { default: 2048 },
|
|
15
|
-
maxBufferHeight: { default: 256 }
|
|
16
|
-
},
|
|
17
|
-
setup(i) {
|
|
18
|
-
const f = i, d = P(null), g = P(null), b = P({ width: 0, height: 0 });
|
|
19
|
-
let c = null;
|
|
20
|
-
function k(a, l, m) {
|
|
21
|
-
return Math.min(Math.max(a, l), m);
|
|
22
|
-
}
|
|
23
|
-
function h(a) {
|
|
24
|
-
return k(Number.isFinite(a) ? a : 0, 0, 1);
|
|
25
|
-
}
|
|
26
|
-
function v() {
|
|
27
|
-
const a = d.value;
|
|
28
|
-
a && (b.value = {
|
|
29
|
-
width: Math.max(a.clientWidth, 0),
|
|
30
|
-
height: Math.max(a.clientHeight, 0)
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
function $() {
|
|
34
|
-
const a = g.value;
|
|
35
|
-
if (!a)
|
|
36
|
-
return;
|
|
37
|
-
const l = b.value.width, m = b.value.height;
|
|
38
|
-
if (l <= 0 || m <= 0)
|
|
39
|
-
return;
|
|
40
|
-
const _ = Math.min(window.devicePixelRatio || 1, 2), R = k(Math.round(l * _), 1, f.maxBufferWidth), w = k(Math.round(m * _), 1, f.maxBufferHeight);
|
|
41
|
-
a.width !== R && (a.width = R), a.height !== w && (a.height = w);
|
|
42
|
-
const W = a.getContext("2d");
|
|
43
|
-
if (!W)
|
|
44
|
-
return;
|
|
45
|
-
const x = R / l, I = w / m;
|
|
46
|
-
W.setTransform(x, 0, 0, I, 0, 0), W.clearRect(0, 0, l, m);
|
|
47
|
-
const M = f.peaks;
|
|
48
|
-
if (!M.length)
|
|
49
|
-
return;
|
|
50
|
-
const n = l / M.length;
|
|
51
|
-
if (!Number.isFinite(n) || n <= 0)
|
|
52
|
-
return;
|
|
53
|
-
const r = Math.min(f.barGap, Math.max(0, n - 0.1));
|
|
54
|
-
W.fillStyle = f.barColor;
|
|
55
|
-
for (let e = 0; e < M.length; e++) {
|
|
56
|
-
const s = e * n, t = s + n, o = s + r / 2, u = t - r / 2 - o;
|
|
57
|
-
if (u <= 0)
|
|
58
|
-
continue;
|
|
59
|
-
const z = Math.min(f.maxBarWidth, u), A = o + (u - z) / 2, C = h(M[e] ?? 0), H = Math.max(f.minBarHeight, C * m * 0.88), J = (m - H) / 2;
|
|
60
|
-
W.fillRect(A, J, z, H);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return re(() => {
|
|
64
|
-
v();
|
|
65
|
-
const a = d.value;
|
|
66
|
-
a && (c = new ResizeObserver(() => {
|
|
67
|
-
v();
|
|
68
|
-
}), c.observe(a));
|
|
69
|
-
}), se(() => {
|
|
70
|
-
c?.disconnect(), c = null;
|
|
71
|
-
}), F(
|
|
72
|
-
[
|
|
73
|
-
() => f.peaks,
|
|
74
|
-
() => f.barColor,
|
|
75
|
-
() => f.minBarHeight,
|
|
76
|
-
() => f.maxBarWidth,
|
|
77
|
-
() => f.barGap,
|
|
78
|
-
() => f.maxBufferWidth,
|
|
79
|
-
() => f.maxBufferHeight,
|
|
80
|
-
() => b.value.width,
|
|
81
|
-
() => b.value.height
|
|
82
|
-
],
|
|
83
|
-
async () => {
|
|
84
|
-
await fe(), $();
|
|
85
|
-
},
|
|
86
|
-
{ immediate: !0, flush: "post" }
|
|
87
|
-
), (a, l) => (y(), T("div", {
|
|
88
|
-
ref_key: "containerRef",
|
|
89
|
-
ref: d,
|
|
90
|
-
class: "waveform-canvas-strip"
|
|
91
|
-
}, [
|
|
92
|
-
S("canvas", {
|
|
93
|
-
ref_key: "canvasRef",
|
|
94
|
-
ref: g,
|
|
95
|
-
class: "waveform-canvas-strip__canvas"
|
|
96
|
-
}, null, 512)
|
|
97
|
-
], 512));
|
|
98
|
-
}
|
|
99
|
-
}), ce = /* @__PURE__ */ G(Me, [["__scopeId", "data-v-7cbe9830"]]), Te = {
|
|
100
|
-
key: 1,
|
|
101
|
-
class: "audio-segment__placeholder"
|
|
102
|
-
}, Se = {
|
|
103
|
-
key: 0,
|
|
104
|
-
class: "audio-segment__badge"
|
|
105
|
-
}, we = 1, Re = 1, $e = 4096, _e = /* @__PURE__ */ L({
|
|
106
|
-
name: "AudioSegment",
|
|
107
|
-
__name: "AudioSegment",
|
|
108
|
-
props: {
|
|
109
|
-
segment: {}
|
|
110
|
-
},
|
|
111
|
-
setup(i) {
|
|
112
|
-
const f = i, d = P(null), g = P(0);
|
|
113
|
-
let b = null;
|
|
114
|
-
re(() => {
|
|
115
|
-
d.value && (g.value = d.value.clientWidth, b = new ResizeObserver((a) => {
|
|
116
|
-
for (const l of a)
|
|
117
|
-
g.value = l.contentRect.width;
|
|
118
|
-
}), b.observe(d.value));
|
|
119
|
-
}), se(() => {
|
|
120
|
-
b?.disconnect();
|
|
121
|
-
});
|
|
122
|
-
const c = q({
|
|
123
|
-
data: null,
|
|
124
|
-
loading: !1,
|
|
125
|
-
error: null,
|
|
126
|
-
loadedUrl: null
|
|
127
|
-
});
|
|
128
|
-
let k = 0;
|
|
129
|
-
F(() => f.segment.url, (a, l) => {
|
|
130
|
-
a && a !== l && h(a);
|
|
131
|
-
}, { immediate: !0 });
|
|
132
|
-
async function h(a) {
|
|
133
|
-
if (!a || c.loadedUrl === a && c.data)
|
|
134
|
-
return;
|
|
135
|
-
const l = ++k;
|
|
136
|
-
c.loading = !0, c.error = null;
|
|
137
|
-
try {
|
|
138
|
-
const m = await le(a, { samples: 1e3 });
|
|
139
|
-
if (k !== l)
|
|
140
|
-
return;
|
|
141
|
-
c.data = m, c.loadedUrl = a, c.loading = !1;
|
|
142
|
-
} catch (m) {
|
|
143
|
-
if (k !== l)
|
|
144
|
-
return;
|
|
145
|
-
c.error = m instanceof Error ? m.message : String(m), c.loading = !1;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function v(a, l) {
|
|
149
|
-
if (l >= a.length)
|
|
150
|
-
return a;
|
|
151
|
-
const m = [], _ = a.length / l;
|
|
152
|
-
for (let R = 0; R < l; R++) {
|
|
153
|
-
const w = Math.floor(R * _), W = Math.max(w + 1, Math.ceil((R + 1) * _));
|
|
154
|
-
let x = 0;
|
|
155
|
-
for (let I = w; I < W; I++) {
|
|
156
|
-
const M = a[I] ?? 0;
|
|
157
|
-
M > x && (x = M);
|
|
158
|
-
}
|
|
159
|
-
m.push(x);
|
|
160
|
-
}
|
|
161
|
-
return m;
|
|
162
|
-
}
|
|
163
|
-
const $ = U(() => {
|
|
164
|
-
if (!c.data)
|
|
165
|
-
return { peaks: [], renderPeaks: [], coveragePercent: 100 };
|
|
166
|
-
const a = f.segment, l = c.data.duration * 1e3, m = c.data.peaks, _ = a.fromTime ?? 0, R = a.endTime - a.startTime, w = a.playRate ?? 1, W = R * w, x = Math.max(0, l - _), I = Math.min(W, x), M = R > 0 ? Math.min(100, I / w / R * 100) : 0, n = _ / l, r = (_ + I) / l, e = Math.floor(n * m.length), s = Math.ceil(r * m.length), t = m.slice(
|
|
167
|
-
Math.max(0, e),
|
|
168
|
-
Math.min(m.length, s)
|
|
169
|
-
);
|
|
170
|
-
if (!t.length)
|
|
171
|
-
return { peaks: [], renderPeaks: [], coveragePercent: M };
|
|
172
|
-
const o = g.value * (M / 100), B = o > 0 ? Math.min(
|
|
173
|
-
$e,
|
|
174
|
-
Math.max(1, Math.floor(o / (we + Re)))
|
|
175
|
-
) : t.length;
|
|
176
|
-
return {
|
|
177
|
-
peaks: t,
|
|
178
|
-
renderPeaks: v(t, B),
|
|
179
|
-
coveragePercent: M
|
|
180
|
-
};
|
|
181
|
-
});
|
|
182
|
-
return (a, l) => (y(), T("div", {
|
|
183
|
-
ref_key: "containerRef",
|
|
184
|
-
ref: d,
|
|
185
|
-
class: "audio-segment"
|
|
186
|
-
}, [
|
|
187
|
-
c.data && $.value.renderPeaks.length ? p(a.$slots, "waveform", {
|
|
188
|
-
key: 0,
|
|
189
|
-
segment: i.segment,
|
|
190
|
-
waveform: c.data,
|
|
191
|
-
peaks: $.value.renderPeaks,
|
|
192
|
-
rawPeaks: $.value.peaks,
|
|
193
|
-
coveragePercent: $.value.coveragePercent
|
|
194
|
-
}, () => [
|
|
195
|
-
S("div", {
|
|
196
|
-
class: "audio-segment__waveform",
|
|
197
|
-
style: N({ width: `${$.value.coveragePercent}%` })
|
|
198
|
-
}, [
|
|
199
|
-
E(ce, {
|
|
200
|
-
class: "audio-segment__waveform-canvas",
|
|
201
|
-
peaks: $.value.renderPeaks,
|
|
202
|
-
"bar-color": "#2B2B2B",
|
|
203
|
-
"min-bar-height": 4,
|
|
204
|
-
"max-bar-width": 4,
|
|
205
|
-
"bar-gap": 1
|
|
206
|
-
}, null, 8, ["peaks"])
|
|
207
|
-
], 4)
|
|
208
|
-
], !0) : (y(), T("div", Te, [
|
|
209
|
-
c.loading ? p(a.$slots, "loading", {
|
|
210
|
-
key: 0,
|
|
211
|
-
segment: i.segment
|
|
212
|
-
}, () => [
|
|
213
|
-
l[0] || (l[0] = S("span", null, "加载波形…", -1))
|
|
214
|
-
], !0) : c.error ? p(a.$slots, "error", {
|
|
215
|
-
key: 1,
|
|
216
|
-
segment: i.segment,
|
|
217
|
-
error: c.error
|
|
218
|
-
}, () => [
|
|
219
|
-
l[1] || (l[1] = S("span", null, "波形加载失败", -1))
|
|
220
|
-
], !0) : p(a.$slots, "empty", {
|
|
221
|
-
key: 2,
|
|
222
|
-
segment: i.segment
|
|
223
|
-
}, () => [
|
|
224
|
-
l[2] || (l[2] = S("div", { class: "waveform-pattern" }, null, -1))
|
|
225
|
-
], !0)
|
|
226
|
-
])),
|
|
227
|
-
p(a.$slots, "overlay", { segment: i.segment }, () => [
|
|
228
|
-
i.segment.extra?.label ? (y(), T("span", Se, O(i.segment.extra?.label), 1)) : j("", !0)
|
|
229
|
-
], !0)
|
|
230
|
-
], 512));
|
|
231
|
-
}
|
|
232
|
-
}), Be = /* @__PURE__ */ G(_e, [["__scopeId", "data-v-47cbc534"]]), We = { class: "frames-segment" }, Ie = { class: "frames-segment__video-wrap" }, xe = { class: "frames-segment__video" }, Pe = {
|
|
233
|
-
key: 1,
|
|
234
|
-
class: "frames-segment__placeholder frames-segment__placeholder--video"
|
|
235
|
-
}, Ae = {
|
|
236
|
-
key: 0,
|
|
237
|
-
class: "frames-segment__waveform",
|
|
238
|
-
style: { width: "100%" }
|
|
239
|
-
}, Ee = {
|
|
240
|
-
key: 1,
|
|
241
|
-
class: "frames-segment__waveform-pattern"
|
|
242
|
-
}, ze = { class: "frames-segment__placeholder" }, Ce = {
|
|
243
|
-
key: 0,
|
|
244
|
-
class: "frames-segment__badge"
|
|
245
|
-
}, De = 1, Ve = 1, Fe = 4096, Ue = /* @__PURE__ */ L({
|
|
246
|
-
name: "FramesSegment",
|
|
247
|
-
__name: "FramesSegment",
|
|
248
|
-
props: {
|
|
249
|
-
segment: {}
|
|
250
|
-
},
|
|
251
|
-
setup(i) {
|
|
252
|
-
const f = i, d = P(null), g = P(null), b = P(1), c = P(0);
|
|
253
|
-
let k = null;
|
|
254
|
-
re(() => {
|
|
255
|
-
k = new ResizeObserver((n) => {
|
|
256
|
-
for (const r of n) {
|
|
257
|
-
if (r.target === d.value) {
|
|
258
|
-
const e = Math.max(1, Math.ceil(r.contentRect.width / 56));
|
|
259
|
-
b.value !== e && (b.value = e);
|
|
260
|
-
}
|
|
261
|
-
r.target === g.value && (c.value = r.contentRect.width);
|
|
262
|
-
}
|
|
263
|
-
}), d.value && k.observe(d.value), g.value && (c.value = g.value.clientWidth, k.observe(g.value));
|
|
264
|
-
}), se(() => {
|
|
265
|
-
k?.disconnect(), I();
|
|
266
|
-
}), F(g, (n, r) => {
|
|
267
|
-
k && r && k.unobserve(r), k && n && (c.value = n.clientWidth, k.observe(n));
|
|
268
|
-
});
|
|
269
|
-
const h = q({ items: [], loading: !1, error: null }), v = q({
|
|
270
|
-
data: null,
|
|
271
|
-
loading: !1,
|
|
272
|
-
error: null,
|
|
273
|
-
loadedUrl: null
|
|
274
|
-
});
|
|
275
|
-
let $ = 0, a = 0, l, m = null;
|
|
276
|
-
F(() => f.segment, (n, r) => {
|
|
277
|
-
if (!V(n))
|
|
278
|
-
return;
|
|
279
|
-
(!r || _(r, n)) && R(n, r);
|
|
280
|
-
}, { immediate: !0, deep: !0 }), F(() => f.segment, (n, r) => {
|
|
281
|
-
if (!V(n))
|
|
282
|
-
return;
|
|
283
|
-
const e = n, s = r && V(r) ? r : void 0;
|
|
284
|
-
e.url && e.url !== s?.url && W(e.url);
|
|
285
|
-
}, { immediate: !0, deep: !0 });
|
|
286
|
-
function _(n, r) {
|
|
287
|
-
return n.url !== r.url || n.startTime !== r.startTime || n.endTime !== r.endTime || n.fromTime !== r.fromTime;
|
|
288
|
-
}
|
|
289
|
-
function R(n, r) {
|
|
290
|
-
const e = !r || r.url !== n.url, s = !r || r.fromTime !== n.fromTime, t = e || s;
|
|
291
|
-
if (m = n, l && (window.clearTimeout(l), l = void 0), t) {
|
|
292
|
-
w(n);
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
l = window.setTimeout(() => {
|
|
296
|
-
m && w(m), l = void 0;
|
|
297
|
-
}, 240);
|
|
298
|
-
}
|
|
299
|
-
async function w(n) {
|
|
300
|
-
if (!n.url)
|
|
301
|
-
return;
|
|
302
|
-
const r = ++$;
|
|
303
|
-
I(), h.loading = !0, h.error = null;
|
|
304
|
-
try {
|
|
305
|
-
const e = x(n), s = await pe(n.url, e);
|
|
306
|
-
if ($ !== r)
|
|
307
|
-
return;
|
|
308
|
-
const t = s.map((o) => ({
|
|
309
|
-
tsMs: Math.round(o.ts / 1e3),
|
|
310
|
-
url: URL.createObjectURL(o.img)
|
|
311
|
-
}));
|
|
312
|
-
h.items = t, h.loading = !1;
|
|
313
|
-
} catch (e) {
|
|
314
|
-
if ($ !== r)
|
|
315
|
-
return;
|
|
316
|
-
h.error = e instanceof Error ? e.message : String(e), h.loading = !1;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
async function W(n) {
|
|
320
|
-
if (!n || v.loadedUrl === n && v.data)
|
|
321
|
-
return;
|
|
322
|
-
const r = ++a;
|
|
323
|
-
v.loading = !0, v.error = null;
|
|
324
|
-
try {
|
|
325
|
-
const e = await le(n, { samples: 1e3 });
|
|
326
|
-
if (a !== r)
|
|
327
|
-
return;
|
|
328
|
-
v.data = e, v.loadedUrl = n, v.loading = !1;
|
|
329
|
-
} catch (e) {
|
|
330
|
-
if (a !== r)
|
|
331
|
-
return;
|
|
332
|
-
v.data = null, v.error = e instanceof Error ? e.message : String(e), v.loading = !1;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
function x(n) {
|
|
336
|
-
const r = Math.max(n.fromTime ?? 0, 0) * 1e3, e = Math.max(n.endTime - n.startTime, 1), s = r + e * 1e3, o = Math.max(Math.floor((s - r) / 8), 2e5);
|
|
337
|
-
return { start: r, end: s, step: o };
|
|
338
|
-
}
|
|
339
|
-
function I() {
|
|
340
|
-
h.items.forEach((n) => URL.revokeObjectURL(n.url)), h.items = [];
|
|
341
|
-
}
|
|
342
|
-
const M = U(() => {
|
|
343
|
-
if (!V(f.segment))
|
|
344
|
-
return { peaks: [], coveragePercent: 100 };
|
|
345
|
-
if (!v.data)
|
|
346
|
-
return { peaks: [], coveragePercent: 100 };
|
|
347
|
-
const n = f.segment, r = Math.max(n.endTime - n.startTime, 0);
|
|
348
|
-
if (r <= 0)
|
|
349
|
-
return { peaks: [], coveragePercent: 100 };
|
|
350
|
-
const e = Math.max(c.value, 1), s = Math.min(
|
|
351
|
-
Fe,
|
|
352
|
-
Math.max(1, Math.floor(e / (De + Ve)))
|
|
353
|
-
), t = v.data.duration * 1e3, o = v.data.peaks;
|
|
354
|
-
if (!Number.isFinite(t) || t <= 0 || o.length === 0)
|
|
355
|
-
return { peaks: new Array(s).fill(0), coveragePercent: 100 };
|
|
356
|
-
const B = Math.max(n.fromTime ?? 0, 0), u = Math.max(n.playRate ?? 1, 1e-4), z = r * u, A = [];
|
|
357
|
-
for (let C = 0; C < s; C++) {
|
|
358
|
-
const H = B + z * C / s, J = B + z * (C + 1) / s;
|
|
359
|
-
if (H >= t || J <= 0) {
|
|
360
|
-
A.push(0);
|
|
361
|
-
continue;
|
|
362
|
-
}
|
|
363
|
-
const de = Math.max(H, 0), me = Math.min(J, t), oe = Math.floor(de / t * o.length), ue = Math.max(oe + 1, Math.ceil(me / t * o.length));
|
|
364
|
-
let Q = 0;
|
|
365
|
-
for (let Z = oe; Z < ue; Z++) {
|
|
366
|
-
const ie = o[Z] ?? 0;
|
|
367
|
-
ie > Q && (Q = ie);
|
|
368
|
-
}
|
|
369
|
-
A.push(Q);
|
|
370
|
-
}
|
|
371
|
-
return { peaks: A, coveragePercent: 100 };
|
|
372
|
-
});
|
|
373
|
-
return (n, r) => (y(), T("div", We, [
|
|
374
|
-
i.segment.type === "image" ? p(n.$slots, "image", {
|
|
375
|
-
key: 0,
|
|
376
|
-
segment: i.segment,
|
|
377
|
-
style: N({ backgroundImage: i.segment.url ? `url(${i.segment.url})` : "" })
|
|
378
|
-
}, () => [
|
|
379
|
-
S("div", {
|
|
380
|
-
ref_key: "containerRef",
|
|
381
|
-
ref: d,
|
|
382
|
-
class: "frames-segment__image"
|
|
383
|
-
}, [
|
|
384
|
-
(y(!0), T(K, null, ae(b.value, (e) => (y(), T("div", {
|
|
385
|
-
key: e,
|
|
386
|
-
class: "frames-segment__image-item",
|
|
387
|
-
style: N({ backgroundImage: i.segment.url ? `url(${i.segment.url})` : "" })
|
|
388
|
-
}, null, 4))), 128))
|
|
389
|
-
], 512)
|
|
390
|
-
], !0) : i.segment.type === "video" ? p(n.$slots, "video", {
|
|
391
|
-
key: 1,
|
|
392
|
-
segment: i.segment,
|
|
393
|
-
thumbnails: h.items,
|
|
394
|
-
waveformPeaks: M.value.peaks,
|
|
395
|
-
waveformCoveragePercent: M.value.coveragePercent
|
|
396
|
-
}, () => [
|
|
397
|
-
S("div", Ie, [
|
|
398
|
-
S("div", xe, [
|
|
399
|
-
h.items.length ? (y(!0), T(K, { key: 0 }, ae(h.items, (e) => (y(), T("div", {
|
|
400
|
-
key: `${i.segment.id}-${e.tsMs}`,
|
|
401
|
-
class: "frames-segment__thumb",
|
|
402
|
-
style: N({ backgroundImage: `url(${e.url})` })
|
|
403
|
-
}, null, 4))), 128)) : (y(), T("div", Pe, [
|
|
404
|
-
h.loading ? p(n.$slots, "loading", {
|
|
405
|
-
key: 0,
|
|
406
|
-
segment: i.segment
|
|
407
|
-
}, () => [
|
|
408
|
-
r[0] || (r[0] = S("span", null, "抽帧中…", -1))
|
|
409
|
-
], !0) : h.error ? p(n.$slots, "error", {
|
|
410
|
-
key: 1,
|
|
411
|
-
segment: i.segment,
|
|
412
|
-
error: h.error
|
|
413
|
-
}, () => [
|
|
414
|
-
r[1] || (r[1] = S("span", null, "生成失败", -1))
|
|
415
|
-
], !0) : p(n.$slots, "empty", {
|
|
416
|
-
key: 2,
|
|
417
|
-
segment: i.segment
|
|
418
|
-
}, () => [
|
|
419
|
-
r[2] || (r[2] = S("span", null, "未生成缩略图", -1))
|
|
420
|
-
], !0)
|
|
421
|
-
]))
|
|
422
|
-
]),
|
|
423
|
-
S("div", {
|
|
424
|
-
ref_key: "waveformRef",
|
|
425
|
-
ref: g,
|
|
426
|
-
class: "frames-segment__waveform-strip"
|
|
427
|
-
}, [
|
|
428
|
-
M.value.peaks.length ? (y(), T("div", Ae, [
|
|
429
|
-
E(ce, {
|
|
430
|
-
class: "frames-segment__waveform-canvas",
|
|
431
|
-
peaks: M.value.peaks,
|
|
432
|
-
"bar-color": "#3f3f46",
|
|
433
|
-
"min-bar-height": 3,
|
|
434
|
-
"max-bar-width": 4,
|
|
435
|
-
"bar-gap": 1
|
|
436
|
-
}, null, 8, ["peaks"])
|
|
437
|
-
])) : (y(), T("div", Ee))
|
|
438
|
-
], 512)
|
|
439
|
-
])
|
|
440
|
-
], !0) : p(n.$slots, "fallback", {
|
|
441
|
-
key: 2,
|
|
442
|
-
segment: i.segment
|
|
443
|
-
}, () => [
|
|
444
|
-
S("div", ze, [
|
|
445
|
-
S("span", null, O(i.segment.type), 1)
|
|
446
|
-
])
|
|
447
|
-
], !0),
|
|
448
|
-
p(n.$slots, "overlay", { segment: i.segment }, () => [
|
|
449
|
-
i.segment.extra?.label ? (y(), T("span", Ce, O(i.segment.extra?.label), 1)) : j("", !0)
|
|
450
|
-
], !0)
|
|
451
|
-
]));
|
|
452
|
-
}
|
|
453
|
-
}), Oe = /* @__PURE__ */ G(Ue, [["__scopeId", "data-v-fed75c7c"]]), He = { class: "segment-base" }, Ne = { class: "segment-base__content" }, je = { class: "segment-base__pill segment-base__pill--primary" }, Le = { class: "segment-base__pill segment-base__pill--muted" }, Ge = {
|
|
454
|
-
key: 0,
|
|
455
|
-
class: "segment-base__badge"
|
|
456
|
-
}, Je = /* @__PURE__ */ L({
|
|
457
|
-
name: "SegmentBase",
|
|
458
|
-
__name: "SegmentBase",
|
|
459
|
-
props: {
|
|
460
|
-
segment: {},
|
|
461
|
-
trackType: {},
|
|
462
|
-
accentColor: { default: "#222226" }
|
|
463
|
-
},
|
|
464
|
-
setup(i) {
|
|
465
|
-
const f = i, d = U(() => {
|
|
466
|
-
const g = f.segment?.extra?.label;
|
|
467
|
-
return typeof g == "string" ? g : null;
|
|
468
|
-
});
|
|
469
|
-
return (g, b) => (y(), T("div", He, [
|
|
470
|
-
S("div", Ne, [
|
|
471
|
-
S("span", je, O(i.trackType), 1),
|
|
472
|
-
S("span", Le, O(i.segment.segmentType), 1)
|
|
473
|
-
]),
|
|
474
|
-
d.value ? (y(), T("span", Ge, O(d.value), 1)) : j("", !0)
|
|
475
|
-
]));
|
|
476
|
-
}
|
|
477
|
-
}), Y = /* @__PURE__ */ G(Je, [["__scopeId", "data-v-d386af72"]]), Xe = { class: "ve-editor-segment__preview" }, ne = "#222226", Ye = 0.4, qe = /* @__PURE__ */ L({
|
|
478
|
-
name: "VideoEditorTimeline",
|
|
479
|
-
__name: "index",
|
|
480
|
-
props: {
|
|
481
|
-
protocol: { default: null },
|
|
482
|
-
currentTime: {},
|
|
483
|
-
zoom: {},
|
|
484
|
-
snapStep: { default: 0 },
|
|
485
|
-
selectedSegmentId: { default: null },
|
|
486
|
-
trackTypes: { default: void 0 },
|
|
487
|
-
disableInteraction: { type: Boolean, default: !1 }
|
|
488
|
-
},
|
|
489
|
-
emits: ["update:currentTime", "update:zoom", "update:selectedSegmentId", "segmentClick", "segmentDragEnd", "segmentResizeEnd", "add-segment"],
|
|
490
|
-
setup(i, { emit: f }) {
|
|
491
|
-
const d = i, g = f, b = P(d.selectedSegmentId ?? null);
|
|
492
|
-
F(() => d.selectedSegmentId, (e) => {
|
|
493
|
-
b.value = e ?? null;
|
|
494
|
-
});
|
|
495
|
-
const c = {
|
|
496
|
-
frames: ne,
|
|
497
|
-
audio: "#0ea5e9",
|
|
498
|
-
text: "#16a34a",
|
|
499
|
-
sticker: "#f97316",
|
|
500
|
-
effect: "#a855f7",
|
|
501
|
-
filter: "#64748b"
|
|
502
|
-
}, k = U(() => {
|
|
503
|
-
if (!d.protocol?.tracks?.length)
|
|
504
|
-
return [];
|
|
505
|
-
const s = (d.trackTypes?.length ? d.protocol.tracks.filter((u) => d.trackTypes?.includes(u.trackType)) : d.protocol.tracks).slice(), t = s.find((u) => u.trackType === "frames" && u.isMain === !0), o = s.filter((u) => !(u.trackType === "audio" || u === t)), B = s.filter((u) => u.trackType === "audio");
|
|
506
|
-
return [
|
|
507
|
-
...o,
|
|
508
|
-
...t ? [t] : [],
|
|
509
|
-
...B
|
|
510
|
-
];
|
|
511
|
-
}), h = q(/* @__PURE__ */ new Map()), v = /* @__PURE__ */ new Map();
|
|
512
|
-
function $(e) {
|
|
513
|
-
if (!e || h.has(e) || v.has(e))
|
|
514
|
-
return;
|
|
515
|
-
const s = (async () => {
|
|
516
|
-
try {
|
|
517
|
-
const t = await ke(e);
|
|
518
|
-
h.set(e, t.durationMs);
|
|
519
|
-
} catch {
|
|
520
|
-
}
|
|
521
|
-
})().finally(() => {
|
|
522
|
-
v.delete(e);
|
|
523
|
-
});
|
|
524
|
-
v.set(e, s);
|
|
525
|
-
}
|
|
526
|
-
const a = U(() => k.value.map((e, s) => {
|
|
527
|
-
const t = c[e.trackType] || ne, o = m(t, Ye), B = e.trackType === "frames" && e.isMain === !0;
|
|
528
|
-
return {
|
|
529
|
-
id: e.trackId || `${e.trackType}-${s}`,
|
|
530
|
-
label: e.trackType,
|
|
531
|
-
type: e.trackType,
|
|
532
|
-
color: t,
|
|
533
|
-
isMain: B,
|
|
534
|
-
payload: e,
|
|
535
|
-
segments: e.children.map((u) => ({
|
|
536
|
-
...V(u) ? { fromTime: u.fromTime ?? 0, sourceDurationMs: h.get(u.url) } : ye(u) ? { fromTime: u.fromTime ?? 0 } : {},
|
|
537
|
-
id: u.id,
|
|
538
|
-
start: u.startTime,
|
|
539
|
-
end: u.endTime,
|
|
540
|
-
type: u.segmentType,
|
|
541
|
-
color: o,
|
|
542
|
-
payload: u
|
|
543
|
-
}))
|
|
544
|
-
};
|
|
545
|
-
}));
|
|
546
|
-
ge(() => {
|
|
547
|
-
for (const e of k.value)
|
|
548
|
-
for (const s of e.children)
|
|
549
|
-
V(s) && $(s.url);
|
|
550
|
-
});
|
|
551
|
-
const l = U(() => {
|
|
552
|
-
if (!d.protocol?.tracks?.length)
|
|
553
|
-
return 0;
|
|
554
|
-
const e = d.protocol.tracks.flatMap((s) => s.children.map((t) => t.endTime));
|
|
555
|
-
return e.length ? Math.max(...e) : 0;
|
|
556
|
-
});
|
|
557
|
-
function m(e, s) {
|
|
558
|
-
const t = e.replace("#", "");
|
|
559
|
-
if (!(t.length === 3 || t.length === 6))
|
|
560
|
-
return e;
|
|
561
|
-
const o = t.length === 3 ? t.split("").map((A) => A + A).join("") : t, B = Number.parseInt(o.slice(0, 2), 16), u = Number.parseInt(o.slice(2, 4), 16), z = Number.parseInt(o.slice(4, 6), 16);
|
|
562
|
-
return `rgba(${B}, ${u}, ${z}, ${s})`;
|
|
563
|
-
}
|
|
564
|
-
function _(e) {
|
|
565
|
-
return e && typeof e == "object" && "segmentType" in e ? e : null;
|
|
566
|
-
}
|
|
567
|
-
function R(e) {
|
|
568
|
-
const s = e.payload;
|
|
569
|
-
if (s)
|
|
570
|
-
return s;
|
|
571
|
-
if (d.protocol)
|
|
572
|
-
return d.protocol.tracks.find((t) => t.trackId === e.id);
|
|
573
|
-
}
|
|
574
|
-
function w(e) {
|
|
575
|
-
b.value = e, g("update:selectedSegmentId", e);
|
|
576
|
-
}
|
|
577
|
-
function W(e) {
|
|
578
|
-
const s = _(e.segment.payload), t = R(e.track);
|
|
579
|
-
s && (w(s.id), t && g("segmentClick", { segment: s, track: t }));
|
|
580
|
-
}
|
|
581
|
-
function x(e) {
|
|
582
|
-
w(e.segment.id);
|
|
583
|
-
}
|
|
584
|
-
function I(e) {
|
|
585
|
-
g("segmentDragEnd", e);
|
|
586
|
-
}
|
|
587
|
-
function M(e) {
|
|
588
|
-
w(e.segment.id);
|
|
589
|
-
}
|
|
590
|
-
function n(e) {
|
|
591
|
-
g("segmentResizeEnd", e);
|
|
592
|
-
}
|
|
593
|
-
function r({ track: e, startTime: s, endTime: t, event: o }) {
|
|
594
|
-
const B = e.payload;
|
|
595
|
-
B && g("add-segment", { track: B, startTime: s, endTime: t, event: o });
|
|
596
|
-
}
|
|
597
|
-
return (e, s) => (y(), he(be, {
|
|
598
|
-
tracks: a.value,
|
|
599
|
-
duration: l.value,
|
|
600
|
-
"current-time": i.currentTime,
|
|
601
|
-
zoom: i.zoom,
|
|
602
|
-
fps: i.protocol?.fps || 30,
|
|
603
|
-
"snap-step": i.snapStep,
|
|
604
|
-
"selected-segment-id": b.value ?? null,
|
|
605
|
-
"disable-interaction": i.disableInteraction,
|
|
606
|
-
"onUpdate:currentTime": s[0] || (s[0] = (t) => g("update:currentTime", t)),
|
|
607
|
-
"onUpdate:zoom": s[1] || (s[1] = (t) => g("update:zoom", t)),
|
|
608
|
-
onSegmentClick: W,
|
|
609
|
-
onSegmentDragStart: x,
|
|
610
|
-
onSegmentDragEnd: I,
|
|
611
|
-
onSegmentResizeStart: M,
|
|
612
|
-
onSegmentResizeEnd: n,
|
|
613
|
-
onBackgroundClick: s[2] || (s[2] = (t) => w(null)),
|
|
614
|
-
onAddSegment: r
|
|
615
|
-
}, ve({
|
|
616
|
-
segment: X(({ layout: t }) => [
|
|
617
|
-
(y(!0), T(K, null, ae([_(t.segment.payload)], (o) => (y(), T(K, {
|
|
618
|
-
key: o?.id || t.segment.id
|
|
619
|
-
}, [
|
|
620
|
-
o ? (y(), T("div", {
|
|
621
|
-
key: 0,
|
|
622
|
-
class: "ve-editor-segment",
|
|
623
|
-
style: N({ "--ve-segment-accent": t.track.color || ne })
|
|
624
|
-
}, [
|
|
625
|
-
S("div", Xe, [
|
|
626
|
-
o.segmentType === "frames" ? p(e.$slots, "segment-frames", {
|
|
627
|
-
key: 0,
|
|
628
|
-
segment: o,
|
|
629
|
-
layout: t
|
|
630
|
-
}, () => [
|
|
631
|
-
E(D(Oe), { segment: o }, null, 8, ["segment"])
|
|
632
|
-
], !0) : o.segmentType === "text" ? p(e.$slots, "segment-text", {
|
|
633
|
-
key: 1,
|
|
634
|
-
segment: o,
|
|
635
|
-
layout: t
|
|
636
|
-
}, () => [
|
|
637
|
-
E(D(Y), {
|
|
638
|
-
segment: o,
|
|
639
|
-
"track-type": t.track.type || "unknown",
|
|
640
|
-
"accent-color": t.track.color
|
|
641
|
-
}, null, 8, ["segment", "track-type", "accent-color"])
|
|
642
|
-
], !0) : o.segmentType === "sticker" ? p(e.$slots, "segment-sticker", {
|
|
643
|
-
key: 2,
|
|
644
|
-
segment: o,
|
|
645
|
-
layout: t
|
|
646
|
-
}, () => [
|
|
647
|
-
E(D(Y), {
|
|
648
|
-
segment: o,
|
|
649
|
-
"track-type": t.track.type || "unknown",
|
|
650
|
-
"accent-color": t.track.color
|
|
651
|
-
}, null, 8, ["segment", "track-type", "accent-color"])
|
|
652
|
-
], !0) : o.segmentType === "audio" ? p(e.$slots, "segment-audio", {
|
|
653
|
-
key: 3,
|
|
654
|
-
segment: o,
|
|
655
|
-
layout: t
|
|
656
|
-
}, () => [
|
|
657
|
-
E(D(Be), {
|
|
658
|
-
segment: o
|
|
659
|
-
}, null, 8, ["segment"])
|
|
660
|
-
], !0) : o.segmentType === "effect" ? p(e.$slots, "segment-effect", {
|
|
661
|
-
key: 4,
|
|
662
|
-
segment: o,
|
|
663
|
-
layout: t
|
|
664
|
-
}, () => [
|
|
665
|
-
E(D(Y), {
|
|
666
|
-
segment: o,
|
|
667
|
-
"track-type": t.track.type || "unknown",
|
|
668
|
-
"accent-color": t.track.color
|
|
669
|
-
}, null, 8, ["segment", "track-type", "accent-color"])
|
|
670
|
-
], !0) : o.segmentType === "filter" ? p(e.$slots, "segment-filter", {
|
|
671
|
-
key: 5,
|
|
672
|
-
segment: o,
|
|
673
|
-
layout: t
|
|
674
|
-
}, () => [
|
|
675
|
-
E(D(Y), {
|
|
676
|
-
segment: o,
|
|
677
|
-
"track-type": t.track.type || "unknown",
|
|
678
|
-
"accent-color": t.track.color
|
|
679
|
-
}, null, 8, ["segment", "track-type", "accent-color"])
|
|
680
|
-
], !0) : j("", !0)
|
|
681
|
-
])
|
|
682
|
-
], 4)) : j("", !0)
|
|
683
|
-
], 64))), 128))
|
|
684
|
-
]),
|
|
685
|
-
_: 2
|
|
686
|
-
}, [
|
|
687
|
-
e.$slots.toolbar ? {
|
|
688
|
-
name: "toolbar",
|
|
689
|
-
fn: X((t) => [
|
|
690
|
-
p(e.$slots, "toolbar", ee(te(t)), void 0, !0)
|
|
691
|
-
]),
|
|
692
|
-
key: "0"
|
|
693
|
-
} : void 0,
|
|
694
|
-
e.$slots.ruler ? {
|
|
695
|
-
name: "ruler",
|
|
696
|
-
fn: X((t) => [
|
|
697
|
-
p(e.$slots, "ruler", ee(te(t)), void 0, !0)
|
|
698
|
-
]),
|
|
699
|
-
key: "1"
|
|
700
|
-
} : void 0,
|
|
701
|
-
e.$slots.playhead ? {
|
|
702
|
-
name: "playhead",
|
|
703
|
-
fn: X((t) => [
|
|
704
|
-
p(e.$slots, "playhead", ee(te(t)), void 0, !0)
|
|
705
|
-
]),
|
|
706
|
-
key: "2"
|
|
707
|
-
} : void 0
|
|
708
|
-
]), 1032, ["tracks", "duration", "current-time", "zoom", "fps", "snap-step", "selected-segment-id", "disable-interaction"]));
|
|
709
|
-
}
|
|
710
|
-
}), tt = /* @__PURE__ */ G(qe, [["__scopeId", "data-v-14600e74"]]);
|
|
711
|
-
export {
|
|
712
|
-
Be as A,
|
|
713
|
-
Oe as F,
|
|
714
|
-
Y as S,
|
|
715
|
-
tt as V
|
|
716
|
-
};
|