@video-editor/ui 0.0.1-beta.22 → 0.0.1-beta.24

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-CzWd59zK.js";
1
+ import { V as a } from "./index-BXF8FAG_.js";
2
2
  import "./index-C0eQjJkj.js";
3
3
  export {
4
4
  a as default
@@ -0,0 +1,393 @@
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
+ };
package/dist/index.d.ts CHANGED
@@ -111,7 +111,9 @@ contentRef: HTMLDivElement;
111
111
  tracksRef: HTMLDivElement;
112
112
  }, HTMLDivElement>;
113
113
 
114
- declare const __VLS_component_3: DefineComponent<__VLS_Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
114
+ declare const __VLS_component_3: DefineComponent<__VLS_Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
115
+ containerRef: HTMLDivElement;
116
+ }, HTMLDivElement>;
115
117
 
116
118
  declare type __VLS_Props = {
117
119
  protocol?: IVideoProtocol | null;
@@ -311,9 +313,6 @@ declare function __VLS_template_3(): {
311
313
  image?(_: {
312
314
  style: {
313
315
  backgroundImage: string;
314
- backgroundRepeat: string;
315
- backgroundSize: string;
316
- backgroundPosition: string;
317
316
  };
318
317
  segment: IImageFramesSegment;
319
318
  }): any;
@@ -341,7 +340,9 @@ declare function __VLS_template_3(): {
341
340
  segment: IFramesSegmentUnion;
342
341
  }): any;
343
342
  };
344
- refs: {};
343
+ refs: {
344
+ containerRef: HTMLDivElement;
345
+ };
345
346
  rootEl: HTMLDivElement;
346
347
  };
347
348
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { V as i } from "./index-CzWd59zK.js";
2
- import { F as s, S as d } from "./index-CzWd59zK.js";
1
+ import { V as i } from "./index-BXF8FAG_.js";
2
+ import { F as s, S as d } from "./index-BXF8FAG_.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-4ab97cd2]){--at-apply: relative flex items-stretch w-full h-full overflow-hidden rounded-4px}:where(.frames-segment .frames-segment__image[data-v-4ab97cd2]){--at-apply: w-full h-full rounded-4px;background-color:color-mix(in srgb,var(--ve-segment-accent, #222226) 15%,transparent)}:where(.frames-segment .frames-segment__video[data-v-4ab97cd2]){--at-apply: flex items-center w-full h-full overflow-hidden;background:#f1f5f9}:where(.frames-segment .frames-segment__thumb[data-v-4ab97cd2]){--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-4ab97cd2]){--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-4ab97cd2]){--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-4366b771]){--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-4366b771]){--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-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}
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.22",
4
+ "version": "0.0.1-beta.24",
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.22",
24
- "@video-editor/shared": "0.0.1-beta.22"
23
+ "@video-editor/shared": "0.0.1-beta.24",
24
+ "@video-editor/protocol": "0.0.1-beta.24"
25
25
  },
