@video-editor/ui 0.0.1-beta.13 → 0.0.1-beta.15

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