@vivix-labs/media-tools 1.0.0-beta → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -9
- package/dist/assets/copy-document-EF4PHM7F.svg +10 -0
- package/dist/assets/crop-5JXWHIPN.svg +6 -0
- package/dist/assets/delete-4Y3OUMEL.svg +8 -0
- package/dist/assets/detail-E52XPONK.svg +4 -0
- package/dist/assets/download-VTKCEAZG.svg +6 -0
- package/dist/assets/edit-JUVJDD5A.svg +6 -0
- package/dist/assets/export-W2OBXZDQ.svg +6 -0
- package/dist/assets/favorite-6GMNHJCN.svg +5 -0
- package/dist/assets/favorite-filled-FR74TEBM.svg +3 -0
- package/dist/assets/filter-JSDZZVGN.svg +5 -0
- package/dist/assets/fullscreen-large-MPLIWDMI.svg +6 -0
- package/dist/assets/inria-serif-latin-400-italic-ZCFRMMVP.woff2 +0 -0
- package/dist/assets/inria-serif-latin-700-italic-UNRIXGAH.woff2 +0 -0
- package/dist/assets/inter-latin-700-normal-SU5XVJMF.woff2 +0 -0
- package/dist/assets/inter-latin-900-normal-FKACR3DR.woff2 +0 -0
- package/dist/assets/mute-large-LSZZ44HF.svg +6 -0
- package/dist/assets/pause-large-XEUBL4KC.svg +6 -0
- package/dist/assets/placeholder-audio-EJEBE7OB.svg +11 -0
- package/dist/assets/placeholder-image-NOVXFVRL.svg +10 -0
- package/dist/assets/placeholder-script-LR2GKWKS.svg +7 -0
- package/dist/assets/placeholder-video-ZFOYHYCR.svg +7 -0
- package/dist/assets/play-cover-WQLOHHPZ.svg +5 -0
- package/dist/assets/playback-play-YRMIX5W4.svg +5 -0
- package/dist/assets/playback-play-large-TM3QUJGG.svg +5 -0
- package/dist/assets/refresh-WQ3CTB57.svg +3 -0
- package/dist/assets/select-items-GJZIVO37.svg +6 -0
- package/dist/assets/trim-LQMHHN2M.svg +9 -0
- package/dist/assets/upload-U5RZT5QI.svg +5 -0
- package/dist/assets/volume-large-QNULSJ2I.svg +6 -0
- package/dist/client.bundle.js +1356 -229
- package/dist/client.css +1585 -138
- package/dist/client.d.ts +1 -0
- package/dist/server.d.ts +2 -1
- package/dist/server.js +182 -41
- package/dist/shared.d.ts +155 -2
- package/dist/shared.js +60 -0
- package/package.json +2 -2
package/dist/client.bundle.js
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
// packages/media-tools/src/client.tsx
|
|
2
|
-
import * as
|
|
2
|
+
import * as React8 from "react";
|
|
3
|
+
|
|
4
|
+
// packages/media-tools/src/export-settings.ts
|
|
5
|
+
var exportProfiles = {
|
|
6
|
+
h264: {
|
|
7
|
+
label: "MP4 \xB7 H.264",
|
|
8
|
+
extension: "mp4",
|
|
9
|
+
container: "mp4",
|
|
10
|
+
codec: "h264",
|
|
11
|
+
encoder: "libx264",
|
|
12
|
+
audio: "aac",
|
|
13
|
+
crf: [18, 23, 28]
|
|
14
|
+
},
|
|
15
|
+
hevc: {
|
|
16
|
+
label: "MP4 \xB7 H.265",
|
|
17
|
+
extension: "mp4",
|
|
18
|
+
container: "mp4",
|
|
19
|
+
codec: "hevc",
|
|
20
|
+
encoder: "libx265",
|
|
21
|
+
audio: "aac",
|
|
22
|
+
crf: [20, 25, 30]
|
|
23
|
+
},
|
|
24
|
+
vp9: {
|
|
25
|
+
label: "WebM \xB7 VP9",
|
|
26
|
+
extension: "webm",
|
|
27
|
+
container: "webm",
|
|
28
|
+
codec: "vp9",
|
|
29
|
+
encoder: "libvpx-vp9",
|
|
30
|
+
audio: "opus",
|
|
31
|
+
crf: [23, 31, 39]
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var exportAspects = ["source", "16:9", "9:16", "1:1", "4:3", "3:4", "21:9"];
|
|
35
|
+
var exportResolutions = [480, 720, 1080, 2160];
|
|
36
|
+
var exportRates = [24, 25, 30, 50, 60];
|
|
37
|
+
var exportQualities = ["high", "standard", "small"];
|
|
38
|
+
function exportDimensions(source, aspect, resolution) {
|
|
39
|
+
if (aspect === "source" && resolution === "source") return source;
|
|
40
|
+
const [w = source.width, h = source.height] = aspect === "source" ? [] : aspect.split(":").map(Number);
|
|
41
|
+
const short = resolution === "source" ? Math.min(source.width, source.height) : resolution;
|
|
42
|
+
const even = (n) => 2 * Math.round(n / 2);
|
|
43
|
+
const width = w >= h ? even(short * w / h) : short;
|
|
44
|
+
const height = h >= w ? even(short * h / w) : short;
|
|
45
|
+
return Math.min(width, height) >= 2 && Math.max(width, height) <= 3840 && Math.min(width, height) <= 2160 ? { width, height } : null;
|
|
46
|
+
}
|
|
47
|
+
function exportName(name, extension) {
|
|
48
|
+
return `${name.trim().replace(/\.(mp4|webm)$/i, "").trim()}.${extension}`;
|
|
49
|
+
}
|
|
3
50
|
|
|
4
51
|
// packages/media-tools/src/shared.ts
|
|
5
52
|
import { z, PluginError } from "vivix-studio/sdk/shared";
|
|
@@ -77,10 +124,35 @@ var canvas = z.object({ width: z.number().int().min(2).max(3840), height: z.numb
|
|
|
77
124
|
(v) => v.width % 2 === 0 && v.height % 2 === 0 && Math.min(v.width, v.height) <= 2160,
|
|
78
125
|
"Canvas dimensions must be even and within 3840 by 2160."
|
|
79
126
|
);
|
|
127
|
+
var exportFormat = z.enum(
|
|
128
|
+
Object.keys(exportProfiles)
|
|
129
|
+
);
|
|
130
|
+
var exportSettings = z.object({
|
|
131
|
+
format: exportFormat,
|
|
132
|
+
aspect: z.enum(exportAspects),
|
|
133
|
+
resolution: z.union([
|
|
134
|
+
z.literal("source"),
|
|
135
|
+
z.literal(480),
|
|
136
|
+
z.literal(720),
|
|
137
|
+
z.literal(1080),
|
|
138
|
+
z.literal(2160)
|
|
139
|
+
]),
|
|
140
|
+
frameRate: z.union([
|
|
141
|
+
z.literal("source"),
|
|
142
|
+
z.literal(24),
|
|
143
|
+
z.literal(25),
|
|
144
|
+
z.literal(30),
|
|
145
|
+
z.literal(50),
|
|
146
|
+
z.literal(60)
|
|
147
|
+
]),
|
|
148
|
+
quality: z.enum(exportQualities),
|
|
149
|
+
audio: z.boolean()
|
|
150
|
+
}).strict();
|
|
80
151
|
var processSequence = z.object({
|
|
81
152
|
inputs: z.array(sequenceVideoInput).min(1).max(64),
|
|
82
153
|
outputName,
|
|
83
154
|
canvas,
|
|
155
|
+
settings: exportSettings.optional(),
|
|
84
156
|
retryOfJobId: z.uuid().optional()
|
|
85
157
|
}).strict();
|
|
86
158
|
var mediaRequest = z.discriminatedUnion("operation", [
|
|
@@ -178,8 +250,211 @@ import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
178
250
|
|
|
179
251
|
// packages/ui-system/dist/icon.js
|
|
180
252
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
253
|
+
var iconGeometry = {
|
|
254
|
+
add: {
|
|
255
|
+
width: 16,
|
|
256
|
+
height: 16,
|
|
257
|
+
slot: 16
|
|
258
|
+
},
|
|
259
|
+
check: {
|
|
260
|
+
width: 12,
|
|
261
|
+
height: 12,
|
|
262
|
+
slot: 12
|
|
263
|
+
},
|
|
264
|
+
"check-on-content": {
|
|
265
|
+
width: 12,
|
|
266
|
+
height: 12,
|
|
267
|
+
slot: 12
|
|
268
|
+
},
|
|
269
|
+
"chevron-up": {
|
|
270
|
+
width: 12,
|
|
271
|
+
height: 12,
|
|
272
|
+
slot: 12
|
|
273
|
+
},
|
|
274
|
+
expand: {
|
|
275
|
+
width: 16,
|
|
276
|
+
height: 16,
|
|
277
|
+
slot: 16
|
|
278
|
+
},
|
|
279
|
+
"chevron-down": {
|
|
280
|
+
width: 12,
|
|
281
|
+
height: 12,
|
|
282
|
+
slot: 12
|
|
283
|
+
},
|
|
284
|
+
clear: {
|
|
285
|
+
width: 14.5332,
|
|
286
|
+
height: 14.5332,
|
|
287
|
+
slot: 16
|
|
288
|
+
},
|
|
289
|
+
grid: {
|
|
290
|
+
width: 13.2039,
|
|
291
|
+
height: 13.2,
|
|
292
|
+
slot: 16
|
|
293
|
+
},
|
|
294
|
+
list: {
|
|
295
|
+
width: 13.3372,
|
|
296
|
+
height: 12.0039,
|
|
297
|
+
slot: 16
|
|
298
|
+
},
|
|
299
|
+
search: {
|
|
300
|
+
width: 13.2,
|
|
301
|
+
height: 13.2,
|
|
302
|
+
slot: 16
|
|
303
|
+
},
|
|
304
|
+
calendar: {
|
|
305
|
+
width: 16,
|
|
306
|
+
height: 16,
|
|
307
|
+
slot: 16
|
|
308
|
+
},
|
|
309
|
+
import: {
|
|
310
|
+
width: 16,
|
|
311
|
+
height: 16,
|
|
312
|
+
slot: 16
|
|
313
|
+
},
|
|
314
|
+
magic: {
|
|
315
|
+
width: 14.0625,
|
|
316
|
+
height: 15.5625,
|
|
317
|
+
slot: 18
|
|
318
|
+
},
|
|
319
|
+
"select-items": { width: 13.8681, height: 13.8667, slot: 16 },
|
|
320
|
+
trim: { width: 14.85, height: 14.85, slot: 16 },
|
|
321
|
+
crop: { width: 16.25, height: 16.25, slot: 16 },
|
|
322
|
+
filter: { width: 13.2, height: 13.2, slot: 16 },
|
|
323
|
+
select: {
|
|
324
|
+
width: 14.6298,
|
|
325
|
+
height: 16.065,
|
|
326
|
+
slot: 18
|
|
327
|
+
},
|
|
328
|
+
area: {
|
|
329
|
+
width: 16.125,
|
|
330
|
+
height: 16.125,
|
|
331
|
+
slot: 18
|
|
332
|
+
},
|
|
333
|
+
draw: {
|
|
334
|
+
width: 16.125,
|
|
335
|
+
height: 16.125,
|
|
336
|
+
slot: 18
|
|
337
|
+
},
|
|
338
|
+
close: {
|
|
339
|
+
width: 18,
|
|
340
|
+
height: 18,
|
|
341
|
+
slot: 18
|
|
342
|
+
},
|
|
343
|
+
reset: {
|
|
344
|
+
width: 16.35,
|
|
345
|
+
height: 16.35,
|
|
346
|
+
slot: 18
|
|
347
|
+
},
|
|
348
|
+
more: {
|
|
349
|
+
width: 16,
|
|
350
|
+
height: 16,
|
|
351
|
+
slot: 16
|
|
352
|
+
},
|
|
353
|
+
play: {
|
|
354
|
+
width: 12.381,
|
|
355
|
+
height: 13.2143,
|
|
356
|
+
slot: 20
|
|
357
|
+
},
|
|
358
|
+
pause: {
|
|
359
|
+
width: 14.1905,
|
|
360
|
+
height: 14.1905,
|
|
361
|
+
slot: 20
|
|
362
|
+
},
|
|
363
|
+
mute: {
|
|
364
|
+
width: 17.5239,
|
|
365
|
+
height: 14.1922,
|
|
366
|
+
slot: 20
|
|
367
|
+
},
|
|
368
|
+
volume: {
|
|
369
|
+
width: 17.5239,
|
|
370
|
+
height: 14.1922,
|
|
371
|
+
slot: 20
|
|
372
|
+
},
|
|
373
|
+
fullscreen: {
|
|
374
|
+
width: 20,
|
|
375
|
+
height: 20,
|
|
376
|
+
slot: 20
|
|
377
|
+
},
|
|
378
|
+
"placeholder-image": {
|
|
379
|
+
width: 20,
|
|
380
|
+
height: 20,
|
|
381
|
+
slot: 20
|
|
382
|
+
},
|
|
383
|
+
"placeholder-video": {
|
|
384
|
+
width: 17.9199,
|
|
385
|
+
height: 16.2506,
|
|
386
|
+
slot: 20
|
|
387
|
+
},
|
|
388
|
+
"placeholder-audio": {
|
|
389
|
+
width: 17.5017,
|
|
390
|
+
height: 17.4992,
|
|
391
|
+
slot: 20
|
|
392
|
+
},
|
|
393
|
+
"placeholder-script": {
|
|
394
|
+
width: 17.0834,
|
|
395
|
+
height: 17.0837,
|
|
396
|
+
slot: 20
|
|
397
|
+
},
|
|
398
|
+
export: {
|
|
399
|
+
width: 11.8667,
|
|
400
|
+
height: 13.2,
|
|
401
|
+
slot: 16
|
|
402
|
+
},
|
|
403
|
+
favorite: { width: 11.8667, height: 14.5333, slot: 16 },
|
|
404
|
+
download: { width: 13.2001, height: 13.1997, slot: 16 },
|
|
405
|
+
delete: { width: 13.2, height: 14.533, slot: 16 },
|
|
406
|
+
edit: {
|
|
407
|
+
width: 10.8791,
|
|
408
|
+
height: 12.0459,
|
|
409
|
+
slot: 14
|
|
410
|
+
},
|
|
411
|
+
"play-cover": {
|
|
412
|
+
width: 12.9167,
|
|
413
|
+
height: 13.7501,
|
|
414
|
+
slot: 20
|
|
415
|
+
},
|
|
416
|
+
"playback-play": {
|
|
417
|
+
width: 13.29564,
|
|
418
|
+
height: 14.1905,
|
|
419
|
+
slot: 20
|
|
420
|
+
},
|
|
421
|
+
"playback-play-large": {
|
|
422
|
+
width: 15.95477,
|
|
423
|
+
height: 17.0286,
|
|
424
|
+
slot: 24
|
|
425
|
+
},
|
|
426
|
+
"pause-large": {
|
|
427
|
+
width: 17.0286,
|
|
428
|
+
height: 17.0286,
|
|
429
|
+
slot: 24
|
|
430
|
+
},
|
|
431
|
+
"volume-large": {
|
|
432
|
+
width: 21.02868,
|
|
433
|
+
height: 17.03064,
|
|
434
|
+
slot: 24
|
|
435
|
+
},
|
|
436
|
+
"mute-large": {
|
|
437
|
+
width: 21.0286,
|
|
438
|
+
height: 17.0307,
|
|
439
|
+
slot: 24
|
|
440
|
+
},
|
|
441
|
+
"fullscreen-large": {
|
|
442
|
+
width: 24,
|
|
443
|
+
height: 24,
|
|
444
|
+
slot: 24
|
|
445
|
+
}
|
|
446
|
+
};
|
|
181
447
|
function Icon({ name, size }) {
|
|
182
|
-
|
|
448
|
+
const geometry2 = iconGeometry[name];
|
|
449
|
+
const style = {
|
|
450
|
+
...geometry2 && {
|
|
451
|
+
"--vx-icon-native-size": `${geometry2.slot}px`,
|
|
452
|
+
"--vx-icon-width": `${geometry2.width / geometry2.slot * 100}%`,
|
|
453
|
+
"--vx-icon-height": `${geometry2.height / geometry2.slot * 100}%`
|
|
454
|
+
},
|
|
455
|
+
...size === void 0 ? {} : { "--vx-icon-size": `${size}px` }
|
|
456
|
+
};
|
|
457
|
+
return _jsx("span", { "aria-hidden": "true", className: "vx-icon", "data-icon": name, style });
|
|
183
458
|
}
|
|
184
459
|
|
|
185
460
|
// packages/ui-system/dist/button-variants.js
|
|
@@ -188,6 +463,9 @@ var buttonVariants = {
|
|
|
188
463
|
"text-filled-leading-sm": { size: 32, appearance: "filled", shape: "text" },
|
|
189
464
|
"text-ghost-sm": { size: 32, appearance: "ghost", shape: "text" },
|
|
190
465
|
"text-on-content-sm": { size: 32, appearance: "on-content", shape: "text" },
|
|
466
|
+
"text-plain-sm": { size: 32, appearance: "plain", shape: "text" },
|
|
467
|
+
"text-link-sm": { size: 32, appearance: "link", shape: "text" },
|
|
468
|
+
"text-outline-sm": { size: 32, appearance: "outline", shape: "text" },
|
|
191
469
|
"text-tonal-sm": { size: 32, appearance: "tonal", shape: "text" },
|
|
192
470
|
// The medium recipes are shared by all dialog footer actions.
|
|
193
471
|
"text-filled-md": { size: 40, appearance: "filled", shape: "text" },
|
|
@@ -222,35 +500,181 @@ function ButtonFrame({ label, variant, loading = false, width, children, disable
|
|
|
222
500
|
const buttonStyle = "width" in spec ? { ...style, "--vx-button-width": `${spec.width}px` } : style;
|
|
223
501
|
return _jsxs("button", { ...props, type, className: className ? `vx-button ${className}` : "vx-button", "data-variant": variant, "data-appearance": spec.appearance, "data-shape": spec.shape, "data-size": spec.size, "data-width": width, "data-state": loading ? "loading" : disabled ? "disabled" : "default", style: buttonStyle, disabled: disabled || loading, "aria-label": label, "aria-busy": loading || void 0, children: [_jsx2("span", { className: "vx-button-content", children }), loading && _jsx2("span", { className: "vx-button-loading", "aria-hidden": "true" })] });
|
|
224
502
|
}
|
|
225
|
-
function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, ...props }) {
|
|
226
|
-
return _jsxs(ButtonFrame, { ...props, variant, children: [leadingIcon && _jsx2(Icon, { name: leadingIcon }), _jsx2("span", { className: "vx-button-label", children: props.label }), trailingIcon && _jsx2("span", { className: "vx-button-trailing", children: _jsx2(Icon, { name: trailingIcon }) })] });
|
|
503
|
+
function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, badge, ...props }) {
|
|
504
|
+
return _jsxs(ButtonFrame, { ...props, label: badge ? `${props.label} (${badge})` : props.label, variant, children: [leadingIcon && _jsx2(Icon, { name: leadingIcon }), _jsx2("span", { className: "vx-button-label", children: props.label }), badge !== void 0 && badge > 0 && _jsx2("span", { className: "vx-button-badge", children: badge }), trailingIcon && _jsx2("span", { className: "vx-button-trailing", children: _jsx2(Icon, { name: trailingIcon }) })] });
|
|
227
505
|
}
|
|
228
506
|
function IconButton({ icon, variant = "icon-ghost-sm", ...props }) {
|
|
229
507
|
return _jsx2(ButtonFrame, { ...props, variant, children: _jsx2(Icon, { name: icon }) });
|
|
230
508
|
}
|
|
231
509
|
|
|
232
|
-
// packages/ui-system/dist/
|
|
510
|
+
// packages/ui-system/dist/dropdown.js
|
|
233
511
|
import { jsx as _jsx3, jsxs as _jsxs2 } from "react/jsx-runtime";
|
|
234
|
-
import { useId } from "react";
|
|
235
|
-
function
|
|
512
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
513
|
+
function optionIcon(icon) {
|
|
514
|
+
return typeof icon === "string" ? _jsx3(Icon, { name: icon }) : icon;
|
|
515
|
+
}
|
|
516
|
+
function Dropdown({ label, options, value, onValueChange, placeholder = "Select an option", size = "medium", width = "fixed", appearance = "default", textSize = 14, floating = false, disabled = false }) {
|
|
236
517
|
const id = useId();
|
|
237
|
-
|
|
518
|
+
const trigger = useRef(null);
|
|
519
|
+
const list = useRef(null);
|
|
520
|
+
const heading = appearance === "heading";
|
|
521
|
+
const popover = heading || floating;
|
|
522
|
+
const activeOption = useRef(null);
|
|
523
|
+
const search = useRef({ query: "", time: 0 });
|
|
524
|
+
const [open, setOpen] = useState(false);
|
|
525
|
+
const [highlighted, setHighlighted] = useState(null);
|
|
526
|
+
const enabled = options.filter((option) => !option.disabled);
|
|
527
|
+
const canOpen = !disabled && enabled.length > 0;
|
|
528
|
+
const expanded = canOpen && open;
|
|
529
|
+
const selected = options.find((option) => option.value === value);
|
|
530
|
+
const active = enabled.find((option) => option.value === highlighted) ?? enabled.find((option) => option.value === value) ?? enabled[0];
|
|
531
|
+
const activeIndex = active ? enabled.indexOf(active) : -1;
|
|
532
|
+
useLayoutEffect(() => {
|
|
533
|
+
const anchor = trigger.current;
|
|
534
|
+
const popup = list.current;
|
|
535
|
+
if (!expanded || !popover || !popup || !anchor)
|
|
536
|
+
return;
|
|
537
|
+
const win = anchor.ownerDocument.defaultView;
|
|
538
|
+
popup.showPopover?.();
|
|
539
|
+
function place() {
|
|
540
|
+
if (!anchor || !popup)
|
|
541
|
+
return;
|
|
542
|
+
const box = anchor.getBoundingClientRect();
|
|
543
|
+
const width2 = anchor.ownerDocument.documentElement.clientWidth;
|
|
544
|
+
const margin = 8;
|
|
545
|
+
const gap = 4;
|
|
546
|
+
const below = win.innerHeight - box.bottom - gap - margin;
|
|
547
|
+
const above = box.top - gap - margin;
|
|
548
|
+
const up = below < Math.min(popup.scrollHeight, 240) && above > below;
|
|
549
|
+
popup.style.maxHeight = Math.max(0, Math.min(240, up ? above : below)) + "px";
|
|
550
|
+
if (floating)
|
|
551
|
+
popup.style.width = box.width + "px";
|
|
552
|
+
const size2 = popup.getBoundingClientRect();
|
|
553
|
+
popup.style.left = Math.max(margin, Math.min(box.left, width2 - size2.width - margin)) + "px";
|
|
554
|
+
popup.style.top = (up ? box.top - gap - size2.height : box.bottom + gap) + "px";
|
|
555
|
+
}
|
|
556
|
+
place();
|
|
557
|
+
win.addEventListener("resize", place);
|
|
558
|
+
win.addEventListener("scroll", place, true);
|
|
559
|
+
return () => {
|
|
560
|
+
popup.hidePopover?.();
|
|
561
|
+
win.removeEventListener("resize", place);
|
|
562
|
+
win.removeEventListener("scroll", place, true);
|
|
563
|
+
};
|
|
564
|
+
}, [expanded, floating, popover]);
|
|
565
|
+
useEffect(() => {
|
|
566
|
+
if (expanded)
|
|
567
|
+
activeOption.current?.scrollIntoView({ block: "nearest" });
|
|
568
|
+
}, [expanded, active?.value]);
|
|
569
|
+
useEffect(() => {
|
|
570
|
+
if (!canOpen) {
|
|
571
|
+
setOpen(false);
|
|
572
|
+
setHighlighted(null);
|
|
573
|
+
}
|
|
574
|
+
}, [canOpen]);
|
|
575
|
+
function close() {
|
|
576
|
+
search.current = { query: "", time: 0 };
|
|
577
|
+
setHighlighted(null);
|
|
578
|
+
setOpen(false);
|
|
579
|
+
}
|
|
580
|
+
function choose(option) {
|
|
581
|
+
close();
|
|
582
|
+
if (option && !option.disabled && option.value !== value)
|
|
583
|
+
onValueChange(option.value);
|
|
584
|
+
}
|
|
585
|
+
function handleKey(event) {
|
|
586
|
+
if (!canOpen || event.nativeEvent.isComposing)
|
|
587
|
+
return;
|
|
588
|
+
const { key } = event;
|
|
589
|
+
if (key === "Tab") {
|
|
590
|
+
if (expanded)
|
|
591
|
+
choose(active);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
if (key === "Escape") {
|
|
595
|
+
if (!expanded)
|
|
596
|
+
return;
|
|
597
|
+
event.preventDefault();
|
|
598
|
+
event.stopPropagation();
|
|
599
|
+
close();
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
if (key === " " || key === "Enter") {
|
|
603
|
+
event.preventDefault();
|
|
604
|
+
if (expanded)
|
|
605
|
+
choose(active);
|
|
606
|
+
else
|
|
607
|
+
setOpen(true);
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
if (key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End") {
|
|
611
|
+
event.preventDefault();
|
|
612
|
+
if (event.altKey && key === "ArrowUp" && expanded) {
|
|
613
|
+
choose(active);
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
setOpen(true);
|
|
617
|
+
let index = activeIndex;
|
|
618
|
+
if (key === "Home")
|
|
619
|
+
index = 0;
|
|
620
|
+
else if (key === "End")
|
|
621
|
+
index = enabled.length - 1;
|
|
622
|
+
else if (expanded && !event.altKey) {
|
|
623
|
+
const step = key === "ArrowDown" ? 1 : -1;
|
|
624
|
+
index = Math.max(0, Math.min(activeIndex + step, enabled.length - 1));
|
|
625
|
+
}
|
|
626
|
+
setHighlighted(enabled[index]?.value ?? null);
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
if (key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey)
|
|
630
|
+
return;
|
|
631
|
+
event.preventDefault();
|
|
632
|
+
const char = key.toLocaleLowerCase();
|
|
633
|
+
const previous = performance.now() - search.current.time < 500 ? search.current.query : "";
|
|
634
|
+
const repeated = previous.length > 0 && [...previous].every((letter) => letter === char);
|
|
635
|
+
const query = repeated ? char : previous + char;
|
|
636
|
+
search.current = { query, time: performance.now() };
|
|
637
|
+
const start = previous && !repeated ? activeIndex : activeIndex + 1;
|
|
638
|
+
const ordered = [...enabled.slice(start), ...enabled.slice(0, start)];
|
|
639
|
+
const match = ordered.find((option) => option.label.toLocaleLowerCase().startsWith(query));
|
|
640
|
+
setOpen(true);
|
|
641
|
+
if (match)
|
|
642
|
+
setHighlighted(match.value);
|
|
643
|
+
}
|
|
644
|
+
return _jsxs2("div", { className: "vx-dropdown", "data-size": size, "data-width": width, "data-appearance": appearance, "data-text-size": textSize, "data-floating": floating || void 0, children: [_jsxs2("button", { type: "button", ref: trigger, role: "combobox", className: "vx-dropdown-trigger", "aria-label": label, "aria-expanded": expanded, "aria-controls": `${id}-listbox`, "aria-activedescendant": expanded && active ? `${id}-option-${options.indexOf(active)}` : void 0, disabled: !canOpen, onClick: () => expanded ? close() : setOpen(true), onBlur: close, onKeyDown: handleKey, children: [_jsxs2("span", { className: "vx-dropdown-value", children: [optionIcon(selected?.icon), _jsx3("span", { children: selected?.triggerLabel ?? selected?.label ?? placeholder })] }), _jsx3(Icon, { name: expanded ? "chevron-up" : "chevron-down" })] }), _jsx3("ul", { ref: list, popover: popover ? "manual" : void 0, id: `${id}-listbox`, role: "listbox", "aria-label": label, hidden: !expanded, children: options.map((option, index) => _jsxs2("li", { id: `${id}-option-${index}`, ref: active === option ? activeOption : void 0, role: "option", "aria-selected": option.value === value, "aria-disabled": option.disabled || void 0, "data-active": active === option, onMouseDown: (event) => event.preventDefault(), onClick: () => {
|
|
645
|
+
if (!option.disabled)
|
|
646
|
+
choose(option);
|
|
647
|
+
}, children: [optionIcon(option.icon), option.label, width === "hug" && option.value === value && _jsx3(Icon, { name: "check" })] }, option.value)) })] });
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// packages/ui-system/dist/segmented-control.js
|
|
651
|
+
import { jsx as _jsx4, jsxs as _jsxs3 } from "react/jsx-runtime";
|
|
652
|
+
import { useId as useId2 } from "react";
|
|
653
|
+
function SegmentedControl({ label, items, value, onValueChange, size = "medium", width = "fixed", iconOnly = false }) {
|
|
654
|
+
const id = useId2();
|
|
655
|
+
return _jsx4("div", { role: "radiogroup", "aria-label": label, className: "vx-segment", "data-size": size, "data-width": width, "data-icon-only": iconOnly, children: items.map((item) => _jsxs3("label", { children: [_jsx4("input", { type: "radio", name: id, value: item.value, disabled: item.disabled, checked: item.value === value, "aria-label": item.label, onChange: () => onValueChange(item.value) }), _jsxs3("span", { className: "vx-segment-item", children: [item.icon && _jsx4(Icon, { name: item.icon }), (!iconOnly || !item.icon) && item.label] })] }, item.value)) });
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// packages/ui-system/dist/input.js
|
|
659
|
+
import { jsx as _jsx5, jsxs as _jsxs4 } from "react/jsx-runtime";
|
|
660
|
+
function TextInput({ label, value, onValueChange, size = "medium", appearance = "default", placeholder, ...props }) {
|
|
661
|
+
return _jsxs4("label", { className: "vx-field", "data-size": size, "data-appearance": appearance, children: [_jsx5("span", { children: label }), _jsx5("input", { ...props, type: "text", placeholder: placeholder ?? (props.readOnly ? void 0 : "Enter text"), value, onChange: (event) => onValueChange(event.currentTarget.value) })] });
|
|
238
662
|
}
|
|
239
663
|
|
|
240
664
|
// packages/ui-system/dist/tag.js
|
|
241
|
-
import { jsx as
|
|
242
|
-
function Tag({ children, variant = "overlay" }) {
|
|
243
|
-
return
|
|
665
|
+
import { jsx as _jsx6 } from "react/jsx-runtime";
|
|
666
|
+
function Tag({ children, variant = "overlay", className }) {
|
|
667
|
+
return _jsx6("span", { className: className ? `vx-tag ${className}` : "vx-tag", "data-variant": variant, children });
|
|
244
668
|
}
|
|
245
669
|
|
|
246
670
|
// packages/ui-system/dist/frame-range.js
|
|
247
|
-
import { jsx as
|
|
671
|
+
import { jsx as _jsx7, jsxs as _jsxs5, Fragment as _Fragment } from "react/jsx-runtime";
|
|
248
672
|
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
249
673
|
function timeLabel(seconds) {
|
|
250
674
|
const whole = Math.floor(seconds);
|
|
251
|
-
return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
|
|
675
|
+
return `${String(Math.floor(whole / 60)).padStart(2, "0")}:${String(whole % 60).padStart(2, "0")}`;
|
|
252
676
|
}
|
|
253
|
-
function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range", onValueChange }) {
|
|
677
|
+
function FrameRange({ duration, thumbnail, frames, value, step = 0.1, variant = "range", onValueChange }) {
|
|
254
678
|
const length = Number.isFinite(duration) && duration > 0 ? duration : 0;
|
|
255
679
|
const increment = Math.min(length, Number.isFinite(step) && step > 0 ? step : 0.1);
|
|
256
680
|
const start = clamp(Number.isFinite(value.start) ? value.start : 0, 0, length - increment);
|
|
@@ -283,12 +707,12 @@ function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range",
|
|
|
283
707
|
event.preventDefault();
|
|
284
708
|
move(edge, next);
|
|
285
709
|
}
|
|
286
|
-
return
|
|
710
|
+
return _jsxs5("div", { className: "vx-frame-range", "data-variant": variant, role: "group", "aria-label": "Playback range", "aria-disabled": !length, style: length ? {
|
|
287
711
|
"--vx-range-start": `${start / length * 100}%`,
|
|
288
712
|
"--vx-range-end": `${end / length * 100}%`
|
|
289
|
-
} : void 0, children: [thumbnail && length > 0 &&
|
|
713
|
+
} : void 0, children: [frames?.length && length > 0 ? _jsx7("div", { className: "vx-frame-filmstrip", children: frames.map((src, index) => _jsx7("img", { src, alt: "" }, index)) }) : thumbnail && length > 0 && _jsx7("img", { src: thumbnail, alt: "" }), length > 0 && _jsxs5(_Fragment, { children: [_jsx7("span", { className: "vx-frame-selection", "aria-hidden": "true", children: _jsxs5(Tag, { children: [timeLabel(start), " \u2013 ", timeLabel(end)] }) }), ["start", "end"].map((edge) => {
|
|
290
714
|
const current = edge === "start" ? start : end;
|
|
291
|
-
return
|
|
715
|
+
return _jsx7("div", { tabIndex: 0, role: "slider", className: "vx-frame-handle", "data-edge": edge, "aria-label": edge === "start" ? "Range start" : "Range end", "aria-valuemin": edge === "start" ? 0 : start + increment, "aria-valuemax": edge === "start" ? end - increment : length, "aria-valuenow": current, "aria-valuetext": `${Number(current.toFixed(3))} seconds`, onKeyDown: (event) => handleKey(event, edge, current), onPointerDown: (event) => {
|
|
292
716
|
if (event.button !== 0)
|
|
293
717
|
return;
|
|
294
718
|
event.currentTarget.focus();
|
|
@@ -298,106 +722,246 @@ function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range",
|
|
|
298
722
|
}
|
|
299
723
|
|
|
300
724
|
// packages/ui-system/dist/dialog.js
|
|
301
|
-
import { jsx as
|
|
302
|
-
import {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
725
|
+
import { jsx as _jsx8, jsxs as _jsxs6, Fragment as _Fragment2 } from "react/jsx-runtime";
|
|
726
|
+
import { useId as useId3, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
727
|
+
import { createPortal } from "react-dom";
|
|
728
|
+
|
|
729
|
+
// packages/ui-system/dist/dialog-surface.js
|
|
730
|
+
var overlayOpeningEvent = "vx-overlay-opening";
|
|
731
|
+
function outerDialogDocument(anchor) {
|
|
732
|
+
const source = anchor.ownerDocument;
|
|
733
|
+
try {
|
|
734
|
+
const target = source.defaultView?.top?.document;
|
|
735
|
+
return target && target !== source ? target : void 0;
|
|
736
|
+
} catch {
|
|
737
|
+
return void 0;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
function createDialogSurface(anchor) {
|
|
741
|
+
const source = anchor.ownerDocument;
|
|
742
|
+
const target = outerDialogDocument(anchor);
|
|
743
|
+
if (!target)
|
|
744
|
+
return void 0;
|
|
745
|
+
const host = target.createElement("div");
|
|
746
|
+
host.dataset.studioDialogSurface = "";
|
|
747
|
+
const shadow = host.attachShadow({ mode: "open" });
|
|
748
|
+
shadow.addEventListener("beforetoggle", (event) => {
|
|
749
|
+
if (event.newState === "open" && !event.target.classList.contains("vx-toast"))
|
|
750
|
+
target.dispatchEvent(new Event(overlayOpeningEvent));
|
|
751
|
+
}, true);
|
|
752
|
+
for (const original of source.querySelectorAll('link[rel="stylesheet"], style')) {
|
|
753
|
+
const clone = original.cloneNode(true);
|
|
754
|
+
if (original.tagName === "LINK")
|
|
755
|
+
clone.setAttribute("href", original.href);
|
|
756
|
+
shadow.append(clone);
|
|
757
|
+
}
|
|
758
|
+
const theme = anchor.closest("[data-vx-theme]");
|
|
759
|
+
const root = target.createElement("div");
|
|
760
|
+
root.dataset.vxTheme = theme?.dataset.vxTheme ?? "light";
|
|
761
|
+
root.className = theme?.className ?? "";
|
|
762
|
+
root.style.display = "contents";
|
|
763
|
+
const style = source.defaultView.getComputedStyle(anchor);
|
|
764
|
+
for (const name of style)
|
|
765
|
+
if (name.startsWith("--"))
|
|
766
|
+
root.style.setProperty(name, style.getPropertyValue(name));
|
|
767
|
+
shadow.append(root);
|
|
768
|
+
let container = root;
|
|
769
|
+
const ancestors = [];
|
|
770
|
+
for (let parent = anchor.parentElement; parent && parent !== theme; parent = parent.parentElement)
|
|
771
|
+
ancestors.unshift(parent);
|
|
772
|
+
for (const original of ancestors) {
|
|
773
|
+
const wrapper = target.createElement("div");
|
|
774
|
+
wrapper.className = original.className;
|
|
775
|
+
for (const { name, value } of original.attributes)
|
|
776
|
+
if (name.startsWith("data-"))
|
|
777
|
+
wrapper.setAttribute(name, value);
|
|
778
|
+
wrapper.style.display = "contents";
|
|
779
|
+
container.append(wrapper);
|
|
780
|
+
container = wrapper;
|
|
781
|
+
}
|
|
782
|
+
target.body.append(host);
|
|
783
|
+
return { root: container, dispose: () => host.remove() };
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// packages/ui-system/dist/dialog.js
|
|
787
|
+
function useInlineDialog(anchor) {
|
|
788
|
+
const [inline, setInline] = useState2(false);
|
|
789
|
+
useLayoutEffect2(() => {
|
|
790
|
+
if (anchor.current)
|
|
791
|
+
setInline(!outerDialogDocument(anchor.current));
|
|
792
|
+
}, [anchor]);
|
|
793
|
+
return inline;
|
|
794
|
+
}
|
|
795
|
+
function Dialog({ title, open, onOpenChange, children, actions, className, inlineWhenClosed = false, variant = "default", closeOnEscape = true, focusTitleOnOpen = variant === "welcome" }) {
|
|
796
|
+
const ref = useRef2(null);
|
|
797
|
+
const anchor = useRef2(null);
|
|
798
|
+
const [surface, setSurface] = useState2();
|
|
799
|
+
const heading = useId3();
|
|
800
|
+
useLayoutEffect2(() => {
|
|
801
|
+
if (inlineWhenClosed || !open || !anchor.current)
|
|
309
802
|
return;
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
dialog.close();
|
|
314
|
-
}, [open]);
|
|
315
|
-
useLayoutEffect(() => {
|
|
316
|
-
const dialog = ref.current;
|
|
803
|
+
const mounted = createDialogSurface(anchor.current);
|
|
804
|
+
const active = anchor.current.getRootNode().activeElement;
|
|
805
|
+
setSurface(mounted?.root ?? null);
|
|
317
806
|
return () => {
|
|
318
|
-
|
|
319
|
-
|
|
807
|
+
mounted?.dispose();
|
|
808
|
+
setSurface(void 0);
|
|
809
|
+
queueMicrotask(() => {
|
|
810
|
+
if (active?.isConnected)
|
|
811
|
+
active.focus();
|
|
812
|
+
});
|
|
320
813
|
};
|
|
321
|
-
}, []);
|
|
322
|
-
|
|
814
|
+
}, [open, inlineWhenClosed]);
|
|
815
|
+
useLayoutEffect2(() => {
|
|
816
|
+
const dialog2 = ref.current;
|
|
817
|
+
if (inlineWhenClosed && dialog2) {
|
|
818
|
+
if (open) {
|
|
819
|
+
dialog2.close();
|
|
820
|
+
dialog2.showModal();
|
|
821
|
+
} else {
|
|
822
|
+
if (dialog2.matches(":modal"))
|
|
823
|
+
dialog2.close();
|
|
824
|
+
dialog2.open = true;
|
|
825
|
+
}
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
if (!open || surface === void 0 || !dialog2)
|
|
829
|
+
return;
|
|
830
|
+
dialog2.showModal();
|
|
831
|
+
return () => {
|
|
832
|
+
if (dialog2.open)
|
|
833
|
+
dialog2.close();
|
|
834
|
+
};
|
|
835
|
+
}, [open, surface, inlineWhenClosed]);
|
|
836
|
+
const welcome = variant === "welcome";
|
|
837
|
+
const closeButton = _jsx8(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) });
|
|
838
|
+
const dialog = _jsxs6("dialog", { ref, open: inlineWhenClosed || void 0, className: inlineWhenClosed && !open ? "vx-dialog vx-dialog-inline" : className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, role: inlineWhenClosed && !open ? "presentation" : void 0, "aria-labelledby": inlineWhenClosed && !open ? void 0 : heading, onCancel: (event) => {
|
|
323
839
|
event.preventDefault();
|
|
324
840
|
event.stopPropagation();
|
|
325
|
-
|
|
841
|
+
if (closeOnEscape)
|
|
842
|
+
onOpenChange(false);
|
|
326
843
|
}, onClose: (event) => {
|
|
327
|
-
if (open && !event.currentTarget.open)
|
|
844
|
+
if (open && event.currentTarget.isConnected && !event.currentTarget.open)
|
|
328
845
|
onOpenChange(false);
|
|
329
|
-
}, children: [
|
|
846
|
+
}, children: [_jsxs6("header", { hidden: inlineWhenClosed && !open, children: [_jsx8("h2", { id: heading, tabIndex: focusTitleOnOpen ? -1 : void 0, autoFocus: focusTitleOnOpen, children: title }), !welcome && closeButton] }), _jsx8("div", { className: "vx-dialog-body", children }), (actions || welcome) && _jsxs6("footer", { hidden: inlineWhenClosed && !open, children: [actions, welcome && closeButton] })] });
|
|
847
|
+
return _jsxs6(_Fragment2, { children: [_jsx8("span", { ref: anchor, hidden: true }), (open || inlineWhenClosed) && (surface ? createPortal(dialog, surface) : dialog)] });
|
|
330
848
|
}
|
|
331
849
|
|
|
332
850
|
// packages/ui-system/dist/menu.js
|
|
333
|
-
import { jsx as
|
|
334
|
-
import { useEffect as useEffect2, useId as
|
|
335
|
-
import { createPortal } from "react-dom";
|
|
851
|
+
import { jsx as _jsx9, jsxs as _jsxs7 } from "react/jsx-runtime";
|
|
852
|
+
import { useEffect as useEffect2, useId as useId4, useLayoutEffect as useLayoutEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
853
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
854
|
+
function MenuPreview({ children }) {
|
|
855
|
+
const ref = useRef3(null);
|
|
856
|
+
const [visible, setVisible] = useState3(false);
|
|
857
|
+
useEffect2(() => {
|
|
858
|
+
const node = ref.current;
|
|
859
|
+
if (!node)
|
|
860
|
+
return;
|
|
861
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
862
|
+
if (entry?.isIntersecting) {
|
|
863
|
+
setVisible(true);
|
|
864
|
+
observer.disconnect();
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
observer.observe(node);
|
|
868
|
+
return () => observer.disconnect();
|
|
869
|
+
}, []);
|
|
870
|
+
return _jsx9("span", { ref, className: "vx-menu-preview", "aria-hidden": "true", children: visible && children });
|
|
871
|
+
}
|
|
336
872
|
function isEnabled(item) {
|
|
337
873
|
return !item.disabled && item.items?.length !== 0;
|
|
338
874
|
}
|
|
339
|
-
function Menu({ label, items, triggerIcon, floating = false }) {
|
|
340
|
-
const id =
|
|
341
|
-
const trigger =
|
|
342
|
-
const popup =
|
|
343
|
-
const
|
|
344
|
-
const
|
|
345
|
-
const
|
|
346
|
-
const
|
|
347
|
-
|
|
875
|
+
function Menu({ label, items, triggerIcon, textTrigger = "dropdown", floating = false, cascading = false }) {
|
|
876
|
+
const id = useId4();
|
|
877
|
+
const trigger = useRef3(null);
|
|
878
|
+
const popup = useRef3(null);
|
|
879
|
+
const children = useRef3(/* @__PURE__ */ new Map());
|
|
880
|
+
const focusOnOpen = useRef3(true);
|
|
881
|
+
const cascade = floating && cascading;
|
|
882
|
+
const focusIndex = useRef3(0);
|
|
883
|
+
const [path, setPath] = useState3(null);
|
|
884
|
+
const [placement, setPlacement] = useState3({ visibility: "hidden" });
|
|
885
|
+
const portalRoot = floating ? trigger.current?.closest("dialog, [data-vx-theme]") : null;
|
|
886
|
+
useLayoutEffect3(() => {
|
|
348
887
|
if (!floating || !path || !portalRoot)
|
|
349
888
|
return;
|
|
350
889
|
const position = () => {
|
|
351
890
|
const anchor = trigger.current, menu2 = popup.current;
|
|
352
891
|
if (!anchor || !menu2)
|
|
353
892
|
return;
|
|
893
|
+
const document3 = anchor.ownerDocument;
|
|
894
|
+
const window2 = document3.defaultView;
|
|
354
895
|
const rect = anchor.getBoundingClientRect();
|
|
355
|
-
const width =
|
|
896
|
+
const width = document3.documentElement.clientWidth, height = window2.innerHeight;
|
|
356
897
|
const bounds = menu2.getBoundingClientRect();
|
|
357
898
|
const naturalHeight = menu2.scrollHeight + bounds.height - menu2.clientHeight;
|
|
358
899
|
const below = Math.max(0, height - rect.bottom - 12), above = Math.max(0, rect.top - 12);
|
|
359
900
|
const flip = naturalHeight > below && above > below;
|
|
360
901
|
const maxHeight = Math.max(0, Math.min(480, height - 16, flip ? above : below));
|
|
361
902
|
const menuHeight = Math.min(naturalHeight, maxHeight);
|
|
903
|
+
const left = Math.max(8, Math.min(rect.right - bounds.width, width - bounds.width - 8));
|
|
904
|
+
const top = Math.max(8, Math.min(flip ? rect.top - menuHeight - 4 : rect.bottom + 4, height - menuHeight - 8));
|
|
362
905
|
setPlacement({
|
|
363
906
|
position: "fixed",
|
|
364
907
|
visibility: "visible",
|
|
365
908
|
insetInlineStart: "auto",
|
|
366
|
-
left
|
|
367
|
-
top
|
|
909
|
+
left,
|
|
910
|
+
top,
|
|
368
911
|
maxHeight,
|
|
369
912
|
zIndex: 100
|
|
370
913
|
});
|
|
914
|
+
let parent = menu2, parentLeft = left, parentTop = top;
|
|
915
|
+
for (let depth = 1; cascade && depth <= path.length; depth++) {
|
|
916
|
+
const panel = children.current.get(depth);
|
|
917
|
+
const item = Array.from(parent.querySelectorAll("button")).find((b) => b.dataset.key === path[depth - 1]);
|
|
918
|
+
if (!panel || !item)
|
|
919
|
+
break;
|
|
920
|
+
const parentBox = parent.getBoundingClientRect(), box = panel.getBoundingClientRect();
|
|
921
|
+
const nextLeft = parentLeft + parentBox.width;
|
|
922
|
+
parentLeft = Math.max(8, Math.min(nextLeft + box.width <= width - 8 ? nextLeft : parentLeft - box.width, width - box.width - 8));
|
|
923
|
+
parentTop = Math.max(8, Math.min(parentTop + item.getBoundingClientRect().top - parentBox.top - 4, height - box.height - 8));
|
|
924
|
+
Object.assign(panel.style, {
|
|
925
|
+
left: parentLeft + "px",
|
|
926
|
+
top: parentTop + "px",
|
|
927
|
+
visibility: "visible"
|
|
928
|
+
});
|
|
929
|
+
parent = panel;
|
|
930
|
+
}
|
|
371
931
|
};
|
|
372
932
|
const outside = (event) => {
|
|
373
|
-
const
|
|
374
|
-
if (
|
|
933
|
+
const path2 = event.composedPath();
|
|
934
|
+
if (!path2.includes(trigger.current) && !path2.includes(popup.current) && ![...children.current.values()].some((panel) => path2.includes(panel)))
|
|
375
935
|
setPath(null);
|
|
376
936
|
};
|
|
937
|
+
const document2 = portalRoot.ownerDocument;
|
|
938
|
+
const window = document2.defaultView;
|
|
377
939
|
position();
|
|
378
940
|
window.addEventListener("resize", position);
|
|
379
941
|
window.addEventListener("scroll", position, true);
|
|
380
|
-
|
|
942
|
+
document2.addEventListener("pointerdown", outside);
|
|
381
943
|
return () => {
|
|
382
944
|
window.removeEventListener("resize", position);
|
|
383
945
|
window.removeEventListener("scroll", position, true);
|
|
384
|
-
|
|
946
|
+
document2.removeEventListener("pointerdown", outside);
|
|
385
947
|
};
|
|
386
|
-
}, [floating, path, portalRoot]);
|
|
948
|
+
}, [floating, path, portalRoot, cascade]);
|
|
387
949
|
let entries = items;
|
|
388
950
|
let menuLabel = label;
|
|
951
|
+
const levels = [{ entries, menuLabel }];
|
|
389
952
|
for (const key of path ?? []) {
|
|
390
953
|
const entry = entries.find((item) => item.id === key);
|
|
391
954
|
if (!entry?.items)
|
|
392
955
|
break;
|
|
393
956
|
menuLabel = entry.label;
|
|
394
957
|
entries = entry.items;
|
|
958
|
+
levels.push({ entries, menuLabel });
|
|
395
959
|
}
|
|
396
|
-
function buttons() {
|
|
397
|
-
return [...
|
|
960
|
+
function buttons(panel = cascade && path?.length ? children.current.get(path.length) : popup.current) {
|
|
961
|
+
return [...panel?.querySelectorAll("button:not(:disabled)") ?? []];
|
|
398
962
|
}
|
|
399
963
|
useEffect2(() => {
|
|
400
|
-
if (path && (!floating || !portalRoot || placement.visibility === "visible"))
|
|
964
|
+
if (focusOnOpen.current && path && (!floating || !portalRoot || placement.visibility === "visible"))
|
|
401
965
|
buttons().at(focusIndex.current)?.focus();
|
|
402
966
|
}, [path, floating && placement.visibility, portalRoot]);
|
|
403
967
|
function close() {
|
|
@@ -405,6 +969,7 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
405
969
|
trigger.current?.focus();
|
|
406
970
|
}
|
|
407
971
|
function back() {
|
|
972
|
+
focusOnOpen.current = true;
|
|
408
973
|
if (!path?.length)
|
|
409
974
|
return;
|
|
410
975
|
const parentPath = path.slice(0, -1);
|
|
@@ -412,24 +977,27 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
412
977
|
focusIndex.current = Math.max(0, parent.filter(isEnabled).findIndex((item) => item.id === path.at(-1)));
|
|
413
978
|
setPath(parentPath);
|
|
414
979
|
}
|
|
415
|
-
function choose(item) {
|
|
980
|
+
function choose(item, depth) {
|
|
981
|
+
focusOnOpen.current = true;
|
|
416
982
|
if (item.items?.length) {
|
|
417
983
|
focusIndex.current = 0;
|
|
418
|
-
setPath([...path ?? [], item.id]);
|
|
984
|
+
setPath([...(path ?? []).slice(0, depth), item.id]);
|
|
985
|
+
if (cascade && path?.[depth] === item.id)
|
|
986
|
+
buttons(children.current.get(depth + 1))?.at(0)?.focus();
|
|
419
987
|
} else if (item.onSelect) {
|
|
420
988
|
if (item.checked === void 0)
|
|
421
989
|
close();
|
|
422
990
|
item.onSelect();
|
|
423
991
|
}
|
|
424
992
|
}
|
|
425
|
-
function handleKey(event) {
|
|
993
|
+
function handleKey(event, depth) {
|
|
426
994
|
if (event.key === "Tab" && floating && portalRoot) {
|
|
427
995
|
if (event.shiftKey)
|
|
428
996
|
event.preventDefault();
|
|
429
997
|
close();
|
|
430
998
|
return;
|
|
431
999
|
}
|
|
432
|
-
const available = buttons();
|
|
1000
|
+
const available = buttons(event.currentTarget);
|
|
433
1001
|
const index = available.findIndex((button) => button === event.target);
|
|
434
1002
|
if (event.key === "Escape") {
|
|
435
1003
|
event.preventDefault();
|
|
@@ -446,10 +1014,10 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
446
1014
|
return;
|
|
447
1015
|
}
|
|
448
1016
|
if (event.key === "ArrowRight") {
|
|
449
|
-
const item = entries.filter(isEnabled)[index];
|
|
1017
|
+
const item = levels[depth]?.entries.filter(isEnabled)[index];
|
|
450
1018
|
if (item?.items?.length) {
|
|
451
1019
|
event.preventDefault();
|
|
452
|
-
choose(item);
|
|
1020
|
+
choose(item, depth);
|
|
453
1021
|
}
|
|
454
1022
|
return;
|
|
455
1023
|
}
|
|
@@ -465,6 +1033,7 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
465
1033
|
}
|
|
466
1034
|
}
|
|
467
1035
|
function open(index = 0) {
|
|
1036
|
+
focusOnOpen.current = true;
|
|
468
1037
|
focusIndex.current = index;
|
|
469
1038
|
setPath([]);
|
|
470
1039
|
}
|
|
@@ -474,37 +1043,81 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
474
1043
|
open(event.key === "ArrowUp" ? -1 : 0);
|
|
475
1044
|
}
|
|
476
1045
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
1046
|
+
function hover(item, depth) {
|
|
1047
|
+
if (!cascade || !path)
|
|
1048
|
+
return;
|
|
1049
|
+
const next = path.slice(0, depth);
|
|
1050
|
+
if (item.items?.length && isEnabled(item))
|
|
1051
|
+
next.push(item.id);
|
|
1052
|
+
if (next.length === path.length && next.every((key, i) => path[i] === key))
|
|
1053
|
+
return;
|
|
1054
|
+
focusOnOpen.current = false;
|
|
1055
|
+
setPath(next);
|
|
1056
|
+
}
|
|
1057
|
+
const menu = levels.map(({ entries: entries2, menuLabel: menuLabel2 }, depth) => !cascade && depth !== levels.length - 1 ? null : _jsx9("div", { ref: !cascade || depth === 0 ? popup : (el) => {
|
|
1058
|
+
if (el)
|
|
1059
|
+
children.current.set(depth, el);
|
|
1060
|
+
else
|
|
1061
|
+
children.current.delete(depth);
|
|
1062
|
+
}, className: "vx-action-menu-items", role: "menu", id: !cascade || !depth ? id : id + "-" + depth, "aria-label": menuLabel2, hidden: !path, onKeyDown: (e) => handleKey(e, depth), "data-with-previews": entries2.some((item) => item.preview) || void 0, "data-floating": floating || void 0, style: floating && portalRoot ? cascade && depth ? {
|
|
1063
|
+
position: "fixed",
|
|
1064
|
+
insetInlineStart: "auto",
|
|
1065
|
+
visibility: "hidden",
|
|
1066
|
+
maxHeight: "min(480px, calc(100dvh - 16px))",
|
|
1067
|
+
zIndex: 100 + depth
|
|
1068
|
+
} : placement : void 0, children: entries2.map((item) => _jsxs7("button", { type: "button", role: item.checked === void 0 ? "menuitem" : "menuitemcheckbox", "aria-checked": item.checked, "aria-haspopup": item.items?.length ? "menu" : void 0, "data-key": item.id, "aria-expanded": cascade && item.items ? path?.[depth] === item.id : void 0, onPointerEnter: cascade ? (e) => {
|
|
1069
|
+
if (e.pointerType !== "touch")
|
|
1070
|
+
hover(item, depth);
|
|
1071
|
+
} : void 0, "data-size": item.size ?? "medium", "data-tone": item.tone, disabled: !isEnabled(item), tabIndex: -1, onClick: () => choose(item, depth), children: [item.icon && _jsx9(Icon, { name: item.icon }), path && item.preview && _jsx9(MenuPreview, { children: item.preview }), _jsx9("span", { className: "vx-menu-label", children: item.label }), item.checked && _jsx9(Icon, { name: "check" }), item.items?.length ? _jsx9(Icon, { name: "chevron-right" }) : null] }, item.id)) }, depth));
|
|
1072
|
+
return _jsxs7("div", { className: "vx-action-menu", onBlur: (event) => {
|
|
1073
|
+
if (!event.currentTarget.contains(event.relatedTarget) && !(floating && popup.current?.contains(event.relatedTarget)) && ![...children.current.values()].some((panel) => panel.contains(event.relatedTarget)))
|
|
480
1074
|
setPath(null);
|
|
481
|
-
}, children: [triggerIcon ?
|
|
1075
|
+
}, children: [triggerIcon ? _jsx9(IconButton, { ref: trigger, label, icon: triggerIcon, variant: "icon-ghost-sm", "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }) : _jsx9(Button, { ref: trigger, label, variant: textTrigger === "plain" ? "text-plain-sm" : "text-tonal-sm", trailingIcon: textTrigger === "dropdown" ? "chevron-down" : void 0, "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }), portalRoot ? createPortal2(menu, portalRoot) : menu] });
|
|
482
1076
|
}
|
|
483
1077
|
|
|
484
1078
|
// packages/ui-system/dist/video-player.js
|
|
485
|
-
import { jsx as
|
|
486
|
-
import { useEffect as useEffect3, useRef as
|
|
487
|
-
function timeLabel2(seconds) {
|
|
1079
|
+
import { jsx as _jsx10, jsxs as _jsxs8, Fragment as _Fragment3 } from "react/jsx-runtime";
|
|
1080
|
+
import { useEffect as useEffect3, useRef as useRef4, useState as useState4 } from "react";
|
|
1081
|
+
function timeLabel2(seconds, padMinutes = false) {
|
|
488
1082
|
const whole = Math.floor(seconds);
|
|
489
|
-
|
|
1083
|
+
const minutes = String(Math.floor(whole / 60));
|
|
1084
|
+
return `${padMinutes ? minutes.padStart(2, "0") : minutes}:${String(whole % 60).padStart(2, "0")}`;
|
|
490
1085
|
}
|
|
491
|
-
function PlaybackControls({ playing, muted, time, duration, size = "medium", disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen }) {
|
|
492
|
-
|
|
1086
|
+
function PlaybackControls({ playing, muted, time, duration, size = "medium", disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen, fullscreenLabel = "Toggle fullscreen", actions, appearance = "on-content", timeDisplay = "combined", renderTimeline }) {
|
|
1087
|
+
const slider = _jsx10("input", { className: "vx-playback-range", "aria-label": "Playback position", "aria-valuetext": `${timeLabel2(time)} of ${timeLabel2(duration)}`, type: "range", min: 0, max: duration, value: time, step: "any", disabled: disabled || !duration, onChange: (event) => onSeek(event.currentTarget.valueAsNumber) });
|
|
1088
|
+
return _jsxs8("div", { className: "vx-playback-controls", role: "group", "aria-label": "Playback controls", "data-size": size, "data-appearance": appearance, style: {
|
|
1089
|
+
"--vx-playback-fraction": duration > 0 ? Math.min(1, Math.max(0, time / duration)) : 0
|
|
1090
|
+
}, children: [_jsx10(IconButton, { icon: playing ? size === "large" ? "pause-large" : "pause" : size === "large" ? "playback-play-large" : "playback-play", label: playing ? "Pause" : "Play", disabled, onClick: onTogglePlay }), timeDisplay === "split" && _jsx10("span", { "aria-hidden": "true", "data-time": "elapsed", children: timeLabel2(time, true) }), renderTimeline ? renderTimeline(slider) : slider, _jsx10("span", { "aria-hidden": "true", "data-time": timeDisplay === "split" ? "duration" : void 0, children: timeDisplay === "split" ? timeLabel2(duration, true) : `${timeLabel2(time)} / ${timeLabel2(duration)}` }), _jsx10(IconButton, { icon: muted ? size === "large" ? "mute-large" : "mute" : size === "large" ? "volume-large" : "volume", label: muted ? "Unmute" : "Mute", disabled, onClick: onToggleMute }), actions, onFullscreen && _jsx10(IconButton, { icon: size === "large" ? "fullscreen-large" : "fullscreen", label: fullscreenLabel, onClick: onFullscreen })] });
|
|
493
1091
|
}
|
|
494
1092
|
function VideoPlayer(props) {
|
|
495
|
-
return
|
|
1093
|
+
return _jsx10(Playback, { ...props }, JSON.stringify([props.src, props.poster, props.posterDuration]));
|
|
496
1094
|
}
|
|
497
|
-
function Playback({ src, poster, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", controlsSize, showFullscreen = true, overlay, onBeforePlay, onStateChange, onTimeChange, onEnded, onError }) {
|
|
498
|
-
const root =
|
|
499
|
-
const video =
|
|
500
|
-
const
|
|
501
|
-
const
|
|
502
|
-
const
|
|
503
|
-
const
|
|
504
|
-
const
|
|
505
|
-
const [
|
|
1095
|
+
function Playback({ src, poster, aspectRatio, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", fitContent = false, showCoverInfo = true, showCoverPlay = true, fitExpandedContent = false, controlsSize, controlsAppearance, timeDisplay, controlsActions, showFullscreen = true, fullscreenMode = "native", overlay, onBeforePlay, onStateChange, onTimeChange, onEnded, onError }) {
|
|
1096
|
+
const root = useRef4(null);
|
|
1097
|
+
const video = useRef4(null);
|
|
1098
|
+
const playbackEpoch = useRef4(0);
|
|
1099
|
+
const localDialog = useInlineDialog(root);
|
|
1100
|
+
const inlineDialog = fullscreenMode === "dialog" && localDialog;
|
|
1101
|
+
const position = useRef4(0);
|
|
1102
|
+
const callbacks = useRef4({ onTimeChange, onStateChange, onEnded });
|
|
1103
|
+
const [time, setTime] = useState4(0);
|
|
1104
|
+
const [ratio, setRatio] = useState4();
|
|
1105
|
+
const [metadataDuration, setMetadataDuration] = useState4(0);
|
|
1106
|
+
const [state, setState] = useState4("cover");
|
|
1107
|
+
const [muted, setMuted] = useState4(defaultMuted);
|
|
1108
|
+
const [expanded, setExpanded] = useState4(false);
|
|
1109
|
+
const [inlineHeight, setInlineHeight] = useState4();
|
|
1110
|
+
const restoreFocus = useRef4(false);
|
|
1111
|
+
useEffect3(() => {
|
|
1112
|
+
if (!expanded && restoreFocus.current) {
|
|
1113
|
+
restoreFocus.current = false;
|
|
1114
|
+
root.current?.querySelector('button[aria-label="Expand video"]')?.focus();
|
|
1115
|
+
}
|
|
1116
|
+
}, [expanded]);
|
|
1117
|
+
const restore = useRef4(void 0);
|
|
506
1118
|
const stillDuration = poster && Number.isFinite(posterDuration) ? Math.max(0, posterDuration) : 0;
|
|
507
1119
|
const duration = src ? metadataDuration : stillDuration;
|
|
1120
|
+
const displayRatio = ratio ?? aspectRatio ?? 16 / 9;
|
|
508
1121
|
useEffect3(() => {
|
|
509
1122
|
const element = video.current;
|
|
510
1123
|
return () => {
|
|
@@ -514,7 +1127,7 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
|
|
|
514
1127
|
element.removeAttribute("src");
|
|
515
1128
|
element.load();
|
|
516
1129
|
};
|
|
517
|
-
}, []);
|
|
1130
|
+
}, [inlineDialog ? false : expanded, src, inlineDialog]);
|
|
518
1131
|
function updateTime(next) {
|
|
519
1132
|
position.current = next;
|
|
520
1133
|
setTime(next);
|
|
@@ -548,7 +1161,15 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
|
|
|
548
1161
|
}
|
|
549
1162
|
return () => cancelAnimationFrame(frame);
|
|
550
1163
|
}, [src, state, duration]);
|
|
1164
|
+
function requestPlay(element, onRejected) {
|
|
1165
|
+
const epoch = playbackEpoch.current;
|
|
1166
|
+
void element.play().catch((error) => {
|
|
1167
|
+
if (epoch === playbackEpoch.current && video.current === element && element.isConnected)
|
|
1168
|
+
onRejected(error);
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
551
1171
|
function togglePlay() {
|
|
1172
|
+
playbackEpoch.current++;
|
|
552
1173
|
if (state === "playing") {
|
|
553
1174
|
if (video.current)
|
|
554
1175
|
video.current.pause();
|
|
@@ -559,7 +1180,7 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
|
|
|
559
1180
|
if (onBeforePlay?.() === false)
|
|
560
1181
|
return;
|
|
561
1182
|
if (video.current)
|
|
562
|
-
|
|
1183
|
+
requestPlay(video.current, (error) => onError?.(error));
|
|
563
1184
|
else if (duration) {
|
|
564
1185
|
if (position.current >= duration)
|
|
565
1186
|
updateTime(0);
|
|
@@ -573,25 +1194,82 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
|
|
|
573
1194
|
updateTime(seconds);
|
|
574
1195
|
}
|
|
575
1196
|
async function toggleFullscreen() {
|
|
1197
|
+
if (fullscreenMode === "dialog") {
|
|
1198
|
+
changeExpanded(!expanded);
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
576
1201
|
try {
|
|
577
|
-
const
|
|
578
|
-
if (!
|
|
1202
|
+
const player2 = root.current;
|
|
1203
|
+
if (!player2?.requestFullscreen)
|
|
579
1204
|
return;
|
|
580
|
-
if (
|
|
581
|
-
await
|
|
1205
|
+
if (player2.ownerDocument.fullscreenElement === player2)
|
|
1206
|
+
await player2.ownerDocument.exitFullscreen();
|
|
582
1207
|
else
|
|
583
|
-
await
|
|
1208
|
+
await player2.requestFullscreen();
|
|
584
1209
|
} catch (error) {
|
|
585
1210
|
onError?.(error);
|
|
586
1211
|
}
|
|
587
1212
|
}
|
|
588
|
-
|
|
1213
|
+
function changeExpanded(next) {
|
|
1214
|
+
if (next)
|
|
1215
|
+
setInlineHeight(root.current?.getBoundingClientRect().height);
|
|
1216
|
+
else
|
|
1217
|
+
restoreFocus.current = true;
|
|
1218
|
+
if (inlineDialog) {
|
|
1219
|
+
setExpanded(next);
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
playbackEpoch.current++;
|
|
1223
|
+
const element = video.current;
|
|
1224
|
+
restore.current = {
|
|
1225
|
+
time: element?.currentTime ?? position.current,
|
|
1226
|
+
playing: element ? !element.paused : state === "playing",
|
|
1227
|
+
state
|
|
1228
|
+
};
|
|
1229
|
+
element?.pause();
|
|
1230
|
+
setExpanded(next);
|
|
1231
|
+
}
|
|
1232
|
+
const fitted = fitContent || expanded && fitExpandedContent;
|
|
1233
|
+
const player = _jsxs8("section", { ref: root, className: "vx-video-player", "aria-label": title, "data-fit": fitted ? "content" : void 0, style: { "--vx-video-ratio": displayRatio }, "data-placement": controlsPlacement, "data-controls-size": controlsSize, "data-state": state, children: [_jsxs8("div", { className: "vx-video-stage", children: [src ? _jsx10("video", { ref: video, src, poster, muted, playsInline: true, preload: "metadata", onResize: (event) => {
|
|
1234
|
+
const { videoWidth, videoHeight } = event.currentTarget;
|
|
1235
|
+
if (videoWidth && videoHeight)
|
|
1236
|
+
setRatio(videoWidth / videoHeight);
|
|
1237
|
+
}, onLoadedMetadata: (event) => {
|
|
1238
|
+
const element = event.currentTarget;
|
|
1239
|
+
const { videoWidth, videoHeight } = element;
|
|
1240
|
+
if (videoWidth && videoHeight)
|
|
1241
|
+
setRatio(videoWidth / videoHeight);
|
|
1242
|
+
const previous = restore.current;
|
|
1243
|
+
if (!previous)
|
|
1244
|
+
return;
|
|
1245
|
+
element.currentTime = Math.min(previous.time, element.duration);
|
|
1246
|
+
updateTime(element.currentTime);
|
|
1247
|
+
restore.current = void 0;
|
|
1248
|
+
if (previous.playing)
|
|
1249
|
+
requestPlay(element, () => changeState("paused"));
|
|
1250
|
+
else
|
|
1251
|
+
changeState(previous.state);
|
|
1252
|
+
}, onDurationChange: (event) => {
|
|
589
1253
|
const value = event.currentTarget.duration;
|
|
590
1254
|
setMetadataDuration(Number.isFinite(value) ? value : 0);
|
|
591
1255
|
}, onPlay: () => changeState("playing"), onPause: (event) => {
|
|
1256
|
+
if (restore.current)
|
|
1257
|
+
return;
|
|
592
1258
|
updateTime(event.currentTarget.currentTime);
|
|
593
1259
|
changeState("paused");
|
|
594
|
-
}, onTimeUpdate: (event) =>
|
|
1260
|
+
}, onTimeUpdate: (event) => {
|
|
1261
|
+
if (!restore.current)
|
|
1262
|
+
updateTime(event.currentTarget.currentTime);
|
|
1263
|
+
}, onEnded, onError: (event) => {
|
|
1264
|
+
if (event.currentTarget.error)
|
|
1265
|
+
onError?.(event.currentTarget.error);
|
|
1266
|
+
} }) : poster && _jsx10("img", { src: poster, alt: "" }), overlay, state === "cover" && !fitted && _jsxs8("div", { className: "vx-video-cover", "data-plain": !showCoverInfo || void 0, children: [showCoverInfo && _jsxs8("div", { className: "vx-video-info", children: [_jsxs8("div", { className: "vx-video-title", children: [_jsx10("strong", { title, children: title }), version && _jsx10(Tag, { children: version })] }), (durationLabel || sceneLabel) && _jsxs8("div", { className: "vx-video-meta", children: [durationLabel && _jsx10("span", { children: durationLabel }), durationLabel && sceneLabel && _jsx10("span", { "aria-hidden": "true", children: "\xB7" }), sceneLabel && _jsx10("span", { children: sceneLabel })] })] }), showCoverPlay && (src || duration > 0) && _jsx10(IconButton, { icon: "play-cover", className: "vx-video-start", label: `Play ${title}`, variant: "icon-circle-lg", onClick: togglePlay })] })] }), _jsx10(PlaybackControls, { playing: state === "playing", muted, time: Math.min(time, duration), duration, disabled: !src && !duration, size: controlsSize, appearance: controlsAppearance, timeDisplay, actions: controlsActions, onTogglePlay: togglePlay, onToggleMute: () => setMuted(!muted), onSeek: seek, onFullscreen: showFullscreen && !(expanded && fitExpandedContent) ? () => void toggleFullscreen() : void 0, fullscreenLabel: fullscreenMode === "dialog" ? expanded ? "Close expanded video" : "Expand video" : void 0 })] });
|
|
1267
|
+
return _jsxs8(_Fragment3, { children: [expanded ? _jsx10("div", { "aria-hidden": "true", style: { height: inlineHeight } }) : !inlineDialog && player, _jsx10(Dialog, { title, open: expanded, onOpenChange: changeExpanded, className: fitExpandedContent ? "vx-video-dialog vx-video-dialog-fit" : "vx-video-dialog", inlineWhenClosed: inlineDialog, children: (expanded || inlineDialog) && player })] });
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// packages/ui-system/dist/duration.js
|
|
1271
|
+
function formatDurationSeconds(durationMs) {
|
|
1272
|
+
return (Math.round(durationMs / 100) / 10).toFixed(1);
|
|
595
1273
|
}
|
|
596
1274
|
|
|
597
1275
|
// packages/media-tools/src/ui/recipe-player.tsx
|
|
@@ -985,6 +1663,23 @@ function VideoEditor({ input, mode, onApply, onClose }) {
|
|
|
985
1663
|
const [ratio, setRatio] = React4.useState("Freeform");
|
|
986
1664
|
const [error, setError] = React4.useState("");
|
|
987
1665
|
const [saving, setSaving] = React4.useState(false);
|
|
1666
|
+
const focusCancel = React4.useCallback((button) => {
|
|
1667
|
+
if (!button) return;
|
|
1668
|
+
let opener;
|
|
1669
|
+
queueMicrotask(() => {
|
|
1670
|
+
const frame = button.ownerDocument.activeElement;
|
|
1671
|
+
if (button.closest("dialog")?.open && frame?.tagName === "IFRAME") {
|
|
1672
|
+
opener = frame.contentDocument?.activeElement;
|
|
1673
|
+
button.focus({ preventScroll: true });
|
|
1674
|
+
}
|
|
1675
|
+
});
|
|
1676
|
+
return () => {
|
|
1677
|
+
const target = opener;
|
|
1678
|
+
target?.ownerDocument.defaultView?.requestAnimationFrame(() => {
|
|
1679
|
+
if (target.isConnected) target.focus({ preventScroll: true });
|
|
1680
|
+
});
|
|
1681
|
+
};
|
|
1682
|
+
}, []);
|
|
988
1683
|
const [reload, setReload] = React4.useState(0);
|
|
989
1684
|
const generation = React4.useRef(0);
|
|
990
1685
|
const edit = React4.useRef(null);
|
|
@@ -1118,6 +1813,7 @@ function VideoEditor({ input, mode, onApply, onClose }) {
|
|
|
1118
1813
|
), /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-confirm" }, /* @__PURE__ */ React4.createElement(
|
|
1119
1814
|
Button,
|
|
1120
1815
|
{
|
|
1816
|
+
ref: focusCancel,
|
|
1121
1817
|
label: "Cancel",
|
|
1122
1818
|
variant: "text-tonal-md",
|
|
1123
1819
|
width: "hug",
|
|
@@ -1136,7 +1832,7 @@ function VideoEditor({ input, mode, onApply, onClose }) {
|
|
|
1136
1832
|
}
|
|
1137
1833
|
)))
|
|
1138
1834
|
},
|
|
1139
|
-
video && draft ? /* @__PURE__ */ React4.createElement("div", {
|
|
1835
|
+
video && draft ? /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-content", inert: saving, "aria-busy": saving }, /* @__PURE__ */ React4.createElement(
|
|
1140
1836
|
RecipePlayer,
|
|
1141
1837
|
{
|
|
1142
1838
|
video,
|
|
@@ -1169,27 +1865,7 @@ function VideoEditor({ input, mode, onApply, onClose }) {
|
|
|
1169
1865
|
}
|
|
1170
1866
|
})
|
|
1171
1867
|
}
|
|
1172
|
-
), filmstrip?.error && /* @__PURE__ */ React4.createElement("p", { className: "mt-help", role: "status" }, filmstrip.error), /* @__PURE__ */ React4.createElement("
|
|
1173
|
-
"input",
|
|
1174
|
-
{
|
|
1175
|
-
type: "number",
|
|
1176
|
-
min: "0",
|
|
1177
|
-
max: video.durationMs / 1e3,
|
|
1178
|
-
step: "0.001",
|
|
1179
|
-
value: draft.trim[edge] / 1e3,
|
|
1180
|
-
disabled: saving,
|
|
1181
|
-
onChange: (event) => {
|
|
1182
|
-
if (Number.isFinite(event.currentTarget.valueAsNumber))
|
|
1183
|
-
change({
|
|
1184
|
-
...draft,
|
|
1185
|
-
trim: {
|
|
1186
|
-
...draft.trim,
|
|
1187
|
-
[edge]: Math.round(event.currentTarget.valueAsNumber * 1e3)
|
|
1188
|
-
}
|
|
1189
|
-
});
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
)))))) : /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-hint" }, /* @__PURE__ */ React4.createElement("span", null, "Drag the frame to move. Drag a corner to resize."), /* @__PURE__ */ React4.createElement("span", { role: "status" }, rect?.width, " \xD7 ", rect?.height)), /* @__PURE__ */ React4.createElement(
|
|
1868
|
+
), filmstrip?.error && /* @__PURE__ */ React4.createElement("p", { className: "mt-help", role: "status" }, filmstrip.error)) : /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", { className: "mt-editor-hint" }, /* @__PURE__ */ React4.createElement("span", null, "Drag the frame to move. Drag a corner to resize."), /* @__PURE__ */ React4.createElement("span", { role: "status" }, rect?.width, " \xD7 ", rect?.height)), /* @__PURE__ */ React4.createElement(
|
|
1193
1869
|
SegmentedControl,
|
|
1194
1870
|
{
|
|
1195
1871
|
label: "Aspect ratio",
|
|
@@ -1199,7 +1875,7 @@ function VideoEditor({ input, mode, onApply, onClose }) {
|
|
|
1199
1875
|
size: "large",
|
|
1200
1876
|
width: "full"
|
|
1201
1877
|
}
|
|
1202
|
-
))) : !error && /* @__PURE__ */ React4.createElement("p", { role: "status" }, "Loading fixed video\u2026"),
|
|
1878
|
+
)), video.colorInterpretation === "assumed-bt709" && /* @__PURE__ */ React4.createElement("p", { className: "mt-help", role: "status" }, "Color information is missing. Standard SDR colors are assumed; export may differ slightly.")) : !error && /* @__PURE__ */ React4.createElement("p", { role: "status" }, "Loading fixed video\u2026"),
|
|
1203
1879
|
error && /* @__PURE__ */ React4.createElement("div", { role: "alert", className: "mt-error" }, error, !video && /* @__PURE__ */ React4.createElement(
|
|
1204
1880
|
Button,
|
|
1205
1881
|
{
|
|
@@ -1212,8 +1888,423 @@ function VideoEditor({ input, mode, onApply, onClose }) {
|
|
|
1212
1888
|
);
|
|
1213
1889
|
}
|
|
1214
1890
|
|
|
1215
|
-
// packages/media-tools/src/ui/
|
|
1891
|
+
// packages/media-tools/src/ui/export-dialog.tsx
|
|
1216
1892
|
import * as React5 from "react";
|
|
1893
|
+
import { useEffect as useEffect7, useRef as useRef7, useState as useState8 } from "react";
|
|
1894
|
+
var defaultSettings = {
|
|
1895
|
+
format: "h264",
|
|
1896
|
+
aspect: "source",
|
|
1897
|
+
resolution: "source",
|
|
1898
|
+
frameRate: "source",
|
|
1899
|
+
quality: "high",
|
|
1900
|
+
audio: true
|
|
1901
|
+
};
|
|
1902
|
+
var terminal = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled", "interrupted"]);
|
|
1903
|
+
function VideoExport({
|
|
1904
|
+
title,
|
|
1905
|
+
preview,
|
|
1906
|
+
canvas: canvas2,
|
|
1907
|
+
issue,
|
|
1908
|
+
legacyTracking,
|
|
1909
|
+
prepare,
|
|
1910
|
+
resolveDownload,
|
|
1911
|
+
onClose
|
|
1912
|
+
}) {
|
|
1913
|
+
const { client, instanceId } = useMediaClient();
|
|
1914
|
+
const storageKey = `studio-video-export:${client.project.id}:${instanceId}`;
|
|
1915
|
+
const [tracking, setTracking] = useState8(() => {
|
|
1916
|
+
try {
|
|
1917
|
+
const raw = localStorage.getItem(storageKey);
|
|
1918
|
+
const stored = raw ? JSON.parse(raw) : legacyTracking;
|
|
1919
|
+
const parsed = mediaRequest.safeParse(stored?.pending?.request);
|
|
1920
|
+
return {
|
|
1921
|
+
jobId: typeof stored?.jobId === "string" ? stored.jobId : void 0,
|
|
1922
|
+
downloadPending: stored?.downloadPending === true,
|
|
1923
|
+
pending: typeof stored?.pending?.key === "string" && parsed.success ? { key: stored.pending.key, request: parsed.data } : void 0,
|
|
1924
|
+
recoverIntent: raw ? void 0 : legacyTracking?.recoverIntent
|
|
1925
|
+
};
|
|
1926
|
+
} catch {
|
|
1927
|
+
return {
|
|
1928
|
+
jobId: void 0,
|
|
1929
|
+
downloadPending: false,
|
|
1930
|
+
pending: void 0,
|
|
1931
|
+
recoverIntent: void 0
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
});
|
|
1935
|
+
const [name, setName] = useState8(title.slice(0, 196));
|
|
1936
|
+
const [settings, setSettings] = useState8(defaultSettings);
|
|
1937
|
+
const [preparedCanvas, setPreparedCanvas] = useState8();
|
|
1938
|
+
const [formats, setFormats] = useState8(["h264"]);
|
|
1939
|
+
const [checking, setChecking] = useState8(!issue);
|
|
1940
|
+
const prepareRef = useRef7(prepare);
|
|
1941
|
+
prepareRef.current = prepare;
|
|
1942
|
+
const source = canvas2 ?? preparedCanvas;
|
|
1943
|
+
const dimensions = source && exportDimensions(source, settings.aspect, settings.resolution);
|
|
1944
|
+
const invalidSize = dimensions === null;
|
|
1945
|
+
const [job, setJob] = useState8();
|
|
1946
|
+
const [error, setError] = useState8("");
|
|
1947
|
+
const [pollError, setPollError] = useState8("");
|
|
1948
|
+
const [busy, setBusy] = useState8(false);
|
|
1949
|
+
const lock = useRef7(false);
|
|
1950
|
+
const dialogContent = useRef7(null);
|
|
1951
|
+
const attemptedDownload = useRef7(void 0);
|
|
1952
|
+
const cancelKey = useRef7(void 0);
|
|
1953
|
+
const { jobId, downloadPending, pending, recoverIntent } = tracking;
|
|
1954
|
+
const unresolved = Boolean(pending || recoverIntent);
|
|
1955
|
+
const active = Boolean(jobId && (!job || !terminal.has(job.state)));
|
|
1956
|
+
const readyToDownload = downloadPending && job?.jobId === jobId && job?.state === "succeeded";
|
|
1957
|
+
useEffect7(() => setName(title.slice(0, 196)), [title]);
|
|
1958
|
+
useEffect7(() => {
|
|
1959
|
+
if (issue) {
|
|
1960
|
+
setChecking(false);
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
let live = true;
|
|
1964
|
+
setChecking(true);
|
|
1965
|
+
void (async () => {
|
|
1966
|
+
try {
|
|
1967
|
+
if (!canvas2) {
|
|
1968
|
+
try {
|
|
1969
|
+
const input = await prepareRef.current();
|
|
1970
|
+
if (live) setPreparedCanvas(input.canvas);
|
|
1971
|
+
} catch {
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
if (!live) return;
|
|
1975
|
+
const result = await client.invoke(
|
|
1976
|
+
{ instanceId, operationId: "export.capabilities" },
|
|
1977
|
+
{}
|
|
1978
|
+
);
|
|
1979
|
+
const player = document.createElement("video");
|
|
1980
|
+
if (live)
|
|
1981
|
+
setFormats(
|
|
1982
|
+
result.formats.filter(
|
|
1983
|
+
(format) => format === "h264" || Boolean(
|
|
1984
|
+
player.canPlayType(
|
|
1985
|
+
format === "hevc" ? 'video/mp4; codecs="hvc1.1.6.L93.B0"' : 'video/webm; codecs="vp9, opus"'
|
|
1986
|
+
)
|
|
1987
|
+
)
|
|
1988
|
+
)
|
|
1989
|
+
);
|
|
1990
|
+
} catch {
|
|
1991
|
+
} finally {
|
|
1992
|
+
if (live) setChecking(false);
|
|
1993
|
+
}
|
|
1994
|
+
})();
|
|
1995
|
+
return () => {
|
|
1996
|
+
live = false;
|
|
1997
|
+
};
|
|
1998
|
+
}, [canvas2?.width, canvas2?.height, client, instanceId, issue, title]);
|
|
1999
|
+
useEffect7(() => {
|
|
2000
|
+
if (!jobId || job && job.jobId === jobId && terminal.has(job.state)) return;
|
|
2001
|
+
let live = true;
|
|
2002
|
+
let timer;
|
|
2003
|
+
async function poll(id) {
|
|
2004
|
+
try {
|
|
2005
|
+
const result = await client.invoke(
|
|
2006
|
+
{ instanceId, operationId: "jobs.get" },
|
|
2007
|
+
{ jobId: id }
|
|
2008
|
+
);
|
|
2009
|
+
if (!live) return;
|
|
2010
|
+
updateJob(result);
|
|
2011
|
+
setPollError("");
|
|
2012
|
+
if (terminal.has(result.state)) return;
|
|
2013
|
+
} catch (error2) {
|
|
2014
|
+
if (live) setPollError(readableError(error2));
|
|
2015
|
+
}
|
|
2016
|
+
if (live) timer = setTimeout(() => void poll(id), 750);
|
|
2017
|
+
}
|
|
2018
|
+
void poll(jobId);
|
|
2019
|
+
return () => {
|
|
2020
|
+
live = false;
|
|
2021
|
+
clearTimeout(timer);
|
|
2022
|
+
};
|
|
2023
|
+
}, [client, instanceId, jobId, job?.state]);
|
|
2024
|
+
function updateJob(result) {
|
|
2025
|
+
setJob(
|
|
2026
|
+
(current) => current?.jobId === result.jobId && current.revision > result.revision ? current : result
|
|
2027
|
+
);
|
|
2028
|
+
}
|
|
2029
|
+
function track(next) {
|
|
2030
|
+
try {
|
|
2031
|
+
localStorage.setItem(storageKey, JSON.stringify(next));
|
|
2032
|
+
} catch {
|
|
2033
|
+
}
|
|
2034
|
+
setTracking({ ...next, recoverIntent: void 0 });
|
|
2035
|
+
}
|
|
2036
|
+
async function act(run) {
|
|
2037
|
+
if (lock.current) return;
|
|
2038
|
+
lock.current = true;
|
|
2039
|
+
setBusy(true);
|
|
2040
|
+
setError("");
|
|
2041
|
+
try {
|
|
2042
|
+
await run();
|
|
2043
|
+
} catch (error2) {
|
|
2044
|
+
setError(readableError(error2));
|
|
2045
|
+
} finally {
|
|
2046
|
+
lock.current = false;
|
|
2047
|
+
setBusy(false);
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
async function download(result) {
|
|
2051
|
+
const doc = dialogContent.current?.ownerDocument;
|
|
2052
|
+
if (!doc || !result.result) throw Error("The exported video is unavailable.");
|
|
2053
|
+
const url = await resolveDownload(result.result);
|
|
2054
|
+
if (!url) throw Error("The exported video is unavailable.");
|
|
2055
|
+
const link = doc.createElement("a");
|
|
2056
|
+
link.href = url;
|
|
2057
|
+
link.download = result.outputName;
|
|
2058
|
+
link.click();
|
|
2059
|
+
track({ jobId: void 0, downloadPending: false, pending: void 0 });
|
|
2060
|
+
onClose();
|
|
2061
|
+
}
|
|
2062
|
+
useEffect7(() => {
|
|
2063
|
+
if (!readyToDownload || !job || busy || unresolved || attemptedDownload.current === job.jobId)
|
|
2064
|
+
return;
|
|
2065
|
+
attemptedDownload.current = job.jobId;
|
|
2066
|
+
void act(() => download(job));
|
|
2067
|
+
}, [readyToDownload, job, busy, unresolved]);
|
|
2068
|
+
async function submit(intent) {
|
|
2069
|
+
track({ jobId, downloadPending, pending: intent });
|
|
2070
|
+
try {
|
|
2071
|
+
const result = await client.invoke(
|
|
2072
|
+
{ instanceId, operationId: intent.request.operation },
|
|
2073
|
+
intent.request.input,
|
|
2074
|
+
{ requestKey: intent.key }
|
|
2075
|
+
);
|
|
2076
|
+
setJob(void 0);
|
|
2077
|
+
track({ jobId: result.jobId, downloadPending: true, pending: void 0 });
|
|
2078
|
+
} catch (error2) {
|
|
2079
|
+
const code = error2 && typeof error2 === "object" && "code" in error2 ? error2.code : void 0;
|
|
2080
|
+
if (typeof code === "string" && !["EXECUTION_UNKNOWN", "OPERATION_CONTRACT_CHANGED", "TRANSPORT_UNKNOWN"].includes(code))
|
|
2081
|
+
track({ jobId, downloadPending, pending: void 0 });
|
|
2082
|
+
throw error2;
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
async function findOriginal() {
|
|
2086
|
+
const original = pending ?? await recoverIntent?.();
|
|
2087
|
+
if (!original) return;
|
|
2088
|
+
const found = await client.invoke(
|
|
2089
|
+
{ instanceId, operationId: "jobs.list" },
|
|
2090
|
+
{
|
|
2091
|
+
request: {
|
|
2092
|
+
operation: original.request.operation,
|
|
2093
|
+
requestKey: original.key,
|
|
2094
|
+
intent: original.request.input
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
);
|
|
2098
|
+
if (!found.items[0]) throw Error("No accepted export was found. No new task was submitted.");
|
|
2099
|
+
updateJob(found.items[0]);
|
|
2100
|
+
track({ jobId: found.items[0].jobId, downloadPending: true, pending: void 0 });
|
|
2101
|
+
}
|
|
2102
|
+
async function exportVideo() {
|
|
2103
|
+
const outputName2 = exportName(name, exportProfiles[settings.format].extension);
|
|
2104
|
+
const input = await prepare();
|
|
2105
|
+
if (!exportDimensions(input.canvas, settings.aspect, settings.resolution))
|
|
2106
|
+
throw Error("Choose a smaller resolution for this aspect ratio.");
|
|
2107
|
+
await submit({
|
|
2108
|
+
key: crypto.randomUUID(),
|
|
2109
|
+
request: { operation: "sequence.process", input: { ...input, outputName: outputName2, settings } }
|
|
2110
|
+
});
|
|
2111
|
+
}
|
|
2112
|
+
function update(key, value) {
|
|
2113
|
+
setSettings((current) => ({ ...current, [key]: value }));
|
|
2114
|
+
}
|
|
2115
|
+
const fields = [
|
|
2116
|
+
{
|
|
2117
|
+
label: "Format",
|
|
2118
|
+
value: settings.format,
|
|
2119
|
+
change: (value) => update("format", value),
|
|
2120
|
+
options: Object.keys(exportProfiles).map((value) => ({
|
|
2121
|
+
value,
|
|
2122
|
+
label: exportProfiles[value].label + (formats.includes(value) ? "" : " (Unavailable)"),
|
|
2123
|
+
disabled: !formats.includes(value)
|
|
2124
|
+
}))
|
|
2125
|
+
},
|
|
2126
|
+
{
|
|
2127
|
+
label: "Aspect ratio",
|
|
2128
|
+
value: settings.aspect,
|
|
2129
|
+
change: (value) => update("aspect", value),
|
|
2130
|
+
options: exportAspects.map((value) => {
|
|
2131
|
+
if (value === "source") return { value, label: "Match source" };
|
|
2132
|
+
const [width, height] = value.split(":").map(Number);
|
|
2133
|
+
return {
|
|
2134
|
+
value,
|
|
2135
|
+
label: value,
|
|
2136
|
+
icon: /* @__PURE__ */ React5.createElement("span", { className: "mt-export-ratio-icon", "aria-hidden": "true" }, /* @__PURE__ */ React5.createElement(
|
|
2137
|
+
"span",
|
|
2138
|
+
{
|
|
2139
|
+
style: {
|
|
2140
|
+
width: 14 * Math.min(1, width / height),
|
|
2141
|
+
height: 14 * Math.min(1, height / width)
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
))
|
|
2145
|
+
};
|
|
2146
|
+
})
|
|
2147
|
+
},
|
|
2148
|
+
{
|
|
2149
|
+
label: "Resolution",
|
|
2150
|
+
value: String(settings.resolution),
|
|
2151
|
+
change: (value) => update(
|
|
2152
|
+
"resolution",
|
|
2153
|
+
value === "source" ? value : Number(value)
|
|
2154
|
+
),
|
|
2155
|
+
options: ["source", ...exportResolutions].map((value) => {
|
|
2156
|
+
const size = source && exportDimensions(source, settings.aspect, value);
|
|
2157
|
+
const label = value === "source" ? "Match source" : `${value}p`;
|
|
2158
|
+
return {
|
|
2159
|
+
value: String(value),
|
|
2160
|
+
label: size ? `${label} \xB7 ${size.width} \xD7 ${size.height}` : label,
|
|
2161
|
+
triggerLabel: label,
|
|
2162
|
+
disabled: size === null
|
|
2163
|
+
};
|
|
2164
|
+
})
|
|
2165
|
+
},
|
|
2166
|
+
{
|
|
2167
|
+
label: "Frame rate",
|
|
2168
|
+
value: String(settings.frameRate),
|
|
2169
|
+
change: (value) => update(
|
|
2170
|
+
"frameRate",
|
|
2171
|
+
value === "source" ? value : Number(value)
|
|
2172
|
+
),
|
|
2173
|
+
options: [
|
|
2174
|
+
{ value: "source", label: "Match source" },
|
|
2175
|
+
...exportRates.map((fps) => ({ value: String(fps), label: `${fps}fps` }))
|
|
2176
|
+
]
|
|
2177
|
+
},
|
|
2178
|
+
{
|
|
2179
|
+
label: "Quality",
|
|
2180
|
+
value: settings.quality,
|
|
2181
|
+
change: (value) => update("quality", value),
|
|
2182
|
+
options: [
|
|
2183
|
+
{ value: "high", label: "High" },
|
|
2184
|
+
{ value: "standard", label: "Standard" },
|
|
2185
|
+
{ value: "small", label: "Small file" }
|
|
2186
|
+
]
|
|
2187
|
+
},
|
|
2188
|
+
{
|
|
2189
|
+
label: "Audio",
|
|
2190
|
+
value: String(settings.audio),
|
|
2191
|
+
change: (value) => update("audio", value === "true"),
|
|
2192
|
+
options: [
|
|
2193
|
+
{ value: "true", label: "Include audio" },
|
|
2194
|
+
{ value: "false", label: "No audio" }
|
|
2195
|
+
]
|
|
2196
|
+
}
|
|
2197
|
+
];
|
|
2198
|
+
const ratio = dimensions ? dimensions.width / dimensions.height : settings.aspect !== "source" ? Number(settings.aspect.split(":")[0]) / Number(settings.aspect.split(":")[1]) : void 0;
|
|
2199
|
+
const previewStyle = ratio && settings.aspect !== "source" ? {
|
|
2200
|
+
"--mt-export-frame-width": `${Math.min(1, ratio / (16 / 9)) * 100}%`,
|
|
2201
|
+
"--mt-export-frame-height": `${Math.min(1, 16 / 9 / ratio) * 100}%`
|
|
2202
|
+
} : void 0;
|
|
2203
|
+
return /* @__PURE__ */ React5.createElement(
|
|
2204
|
+
Dialog,
|
|
2205
|
+
{
|
|
2206
|
+
open: true,
|
|
2207
|
+
title: "Export Settings",
|
|
2208
|
+
className: "mt-export-dialog",
|
|
2209
|
+
onOpenChange: (open) => {
|
|
2210
|
+
if (!open && !lock.current) onClose();
|
|
2211
|
+
},
|
|
2212
|
+
actions: /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
|
|
2213
|
+
Button,
|
|
2214
|
+
{
|
|
2215
|
+
label: "Cancel",
|
|
2216
|
+
variant: "text-tonal-lg",
|
|
2217
|
+
width: "hug",
|
|
2218
|
+
onClick: onClose,
|
|
2219
|
+
disabled: busy
|
|
2220
|
+
}
|
|
2221
|
+
), /* @__PURE__ */ React5.createElement(
|
|
2222
|
+
Button,
|
|
2223
|
+
{
|
|
2224
|
+
label: "Export",
|
|
2225
|
+
variant: "text-filled-lg",
|
|
2226
|
+
width: "hug",
|
|
2227
|
+
disabled: busy || active || unresolved || !readyToDownload && (checking || invalidSize || Boolean(issue) || exportName(name, "mp4") === ".mp4"),
|
|
2228
|
+
onClick: () => void act(() => readyToDownload && job ? download(job) : exportVideo())
|
|
2229
|
+
}
|
|
2230
|
+
))
|
|
2231
|
+
},
|
|
2232
|
+
/* @__PURE__ */ React5.createElement("div", { className: "mt-export-layout", ref: dialogContent }, /* @__PURE__ */ React5.createElement("div", { className: "mt-export-preview", style: previewStyle }, preview), /* @__PURE__ */ React5.createElement("div", { className: "mt-export-options" }, /* @__PURE__ */ React5.createElement(
|
|
2233
|
+
TextInput,
|
|
2234
|
+
{
|
|
2235
|
+
placeholder: "Enter a title for the exported video",
|
|
2236
|
+
label: "Title",
|
|
2237
|
+
maxLength: 196,
|
|
2238
|
+
value: name,
|
|
2239
|
+
onValueChange: setName,
|
|
2240
|
+
disabled: busy
|
|
2241
|
+
}
|
|
2242
|
+
), /* @__PURE__ */ React5.createElement("dl", null, fields.map(({ label, value, options, change }) => /* @__PURE__ */ React5.createElement("div", { key: label }, /* @__PURE__ */ React5.createElement("dt", null, label), /* @__PURE__ */ React5.createElement("dd", null, /* @__PURE__ */ React5.createElement(
|
|
2243
|
+
Dropdown,
|
|
2244
|
+
{
|
|
2245
|
+
label,
|
|
2246
|
+
value,
|
|
2247
|
+
options,
|
|
2248
|
+
onValueChange: change,
|
|
2249
|
+
appearance: "field",
|
|
2250
|
+
floating: true,
|
|
2251
|
+
disabled: busy || active || unresolved || label === "Format" && checking
|
|
2252
|
+
}
|
|
2253
|
+
))))))),
|
|
2254
|
+
invalidSize && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-notice", role: "status" }, "Choose a smaller resolution for this aspect ratio."),
|
|
2255
|
+
issue && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-notice" }, issue),
|
|
2256
|
+
busy && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-notice", role: "status" }, "Working\u2026"),
|
|
2257
|
+
unresolved && !busy && /* @__PURE__ */ React5.createElement("div", { className: "mt-export-status" }, "Export outcome has not been confirmed.", /* @__PURE__ */ React5.createElement(
|
|
2258
|
+
Button,
|
|
2259
|
+
{
|
|
2260
|
+
label: "Find original export",
|
|
2261
|
+
variant: "text-ghost-sm",
|
|
2262
|
+
onClick: () => void act(findOriginal)
|
|
2263
|
+
}
|
|
2264
|
+
)),
|
|
2265
|
+
job && job.state !== "succeeded" && !unresolved && /* @__PURE__ */ React5.createElement("div", { className: "mt-export-status" }, /* @__PURE__ */ React5.createElement("span", { role: "status" }, "Export: ", job.state, active && job.progress != null ? ` \xB7 ${Math.min(99, Math.round(job.progress * 100))}%` : ""), active && /* @__PURE__ */ React5.createElement(
|
|
2266
|
+
Button,
|
|
2267
|
+
{
|
|
2268
|
+
label: "Cancel export",
|
|
2269
|
+
variant: "text-ghost-sm",
|
|
2270
|
+
disabled: busy || job.cancelRequested,
|
|
2271
|
+
onClick: () => void act(async () => {
|
|
2272
|
+
if (cancelKey.current?.jobId !== job.jobId)
|
|
2273
|
+
cancelKey.current = { jobId: job.jobId, key: crypto.randomUUID() };
|
|
2274
|
+
updateJob(
|
|
2275
|
+
await client.invoke(
|
|
2276
|
+
{ instanceId, operationId: "jobs.cancel" },
|
|
2277
|
+
{ jobId: job.jobId },
|
|
2278
|
+
{ requestKey: cancelKey.current.key }
|
|
2279
|
+
)
|
|
2280
|
+
);
|
|
2281
|
+
})
|
|
2282
|
+
}
|
|
2283
|
+
), !active && /* @__PURE__ */ React5.createElement(
|
|
2284
|
+
Button,
|
|
2285
|
+
{
|
|
2286
|
+
label: "Retry export",
|
|
2287
|
+
variant: "text-ghost-sm",
|
|
2288
|
+
disabled: busy || job.cleanupPending,
|
|
2289
|
+
onClick: () => void act(() => submit({ key: crypto.randomUUID(), request: job.retryRequest }))
|
|
2290
|
+
}
|
|
2291
|
+
), job.error && /* @__PURE__ */ React5.createElement("span", { className: "mt-export-error", role: "alert" }, job.error.message)),
|
|
2292
|
+
(error || pollError) && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-error", role: "alert" }, error || pollError)
|
|
2293
|
+
);
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
// packages/media-tools/src/ui/compare.tsx
|
|
2297
|
+
import * as React6 from "react";
|
|
2298
|
+
function inputKey(input) {
|
|
2299
|
+
const ref = input.kind === "source" ? input.file.source : input.editRef;
|
|
2300
|
+
return JSON.stringify([
|
|
2301
|
+
input.kind,
|
|
2302
|
+
ref.storeId,
|
|
2303
|
+
ref.objectId,
|
|
2304
|
+
ref.versionId,
|
|
2305
|
+
input.kind === "source" ? input.file.fileId : null
|
|
2306
|
+
]);
|
|
2307
|
+
}
|
|
1217
2308
|
function formatLabel(width, height) {
|
|
1218
2309
|
let a = width, b = height;
|
|
1219
2310
|
while (b) {
|
|
@@ -1231,11 +2322,12 @@ function Candidate({
|
|
|
1231
2322
|
emptyState
|
|
1232
2323
|
}) {
|
|
1233
2324
|
const { resolve } = useMediaClient();
|
|
1234
|
-
const [video, setVideo] =
|
|
1235
|
-
const [error, setError] =
|
|
1236
|
-
const [revision, setRevision] =
|
|
2325
|
+
const [video, setVideo] = React6.useState(null);
|
|
2326
|
+
const [error, setError] = React6.useState("");
|
|
2327
|
+
const [revision, setRevision] = React6.useState(0);
|
|
2328
|
+
const title = slot.context?.shotName?.trim() || video?.name || "Video";
|
|
1237
2329
|
const identity = JSON.stringify(slot.input);
|
|
1238
|
-
|
|
2330
|
+
React6.useEffect(() => {
|
|
1239
2331
|
let active = true;
|
|
1240
2332
|
setVideo(null);
|
|
1241
2333
|
setError("");
|
|
@@ -1249,15 +2341,15 @@ function Candidate({
|
|
|
1249
2341
|
active = false;
|
|
1250
2342
|
};
|
|
1251
2343
|
}, [resolve, identity, revision]);
|
|
1252
|
-
return /* @__PURE__ */
|
|
2344
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("div", { className: "mt-compare-preview" }, replacing ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "status" }, "Choosing replacement\u2026") : !slot.input ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty" }, /* @__PURE__ */ React6.createElement("p", null, "No video selected."), emptyState ?? /* @__PURE__ */ React6.createElement(
|
|
1253
2345
|
Button,
|
|
1254
2346
|
{
|
|
1255
|
-
label: "
|
|
1256
|
-
variant: "text-
|
|
2347
|
+
label: "Select a shot",
|
|
2348
|
+
variant: "text-plain-sm",
|
|
1257
2349
|
width: "hug",
|
|
1258
2350
|
onClick: onChoose
|
|
1259
2351
|
}
|
|
1260
|
-
))
|
|
2352
|
+
)) : error ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "alert" }, /* @__PURE__ */ React6.createElement("p", null, error), /* @__PURE__ */ React6.createElement(
|
|
1261
2353
|
Button,
|
|
1262
2354
|
{
|
|
1263
2355
|
label: "Reload preview",
|
|
@@ -1265,29 +2357,30 @@ function Candidate({
|
|
|
1265
2357
|
width: "hug",
|
|
1266
2358
|
onClick: () => setRevision(revision + 1)
|
|
1267
2359
|
}
|
|
1268
|
-
)) : !video ? /* @__PURE__ */
|
|
2360
|
+
)) : !video ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "status" }, "Loading fixed video\u2026") : video.edited ? /* @__PURE__ */ React6.createElement(RecipePlayer, { video }) : /* @__PURE__ */ React6.createElement(
|
|
1269
2361
|
VideoPlayer,
|
|
1270
2362
|
{
|
|
1271
2363
|
src: video.previewUrl,
|
|
1272
|
-
title
|
|
1273
|
-
|
|
2364
|
+
title,
|
|
2365
|
+
showCoverInfo: false,
|
|
2366
|
+
controlsPlacement: "overlay",
|
|
1274
2367
|
onError: () => setError("This video could not be played. Reload its fixed preview.")
|
|
1275
2368
|
}
|
|
1276
|
-
)), /* @__PURE__ */
|
|
2369
|
+
)), /* @__PURE__ */ React6.createElement("div", { className: "mt-candidate-caption" }, /* @__PURE__ */ React6.createElement("div", { className: "mt-candidate-heading" }, /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("strong", null, slot.input ? title : "Candidate"), video && /* @__PURE__ */ React6.createElement("span", null, "Variant ", video.versionNumber, video.edited ? " \xB7 Edited" : "")), menu), video?.colorInterpretation === "assumed-bt709" && /* @__PURE__ */ React6.createElement("span", null, "Color information is missing. Standard SDR colors are assumed; export may differ slightly.")), /* @__PURE__ */ React6.createElement("div", { className: "mt-candidate-context" }, slot.input && (video || slot.context?.spokenLine || slot.context?.hook || slot.context?.cta) && /* @__PURE__ */ React6.createElement("dl", null, slot.context?.spokenLine && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "Spoken line"), /* @__PURE__ */ React6.createElement("dd", null, slot.context.spokenLine)), slot.context?.hook && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "Opening Hook"), /* @__PURE__ */ React6.createElement("dd", null, slot.context.hook)), slot.context && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "CTA"), /* @__PURE__ */ React6.createElement("dd", null, slot.context.cta || "None")), video && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "Format"), /* @__PURE__ */ React6.createElement("dd", null, formatLabel(video.geometry.pixelRect.width, video.geometry.pixelRect.height)), /* @__PURE__ */ React6.createElement("dt", null, "Duration"), /* @__PURE__ */ React6.createElement("dd", null, formatDurationSeconds(video.effectiveDurationMs), "s")))));
|
|
1277
2370
|
}
|
|
1278
2371
|
function VideoCompare(props) {
|
|
1279
|
-
const [generation, setGeneration] =
|
|
1280
|
-
const [replacing, setReplacing] =
|
|
1281
|
-
const [error, setError] =
|
|
1282
|
-
const active =
|
|
1283
|
-
|
|
2372
|
+
const [generation, setGeneration] = React6.useState(0);
|
|
2373
|
+
const [replacing, setReplacing] = React6.useState(null);
|
|
2374
|
+
const [error, setError] = React6.useState("");
|
|
2375
|
+
const active = React6.useRef(true);
|
|
2376
|
+
React6.useEffect(() => {
|
|
1284
2377
|
active.current = true;
|
|
1285
2378
|
return () => {
|
|
1286
2379
|
active.current = false;
|
|
1287
2380
|
};
|
|
1288
2381
|
}, []);
|
|
1289
2382
|
if (props.slots.length < 2 || props.slots.length > 4 || new Set(props.slots.map((slot) => slot.id)).size !== props.slots.length)
|
|
1290
|
-
return /* @__PURE__ */
|
|
2383
|
+
return /* @__PURE__ */ React6.createElement("p", { role: "alert" }, "Compare requires two to four uniquely identified columns.");
|
|
1291
2384
|
const remove = (slot) => props.onSlotsChange(
|
|
1292
2385
|
props.slots.length > 2 ? props.slots.filter((value) => value.id !== slot.id) : props.slots.map((value) => value.id === slot.id ? { ...value, input: null } : value)
|
|
1293
2386
|
);
|
|
@@ -1307,90 +2400,118 @@ function VideoCompare(props) {
|
|
|
1307
2400
|
if (active.current) setReplacing(null);
|
|
1308
2401
|
}
|
|
1309
2402
|
}
|
|
2403
|
+
const slotKeys = props.slots.map(({ input }) => input && inputKey(input));
|
|
1310
2404
|
function candidateChoices(slot) {
|
|
1311
|
-
return (props.candidates || []).
|
|
1312
|
-
(candidate)
|
|
1313
|
-
|
|
1314
|
-
)
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
2405
|
+
return (props.candidates || []).flatMap((candidate) => {
|
|
2406
|
+
const key = inputKey(candidate.input);
|
|
2407
|
+
const occupied = props.slots[slotKeys.indexOf(key)];
|
|
2408
|
+
if (occupied && (props.allowCandidateSwap ? occupied.id === slot.id : occupied.id !== slot.id))
|
|
2409
|
+
return [];
|
|
2410
|
+
return [
|
|
2411
|
+
{
|
|
2412
|
+
id: key,
|
|
2413
|
+
label: props.allowCandidateSwap && occupied ? "Swap with " + candidate.label : candidate.label,
|
|
2414
|
+
preview: candidate.preview,
|
|
2415
|
+
onSelect: () => props.onSlotsChange(
|
|
2416
|
+
props.slots.map((column) => {
|
|
2417
|
+
if (column.id === slot.id)
|
|
2418
|
+
return { ...column, input: candidate.input, context: candidate.context };
|
|
2419
|
+
if (column.id === occupied?.id)
|
|
2420
|
+
return { ...column, input: slot.input, context: slot.context };
|
|
2421
|
+
return column;
|
|
2422
|
+
})
|
|
2423
|
+
)
|
|
2424
|
+
}
|
|
2425
|
+
];
|
|
2426
|
+
});
|
|
1324
2427
|
}
|
|
1325
|
-
return /* @__PURE__ */
|
|
1326
|
-
Button,
|
|
1327
|
-
{
|
|
1328
|
-
label: "Add column",
|
|
1329
|
-
width: "hug",
|
|
1330
|
-
variant: "text-tonal-sm",
|
|
1331
|
-
disabled: props.slots.length >= 4,
|
|
1332
|
-
onClick: () => props.onSlotsChange([...props.slots, { id: crypto.randomUUID(), input: null }])
|
|
1333
|
-
}
|
|
1334
|
-
)), error && /* @__PURE__ */ React5.createElement("p", { role: "alert", className: "mt-error" }, error), /* @__PURE__ */ React5.createElement(
|
|
2428
|
+
return /* @__PURE__ */ React6.createElement("section", { className: "mt-compare", "aria-label": "Compare videos" }, error && /* @__PURE__ */ React6.createElement("p", { role: "alert", className: "mt-error" }, error), /* @__PURE__ */ React6.createElement(
|
|
1335
2429
|
"div",
|
|
1336
2430
|
{
|
|
1337
2431
|
className: "mt-compare-columns",
|
|
1338
2432
|
style: { gridTemplateColumns: `repeat(${props.slots.length}, minmax(240px,1fr))` }
|
|
1339
2433
|
},
|
|
1340
|
-
props.slots.map((slot, index) =>
|
|
1341
|
-
|
|
1342
|
-
{
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
2434
|
+
props.slots.map((slot, index) => {
|
|
2435
|
+
const replacements = candidateChoices(slot);
|
|
2436
|
+
return /* @__PURE__ */ React6.createElement("article", { className: "mt-compare-column", key: slot.id, "aria-label": `Video ${index + 1}` }, /* @__PURE__ */ React6.createElement(
|
|
2437
|
+
Candidate,
|
|
2438
|
+
{
|
|
2439
|
+
key: JSON.stringify([slot.id, slot.input, generation]),
|
|
2440
|
+
slot,
|
|
2441
|
+
replacing: replacing === slot.id,
|
|
2442
|
+
onChoose: () => void replace(slot),
|
|
2443
|
+
emptyState: props.candidates ? replacements.length || props.allowCandidateSwap ? /* @__PURE__ */ React6.createElement(
|
|
2444
|
+
Menu,
|
|
2445
|
+
{
|
|
2446
|
+
label: "Select a shot",
|
|
2447
|
+
textTrigger: "plain",
|
|
2448
|
+
floating: true,
|
|
2449
|
+
items: replacements
|
|
2450
|
+
}
|
|
2451
|
+
) : /* @__PURE__ */ React6.createElement("p", null, "No other candidates yet.") : void 0,
|
|
2452
|
+
menu: /* @__PURE__ */ React6.createElement(
|
|
2453
|
+
Menu,
|
|
2454
|
+
{
|
|
2455
|
+
label: `Options for video ${index + 1}`,
|
|
2456
|
+
triggerIcon: "more",
|
|
2457
|
+
cascading: props.allowCandidateSwap,
|
|
2458
|
+
floating: true,
|
|
2459
|
+
items: [
|
|
2460
|
+
...props.slotMenuItems?.(slot) ?? [],
|
|
2461
|
+
...props.candidates ? [
|
|
2462
|
+
{
|
|
2463
|
+
id: "replace",
|
|
2464
|
+
label: "Choose video",
|
|
2465
|
+
disabled: replacements.length === 0,
|
|
2466
|
+
items: replacements
|
|
2467
|
+
}
|
|
2468
|
+
] : [
|
|
2469
|
+
{
|
|
2470
|
+
id: "replace",
|
|
2471
|
+
label: slot.input ? "Replace" : "Choose video",
|
|
2472
|
+
disabled: replacing !== null,
|
|
2473
|
+
onSelect: () => void replace(slot)
|
|
2474
|
+
}
|
|
2475
|
+
],
|
|
2476
|
+
...slot.input ? [
|
|
2477
|
+
{
|
|
2478
|
+
id: "details",
|
|
2479
|
+
label: "Details",
|
|
2480
|
+
onSelect: () => {
|
|
2481
|
+
setGeneration((value) => value + 1);
|
|
2482
|
+
props.onOpenDetails(slot.input, {
|
|
2483
|
+
slots: props.slots,
|
|
2484
|
+
origin: props.origin
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
] : [],
|
|
1363
2489
|
{
|
|
1364
|
-
id: "
|
|
1365
|
-
label:
|
|
1366
|
-
disabled:
|
|
1367
|
-
onSelect: () =>
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
2490
|
+
id: "add-column",
|
|
2491
|
+
label: "Add column",
|
|
2492
|
+
disabled: props.slots.length >= 4,
|
|
2493
|
+
onSelect: () => props.onSlotsChange([
|
|
2494
|
+
...props.slots,
|
|
2495
|
+
{ id: crypto.randomUUID(), input: null }
|
|
2496
|
+
])
|
|
2497
|
+
},
|
|
1371
2498
|
{
|
|
1372
|
-
id: "
|
|
1373
|
-
label: "
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
props.onOpenDetails(slot.input, {
|
|
1377
|
-
slots: props.slots,
|
|
1378
|
-
origin: props.origin
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
2499
|
+
id: "remove",
|
|
2500
|
+
label: "Remove",
|
|
2501
|
+
tone: "danger",
|
|
2502
|
+
onSelect: () => remove(slot)
|
|
1381
2503
|
}
|
|
1382
|
-
]
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
), slot.input && props.renderSlotActions && /* @__PURE__ */ React5.createElement("div", { className: "mt-column-actions" }, props.renderSlotActions(slot))))
|
|
2504
|
+
]
|
|
2505
|
+
}
|
|
2506
|
+
)
|
|
2507
|
+
}
|
|
2508
|
+
), slot.input && props.renderSlotActions && /* @__PURE__ */ React6.createElement("div", { className: "mt-column-actions" }, props.renderSlotActions(slot)));
|
|
2509
|
+
})
|
|
1389
2510
|
));
|
|
1390
2511
|
}
|
|
1391
2512
|
|
|
1392
2513
|
// packages/media-tools/src/ui/jobs.tsx
|
|
1393
|
-
import * as
|
|
2514
|
+
import * as React7 from "react";
|
|
1394
2515
|
var labels = {
|
|
1395
2516
|
queued: "Queued",
|
|
1396
2517
|
running: "Processing",
|
|
@@ -1402,20 +2523,20 @@ var labels = {
|
|
|
1402
2523
|
};
|
|
1403
2524
|
function MediaJobs({ onOpenResult }) {
|
|
1404
2525
|
const { client, instanceId } = useMediaClient();
|
|
1405
|
-
const [page, setPage] =
|
|
1406
|
-
const [offset, setOffset] =
|
|
1407
|
-
const [refresh, setRefresh] =
|
|
1408
|
-
const [error, setError] =
|
|
1409
|
-
const [pending, setPending] =
|
|
1410
|
-
const keys =
|
|
1411
|
-
const live =
|
|
1412
|
-
|
|
2526
|
+
const [page, setPage] = React7.useState({ items: [], nextOffset: null });
|
|
2527
|
+
const [offset, setOffset] = React7.useState(0);
|
|
2528
|
+
const [refresh, setRefresh] = React7.useState(0);
|
|
2529
|
+
const [error, setError] = React7.useState("");
|
|
2530
|
+
const [pending, setPending] = React7.useState(null);
|
|
2531
|
+
const keys = React7.useRef(/* @__PURE__ */ new Map());
|
|
2532
|
+
const live = React7.useRef(true);
|
|
2533
|
+
React7.useEffect(() => {
|
|
1413
2534
|
live.current = true;
|
|
1414
2535
|
return () => {
|
|
1415
2536
|
live.current = false;
|
|
1416
2537
|
};
|
|
1417
2538
|
}, []);
|
|
1418
|
-
|
|
2539
|
+
React7.useEffect(() => {
|
|
1419
2540
|
let active = true, timer;
|
|
1420
2541
|
async function poll() {
|
|
1421
2542
|
try {
|
|
@@ -1465,7 +2586,7 @@ function MediaJobs({ onOpenResult }) {
|
|
|
1465
2586
|
if (live.current) setPending(null);
|
|
1466
2587
|
}
|
|
1467
2588
|
}
|
|
1468
|
-
return /* @__PURE__ */
|
|
2589
|
+
return /* @__PURE__ */ React7.createElement("section", { className: "mt-jobs", "aria-label": "Media tasks" }, /* @__PURE__ */ React7.createElement("div", { className: "mt-toolbar" }, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement("h2", null, "Media tasks"), /* @__PURE__ */ React7.createElement("p", { className: "mt-help" }, "Processing continues when this page closes.")), /* @__PURE__ */ React7.createElement(
|
|
1469
2590
|
Button,
|
|
1470
2591
|
{
|
|
1471
2592
|
label: "Refresh tasks",
|
|
@@ -1473,14 +2594,14 @@ function MediaJobs({ onOpenResult }) {
|
|
|
1473
2594
|
width: "hug",
|
|
1474
2595
|
onClick: () => setRefresh(refresh + 1)
|
|
1475
2596
|
}
|
|
1476
|
-
)), error && /* @__PURE__ */
|
|
2597
|
+
)), error && /* @__PURE__ */ React7.createElement("p", { role: "alert", className: "mt-error" }, error), !page.items.length && /* @__PURE__ */ React7.createElement("p", { className: "mt-empty" }, "No media tasks on this page."), page.items.map((job) => /* @__PURE__ */ React7.createElement("article", { className: "mt-job", key: job.jobId }, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement("strong", null, job.outputName), /* @__PURE__ */ React7.createElement("p", null, job.kind === "sequence" ? "Sequence export" : "Video processing", " \xB7", " ", job.cancelRequested && !["succeeded", "failed", "canceled", "interrupted"].includes(job.state) ? "Stopping\u2026" : labels[job.state]), job.cleanupPending && /* @__PURE__ */ React7.createElement("p", { className: "mt-error" }, "Cleanup is pending. New processing is blocked until the old process is confirmed stopped."), job.error && /* @__PURE__ */ React7.createElement("p", { className: "mt-error" }, job.error.message)), /* @__PURE__ */ React7.createElement("div", { className: "mt-job-progress" }, /* @__PURE__ */ React7.createElement(
|
|
1477
2598
|
"progress",
|
|
1478
2599
|
{
|
|
1479
2600
|
"aria-label": `Progress for ${job.outputName}`,
|
|
1480
2601
|
max: 1,
|
|
1481
2602
|
value: job.state === "succeeded" ? 1 : job.progress === null ? void 0 : Math.min(0.99, job.progress)
|
|
1482
2603
|
}
|
|
1483
|
-
), /* @__PURE__ */
|
|
2604
|
+
), /* @__PURE__ */ React7.createElement("span", null, job.state === "succeeded" ? "100%" : job.progress === null ? "Unknown progress" : `${Math.floor(Math.min(0.99, job.progress) * 100)}%`)), /* @__PURE__ */ React7.createElement("div", { className: "mt-column-actions" }, ["queued", "running", "saving"].includes(job.state) && /* @__PURE__ */ React7.createElement(
|
|
1484
2605
|
Button,
|
|
1485
2606
|
{
|
|
1486
2607
|
label: "Cancel task",
|
|
@@ -1489,7 +2610,7 @@ function MediaJobs({ onOpenResult }) {
|
|
|
1489
2610
|
disabled: pending !== null || job.cancelRequested,
|
|
1490
2611
|
onClick: () => void act(job, "cancel")
|
|
1491
2612
|
}
|
|
1492
|
-
), ["failed", "canceled", "interrupted"].includes(job.state) && /* @__PURE__ */
|
|
2613
|
+
), ["failed", "canceled", "interrupted"].includes(job.state) && /* @__PURE__ */ React7.createElement(
|
|
1493
2614
|
Button,
|
|
1494
2615
|
{
|
|
1495
2616
|
label: "Retry task",
|
|
@@ -1498,7 +2619,7 @@ function MediaJobs({ onOpenResult }) {
|
|
|
1498
2619
|
disabled: pending !== null || job.cleanupPending,
|
|
1499
2620
|
onClick: () => void act(job, "retry")
|
|
1500
2621
|
}
|
|
1501
|
-
), job.result && onOpenResult && /* @__PURE__ */
|
|
2622
|
+
), job.result && onOpenResult && /* @__PURE__ */ React7.createElement(Button, { label: "Open result", width: "hug", onClick: () => onOpenResult(job.result) }), /* @__PURE__ */ React7.createElement("details", null, /* @__PURE__ */ React7.createElement("summary", null, "Task identity"), /* @__PURE__ */ React7.createElement("code", null, job.jobId))))), /* @__PURE__ */ React7.createElement("div", { className: "mt-pagination" }, /* @__PURE__ */ React7.createElement(
|
|
1502
2623
|
Button,
|
|
1503
2624
|
{
|
|
1504
2625
|
label: "Previous tasks",
|
|
@@ -1506,7 +2627,7 @@ function MediaJobs({ onOpenResult }) {
|
|
|
1506
2627
|
disabled: offset === 0,
|
|
1507
2628
|
onClick: () => setOffset(Math.max(0, offset - 50))
|
|
1508
2629
|
}
|
|
1509
|
-
), /* @__PURE__ */
|
|
2630
|
+
), /* @__PURE__ */ React7.createElement(
|
|
1510
2631
|
Button,
|
|
1511
2632
|
{
|
|
1512
2633
|
label: "Next tasks",
|
|
@@ -1564,30 +2685,36 @@ async function activate(client) {
|
|
|
1564
2685
|
component: Component,
|
|
1565
2686
|
props
|
|
1566
2687
|
}) {
|
|
1567
|
-
const ready =
|
|
2688
|
+
const ready = React8.useSyncExternalStore(
|
|
1568
2689
|
subscribe,
|
|
1569
2690
|
() => active,
|
|
1570
2691
|
() => active
|
|
1571
2692
|
);
|
|
1572
|
-
return ready ? /* @__PURE__ */
|
|
2693
|
+
return ready ? /* @__PURE__ */ React8.createElement(MediaContext.Provider, { value: { client, instanceId, resolve } }, /* @__PURE__ */ React8.createElement("div", { className: "mt-root" }, /* @__PURE__ */ React8.createElement(Component, { ...props }))) : null;
|
|
1573
2694
|
}
|
|
1574
2695
|
client.registerUI({
|
|
1575
2696
|
id: "media.video-editor",
|
|
1576
2697
|
title: "Video editor",
|
|
1577
2698
|
kind: "component",
|
|
1578
|
-
component: (props) => /* @__PURE__ */
|
|
2699
|
+
component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoEditor, props })
|
|
2700
|
+
});
|
|
2701
|
+
client.registerUI({
|
|
2702
|
+
id: "media.video-export",
|
|
2703
|
+
title: "Export settings",
|
|
2704
|
+
kind: "component",
|
|
2705
|
+
component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoExport, props })
|
|
1579
2706
|
});
|
|
1580
2707
|
client.registerUI({
|
|
1581
2708
|
id: "media.video-compare",
|
|
1582
2709
|
title: "Video comparison",
|
|
1583
2710
|
kind: "component",
|
|
1584
|
-
component: (props) => /* @__PURE__ */
|
|
2711
|
+
component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoCompare, props })
|
|
1585
2712
|
});
|
|
1586
2713
|
client.registerUI({
|
|
1587
2714
|
id: "media.jobs",
|
|
1588
2715
|
title: "Media tasks",
|
|
1589
2716
|
kind: "component",
|
|
1590
|
-
component: (props) => /* @__PURE__ */
|
|
2717
|
+
component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: MediaJobs, props })
|
|
1591
2718
|
});
|
|
1592
2719
|
client.onDispose(() => {
|
|
1593
2720
|
active = false;
|