26
26
  "scripts": {
27
27
  "build": "vite build",
@@ -1,375 +0,0 @@
1
- import { defineComponent as _, reactive as O, watch as J, onBeforeUnmount as Z, createElementBlock as f, openBlock as u, renderSlot as i, normalizeStyle as C, createElementVNode as g, Fragment as D, renderList as H, toDisplayString as R, createCommentVNode as U, computed as V, ref as x, watchEffect as ee, createBlock as te, createSlots as ne, withCtx as w, createVNode as v, unref as $, normalizeProps as F, guardReactiveProps as L } from "vue";
2
- import { generateThumbnails as re, getMp4Meta as se } from "@video-editor/protocol";
3
- import { isVideoFramesSegment as P, isAudioSegment as oe } from "@video-editor/shared";
4
- import { _ as j, V as ae } from "./index-C0eQjJkj.js";
5
- const le = { class: "frames-segment" }, ie = { class: "frames-segment__video" }, ce = {
6
- key: 1,
7
- class: "frames-segment__placeholder"
8
- }, me = { class: "frames-segment__placeholder" }, de = {
9
- key: 0,
10
- class: "frames-segment__badge"
11
- }, ue = /* @__PURE__ */ _({
12
- name: "FramesSegment",
13
- __name: "FramesSegment",
14
- props: {
15
- segment: {}
16
- },
17
- setup(a) {
18
- const p = a, n = O({ items: [], loading: !1, error: null });
19
- let c = 0;
20
- J(() => p.segment, (r, l) => {
21
- if (!P(r))
22
- return;
23
- (!l || k(l, r)) && B(r);
24
- }, { immediate: !0, deep: !0 }), Z(() => {
25
- y();
26
- });
27
- function k(r, l) {
28
- return r.url !== l.url || r.startTime !== l.startTime || r.endTime !== l.endTime || r.fromTime !== l.fromTime;
29
- }
30
- async function B(r) {
31
- if (!r.url)
32
- return;
33
- const l = ++c;
34
- y(), n.loading = !0, n.error = null;
35
- try {
36
- const m = z(r), b = await re(r.url, m);
37
- if (c !== l)
38
- return;
39
- const I = b.map((h) => ({
40
- tsMs: Math.round(h.ts / 1e3),
41
- url: URL.createObjectURL(h.img)
42
- }));
43
- n.items = I, n.loading = !1;
44
- } catch (m) {
45
- if (c !== l)
46
- return;
47
- n.error = m instanceof Error ? m.message : String(m), n.loading = !1;
48
- }
49
- }
50
- function z(r) {
51
- const l = Math.max(r.fromTime ?? 0, 0) * 1e3, m = Math.max(r.endTime - r.startTime, 1), b = l + m * 1e3, h = Math.max(Math.floor((b - l) / 8), 2e5);
52
- return { start: l, end: b, step: h };
53
- }
54
- function y() {
55
- n.items.forEach((r) => URL.revokeObjectURL(r.url)), n.items = [];
56
- }
57
- function T() {
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 (r, l) => (u(), f("div", le, [
66
- a.segment.type === "image" ? i(r.$slots, "image", {
67
- key: 0,
68
- segment: a.segment,
69
- style: C(T())
70
- }, () => [
71
- g("div", {
72
- class: "frames-segment__image",
73
- style: C(T())
74
- }, null, 4)
75
- ], !0) : a.segment.type === "video" ? (u(), f(D, { key: 1 }, [
76
- n.items.length ? i(r.$slots, "video", {
77
- key: 0,
78
- segment: a.segment,
79
- thumbnails: n.items
80
- }, () => [
81
- g("div", ie, [
82
- (u(!0), f(D, null, H(n.items, (m) => (u(), f("div", {
83
- key: `${a.segment.id}-${m.tsMs}`,
84
- class: "frames-segment__thumb",
85
- style: C({ backgroundImage: `url(${m.url})` })
86
- }, null, 4))), 128))
87
- ])
88
- ], !0) : (u(), f("div", ce, [
89
- n.loading ? i(r.$slots, "loading", {
90
- key: 0,
91
- segment: a.segment
92
- }, () => [
93
- l[0] || (l[0] = g("span", null, "抽帧中…", -1))
94
- ], !0) : n.error ? i(r.$slots, "error", {
95
- key: 1,
96
- segment: a.segment,
97
- error: n.error
98
- }, () => [
99
- l[1] || (l[1] = g("span", null, "生成失败", -1))
100
- ], !0) : i(r.$slots, "empty", {
101
- key: 2,
102
- segment: a.segment
103
- }, () => [
104
- l[2] || (l[2] = g("span", null, "未生成缩略图", -1))
105
- ], !0)
106
- ]))
107
- ], 64)) : i(r.$slots, "fallback", {
108
- key: 2,
109
- segment: a.segment
110
- }, () => [
111
- g("div", me, [
112
- g("span", null, R(a.segment.type), 1)
113
- ])
114
- ], !0),
115
- i(r.$slots, "overlay", { segment: a.segment }, () => [
116
- a.segment.extra?.label ? (u(), f("span", de, R(a.segment.extra?.label), 1)) : U("", !0)
117
- ], !0)
118
- ]));
119
- }
120
- }), ge = /* @__PURE__ */ j(ue, [["__scopeId", "data-v-4ab97cd2"]]), fe = { class: "segment-base" }, pe = { class: "segment-base__content" }, ke = { class: "segment-base__pill segment-base__pill--primary" }, ye = { class: "segment-base__pill segment-base__pill--muted" }, Te = {
121
- key: 0,
122
- class: "segment-base__badge"
123
- }, be = /* @__PURE__ */ _({
124
- name: "SegmentBase",
125
- __name: "SegmentBase",
126
- props: {
127
- segment: {},
128
- trackType: {},
129
- accentColor: { default: "#222226" }
130
- },
131
- setup(a) {
132
- const p = a, n = V(() => {
133
- const c = p.segment?.extra?.label;
134
- return typeof c == "string" ? c : null;
135
- });
136
- return (c, k) => (u(), f("div", fe, [
137
- g("div", pe, [
138
- g("span", ke, R(a.trackType), 1),
139
- g("span", ye, R(a.segment.segmentType), 1)
140
- ]),
141
- n.value ? (u(), f("span", Te, R(n.value), 1)) : U("", !0)
142
- ]));
143
- }
144
- }), M = /* @__PURE__ */ j(be, [["__scopeId", "data-v-d386af72"]]), he = { class: "ve-editor-segment__preview" }, A = "#222226", Se = 0.4, ve = /* @__PURE__ */ _({
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", "add-segment"],
157
- setup(a, { emit: p }) {
158
- const n = a, c = p, k = x(n.selectedSegmentId ?? null);
159
- J(() => n.selectedSegmentId, (e) => {
160
- k.value = e ?? null;
161
- });
162
- const B = {
163
- frames: A,
164
- audio: "#0ea5e9",
165
- text: "#16a34a",
166
- sticker: "#f97316",
167
- effect: "#a855f7",
168
- filter: "#64748b"
169
- }, z = V(() => n.protocol?.tracks?.length ? n.trackTypes?.length ? n.protocol.tracks.filter((e) => n.trackTypes?.includes(e.trackType)) : n.protocol.tracks : []), y = O(/* @__PURE__ */ new Map()), T = /* @__PURE__ */ new Map();
170
- function r(e) {
171
- if (!e || y.has(e) || T.has(e))
172
- return;
173
- const o = (async () => {
174
- try {
175
- const t = await se(e);
176
- y.set(e, t.durationMs);
177
- } catch {
178
- }
179
- })().finally(() => {
180
- T.delete(e);
181
- });
182
- T.set(e, o);
183
- }
184
- const l = V(() => z.value.map((e, o) => {
185
- const t = B[e.trackType] || A, s = b(t, Se), S = e.trackType === "frames" && e.isMain === !0;
186
- return {
187
- id: e.trackId || `${e.trackType}-${o}`,
188
- label: e.trackType,
189
- type: e.trackType,
190
- color: t,
191
- isMain: S,
192
- payload: e,
193
- segments: e.children.map((d) => ({
194
- ...P(d) ? { fromTime: d.fromTime ?? 0, sourceDurationMs: y.get(d.url) } : oe(d) ? { fromTime: d.fromTime ?? 0 } : {},
195
- id: d.id,
196
- start: d.startTime,
197
- end: d.endTime,
198
- type: d.segmentType,
199
- color: s,
200
- payload: d
201
- }))
202
- };
203
- }));
204
- ee(() => {
205
- for (const e of z.value)
206
- for (const o of e.children)
207
- P(o) && r(o.url);
208
- });
209
- const m = V(() => {
210
- if (!n.protocol?.tracks?.length)
211
- return 0;
212
- const e = n.protocol.tracks.flatMap((o) => o.children.map((t) => t.endTime));
213
- return e.length ? Math.max(...e) : 0;
214
- });
215
- function b(e, o) {
216
- const t = e.replace("#", "");
217
- if (!(t.length === 3 || t.length === 6))
218
- return e;
219
- const s = t.length === 3 ? t.split("").map((N) => N + N).join("") : t, S = Number.parseInt(s.slice(0, 2), 16), d = Number.parseInt(s.slice(2, 4), 16), X = Number.parseInt(s.slice(4, 6), 16);
220
- return `rgba(${S}, ${d}, ${X}, ${o})`;
221
- }
222
- function I(e) {
223
- return e && typeof e == "object" && "segmentType" in e ? e : null;
224
- }
225
- function h(e) {
226
- const o = e.payload;
227
- if (o)
228
- return o;
229
- if (n.protocol)
230
- return n.protocol.tracks.find((t) => t.trackId === e.id);
231
- }
232
- function E(e) {
233
- k.value = e, c("update:selectedSegmentId", e);
234
- }
235
- function Y(e) {
236
- const o = I(e.segment.payload), t = h(e.track);
237
- o && (E(o.id), t && c("segmentClick", { segment: o, track: t }));
238
- }
239
- function q(e) {
240
- E(e.segment.id);
241
- }
242
- function G(e) {
243
- c("segmentDragEnd", e);
244
- }
245
- function K(e) {
246
- E(e.segment.id);
247
- }
248
- function Q(e) {
249
- c("segmentResizeEnd", e);
250
- }
251
- function W({ track: e, startTime: o, endTime: t, event: s }) {
252
- const S = e.payload;
253
- S && c("add-segment", { track: S, startTime: o, endTime: t, event: s });
254
- }
255
- return (e, o) => (u(), te(ae, {
256
- tracks: l.value,
257
- duration: m.value,
258
- "current-time": a.currentTime,
259
- zoom: a.zoom,
260
- fps: a.protocol?.fps || 30,
261
- "snap-step": a.snapStep,
262
- "selected-segment-id": k.value ?? null,
263
- "disable-interaction": a.disableInteraction,
264
- "onUpdate:currentTime": o[0] || (o[0] = (t) => c("update:currentTime", t)),
265
- "onUpdate:zoom": o[1] || (o[1] = (t) => c("update:zoom", t)),
266
- onSegmentClick: Y,
267
- onSegmentDragStart: q,
268
- onSegmentDragEnd: G,
269
- onSegmentResizeStart: K,
270
- onSegmentResizeEnd: Q,
271
- onBackgroundClick: o[2] || (o[2] = (t) => E(null)),
272
- onAddSegment: W
273
- }, ne({
274
- segment: w(({ layout: t }) => [
275
- (u(!0), f(D, null, H([I(t.segment.payload)], (s) => (u(), f(D, {
276
- key: s?.id || t.segment.id
277
- }, [
278
- s ? (u(), f("div", {
279
- key: 0,
280
- class: "ve-editor-segment",
281
- style: C({ "--ve-segment-accent": t.track.color || A })
282
- }, [
283
- g("div", he, [
284
- s.segmentType === "frames" ? i(e.$slots, "segment-frames", {
285
- key: 0,
286
- segment: s,
287
- layout: t
288
- }, () => [
289
- v($(ge), { segment: s }, null, 8, ["segment"])
290
- ], !0) : s.segmentType === "text" ? i(e.$slots, "segment-text", {
291
- key: 1,
292
- segment: s,
293
- layout: t
294
- }, () => [
295
- v($(M), {
296
- segment: s,
297
- "track-type": t.track.type || "unknown",
298
- "accent-color": t.track.color
299
- }, null, 8, ["segment", "track-type", "accent-color"])
300
- ], !0) : s.segmentType === "sticker" ? i(e.$slots, "segment-sticker", {
301
- key: 2,
302
- segment: s,
303
- layout: t
304
- }, () => [
305
- v($(M), {
306
- segment: s,
307
- "track-type": t.track.type || "unknown",
308
- "accent-color": t.track.color
309
- }, null, 8, ["segment", "track-type", "accent-color"])
310
- ], !0) : s.segmentType === "audio" ? i(e.$slots, "segment-audio", {
311
- key: 3,
312
- segment: s,
313
- layout: t
314
- }, () => [
315
- v($(M), {
316
- segment: s,
317
- "track-type": t.track.type || "unknown",
318
- "accent-color": t.track.color
319
- }, null, 8, ["segment", "track-type", "accent-color"])
320
- ], !0) : s.segmentType === "effect" ? i(e.$slots, "segment-effect", {
321
- key: 4,
322
- segment: s,
323
- layout: t
324
- }, () => [
325
- v($(M), {
326
- segment: s,
327
- "track-type": t.track.type || "unknown",
328
- "accent-color": t.track.color
329
- }, null, 8, ["segment", "track-type", "accent-color"])
330
- ], !0) : s.segmentType === "filter" ? i(e.$slots, "segment-filter", {
331
- key: 5,
332
- segment: s,
333
- layout: t
334
- }, () => [
335
- v($(M), {
336
- segment: s,
337
- "track-type": t.track.type || "unknown",
338
- "accent-color": t.track.color
339
- }, null, 8, ["segment", "track-type", "accent-color"])
340
- ], !0) : U("", !0)
341
- ])
342
- ], 4)) : U("", !0)
343
- ], 64))), 128))
344
- ]),
345
- _: 2
346
- }, [
347
- e.$slots.toolbar ? {
348
- name: "toolbar",
349
- fn: w((t) => [
350
- i(e.$slots, "toolbar", F(L(t)), void 0, !0)
351
- ]),
352
- key: "0"
353
- } : void 0,
354
- e.$slots.ruler ? {
355
- name: "ruler",
356
- fn: w((t) => [
357
- i(e.$slots, "ruler", F(L(t)), void 0, !0)
358
- ]),
359
- key: "1"
360
- } : void 0,
361
- e.$slots.playhead ? {
362
- name: "playhead",
363
- fn: w((t) => [
364
- i(e.$slots, "playhead", F(L(t)), void 0, !0)
365
- ]),
366
- key: "2"
367
- } : void 0
368
- ]), 1032, ["tracks", "duration", "current-time", "zoom", "fps", "snap-step", "selected-segment-id", "disable-interaction"]));
369
- }
370
- }), ze = /* @__PURE__ */ j(ve, [["__scopeId", "data-v-4366b771"]]);
371
- export {
372
- ge as F,
373
- M as S,
374
- ze as V
375
- };