@video-editor/ui 0.0.1-beta.25 → 0.0.1-beta.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { V as a } from "./index-BXF8FAG_.js";
1
+ import { V as a } from "./index-CV2smFQN.js";
2
2
  import "./index-C0eQjJkj.js";
3
3
  export {
4
4
  a as default
@@ -0,0 +1,403 @@
1
+ import { defineComponent as Y, ref as J, onMounted as x, onBeforeUnmount as ee, reactive as K, watch as Q, createElementBlock as f, openBlock as u, renderSlot as m, normalizeStyle as U, createElementVNode as p, Fragment as C, renderList as _, toDisplayString as E, createCommentVNode as F, computed as B, watchEffect as te, createBlock as ne, createSlots as se, withCtx as D, createVNode as M, unref as I, normalizeProps as j, guardReactiveProps as N } from "vue";
2
+ import { generateThumbnails as re, getMp4Meta as oe } from "@video-editor/protocol";
3
+ import { isVideoFramesSegment as H, isAudioSegment as ae } from "@video-editor/shared";
4
+ import { _ as q, V as ie } from "./index-C0eQjJkj.js";
5
+ const le = { class: "frames-segment" }, ce = { class: "frames-segment__video" }, me = {
6
+ key: 1,
7
+ class: "frames-segment__placeholder"
8
+ }, de = { class: "frames-segment__placeholder" }, ue = {
9
+ key: 0,
10
+ class: "frames-segment__badge"
11
+ }, fe = /* @__PURE__ */ Y({
12
+ name: "FramesSegment",
13
+ __name: "FramesSegment",
14
+ props: {
15
+ segment: {}
16
+ },
17
+ setup(a) {
18
+ const R = a, l = J(null), d = J(1);
19
+ let y = null;
20
+ x(() => {
21
+ l.value && (y = new ResizeObserver((n) => {
22
+ for (const r of n) {
23
+ const i = Math.max(1, Math.ceil(r.contentRect.width / 56));
24
+ d.value !== i && (d.value = i);
25
+ }
26
+ }), y.observe(l.value));
27
+ }), ee(() => {
28
+ y?.disconnect(), w();
29
+ });
30
+ const c = K({ items: [], loading: !1, error: null });
31
+ let b = 0, k, h = null;
32
+ Q(() => R.segment, (n, r) => {
33
+ if (!H(n))
34
+ return;
35
+ (!r || L(r, n)) && A(n, r);
36
+ }, { immediate: !0, deep: !0 });
37
+ function L(n, r) {
38
+ return n.url !== r.url || n.startTime !== r.startTime || n.endTime !== r.endTime || n.fromTime !== r.fromTime;
39
+ }
40
+ function A(n, r) {
41
+ const i = !r || r.url !== n.url, T = !r || r.fromTime !== n.fromTime, v = i || T;
42
+ if (h = n, k && (window.clearTimeout(k), k = void 0), v) {
43
+ V(n);
44
+ return;
45
+ }
46
+ k = window.setTimeout(() => {
47
+ h && V(h), k = void 0;
48
+ }, 240);
49
+ }
50
+ async function V(n) {
51
+ if (!n.url)
52
+ return;
53
+ const r = ++b;
54
+ w(), c.loading = !0, c.error = null;
55
+ try {
56
+ const i = O(n), T = await re(n.url, i);
57
+ if (b !== r)
58
+ return;
59
+ const v = T.map((S) => ({
60
+ tsMs: Math.round(S.ts / 1e3),
61
+ url: URL.createObjectURL(S.img)
62
+ }));
63
+ c.items = v, c.loading = !1;
64
+ } catch (i) {
65
+ if (b !== r)
66
+ return;
67
+ c.error = i instanceof Error ? i.message : String(i), c.loading = !1;
68
+ }
69
+ }
70
+ function O(n) {
71
+ const r = Math.max(n.fromTime ?? 0, 0) * 1e3, i = Math.max(n.endTime - n.startTime, 1), T = r + i * 1e3, S = Math.max(Math.floor((T - r) / 8), 2e5);
72
+ return { start: r, end: T, step: S };
73
+ }
74
+ function w() {
75
+ c.items.forEach((n) => URL.revokeObjectURL(n.url)), c.items = [];
76
+ }
77
+ return (n, r) => (u(), f("div", le, [
78
+ a.segment.type === "image" ? m(n.$slots, "image", {
79
+ key: 0,
80
+ segment: a.segment,
81
+ style: U({ backgroundImage: a.segment.url ? `url(${a.segment.url})` : "" })
82
+ }, () => [
83
+ p("div", {
84
+ ref_key: "containerRef",
85
+ ref: l,
86
+ class: "frames-segment__image"
87
+ }, [
88
+ (u(!0), f(C, null, _(d.value, (i) => (u(), f("div", {
89
+ key: i,
90
+ class: "frames-segment__image-item",
91
+ style: U({ backgroundImage: a.segment.url ? `url(${a.segment.url})` : "" })
92
+ }, null, 4))), 128))
93
+ ], 512)
94
+ ], !0) : a.segment.type === "video" ? (u(), f(C, { key: 1 }, [
95
+ c.items.length ? m(n.$slots, "video", {
96
+ key: 0,
97
+ segment: a.segment,
98
+ thumbnails: c.items
99
+ }, () => [
100
+ p("div", ce, [
101
+ (u(!0), f(C, null, _(c.items, (i) => (u(), f("div", {
102
+ key: `${a.segment.id}-${i.tsMs}`,
103
+ class: "frames-segment__thumb",
104
+ style: U({ backgroundImage: `url(${i.url})` })
105
+ }, null, 4))), 128))
106
+ ])
107
+ ], !0) : (u(), f("div", me, [
108
+ c.loading ? m(n.$slots, "loading", {
109
+ key: 0,
110
+ segment: a.segment
111
+ }, () => [
112
+ r[0] || (r[0] = p("span", null, "抽帧中…", -1))
113
+ ], !0) : c.error ? m(n.$slots, "error", {
114
+ key: 1,
115
+ segment: a.segment,
116
+ error: c.error
117
+ }, () => [
118
+ r[1] || (r[1] = p("span", null, "生成失败", -1))
119
+ ], !0) : m(n.$slots, "empty", {
120
+ key: 2,
121
+ segment: a.segment
122
+ }, () => [
123
+ r[2] || (r[2] = p("span", null, "未生成缩略图", -1))
124
+ ], !0)
125
+ ]))
126
+ ], 64)) : m(n.$slots, "fallback", {
127
+ key: 2,
128
+ segment: a.segment
129
+ }, () => [
130
+ p("div", de, [
131
+ p("span", null, E(a.segment.type), 1)
132
+ ])
133
+ ], !0),
134
+ m(n.$slots, "overlay", { segment: a.segment }, () => [
135
+ a.segment.extra?.label ? (u(), f("span", ue, E(a.segment.extra?.label), 1)) : F("", !0)
136
+ ], !0)
137
+ ]));
138
+ }
139
+ }), ge = /* @__PURE__ */ q(fe, [["__scopeId", "data-v-d630c479"]]), pe = { class: "segment-base" }, ke = { class: "segment-base__content" }, ye = { class: "segment-base__pill segment-base__pill--primary" }, Te = { class: "segment-base__pill segment-base__pill--muted" }, he = {
140
+ key: 0,
141
+ class: "segment-base__badge"
142
+ }, be = /* @__PURE__ */ Y({
143
+ name: "SegmentBase",
144
+ __name: "SegmentBase",
145
+ props: {
146
+ segment: {},
147
+ trackType: {},
148
+ accentColor: { default: "#222226" }
149
+ },
150
+ setup(a) {
151
+ const R = a, l = B(() => {
152
+ const d = R.segment?.extra?.label;
153
+ return typeof d == "string" ? d : null;
154
+ });
155
+ return (d, y) => (u(), f("div", pe, [
156
+ p("div", ke, [
157
+ p("span", ye, E(a.trackType), 1),
158
+ p("span", Te, E(a.segment.segmentType), 1)
159
+ ]),
160
+ l.value ? (u(), f("span", he, E(l.value), 1)) : F("", !0)
161
+ ]));
162
+ }
163
+ }), z = /* @__PURE__ */ q(be, [["__scopeId", "data-v-d386af72"]]), ve = { class: "ve-editor-segment__preview" }, P = "#222226", Se = 0.4, $e = /* @__PURE__ */ Y({
164
+ name: "VideoEditorTimeline",
165
+ __name: "index",
166
+ props: {
167
+ protocol: { default: null },
168
+ currentTime: {},
169
+ zoom: {},
170
+ snapStep: { default: 0 },
171
+ selectedSegmentId: { default: null },
172
+ trackTypes: { default: void 0 },
173
+ disableInteraction: { type: Boolean, default: !1 }
174
+ },
175
+ emits: ["update:currentTime", "update:zoom", "update:selectedSegmentId", "segmentClick", "segmentDragEnd", "segmentResizeEnd", "add-segment"],
176
+ setup(a, { emit: R }) {
177
+ const l = a, d = R, y = J(l.selectedSegmentId ?? null);
178
+ Q(() => l.selectedSegmentId, (e) => {
179
+ y.value = e ?? null;
180
+ });
181
+ const c = {
182
+ frames: P,
183
+ audio: "#0ea5e9",
184
+ text: "#16a34a",
185
+ sticker: "#f97316",
186
+ effect: "#a855f7",
187
+ filter: "#64748b"
188
+ }, b = B(() => {
189
+ if (!l.protocol?.tracks?.length)
190
+ return [];
191
+ const o = (l.trackTypes?.length ? l.protocol.tracks.filter((s) => l.trackTypes?.includes(s.trackType)) : l.protocol.tracks).slice(), t = o.findIndex((s) => s.trackType === "frames" && s.isMain === !0);
192
+ if (t !== -1) {
193
+ const [s] = o.splice(t, 1);
194
+ o.push(s);
195
+ }
196
+ return o;
197
+ }), k = K(/* @__PURE__ */ new Map()), h = /* @__PURE__ */ new Map();
198
+ function L(e) {
199
+ if (!e || k.has(e) || h.has(e))
200
+ return;
201
+ const o = (async () => {
202
+ try {
203
+ const t = await oe(e);
204
+ k.set(e, t.durationMs);
205
+ } catch {
206
+ }
207
+ })().finally(() => {
208
+ h.delete(e);
209
+ });
210
+ h.set(e, o);
211
+ }
212
+ const A = B(() => b.value.map((e, o) => {
213
+ const t = c[e.trackType] || P, s = O(t, Se), $ = e.trackType === "frames" && e.isMain === !0;
214
+ return {
215
+ id: e.trackId || `${e.trackType}-${o}`,
216
+ label: e.trackType,
217
+ type: e.trackType,
218
+ color: t,
219
+ isMain: $,
220
+ payload: e,
221
+ segments: e.children.map((g) => ({
222
+ ...H(g) ? { fromTime: g.fromTime ?? 0, sourceDurationMs: k.get(g.url) } : ae(g) ? { fromTime: g.fromTime ?? 0 } : {},
223
+ id: g.id,
224
+ start: g.startTime,
225
+ end: g.endTime,
226
+ type: g.segmentType,
227
+ color: s,
228
+ payload: g
229
+ }))
230
+ };
231
+ }));
232
+ te(() => {
233
+ for (const e of b.value)
234
+ for (const o of e.children)
235
+ H(o) && L(o.url);
236
+ });
237
+ const V = B(() => {
238
+ if (!l.protocol?.tracks?.length)
239
+ return 0;
240
+ const e = l.protocol.tracks.flatMap((o) => o.children.map((t) => t.endTime));
241
+ return e.length ? Math.max(...e) : 0;
242
+ });
243
+ function O(e, o) {
244
+ const t = e.replace("#", "");
245
+ if (!(t.length === 3 || t.length === 6))
246
+ return e;
247
+ const s = t.length === 3 ? t.split("").map((G) => G + G).join("") : t, $ = Number.parseInt(s.slice(0, 2), 16), g = Number.parseInt(s.slice(2, 4), 16), Z = Number.parseInt(s.slice(4, 6), 16);
248
+ return `rgba(${$}, ${g}, ${Z}, ${o})`;
249
+ }
250
+ function w(e) {
251
+ return e && typeof e == "object" && "segmentType" in e ? e : null;
252
+ }
253
+ function n(e) {
254
+ const o = e.payload;
255
+ if (o)
256
+ return o;
257
+ if (l.protocol)
258
+ return l.protocol.tracks.find((t) => t.trackId === e.id);
259
+ }
260
+ function r(e) {
261
+ y.value = e, d("update:selectedSegmentId", e);
262
+ }
263
+ function i(e) {
264
+ const o = w(e.segment.payload), t = n(e.track);
265
+ o && (r(o.id), t && d("segmentClick", { segment: o, track: t }));
266
+ }
267
+ function T(e) {
268
+ r(e.segment.id);
269
+ }
270
+ function v(e) {
271
+ d("segmentDragEnd", e);
272
+ }
273
+ function S(e) {
274
+ r(e.segment.id);
275
+ }
276
+ function W(e) {
277
+ d("segmentResizeEnd", e);
278
+ }
279
+ function X({ track: e, startTime: o, endTime: t, event: s }) {
280
+ const $ = e.payload;
281
+ $ && d("add-segment", { track: $, startTime: o, endTime: t, event: s });
282
+ }
283
+ return (e, o) => (u(), ne(ie, {
284
+ tracks: A.value,
285
+ duration: V.value,
286
+ "current-time": a.currentTime,
287
+ zoom: a.zoom,
288
+ fps: a.protocol?.fps || 30,
289
+ "snap-step": a.snapStep,
290
+ "selected-segment-id": y.value ?? null,
291
+ "disable-interaction": a.disableInteraction,
292
+ "onUpdate:currentTime": o[0] || (o[0] = (t) => d("update:currentTime", t)),
293
+ "onUpdate:zoom": o[1] || (o[1] = (t) => d("update:zoom", t)),
294
+ onSegmentClick: i,
295
+ onSegmentDragStart: T,
296
+ onSegmentDragEnd: v,
297
+ onSegmentResizeStart: S,
298
+ onSegmentResizeEnd: W,
299
+ onBackgroundClick: o[2] || (o[2] = (t) => r(null)),
300
+ onAddSegment: X
301
+ }, se({
302
+ segment: D(({ layout: t }) => [
303
+ (u(!0), f(C, null, _([w(t.segment.payload)], (s) => (u(), f(C, {
304
+ key: s?.id || t.segment.id
305
+ }, [
306
+ s ? (u(), f("div", {
307
+ key: 0,
308
+ class: "ve-editor-segment",
309
+ style: U({ "--ve-segment-accent": t.track.color || P })
310
+ }, [
311
+ p("div", ve, [
312
+ s.segmentType === "frames" ? m(e.$slots, "segment-frames", {
313
+ key: 0,
314
+ segment: s,
315
+ layout: t
316
+ }, () => [
317
+ M(I(ge), { segment: s }, null, 8, ["segment"])
318
+ ], !0) : s.segmentType === "text" ? m(e.$slots, "segment-text", {
319
+ key: 1,
320
+ segment: s,
321
+ layout: t
322
+ }, () => [
323
+ M(I(z), {
324
+ segment: s,
325
+ "track-type": t.track.type || "unknown",
326
+ "accent-color": t.track.color
327
+ }, null, 8, ["segment", "track-type", "accent-color"])
328
+ ], !0) : s.segmentType === "sticker" ? m(e.$slots, "segment-sticker", {
329
+ key: 2,
330
+ segment: s,
331
+ layout: t
332
+ }, () => [
333
+ M(I(z), {
334
+ segment: s,
335
+ "track-type": t.track.type || "unknown",
336
+ "accent-color": t.track.color
337
+ }, null, 8, ["segment", "track-type", "accent-color"])
338
+ ], !0) : s.segmentType === "audio" ? m(e.$slots, "segment-audio", {
339
+ key: 3,
340
+ segment: s,
341
+ layout: t
342
+ }, () => [
343
+ M(I(z), {
344
+ segment: s,
345
+ "track-type": t.track.type || "unknown",
346
+ "accent-color": t.track.color
347
+ }, null, 8, ["segment", "track-type", "accent-color"])
348
+ ], !0) : s.segmentType === "effect" ? m(e.$slots, "segment-effect", {
349
+ key: 4,
350
+ segment: s,
351
+ layout: t
352
+ }, () => [
353
+ M(I(z), {
354
+ segment: s,
355
+ "track-type": t.track.type || "unknown",
356
+ "accent-color": t.track.color
357
+ }, null, 8, ["segment", "track-type", "accent-color"])
358
+ ], !0) : s.segmentType === "filter" ? m(e.$slots, "segment-filter", {
359
+ key: 5,
360
+ segment: s,
361
+ layout: t
362
+ }, () => [
363
+ M(I(z), {
364
+ segment: s,
365
+ "track-type": t.track.type || "unknown",
366
+ "accent-color": t.track.color
367
+ }, null, 8, ["segment", "track-type", "accent-color"])
368
+ ], !0) : F("", !0)
369
+ ])
370
+ ], 4)) : F("", !0)
371
+ ], 64))), 128))
372
+ ]),
373
+ _: 2
374
+ }, [
375
+ e.$slots.toolbar ? {
376
+ name: "toolbar",
377
+ fn: D((t) => [
378
+ m(e.$slots, "toolbar", j(N(t)), void 0, !0)
379
+ ]),
380
+ key: "0"
381
+ } : void 0,
382
+ e.$slots.ruler ? {
383
+ name: "ruler",
384
+ fn: D((t) => [
385
+ m(e.$slots, "ruler", j(N(t)), void 0, !0)
386
+ ]),
387
+ key: "1"
388
+ } : void 0,
389
+ e.$slots.playhead ? {
390
+ name: "playhead",
391
+ fn: D((t) => [
392
+ m(e.$slots, "playhead", j(N(t)), void 0, !0)
393
+ ]),
394
+ key: "2"
395
+ } : void 0
396
+ ]), 1032, ["tracks", "duration", "current-time", "zoom", "fps", "snap-step", "selected-segment-id", "disable-interaction"]));
397
+ }
398
+ }), ze = /* @__PURE__ */ q($e, [["__scopeId", "data-v-2bd14976"]]);
399
+ export {
400
+ ge as F,
401
+ z as S,
402
+ ze as V
403
+ };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { V as i } from "./index-BXF8FAG_.js";
2
- import { F as s, S as d } from "./index-BXF8FAG_.js";
1
+ import { V as i } from "./index-CV2smFQN.js";
2
+ import { F as s, S as d } from "./index-CV2smFQN.js";
3
3
  import { V as o } from "./index-C0eQjJkj.js";
4
4
  const t = {
5
5
  install(e) {
package/dist/ui.css CHANGED
@@ -1 +1 @@
1
- :where(.ve-playhead[data-v-8e647d40]){--ve-playhead-nudge: 0px;--at-apply: absolute z-20 pointer-events-auto cursor-ew-resize h-full;transform:translate(calc(-50% - var(--ve-playhead-nudge)))}:where(.ve-playhead__icon[data-v-8e647d40]){--at-apply: text-[#222226] pointer-events-none relative z-2}:where(.ve-playhead__line[data-v-8e647d40]){--at-apply: bg-[#222226] bottom-0 w-px translate-x--50% left-50% top-2px absolute pointer-events-none}:where(.ve-ruler[data-v-30f91636]){--ve-ruler-major: 8px;--ve-ruler-minor: 4px;--at-apply: sticky top-0 left-0 right-0 bg-white z-3 border-b border-[#e5e7eb] overflow-hidden}:where(.ve-ruler .ve-ruler__ticks[data-v-30f91636]){--at-apply: relative h-full w-full box-border}:where(.ve-ruler .ve-ruler__tick[data-v-30f91636]){--at-apply: absolute top-0 h-full text-center text-[#6b7280] text-[11px]}:where(.ve-ruler .ve-ruler__line[data-v-30f91636]){--at-apply: h-[var(--ve-ruler-minor)] w-px mx-auto bg-[#cbd5e1]}:where(.ve-ruler .ve-ruler__tick--major .ve-ruler__line[data-v-30f91636]){--at-apply: relative h-[var(--ve-ruler-major)] bg-[#94a3b8]}:where(.ve-ruler .ve-ruler__label[data-v-30f91636]){--at-apply: absolute font-mono text-right whitespace-nowrap left-4px bottom-0;transform:translateY(-50%)}:where(.ve-toolbar[data-v-85ddeb0f]){--at-apply: flex items-center justify-between gap-2 px-3 py-2.5 border-b border-[#eceff3]}:where(.ve-toolbar .ve-toolbar__group[data-v-85ddeb0f]){--at-apply: inline-flex items-center gap-2}:where(.ve-toolbar .ve-zoom[data-v-85ddeb0f]){--at-apply: min-w-14 text-center text-xs text-[#222226] px-2 py-1 border border-[#e5e7eb] rounded-lg bg-white}:where(.ve-toolbar .ve-btn[data-v-85ddeb0f]){--at-apply: border border-[#d1d5db] bg-white text-[#222226] rounded-lg h-7 w-7 cursor-pointer transition-all duration-150}:where(.ve-toolbar .ve-btn[data-v-85ddeb0f]:disabled){--at-apply: cursor-not-allowed opacity-45}:where(.ve-toolbar .ve-btn[data-v-85ddeb0f]:not(:disabled):hover){--at-apply: border-[#222226] text-[#222226]}:where(.ve-toolbar .ve-toolbar__time[data-v-85ddeb0f]){--at-apply: inline-flex items-center gap-1.5 text-xs font-mono text-[#222226] ml-auto}:where(.ve-toolbar .ve-toolbar__time-divider[data-v-85ddeb0f]){--at-apply: text-[#9ca3af]}.ve-timeline__tracks[data-v-902b9363]{position:relative;z-index:1;padding-bottom:.75rem;display:flex;flex-direction:column;gap:2px;flex:1}.ve-track[data-v-902b9363]{position:relative;background-color:#f8fafc;overflow:hidden}.ve-track--main[data-v-902b9363]{background-color:#f4f4f6}.ve-track--has-selection[data-v-902b9363]{background-color:#f2f2fa!important;box-shadow:inset 0 1px #e4e4fc,inset 0 -1px #e4e4fc}.ve-track__body[data-v-902b9363]{position:relative;height:100%}.ve-segment[data-v-902b9363]{position:absolute;top:0;bottom:0;border-radius:4px;color:#0f172a;cursor:pointer;display:flex;align-items:center;overflow:hidden;transition-duration:.15s}.ve-segment__content[data-v-902b9363]{display:flex;flex-direction:column;gap:.25rem;padding:.375rem .625rem}.ve-segment__title[data-v-902b9363]{font-size:12px;font-weight:700;text-transform:capitalize}.ve-segment__time[data-v-902b9363]{font-size:11px;color:#0f172acc;font-family:monospace}.ve-segment__selection[data-v-902b9363]{position:absolute;inset:0;pointer-events:none;z-index:10}.ve-segment__handle[data-v-902b9363]{position:absolute;height:100%;width:4px;background-color:#222226;cursor:ew-resize;pointer-events:auto;border:2px solid #222226}.ve-segment__handle--left[data-v-902b9363]{left:0;top:0;border-radius:.25rem 0 0 .25rem}.ve-segment__handle--right[data-v-902b9363]{right:0;top:0;border-radius:0 .25rem .25rem 0}.ve-segment__handle-dots[data-v-902b9363]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;gap:.125rem;justify-content:center}.ve-segment__handle-dot[data-v-902b9363]{border-radius:9999px;background-color:#fff;width:1px;height:1px}.ve-track__add-button[data-v-902b9363]{position:absolute;top:50%;transform:translateY(-50%);margin-left:.5rem;width:2.5rem;height:2.5rem;border-radius:.5rem;display:flex;align-items:center;justify-content:center;color:#222226;background-color:#f2f2fa;cursor:pointer;transition:background-color .2s;border:1px solid #222226}.ve-track__add-button[data-v-902b9363]:hover{background-color:#e5e5e5}.ve-track__gap-add[data-v-902b9363]{position:absolute;top:0;bottom:0;height:100%;display:flex;align-items:center;justify-content:center;cursor:pointer}.ve-track__gap-add[data-v-902b9363]:hover{background-color:#efefef}.ve-track__gap-add-icon[data-v-902b9363]{display:none;color:#fff;background-color:#222226;padding:4px;border-radius:4px}.ve-track__gap-add:hover .ve-track__gap-add-icon[data-v-902b9363]{display:block}:where(.ve-timeline[data-v-4e3078d5]){--ve-primary: #222226;--at-apply: flex flex-col w-full max-w-full min-w-0 rounded-10px h-full}:where(.ve-timeline .ve-timeline__viewport[data-v-4e3078d5]){--at-apply: relative overflow-auto w-full flex-1 bg-white}:where(.ve-timeline .ve-timeline__content[data-v-4e3078d5]){--at-apply: min-h-full min-w-full}:where(.ve-timeline .ve-segment--dragging[data-v-4e3078d5]){--at-apply: absolute z-50 rounded-[4px] text-[#0f172a] cursor-pointer flex items-center overflow-hidden pointer-events-none;box-shadow:0 4px 16px #0000004d,inset 0 0 0 2px #ffffff80}:where(.ve-timeline .ve-segment--preview[data-v-4e3078d5]){--at-apply: absolute z-45 rounded-[4px] pointer-events-none;opacity:.7;box-shadow:0 2px 8px #0003,inset 0 0 0 2px #fff6}:where(.ve-timeline .ve-segment__content[data-v-4e3078d5]){--at-apply: flex flex-col gap-1 px-2.5 py-1.5}:where(.ve-timeline .ve-segment__title[data-v-4e3078d5]){--at-apply: text-[12px] font-bold capitalize}:where(.ve-timeline .ve-segment__time[data-v-4e3078d5]){--at-apply: text-[11px] text-[rgba(15,23,42,.8)] font-mono}:where(.ve-timeline .ve-segment--placeholder[data-v-4e3078d5]){--at-apply: absolute pointer-events-none rounded-[4px] z-24;background:#2222261f;border:2px solid rgba(34,34,38,.6)}:where(.ve-timeline .ve-segment--placeholder-inner[data-v-4e3078d5]){--at-apply: absolute inset-0 rounded-[2px];opacity:.2}:where(.ve-timeline .ve-snap-guide[data-v-4e3078d5]){--at-apply: absolute pointer-events-none z-20;width:1px;background:var(--ve-primary);opacity:.7}:where(.ve-timeline .ve-new-track-line[data-v-4e3078d5]){--at-apply: absolute pointer-events-none z-25;height:1px;background:var(--ve-primary);opacity:.8}:where(.frames-segment[data-v-6262f36a]){--at-apply: relative flex items-stretch w-full h-full overflow-hidden rounded-4px}:where(.frames-segment .frames-segment__image[data-v-6262f36a]){--at-apply: flex w-full h-full overflow-hidden rounded-4px;background-color:color-mix(in srgb,var(--ve-segment-accent, #222226) 15%,transparent)}:where(.frames-segment .frames-segment__image-item[data-v-6262f36a]){--at-apply: flex-shrink-0 w-14 h-full bg-cover bg-left-center bg-no-repeat}:where(.frames-segment .frames-segment__video[data-v-6262f36a]){--at-apply: flex items-center w-full h-full overflow-hidden;background:#f1f5f9}:where(.frames-segment .frames-segment__thumb[data-v-6262f36a]){--at-apply: flex-1 min-w-14;aspect-ratio:1 / 1;background-size:cover;background-position:center}:where(.frames-segment .frames-segment__placeholder[data-v-6262f36a]){--at-apply: flex items-center justify-center w-full h-full text-[12px] rounded-4px whitespace-nowrap;color:#0f172abf;background:#0000000d}:where(.frames-segment .frames-segment__badge[data-v-6262f36a]){--at-apply: absolute top-1.5 left-2 px-1.5 py-0.5 text-[11px] rounded-4px pointer-events-none;background:#00000040;color:#fff;transform-origin:left top;transform:scale(.9)}:where(.segment-base[data-v-d386af72]){--at-apply: relative flex items-center w-full h-full p-1.5 rounded-4px;background:#ffffff52;box-shadow:inset 0 0 0 1px #fff3}:where(.segment-base .segment-base__content[data-v-d386af72]){--at-apply: flex items-center justify-start gap-1.5 w-full}:where(.segment-base .segment-base__pill[data-v-d386af72]){--at-apply: inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-full text-[11px] font-semibold whitespace-nowrap;box-shadow:inset 0 0 0 1px #ffffff4d}:where(.segment-base .segment-base__pill--primary[data-v-d386af72]){color:var(--ve-segment-accent, #222226);background:#22222614}:where(.segment-base .segment-base__pill--muted[data-v-d386af72]){color:#0f172ab3;background:#2222260d}:where(.segment-base .segment-base__badge[data-v-d386af72]){--at-apply: absolute top-1.5 left-2 px-1.5 py-0.5 text-[11px] rounded-4px pointer-events-none;background:#00000040;color:#fff;transform-origin:left top;transform:scale(.9)}:where(.ve-editor-segment[data-v-2bd14976]){--at-apply: relative flex flex-col gap-1.5 w-full h-full text-[#0f172a]}:where(.ve-editor-segment .ve-editor-segment__preview[data-v-2bd14976]){--at-apply: flex items-stretch w-full min-h-14}
1
+ :where(.ve-playhead[data-v-8e647d40]){--ve-playhead-nudge: 0px;--at-apply: absolute z-20 pointer-events-auto cursor-ew-resize h-full;transform:translate(calc(-50% - var(--ve-playhead-nudge)))}:where(.ve-playhead__icon[data-v-8e647d40]){--at-apply: text-[#222226] pointer-events-none relative z-2}:where(.ve-playhead__line[data-v-8e647d40]){--at-apply: bg-[#222226] bottom-0 w-px translate-x--50% left-50% top-2px absolute pointer-events-none}:where(.ve-ruler[data-v-30f91636]){--ve-ruler-major: 8px;--ve-ruler-minor: 4px;--at-apply: sticky top-0 left-0 right-0 bg-white z-3 border-b border-[#e5e7eb] overflow-hidden}:where(.ve-ruler .ve-ruler__ticks[data-v-30f91636]){--at-apply: relative h-full w-full box-border}:where(.ve-ruler .ve-ruler__tick[data-v-30f91636]){--at-apply: absolute top-0 h-full text-center text-[#6b7280] text-[11px]}:where(.ve-ruler .ve-ruler__line[data-v-30f91636]){--at-apply: h-[var(--ve-ruler-minor)] w-px mx-auto bg-[#cbd5e1]}:where(.ve-ruler .ve-ruler__tick--major .ve-ruler__line[data-v-30f91636]){--at-apply: relative h-[var(--ve-ruler-major)] bg-[#94a3b8]}:where(.ve-ruler .ve-ruler__label[data-v-30f91636]){--at-apply: absolute font-mono text-right whitespace-nowrap left-4px bottom-0;transform:translateY(-50%)}:where(.ve-toolbar[data-v-85ddeb0f]){--at-apply: flex items-center justify-between gap-2 px-3 py-2.5 border-b border-[#eceff3]}:where(.ve-toolbar .ve-toolbar__group[data-v-85ddeb0f]){--at-apply: inline-flex items-center gap-2}:where(.ve-toolbar .ve-zoom[data-v-85ddeb0f]){--at-apply: min-w-14 text-center text-xs text-[#222226] px-2 py-1 border border-[#e5e7eb] rounded-lg bg-white}:where(.ve-toolbar .ve-btn[data-v-85ddeb0f]){--at-apply: border border-[#d1d5db] bg-white text-[#222226] rounded-lg h-7 w-7 cursor-pointer transition-all duration-150}:where(.ve-toolbar .ve-btn[data-v-85ddeb0f]:disabled){--at-apply: cursor-not-allowed opacity-45}:where(.ve-toolbar .ve-btn[data-v-85ddeb0f]:not(:disabled):hover){--at-apply: border-[#222226] text-[#222226]}:where(.ve-toolbar .ve-toolbar__time[data-v-85ddeb0f]){--at-apply: inline-flex items-center gap-1.5 text-xs font-mono text-[#222226] ml-auto}:where(.ve-toolbar .ve-toolbar__time-divider[data-v-85ddeb0f]){--at-apply: text-[#9ca3af]}.ve-timeline__tracks[data-v-902b9363]{position:relative;z-index:1;padding-bottom:.75rem;display:flex;flex-direction:column;gap:2px;flex:1}.ve-track[data-v-902b9363]{position:relative;background-color:#f8fafc;overflow:hidden}.ve-track--main[data-v-902b9363]{background-color:#f4f4f6}.ve-track--has-selection[data-v-902b9363]{background-color:#f2f2fa!important;box-shadow:inset 0 1px #e4e4fc,inset 0 -1px #e4e4fc}.ve-track__body[data-v-902b9363]{position:relative;height:100%}.ve-segment[data-v-902b9363]{position:absolute;top:0;bottom:0;border-radius:4px;color:#0f172a;cursor:pointer;display:flex;align-items:center;overflow:hidden;transition-duration:.15s}.ve-segment__content[data-v-902b9363]{display:flex;flex-direction:column;gap:.25rem;padding:.375rem .625rem}.ve-segment__title[data-v-902b9363]{font-size:12px;font-weight:700;text-transform:capitalize}.ve-segment__time[data-v-902b9363]{font-size:11px;color:#0f172acc;font-family:monospace}.ve-segment__selection[data-v-902b9363]{position:absolute;inset:0;pointer-events:none;z-index:10}.ve-segment__handle[data-v-902b9363]{position:absolute;height:100%;width:4px;background-color:#222226;cursor:ew-resize;pointer-events:auto;border:2px solid #222226}.ve-segment__handle--left[data-v-902b9363]{left:0;top:0;border-radius:.25rem 0 0 .25rem}.ve-segment__handle--right[data-v-902b9363]{right:0;top:0;border-radius:0 .25rem .25rem 0}.ve-segment__handle-dots[data-v-902b9363]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;gap:.125rem;justify-content:center}.ve-segment__handle-dot[data-v-902b9363]{border-radius:9999px;background-color:#fff;width:1px;height:1px}.ve-track__add-button[data-v-902b9363]{position:absolute;top:50%;transform:translateY(-50%);margin-left:.5rem;width:2.5rem;height:2.5rem;border-radius:.5rem;display:flex;align-items:center;justify-content:center;color:#222226;background-color:#f2f2fa;cursor:pointer;transition:background-color .2s;border:1px solid #222226}.ve-track__add-button[data-v-902b9363]:hover{background-color:#e5e5e5}.ve-track__gap-add[data-v-902b9363]{position:absolute;top:0;bottom:0;height:100%;display:flex;align-items:center;justify-content:center;cursor:pointer}.ve-track__gap-add[data-v-902b9363]:hover{background-color:#efefef}.ve-track__gap-add-icon[data-v-902b9363]{display:none;color:#fff;background-color:#222226;padding:4px;border-radius:4px}.ve-track__gap-add:hover .ve-track__gap-add-icon[data-v-902b9363]{display:block}:where(.ve-timeline[data-v-4e3078d5]){--ve-primary: #222226;--at-apply: flex flex-col w-full max-w-full min-w-0 rounded-10px h-full}:where(.ve-timeline .ve-timeline__viewport[data-v-4e3078d5]){--at-apply: relative overflow-auto w-full flex-1 bg-white}:where(.ve-timeline .ve-timeline__content[data-v-4e3078d5]){--at-apply: min-h-full min-w-full}:where(.ve-timeline .ve-segment--dragging[data-v-4e3078d5]){--at-apply: absolute z-50 rounded-[4px] text-[#0f172a] cursor-pointer flex items-center overflow-hidden pointer-events-none;box-shadow:0 4px 16px #0000004d,inset 0 0 0 2px #ffffff80}:where(.ve-timeline .ve-segment--preview[data-v-4e3078d5]){--at-apply: absolute z-45 rounded-[4px] pointer-events-none;opacity:.7;box-shadow:0 2px 8px #0003,inset 0 0 0 2px #fff6}:where(.ve-timeline .ve-segment__content[data-v-4e3078d5]){--at-apply: flex flex-col gap-1 px-2.5 py-1.5}:where(.ve-timeline .ve-segment__title[data-v-4e3078d5]){--at-apply: text-[12px] font-bold capitalize}:where(.ve-timeline .ve-segment__time[data-v-4e3078d5]){--at-apply: text-[11px] text-[rgba(15,23,42,.8)] font-mono}:where(.ve-timeline .ve-segment--placeholder[data-v-4e3078d5]){--at-apply: absolute pointer-events-none rounded-[4px] z-24;background:#2222261f;border:2px solid rgba(34,34,38,.6)}:where(.ve-timeline .ve-segment--placeholder-inner[data-v-4e3078d5]){--at-apply: absolute inset-0 rounded-[2px];opacity:.2}:where(.ve-timeline .ve-snap-guide[data-v-4e3078d5]){--at-apply: absolute pointer-events-none z-20;width:1px;background:var(--ve-primary);opacity:.7}:where(.ve-timeline .ve-new-track-line[data-v-4e3078d5]){--at-apply: absolute pointer-events-none z-25;height:1px;background:var(--ve-primary);opacity:.8}:where(.frames-segment[data-v-d630c479]){--at-apply: relative flex items-stretch w-full h-full overflow-hidden rounded-4px}:where(.frames-segment .frames-segment__image[data-v-d630c479]){--at-apply: flex w-full h-full overflow-hidden rounded-4px;background-color:color-mix(in srgb,var(--ve-segment-accent, #222226) 15%,transparent)}:where(.frames-segment .frames-segment__image-item[data-v-d630c479]){--at-apply: flex-shrink-0 w-14 h-full bg-cover bg-left-center bg-no-repeat}:where(.frames-segment .frames-segment__video[data-v-d630c479]){--at-apply: flex items-center w-full h-full overflow-hidden;background:#f1f5f9}:where(.frames-segment .frames-segment__thumb[data-v-d630c479]){--at-apply: flex-1 min-w-14;aspect-ratio:1 / 1;background-size:cover;background-position:center}:where(.frames-segment .frames-segment__placeholder[data-v-d630c479]){--at-apply: flex items-center justify-center w-full h-full text-[12px] rounded-4px whitespace-nowrap;color:#0f172abf;background:#0000000d}:where(.frames-segment .frames-segment__badge[data-v-d630c479]){--at-apply: absolute top-1.5 left-2 px-1.5 py-0.5 text-[11px] rounded-4px pointer-events-none;background:#00000040;color:#fff;transform-origin:left top;transform:scale(.9)}:where(.segment-base[data-v-d386af72]){--at-apply: relative flex items-center w-full h-full p-1.5 rounded-4px;background:#ffffff52;box-shadow:inset 0 0 0 1px #fff3}:where(.segment-base .segment-base__content[data-v-d386af72]){--at-apply: flex items-center justify-start gap-1.5 w-full}:where(.segment-base .segment-base__pill[data-v-d386af72]){--at-apply: inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-full text-[11px] font-semibold whitespace-nowrap;box-shadow:inset 0 0 0 1px #ffffff4d}:where(.segment-base .segment-base__pill--primary[data-v-d386af72]){color:var(--ve-segment-accent, #222226);background:#22222614}:where(.segment-base .segment-base__pill--muted[data-v-d386af72]){color:#0f172ab3;background:#2222260d}:where(.segment-base .segment-base__badge[data-v-d386af72]){--at-apply: absolute top-1.5 left-2 px-1.5 py-0.5 text-[11px] rounded-4px pointer-events-none;background:#00000040;color:#fff;transform-origin:left top;transform:scale(.9)}:where(.ve-editor-segment[data-v-2bd14976]){--at-apply: relative flex flex-col gap-1.5 w-full h-full text-[#0f172a]}:where(.ve-editor-segment .ve-editor-segment__preview[data-v-2bd14976]){--at-apply: flex items-stretch w-full min-h-14}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@video-editor/ui",
3
3
  "type": "module",
4
- "version": "0.0.1-beta.25",
4
+ "version": "0.0.1-beta.26",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "vue": "^3.5.26"
21
21
  },
22
22
  "dependencies": {
23
- "@video-editor/protocol": "0.0.1-beta.25",
24
- "@video-editor/shared": "0.0.1-beta.25"
23
+ "@video-editor/protocol": "0.0.1-beta.26",
24
+ "@video-editor/shared": "0.0.1-beta.26"
25
25
  },
26
26
  "scripts": {
27
27
  "build": "vite build",
@@ -1,393 +0,0 @@
1
- import { defineComponent as J, ref as j, onMounted as x, onBeforeUnmount as ee, reactive as Y, watch as q, createElementBlock as g, openBlock as u, renderSlot as m, normalizeStyle as D, createElementVNode as p, Fragment as w, renderList as N, toDisplayString as E, createCommentVNode as B, computed as U, watchEffect as te, createBlock as ne, createSlots as se, withCtx as V, createVNode as S, unref as $, normalizeProps as L, guardReactiveProps as A } from "vue";
2
- import { generateThumbnails as re, getMp4Meta as oe } from "@video-editor/protocol";
3
- import { isVideoFramesSegment as P, isAudioSegment as ae } from "@video-editor/shared";
4
- import { _, V as le } from "./index-C0eQjJkj.js";
5
- const ie = { class: "frames-segment" }, ce = { class: "frames-segment__video" }, me = {
6
- key: 1,
7
- class: "frames-segment__placeholder"
8
- }, de = { class: "frames-segment__placeholder" }, ue = {
9
- key: 0,
10
- class: "frames-segment__badge"
11
- }, ge = /* @__PURE__ */ J({
12
- name: "FramesSegment",
13
- __name: "FramesSegment",
14
- props: {
15
- segment: {}
16
- },
17
- setup(o) {
18
- const M = o, i = j(null), d = j(1);
19
- let k = null;
20
- x(() => {
21
- i.value && (k = new ResizeObserver((r) => {
22
- for (const a of r) {
23
- const l = Math.max(1, Math.ceil(a.contentRect.width / 56));
24
- d.value !== l && (d.value = l);
25
- }
26
- }), k.observe(i.value));
27
- }), ee(() => {
28
- k?.disconnect(), C();
29
- });
30
- const c = Y({ items: [], loading: !1, error: null });
31
- let T = 0;
32
- q(() => M.segment, (r, a) => {
33
- if (!P(r))
34
- return;
35
- (!a || I(a, r)) && R(r);
36
- }, { immediate: !0, deep: !0 });
37
- function I(r, a) {
38
- return r.url !== a.url || r.startTime !== a.startTime || r.endTime !== a.endTime || r.fromTime !== a.fromTime;
39
- }
40
- async function R(r) {
41
- if (!r.url)
42
- return;
43
- const a = ++T;
44
- C(), c.loading = !0, c.error = null;
45
- try {
46
- const l = F(r), h = await re(r.url, l);
47
- if (T !== a)
48
- return;
49
- const y = h.map((b) => ({
50
- tsMs: Math.round(b.ts / 1e3),
51
- url: URL.createObjectURL(b.img)
52
- }));
53
- c.items = y, c.loading = !1;
54
- } catch (l) {
55
- if (T !== a)
56
- return;
57
- c.error = l instanceof Error ? l.message : String(l), c.loading = !1;
58
- }
59
- }
60
- function F(r) {
61
- const a = Math.max(r.fromTime ?? 0, 0) * 1e3, l = Math.max(r.endTime - r.startTime, 1), h = a + l * 1e3, b = Math.max(Math.floor((h - a) / 8), 2e5);
62
- return { start: a, end: h, step: b };
63
- }
64
- function C() {
65
- c.items.forEach((r) => URL.revokeObjectURL(r.url)), c.items = [];
66
- }
67
- return (r, a) => (u(), g("div", ie, [
68
- o.segment.type === "image" ? m(r.$slots, "image", {
69
- key: 0,
70
- segment: o.segment,
71
- style: D({ backgroundImage: o.segment.url ? `url(${o.segment.url})` : "" })
72
- }, () => [
73
- p("div", {
74
- ref_key: "containerRef",
75
- ref: i,
76
- class: "frames-segment__image"
77
- }, [
78
- (u(!0), g(w, null, N(d.value, (l) => (u(), g("div", {
79
- key: l,
80
- class: "frames-segment__image-item",
81
- style: D({ backgroundImage: o.segment.url ? `url(${o.segment.url})` : "" })
82
- }, null, 4))), 128))
83
- ], 512)
84
- ], !0) : o.segment.type === "video" ? (u(), g(w, { key: 1 }, [
85
- c.items.length ? m(r.$slots, "video", {
86
- key: 0,
87
- segment: o.segment,
88
- thumbnails: c.items
89
- }, () => [
90
- p("div", ce, [
91
- (u(!0), g(w, null, N(c.items, (l) => (u(), g("div", {
92
- key: `${o.segment.id}-${l.tsMs}`,
93
- class: "frames-segment__thumb",
94
- style: D({ backgroundImage: `url(${l.url})` })
95
- }, null, 4))), 128))
96
- ])
97
- ], !0) : (u(), g("div", me, [
98
- c.loading ? m(r.$slots, "loading", {
99
- key: 0,
100
- segment: o.segment
101
- }, () => [
102
- a[0] || (a[0] = p("span", null, "抽帧中…", -1))
103
- ], !0) : c.error ? m(r.$slots, "error", {
104
- key: 1,
105
- segment: o.segment,
106
- error: c.error
107
- }, () => [
108
- a[1] || (a[1] = p("span", null, "生成失败", -1))
109
- ], !0) : m(r.$slots, "empty", {
110
- key: 2,
111
- segment: o.segment
112
- }, () => [
113
- a[2] || (a[2] = p("span", null, "未生成缩略图", -1))
114
- ], !0)
115
- ]))
116
- ], 64)) : m(r.$slots, "fallback", {
117
- key: 2,
118
- segment: o.segment
119
- }, () => [
120
- p("div", de, [
121
- p("span", null, E(o.segment.type), 1)
122
- ])
123
- ], !0),
124
- m(r.$slots, "overlay", { segment: o.segment }, () => [
125
- o.segment.extra?.label ? (u(), g("span", ue, E(o.segment.extra?.label), 1)) : B("", !0)
126
- ], !0)
127
- ]));
128
- }
129
- }), fe = /* @__PURE__ */ _(ge, [["__scopeId", "data-v-6262f36a"]]), pe = { class: "segment-base" }, ke = { class: "segment-base__content" }, ye = { class: "segment-base__pill segment-base__pill--primary" }, Te = { class: "segment-base__pill segment-base__pill--muted" }, he = {
130
- key: 0,
131
- class: "segment-base__badge"
132
- }, be = /* @__PURE__ */ J({
133
- name: "SegmentBase",
134
- __name: "SegmentBase",
135
- props: {
136
- segment: {},
137
- trackType: {},
138
- accentColor: { default: "#222226" }
139
- },
140
- setup(o) {
141
- const M = o, i = U(() => {
142
- const d = M.segment?.extra?.label;
143
- return typeof d == "string" ? d : null;
144
- });
145
- return (d, k) => (u(), g("div", pe, [
146
- p("div", ke, [
147
- p("span", ye, E(o.trackType), 1),
148
- p("span", Te, E(o.segment.segmentType), 1)
149
- ]),
150
- i.value ? (u(), g("span", he, E(i.value), 1)) : B("", !0)
151
- ]));
152
- }
153
- }), z = /* @__PURE__ */ _(be, [["__scopeId", "data-v-d386af72"]]), ve = { class: "ve-editor-segment__preview" }, O = "#222226", Se = 0.4, $e = /* @__PURE__ */ J({
154
- name: "VideoEditorTimeline",
155
- __name: "index",
156
- props: {
157
- protocol: { default: null },
158
- currentTime: {},
159
- zoom: {},
160
- snapStep: { default: 0 },
161
- selectedSegmentId: { default: null },
162
- trackTypes: { default: void 0 },
163
- disableInteraction: { type: Boolean, default: !1 }
164
- },
165
- emits: ["update:currentTime", "update:zoom", "update:selectedSegmentId", "segmentClick", "segmentDragEnd", "segmentResizeEnd", "add-segment"],
166
- setup(o, { emit: M }) {
167
- const i = o, d = M, k = j(i.selectedSegmentId ?? null);
168
- q(() => i.selectedSegmentId, (e) => {
169
- k.value = e ?? null;
170
- });
171
- const c = {
172
- frames: O,
173
- audio: "#0ea5e9",
174
- text: "#16a34a",
175
- sticker: "#f97316",
176
- effect: "#a855f7",
177
- filter: "#64748b"
178
- }, T = U(() => {
179
- if (!i.protocol?.tracks?.length)
180
- return [];
181
- const s = (i.trackTypes?.length ? i.protocol.tracks.filter((n) => i.trackTypes?.includes(n.trackType)) : i.protocol.tracks).slice(), t = s.findIndex((n) => n.trackType === "frames" && n.isMain === !0);
182
- if (t !== -1) {
183
- const [n] = s.splice(t, 1);
184
- s.push(n);
185
- }
186
- return s;
187
- }), I = Y(/* @__PURE__ */ new Map()), R = /* @__PURE__ */ new Map();
188
- function F(e) {
189
- if (!e || I.has(e) || R.has(e))
190
- return;
191
- const s = (async () => {
192
- try {
193
- const t = await oe(e);
194
- I.set(e, t.durationMs);
195
- } catch {
196
- }
197
- })().finally(() => {
198
- R.delete(e);
199
- });
200
- R.set(e, s);
201
- }
202
- const C = U(() => T.value.map((e, s) => {
203
- const t = c[e.trackType] || O, n = a(t, Se), v = e.trackType === "frames" && e.isMain === !0;
204
- return {
205
- id: e.trackId || `${e.trackType}-${s}`,
206
- label: e.trackType,
207
- type: e.trackType,
208
- color: t,
209
- isMain: v,
210
- payload: e,
211
- segments: e.children.map((f) => ({
212
- ...P(f) ? { fromTime: f.fromTime ?? 0, sourceDurationMs: I.get(f.url) } : ae(f) ? { fromTime: f.fromTime ?? 0 } : {},
213
- id: f.id,
214
- start: f.startTime,
215
- end: f.endTime,
216
- type: f.segmentType,
217
- color: n,
218
- payload: f
219
- }))
220
- };
221
- }));
222
- te(() => {
223
- for (const e of T.value)
224
- for (const s of e.children)
225
- P(s) && F(s.url);
226
- });
227
- const r = U(() => {
228
- if (!i.protocol?.tracks?.length)
229
- return 0;
230
- const e = i.protocol.tracks.flatMap((s) => s.children.map((t) => t.endTime));
231
- return e.length ? Math.max(...e) : 0;
232
- });
233
- function a(e, s) {
234
- const t = e.replace("#", "");
235
- if (!(t.length === 3 || t.length === 6))
236
- return e;
237
- const n = t.length === 3 ? t.split("").map((H) => H + H).join("") : t, v = Number.parseInt(n.slice(0, 2), 16), f = Number.parseInt(n.slice(2, 4), 16), Z = Number.parseInt(n.slice(4, 6), 16);
238
- return `rgba(${v}, ${f}, ${Z}, ${s})`;
239
- }
240
- function l(e) {
241
- return e && typeof e == "object" && "segmentType" in e ? e : null;
242
- }
243
- function h(e) {
244
- const s = e.payload;
245
- if (s)
246
- return s;
247
- if (i.protocol)
248
- return i.protocol.tracks.find((t) => t.trackId === e.id);
249
- }
250
- function y(e) {
251
- k.value = e, d("update:selectedSegmentId", e);
252
- }
253
- function b(e) {
254
- const s = l(e.segment.payload), t = h(e.track);
255
- s && (y(s.id), t && d("segmentClick", { segment: s, track: t }));
256
- }
257
- function G(e) {
258
- y(e.segment.id);
259
- }
260
- function K(e) {
261
- d("segmentDragEnd", e);
262
- }
263
- function Q(e) {
264
- y(e.segment.id);
265
- }
266
- function W(e) {
267
- d("segmentResizeEnd", e);
268
- }
269
- function X({ track: e, startTime: s, endTime: t, event: n }) {
270
- const v = e.payload;
271
- v && d("add-segment", { track: v, startTime: s, endTime: t, event: n });
272
- }
273
- return (e, s) => (u(), ne(le, {
274
- tracks: C.value,
275
- duration: r.value,
276
- "current-time": o.currentTime,
277
- zoom: o.zoom,
278
- fps: o.protocol?.fps || 30,
279
- "snap-step": o.snapStep,
280
- "selected-segment-id": k.value ?? null,
281
- "disable-interaction": o.disableInteraction,
282
- "onUpdate:currentTime": s[0] || (s[0] = (t) => d("update:currentTime", t)),
283
- "onUpdate:zoom": s[1] || (s[1] = (t) => d("update:zoom", t)),
284
- onSegmentClick: b,
285
- onSegmentDragStart: G,
286
- onSegmentDragEnd: K,
287
- onSegmentResizeStart: Q,
288
- onSegmentResizeEnd: W,
289
- onBackgroundClick: s[2] || (s[2] = (t) => y(null)),
290
- onAddSegment: X
291
- }, se({
292
- segment: V(({ layout: t }) => [
293
- (u(!0), g(w, null, N([l(t.segment.payload)], (n) => (u(), g(w, {
294
- key: n?.id || t.segment.id
295
- }, [
296
- n ? (u(), g("div", {
297
- key: 0,
298
- class: "ve-editor-segment",
299
- style: D({ "--ve-segment-accent": t.track.color || O })
300
- }, [
301
- p("div", ve, [
302
- n.segmentType === "frames" ? m(e.$slots, "segment-frames", {
303
- key: 0,
304
- segment: n,
305
- layout: t
306
- }, () => [
307
- S($(fe), { segment: n }, null, 8, ["segment"])
308
- ], !0) : n.segmentType === "text" ? m(e.$slots, "segment-text", {
309
- key: 1,
310
- segment: n,
311
- layout: t
312
- }, () => [
313
- S($(z), {
314
- segment: n,
315
- "track-type": t.track.type || "unknown",
316
- "accent-color": t.track.color
317
- }, null, 8, ["segment", "track-type", "accent-color"])
318
- ], !0) : n.segmentType === "sticker" ? m(e.$slots, "segment-sticker", {
319
- key: 2,
320
- segment: n,
321
- layout: t
322
- }, () => [
323
- S($(z), {
324
- segment: n,
325
- "track-type": t.track.type || "unknown",
326
- "accent-color": t.track.color
327
- }, null, 8, ["segment", "track-type", "accent-color"])
328
- ], !0) : n.segmentType === "audio" ? m(e.$slots, "segment-audio", {
329
- key: 3,
330
- segment: n,
331
- layout: t
332
- }, () => [
333
- S($(z), {
334
- segment: n,
335
- "track-type": t.track.type || "unknown",
336
- "accent-color": t.track.color
337
- }, null, 8, ["segment", "track-type", "accent-color"])
338
- ], !0) : n.segmentType === "effect" ? m(e.$slots, "segment-effect", {
339
- key: 4,
340
- segment: n,
341
- layout: t
342
- }, () => [
343
- S($(z), {
344
- segment: n,
345
- "track-type": t.track.type || "unknown",
346
- "accent-color": t.track.color
347
- }, null, 8, ["segment", "track-type", "accent-color"])
348
- ], !0) : n.segmentType === "filter" ? m(e.$slots, "segment-filter", {
349
- key: 5,
350
- segment: n,
351
- layout: t
352
- }, () => [
353
- S($(z), {
354
- segment: n,
355
- "track-type": t.track.type || "unknown",
356
- "accent-color": t.track.color
357
- }, null, 8, ["segment", "track-type", "accent-color"])
358
- ], !0) : B("", !0)
359
- ])
360
- ], 4)) : B("", !0)
361
- ], 64))), 128))
362
- ]),
363
- _: 2
364
- }, [
365
- e.$slots.toolbar ? {
366
- name: "toolbar",
367
- fn: V((t) => [
368
- m(e.$slots, "toolbar", L(A(t)), void 0, !0)
369
- ]),
370
- key: "0"
371
- } : void 0,
372
- e.$slots.ruler ? {
373
- name: "ruler",
374
- fn: V((t) => [
375
- m(e.$slots, "ruler", L(A(t)), void 0, !0)
376
- ]),
377
- key: "1"
378
- } : void 0,
379
- e.$slots.playhead ? {
380
- name: "playhead",
381
- fn: V((t) => [
382
- m(e.$slots, "playhead", L(A(t)), void 0, !0)
383
- ]),
384
- key: "2"
385
- } : void 0
386
- ]), 1032, ["tracks", "duration", "current-time", "zoom", "fps", "snap-step", "selected-segment-id", "disable-interaction"]));
387
- }
388
- }), we = /* @__PURE__ */ _($e, [["__scopeId", "data-v-2bd14976"]]);
389
- export {
390
- fe as F,
391
- z as S,
392
- we as V
393
- };