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