@pixerate/editor-react 0.105.0 → 0.107.0
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/dist/animation-editor/index.cjs +2 -1
- package/dist/animation-editor/index.js +1 -1
- package/dist/canvas/index.cjs +2 -1
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-CEV4OEOY.js → chunk-6XI62THS.js} +1 -1
- package/dist/{chunk-Q7LAFHGP.js → chunk-ZQ6H2C7N.js} +2 -1
- package/dist/effects/EffectParameters.d.cts +4 -2
- package/dist/effects/EffectParameters.d.ts +4 -2
- package/dist/effects/index.cjs +2 -1
- package/dist/effects/index.js +1 -1
- package/dist/image-editor/index.cjs +2 -1
- package/dist/image-editor/index.js +2 -2
- package/dist/index.cjs +2 -1
- package/dist/index.js +2 -2
- package/dist/paint-editor/index.cjs +2 -1
- package/dist/paint-editor/index.js +1 -1
- package/dist/typography/FontPicker.d.cts +48 -0
- package/dist/typography/FontPicker.d.ts +48 -0
- package/dist/typography/TypographyControl.d.cts +11 -0
- package/dist/typography/TypographyControl.d.ts +11 -0
- package/dist/typography/index.cjs +328 -0
- package/dist/typography/index.d.cts +7 -0
- package/dist/typography/index.d.ts +7 -0
- package/dist/typography/index.js +299 -0
- package/dist/typography/useFontPicker.d.cts +17 -0
- package/dist/typography/useFontPicker.d.ts +17 -0
- package/dist/vector/index.cjs +2 -1
- package/dist/vector/index.js +1 -1
- package/dist/video-editor/EditPlanPreview.d.cts +16 -0
- package/dist/video-editor/EditPlanPreview.d.ts +16 -0
- package/dist/video-editor/TranscriptEditor.d.cts +20 -0
- package/dist/video-editor/TranscriptEditor.d.ts +20 -0
- package/dist/video-editor/VideoEditor.d.cts +7 -1
- package/dist/video-editor/VideoEditor.d.ts +7 -1
- package/dist/video-editor/VideoTransport.d.cts +2 -1
- package/dist/video-editor/VideoTransport.d.ts +2 -1
- package/dist/video-editor/index.cjs +1054 -260
- package/dist/video-editor/index.d.cts +3 -0
- package/dist/video-editor/index.d.ts +3 -0
- package/dist/video-editor/index.js +438 -70
- package/dist/video-editor/useTranscriptVideo.d.cts +8 -0
- package/dist/video-editor/useTranscriptVideo.d.ts +8 -0
- package/dist/video-editor/useVideoEditor.d.cts +12 -1
- package/dist/video-editor/useVideoEditor.d.ts +12 -1
- package/package.json +16 -3
|
@@ -32,7 +32,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
var video_editor_exports = {};
|
|
33
33
|
__export(video_editor_exports, {
|
|
34
34
|
ClipInspector: () => ClipInspector,
|
|
35
|
+
EditPlanPreview: () => EditPlanPreview,
|
|
35
36
|
MediaBin: () => MediaBin,
|
|
37
|
+
TranscriptEditor: () => TranscriptEditor,
|
|
36
38
|
TranscriptPanel: () => TranscriptPanel,
|
|
37
39
|
VideoEditor: () => VideoEditor,
|
|
38
40
|
VideoEffectsPanel: () => VideoEffectsPanel,
|
|
@@ -40,11 +42,15 @@ __export(video_editor_exports, {
|
|
|
40
42
|
VideoScopes: () => VideoScopes,
|
|
41
43
|
VideoTimeline: () => VideoTimeline,
|
|
42
44
|
VideoTransport: () => VideoTransport,
|
|
45
|
+
useTranscriptVideoController: () => useTranscriptVideoController,
|
|
46
|
+
useTranscriptVideoState: () => useTranscriptVideoState,
|
|
47
|
+
useVideoDialogueTools: () => useVideoDialogueTools,
|
|
43
48
|
useVideoEditor: () => useVideoEditor,
|
|
44
49
|
useVideoEditorController: () => useVideoEditorController,
|
|
45
50
|
useVideoEditorState: () => useVideoEditorState,
|
|
46
51
|
useVideoEditorTools: () => useVideoEditorTools,
|
|
47
|
-
useVideoEffectsTools: () => useVideoEffectsTools
|
|
52
|
+
useVideoEffectsTools: () => useVideoEffectsTools,
|
|
53
|
+
useVideoMusicTools: () => useVideoMusicTools
|
|
48
54
|
});
|
|
49
55
|
module.exports = __toCommonJS(video_editor_exports);
|
|
50
56
|
|
|
@@ -103,6 +109,20 @@ function useVideoEffectsTools(registry, controller, options = {}) {
|
|
|
103
109
|
return registry.register((0, import_video_editor.createVideoEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
104
110
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
105
111
|
}
|
|
112
|
+
function useVideoDialogueTools(registry, controller, options = {}) {
|
|
113
|
+
const { id, namespace, readOnly, playbackSurface } = options;
|
|
114
|
+
(0, import_react.useEffect)(() => {
|
|
115
|
+
if (!registry) return;
|
|
116
|
+
return registry.register((0, import_video_editor.createVideoDialogueToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
117
|
+
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
118
|
+
}
|
|
119
|
+
function useVideoMusicTools(registry, controller, options = {}) {
|
|
120
|
+
const { id, namespace, readOnly, playbackSurface } = options;
|
|
121
|
+
(0, import_react.useEffect)(() => {
|
|
122
|
+
if (!registry) return;
|
|
123
|
+
return registry.register((0, import_video_editor.createVideoMusicToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
124
|
+
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
125
|
+
}
|
|
106
126
|
|
|
107
127
|
// src/video-editor/VideoPreview.tsx
|
|
108
128
|
var import_react2 = require("react");
|
|
@@ -245,6 +265,24 @@ function VideoTransport({ controller, editable = true, className = "" }) {
|
|
|
245
265
|
children: "Ripple delete"
|
|
246
266
|
}
|
|
247
267
|
),
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
269
|
+
"button",
|
|
270
|
+
{
|
|
271
|
+
type: "button",
|
|
272
|
+
className: btn,
|
|
273
|
+
onClick: () => {
|
|
274
|
+
const r = controller.apply((0, import_video_editor4.videoAddAdjustmentEdits)(project, time), "Add adjustment clip");
|
|
275
|
+
if (r.ok) {
|
|
276
|
+
const added = r.outcomes[r.outcomes.length - 1].clip;
|
|
277
|
+
if (added) controller.select([added]);
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
disabled: !canEdit,
|
|
281
|
+
title: "Add an adjustment clip at the playhead over every track: its grade, effects and mask change the pictures underneath",
|
|
282
|
+
"data-add-adjustment": "",
|
|
283
|
+
children: "Adjustment"
|
|
284
|
+
}
|
|
285
|
+
),
|
|
248
286
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: btn, onClick: () => controller.undo(), disabled: !canEdit || !state.canUndo, title: state.canUndo ? `Undo ${state.undoLabel}` : "Nothing to undo", "data-undo": "", children: "Undo" }),
|
|
249
287
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: btn, onClick: () => controller.redo(), disabled: !canEdit || !state.canRedo, title: state.canRedo ? `Redo ${state.redoLabel}` : "Nothing to redo", "data-redo": "", children: "Redo" })
|
|
250
288
|
] })
|
|
@@ -782,6 +820,26 @@ function LutControls({ controller, clip, disabled }) {
|
|
|
782
820
|
}
|
|
783
821
|
}
|
|
784
822
|
) }),
|
|
823
|
+
lut && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Row, { label: "Protect skin", name: "grade.lut.preserveSkinTones", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
824
|
+
Commit,
|
|
825
|
+
{
|
|
826
|
+
type: "number",
|
|
827
|
+
min: 0,
|
|
828
|
+
max: 1,
|
|
829
|
+
step: 0.1,
|
|
830
|
+
value: String(lut.preserveSkinTones ?? 0),
|
|
831
|
+
"aria-label": "Protect skin tones",
|
|
832
|
+
title: "How much of the LUT to hold back on skin tones (0 to 1)",
|
|
833
|
+
disabled,
|
|
834
|
+
onCommit: (raw) => {
|
|
835
|
+
const n = Number(raw);
|
|
836
|
+
if (raw.trim() && Number.isFinite(n)) {
|
|
837
|
+
const r = controller.apply((0, import_video_editor6.videoSkinProtectionEdits)(controller.getProject(), [clip.id], n), n > 0 ? "Protect skin tones" : "Stop protecting skin tones");
|
|
838
|
+
setMessage(r.ok ? null : r.error);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
) }),
|
|
785
843
|
message && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-xs text-red-500", role: "alert", "data-lut-error": "", children: message })
|
|
786
844
|
] });
|
|
787
845
|
}
|
|
@@ -821,7 +879,7 @@ function ClipInspector({ controller, className = "" }) {
|
|
|
821
879
|
const transition = clip.transition;
|
|
822
880
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `flex flex-col gap-1.5 ${className}`, "data-clip-inspector": "", "data-clip-id": clip.id, children: [
|
|
823
881
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2 text-xs", children: [
|
|
824
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "font-medium", children:
|
|
882
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "font-medium", children: (0, import_video_editor6.videoClipHeading)(clip) }),
|
|
825
883
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { className: "text-muted-foreground", children: clip.id }),
|
|
826
884
|
at.track.locked && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-amber-500", children: "locked track" })
|
|
827
885
|
] }),
|
|
@@ -907,6 +965,87 @@ function ClipInspector({ controller, className = "" }) {
|
|
|
907
965
|
) }, c.key)),
|
|
908
966
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LutControls, { controller, clip, disabled })
|
|
909
967
|
] }),
|
|
968
|
+
clip.type === "adjustment" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
969
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Row, { label: "Changes", name: "scope", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
970
|
+
"select",
|
|
971
|
+
{
|
|
972
|
+
className: field,
|
|
973
|
+
value: clip.scope ?? "underneath",
|
|
974
|
+
disabled,
|
|
975
|
+
"aria-label": "Adjustment scope",
|
|
976
|
+
onChange: (e) => {
|
|
977
|
+
const scope = e.target.value;
|
|
978
|
+
const target = project.tracks.find((t) => t.kind === "video" && t.id !== at.track.id)?.id;
|
|
979
|
+
if (scope === "track") controller.apply({ op: "update_clip", clip: clip.id, set: { scope, targetTrack: clip.targetTrack ?? target ?? at.track.id } }, "Change adjustment scope");
|
|
980
|
+
else controller.apply({ op: "update_clip", clip: clip.id, ...scope === "underneath" ? { remove: ["scope", "targetTrack"] } : { set: { scope }, remove: ["targetTrack"] } }, "Change adjustment scope");
|
|
981
|
+
},
|
|
982
|
+
children: import_video_editor6.VIDEO_ADJUSTMENT_SCOPES.map((s) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: s, children: import_video_editor6.VIDEO_ADJUSTMENT_SCOPE_LABELS[s] }, s))
|
|
983
|
+
}
|
|
984
|
+
) }),
|
|
985
|
+
clip.scope === "track" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Row, { label: "Track", name: "targetTrack", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { className: field, value: clip.targetTrack ?? "", disabled, "aria-label": "Adjusted track", onChange: (e) => set("targetTrack", e.target.value, "Change adjusted track"), children: project.tracks.filter((t) => t.kind === "video").map((t) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: t.id, children: t.name ?? t.id }, t.id)) }) })
|
|
986
|
+
] }),
|
|
987
|
+
at.track.kind === "video" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
988
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Row, { label: "Mask", name: "mask", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
989
|
+
"select",
|
|
990
|
+
{
|
|
991
|
+
className: field,
|
|
992
|
+
value: clip.mask?.shape ?? "",
|
|
993
|
+
disabled,
|
|
994
|
+
"aria-label": "Mask shape",
|
|
995
|
+
onChange: (e) => {
|
|
996
|
+
const shape = e.target.value;
|
|
997
|
+
const points = [
|
|
998
|
+
{ x: 0.5, y: 0.2 },
|
|
999
|
+
{ x: 0.8, y: 0.8 },
|
|
1000
|
+
{ x: 0.2, y: 0.8 }
|
|
1001
|
+
];
|
|
1002
|
+
const { points: _p, cornerRadius: _c, ...rest } = clip.mask ?? { shape: "ellipse" };
|
|
1003
|
+
controller.apply((0, import_video_editor6.videoMaskEdit)(clip.id, shape ? { ...rest, shape, ...shape === "polygon" ? { points } : {} } : null), shape ? "Mask clip" : "Remove mask");
|
|
1004
|
+
},
|
|
1005
|
+
children: [
|
|
1006
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "", children: "None" }),
|
|
1007
|
+
import_video_editor6.VIDEO_MASK_SHAPES.map((s) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: s, children: import_video_editor6.VIDEO_MASK_SHAPE_LABELS[s] }, s))
|
|
1008
|
+
]
|
|
1009
|
+
}
|
|
1010
|
+
) }),
|
|
1011
|
+
clip.mask && [
|
|
1012
|
+
["width", "Mask width", 0.05],
|
|
1013
|
+
["height", "Mask height", 0.05],
|
|
1014
|
+
["feather", "Feather (px)", 5],
|
|
1015
|
+
["rotation", "Mask angle", 5]
|
|
1016
|
+
].map(([key, label, step]) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Row, { label, name: `mask.${key}`, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1017
|
+
Commit,
|
|
1018
|
+
{
|
|
1019
|
+
type: "number",
|
|
1020
|
+
step,
|
|
1021
|
+
min: key === "rotation" ? void 0 : 0,
|
|
1022
|
+
value: clip.mask[key] === void 0 ? "" : String(clip.mask[key]),
|
|
1023
|
+
placeholder: key === "feather" || key === "rotation" ? "0" : "0.5",
|
|
1024
|
+
"aria-label": label,
|
|
1025
|
+
disabled,
|
|
1026
|
+
onCommit: (raw) => {
|
|
1027
|
+
const n = Number(raw);
|
|
1028
|
+
if (raw.trim() && !Number.isFinite(n)) return;
|
|
1029
|
+
const { [key]: _old, ...rest } = clip.mask;
|
|
1030
|
+
controller.apply((0, import_video_editor6.videoMaskEdit)(clip.id, raw.trim() ? { ...rest, [key]: n } : rest), "Change mask");
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
) }, key)),
|
|
1034
|
+
clip.mask && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Row, { label: "Invert mask", name: "mask.inverted", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1035
|
+
"input",
|
|
1036
|
+
{
|
|
1037
|
+
type: "checkbox",
|
|
1038
|
+
className: "justify-self-start",
|
|
1039
|
+
checked: !!clip.mask.inverted,
|
|
1040
|
+
disabled,
|
|
1041
|
+
"aria-label": "Invert mask",
|
|
1042
|
+
onChange: (e) => {
|
|
1043
|
+
const { inverted: _i, ...rest } = clip.mask;
|
|
1044
|
+
controller.apply((0, import_video_editor6.videoMaskEdit)(clip.id, e.target.checked ? { ...rest, inverted: true } : rest), "Invert mask");
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
) })
|
|
1048
|
+
] }),
|
|
910
1049
|
at.track.kind === "video" && ["animateIn", "animateOut"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Row, { label: key === "animateIn" ? "Animate in" : "Animate out", name: key, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
911
1050
|
"select",
|
|
912
1051
|
{
|
|
@@ -1296,21 +1435,200 @@ function TranscriptPanel({ controller, track, editable = true, className = "" })
|
|
|
1296
1435
|
] });
|
|
1297
1436
|
}
|
|
1298
1437
|
|
|
1438
|
+
// src/video-editor/TranscriptEditor.tsx
|
|
1439
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
1440
|
+
|
|
1441
|
+
// src/video-editor/useTranscriptVideo.ts
|
|
1442
|
+
var import_react11 = require("react");
|
|
1443
|
+
var import_video_editor9 = require("@pixerate/editor/video-editor");
|
|
1444
|
+
function useTranscriptVideoController(controller, options = {}) {
|
|
1445
|
+
const ref = (0, import_react11.useRef)(null);
|
|
1446
|
+
const key = `${options.track ?? ""}|${options.planFirst ? 1 : 0}`;
|
|
1447
|
+
if (!ref.current || ref.current.editor !== controller || ref.current.key !== key) {
|
|
1448
|
+
ref.current?.transcript.destroy();
|
|
1449
|
+
ref.current = { key, editor: controller, transcript: new import_video_editor9.TranscriptVideoController(controller, options) };
|
|
1450
|
+
}
|
|
1451
|
+
const transcript = ref.current.transcript;
|
|
1452
|
+
(0, import_react11.useEffect)(() => () => transcript.destroy(), [transcript]);
|
|
1453
|
+
return transcript;
|
|
1454
|
+
}
|
|
1455
|
+
function useTranscriptVideoState(transcript) {
|
|
1456
|
+
return (0, import_react11.useSyncExternalStore)(transcript.subscribe, transcript.getState, transcript.getState);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
// src/video-editor/TranscriptEditor.tsx
|
|
1460
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1461
|
+
var btn5 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
1462
|
+
var CHIP = {
|
|
1463
|
+
filler: "bg-amber-400/30 text-amber-700 dark:text-amber-300",
|
|
1464
|
+
pause: "bg-sky-400/25 text-sky-700 dark:text-sky-300",
|
|
1465
|
+
repetition: "bg-violet-400/25 text-violet-700 dark:text-violet-300"
|
|
1466
|
+
};
|
|
1467
|
+
var KIND_LABEL = { filler: "filler", pause: "pause", repetition: "repeat" };
|
|
1468
|
+
function TranscriptEditor({ controller, track, planFirst = false, editable = true, className = "" }) {
|
|
1469
|
+
const transcript = useTranscriptVideoController(controller, { track, planFirst });
|
|
1470
|
+
const state = useTranscriptVideoState(transcript);
|
|
1471
|
+
const [anchor, setAnchor] = (0, import_react12.useState)(null);
|
|
1472
|
+
const canEdit = editable && state.editable;
|
|
1473
|
+
const { words, current, selection, disfluencies, flags } = state;
|
|
1474
|
+
if (!words.length)
|
|
1475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: `text-xs text-muted-foreground ${className}`, "data-transcript-editor": "", "data-transcript-empty": "", children: "No transcribed media on the timeline. Attach a transcript (Whisper JSON, .srt or .vtt) to edit by text." });
|
|
1476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `flex flex-col gap-2 text-xs ${className}`, "data-transcript-editor": "", children: [
|
|
1477
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1478
|
+
"div",
|
|
1479
|
+
{
|
|
1480
|
+
className: "max-h-56 overflow-y-auto leading-6",
|
|
1481
|
+
role: "listbox",
|
|
1482
|
+
"aria-label": "Transcript",
|
|
1483
|
+
"aria-multiselectable": "true",
|
|
1484
|
+
tabIndex: 0,
|
|
1485
|
+
onKeyDown: (e) => {
|
|
1486
|
+
if (canEdit && selection && (e.key === "Delete" || e.key === "Backspace")) {
|
|
1487
|
+
e.preventDefault();
|
|
1488
|
+
transcript.deleteSelection();
|
|
1489
|
+
}
|
|
1490
|
+
},
|
|
1491
|
+
children: words.map((w, i) => {
|
|
1492
|
+
const selected = !!selection && i >= selection[0] && i <= selection[1];
|
|
1493
|
+
const kinds = flags[i];
|
|
1494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react12.default.Fragment, { children: [
|
|
1495
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1496
|
+
"span",
|
|
1497
|
+
{
|
|
1498
|
+
role: "option",
|
|
1499
|
+
"aria-selected": selected,
|
|
1500
|
+
tabIndex: -1,
|
|
1501
|
+
className: `cursor-pointer rounded px-0.5 ${selected ? "bg-rose-500/30" : i === current ? "bg-amber-400/50" : kinds?.length ? CHIP[kinds[0]] : "hover:bg-muted"}`,
|
|
1502
|
+
"data-word": i,
|
|
1503
|
+
"data-current": i === current ? "" : void 0,
|
|
1504
|
+
"data-selected": selected ? "" : void 0,
|
|
1505
|
+
"data-disfluency": kinds?.join(" ") || void 0,
|
|
1506
|
+
title: kinds?.length ? kinds.map((k) => KIND_LABEL[k]).join(", ") : void 0,
|
|
1507
|
+
onClick: (e) => {
|
|
1508
|
+
if (e.shiftKey && anchor !== null) transcript.select(anchor, i);
|
|
1509
|
+
else {
|
|
1510
|
+
setAnchor(i);
|
|
1511
|
+
transcript.select(i);
|
|
1512
|
+
transcript.seekToWord(i);
|
|
1513
|
+
}
|
|
1514
|
+
},
|
|
1515
|
+
children: w.word
|
|
1516
|
+
}
|
|
1517
|
+
),
|
|
1518
|
+
kinds?.includes("pause") ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "mx-0.5 text-sky-500", "aria-hidden": "true", children: "\u23F8" }) : " "
|
|
1519
|
+
] }, `${w.clip}:${w.index}`);
|
|
1520
|
+
})
|
|
1521
|
+
}
|
|
1522
|
+
),
|
|
1523
|
+
canEdit && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1524
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: btn5, disabled: !selection, onClick: () => transcript.deleteSelection(), "data-delete-words": "", children: planFirst ? "Propose deleting words" : "Delete words" }),
|
|
1525
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("button", { type: "button", className: btn5, disabled: !disfluencies.length, onClick: () => transcript.planCleanup(), "data-plan-cleanup": "", children: [
|
|
1526
|
+
"Plan cleanup (",
|
|
1527
|
+
disfluencies.length,
|
|
1528
|
+
")"
|
|
1529
|
+
] })
|
|
1530
|
+
] }),
|
|
1531
|
+
disfluencies.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "flex flex-wrap gap-1", "aria-label": "Disfluencies", "data-disfluencies": "", children: disfluencies.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("li", { className: `flex items-center gap-1 rounded px-1 ${CHIP[d.kind]}`, "data-disfluency-chip": d.kind, children: [
|
|
1532
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("button", { type: "button", className: "tabular-nums", title: "Go to it", onClick: () => controller.seek(d.from), children: [
|
|
1533
|
+
KIND_LABEL[d.kind],
|
|
1534
|
+
": ",
|
|
1535
|
+
d.kind === "pause" ? `${((d.to - d.from) / 1e3).toFixed(1)} s` : d.text
|
|
1536
|
+
] }),
|
|
1537
|
+
canEdit && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", "aria-label": `Cut ${KIND_LABEL[d.kind]} ${d.text}`, onClick: () => transcript.removeDisfluency(i), "data-cut-disfluency": i, children: "\u2715" })
|
|
1538
|
+
] }, `${d.kind}:${d.from}`)) }),
|
|
1539
|
+
state.error && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-red-500", role: "alert", "data-transcript-error": "", children: state.error })
|
|
1540
|
+
] });
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// src/video-editor/EditPlanPreview.tsx
|
|
1544
|
+
var import_react13 = require("react");
|
|
1545
|
+
var import_video_editor10 = require("@pixerate/editor/video-editor");
|
|
1546
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1547
|
+
var btn6 = "rounded border border-border px-2 py-0.5 text-[11px] disabled:opacity-40";
|
|
1548
|
+
function EditPlanPreview({ controller, editable = true, className = "" }) {
|
|
1549
|
+
const state = useVideoEditorState(controller);
|
|
1550
|
+
const [message, setMessage] = (0, import_react13.useState)(null);
|
|
1551
|
+
if (!state.plans.length) return null;
|
|
1552
|
+
const total = Math.max(1, state.duration);
|
|
1553
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { className: `flex flex-col gap-2 rounded-md border border-amber-500/50 bg-amber-500/5 p-2 text-xs ${className}`, "aria-label": "Proposed edits", "data-edit-plans": "", children: [
|
|
1554
|
+
state.plans.map((plan) => {
|
|
1555
|
+
const s = plan.summary;
|
|
1556
|
+
const stale = controller.isPlanStale(plan.id);
|
|
1557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("article", { className: "flex flex-col gap-1", "data-edit-plan": plan.id, children: [
|
|
1558
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1559
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { className: "flex-1 font-semibold", children: plan.title }),
|
|
1560
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: `tabular-nums ${s.durationDelta < 0 ? "text-emerald-600" : "text-muted-foreground"}`, "data-plan-delta": "", children: [
|
|
1561
|
+
s.durationDelta < 0 ? "\u2212" : s.durationDelta > 0 ? "+" : "\xB1",
|
|
1562
|
+
(0, import_video_editor10.formatVideoSeconds)(Math.abs(s.durationDelta))
|
|
1563
|
+
] })
|
|
1564
|
+
] }),
|
|
1565
|
+
plan.description && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-muted-foreground", children: plan.description }),
|
|
1566
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: "text-muted-foreground", "data-plan-summary": "", children: [
|
|
1567
|
+
(0, import_video_editor10.describeVideoEditPlan)(plan),
|
|
1568
|
+
" \xB7 ",
|
|
1569
|
+
(0, import_video_editor10.formatVideoSeconds)(s.durationBefore),
|
|
1570
|
+
" \u2192 ",
|
|
1571
|
+
(0, import_video_editor10.formatVideoSeconds)(s.durationAfter)
|
|
1572
|
+
] }),
|
|
1573
|
+
plan.ranges && plan.ranges.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "relative h-3 w-full overflow-hidden rounded bg-muted", "aria-label": "Stretches the plan cuts", "data-plan-strip": "", children: plan.ranges.map((r, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1574
|
+
"button",
|
|
1575
|
+
{
|
|
1576
|
+
type: "button",
|
|
1577
|
+
className: "absolute top-0 h-full bg-rose-500/70 hover:bg-rose-600",
|
|
1578
|
+
style: { left: `${r.from / total * 100}%`, width: `${Math.max(0.4, (r.to - r.from) / total * 100)}%` },
|
|
1579
|
+
title: `${r.reason ? `${r.reason}: ` : ""}${r.text ?? ""} (${(0, import_video_editor10.formatVideoSeconds)(r.from)})`,
|
|
1580
|
+
"aria-label": `Go to ${r.reason ?? "cut"} at ${(0, import_video_editor10.formatVideoSeconds)(r.from)}`,
|
|
1581
|
+
onClick: () => controller.seek(r.from)
|
|
1582
|
+
},
|
|
1583
|
+
i
|
|
1584
|
+
)) }),
|
|
1585
|
+
s.newIssues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: "text-amber-600", children: [
|
|
1586
|
+
"It would add ",
|
|
1587
|
+
s.newIssues.length,
|
|
1588
|
+
" problem",
|
|
1589
|
+
s.newIssues.length > 1 ? "s" : "",
|
|
1590
|
+
": ",
|
|
1591
|
+
s.newIssues[0].message
|
|
1592
|
+
] }),
|
|
1593
|
+
stale && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-amber-600", "data-plan-stale": "", children: "The project changed since this plan was made; it is checked again when accepted." }),
|
|
1594
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex gap-1", children: [
|
|
1595
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1596
|
+
"button",
|
|
1597
|
+
{
|
|
1598
|
+
type: "button",
|
|
1599
|
+
className: btn6,
|
|
1600
|
+
disabled: !editable || state.readOnly,
|
|
1601
|
+
"data-accept-plan": "",
|
|
1602
|
+
onClick: () => {
|
|
1603
|
+
const r = controller.applyPlan(plan.id);
|
|
1604
|
+
setMessage(r.ok ? null : r.error);
|
|
1605
|
+
},
|
|
1606
|
+
children: "Accept plan"
|
|
1607
|
+
}
|
|
1608
|
+
),
|
|
1609
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: btn6, "data-discard-plan": "", onClick: () => (controller.discardPlan(plan.id), setMessage(null)), children: "Discard" })
|
|
1610
|
+
] })
|
|
1611
|
+
] }, plan.id);
|
|
1612
|
+
}),
|
|
1613
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-red-500", role: "alert", "data-plan-error": "", children: message })
|
|
1614
|
+
] });
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1299
1617
|
// src/video-editor/VideoEditor.tsx
|
|
1300
|
-
var
|
|
1618
|
+
var import_react25 = require("react");
|
|
1301
1619
|
|
|
1302
1620
|
// src/effects/useEffects.ts
|
|
1303
|
-
var
|
|
1621
|
+
var import_react14 = require("react");
|
|
1304
1622
|
function useEffects(host, provider) {
|
|
1305
|
-
(0,
|
|
1623
|
+
(0, import_react14.useEffect)(() => {
|
|
1306
1624
|
if (!host || !provider) return;
|
|
1307
1625
|
return host.useEffects(provider);
|
|
1308
1626
|
}, [host, provider]);
|
|
1309
1627
|
}
|
|
1310
1628
|
function useEffectDescription(provider, effect) {
|
|
1311
|
-
const [state, setState] = (0,
|
|
1629
|
+
const [state, setState] = (0, import_react14.useState)({ key: "", description: null, error: null });
|
|
1312
1630
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
1313
|
-
(0,
|
|
1631
|
+
(0, import_react14.useEffect)(() => {
|
|
1314
1632
|
if (!provider || !effect) return;
|
|
1315
1633
|
let live = true;
|
|
1316
1634
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -1325,13 +1643,13 @@ function useEffectDescription(provider, effect) {
|
|
|
1325
1643
|
}
|
|
1326
1644
|
|
|
1327
1645
|
// src/effects/EffectThumbnail.tsx
|
|
1328
|
-
var
|
|
1646
|
+
var import_react15 = require("react");
|
|
1329
1647
|
var import_effects = require("@pixerate/editor/effects");
|
|
1330
|
-
var
|
|
1648
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1331
1649
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
1332
|
-
const ref = (0,
|
|
1333
|
-
const [failed, setFailed] = (0,
|
|
1334
|
-
(0,
|
|
1650
|
+
const ref = (0, import_react15.useRef)(null);
|
|
1651
|
+
const [failed, setFailed] = (0, import_react15.useState)(effect.kind === "motion");
|
|
1652
|
+
(0, import_react15.useEffect)(() => {
|
|
1335
1653
|
if (effect.kind === "motion") return;
|
|
1336
1654
|
let live = true;
|
|
1337
1655
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -1346,28 +1664,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
1346
1664
|
live = false;
|
|
1347
1665
|
};
|
|
1348
1666
|
}, [provider, effect, width, height]);
|
|
1349
|
-
return /* @__PURE__ */ (0,
|
|
1667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1350
1668
|
"div",
|
|
1351
1669
|
{
|
|
1352
1670
|
className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
|
|
1353
1671
|
style: { aspectRatio: `${width} / ${height}` },
|
|
1354
1672
|
"data-effect-thumbnail": effect.id,
|
|
1355
|
-
children: failed ? /* @__PURE__ */ (0,
|
|
1673
|
+
children: failed ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "absolute inset-0 flex items-center justify-center text-[10px] text-muted-foreground", children: effect.kind === "motion" ? "Motion" : "No preview" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
|
|
1356
1674
|
}
|
|
1357
1675
|
);
|
|
1358
1676
|
}
|
|
1359
1677
|
|
|
1360
1678
|
// src/effects/EffectsBrowser.tsx
|
|
1361
|
-
var
|
|
1679
|
+
var import_react16 = require("react");
|
|
1362
1680
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
1363
|
-
var
|
|
1681
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1364
1682
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
1365
|
-
const [all, setAll] = (0,
|
|
1366
|
-
const [query, setQuery] = (0,
|
|
1367
|
-
const [category, setCategory] = (0,
|
|
1368
|
-
const [use, setUse] = (0,
|
|
1369
|
-
const [error, setError] = (0,
|
|
1370
|
-
(0,
|
|
1683
|
+
const [all, setAll] = (0, import_react16.useState)([]);
|
|
1684
|
+
const [query, setQuery] = (0, import_react16.useState)("");
|
|
1685
|
+
const [category, setCategory] = (0, import_react16.useState)("");
|
|
1686
|
+
const [use, setUse] = (0, import_react16.useState)("");
|
|
1687
|
+
const [error, setError] = (0, import_react16.useState)(null);
|
|
1688
|
+
(0, import_react16.useEffect)(() => {
|
|
1371
1689
|
if (!provider) return setAll([]);
|
|
1372
1690
|
let live = true;
|
|
1373
1691
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -1378,8 +1696,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1378
1696
|
live = false;
|
|
1379
1697
|
};
|
|
1380
1698
|
}, [provider]);
|
|
1381
|
-
const [found, setFound] = (0,
|
|
1382
|
-
(0,
|
|
1699
|
+
const [found, setFound] = (0, import_react16.useState)([]);
|
|
1700
|
+
(0, import_react16.useEffect)(() => {
|
|
1383
1701
|
if (!provider) return setFound([]);
|
|
1384
1702
|
let live = true;
|
|
1385
1703
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -1388,14 +1706,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1388
1706
|
};
|
|
1389
1707
|
}, [provider, query, category, use]);
|
|
1390
1708
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (uses ? e.kind !== "motion" || uses.includes("motion") : e.kind !== "motion") && (!uses || e.uses.some((u) => uses.includes(u)));
|
|
1391
|
-
const categories = (0,
|
|
1709
|
+
const categories = (0, import_react16.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
1392
1710
|
const shown = found.filter(allowed);
|
|
1393
1711
|
if (!provider)
|
|
1394
|
-
return /* @__PURE__ */ (0,
|
|
1395
|
-
return /* @__PURE__ */ (0,
|
|
1396
|
-
title && /* @__PURE__ */ (0,
|
|
1397
|
-
/* @__PURE__ */ (0,
|
|
1398
|
-
/* @__PURE__ */ (0,
|
|
1712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
|
|
1713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
|
|
1714
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { className: "text-xs font-semibold", children: title }),
|
|
1715
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1716
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1399
1717
|
"input",
|
|
1400
1718
|
{
|
|
1401
1719
|
type: "search",
|
|
@@ -1406,17 +1724,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1406
1724
|
onChange: (e) => setQuery(e.currentTarget.value)
|
|
1407
1725
|
}
|
|
1408
1726
|
),
|
|
1409
|
-
/* @__PURE__ */ (0,
|
|
1410
|
-
/* @__PURE__ */ (0,
|
|
1411
|
-
categories.map((c) => /* @__PURE__ */ (0,
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Category", value: category, onChange: (e) => setCategory(e.currentTarget.value), children: [
|
|
1728
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: "All categories" }),
|
|
1729
|
+
categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: c, children: c }, c))
|
|
1412
1730
|
] }),
|
|
1413
|
-
uses && uses.length > 1 && /* @__PURE__ */ (0,
|
|
1414
|
-
/* @__PURE__ */ (0,
|
|
1415
|
-
uses.map((u) => /* @__PURE__ */ (0,
|
|
1731
|
+
uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Use", value: use, onChange: (e) => setUse(e.currentTarget.value), children: [
|
|
1732
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: "Any use" }),
|
|
1733
|
+
uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
|
|
1416
1734
|
] })
|
|
1417
1735
|
] }),
|
|
1418
|
-
error && /* @__PURE__ */ (0,
|
|
1419
|
-
/* @__PURE__ */ (0,
|
|
1736
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
|
|
1737
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: "grid max-h-96 grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-1.5 overflow-y-auto", role: "list", children: shown.map((e) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1420
1738
|
"button",
|
|
1421
1739
|
{
|
|
1422
1740
|
type: "button",
|
|
@@ -1425,23 +1743,23 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1425
1743
|
"data-effect-id": e.id,
|
|
1426
1744
|
onClick: () => onPick(e),
|
|
1427
1745
|
children: [
|
|
1428
|
-
thumbnails && /* @__PURE__ */ (0,
|
|
1429
|
-
/* @__PURE__ */ (0,
|
|
1430
|
-
/* @__PURE__ */ (0,
|
|
1746
|
+
thumbnails && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EffectThumbnail, { provider, effect: e }),
|
|
1747
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
|
|
1748
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
|
|
1431
1749
|
]
|
|
1432
1750
|
}
|
|
1433
1751
|
) }, e.id)) }),
|
|
1434
|
-
!shown.length && !error && /* @__PURE__ */ (0,
|
|
1752
|
+
!shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
|
|
1435
1753
|
] });
|
|
1436
1754
|
}
|
|
1437
1755
|
|
|
1438
1756
|
// src/effects/EffectParameters.tsx
|
|
1439
|
-
var
|
|
1757
|
+
var import_react21 = __toESM(require("react"), 1);
|
|
1440
1758
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1441
1759
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1442
1760
|
|
|
1443
1761
|
// src/parameters/fields.tsx
|
|
1444
|
-
var
|
|
1762
|
+
var import_react20 = require("react");
|
|
1445
1763
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1446
1764
|
|
|
1447
1765
|
// src/color/index.ts
|
|
@@ -1454,9 +1772,9 @@ __export(color_exports, {
|
|
|
1454
1772
|
});
|
|
1455
1773
|
|
|
1456
1774
|
// src/color/ColorPicker.tsx
|
|
1457
|
-
var
|
|
1775
|
+
var import_react17 = require("react");
|
|
1458
1776
|
var import_color = require("@pixerate/editor/color");
|
|
1459
|
-
var
|
|
1777
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1460
1778
|
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
1461
1779
|
function readLocalRecents() {
|
|
1462
1780
|
try {
|
|
@@ -1494,24 +1812,24 @@ var ColorPicker = ({
|
|
|
1494
1812
|
id,
|
|
1495
1813
|
"aria-label": ariaLabel = "Color picker"
|
|
1496
1814
|
}) => {
|
|
1497
|
-
const generatedId = (0,
|
|
1815
|
+
const generatedId = (0, import_react17.useId)();
|
|
1498
1816
|
const pickerId = id || generatedId;
|
|
1499
|
-
const [pickerState, setPickerState] = (0,
|
|
1817
|
+
const [pickerState, setPickerState] = (0, import_react17.useState)(
|
|
1500
1818
|
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
1501
1819
|
);
|
|
1502
|
-
const stateRef = (0,
|
|
1820
|
+
const stateRef = (0, import_react17.useRef)(pickerState);
|
|
1503
1821
|
stateRef.current = pickerState;
|
|
1504
|
-
(0,
|
|
1822
|
+
(0, import_react17.useEffect)(() => {
|
|
1505
1823
|
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
1506
1824
|
if (next) {
|
|
1507
1825
|
setPickerState(next);
|
|
1508
1826
|
}
|
|
1509
1827
|
}, [value]);
|
|
1510
|
-
const [internalRecent, setInternalRecent] = (0,
|
|
1828
|
+
const [internalRecent, setInternalRecent] = (0, import_react17.useState)(
|
|
1511
1829
|
() => controlledRecent ? [] : readLocalRecents()
|
|
1512
1830
|
);
|
|
1513
1831
|
const activeRecent = controlledRecent ?? internalRecent;
|
|
1514
|
-
const recordRecent = (0,
|
|
1832
|
+
const recordRecent = (0, import_react17.useCallback)(
|
|
1515
1833
|
(color) => {
|
|
1516
1834
|
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
1517
1835
|
if (!controlledRecent) {
|
|
@@ -1522,11 +1840,11 @@ var ColorPicker = ({
|
|
|
1522
1840
|
},
|
|
1523
1841
|
[activeRecent, controlledRecent, onRecentChange]
|
|
1524
1842
|
);
|
|
1525
|
-
const [textDraft, setTextDraft] = (0,
|
|
1526
|
-
const [isInvalid, setIsInvalid] = (0,
|
|
1527
|
-
const [isClipped, setIsClipped] = (0,
|
|
1528
|
-
const isTypingRef = (0,
|
|
1529
|
-
(0,
|
|
1843
|
+
const [textDraft, setTextDraft] = (0, import_react17.useState)(value);
|
|
1844
|
+
const [isInvalid, setIsInvalid] = (0, import_react17.useState)(false);
|
|
1845
|
+
const [isClipped, setIsClipped] = (0, import_react17.useState)(false);
|
|
1846
|
+
const isTypingRef = (0, import_react17.useRef)(false);
|
|
1847
|
+
(0, import_react17.useEffect)(() => {
|
|
1530
1848
|
if (!isTypingRef.current) {
|
|
1531
1849
|
setTextDraft(value);
|
|
1532
1850
|
setIsInvalid(false);
|
|
@@ -1534,11 +1852,11 @@ var ColorPicker = ({
|
|
|
1534
1852
|
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
1535
1853
|
}
|
|
1536
1854
|
}, [value]);
|
|
1537
|
-
const [hasEyeDropper, setHasEyeDropper] = (0,
|
|
1538
|
-
(0,
|
|
1855
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react17.useState)(false);
|
|
1856
|
+
(0, import_react17.useEffect)(() => {
|
|
1539
1857
|
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
1540
1858
|
}, []);
|
|
1541
|
-
const emitColorChange = (0,
|
|
1859
|
+
const emitColorChange = (0, import_react17.useCallback)(
|
|
1542
1860
|
(nextState) => {
|
|
1543
1861
|
setPickerState(nextState);
|
|
1544
1862
|
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
@@ -1546,10 +1864,10 @@ var ColorPicker = ({
|
|
|
1546
1864
|
},
|
|
1547
1865
|
[alpha, onChange]
|
|
1548
1866
|
);
|
|
1549
|
-
const latest = (0,
|
|
1867
|
+
const latest = (0, import_react17.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
1550
1868
|
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
1551
|
-
const endDragRef = (0,
|
|
1552
|
-
(0,
|
|
1869
|
+
const endDragRef = (0, import_react17.useRef)(null);
|
|
1870
|
+
(0, import_react17.useEffect)(() => () => endDragRef.current?.(), []);
|
|
1553
1871
|
const startDrag = (e, next) => {
|
|
1554
1872
|
if (disabled) return;
|
|
1555
1873
|
e.preventDefault();
|
|
@@ -1651,7 +1969,7 @@ var ColorPicker = ({
|
|
|
1651
1969
|
} catch {
|
|
1652
1970
|
}
|
|
1653
1971
|
};
|
|
1654
|
-
const contrastResult = (0,
|
|
1972
|
+
const contrastResult = (0, import_react17.useMemo)(() => {
|
|
1655
1973
|
if (!contrastAgainst) return null;
|
|
1656
1974
|
const fg = (0, import_color.parseColor)(value);
|
|
1657
1975
|
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
@@ -1663,7 +1981,7 @@ var ColorPicker = ({
|
|
|
1663
1981
|
}, [value, contrastAgainst]);
|
|
1664
1982
|
const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
|
|
1665
1983
|
const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
|
|
1666
|
-
return /* @__PURE__ */ (0,
|
|
1984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1667
1985
|
"div",
|
|
1668
1986
|
{
|
|
1669
1987
|
id: pickerId,
|
|
@@ -1687,7 +2005,7 @@ var ColorPicker = ({
|
|
|
1687
2005
|
pointerEvents: disabled ? "none" : "auto"
|
|
1688
2006
|
},
|
|
1689
2007
|
children: [
|
|
1690
|
-
/* @__PURE__ */ (0,
|
|
2008
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1691
2009
|
"span",
|
|
1692
2010
|
{
|
|
1693
2011
|
role: "status",
|
|
@@ -1706,7 +2024,7 @@ var ColorPicker = ({
|
|
|
1706
2024
|
children: liveDescription
|
|
1707
2025
|
}
|
|
1708
2026
|
),
|
|
1709
|
-
/* @__PURE__ */ (0,
|
|
2027
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1710
2028
|
"div",
|
|
1711
2029
|
{
|
|
1712
2030
|
role: "slider",
|
|
@@ -1728,7 +2046,7 @@ var ColorPicker = ({
|
|
|
1728
2046
|
touchAction: "none",
|
|
1729
2047
|
outline: "none"
|
|
1730
2048
|
},
|
|
1731
|
-
children: /* @__PURE__ */ (0,
|
|
2049
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1732
2050
|
"div",
|
|
1733
2051
|
{
|
|
1734
2052
|
style: {
|
|
@@ -1748,7 +2066,7 @@ var ColorPicker = ({
|
|
|
1748
2066
|
)
|
|
1749
2067
|
}
|
|
1750
2068
|
),
|
|
1751
|
-
/* @__PURE__ */ (0,
|
|
2069
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1752
2070
|
"div",
|
|
1753
2071
|
{
|
|
1754
2072
|
role: "slider",
|
|
@@ -1771,7 +2089,7 @@ var ColorPicker = ({
|
|
|
1771
2089
|
touchAction: "none",
|
|
1772
2090
|
outline: "none"
|
|
1773
2091
|
},
|
|
1774
|
-
children: /* @__PURE__ */ (0,
|
|
2092
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1775
2093
|
"div",
|
|
1776
2094
|
{
|
|
1777
2095
|
style: {
|
|
@@ -1791,7 +2109,7 @@ var ColorPicker = ({
|
|
|
1791
2109
|
)
|
|
1792
2110
|
}
|
|
1793
2111
|
),
|
|
1794
|
-
alpha && /* @__PURE__ */ (0,
|
|
2112
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1795
2113
|
"div",
|
|
1796
2114
|
{
|
|
1797
2115
|
role: "slider",
|
|
@@ -1817,7 +2135,7 @@ var ColorPicker = ({
|
|
|
1817
2135
|
overflow: "hidden"
|
|
1818
2136
|
},
|
|
1819
2137
|
children: [
|
|
1820
|
-
/* @__PURE__ */ (0,
|
|
2138
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1821
2139
|
"div",
|
|
1822
2140
|
{
|
|
1823
2141
|
style: {
|
|
@@ -1827,7 +2145,7 @@ var ColorPicker = ({
|
|
|
1827
2145
|
}
|
|
1828
2146
|
}
|
|
1829
2147
|
),
|
|
1830
|
-
/* @__PURE__ */ (0,
|
|
2148
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1831
2149
|
"div",
|
|
1832
2150
|
{
|
|
1833
2151
|
style: {
|
|
@@ -1848,8 +2166,8 @@ var ColorPicker = ({
|
|
|
1848
2166
|
]
|
|
1849
2167
|
}
|
|
1850
2168
|
),
|
|
1851
|
-
/* @__PURE__ */ (0,
|
|
1852
|
-
/* @__PURE__ */ (0,
|
|
2169
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
|
|
2170
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1853
2171
|
"div",
|
|
1854
2172
|
{
|
|
1855
2173
|
style: {
|
|
@@ -1863,7 +2181,7 @@ var ColorPicker = ({
|
|
|
1863
2181
|
flexShrink: 0,
|
|
1864
2182
|
border: "1px solid rgba(255,255,255,0.15)"
|
|
1865
2183
|
},
|
|
1866
|
-
children: /* @__PURE__ */ (0,
|
|
2184
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1867
2185
|
"div",
|
|
1868
2186
|
{
|
|
1869
2187
|
style: {
|
|
@@ -1875,7 +2193,7 @@ var ColorPicker = ({
|
|
|
1875
2193
|
)
|
|
1876
2194
|
}
|
|
1877
2195
|
),
|
|
1878
|
-
/* @__PURE__ */ (0,
|
|
2196
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1879
2197
|
"input",
|
|
1880
2198
|
{
|
|
1881
2199
|
type: "text",
|
|
@@ -1905,7 +2223,7 @@ var ColorPicker = ({
|
|
|
1905
2223
|
}
|
|
1906
2224
|
}
|
|
1907
2225
|
),
|
|
1908
|
-
hasEyeDropper && /* @__PURE__ */ (0,
|
|
2226
|
+
hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1909
2227
|
"button",
|
|
1910
2228
|
{
|
|
1911
2229
|
type: "button",
|
|
@@ -1925,7 +2243,7 @@ var ColorPicker = ({
|
|
|
1925
2243
|
color: "inherit",
|
|
1926
2244
|
cursor: disabled ? "default" : "pointer"
|
|
1927
2245
|
},
|
|
1928
|
-
children: /* @__PURE__ */ (0,
|
|
2246
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1929
2247
|
"svg",
|
|
1930
2248
|
{
|
|
1931
2249
|
width: "14",
|
|
@@ -1937,16 +2255,16 @@ var ColorPicker = ({
|
|
|
1937
2255
|
strokeLinecap: "round",
|
|
1938
2256
|
strokeLinejoin: "round",
|
|
1939
2257
|
children: [
|
|
1940
|
-
/* @__PURE__ */ (0,
|
|
1941
|
-
/* @__PURE__ */ (0,
|
|
1942
|
-
/* @__PURE__ */ (0,
|
|
2258
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m19 11-8-8-8.5 8.5a2.12 2.12 0 0 0 0 3l2.5 2.5 1.5-1.5" }),
|
|
2259
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
|
|
2260
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m14 6 4 4" })
|
|
1943
2261
|
]
|
|
1944
2262
|
}
|
|
1945
2263
|
)
|
|
1946
2264
|
}
|
|
1947
2265
|
)
|
|
1948
2266
|
] }),
|
|
1949
|
-
isClipped && /* @__PURE__ */ (0,
|
|
2267
|
+
isClipped && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1950
2268
|
"div",
|
|
1951
2269
|
{
|
|
1952
2270
|
role: "note",
|
|
@@ -1962,10 +2280,10 @@ var ColorPicker = ({
|
|
|
1962
2280
|
borderRadius: "4px",
|
|
1963
2281
|
alignSelf: "flex-start"
|
|
1964
2282
|
},
|
|
1965
|
-
children: /* @__PURE__ */ (0,
|
|
2283
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
|
|
1966
2284
|
}
|
|
1967
2285
|
),
|
|
1968
|
-
contrastResult && /* @__PURE__ */ (0,
|
|
2286
|
+
contrastResult && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1969
2287
|
"div",
|
|
1970
2288
|
{
|
|
1971
2289
|
style: {
|
|
@@ -1979,15 +2297,15 @@ var ColorPicker = ({
|
|
|
1979
2297
|
border: "1px solid rgba(255,255,255,0.1)"
|
|
1980
2298
|
},
|
|
1981
2299
|
children: [
|
|
1982
|
-
/* @__PURE__ */ (0,
|
|
2300
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { children: [
|
|
1983
2301
|
"Contrast: ",
|
|
1984
|
-
/* @__PURE__ */ (0,
|
|
2302
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("strong", { children: [
|
|
1985
2303
|
contrastResult.ratio.toFixed(2),
|
|
1986
2304
|
":1"
|
|
1987
2305
|
] })
|
|
1988
2306
|
] }),
|
|
1989
|
-
/* @__PURE__ */ (0,
|
|
1990
|
-
/* @__PURE__ */ (0,
|
|
2307
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
2308
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1991
2309
|
"span",
|
|
1992
2310
|
{
|
|
1993
2311
|
style: {
|
|
@@ -2000,7 +2318,7 @@ var ColorPicker = ({
|
|
|
2000
2318
|
]
|
|
2001
2319
|
}
|
|
2002
2320
|
),
|
|
2003
|
-
/* @__PURE__ */ (0,
|
|
2321
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2004
2322
|
"span",
|
|
2005
2323
|
{
|
|
2006
2324
|
style: {
|
|
@@ -2017,9 +2335,9 @@ var ColorPicker = ({
|
|
|
2017
2335
|
]
|
|
2018
2336
|
}
|
|
2019
2337
|
),
|
|
2020
|
-
swatches && swatches.length > 0 && /* @__PURE__ */ (0,
|
|
2021
|
-
/* @__PURE__ */ (0,
|
|
2022
|
-
/* @__PURE__ */ (0,
|
|
2338
|
+
swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
2339
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
|
|
2340
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2023
2341
|
"button",
|
|
2024
2342
|
{
|
|
2025
2343
|
type: "button",
|
|
@@ -2045,9 +2363,9 @@ var ColorPicker = ({
|
|
|
2045
2363
|
`${color}-${idx}`
|
|
2046
2364
|
)) })
|
|
2047
2365
|
] }),
|
|
2048
|
-
activeRecent.length > 0 && /* @__PURE__ */ (0,
|
|
2049
|
-
/* @__PURE__ */ (0,
|
|
2050
|
-
/* @__PURE__ */ (0,
|
|
2366
|
+
activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
2367
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
|
|
2368
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2051
2369
|
"button",
|
|
2052
2370
|
{
|
|
2053
2371
|
type: "button",
|
|
@@ -2078,9 +2396,9 @@ var ColorPicker = ({
|
|
|
2078
2396
|
};
|
|
2079
2397
|
|
|
2080
2398
|
// src/color/DualColorPicker.tsx
|
|
2081
|
-
var
|
|
2399
|
+
var import_react18 = require("react");
|
|
2082
2400
|
var import_color2 = require("@pixerate/editor/color");
|
|
2083
|
-
var
|
|
2401
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2084
2402
|
function DualColorPicker({
|
|
2085
2403
|
value,
|
|
2086
2404
|
onChange,
|
|
@@ -2095,8 +2413,8 @@ function DualColorPicker({
|
|
|
2095
2413
|
disabled = false,
|
|
2096
2414
|
className = ""
|
|
2097
2415
|
}) {
|
|
2098
|
-
const sameId = (0,
|
|
2099
|
-
const [internalScheme, setInternalScheme] = (0,
|
|
2416
|
+
const sameId = (0, import_react18.useId)();
|
|
2417
|
+
const [internalScheme, setInternalScheme] = (0, import_react18.useState)("light");
|
|
2100
2418
|
const activeScheme = controlledScheme ?? internalScheme;
|
|
2101
2419
|
const handleSchemeSelect = (nextScheme) => {
|
|
2102
2420
|
if (onSchemeChange) {
|
|
@@ -2107,7 +2425,7 @@ function DualColorPicker({
|
|
|
2107
2425
|
};
|
|
2108
2426
|
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
2109
2427
|
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
2110
|
-
const [sameInBoth, setSameInBoth] = (0,
|
|
2428
|
+
const [sameInBoth, setSameInBoth] = (0, import_react18.useState)(isSame);
|
|
2111
2429
|
const handleSameToggle = (e) => {
|
|
2112
2430
|
const nextSame = e.target.checked;
|
|
2113
2431
|
setSameInBoth(nextSame);
|
|
@@ -2139,7 +2457,7 @@ function DualColorPicker({
|
|
|
2139
2457
|
const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
|
|
2140
2458
|
const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
|
|
2141
2459
|
const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
|
|
2142
|
-
return /* @__PURE__ */ (0,
|
|
2460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2143
2461
|
"div",
|
|
2144
2462
|
{
|
|
2145
2463
|
className: `pixerate-dual-color-picker ${className}`,
|
|
@@ -2158,7 +2476,7 @@ function DualColorPicker({
|
|
|
2158
2476
|
boxSizing: "border-box"
|
|
2159
2477
|
},
|
|
2160
2478
|
children: [
|
|
2161
|
-
/* @__PURE__ */ (0,
|
|
2479
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2162
2480
|
"div",
|
|
2163
2481
|
{
|
|
2164
2482
|
role: "tablist",
|
|
@@ -2171,7 +2489,7 @@ function DualColorPicker({
|
|
|
2171
2489
|
gap: "2px"
|
|
2172
2490
|
},
|
|
2173
2491
|
children: [
|
|
2174
|
-
/* @__PURE__ */ (0,
|
|
2492
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2175
2493
|
"button",
|
|
2176
2494
|
{
|
|
2177
2495
|
type: "button",
|
|
@@ -2194,7 +2512,7 @@ function DualColorPicker({
|
|
|
2194
2512
|
children: "Light"
|
|
2195
2513
|
}
|
|
2196
2514
|
),
|
|
2197
|
-
/* @__PURE__ */ (0,
|
|
2515
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2198
2516
|
"button",
|
|
2199
2517
|
{
|
|
2200
2518
|
type: "button",
|
|
@@ -2220,8 +2538,8 @@ function DualColorPicker({
|
|
|
2220
2538
|
]
|
|
2221
2539
|
}
|
|
2222
2540
|
),
|
|
2223
|
-
/* @__PURE__ */ (0,
|
|
2224
|
-
/* @__PURE__ */ (0,
|
|
2541
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
2542
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2225
2543
|
"button",
|
|
2226
2544
|
{
|
|
2227
2545
|
type: "button",
|
|
@@ -2243,7 +2561,7 @@ function DualColorPicker({
|
|
|
2243
2561
|
outline: "none"
|
|
2244
2562
|
},
|
|
2245
2563
|
children: [
|
|
2246
|
-
/* @__PURE__ */ (0,
|
|
2564
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2247
2565
|
"span",
|
|
2248
2566
|
{
|
|
2249
2567
|
style: {
|
|
@@ -2255,11 +2573,11 @@ function DualColorPicker({
|
|
|
2255
2573
|
}
|
|
2256
2574
|
}
|
|
2257
2575
|
),
|
|
2258
|
-
/* @__PURE__ */ (0,
|
|
2576
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
|
|
2259
2577
|
]
|
|
2260
2578
|
}
|
|
2261
2579
|
),
|
|
2262
|
-
/* @__PURE__ */ (0,
|
|
2580
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2263
2581
|
"button",
|
|
2264
2582
|
{
|
|
2265
2583
|
type: "button",
|
|
@@ -2281,7 +2599,7 @@ function DualColorPicker({
|
|
|
2281
2599
|
outline: "none"
|
|
2282
2600
|
},
|
|
2283
2601
|
children: [
|
|
2284
|
-
/* @__PURE__ */ (0,
|
|
2602
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2285
2603
|
"span",
|
|
2286
2604
|
{
|
|
2287
2605
|
style: {
|
|
@@ -2293,12 +2611,12 @@ function DualColorPicker({
|
|
|
2293
2611
|
}
|
|
2294
2612
|
}
|
|
2295
2613
|
),
|
|
2296
|
-
/* @__PURE__ */ (0,
|
|
2614
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
|
|
2297
2615
|
]
|
|
2298
2616
|
}
|
|
2299
2617
|
)
|
|
2300
2618
|
] }),
|
|
2301
|
-
/* @__PURE__ */ (0,
|
|
2619
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2302
2620
|
"div",
|
|
2303
2621
|
{
|
|
2304
2622
|
style: {
|
|
@@ -2309,7 +2627,7 @@ function DualColorPicker({
|
|
|
2309
2627
|
padding: "2px 0"
|
|
2310
2628
|
},
|
|
2311
2629
|
children: [
|
|
2312
|
-
/* @__PURE__ */ (0,
|
|
2630
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2313
2631
|
"label",
|
|
2314
2632
|
{
|
|
2315
2633
|
htmlFor: sameId,
|
|
@@ -2323,7 +2641,7 @@ function DualColorPicker({
|
|
|
2323
2641
|
color: "#c4cad4"
|
|
2324
2642
|
},
|
|
2325
2643
|
children: [
|
|
2326
|
-
/* @__PURE__ */ (0,
|
|
2644
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2327
2645
|
"input",
|
|
2328
2646
|
{
|
|
2329
2647
|
id: sameId,
|
|
@@ -2334,11 +2652,11 @@ function DualColorPicker({
|
|
|
2334
2652
|
style: { cursor: disabled ? "not-allowed" : "pointer" }
|
|
2335
2653
|
}
|
|
2336
2654
|
),
|
|
2337
|
-
/* @__PURE__ */ (0,
|
|
2655
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: "Same in both" })
|
|
2338
2656
|
]
|
|
2339
2657
|
}
|
|
2340
2658
|
),
|
|
2341
|
-
/* @__PURE__ */ (0,
|
|
2659
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2342
2660
|
"button",
|
|
2343
2661
|
{
|
|
2344
2662
|
type: "button",
|
|
@@ -2360,7 +2678,7 @@ function DualColorPicker({
|
|
|
2360
2678
|
]
|
|
2361
2679
|
}
|
|
2362
2680
|
),
|
|
2363
|
-
dualContrast && /* @__PURE__ */ (0,
|
|
2681
|
+
dualContrast && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2364
2682
|
"div",
|
|
2365
2683
|
{
|
|
2366
2684
|
"data-testid": "dual-contrast-summary",
|
|
@@ -2374,20 +2692,20 @@ function DualColorPicker({
|
|
|
2374
2692
|
color: "#8c95a6"
|
|
2375
2693
|
},
|
|
2376
2694
|
children: [
|
|
2377
|
-
/* @__PURE__ */ (0,
|
|
2695
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
|
|
2378
2696
|
"Light:",
|
|
2379
2697
|
" ",
|
|
2380
|
-
/* @__PURE__ */ (0,
|
|
2698
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2381
2699
|
dualContrast.light.ratio.toFixed(2),
|
|
2382
2700
|
" (",
|
|
2383
2701
|
dualContrast.light.level,
|
|
2384
2702
|
")"
|
|
2385
2703
|
] })
|
|
2386
2704
|
] }),
|
|
2387
|
-
/* @__PURE__ */ (0,
|
|
2705
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
|
|
2388
2706
|
"Dark:",
|
|
2389
2707
|
" ",
|
|
2390
|
-
/* @__PURE__ */ (0,
|
|
2708
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2391
2709
|
dualContrast.dark.ratio.toFixed(2),
|
|
2392
2710
|
" (",
|
|
2393
2711
|
dualContrast.dark.level,
|
|
@@ -2397,7 +2715,7 @@ function DualColorPicker({
|
|
|
2397
2715
|
]
|
|
2398
2716
|
}
|
|
2399
2717
|
),
|
|
2400
|
-
/* @__PURE__ */ (0,
|
|
2718
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2401
2719
|
ColorPicker,
|
|
2402
2720
|
{
|
|
2403
2721
|
value: activeColor,
|
|
@@ -2416,7 +2734,7 @@ function DualColorPicker({
|
|
|
2416
2734
|
}
|
|
2417
2735
|
|
|
2418
2736
|
// src/color/useColorScheme.ts
|
|
2419
|
-
var
|
|
2737
|
+
var import_react19 = require("react");
|
|
2420
2738
|
var import_color3 = require("@pixerate/editor/color");
|
|
2421
2739
|
function getSnapshot(attribute) {
|
|
2422
2740
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -2441,7 +2759,7 @@ function getServerSnapshot() {
|
|
|
2441
2759
|
function useColorScheme(options) {
|
|
2442
2760
|
const override = options?.override;
|
|
2443
2761
|
const attribute = options?.attribute;
|
|
2444
|
-
const subscribe = (0,
|
|
2762
|
+
const subscribe = (0, import_react19.useMemo)(() => {
|
|
2445
2763
|
return (callback) => {
|
|
2446
2764
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2447
2765
|
return () => {
|
|
@@ -2467,7 +2785,7 @@ function useColorScheme(options) {
|
|
|
2467
2785
|
};
|
|
2468
2786
|
};
|
|
2469
2787
|
}, [attribute]);
|
|
2470
|
-
const detected = (0,
|
|
2788
|
+
const detected = (0, import_react19.useSyncExternalStore)(
|
|
2471
2789
|
subscribe,
|
|
2472
2790
|
() => getSnapshot(attribute),
|
|
2473
2791
|
getServerSnapshot
|
|
@@ -2484,7 +2802,7 @@ function useResolvedColor(value, scheme) {
|
|
|
2484
2802
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
2485
2803
|
|
|
2486
2804
|
// src/parameters/fields.tsx
|
|
2487
|
-
var
|
|
2805
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2488
2806
|
var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
2489
2807
|
var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
|
|
2490
2808
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
@@ -2508,7 +2826,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2508
2826
|
onKeyDown: keyDown,
|
|
2509
2827
|
...rest
|
|
2510
2828
|
};
|
|
2511
|
-
return multiline ? /* @__PURE__ */ (0,
|
|
2829
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "text", ...props }, value);
|
|
2512
2830
|
}
|
|
2513
2831
|
var plainNumber = (field2, value) => (0, import_parameters.formatParameterNumber)({ ...field2, unit: void 0 }, value);
|
|
2514
2832
|
function ParameterNumberInput({
|
|
@@ -2519,8 +2837,8 @@ function ParameterNumberInput({
|
|
|
2519
2837
|
id,
|
|
2520
2838
|
"aria-label": ariaLabel
|
|
2521
2839
|
}) {
|
|
2522
|
-
return /* @__PURE__ */ (0,
|
|
2523
|
-
/* @__PURE__ */ (0,
|
|
2840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
2841
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2524
2842
|
ParameterCommitInput,
|
|
2525
2843
|
{
|
|
2526
2844
|
id,
|
|
@@ -2542,21 +2860,21 @@ function ParameterNumberInput({
|
|
|
2542
2860
|
}
|
|
2543
2861
|
}
|
|
2544
2862
|
),
|
|
2545
|
-
field2.unit && /* @__PURE__ */ (0,
|
|
2863
|
+
field2.unit && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field2.unit })
|
|
2546
2864
|
] });
|
|
2547
2865
|
}
|
|
2548
2866
|
function ParameterSlider(props) {
|
|
2549
2867
|
const { field: field2, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
2550
|
-
const dragging = (0,
|
|
2868
|
+
const dragging = (0, import_react20.useRef)(false);
|
|
2551
2869
|
const end = () => {
|
|
2552
2870
|
if (!dragging.current) return;
|
|
2553
2871
|
dragging.current = false;
|
|
2554
2872
|
onGestureEnd?.();
|
|
2555
2873
|
};
|
|
2556
|
-
if (!(0, import_parameters.isSliderField)(field2)) return /* @__PURE__ */ (0,
|
|
2874
|
+
if (!(0, import_parameters.isSliderField)(field2)) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterNumberInput, { ...props });
|
|
2557
2875
|
const step = (0, import_parameters.parameterStep)(field2);
|
|
2558
|
-
return /* @__PURE__ */ (0,
|
|
2559
|
-
/* @__PURE__ */ (0,
|
|
2876
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2877
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2560
2878
|
"input",
|
|
2561
2879
|
{
|
|
2562
2880
|
type: "range",
|
|
@@ -2579,11 +2897,11 @@ function ParameterSlider(props) {
|
|
|
2579
2897
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field2, Number(e.target.value)))
|
|
2580
2898
|
}
|
|
2581
2899
|
),
|
|
2582
|
-
/* @__PURE__ */ (0,
|
|
2900
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field2)} value` }) })
|
|
2583
2901
|
] });
|
|
2584
2902
|
}
|
|
2585
2903
|
function ParameterToggle({ field: field2, value, onChange, disabled, id }) {
|
|
2586
|
-
return /* @__PURE__ */ (0,
|
|
2904
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2587
2905
|
"button",
|
|
2588
2906
|
{
|
|
2589
2907
|
type: "button",
|
|
@@ -2594,7 +2912,7 @@ function ParameterToggle({ field: field2, value, onChange, disabled, id }) {
|
|
|
2594
2912
|
disabled: disabled || field2.readOnly,
|
|
2595
2913
|
onClick: () => onChange(!value),
|
|
2596
2914
|
className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-50 ${value ? "bg-primary" : "bg-muted"}`,
|
|
2597
|
-
children: /* @__PURE__ */ (0,
|
|
2915
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2598
2916
|
"span",
|
|
2599
2917
|
{
|
|
2600
2918
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -2607,7 +2925,7 @@ function ParameterSelect({ field: field2, value, onChange, disabled, id }) {
|
|
|
2607
2925
|
const options = (0, import_parameters.getChoiceOptions)(field2);
|
|
2608
2926
|
const off = disabled || field2.readOnly;
|
|
2609
2927
|
if (field2.control === "segmented") {
|
|
2610
|
-
return /* @__PURE__ */ (0,
|
|
2928
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field2), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2611
2929
|
"button",
|
|
2612
2930
|
{
|
|
2613
2931
|
type: "button",
|
|
@@ -2623,7 +2941,7 @@ function ParameterSelect({ field: field2, value, onChange, disabled, id }) {
|
|
|
2623
2941
|
)) });
|
|
2624
2942
|
}
|
|
2625
2943
|
const index = options.findIndex((o) => o.value === value);
|
|
2626
|
-
return /* @__PURE__ */ (0,
|
|
2944
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2627
2945
|
"select",
|
|
2628
2946
|
{
|
|
2629
2947
|
id,
|
|
@@ -2635,22 +2953,22 @@ function ParameterSelect({ field: field2, value, onChange, disabled, id }) {
|
|
|
2635
2953
|
if (option) onChange(option.value);
|
|
2636
2954
|
},
|
|
2637
2955
|
className: parameterInputClass,
|
|
2638
|
-
children: options.map((o, i) => /* @__PURE__ */ (0,
|
|
2956
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
2639
2957
|
}
|
|
2640
2958
|
);
|
|
2641
2959
|
}
|
|
2642
2960
|
function ParameterColor({ field: field2, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
2643
|
-
const [open, setOpen] = (0,
|
|
2644
|
-
const containerRef = (0,
|
|
2645
|
-
const buttonRef = (0,
|
|
2646
|
-
const popoverRef = (0,
|
|
2961
|
+
const [open, setOpen] = (0, import_react20.useState)(false);
|
|
2962
|
+
const containerRef = (0, import_react20.useRef)(null);
|
|
2963
|
+
const buttonRef = (0, import_react20.useRef)(null);
|
|
2964
|
+
const popoverRef = (0, import_react20.useRef)(null);
|
|
2647
2965
|
const alpha = !!field2.alpha;
|
|
2648
2966
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2649
2967
|
const rgb = hex.slice(0, 7);
|
|
2650
2968
|
const shown = alpha ? hex : rgb;
|
|
2651
2969
|
const off = disabled || field2.readOnly;
|
|
2652
2970
|
const name = (0, import_parameters.parameterLabel)(field2);
|
|
2653
|
-
(0,
|
|
2971
|
+
(0, import_react20.useEffect)(() => {
|
|
2654
2972
|
if (!open) return;
|
|
2655
2973
|
const onPointerDown = (e) => {
|
|
2656
2974
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2671,9 +2989,9 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
|
|
|
2671
2989
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
2672
2990
|
};
|
|
2673
2991
|
}, [open]);
|
|
2674
|
-
return /* @__PURE__ */ (0,
|
|
2675
|
-
/* @__PURE__ */ (0,
|
|
2676
|
-
/* @__PURE__ */ (0,
|
|
2992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
2993
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2994
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2677
2995
|
"button",
|
|
2678
2996
|
{
|
|
2679
2997
|
ref: buttonRef,
|
|
@@ -2684,10 +3002,10 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
|
|
|
2684
3002
|
disabled: off,
|
|
2685
3003
|
onClick: () => setOpen((prev) => !prev),
|
|
2686
3004
|
className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50",
|
|
2687
|
-
children: /* @__PURE__ */ (0,
|
|
3005
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
2688
3006
|
}
|
|
2689
3007
|
),
|
|
2690
|
-
/* @__PURE__ */ (0,
|
|
3008
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2691
3009
|
ParameterCommitInput,
|
|
2692
3010
|
{
|
|
2693
3011
|
id,
|
|
@@ -2703,7 +3021,7 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
|
|
|
2703
3021
|
}
|
|
2704
3022
|
)
|
|
2705
3023
|
] }),
|
|
2706
|
-
open && /* @__PURE__ */ (0,
|
|
3024
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2707
3025
|
"div",
|
|
2708
3026
|
{
|
|
2709
3027
|
ref: popoverRef,
|
|
@@ -2717,7 +3035,7 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
|
|
|
2717
3035
|
},
|
|
2718
3036
|
className: "absolute left-0 top-full z-50 mt-1 w-64 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-xl",
|
|
2719
3037
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
2720
|
-
children: /* @__PURE__ */ (0,
|
|
3038
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2721
3039
|
ColorPicker,
|
|
2722
3040
|
{
|
|
2723
3041
|
value: shown,
|
|
@@ -2735,11 +3053,11 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
|
|
|
2735
3053
|
}
|
|
2736
3054
|
function ParameterVector({ field: field2, value, onChange, disabled, id }) {
|
|
2737
3055
|
const size = (0, import_parameters.vectorSize)(field2);
|
|
2738
|
-
return /* @__PURE__ */ (0,
|
|
3056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
2739
3057
|
const component = (0, import_parameters.vectorComponentField)(field2, i);
|
|
2740
|
-
return /* @__PURE__ */ (0,
|
|
2741
|
-
/* @__PURE__ */ (0,
|
|
2742
|
-
/* @__PURE__ */ (0,
|
|
3058
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
3059
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
3060
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2743
3061
|
ParameterNumberInput,
|
|
2744
3062
|
{
|
|
2745
3063
|
field: component,
|
|
@@ -2756,11 +3074,11 @@ function ParameterVector({ field: field2, value, onChange, disabled, id }) {
|
|
|
2756
3074
|
function ParameterImage({ field: field2, value, onChange, disabled, id, resolveFile }) {
|
|
2757
3075
|
const off = disabled || field2.readOnly;
|
|
2758
3076
|
const name = (0, import_parameters.parameterLabel)(field2);
|
|
2759
|
-
return /* @__PURE__ */ (0,
|
|
2760
|
-
/* @__PURE__ */ (0,
|
|
2761
|
-
/* @__PURE__ */ (0,
|
|
2762
|
-
/* @__PURE__ */ (0,
|
|
2763
|
-
/* @__PURE__ */ (0,
|
|
3077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-1.5", children: [
|
|
3078
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3079
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
3080
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3081
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2764
3082
|
ParameterCommitInput,
|
|
2765
3083
|
{
|
|
2766
3084
|
id,
|
|
@@ -2771,10 +3089,10 @@ function ParameterImage({ field: field2, value, onChange, disabled, id, resolveF
|
|
|
2771
3089
|
onCommit: (text) => onChange(text.trim())
|
|
2772
3090
|
}
|
|
2773
3091
|
),
|
|
2774
|
-
/* @__PURE__ */ (0,
|
|
2775
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
3092
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex gap-1", children: [
|
|
3093
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
|
|
2776
3094
|
"Choose file\u2026",
|
|
2777
|
-
/* @__PURE__ */ (0,
|
|
3095
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2778
3096
|
"input",
|
|
2779
3097
|
{
|
|
2780
3098
|
type: "file",
|
|
@@ -2790,11 +3108,11 @@ function ParameterImage({ field: field2, value, onChange, disabled, id, resolveF
|
|
|
2790
3108
|
}
|
|
2791
3109
|
)
|
|
2792
3110
|
] }),
|
|
2793
|
-
value && /* @__PURE__ */ (0,
|
|
3111
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
|
|
2794
3112
|
] })
|
|
2795
3113
|
] })
|
|
2796
3114
|
] }),
|
|
2797
|
-
field2.options && field2.options.length > 0 && /* @__PURE__ */ (0,
|
|
3115
|
+
field2.options && field2.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-wrap gap-1", children: field2.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2798
3116
|
"button",
|
|
2799
3117
|
{
|
|
2800
3118
|
type: "button",
|
|
@@ -2804,14 +3122,14 @@ function ParameterImage({ field: field2, value, onChange, disabled, id, resolveF
|
|
|
2804
3122
|
disabled: off,
|
|
2805
3123
|
onClick: () => onChange(o.url),
|
|
2806
3124
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
2807
|
-
children: /* @__PURE__ */ (0,
|
|
3125
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
2808
3126
|
},
|
|
2809
3127
|
o.url
|
|
2810
3128
|
)) })
|
|
2811
3129
|
] });
|
|
2812
3130
|
}
|
|
2813
3131
|
function ParameterText({ field: field2, value, onChange, disabled, id }) {
|
|
2814
|
-
return /* @__PURE__ */ (0,
|
|
3132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2815
3133
|
ParameterCommitInput,
|
|
2816
3134
|
{
|
|
2817
3135
|
id,
|
|
@@ -2830,24 +3148,24 @@ function ParameterFieldControl({ field: field2, value, onChange, resolveFile, ..
|
|
|
2830
3148
|
switch (field2.type) {
|
|
2831
3149
|
case "number":
|
|
2832
3150
|
case "int":
|
|
2833
|
-
return /* @__PURE__ */ (0,
|
|
3151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterSlider, { field: field2, value, onChange: set, ...rest });
|
|
2834
3152
|
case "boolean":
|
|
2835
|
-
return /* @__PURE__ */ (0,
|
|
3153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterToggle, { field: field2, value, onChange: set, ...rest });
|
|
2836
3154
|
case "choice":
|
|
2837
|
-
return /* @__PURE__ */ (0,
|
|
3155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterSelect, { field: field2, value, onChange: set, ...rest });
|
|
2838
3156
|
case "color":
|
|
2839
|
-
return /* @__PURE__ */ (0,
|
|
3157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterColor, { field: field2, value, onChange: set, ...rest });
|
|
2840
3158
|
case "vector":
|
|
2841
|
-
return /* @__PURE__ */ (0,
|
|
3159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterVector, { field: field2, value, onChange: set, ...rest });
|
|
2842
3160
|
case "image":
|
|
2843
|
-
return /* @__PURE__ */ (0,
|
|
3161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterImage, { field: field2, value, onChange: set, resolveFile, ...rest });
|
|
2844
3162
|
case "text":
|
|
2845
|
-
return /* @__PURE__ */ (0,
|
|
3163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ParameterText, { field: field2, value, onChange: set, ...rest });
|
|
2846
3164
|
}
|
|
2847
3165
|
}
|
|
2848
3166
|
|
|
2849
3167
|
// src/effects/EffectParameters.tsx
|
|
2850
|
-
var
|
|
3168
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2851
3169
|
function EffectParameters({
|
|
2852
3170
|
description,
|
|
2853
3171
|
values,
|
|
@@ -2857,15 +3175,16 @@ function EffectParameters({
|
|
|
2857
3175
|
onPreset,
|
|
2858
3176
|
onPresetName,
|
|
2859
3177
|
renderControlAddon,
|
|
3178
|
+
fonts,
|
|
2860
3179
|
disabled = false,
|
|
2861
3180
|
className = ""
|
|
2862
3181
|
}) {
|
|
2863
|
-
const fields = (0,
|
|
2864
|
-
const idBase = (0,
|
|
2865
|
-
const gesture =
|
|
2866
|
-
const count =
|
|
2867
|
-
return /* @__PURE__ */ (0,
|
|
2868
|
-
(onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0,
|
|
3182
|
+
const fields = (0, import_react21.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
3183
|
+
const idBase = (0, import_react21.useId)();
|
|
3184
|
+
const gesture = import_react21.default.useRef(null);
|
|
3185
|
+
const count = import_react21.default.useRef(0);
|
|
3186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
3187
|
+
(onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2869
3188
|
"select",
|
|
2870
3189
|
{
|
|
2871
3190
|
className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
|
|
@@ -2883,8 +3202,8 @@ function EffectParameters({
|
|
|
2883
3202
|
}
|
|
2884
3203
|
},
|
|
2885
3204
|
children: [
|
|
2886
|
-
/* @__PURE__ */ (0,
|
|
2887
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
3205
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "", children: "Presets\u2026" }),
|
|
3206
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: p.name, children: p.name }, p.name))
|
|
2888
3207
|
]
|
|
2889
3208
|
}
|
|
2890
3209
|
),
|
|
@@ -2894,14 +3213,14 @@ function EffectParameters({
|
|
|
2894
3213
|
const keyed = keyframed?.has(field2.id) ?? false;
|
|
2895
3214
|
const value = (0, import_effects3.effectFieldValue)(field2, values[field2.id]);
|
|
2896
3215
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field2.default);
|
|
2897
|
-
return /* @__PURE__ */ (0,
|
|
2898
|
-
/* @__PURE__ */ (0,
|
|
2899
|
-
/* @__PURE__ */ (0,
|
|
2900
|
-
keyed && /* @__PURE__ */ (0,
|
|
3216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-1", "data-effect-control": field2.id, children: [
|
|
3217
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
3218
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field2.description, children: label }),
|
|
3219
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
2901
3220
|
renderControlAddon?.(field2.id),
|
|
2902
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
3221
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field2.id), children: "\u21BA" })
|
|
2903
3222
|
] }),
|
|
2904
|
-
/* @__PURE__ */ (0,
|
|
3223
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2905
3224
|
ParameterFieldControl,
|
|
2906
3225
|
{
|
|
2907
3226
|
field: field2,
|
|
@@ -2915,16 +3234,446 @@ function EffectParameters({
|
|
|
2915
3234
|
)
|
|
2916
3235
|
] }, field2.id);
|
|
2917
3236
|
}),
|
|
2918
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
3237
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
3238
|
+
] });
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
// src/effects/useEffectAuthoring.ts
|
|
3242
|
+
var import_react22 = require("react");
|
|
3243
|
+
function useEffectAuthoring(session) {
|
|
3244
|
+
return (0, import_react22.useSyncExternalStore)(
|
|
3245
|
+
(callback) => {
|
|
3246
|
+
if (!session) return () => {
|
|
3247
|
+
};
|
|
3248
|
+
return session.subscribe(callback);
|
|
3249
|
+
},
|
|
3250
|
+
() => session ? session.getState() : null,
|
|
3251
|
+
() => null
|
|
3252
|
+
);
|
|
3253
|
+
}
|
|
3254
|
+
|
|
3255
|
+
// src/effects/EffectAuthoringEditor.tsx
|
|
3256
|
+
var import_react23 = require("react");
|
|
3257
|
+
var import_effects4 = require("@pixerate/editor/effects");
|
|
3258
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3259
|
+
function EffectAuthoringEditor({
|
|
3260
|
+
session,
|
|
3261
|
+
showSource = true,
|
|
3262
|
+
showTimeline = true,
|
|
3263
|
+
previewSize = { width: 480, height: 270 },
|
|
3264
|
+
className = ""
|
|
3265
|
+
}) {
|
|
3266
|
+
const state = useEffectAuthoring(session);
|
|
3267
|
+
const canvasRef = (0, import_react23.useRef)(null);
|
|
3268
|
+
const rendererRef = (0, import_react23.useRef)(null);
|
|
3269
|
+
const [rendererReady, setRendererReady] = (0, import_react23.useState)(0);
|
|
3270
|
+
const renderingRef = (0, import_react23.useRef)(false);
|
|
3271
|
+
const pendingRef = (0, import_react23.useRef)(false);
|
|
3272
|
+
const timeRef = (0, import_react23.useRef)(0);
|
|
3273
|
+
const inputsRef = (0, import_react23.useRef)({});
|
|
3274
|
+
const [savingPreset, setSavingPreset] = (0, import_react23.useState)(false);
|
|
3275
|
+
const [presetName, setPresetName] = (0, import_react23.useState)("");
|
|
3276
|
+
const textareaRef = (0, import_react23.useRef)(null);
|
|
3277
|
+
const gutterRef = (0, import_react23.useRef)(null);
|
|
3278
|
+
const [sourceCode, setSourceCode] = (0, import_react23.useState)("");
|
|
3279
|
+
const sourceDebounceRef = (0, import_react23.useRef)(null);
|
|
3280
|
+
(0, import_react23.useEffect)(() => {
|
|
3281
|
+
if (!session) {
|
|
3282
|
+
if (rendererRef.current) {
|
|
3283
|
+
rendererRef.current.dispose();
|
|
3284
|
+
rendererRef.current = null;
|
|
3285
|
+
}
|
|
3286
|
+
return;
|
|
3287
|
+
}
|
|
3288
|
+
let live = true;
|
|
3289
|
+
let createdRenderer = null;
|
|
3290
|
+
Promise.resolve(session.createPreview(previewSize)).then((renderer) => {
|
|
3291
|
+
if (!live) {
|
|
3292
|
+
renderer.dispose();
|
|
3293
|
+
return;
|
|
3294
|
+
}
|
|
3295
|
+
createdRenderer = renderer;
|
|
3296
|
+
rendererRef.current = renderer;
|
|
3297
|
+
setRendererReady((c) => c + 1);
|
|
3298
|
+
});
|
|
3299
|
+
return () => {
|
|
3300
|
+
live = false;
|
|
3301
|
+
if (createdRenderer) {
|
|
3302
|
+
createdRenderer.dispose();
|
|
3303
|
+
}
|
|
3304
|
+
if (rendererRef.current === createdRenderer) {
|
|
3305
|
+
rendererRef.current = null;
|
|
3306
|
+
}
|
|
3307
|
+
};
|
|
3308
|
+
}, [session, previewSize.width, previewSize.height]);
|
|
3309
|
+
const pump = (0, import_react23.useCallback)(async () => {
|
|
3310
|
+
if (renderingRef.current) {
|
|
3311
|
+
pendingRef.current = true;
|
|
3312
|
+
return;
|
|
3313
|
+
}
|
|
3314
|
+
renderingRef.current = true;
|
|
3315
|
+
try {
|
|
3316
|
+
do {
|
|
3317
|
+
pendingRef.current = false;
|
|
3318
|
+
const renderer = rendererRef.current;
|
|
3319
|
+
if (!renderer) break;
|
|
3320
|
+
try {
|
|
3321
|
+
const pixels = await renderer.render({ time: timeRef.current, inputs: inputsRef.current });
|
|
3322
|
+
const ctx = rendererRef.current === renderer ? canvasRef.current?.getContext("2d") : null;
|
|
3323
|
+
if (ctx && typeof ImageData !== "undefined") {
|
|
3324
|
+
ctx.putImageData(new ImageData(new Uint8ClampedArray(pixels.data), pixels.width, pixels.height), 0, 0);
|
|
3325
|
+
}
|
|
3326
|
+
} catch {
|
|
3327
|
+
}
|
|
3328
|
+
} while (pendingRef.current);
|
|
3329
|
+
} finally {
|
|
3330
|
+
renderingRef.current = false;
|
|
3331
|
+
}
|
|
3332
|
+
}, []);
|
|
3333
|
+
const inputSpecs = state?.description.inputs;
|
|
3334
|
+
(0, import_react23.useEffect)(() => {
|
|
3335
|
+
inputsRef.current = inputSpecs ? (0, import_effects4.effectSampleInputs)({ inputs: inputSpecs }, previewSize) : {};
|
|
3336
|
+
}, [inputSpecs, previewSize.width, previewSize.height]);
|
|
3337
|
+
(0, import_react23.useEffect)(() => {
|
|
3338
|
+
if (!state) return;
|
|
3339
|
+
timeRef.current = state.time;
|
|
3340
|
+
void pump();
|
|
3341
|
+
}, [state, rendererReady, pump]);
|
|
3342
|
+
(0, import_react23.useEffect)(() => {
|
|
3343
|
+
if (state?.source !== null && state?.source !== void 0) {
|
|
3344
|
+
setSourceCode(state.source);
|
|
3345
|
+
}
|
|
3346
|
+
}, [state?.source]);
|
|
3347
|
+
(0, import_react23.useEffect)(() => {
|
|
3348
|
+
return () => {
|
|
3349
|
+
if (sourceDebounceRef.current) clearTimeout(sourceDebounceRef.current);
|
|
3350
|
+
};
|
|
3351
|
+
}, []);
|
|
3352
|
+
if (!session || !state) {
|
|
3353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: `p-4 text-center text-xs text-muted-foreground ${className}`, children: "No effect authoring session is open." });
|
|
3354
|
+
}
|
|
3355
|
+
const hasSource = showSource && state.sourceLanguage !== null && typeof session.setSource === "function";
|
|
3356
|
+
const handleSourceChange = (e) => {
|
|
3357
|
+
const val = e.target.value;
|
|
3358
|
+
setSourceCode(val);
|
|
3359
|
+
if (sourceDebounceRef.current) clearTimeout(sourceDebounceRef.current);
|
|
3360
|
+
sourceDebounceRef.current = setTimeout(() => {
|
|
3361
|
+
session.setSource?.(val);
|
|
3362
|
+
}, 300);
|
|
3363
|
+
};
|
|
3364
|
+
const handleSavePreset = (e) => {
|
|
3365
|
+
e.preventDefault();
|
|
3366
|
+
const trimmed = presetName.trim();
|
|
3367
|
+
if (trimmed) {
|
|
3368
|
+
session.savePreset(trimmed);
|
|
3369
|
+
setSavingPreset(false);
|
|
3370
|
+
setPresetName("");
|
|
3371
|
+
}
|
|
3372
|
+
};
|
|
3373
|
+
const jumpToLine = (lineNum) => {
|
|
3374
|
+
if (!textareaRef.current) return;
|
|
3375
|
+
const lines = sourceCode.split("\n");
|
|
3376
|
+
let offset = 0;
|
|
3377
|
+
for (let i = 0; i < lineNum - 1 && i < lines.length; i++) {
|
|
3378
|
+
offset += lines[i].length + 1;
|
|
3379
|
+
}
|
|
3380
|
+
textareaRef.current.focus();
|
|
3381
|
+
textareaRef.current.setSelectionRange(offset, offset);
|
|
3382
|
+
};
|
|
3383
|
+
const sourceLines = sourceCode.split("\n");
|
|
3384
|
+
const issueLines = new Set(
|
|
3385
|
+
state.issues.map((i) => i.line).filter((l) => typeof l === "number")
|
|
3386
|
+
);
|
|
3387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `space-y-4 rounded border border-border bg-background p-4 text-foreground ${className}`, "data-effect-authoring-editor": state.name, children: [
|
|
3388
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border pb-3", children: [
|
|
3389
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3390
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3391
|
+
"button",
|
|
3392
|
+
{
|
|
3393
|
+
type: "button",
|
|
3394
|
+
className: "rounded border border-border px-2.5 py-1 text-xs font-medium hover:bg-muted",
|
|
3395
|
+
"aria-label": state.playing ? "Pause playback" : "Start playback",
|
|
3396
|
+
onClick: () => state.playing ? session.pause() : session.play(),
|
|
3397
|
+
children: state.playing ? "Pause" : "Play"
|
|
3398
|
+
}
|
|
3399
|
+
),
|
|
3400
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "font-mono text-xs text-muted-foreground", "data-time-readout": true, children: [
|
|
3401
|
+
state.time,
|
|
3402
|
+
"ms / ",
|
|
3403
|
+
state.duration,
|
|
3404
|
+
"ms"
|
|
3405
|
+
] })
|
|
3406
|
+
] }),
|
|
3407
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3408
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3409
|
+
"button",
|
|
3410
|
+
{
|
|
3411
|
+
type: "button",
|
|
3412
|
+
className: "rounded border border-border px-2 py-1 text-xs disabled:opacity-40 hover:bg-muted",
|
|
3413
|
+
"aria-label": "Undo",
|
|
3414
|
+
disabled: !state.canUndo,
|
|
3415
|
+
onClick: () => session.undo(),
|
|
3416
|
+
children: "Undo"
|
|
3417
|
+
}
|
|
3418
|
+
),
|
|
3419
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3420
|
+
"button",
|
|
3421
|
+
{
|
|
3422
|
+
type: "button",
|
|
3423
|
+
className: "rounded border border-border px-2 py-1 text-xs disabled:opacity-40 hover:bg-muted",
|
|
3424
|
+
"aria-label": "Redo",
|
|
3425
|
+
disabled: !state.canRedo,
|
|
3426
|
+
onClick: () => session.redo(),
|
|
3427
|
+
children: "Redo"
|
|
3428
|
+
}
|
|
3429
|
+
),
|
|
3430
|
+
savingPreset ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("form", { onSubmit: handleSavePreset, className: "flex items-center gap-1", children: [
|
|
3431
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3432
|
+
"input",
|
|
3433
|
+
{
|
|
3434
|
+
type: "text",
|
|
3435
|
+
className: "rounded border border-border bg-background px-1.5 py-0.5 text-xs",
|
|
3436
|
+
placeholder: "Preset name",
|
|
3437
|
+
autoFocus: true,
|
|
3438
|
+
value: presetName,
|
|
3439
|
+
onChange: (e) => setPresetName(e.target.value)
|
|
3440
|
+
}
|
|
3441
|
+
),
|
|
3442
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3443
|
+
"button",
|
|
3444
|
+
{
|
|
3445
|
+
type: "submit",
|
|
3446
|
+
className: "rounded bg-primary px-2 py-0.5 text-xs text-primary-foreground",
|
|
3447
|
+
children: "Save"
|
|
3448
|
+
}
|
|
3449
|
+
),
|
|
3450
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3451
|
+
"button",
|
|
3452
|
+
{
|
|
3453
|
+
type: "button",
|
|
3454
|
+
className: "rounded border border-border px-1.5 py-0.5 text-xs hover:bg-muted",
|
|
3455
|
+
onClick: () => setSavingPreset(false),
|
|
3456
|
+
children: "Cancel"
|
|
3457
|
+
}
|
|
3458
|
+
)
|
|
3459
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3460
|
+
"button",
|
|
3461
|
+
{
|
|
3462
|
+
type: "button",
|
|
3463
|
+
className: "rounded border border-border px-2 py-1 text-xs hover:bg-muted",
|
|
3464
|
+
onClick: () => setSavingPreset(true),
|
|
3465
|
+
children: "Save preset\u2026"
|
|
3466
|
+
}
|
|
3467
|
+
)
|
|
3468
|
+
] })
|
|
3469
|
+
] }),
|
|
3470
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
|
|
3471
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
3472
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Preview" }),
|
|
3473
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "relative flex aspect-video w-full items-center justify-center overflow-hidden rounded border border-border bg-black", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3474
|
+
"canvas",
|
|
3475
|
+
{
|
|
3476
|
+
ref: canvasRef,
|
|
3477
|
+
width: previewSize.width,
|
|
3478
|
+
height: previewSize.height,
|
|
3479
|
+
className: "h-full w-full object-contain",
|
|
3480
|
+
"aria-label": "Effect preview canvas"
|
|
3481
|
+
}
|
|
3482
|
+
) }),
|
|
3483
|
+
state.issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "space-y-1 rounded border border-destructive/20 bg-destructive/10 p-2 text-xs", "data-effect-issues": true, children: state.issues.map((issue, idx) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
3484
|
+
"div",
|
|
3485
|
+
{
|
|
3486
|
+
className: `cursor-pointer ${issue.severity === "error" ? "text-destructive" : "text-amber-500"}`,
|
|
3487
|
+
onClick: () => issue.line !== void 0 && jumpToLine(issue.line),
|
|
3488
|
+
children: [
|
|
3489
|
+
issue.line !== void 0 ? `Line ${issue.line}: ` : "",
|
|
3490
|
+
issue.message
|
|
3491
|
+
]
|
|
3492
|
+
},
|
|
3493
|
+
idx
|
|
3494
|
+
)) })
|
|
3495
|
+
] }),
|
|
3496
|
+
hasSource && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", "data-effect-source-pane": true, children: [
|
|
3497
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex items-center justify-between text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
3498
|
+
"Source (",
|
|
3499
|
+
state.sourceLanguage,
|
|
3500
|
+
")"
|
|
3501
|
+
] }) }),
|
|
3502
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex h-64 rounded border border-border bg-muted/20 font-mono text-xs", children: [
|
|
3503
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { ref: gutterRef, className: "select-none overflow-hidden border-r border-border bg-muted/40 px-2 py-2 text-right text-muted-foreground", "aria-hidden": "true", children: sourceLines.map((_, i) => {
|
|
3504
|
+
const lineNum = i + 1;
|
|
3505
|
+
const hasIssue = issueLines.has(lineNum);
|
|
3506
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3507
|
+
"div",
|
|
3508
|
+
{
|
|
3509
|
+
"data-gutter-line": lineNum,
|
|
3510
|
+
className: hasIssue ? "font-bold text-destructive" : "",
|
|
3511
|
+
children: lineNum
|
|
3512
|
+
},
|
|
3513
|
+
i
|
|
3514
|
+
);
|
|
3515
|
+
}) }),
|
|
3516
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3517
|
+
"textarea",
|
|
3518
|
+
{
|
|
3519
|
+
ref: textareaRef,
|
|
3520
|
+
value: sourceCode,
|
|
3521
|
+
onChange: handleSourceChange,
|
|
3522
|
+
onScroll: (e) => {
|
|
3523
|
+
if (gutterRef.current) gutterRef.current.scrollTop = e.currentTarget.scrollTop;
|
|
3524
|
+
},
|
|
3525
|
+
"aria-label": "Effect source code",
|
|
3526
|
+
spellCheck: false,
|
|
3527
|
+
wrap: "off",
|
|
3528
|
+
className: "flex-1 resize-none bg-transparent p-2 font-mono text-xs text-foreground focus:outline-none"
|
|
3529
|
+
}
|
|
3530
|
+
)
|
|
3531
|
+
] })
|
|
3532
|
+
] })
|
|
3533
|
+
] }),
|
|
3534
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2 border-t border-border pt-4", children: [
|
|
3535
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Parameters" }),
|
|
3536
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3537
|
+
EffectParameters,
|
|
3538
|
+
{
|
|
3539
|
+
description: state.description,
|
|
3540
|
+
values: state.values,
|
|
3541
|
+
onChange: (control, val, gesture) => session.setValue(control, val, { gesture }),
|
|
3542
|
+
onReset: (control) => session.resetValues([control]),
|
|
3543
|
+
onPresetName: (name) => session.applyPreset(name),
|
|
3544
|
+
renderControlAddon: (control) => {
|
|
3545
|
+
const track = state.tracks[control];
|
|
3546
|
+
const isAnimated = Boolean(track && track.length > 0);
|
|
3547
|
+
const hasKeyframeAtPlayhead = isAnimated && track.some((kf) => kf.time === state.time);
|
|
3548
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3549
|
+
"button",
|
|
3550
|
+
{
|
|
3551
|
+
type: "button",
|
|
3552
|
+
"data-keyframe-toggle": control,
|
|
3553
|
+
"aria-label": hasKeyframeAtPlayhead ? `Remove keyframe for ${control}` : `Add keyframe for ${control}`,
|
|
3554
|
+
onClick: () => {
|
|
3555
|
+
if (hasKeyframeAtPlayhead) {
|
|
3556
|
+
session.removeKeyframe(control, state.time);
|
|
3557
|
+
} else {
|
|
3558
|
+
session.setKeyframe(control, state.time);
|
|
3559
|
+
}
|
|
3560
|
+
},
|
|
3561
|
+
className: `rounded px-1 text-xs transition-colors ${hasKeyframeAtPlayhead ? "text-primary font-bold" : isAnimated ? "text-foreground" : "text-muted-foreground hover:text-foreground"}`,
|
|
3562
|
+
title: hasKeyframeAtPlayhead ? "Remove keyframe at playhead" : "Add keyframe at playhead",
|
|
3563
|
+
children: hasKeyframeAtPlayhead ? "\u25C6" : "\u25C7"
|
|
3564
|
+
}
|
|
3565
|
+
);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
)
|
|
3569
|
+
] }),
|
|
3570
|
+
showTimeline && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-3 border-t border-border pt-4", "data-effect-timeline": true, children: [
|
|
3571
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-4", children: [
|
|
3572
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Timeline" }),
|
|
3573
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-3 text-xs", children: [
|
|
3574
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
3575
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: "Duration:" }),
|
|
3576
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DurationField, { duration: state.duration, onCommit: (duration) => session.setTiming({ duration }) }),
|
|
3577
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-muted-foreground", children: "ms" })
|
|
3578
|
+
] }),
|
|
3579
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-1.5 cursor-pointer", children: [
|
|
3580
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3581
|
+
"input",
|
|
3582
|
+
{
|
|
3583
|
+
type: "checkbox",
|
|
3584
|
+
"aria-label": "Loop playback",
|
|
3585
|
+
checked: state.loop,
|
|
3586
|
+
onChange: (e) => session.setTiming({ loop: e.target.checked })
|
|
3587
|
+
}
|
|
3588
|
+
),
|
|
3589
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: "Loop" })
|
|
3590
|
+
] })
|
|
3591
|
+
] })
|
|
3592
|
+
] }),
|
|
3593
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "space-y-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3594
|
+
"input",
|
|
3595
|
+
{
|
|
3596
|
+
type: "range",
|
|
3597
|
+
"aria-label": "Timeline scrubber",
|
|
3598
|
+
min: 0,
|
|
3599
|
+
max: state.duration,
|
|
3600
|
+
value: state.time,
|
|
3601
|
+
onChange: (e) => session.seek(Number(e.target.value)),
|
|
3602
|
+
className: "w-full cursor-pointer accent-primary"
|
|
3603
|
+
}
|
|
3604
|
+
) }),
|
|
3605
|
+
Object.entries(state.tracks).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "space-y-2 pt-1", children: Object.entries(state.tracks).map(([control, keyframes]) => {
|
|
3606
|
+
if (!keyframes || keyframes.length === 0) return null;
|
|
3607
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-1", "data-track": control, children: [
|
|
3608
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
3609
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "font-medium", children: control }),
|
|
3610
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3611
|
+
"button",
|
|
3612
|
+
{
|
|
3613
|
+
type: "button",
|
|
3614
|
+
className: "text-[11px] hover:text-foreground",
|
|
3615
|
+
onClick: () => session.clearTrack(control),
|
|
3616
|
+
"aria-label": `Clear animation track for ${control}`,
|
|
3617
|
+
children: "Clear track"
|
|
3618
|
+
}
|
|
3619
|
+
)
|
|
3620
|
+
] }),
|
|
3621
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "relative h-4 w-full rounded bg-muted/40", children: keyframes.map((kf, i) => {
|
|
3622
|
+
const leftPct = Math.max(
|
|
3623
|
+
0,
|
|
3624
|
+
Math.min(100, kf.time / (state.duration || 1) * 100)
|
|
3625
|
+
);
|
|
3626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3627
|
+
"button",
|
|
3628
|
+
{
|
|
3629
|
+
type: "button",
|
|
3630
|
+
onClick: () => session.seek(kf.time),
|
|
3631
|
+
"aria-label": `Seek to ${control} keyframe at ${kf.time}ms`,
|
|
3632
|
+
title: `${control} @ ${kf.time}ms`,
|
|
3633
|
+
style: { left: `${leftPct}%` },
|
|
3634
|
+
className: "absolute top-1/2 -translate-x-1/2 -translate-y-1/2 text-[10px] text-primary hover:scale-125",
|
|
3635
|
+
children: "\u25C6"
|
|
3636
|
+
},
|
|
3637
|
+
i
|
|
3638
|
+
);
|
|
3639
|
+
}) })
|
|
3640
|
+
] }, control);
|
|
3641
|
+
}) })
|
|
3642
|
+
] })
|
|
2919
3643
|
] });
|
|
2920
3644
|
}
|
|
3645
|
+
function DurationField({ duration, onCommit }) {
|
|
3646
|
+
const [draft, setDraft] = (0, import_react23.useState)(String(duration));
|
|
3647
|
+
(0, import_react23.useEffect)(() => setDraft(String(duration)), [duration]);
|
|
3648
|
+
const commit = () => {
|
|
3649
|
+
const next = Number(draft);
|
|
3650
|
+
if (Number.isFinite(next) && next >= 1 && next !== duration) onCommit(next);
|
|
3651
|
+
else setDraft(String(duration));
|
|
3652
|
+
};
|
|
3653
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3654
|
+
"input",
|
|
3655
|
+
{
|
|
3656
|
+
type: "number",
|
|
3657
|
+
"aria-label": "Duration",
|
|
3658
|
+
min: 1,
|
|
3659
|
+
value: draft,
|
|
3660
|
+
onChange: (e) => setDraft(e.target.value),
|
|
3661
|
+
onBlur: commit,
|
|
3662
|
+
onKeyDown: (e) => {
|
|
3663
|
+
if (e.key === "Enter") commit();
|
|
3664
|
+
else if (e.key === "Escape") setDraft(String(duration));
|
|
3665
|
+
},
|
|
3666
|
+
className: "w-16 rounded border border-border bg-background px-1.5 py-0.5 text-xs font-mono"
|
|
3667
|
+
}
|
|
3668
|
+
);
|
|
3669
|
+
}
|
|
2921
3670
|
|
|
2922
3671
|
// src/video-editor/VideoEffectsPanel.tsx
|
|
2923
|
-
var
|
|
2924
|
-
var
|
|
2925
|
-
var
|
|
2926
|
-
var
|
|
2927
|
-
var keyedOf = (values) => new Set(Object.entries(values ?? {}).filter(([, v]) => (0,
|
|
3672
|
+
var import_react24 = require("react");
|
|
3673
|
+
var import_video_editor11 = require("@pixerate/editor/video-editor");
|
|
3674
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3675
|
+
var btn7 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
3676
|
+
var keyedOf = (values) => new Set(Object.entries(values ?? {}).filter(([, v]) => (0, import_video_editor11.isVideoKeyframes)(v)).map(([k]) => k));
|
|
2928
3677
|
function EffectControls({
|
|
2929
3678
|
provider,
|
|
2930
3679
|
effect,
|
|
@@ -2935,23 +3684,25 @@ function EffectControls({
|
|
|
2935
3684
|
onPreset
|
|
2936
3685
|
}) {
|
|
2937
3686
|
const { description, error } = useEffectDescription(provider, effect);
|
|
2938
|
-
if (!provider) return /* @__PURE__ */ (0,
|
|
3687
|
+
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
2939
3688
|
'No effects provider: "',
|
|
2940
3689
|
name ?? effect,
|
|
2941
3690
|
'" is kept and shown as a placeholder.'
|
|
2942
3691
|
] });
|
|
2943
|
-
if (error) return /* @__PURE__ */ (0,
|
|
2944
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
2945
|
-
return /* @__PURE__ */ (0,
|
|
3692
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
|
|
3693
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
|
|
3694
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EffectParameters, { description, values: values ?? {}, keyframed: keyedOf(values), disabled, onChange, onReset: (k) => onChange(k, description.defaults[k], null), onPreset });
|
|
2946
3695
|
}
|
|
2947
3696
|
function VideoEffectsPanel({ controller, className = "" }) {
|
|
2948
3697
|
const state = useVideoEditorState(controller);
|
|
2949
3698
|
const provider = state.effectsProvider;
|
|
2950
|
-
const [browse, setBrowse] = (0,
|
|
2951
|
-
const [message, setMessage] = (0,
|
|
2952
|
-
const [open, setOpen] = (0,
|
|
3699
|
+
const [browse, setBrowse] = (0, import_react24.useState)(null);
|
|
3700
|
+
const [message, setMessage] = (0, import_react24.useState)(null);
|
|
3701
|
+
const [open, setOpen] = (0, import_react24.useState)(null);
|
|
3702
|
+
const [authoring, setAuthoring] = (0, import_react24.useState)(null);
|
|
3703
|
+
(0, import_react24.useEffect)(() => () => authoring?.dispose(), [authoring]);
|
|
2953
3704
|
const selected = state.selection[0];
|
|
2954
|
-
const at = selected ? (0,
|
|
3705
|
+
const at = selected ? (0, import_video_editor11.findVideoClip)(state.project, selected) : null;
|
|
2955
3706
|
const clip = at?.clip ?? null;
|
|
2956
3707
|
const disabled = state.readOnly;
|
|
2957
3708
|
const report = (r) => void Promise.resolve(r).then((x) => setMessage(x.ok ? null : x.error));
|
|
@@ -2960,18 +3711,18 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
2960
3711
|
if (!track) return setMessage("Add a video track first.");
|
|
2961
3712
|
report(controller.addEffectClip(track, effect, { start: Math.round(state.time), mode: "overwrite" }).then((r) => (r.ok && r.clip && controller.select([r.clip]), r)));
|
|
2962
3713
|
};
|
|
2963
|
-
return /* @__PURE__ */ (0,
|
|
2964
|
-
/* @__PURE__ */ (0,
|
|
2965
|
-
/* @__PURE__ */ (0,
|
|
2966
|
-
/* @__PURE__ */ (0,
|
|
3714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("section", { className: `flex flex-col gap-2 rounded-md border border-border p-2 text-xs ${className}`, "aria-label": "Effects", "data-video-effects": "", children: [
|
|
3715
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3716
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h3", { className: "flex-1 font-semibold", children: "Effects" }),
|
|
3717
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn7, disabled: disabled || !provider, onClick: () => setBrowse(browse === "generator" ? null : "generator"), "aria-pressed": browse === "generator", children: "Add effect clip" })
|
|
2967
3718
|
] }),
|
|
2968
|
-
!provider && /* @__PURE__ */ (0,
|
|
2969
|
-
browse === "generator" && /* @__PURE__ */ (0,
|
|
2970
|
-
!clip && /* @__PURE__ */ (0,
|
|
2971
|
-
clip && /* @__PURE__ */ (0,
|
|
2972
|
-
clip.type === "effect" && /* @__PURE__ */ (0,
|
|
2973
|
-
/* @__PURE__ */ (0,
|
|
2974
|
-
/* @__PURE__ */ (0,
|
|
3719
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects in the project are kept and drawn as placeholders." }),
|
|
3720
|
+
browse === "generator" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EffectsBrowser, { provider, uses: ["generator", "title", "overlay"], title: "Generators and titles", onPick: (e) => (setBrowse(null), addEffectClip(e.id)) }),
|
|
3721
|
+
!clip && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Select a clip to see its effects." }),
|
|
3722
|
+
clip && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
3723
|
+
clip.type === "effect" && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1", "data-effect-part": "generator", children: [
|
|
3724
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "font-medium", children: clip.name ?? clip.effect }),
|
|
3725
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2975
3726
|
EffectControls,
|
|
2976
3727
|
{
|
|
2977
3728
|
provider,
|
|
@@ -2984,13 +3735,13 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
2984
3735
|
}
|
|
2985
3736
|
)
|
|
2986
3737
|
] }),
|
|
2987
|
-
/* @__PURE__ */ (0,
|
|
2988
|
-
/* @__PURE__ */ (0,
|
|
2989
|
-
/* @__PURE__ */ (0,
|
|
2990
|
-
clip.transition?.type === "effect" ? /* @__PURE__ */ (0,
|
|
3738
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1", "data-effect-part": "transition", children: [
|
|
3739
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3740
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "flex-1 font-medium", children: "Transition in" }),
|
|
3741
|
+
clip.transition?.type === "effect" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn7, disabled, onClick: () => report(controller.apply({ op: "set_transition", clip: clip.id, transition: null }, "Remove transition")), children: "Remove" }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn7, disabled: disabled || !provider, "aria-pressed": browse === "transition", onClick: () => setBrowse(browse === "transition" ? null : "transition"), children: "Effect transition\u2026" })
|
|
2991
3742
|
] }),
|
|
2992
|
-
browse === "transition" && /* @__PURE__ */ (0,
|
|
2993
|
-
clip.transition?.type === "effect" && clip.transition.effect && /* @__PURE__ */ (0,
|
|
3743
|
+
browse === "transition" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EffectsBrowser, { provider, uses: ["transition"], title: "Transitions", onPick: (e) => (setBrowse(null), report(controller.setEffectTransition(clip.id, e.id))) }),
|
|
3744
|
+
clip.transition?.type === "effect" && clip.transition.effect && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2994
3745
|
EffectControls,
|
|
2995
3746
|
{
|
|
2996
3747
|
provider,
|
|
@@ -3003,24 +3754,40 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
3003
3754
|
}
|
|
3004
3755
|
)
|
|
3005
3756
|
] }),
|
|
3006
|
-
/* @__PURE__ */ (0,
|
|
3007
|
-
/* @__PURE__ */ (0,
|
|
3008
|
-
/* @__PURE__ */ (0,
|
|
3009
|
-
/* @__PURE__ */ (0,
|
|
3757
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1", "data-effect-part": "stack", children: [
|
|
3758
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3759
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "flex-1 font-medium", children: "On this clip" }),
|
|
3760
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn7, disabled: disabled || !provider, "aria-pressed": browse === "clip", onClick: () => setBrowse(browse === "clip" ? null : "clip"), children: "Add effect\u2026" })
|
|
3010
3761
|
] }),
|
|
3011
|
-
browse === "clip" && /* @__PURE__ */ (0,
|
|
3012
|
-
/* @__PURE__ */ (0,
|
|
3013
|
-
/* @__PURE__ */ (0,
|
|
3014
|
-
/* @__PURE__ */ (0,
|
|
3015
|
-
/* @__PURE__ */ (0,
|
|
3016
|
-
/* @__PURE__ */ (0,
|
|
3017
|
-
/* @__PURE__ */ (0,
|
|
3018
|
-
/* @__PURE__ */ (0,
|
|
3762
|
+
browse === "clip" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EffectsBrowser, { provider, uses: ["filter", "overlay"], title: "Filters and overlays", onPick: (e) => (setBrowse(null), report(controller.applyClipEffect(clip.id, e.id))) }),
|
|
3763
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("ol", { className: "space-y-1", children: (clip.effects ?? []).map((e, i, all) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("li", { className: "rounded border border-border p-1", "data-clip-effect": e.id, children: [
|
|
3764
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3765
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { type: "checkbox", checked: e.enabled !== false, disabled, "aria-label": `${e.name ?? e.effect} on`, onChange: (ev) => report(controller.updateClipEffect(clip.id, e.id, { enabled: ev.currentTarget.checked })) }),
|
|
3766
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: "min-w-0 flex-1 truncate text-left", "aria-expanded": open === e.id, onClick: () => setOpen(open === e.id ? null : e.id), children: e.name ?? e.effect }),
|
|
3767
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn7, disabled: disabled || i === 0, "aria-label": "Move up", onClick: () => report(controller.updateClipEffect(clip.id, e.id, { index: i - 1 })), children: "\u2191" }),
|
|
3768
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn7, disabled: disabled || i === all.length - 1, "aria-label": "Move down", onClick: () => report(controller.updateClipEffect(clip.id, e.id, { index: i + 1 })), children: "\u2193" }),
|
|
3769
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3770
|
+
"button",
|
|
3771
|
+
{
|
|
3772
|
+
type: "button",
|
|
3773
|
+
className: btn7,
|
|
3774
|
+
disabled: disabled || !provider,
|
|
3775
|
+
"aria-label": `Author ${e.name ?? e.effect}`,
|
|
3776
|
+
title: "Tune and keyframe it in the effect authoring editor",
|
|
3777
|
+
"data-author-effect": e.id,
|
|
3778
|
+
onClick: () => void (0, import_video_editor11.openVideoClipEffectAuthoring)(controller, clip.id, e.id).then(
|
|
3779
|
+
(a) => setAuthoring(a),
|
|
3780
|
+
(err) => setMessage(err instanceof Error ? err.message : String(err))
|
|
3781
|
+
),
|
|
3782
|
+
children: "\u270E"
|
|
3783
|
+
}
|
|
3784
|
+
),
|
|
3785
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn7, disabled, "aria-label": `Remove ${e.name ?? e.effect}`, onClick: () => report(controller.removeClipEffect(clip.id, e.id)), children: "\u2715" })
|
|
3019
3786
|
] }),
|
|
3020
|
-
open === e.id && /* @__PURE__ */ (0,
|
|
3021
|
-
/* @__PURE__ */ (0,
|
|
3022
|
-
/* @__PURE__ */ (0,
|
|
3023
|
-
/* @__PURE__ */ (0,
|
|
3787
|
+
open === e.id && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "mt-1 space-y-2", children: [
|
|
3788
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3789
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "w-14 text-[11px]", children: "Opacity" }),
|
|
3790
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3024
3791
|
"input",
|
|
3025
3792
|
{
|
|
3026
3793
|
type: "range",
|
|
@@ -3028,14 +3795,14 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
3028
3795
|
max: 1,
|
|
3029
3796
|
step: 0.01,
|
|
3030
3797
|
className: "flex-1",
|
|
3031
|
-
disabled: disabled || (0,
|
|
3798
|
+
disabled: disabled || (0, import_video_editor11.isVideoKeyframes)(e.opacity),
|
|
3032
3799
|
value: typeof e.opacity === "number" ? e.opacity : 1,
|
|
3033
3800
|
"aria-label": `${e.name ?? e.effect} opacity`,
|
|
3034
3801
|
onChange: (ev) => report(controller.updateClipEffect(clip.id, e.id, { opacity: Number(ev.currentTarget.value) }, { merge: `opacity:${clip.id}:${e.id}` }))
|
|
3035
3802
|
}
|
|
3036
3803
|
)
|
|
3037
3804
|
] }),
|
|
3038
|
-
/* @__PURE__ */ (0,
|
|
3805
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3039
3806
|
EffectControls,
|
|
3040
3807
|
{
|
|
3041
3808
|
provider,
|
|
@@ -3049,49 +3816,72 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
3049
3816
|
)
|
|
3050
3817
|
] })
|
|
3051
3818
|
] }, e.id)) }),
|
|
3052
|
-
!clip.effects?.length && /* @__PURE__ */ (0,
|
|
3819
|
+
!clip.effects?.length && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects on this clip." })
|
|
3053
3820
|
] })
|
|
3054
3821
|
] }),
|
|
3055
|
-
|
|
3822
|
+
authoring && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1 rounded border border-border p-1", "data-effect-authoring": authoring.instance, children: [
|
|
3823
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EffectAuthoringEditor, { session: authoring.session, showSource: false, previewSize: { width: 240, height: 135 } }),
|
|
3824
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex gap-1", children: [
|
|
3825
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3826
|
+
"button",
|
|
3827
|
+
{
|
|
3828
|
+
type: "button",
|
|
3829
|
+
className: btn7,
|
|
3830
|
+
disabled,
|
|
3831
|
+
"data-apply-authoring": "",
|
|
3832
|
+
onClick: () => void authoring.commit().then((r) => {
|
|
3833
|
+
setMessage(r.ok ? r.notes?.join(" ") ?? null : r.error);
|
|
3834
|
+
if (r.ok) setAuthoring(null);
|
|
3835
|
+
}),
|
|
3836
|
+
children: "Apply to clip"
|
|
3837
|
+
}
|
|
3838
|
+
),
|
|
3839
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn7, onClick: () => setAuthoring(null), children: "Close" })
|
|
3840
|
+
] })
|
|
3841
|
+
] }),
|
|
3842
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
3056
3843
|
] });
|
|
3057
3844
|
}
|
|
3058
3845
|
|
|
3059
3846
|
// src/video-editor/VideoEditor.tsx
|
|
3060
|
-
var
|
|
3061
|
-
function VideoEditor({ controller: given, options, editable = true, pxPerSecond, onPxPerSecondChange, resolution, showIssues = true, showTranscript = true, showScopes = false, effects, showEffects, className = "", playback, onPlaybackReveal }) {
|
|
3847
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3848
|
+
function VideoEditor({ controller: given, options, editable = true, pxPerSecond, onPxPerSecondChange, resolution, showIssues = true, showTranscript = true, transcriptMode = "panel", showScopes = false, effects, showEffects, className = "", playback, onPlaybackReveal }) {
|
|
3062
3849
|
const { controller, state } = useVideoEditor(given ?? options ?? {});
|
|
3063
3850
|
useEffects(controller, effects);
|
|
3064
|
-
const effectsShown = showEffects ?? !!(state.effectsProvider || state.project.tracks.some((t) => t.clips.some((c) => c.type === "effect" || c.effects?.length || c.transition?.type === "effect")));
|
|
3065
|
-
(0,
|
|
3851
|
+
const effectsShown = showEffects ?? !!(state.effectsProvider || state.project.tracks.some((t) => t.clips.some((c) => c.type === "effect" || c.type === "adjustment" || c.effects?.length || c.transition?.type === "effect")));
|
|
3852
|
+
(0, import_react25.useEffect)(() => {
|
|
3066
3853
|
if (editable) return;
|
|
3067
3854
|
const was = controller.getState().readOnly;
|
|
3068
3855
|
controller.setReadOnly(true);
|
|
3069
3856
|
return () => controller.setReadOnly(was);
|
|
3070
3857
|
}, [controller, editable]);
|
|
3071
3858
|
const { issues } = state;
|
|
3072
|
-
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0,
|
|
3073
|
-
return /* @__PURE__ */ (0,
|
|
3074
|
-
/* @__PURE__ */ (0,
|
|
3075
|
-
editable && /* @__PURE__ */ (0,
|
|
3076
|
-
/* @__PURE__ */ (0,
|
|
3077
|
-
/* @__PURE__ */ (0,
|
|
3078
|
-
/* @__PURE__ */ (0,
|
|
3079
|
-
showScopes && /* @__PURE__ */ (0,
|
|
3859
|
+
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { className: "space-y-0.5 text-xs", "aria-label": "Video issues", "data-video-issues": "", children: issues.map((issue, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("li", { className: issue.severity === "error" ? "text-red-500" : issue.severity === "warning" ? "text-amber-500" : "text-muted-foreground", "data-issue": issue.code, children: issue.message }, i)) });
|
|
3860
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `flex flex-col gap-3 ${className}`, "data-video-editor": "", children: [
|
|
3861
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `grid gap-3 ${editable ? "lg:grid-cols-[16rem_minmax(0,1fr)_18rem]" : ""}`, children: [
|
|
3862
|
+
editable && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(MediaBin, { controller, className: "min-w-0" }),
|
|
3863
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex min-w-0 flex-col gap-2", children: [
|
|
3864
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(VideoPreview, { controller, resolution, className: "rounded-md border border-border" }),
|
|
3865
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(VideoTransport, { controller, editable }),
|
|
3866
|
+
showScopes && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(VideoScopes, { controller })
|
|
3080
3867
|
] }),
|
|
3081
|
-
editable && /* @__PURE__ */ (0,
|
|
3082
|
-
/* @__PURE__ */ (0,
|
|
3083
|
-
effectsShown && /* @__PURE__ */ (0,
|
|
3868
|
+
editable && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex min-w-0 flex-col gap-3", children: [
|
|
3869
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ClipInspector, { controller, className: "min-w-0" }),
|
|
3870
|
+
effectsShown && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(VideoEffectsPanel, { controller, className: "min-w-0" })
|
|
3084
3871
|
] })
|
|
3085
3872
|
] }),
|
|
3086
|
-
/* @__PURE__ */ (0,
|
|
3087
|
-
|
|
3873
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(VideoTimeline, { controller, editable, pxPerSecond, onPxPerSecondChange, playback, onPlaybackReveal }),
|
|
3874
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EditPlanPreview, { controller, editable }),
|
|
3875
|
+
showTranscript && (transcriptMode === "editor" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TranscriptEditor, { controller, editable }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TranscriptPanel, { controller, editable })),
|
|
3088
3876
|
issueList
|
|
3089
3877
|
] });
|
|
3090
3878
|
}
|
|
3091
3879
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3092
3880
|
0 && (module.exports = {
|
|
3093
3881
|
ClipInspector,
|
|
3882
|
+
EditPlanPreview,
|
|
3094
3883
|
MediaBin,
|
|
3884
|
+
TranscriptEditor,
|
|
3095
3885
|
TranscriptPanel,
|
|
3096
3886
|
VideoEditor,
|
|
3097
3887
|
VideoEffectsPanel,
|
|
@@ -3099,9 +3889,13 @@ function VideoEditor({ controller: given, options, editable = true, pxPerSecond,
|
|
|
3099
3889
|
VideoScopes,
|
|
3100
3890
|
VideoTimeline,
|
|
3101
3891
|
VideoTransport,
|
|
3892
|
+
useTranscriptVideoController,
|
|
3893
|
+
useTranscriptVideoState,
|
|
3894
|
+
useVideoDialogueTools,
|
|
3102
3895
|
useVideoEditor,
|
|
3103
3896
|
useVideoEditorController,
|
|
3104
3897
|
useVideoEditorState,
|
|
3105
3898
|
useVideoEditorTools,
|
|
3106
|
-
useVideoEffectsTools
|
|
3899
|
+
useVideoEffectsTools,
|
|
3900
|
+
useVideoMusicTools
|
|
3107
3901
|
});
|