@video-editor/ui 0.0.1-beta.7
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/README.md +3 -0
- package/dist/VideoEditorTimeline.d.ts +94 -0
- package/dist/VideoEditorTimeline.js +248 -0
- package/dist/VideoTimeline.d.ts +200 -0
- package/dist/VideoTimeline.js +4 -0
- package/dist/index-y5KhRW21.js +750 -0
- package/dist/index.d.ts +254 -0
- package/dist/index.js +12 -0
- package/dist/ui.css +1 -0
- package/package.json +30 -0
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
import { defineComponent as pe, createElementBlock as k, openBlock as _, withModifiers as le, normalizeStyle as D, createStaticVNode as Se, createElementVNode as c, Fragment as ge, renderList as he, normalizeClass as $e, createCommentVNode as ee, toDisplayString as G, renderSlot as V, computed as T, ref as z, watch as fe, toRef as Re, onMounted as Pe, onBeforeUnmount as Ge, createVNode as ye, withDirectives as Ve, unref as K, vShow as Le } from "vue";
|
|
2
|
+
const Ne = /* @__PURE__ */ pe({
|
|
3
|
+
name: "TimelinePlayhead",
|
|
4
|
+
__name: "TimelinePlayhead",
|
|
5
|
+
props: {
|
|
6
|
+
left: {}
|
|
7
|
+
},
|
|
8
|
+
emits: ["dragStart"],
|
|
9
|
+
setup(l, { emit: f }) {
|
|
10
|
+
const s = f;
|
|
11
|
+
return (o, i) => (_(), k("div", {
|
|
12
|
+
class: "ve-playhead",
|
|
13
|
+
style: D({ left: `${l.left}px` }),
|
|
14
|
+
onMousedown: i[0] || (i[0] = le((M) => s("dragStart", M), ["stop", "prevent"]))
|
|
15
|
+
}, [...i[1] || (i[1] = [
|
|
16
|
+
Se('<svg class="ve-playhead__icon" width="12" height="18" viewBox="0 0 12 18" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-5de83cfe><g filter="url(#ve_playhead_drop_shadow)" data-v-5de83cfe><path d="M2 3C2 1.89543 2.89543 1 4 1H8C9.10457 1 10 1.89543 10 3V11.0925C10 11.6692 9.75104 12.2178 9.31701 12.5976L7.31701 14.3476C6.56296 15.0074 5.43704 15.0074 4.68299 14.3476L2.68299 12.5976C2.24896 12.2178 2 11.6692 2 11.0925V3Z" fill="white" data-v-5de83cfe></path><path d="M4 1.5H8C8.82843 1.5 9.5 2.17157 9.5 3V11.0928C9.49991 11.5252 9.31275 11.9369 8.9873 12.2217L6.9873 13.9717C6.42191 14.466 5.57809 14.466 5.0127 13.9717L3.0127 12.2217C2.68725 11.9369 2.50009 11.5252 2.5 11.0928V3C2.5 2.17157 3.17157 1.5 4 1.5Z" stroke="currentColor" data-v-5de83cfe></path></g><defs data-v-5de83cfe><filter id="ve_playhead_drop_shadow" x="0" y="0" width="12" height="17.8428" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB" data-v-5de83cfe><feFlood flood-opacity="0" result="BackgroundImageFix" data-v-5de83cfe></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" data-v-5de83cfe></feColorMatrix><feOffset dy="1" data-v-5de83cfe></feOffset><feGaussianBlur stdDeviation="1" data-v-5de83cfe></feGaussianBlur><feComposite in2="hardAlpha" operator="out" data-v-5de83cfe></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.08 0" data-v-5de83cfe></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow" data-v-5de83cfe></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape" data-v-5de83cfe></feBlend></filter></defs></svg><div class="ve-playhead__line" data-v-5de83cfe></div>', 2)
|
|
17
|
+
])], 36));
|
|
18
|
+
}
|
|
19
|
+
}), xe = (l, f) => {
|
|
20
|
+
const s = l.__vccOpts || l;
|
|
21
|
+
for (const [o, i] of f)
|
|
22
|
+
s[o] = i;
|
|
23
|
+
return s;
|
|
24
|
+
}, Oe = /* @__PURE__ */ xe(Ne, [["__scopeId", "data-v-5de83cfe"]]), Ye = { class: "ve-ruler" }, He = { class: "ve-ruler__ticks" }, We = {
|
|
25
|
+
key: 0,
|
|
26
|
+
class: "ve-ruler__label"
|
|
27
|
+
}, Ae = /* @__PURE__ */ pe({
|
|
28
|
+
name: "TimelineRuler",
|
|
29
|
+
__name: "TimelineRuler",
|
|
30
|
+
props: {
|
|
31
|
+
ticks: {}
|
|
32
|
+
},
|
|
33
|
+
setup(l) {
|
|
34
|
+
return (f, s) => (_(), k("div", Ye, [
|
|
35
|
+
c("div", He, [
|
|
36
|
+
(_(!0), k(ge, null, he(l.ticks, (o) => (_(), k("div", {
|
|
37
|
+
key: o.timeMs,
|
|
38
|
+
class: $e(["ve-ruler__tick", { "ve-ruler__tick--major": o.isMajor }]),
|
|
39
|
+
style: D({
|
|
40
|
+
left: `${o.position}px`,
|
|
41
|
+
transform: "translateX(-50%)"
|
|
42
|
+
})
|
|
43
|
+
}, [
|
|
44
|
+
s[0] || (s[0] = c("div", { class: "ve-ruler__line" }, null, -1)),
|
|
45
|
+
o.isMajor && o.label ? (_(), k("div", We, G(o.label), 1)) : ee("", !0)
|
|
46
|
+
], 6))), 128))
|
|
47
|
+
])
|
|
48
|
+
]));
|
|
49
|
+
}
|
|
50
|
+
}), je = /* @__PURE__ */ xe(Ae, [["__scopeId", "data-v-30f91636"]]), Ue = { class: "ve-toolbar" }, Ke = { class: "ve-toolbar__group" }, qe = ["disabled"], Je = { class: "ve-toolbar__group" }, Qe = { class: "ve-zoom" }, et = { class: "ve-toolbar__group" }, tt = ["disabled"], at = { class: "ve-toolbar__time" }, nt = /* @__PURE__ */ pe({
|
|
51
|
+
name: "TimelineToolbar",
|
|
52
|
+
__name: "TimelineToolbar",
|
|
53
|
+
props: {
|
|
54
|
+
zoom: {},
|
|
55
|
+
minZoom: { default: 0.25 },
|
|
56
|
+
maxZoom: { default: 10 },
|
|
57
|
+
currentTime: { default: 0 },
|
|
58
|
+
duration: { default: 0 },
|
|
59
|
+
formatTime: { type: Function, default: (l) => `${(l / 1e3).toFixed(2)}s` }
|
|
60
|
+
},
|
|
61
|
+
emits: ["zoomIn", "zoomOut"],
|
|
62
|
+
setup(l, { emit: f }) {
|
|
63
|
+
const s = f;
|
|
64
|
+
return (o, i) => (_(), k("div", Ue, [
|
|
65
|
+
c("div", Ke, [
|
|
66
|
+
V(o.$slots, "left-actions", {}, () => [
|
|
67
|
+
c("button", {
|
|
68
|
+
class: "ve-btn",
|
|
69
|
+
type: "button",
|
|
70
|
+
disabled: l.zoom <= l.minZoom,
|
|
71
|
+
onClick: i[0] || (i[0] = (M) => s("zoomOut"))
|
|
72
|
+
}, " - ", 8, qe)
|
|
73
|
+
], !0)
|
|
74
|
+
]),
|
|
75
|
+
c("div", Je, [
|
|
76
|
+
V(o.$slots, "center", {}, () => [
|
|
77
|
+
c("div", Qe, G((l.zoom * 100).toFixed(0)) + "% ", 1)
|
|
78
|
+
], !0)
|
|
79
|
+
]),
|
|
80
|
+
c("div", et, [
|
|
81
|
+
V(o.$slots, "right-actions", {}, () => [
|
|
82
|
+
c("button", {
|
|
83
|
+
class: "ve-btn",
|
|
84
|
+
type: "button",
|
|
85
|
+
disabled: l.zoom >= l.maxZoom,
|
|
86
|
+
onClick: i[1] || (i[1] = (M) => s("zoomIn"))
|
|
87
|
+
}, " + ", 8, tt)
|
|
88
|
+
], !0)
|
|
89
|
+
]),
|
|
90
|
+
c("div", at, [
|
|
91
|
+
V(o.$slots, "time", {
|
|
92
|
+
currentTime: l.currentTime,
|
|
93
|
+
duration: l.duration
|
|
94
|
+
}, () => [
|
|
95
|
+
c("span", null, G(l.formatTime?.(l.currentTime || 0)), 1),
|
|
96
|
+
i[2] || (i[2] = c("span", { class: "ve-toolbar__time-divider" }, "/", -1)),
|
|
97
|
+
c("span", null, G(l.formatTime?.(l.duration || 0)), 1)
|
|
98
|
+
], !0)
|
|
99
|
+
])
|
|
100
|
+
]));
|
|
101
|
+
}
|
|
102
|
+
}), st = /* @__PURE__ */ xe(nt, [["__scopeId", "data-v-85ddeb0f"]]);
|
|
103
|
+
function lt(l, f, s, o) {
|
|
104
|
+
function i(Z) {
|
|
105
|
+
if (!l.value || !f.value.length)
|
|
106
|
+
return null;
|
|
107
|
+
const h = l.value.getBoundingClientRect(), I = Z - h.top, r = s.value + o.value, p = o.value;
|
|
108
|
+
if (I < p / 2)
|
|
109
|
+
return { isGap: !0, insertIndex: 0 };
|
|
110
|
+
for (let g = 0; g < f.value.length; g++) {
|
|
111
|
+
const u = (g + 1) * r - p / 2, te = (g + 1) * r + p / 2;
|
|
112
|
+
if (I >= u && I < te)
|
|
113
|
+
return { isGap: !0, insertIndex: g + 1 };
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
function M(Z) {
|
|
118
|
+
if (!l.value || !f.value.length)
|
|
119
|
+
return -1;
|
|
120
|
+
const h = l.value.getBoundingClientRect(), I = Z - h.top, r = s.value + o.value;
|
|
121
|
+
return I < 0 ? -1 : Math.min(
|
|
122
|
+
f.value.length - 1,
|
|
123
|
+
Math.max(0, Math.floor(I / r))
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
detectTrackGap: i,
|
|
128
|
+
resolveTrackIndexFromClientY: M
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function ot(l, f, s) {
|
|
132
|
+
return {
|
|
133
|
+
snapGuides: T(() => {
|
|
134
|
+
if (!l.value)
|
|
135
|
+
return [];
|
|
136
|
+
const i = /* @__PURE__ */ new Set(), M = l.value.startTime, Z = l.value.endTime, h = 100;
|
|
137
|
+
return ("value" in f ? f.value : f).forEach((r) => {
|
|
138
|
+
r.segments.forEach((p) => {
|
|
139
|
+
p.id !== l.value?.segment.id && (Math.abs(p.start - M) < h && i.add(p.start), Math.abs(p.end - M) < h && i.add(p.end), Math.abs(p.start - Z) < h && i.add(p.start), Math.abs(p.end - Z) < h && i.add(p.end));
|
|
140
|
+
});
|
|
141
|
+
}), Array.from(i).map((r) => ({
|
|
142
|
+
time: r,
|
|
143
|
+
left: r * s.value
|
|
144
|
+
}));
|
|
145
|
+
})
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function it(l) {
|
|
149
|
+
const {
|
|
150
|
+
tracks: f,
|
|
151
|
+
tracksRef: s,
|
|
152
|
+
trackHeightPx: o,
|
|
153
|
+
trackGapPx: i,
|
|
154
|
+
pixelsPerMs: M,
|
|
155
|
+
disableInteraction: Z,
|
|
156
|
+
snap: h,
|
|
157
|
+
onDragStart: I,
|
|
158
|
+
onDrag: r,
|
|
159
|
+
onDragEnd: p
|
|
160
|
+
} = l, g = z(null), u = z(null), { detectTrackGap: te, resolveTrackIndexFromClientY: ke } = lt(
|
|
161
|
+
s,
|
|
162
|
+
f,
|
|
163
|
+
o,
|
|
164
|
+
i
|
|
165
|
+
), { snapGuides: oe } = ot(
|
|
166
|
+
u,
|
|
167
|
+
f,
|
|
168
|
+
M
|
|
169
|
+
);
|
|
170
|
+
function ie(v, q) {
|
|
171
|
+
Z.value || (g.value = {
|
|
172
|
+
layout: v,
|
|
173
|
+
initialX: q.clientX,
|
|
174
|
+
initialY: q.clientY,
|
|
175
|
+
moved: !1
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function re(v, q, F, $) {
|
|
179
|
+
const { layout: d, initialX: _e, initialY: Me } = v, de = q - _e, O = F - Me, Y = Math.abs(de) > 5 || Math.abs(O) > 5;
|
|
180
|
+
if (!v.moved && Y) {
|
|
181
|
+
v.moved = !0;
|
|
182
|
+
const E = {
|
|
183
|
+
segment: d.segment,
|
|
184
|
+
track: d.track,
|
|
185
|
+
trackIndex: d.trackIndex,
|
|
186
|
+
segmentIndex: d.segmentIndex,
|
|
187
|
+
startTime: d.segment.start,
|
|
188
|
+
endTime: d.segment.end,
|
|
189
|
+
targetTrackIndex: d.trackIndex,
|
|
190
|
+
targetTrackId: d.track.id,
|
|
191
|
+
isNewTrack: !1,
|
|
192
|
+
visualTrackIndex: d.trackIndex,
|
|
193
|
+
isValidTarget: !0,
|
|
194
|
+
mouseDeltaY: 0
|
|
195
|
+
};
|
|
196
|
+
I(E);
|
|
197
|
+
}
|
|
198
|
+
const H = d.segment.end - d.segment.start, W = d.segment.type || d.track.type, J = ke(F), w = J >= 0 ? J : d.trackIndex, L = f.value[w];
|
|
199
|
+
let x, Q, A, B = !1, ae, R = !0;
|
|
200
|
+
if (L && L.type === W) {
|
|
201
|
+
const E = te(F);
|
|
202
|
+
E ? (B = !0, ae = E.insertIndex, x = E.insertIndex, Q = E.insertIndex, A = d.track.id, R = !0) : (x = w, Q = w, A = L.id, R = !0);
|
|
203
|
+
} else if (!s.value)
|
|
204
|
+
x = d.trackIndex, Q = w, A = d.track.id, R = !1;
|
|
205
|
+
else {
|
|
206
|
+
const E = s.value.getBoundingClientRect(), ue = F - E.top, ce = o.value + i.value, me = w * ce + o.value / 2, ve = ue < me;
|
|
207
|
+
B = !0, ae = ve ? w : w + 1, x = ae, Q = w, A = d.track.id, R = !0;
|
|
208
|
+
}
|
|
209
|
+
const be = h(d.segment.start + de / Math.max(M.value, 1e-4)), j = Math.max(0, be), Ie = j + H, se = {
|
|
210
|
+
segment: d.segment,
|
|
211
|
+
track: d.track,
|
|
212
|
+
trackIndex: d.trackIndex,
|
|
213
|
+
segmentIndex: d.segmentIndex,
|
|
214
|
+
startTime: j,
|
|
215
|
+
endTime: Ie,
|
|
216
|
+
targetTrackIndex: x,
|
|
217
|
+
targetTrackId: A,
|
|
218
|
+
isNewTrack: B,
|
|
219
|
+
newTrackInsertIndex: ae,
|
|
220
|
+
visualTrackIndex: Q,
|
|
221
|
+
isValidTarget: R,
|
|
222
|
+
mouseDeltaY: O
|
|
223
|
+
};
|
|
224
|
+
v.moved && (u.value = se, $ === "drag" ? r(se) : $ === "end" && p(se));
|
|
225
|
+
}
|
|
226
|
+
function S(v) {
|
|
227
|
+
g.value && re(g.value, v.clientX, v.clientY, "drag");
|
|
228
|
+
}
|
|
229
|
+
function b(v) {
|
|
230
|
+
g.value && (re(g.value, v.clientX, v.clientY, "end"), g.value = null, u.value = null);
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
// State
|
|
234
|
+
draggingState: g,
|
|
235
|
+
dragPreview: u,
|
|
236
|
+
snapGuides: oe,
|
|
237
|
+
// Methods
|
|
238
|
+
startDrag: ie,
|
|
239
|
+
handleDragMove: S,
|
|
240
|
+
handleDragEnd: b
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
const rt = { class: "ve-timeline" }, dt = { class: "ve-track__body" }, ut = ["onMousedown", "onClick"], ct = { class: "ve-segment__content" }, mt = { class: "ve-segment__title" }, vt = { class: "ve-segment__time" }, ft = {
|
|
244
|
+
key: 0,
|
|
245
|
+
class: "ve-segment__selection"
|
|
246
|
+
}, gt = ["onMousedown"], ht = ["onMousedown"], pt = { class: "ve-segment__content" }, xt = { class: "ve-segment__title" }, kt = { class: "ve-segment__time" }, _t = 120, Ee = 10, Mt = /* @__PURE__ */ pe({
|
|
247
|
+
name: "VideoTimeline",
|
|
248
|
+
__name: "index",
|
|
249
|
+
props: {
|
|
250
|
+
tracks: {},
|
|
251
|
+
currentTime: {},
|
|
252
|
+
duration: {},
|
|
253
|
+
zoom: {},
|
|
254
|
+
minZoom: { default: 0.25 },
|
|
255
|
+
maxZoom: { default: 10 },
|
|
256
|
+
snapStep: { default: 0 },
|
|
257
|
+
trackHeight: { default: 56 },
|
|
258
|
+
trackGap: { default: 8 },
|
|
259
|
+
rulerHeight: { default: 28 },
|
|
260
|
+
minSegmentDuration: { default: 60 },
|
|
261
|
+
selectedSegmentId: { default: null },
|
|
262
|
+
disableInteraction: { type: Boolean, default: !1 },
|
|
263
|
+
fps: { default: 30 }
|
|
264
|
+
},
|
|
265
|
+
emits: ["update:currentTime", "update:zoom", "segmentClick", "segmentDragStart", "segmentDrag", "segmentDragEnd", "segmentResizeStart", "segmentResize", "segmentResizeEnd", "backgroundClick"],
|
|
266
|
+
setup(l, { emit: f }) {
|
|
267
|
+
const s = l, o = f, i = z(null), M = z(null), Z = z(null), h = z(0);
|
|
268
|
+
let I = null;
|
|
269
|
+
const r = z(B(s.zoom ?? s.minZoom)), p = z(!1);
|
|
270
|
+
fe(() => s.zoom, (e) => {
|
|
271
|
+
typeof e == "number" && (r.value = B(e));
|
|
272
|
+
}), fe(r, (e) => o("update:zoom", e));
|
|
273
|
+
const g = T(() => typeof s.duration == "number" ? Math.max(s.duration, 0) : Math.max(
|
|
274
|
+
0,
|
|
275
|
+
...s.tracks.flatMap(
|
|
276
|
+
(n) => n.segments.map((t) => t.end)
|
|
277
|
+
)
|
|
278
|
+
));
|
|
279
|
+
fe(g, (e, n) => {
|
|
280
|
+
if (!n || !e || n <= 0 || e <= 0 || !p.value || !h.value)
|
|
281
|
+
return;
|
|
282
|
+
const t = h.value * r.value / n;
|
|
283
|
+
if (!Number.isFinite(t) || t <= 0)
|
|
284
|
+
return;
|
|
285
|
+
const a = B(t * e / h.value);
|
|
286
|
+
Math.abs(a - r.value) > 1e-6 && (r.value = a);
|
|
287
|
+
});
|
|
288
|
+
const u = T(() => {
|
|
289
|
+
const e = Math.max(g.value, 1);
|
|
290
|
+
return Math.max(h.value, 1) * r.value / e;
|
|
291
|
+
}), te = T(() => {
|
|
292
|
+
const e = g.value * u.value, n = Number.isFinite(e) ? Math.max(e, 0) : 0;
|
|
293
|
+
return Math.max(Math.ceil(n), Math.ceil(h.value || 0));
|
|
294
|
+
}), ke = T(() => {
|
|
295
|
+
const e = Math.max(u.value, 1e-4), t = (te.value || h.value || 0) / e;
|
|
296
|
+
return Math.max(g.value, t);
|
|
297
|
+
}), oe = T(() => s.currentTime * u.value), ie = T(() => be(ke.value, u.value)), re = T(() => 1e3 / Math.max(s.fps || 30, 1)), S = T(() => s.trackHeight), b = T(() => s.trackGap), v = T(() => s.rulerHeight), q = T(() => s.tracks.map((e, n) => ({
|
|
298
|
+
track: e,
|
|
299
|
+
trackIndex: n,
|
|
300
|
+
segments: e.segments.map((t, a) => {
|
|
301
|
+
const m = Math.max((t.end - t.start) * u.value, 6), C = t.start * u.value;
|
|
302
|
+
return {
|
|
303
|
+
track: e,
|
|
304
|
+
trackIndex: n,
|
|
305
|
+
segment: t,
|
|
306
|
+
segmentIndex: a,
|
|
307
|
+
left: C,
|
|
308
|
+
width: m,
|
|
309
|
+
isSelected: s.selectedSegmentId === t.id
|
|
310
|
+
};
|
|
311
|
+
})
|
|
312
|
+
}))), {
|
|
313
|
+
draggingState: F,
|
|
314
|
+
dragPreview: $,
|
|
315
|
+
snapGuides: d,
|
|
316
|
+
startDrag: _e,
|
|
317
|
+
handleDragMove: Me,
|
|
318
|
+
handleDragEnd: de
|
|
319
|
+
} = it({
|
|
320
|
+
tracks: Re(s, "tracks"),
|
|
321
|
+
tracksRef: Z,
|
|
322
|
+
trackHeightPx: S,
|
|
323
|
+
trackGapPx: b,
|
|
324
|
+
pixelsPerMs: u,
|
|
325
|
+
disableInteraction: Re(s, "disableInteraction"),
|
|
326
|
+
snap: j,
|
|
327
|
+
onDragStart: (e) => {
|
|
328
|
+
o("segmentDragStart", e);
|
|
329
|
+
},
|
|
330
|
+
onDrag: (e) => {
|
|
331
|
+
o("segmentDrag", e);
|
|
332
|
+
},
|
|
333
|
+
onDragEnd: (e) => {
|
|
334
|
+
o("segmentDragEnd", e);
|
|
335
|
+
}
|
|
336
|
+
}), O = z(null), Y = T(() => $.value), H = T(() => O.value), W = z(null), J = z(!1), w = z(!1), L = z(!1), x = T(() => {
|
|
337
|
+
if (!$.value)
|
|
338
|
+
return null;
|
|
339
|
+
const e = $.value, t = q.value.find((y) => y.track.id === e.track.id)?.segments.find((y) => y.segment.id === e.segment.id);
|
|
340
|
+
if (!t)
|
|
341
|
+
return null;
|
|
342
|
+
const a = (e.startTime - e.segment.start) * u.value, C = v.value + e.trackIndex * (S.value + b.value) + b.value + e.mouseDeltaY;
|
|
343
|
+
return {
|
|
344
|
+
...t,
|
|
345
|
+
left: t.left + a,
|
|
346
|
+
top: C
|
|
347
|
+
};
|
|
348
|
+
}), Q = T(() => {
|
|
349
|
+
if (!$.value)
|
|
350
|
+
return 0;
|
|
351
|
+
const e = $.value;
|
|
352
|
+
return e.isNewTrack && e.newTrackInsertIndex === 0 ? v.value + b.value : v.value + e.targetTrackIndex * (S.value + b.value) + b.value;
|
|
353
|
+
});
|
|
354
|
+
Pe(() => {
|
|
355
|
+
i.value && (I = new ResizeObserver((e) => {
|
|
356
|
+
const n = e[0];
|
|
357
|
+
h.value = n?.contentRect.width || i.value?.clientWidth || 0;
|
|
358
|
+
}), I.observe(i.value), h.value = i.value.clientWidth || 0), window.addEventListener("mousemove", me), window.addEventListener("mouseup", ve), ae();
|
|
359
|
+
}), Ge(() => {
|
|
360
|
+
I?.disconnect(), I = null, window.removeEventListener("mousemove", me), window.removeEventListener("mouseup", ve);
|
|
361
|
+
}), fe(r, () => {
|
|
362
|
+
A();
|
|
363
|
+
});
|
|
364
|
+
function A() {
|
|
365
|
+
const e = i.value;
|
|
366
|
+
if (!e)
|
|
367
|
+
return;
|
|
368
|
+
const n = e.clientWidth / 2, t = s.currentTime * u.value - n;
|
|
369
|
+
e.scrollLeft = Math.max(0, t);
|
|
370
|
+
}
|
|
371
|
+
function B(e) {
|
|
372
|
+
return Number.isFinite(e) ? Math.min(Math.max(e, s.minZoom), s.maxZoom) : s.minZoom;
|
|
373
|
+
}
|
|
374
|
+
function ae() {
|
|
375
|
+
if (p.value)
|
|
376
|
+
return;
|
|
377
|
+
if (s.zoom !== void 0) {
|
|
378
|
+
p.value = !0;
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (!h.value || g.value <= 0)
|
|
382
|
+
return;
|
|
383
|
+
const e = B(1 / 3);
|
|
384
|
+
r.value = e, p.value = !0;
|
|
385
|
+
}
|
|
386
|
+
function R(e) {
|
|
387
|
+
const n = Math.max(e, 0), t = Math.floor(n / 1e3), a = Math.floor(t / 60).toString().padStart(2, "0"), m = (t % 60).toString().padStart(2, "0"), C = Math.floor(n % 1e3 / 10).toString().padStart(2, "0");
|
|
388
|
+
return `${a}:${m}.${C}`;
|
|
389
|
+
}
|
|
390
|
+
function Te(e) {
|
|
391
|
+
const n = Math.max(e, 0), t = Math.floor(n / 1e3), a = Math.floor(t / 60).toString().padStart(2, "0"), m = (t % 60).toString().padStart(2, "0");
|
|
392
|
+
return `${a}:${m}`;
|
|
393
|
+
}
|
|
394
|
+
function be(e, n) {
|
|
395
|
+
if (!e || !n)
|
|
396
|
+
return [];
|
|
397
|
+
const t = Ze(n, s.fps || 30), a = Math.max(1, Math.round(t.mainMs / t.minorMs)), m = Math.max(e, 1), C = Math.ceil(m / t.minorMs), y = [];
|
|
398
|
+
for (let X = 0; X <= C; X += 1) {
|
|
399
|
+
const P = Math.min(m, X * t.minorMs), N = P * n, U = X % a === 0;
|
|
400
|
+
y.push({
|
|
401
|
+
position: N,
|
|
402
|
+
timeMs: P,
|
|
403
|
+
isMajor: U,
|
|
404
|
+
label: U ? Be(P, s.fps || 30, t) : void 0
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
return y;
|
|
408
|
+
}
|
|
409
|
+
function j(e) {
|
|
410
|
+
const n = s.snapStep, t = n && n > 0 ? n : re.value;
|
|
411
|
+
return Math.max(Math.round(e / t) * t, 0);
|
|
412
|
+
}
|
|
413
|
+
function Ie(e) {
|
|
414
|
+
if (!M.value)
|
|
415
|
+
return;
|
|
416
|
+
if (L.value) {
|
|
417
|
+
L.value = !1;
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
const n = M.value.getBoundingClientRect(), t = e.clientX - n.left, a = j(t / Math.max(u.value, 1e-4));
|
|
421
|
+
o("update:currentTime", a), o("backgroundClick", e), w.value = !0;
|
|
422
|
+
}
|
|
423
|
+
function se(e) {
|
|
424
|
+
s.disableInteraction || (e.preventDefault(), J.value = !0, w.value = !0, E(e.clientX), A());
|
|
425
|
+
}
|
|
426
|
+
function E(e) {
|
|
427
|
+
if (!M.value)
|
|
428
|
+
return;
|
|
429
|
+
const n = M.value.getBoundingClientRect(), t = e - n.left, a = j(t / Math.max(u.value, 1e-4));
|
|
430
|
+
o("update:currentTime", a);
|
|
431
|
+
}
|
|
432
|
+
function ue(e, n, t) {
|
|
433
|
+
if (s.disableInteraction)
|
|
434
|
+
return;
|
|
435
|
+
t.stopPropagation(), t.preventDefault(), W.value = {
|
|
436
|
+
layout: e,
|
|
437
|
+
edge: n,
|
|
438
|
+
initialX: t.clientX
|
|
439
|
+
};
|
|
440
|
+
const a = {
|
|
441
|
+
segment: e.segment,
|
|
442
|
+
track: e.track,
|
|
443
|
+
trackIndex: e.trackIndex,
|
|
444
|
+
segmentIndex: e.segmentIndex,
|
|
445
|
+
startTime: e.segment.start,
|
|
446
|
+
endTime: e.segment.end,
|
|
447
|
+
edge: n
|
|
448
|
+
};
|
|
449
|
+
O.value = a, o("segmentResizeStart", a);
|
|
450
|
+
}
|
|
451
|
+
function ce(e, n, t) {
|
|
452
|
+
const { layout: a, edge: m, initialX: C } = e, X = (n - C) / Math.max(u.value, 1e-4), P = Math.max(s.minSegmentDuration, 10);
|
|
453
|
+
let N = a.segment.start, U = a.segment.end;
|
|
454
|
+
m === "start" ? (N = j(Math.max(0, a.segment.start + X)), a.segment.end - N < P && (N = a.segment.end - P)) : U = j(Math.max(a.segment.start + P, a.segment.end + X));
|
|
455
|
+
const ne = {
|
|
456
|
+
segment: a.segment,
|
|
457
|
+
track: a.track,
|
|
458
|
+
trackIndex: a.trackIndex,
|
|
459
|
+
segmentIndex: a.segmentIndex,
|
|
460
|
+
startTime: N,
|
|
461
|
+
endTime: U,
|
|
462
|
+
edge: m
|
|
463
|
+
};
|
|
464
|
+
O.value = ne, t === "drag" ? o("segmentResize", ne) : t === "end" && o("segmentResizeEnd", ne);
|
|
465
|
+
}
|
|
466
|
+
function we(e, n) {
|
|
467
|
+
F.value?.layout.segment.id === e.segment.id && F.value.moved || o("segmentClick", e, n);
|
|
468
|
+
}
|
|
469
|
+
function me(e) {
|
|
470
|
+
if (J.value) {
|
|
471
|
+
E(e.clientX);
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (W.value) {
|
|
475
|
+
ce(W.value, e.clientX, "drag");
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
Me(e);
|
|
479
|
+
}
|
|
480
|
+
function ve(e) {
|
|
481
|
+
if (J.value) {
|
|
482
|
+
J.value = !1, w.value = !1, E(e.clientX), L.value = !0;
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (W.value) {
|
|
486
|
+
ce(W.value, e.clientX, "end"), W.value = null, O.value = null, w.value = !1, L.value = !0;
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
if (F.value)
|
|
490
|
+
if (F.value.moved)
|
|
491
|
+
L.value = !0;
|
|
492
|
+
else {
|
|
493
|
+
const { layout: n } = F.value;
|
|
494
|
+
we(n, e);
|
|
495
|
+
}
|
|
496
|
+
de(e), w.value = !1;
|
|
497
|
+
}
|
|
498
|
+
function Ce() {
|
|
499
|
+
r.value = B(r.value * 1.25);
|
|
500
|
+
}
|
|
501
|
+
function De() {
|
|
502
|
+
r.value = B(r.value / 1.25);
|
|
503
|
+
}
|
|
504
|
+
function Ze(e, n) {
|
|
505
|
+
const a = 1e3 / (Number.isFinite(n) && n > 0 ? n : 30), m = e * a, C = Xe(a), y = Fe(a), X = m >= Ee ? [...y, ...C] : C;
|
|
506
|
+
let P = null, N = 1 / 0;
|
|
507
|
+
for (const U of X) {
|
|
508
|
+
const ne = U.mainMs * e;
|
|
509
|
+
if (ne < Ee)
|
|
510
|
+
continue;
|
|
511
|
+
const ze = Math.abs(ne - _t);
|
|
512
|
+
ze < N && (P = U, N = ze);
|
|
513
|
+
}
|
|
514
|
+
return P || X[X.length - 1] || y[y.length - 1];
|
|
515
|
+
}
|
|
516
|
+
function Xe(e) {
|
|
517
|
+
return [600, 300, 180, 120, 60, 30, 20, 15, 10, 5, 3, 2, 1].map((t) => {
|
|
518
|
+
const a = t * 1e3;
|
|
519
|
+
return {
|
|
520
|
+
mainMs: a,
|
|
521
|
+
minorMs: Math.max(a / 10, e),
|
|
522
|
+
mode: "time",
|
|
523
|
+
label: "time"
|
|
524
|
+
};
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function Fe(e) {
|
|
528
|
+
return [
|
|
529
|
+
{
|
|
530
|
+
mainMs: Math.max(e * 2, 1),
|
|
531
|
+
minorMs: Math.max(e, 1),
|
|
532
|
+
mode: "frame",
|
|
533
|
+
label: "frame"
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
mainMs: Math.max(e * 10, 1),
|
|
537
|
+
minorMs: Math.max(e * 2, 1),
|
|
538
|
+
mode: "frame",
|
|
539
|
+
label: "frame"
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
mainMs: 1e3,
|
|
543
|
+
minorMs: Math.max(e * 10, 1),
|
|
544
|
+
mode: "frame",
|
|
545
|
+
label: "frame"
|
|
546
|
+
}
|
|
547
|
+
];
|
|
548
|
+
}
|
|
549
|
+
function Be(e, n, t) {
|
|
550
|
+
if (t.label === "frame") {
|
|
551
|
+
const a = Number.isFinite(n) && n > 0 ? n : 30, m = 1e3 / a, y = Math.round(e / m) % a;
|
|
552
|
+
return y === 0 ? Te(e) : `${y}f`;
|
|
553
|
+
}
|
|
554
|
+
return Te(e);
|
|
555
|
+
}
|
|
556
|
+
return (e, n) => (_(), k("div", rt, [
|
|
557
|
+
V(e.$slots, "toolbar", {
|
|
558
|
+
zoom: r.value,
|
|
559
|
+
canZoomIn: r.value < l.maxZoom,
|
|
560
|
+
canZoomOut: r.value > l.minZoom,
|
|
561
|
+
zoomIn: Ce,
|
|
562
|
+
zoomOut: De,
|
|
563
|
+
currentTime: l.currentTime,
|
|
564
|
+
duration: g.value,
|
|
565
|
+
formatTime: R
|
|
566
|
+
}, () => [
|
|
567
|
+
ye(st, {
|
|
568
|
+
zoom: r.value,
|
|
569
|
+
"min-zoom": l.minZoom,
|
|
570
|
+
"max-zoom": l.maxZoom,
|
|
571
|
+
"current-time": l.currentTime,
|
|
572
|
+
duration: g.value,
|
|
573
|
+
"format-time": R,
|
|
574
|
+
onZoomIn: Ce,
|
|
575
|
+
onZoomOut: De
|
|
576
|
+
}, null, 8, ["zoom", "min-zoom", "max-zoom", "current-time", "duration"])
|
|
577
|
+
], !0),
|
|
578
|
+
c("div", {
|
|
579
|
+
ref_key: "viewportRef",
|
|
580
|
+
ref: i,
|
|
581
|
+
class: "ve-timeline__viewport",
|
|
582
|
+
onClick: Ie
|
|
583
|
+
}, [
|
|
584
|
+
c("div", {
|
|
585
|
+
ref_key: "contentRef",
|
|
586
|
+
ref: M,
|
|
587
|
+
class: "ve-timeline__content",
|
|
588
|
+
style: D({ width: `${te.value}px` })
|
|
589
|
+
}, [
|
|
590
|
+
V(e.$slots, "ruler", {
|
|
591
|
+
ticks: ie.value,
|
|
592
|
+
pixelsPerMs: u.value
|
|
593
|
+
}, () => [
|
|
594
|
+
ye(je, {
|
|
595
|
+
ticks: ie.value,
|
|
596
|
+
style: D({ height: `${v.value}px` })
|
|
597
|
+
}, null, 8, ["ticks", "style"])
|
|
598
|
+
], !0),
|
|
599
|
+
V(e.$slots, "playhead", {
|
|
600
|
+
left: oe.value,
|
|
601
|
+
currentTime: l.currentTime
|
|
602
|
+
}, () => [
|
|
603
|
+
ye(Oe, {
|
|
604
|
+
class: "top-0",
|
|
605
|
+
left: oe.value,
|
|
606
|
+
onDragStart: se
|
|
607
|
+
}, null, 8, ["left"])
|
|
608
|
+
], !0),
|
|
609
|
+
c("div", {
|
|
610
|
+
ref_key: "tracksRef",
|
|
611
|
+
ref: Z,
|
|
612
|
+
class: "ve-timeline__tracks",
|
|
613
|
+
style: D({ gap: `${b.value}px`, paddingTop: `${b.value}px` })
|
|
614
|
+
}, [
|
|
615
|
+
(_(!0), k(ge, null, he(q.value, (t) => (_(), k("div", {
|
|
616
|
+
key: t.track.id,
|
|
617
|
+
class: $e(["ve-track", { "ve-track--main": t.track.isMain }]),
|
|
618
|
+
style: D({ height: `${S.value}px` })
|
|
619
|
+
}, [
|
|
620
|
+
V(e.$slots, "track", {
|
|
621
|
+
track: t.track,
|
|
622
|
+
index: t.trackIndex,
|
|
623
|
+
segments: t.segments,
|
|
624
|
+
pixelsPerMs: u.value,
|
|
625
|
+
height: S.value
|
|
626
|
+
}, () => [
|
|
627
|
+
c("div", dt, [
|
|
628
|
+
(_(!0), k(ge, null, he(t.segments, (a) => Ve((_(), k("div", {
|
|
629
|
+
key: a.segment.id,
|
|
630
|
+
class: $e(["ve-segment", {
|
|
631
|
+
"ve-segment--selected": a.isSelected
|
|
632
|
+
}]),
|
|
633
|
+
style: D({
|
|
634
|
+
left: `${a.left}px`,
|
|
635
|
+
width: `${a.width}px`,
|
|
636
|
+
backgroundColor: a.segment.color || t.track.color || "var(--ve-primary)"
|
|
637
|
+
}),
|
|
638
|
+
onMousedown: le((m) => K(_e)(a, m), ["prevent", "stop"]),
|
|
639
|
+
onClick: le((m) => we(a, m), ["stop"])
|
|
640
|
+
}, [
|
|
641
|
+
V(e.$slots, "segment", {
|
|
642
|
+
layout: a,
|
|
643
|
+
segment: a.segment,
|
|
644
|
+
track: a.track,
|
|
645
|
+
isSelected: a.isSelected
|
|
646
|
+
}, () => [
|
|
647
|
+
c("div", ct, [
|
|
648
|
+
c("div", mt, G(a.segment.type || "segment"), 1),
|
|
649
|
+
c("div", vt, G(R(a.segment.start)) + " - " + G(R(a.segment.end)), 1)
|
|
650
|
+
])
|
|
651
|
+
], !0),
|
|
652
|
+
a.isSelected ? (_(), k("div", ft, [
|
|
653
|
+
c("div", {
|
|
654
|
+
class: "ve-segment__handle ve-segment__handle--left",
|
|
655
|
+
onMousedown: le((m) => ue(a, "start", m), ["stop"])
|
|
656
|
+
}, [...n[0] || (n[0] = [
|
|
657
|
+
Se('<div class="ve-segment__handle-dots" data-v-66a36acd><div class="ve-segment__handle-dot" data-v-66a36acd></div><div class="ve-segment__handle-dot" data-v-66a36acd></div><div class="ve-segment__handle-dot" data-v-66a36acd></div><div class="ve-segment__handle-dot" data-v-66a36acd></div></div>', 1)
|
|
658
|
+
])], 40, gt),
|
|
659
|
+
c("div", {
|
|
660
|
+
class: "ve-segment__handle ve-segment__handle--right",
|
|
661
|
+
onMousedown: le((m) => ue(a, "end", m), ["stop"])
|
|
662
|
+
}, [...n[1] || (n[1] = [
|
|
663
|
+
Se('<div class="ve-segment__handle-dots" data-v-66a36acd><div class="ve-segment__handle-dot" data-v-66a36acd></div><div class="ve-segment__handle-dot" data-v-66a36acd></div><div class="ve-segment__handle-dot" data-v-66a36acd></div><div class="ve-segment__handle-dot" data-v-66a36acd></div></div>', 1)
|
|
664
|
+
])], 40, ht)
|
|
665
|
+
])) : ee("", !0)
|
|
666
|
+
], 46, ut)), [
|
|
667
|
+
[Le, K($)?.segment.id !== a.segment.id && O.value?.segment.id !== a.segment.id]
|
|
668
|
+
])), 128))
|
|
669
|
+
])
|
|
670
|
+
], !0)
|
|
671
|
+
], 6))), 128))
|
|
672
|
+
], 4),
|
|
673
|
+
x.value ? (_(), k("div", {
|
|
674
|
+
key: 0,
|
|
675
|
+
class: "ve-segment ve-segment--dragging",
|
|
676
|
+
style: D({
|
|
677
|
+
left: `${x.value.left}px`,
|
|
678
|
+
width: `${x.value.width}px`,
|
|
679
|
+
top: `${x.value.top}px`,
|
|
680
|
+
height: `${S.value}px`,
|
|
681
|
+
backgroundColor: x.value.segment.color || "var(--ve-primary)"
|
|
682
|
+
})
|
|
683
|
+
}, [
|
|
684
|
+
V(e.$slots, "segment", {
|
|
685
|
+
layout: x.value,
|
|
686
|
+
segment: x.value.segment,
|
|
687
|
+
track: x.value.track,
|
|
688
|
+
isSelected: x.value.isSelected
|
|
689
|
+
}, () => [
|
|
690
|
+
c("div", pt, [
|
|
691
|
+
c("div", xt, G(x.value.segment.type || "segment"), 1),
|
|
692
|
+
c("div", kt, G(R(x.value.segment.start)) + " - " + G(R(x.value.segment.end)), 1)
|
|
693
|
+
])
|
|
694
|
+
], !0)
|
|
695
|
+
], 4)) : ee("", !0),
|
|
696
|
+
Y.value && !Y.value.isNewTrack ? (_(), k("div", {
|
|
697
|
+
key: 1,
|
|
698
|
+
class: "ve-segment ve-segment--placeholder",
|
|
699
|
+
style: D({
|
|
700
|
+
left: `${Y.value.startTime * u.value}px`,
|
|
701
|
+
width: `${(Y.value.endTime - Y.value.startTime) * u.value}px`,
|
|
702
|
+
top: `${Q.value}px`,
|
|
703
|
+
height: `${S.value}px`
|
|
704
|
+
})
|
|
705
|
+
}, [
|
|
706
|
+
c("div", {
|
|
707
|
+
class: "ve-segment--placeholder-inner",
|
|
708
|
+
style: D({
|
|
709
|
+
backgroundColor: Y.value.segment.color || "var(--ve-primary)"
|
|
710
|
+
})
|
|
711
|
+
}, null, 4)
|
|
712
|
+
], 4)) : ee("", !0),
|
|
713
|
+
H.value ? (_(), k("div", {
|
|
714
|
+
key: 2,
|
|
715
|
+
class: "ve-segment ve-segment--preview",
|
|
716
|
+
style: D({
|
|
717
|
+
left: `${H.value.startTime * u.value}px`,
|
|
718
|
+
width: `${(H.value.endTime - H.value.startTime) * u.value}px`,
|
|
719
|
+
top: `${v.value + H.value.trackIndex * (S.value + b.value) + b.value}px`,
|
|
720
|
+
height: `${S.value}px`,
|
|
721
|
+
backgroundColor: H.value.segment.color || "var(--ve-primary)"
|
|
722
|
+
})
|
|
723
|
+
}, null, 4)) : ee("", !0),
|
|
724
|
+
K($) && K(d).length ? (_(!0), k(ge, { key: 3 }, he(K(d), (t) => (_(), k("div", {
|
|
725
|
+
key: `snap-${t.time}`,
|
|
726
|
+
class: "ve-snap-guide",
|
|
727
|
+
style: D({
|
|
728
|
+
left: `${t.left}px`,
|
|
729
|
+
top: `${v.value}px`,
|
|
730
|
+
height: `calc(100% - ${v.value}px)`
|
|
731
|
+
})
|
|
732
|
+
}, null, 4))), 128)) : ee("", !0),
|
|
733
|
+
K($) && K($).isNewTrack ? (_(), k("div", {
|
|
734
|
+
key: 4,
|
|
735
|
+
class: "ve-new-track-line",
|
|
736
|
+
style: D({
|
|
737
|
+
top: `${v.value + K($).targetTrackIndex * (S.value + b.value)}px`,
|
|
738
|
+
left: "0",
|
|
739
|
+
right: "0"
|
|
740
|
+
})
|
|
741
|
+
}, null, 4)) : ee("", !0)
|
|
742
|
+
], 4)
|
|
743
|
+
], 512)
|
|
744
|
+
]));
|
|
745
|
+
}
|
|
746
|
+
}), bt = /* @__PURE__ */ xe(Mt, [["__scopeId", "data-v-66a36acd"]]);
|
|
747
|
+
export {
|
|
748
|
+
bt as V,
|
|
749
|
+
xe as _
|
|
750
|
+
};
|