@pixerate/editor-react 0.114.1 → 0.114.3
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 +342 -215
- package/dist/animation-editor/index.js +2 -2
- package/dist/canvas/index.cjs +520 -393
- package/dist/canvas/index.js +2 -2
- package/dist/chart/index.cjs +2 -2
- package/dist/chart/index.js +1 -1
- package/dist/{chunk-5LFQ2UQZ.js → chunk-354TA5QV.js} +221 -101
- package/dist/{chunk-2INOKIJN.js → chunk-SH63DFOO.js} +345 -297
- package/dist/{chunk-BWEARAWR.js → chunk-TOGMXZM4.js} +40 -18
- package/dist/{chunk-N2F53ESC.js → chunk-VUSYAHIU.js} +2 -2
- package/dist/effects/EffectParameters.d.cts +4 -1
- package/dist/effects/EffectParameters.d.ts +4 -1
- package/dist/effects/index.cjs +348 -221
- package/dist/effects/index.js +2 -2
- package/dist/image-editor/ImageEffectControls.d.cts +4 -1
- package/dist/image-editor/ImageEffectControls.d.ts +4 -1
- package/dist/image-editor/ImageProviderEffectsPanel.d.cts +4 -1
- package/dist/image-editor/ImageProviderEffectsPanel.d.ts +4 -1
- package/dist/image-editor/controls/parameterControls.d.cts +4 -0
- package/dist/image-editor/controls/parameterControls.d.ts +4 -0
- package/dist/image-editor/index.cjs +868 -697
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +1390 -1219
- package/dist/index.js +4 -4
- package/dist/paint-editor/index.cjs +335 -208
- package/dist/paint-editor/index.js +2 -2
- package/dist/parameters/ParametersPanel.d.cts +4 -1
- package/dist/parameters/ParametersPanel.d.ts +4 -1
- package/dist/parameters/controls.d.cts +72 -0
- package/dist/parameters/controls.d.ts +72 -0
- package/dist/parameters/fields.d.cts +19 -6
- package/dist/parameters/fields.d.ts +19 -6
- package/dist/parameters/index.cjs +350 -183
- package/dist/parameters/index.d.cts +1 -0
- package/dist/parameters/index.d.ts +1 -0
- package/dist/parameters/index.js +70 -14
- package/dist/vector/index.cjs +321 -194
- package/dist/vector/index.js +2 -2
- package/dist/video-editor/index.cjs +418 -291
- package/dist/video-editor/index.js +2 -2
- package/package.json +3 -3
|
@@ -1615,7 +1615,7 @@ function EditPlanPreview({ controller, editable = true, className = "" }) {
|
|
|
1615
1615
|
}
|
|
1616
1616
|
|
|
1617
1617
|
// src/video-editor/VideoEditor.tsx
|
|
1618
|
-
var
|
|
1618
|
+
var import_react26 = require("react");
|
|
1619
1619
|
|
|
1620
1620
|
// src/effects/useEffects.ts
|
|
1621
1621
|
var import_react14 = require("react");
|
|
@@ -1754,12 +1754,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1754
1754
|
}
|
|
1755
1755
|
|
|
1756
1756
|
// src/effects/EffectParameters.tsx
|
|
1757
|
-
var
|
|
1757
|
+
var import_react22 = __toESM(require("react"), 1);
|
|
1758
1758
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1759
1759
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1760
1760
|
|
|
1761
1761
|
// src/parameters/fields.tsx
|
|
1762
|
-
var
|
|
1762
|
+
var import_react21 = require("react");
|
|
1763
1763
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1764
1764
|
|
|
1765
1765
|
// src/color/index.ts
|
|
@@ -2801,18 +2801,57 @@ function useResolvedColor(value, scheme) {
|
|
|
2801
2801
|
// src/color/index.ts
|
|
2802
2802
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
2803
2803
|
|
|
2804
|
-
// src/parameters/
|
|
2804
|
+
// src/parameters/controls.tsx
|
|
2805
|
+
var import_react20 = require("react");
|
|
2805
2806
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2807
|
+
var ParameterComponentsContext = (0, import_react20.createContext)({});
|
|
2808
|
+
function useParameterComponents() {
|
|
2809
|
+
return (0, import_react20.useContext)(ParameterComponentsContext);
|
|
2810
|
+
}
|
|
2811
|
+
function resolveParameterComponents(explicit, context) {
|
|
2812
|
+
return {
|
|
2813
|
+
input: explicit?.input ?? context?.input,
|
|
2814
|
+
slider: explicit?.slider ?? context?.slider,
|
|
2815
|
+
select: explicit?.select ?? context?.select
|
|
2816
|
+
};
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
// src/parameters/fields.tsx
|
|
2820
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2821
|
+
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
2822
|
+
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
2823
|
+
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
2824
|
+
var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
|
|
2806
2825
|
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";
|
|
2807
2826
|
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";
|
|
2808
2827
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
2809
|
-
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
|
|
2828
|
+
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
2829
|
+
const inputRef = (0, import_react21.useRef)(null);
|
|
2830
|
+
const lastCommitted = (0, import_react21.useRef)(null);
|
|
2831
|
+
(0, import_react21.useLayoutEffect)(() => {
|
|
2832
|
+
lastCommitted.current = null;
|
|
2833
|
+
const el = inputRef.current;
|
|
2834
|
+
if (el && el.value !== value) el.value = value;
|
|
2835
|
+
}, [value]);
|
|
2810
2836
|
const commit = (el) => {
|
|
2811
|
-
|
|
2837
|
+
const text = el.value;
|
|
2838
|
+
if (text === value || text === lastCommitted.current) return;
|
|
2839
|
+
onCommit(text, el);
|
|
2840
|
+
lastCommitted.current = el.value === text ? text : null;
|
|
2812
2841
|
};
|
|
2842
|
+
const commitRef = (0, import_react21.useRef)(commit);
|
|
2843
|
+
commitRef.current = commit;
|
|
2844
|
+
(0, import_react21.useEffect)(() => {
|
|
2845
|
+
const el = inputRef.current;
|
|
2846
|
+
if (!el) return;
|
|
2847
|
+
const change = () => commitRef.current(el);
|
|
2848
|
+
el.addEventListener("change", change);
|
|
2849
|
+
return () => el.removeEventListener("change", change);
|
|
2850
|
+
}, [multiline]);
|
|
2813
2851
|
const keyDown = (e) => {
|
|
2814
2852
|
onKeyDown?.(e);
|
|
2815
2853
|
if (e.defaultPrevented) return;
|
|
2854
|
+
if (e.key === "Tab") commit(e.currentTarget);
|
|
2816
2855
|
if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
|
|
2817
2856
|
e.preventDefault();
|
|
2818
2857
|
commit(e.currentTarget);
|
|
@@ -2822,86 +2861,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2822
2861
|
const props = {
|
|
2823
2862
|
defaultValue: value,
|
|
2824
2863
|
className: className ?? parameterInputClass,
|
|
2864
|
+
style: { ...parameterInputStyle, ...style },
|
|
2825
2865
|
onBlur: (e) => commit(e.currentTarget),
|
|
2826
2866
|
onKeyDown: keyDown,
|
|
2827
2867
|
...rest
|
|
2828
2868
|
};
|
|
2829
|
-
|
|
2869
|
+
const forwarded = rest.ref;
|
|
2870
|
+
const setRef = (el) => {
|
|
2871
|
+
inputRef.current = el;
|
|
2872
|
+
if (typeof forwarded === "function") forwarded(el);
|
|
2873
|
+
else if (forwarded) forwarded.current = el;
|
|
2874
|
+
};
|
|
2875
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
2830
2876
|
}
|
|
2831
2877
|
var plainNumber = (field2, value) => (0, import_parameters.formatParameterNumber)({ ...field2, unit: void 0 }, value);
|
|
2832
|
-
function ParameterNumberInput({
|
|
2833
|
-
field: field2,
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2878
|
+
function ParameterNumberInput(props) {
|
|
2879
|
+
const { field: field2, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
|
|
2880
|
+
const ctx = useParameterComponents();
|
|
2881
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2882
|
+
const CustomInput = resolved.input;
|
|
2883
|
+
const plain = plainNumber(field2, value);
|
|
2884
|
+
const handleCommit = (text, input) => {
|
|
2885
|
+
const n = (0, import_parameters.parseParameterNumberInput)(field2, text);
|
|
2886
|
+
if (n === null || n === value) {
|
|
2887
|
+
if (input) input.value = plain;
|
|
2888
|
+
} else {
|
|
2889
|
+
onChange(n);
|
|
2890
|
+
}
|
|
2891
|
+
};
|
|
2892
|
+
const handleKeyDown = (e) => {
|
|
2893
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
2894
|
+
e.preventDefault();
|
|
2895
|
+
const step = (0, import_parameters.parameterStep)(field2) * (e.shiftKey ? 10 : 1);
|
|
2896
|
+
onChange((0, import_parameters.clampParameterNumber)(field2, value + (e.key === "ArrowUp" ? step : -step)));
|
|
2897
|
+
};
|
|
2898
|
+
const inputProps = {
|
|
2899
|
+
id,
|
|
2900
|
+
inputMode: "decimal",
|
|
2901
|
+
"aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field2),
|
|
2902
|
+
value: plain,
|
|
2903
|
+
disabled: disabled || field2.readOnly,
|
|
2904
|
+
className: `${parameterInputClass} ${field2.unit ? "pr-6" : ""}`,
|
|
2905
|
+
style: parameterInputStyle,
|
|
2906
|
+
onCommit: handleCommit,
|
|
2907
|
+
onKeyDown: handleKeyDown
|
|
2908
|
+
};
|
|
2909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
2910
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field2) }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
2911
|
+
field2.unit && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field2.unit })
|
|
2864
2912
|
] });
|
|
2865
2913
|
}
|
|
2866
2914
|
function ParameterSlider(props) {
|
|
2867
|
-
const { field: field2, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
2868
|
-
const
|
|
2915
|
+
const { field: field2, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
|
|
2916
|
+
const ctx = useParameterComponents();
|
|
2917
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2918
|
+
const CustomSlider = resolved.slider;
|
|
2919
|
+
const dragging = (0, import_react21.useRef)(false);
|
|
2920
|
+
const start = () => {
|
|
2921
|
+
if (dragging.current) return;
|
|
2922
|
+
dragging.current = true;
|
|
2923
|
+
onGestureStart?.();
|
|
2924
|
+
};
|
|
2869
2925
|
const end = () => {
|
|
2870
2926
|
if (!dragging.current) return;
|
|
2871
2927
|
dragging.current = false;
|
|
2872
2928
|
onGestureEnd?.();
|
|
2873
2929
|
};
|
|
2874
|
-
if (!(0, import_parameters.isSliderField)(field2)) return /* @__PURE__ */ (0,
|
|
2930
|
+
if (!(0, import_parameters.isSliderField)(field2)) return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterNumberInput, { ...props });
|
|
2875
2931
|
const step = (0, import_parameters.parameterStep)(field2);
|
|
2876
|
-
|
|
2877
|
-
|
|
2932
|
+
const sliderProps = {
|
|
2933
|
+
"aria-label": (0, import_parameters.parameterLabel)(field2),
|
|
2934
|
+
"aria-valuetext": (0, import_parameters.formatParameterNumber)(field2, value),
|
|
2935
|
+
// A `control: 'slider'` field may leave out a bound: the range input's own defaults.
|
|
2936
|
+
min: field2.min ?? 0,
|
|
2937
|
+
max: field2.max ?? 100,
|
|
2938
|
+
step,
|
|
2939
|
+
value,
|
|
2940
|
+
disabled: disabled || field2.readOnly,
|
|
2941
|
+
className: rangeClass,
|
|
2942
|
+
style: parameterRangeStyle
|
|
2943
|
+
};
|
|
2944
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2945
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2946
|
+
CustomSlider,
|
|
2947
|
+
{
|
|
2948
|
+
...sliderProps,
|
|
2949
|
+
id: props.id ? `${props.id}-slider` : void 0,
|
|
2950
|
+
label: (0, import_parameters.parameterLabel)(field2),
|
|
2951
|
+
onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field2, v)),
|
|
2952
|
+
onGestureStart: start,
|
|
2953
|
+
onGestureEnd: end
|
|
2954
|
+
}
|
|
2955
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2878
2956
|
"input",
|
|
2879
2957
|
{
|
|
2880
2958
|
type: "range",
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
min: field2.min,
|
|
2884
|
-
max: field2.max,
|
|
2885
|
-
step,
|
|
2886
|
-
value,
|
|
2887
|
-
disabled: disabled || field2.readOnly,
|
|
2888
|
-
className: rangeClass,
|
|
2889
|
-
onPointerDown: () => {
|
|
2890
|
-
if (dragging.current) return;
|
|
2891
|
-
dragging.current = true;
|
|
2892
|
-
onGestureStart?.();
|
|
2893
|
-
},
|
|
2959
|
+
...sliderProps,
|
|
2960
|
+
onPointerDown: start,
|
|
2894
2961
|
onPointerUp: end,
|
|
2895
2962
|
onPointerCancel: end,
|
|
2896
2963
|
onBlur: end,
|
|
2897
2964
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field2, Number(e.target.value)))
|
|
2898
2965
|
}
|
|
2899
2966
|
),
|
|
2900
|
-
/* @__PURE__ */ (0,
|
|
2967
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field2)} value` }) })
|
|
2901
2968
|
] });
|
|
2902
2969
|
}
|
|
2903
2970
|
function ParameterToggle({ field: field2, value, onChange, disabled, id }) {
|
|
2904
|
-
return /* @__PURE__ */ (0,
|
|
2971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2905
2972
|
"button",
|
|
2906
2973
|
{
|
|
2907
2974
|
type: "button",
|
|
@@ -2912,7 +2979,7 @@ function ParameterToggle({ field: field2, value, onChange, disabled, id }) {
|
|
|
2912
2979
|
disabled: disabled || field2.readOnly,
|
|
2913
2980
|
onClick: () => onChange(!value),
|
|
2914
2981
|
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"}`,
|
|
2915
|
-
children: /* @__PURE__ */ (0,
|
|
2982
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2916
2983
|
"span",
|
|
2917
2984
|
{
|
|
2918
2985
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -2921,11 +2988,15 @@ function ParameterToggle({ field: field2, value, onChange, disabled, id }) {
|
|
|
2921
2988
|
}
|
|
2922
2989
|
);
|
|
2923
2990
|
}
|
|
2924
|
-
function ParameterSelect(
|
|
2991
|
+
function ParameterSelect(props) {
|
|
2992
|
+
const { field: field2, value, onChange, disabled, id, components } = props;
|
|
2993
|
+
const ctx = useParameterComponents();
|
|
2994
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
2995
|
+
const CustomSelect = resolved.select;
|
|
2925
2996
|
const options = (0, import_parameters.getChoiceOptions)(field2);
|
|
2926
2997
|
const off = disabled || field2.readOnly;
|
|
2927
2998
|
if (field2.control === "segmented") {
|
|
2928
|
-
return /* @__PURE__ */ (0,
|
|
2999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.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_runtime17.jsx)(
|
|
2929
3000
|
"button",
|
|
2930
3001
|
{
|
|
2931
3002
|
type: "button",
|
|
@@ -2940,8 +3011,25 @@ function ParameterSelect({ field: field2, value, onChange, disabled, id }) {
|
|
|
2940
3011
|
String(o.value)
|
|
2941
3012
|
)) });
|
|
2942
3013
|
}
|
|
3014
|
+
if (CustomSelect) {
|
|
3015
|
+
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
3016
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3017
|
+
CustomSelect,
|
|
3018
|
+
{
|
|
3019
|
+
id,
|
|
3020
|
+
label: (0, import_parameters.parameterLabel)(field2),
|
|
3021
|
+
"aria-label": (0, import_parameters.parameterLabel)(field2),
|
|
3022
|
+
value,
|
|
3023
|
+
options: customOptions,
|
|
3024
|
+
disabled: off,
|
|
3025
|
+
className: parameterInputClass,
|
|
3026
|
+
style: parameterSelectStyle,
|
|
3027
|
+
onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
|
|
3028
|
+
}
|
|
3029
|
+
);
|
|
3030
|
+
}
|
|
2943
3031
|
const index = options.findIndex((o) => o.value === value);
|
|
2944
|
-
return /* @__PURE__ */ (0,
|
|
3032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2945
3033
|
"select",
|
|
2946
3034
|
{
|
|
2947
3035
|
id,
|
|
@@ -2953,22 +3041,23 @@ function ParameterSelect({ field: field2, value, onChange, disabled, id }) {
|
|
|
2953
3041
|
if (option) onChange(option.value);
|
|
2954
3042
|
},
|
|
2955
3043
|
className: parameterInputClass,
|
|
2956
|
-
|
|
3044
|
+
style: parameterSelectStyle,
|
|
3045
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
2957
3046
|
}
|
|
2958
3047
|
);
|
|
2959
3048
|
}
|
|
2960
3049
|
function ParameterColor({ field: field2, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
2961
|
-
const [open, setOpen] = (0,
|
|
2962
|
-
const containerRef = (0,
|
|
2963
|
-
const buttonRef = (0,
|
|
2964
|
-
const popoverRef = (0,
|
|
3050
|
+
const [open, setOpen] = (0, import_react21.useState)(false);
|
|
3051
|
+
const containerRef = (0, import_react21.useRef)(null);
|
|
3052
|
+
const buttonRef = (0, import_react21.useRef)(null);
|
|
3053
|
+
const popoverRef = (0, import_react21.useRef)(null);
|
|
2965
3054
|
const alpha = !!field2.alpha;
|
|
2966
3055
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2967
3056
|
const rgb = hex.slice(0, 7);
|
|
2968
3057
|
const shown = alpha ? hex : rgb;
|
|
2969
3058
|
const off = disabled || field2.readOnly;
|
|
2970
3059
|
const name = (0, import_parameters.parameterLabel)(field2);
|
|
2971
|
-
(0,
|
|
3060
|
+
(0, import_react21.useEffect)(() => {
|
|
2972
3061
|
if (!open) return;
|
|
2973
3062
|
const onPointerDown = (e) => {
|
|
2974
3063
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2989,9 +3078,9 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
|
|
|
2989
3078
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
2990
3079
|
};
|
|
2991
3080
|
}, [open]);
|
|
2992
|
-
return /* @__PURE__ */ (0,
|
|
2993
|
-
/* @__PURE__ */ (0,
|
|
2994
|
-
/* @__PURE__ */ (0,
|
|
3081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
3082
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3083
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2995
3084
|
"button",
|
|
2996
3085
|
{
|
|
2997
3086
|
ref: buttonRef,
|
|
@@ -3002,10 +3091,10 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
|
|
|
3002
3091
|
disabled: off,
|
|
3003
3092
|
onClick: () => setOpen((prev) => !prev),
|
|
3004
3093
|
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",
|
|
3005
|
-
children: /* @__PURE__ */ (0,
|
|
3094
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
3006
3095
|
}
|
|
3007
3096
|
),
|
|
3008
|
-
/* @__PURE__ */ (0,
|
|
3097
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3009
3098
|
ParameterCommitInput,
|
|
3010
3099
|
{
|
|
3011
3100
|
id,
|
|
@@ -3021,7 +3110,7 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
|
|
|
3021
3110
|
}
|
|
3022
3111
|
)
|
|
3023
3112
|
] }),
|
|
3024
|
-
open && /* @__PURE__ */ (0,
|
|
3113
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3025
3114
|
"div",
|
|
3026
3115
|
{
|
|
3027
3116
|
ref: popoverRef,
|
|
@@ -3035,7 +3124,7 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
|
|
|
3035
3124
|
},
|
|
3036
3125
|
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",
|
|
3037
3126
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
3038
|
-
children: /* @__PURE__ */ (0,
|
|
3127
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3039
3128
|
ColorPicker,
|
|
3040
3129
|
{
|
|
3041
3130
|
value: shown,
|
|
@@ -3051,13 +3140,13 @@ function ParameterColor({ field: field2, value, onChange, onGestureStart, onGest
|
|
|
3051
3140
|
)
|
|
3052
3141
|
] });
|
|
3053
3142
|
}
|
|
3054
|
-
function ParameterVector({ field: field2, value, onChange, disabled, id }) {
|
|
3143
|
+
function ParameterVector({ field: field2, value, onChange, disabled, id, components }) {
|
|
3055
3144
|
const size = (0, import_parameters.vectorSize)(field2);
|
|
3056
|
-
return /* @__PURE__ */ (0,
|
|
3145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
3057
3146
|
const component = (0, import_parameters.vectorComponentField)(field2, i);
|
|
3058
|
-
return /* @__PURE__ */ (0,
|
|
3059
|
-
/* @__PURE__ */ (0,
|
|
3060
|
-
/* @__PURE__ */ (0,
|
|
3147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
3148
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
3149
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3061
3150
|
ParameterNumberInput,
|
|
3062
3151
|
{
|
|
3063
3152
|
field: component,
|
|
@@ -3065,6 +3154,7 @@ function ParameterVector({ field: field2, value, onChange, disabled, id }) {
|
|
|
3065
3154
|
id: i === 0 ? id : void 0,
|
|
3066
3155
|
"aria-label": `${(0, import_parameters.parameterLabel)(field2)} ${component.label}`,
|
|
3067
3156
|
disabled: disabled || field2.readOnly,
|
|
3157
|
+
components,
|
|
3068
3158
|
onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
|
|
3069
3159
|
}
|
|
3070
3160
|
)
|
|
@@ -3074,11 +3164,11 @@ function ParameterVector({ field: field2, value, onChange, disabled, id }) {
|
|
|
3074
3164
|
function ParameterImage({ field: field2, value, onChange, disabled, id, resolveFile }) {
|
|
3075
3165
|
const off = disabled || field2.readOnly;
|
|
3076
3166
|
const name = (0, import_parameters.parameterLabel)(field2);
|
|
3077
|
-
return /* @__PURE__ */ (0,
|
|
3078
|
-
/* @__PURE__ */ (0,
|
|
3079
|
-
/* @__PURE__ */ (0,
|
|
3080
|
-
/* @__PURE__ */ (0,
|
|
3081
|
-
/* @__PURE__ */ (0,
|
|
3167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-1.5", children: [
|
|
3168
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3169
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.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_runtime17.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3171
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3082
3172
|
ParameterCommitInput,
|
|
3083
3173
|
{
|
|
3084
3174
|
id,
|
|
@@ -3089,30 +3179,48 @@ function ParameterImage({ field: field2, value, onChange, disabled, id, resolveF
|
|
|
3089
3179
|
onCommit: (text) => onChange(text.trim())
|
|
3090
3180
|
}
|
|
3091
3181
|
),
|
|
3092
|
-
/* @__PURE__ */ (0,
|
|
3093
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
3094
|
-
"
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
{
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3182
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex gap-1", children: [
|
|
3183
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3184
|
+
"label",
|
|
3185
|
+
{
|
|
3186
|
+
style: parameterButtonStyle,
|
|
3187
|
+
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
3188
|
+
children: [
|
|
3189
|
+
"Choose file\u2026",
|
|
3190
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3191
|
+
"input",
|
|
3192
|
+
{
|
|
3193
|
+
type: "file",
|
|
3194
|
+
className: "sr-only",
|
|
3195
|
+
accept: field2.accept ?? "image/*",
|
|
3196
|
+
disabled: off,
|
|
3197
|
+
"aria-label": `${name} file`,
|
|
3198
|
+
onChange: async (e) => {
|
|
3199
|
+
const file = e.target.files?.[0];
|
|
3200
|
+
e.target.value = "";
|
|
3201
|
+
if (file) onChange(await resolveFile(file));
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
)
|
|
3205
|
+
]
|
|
3206
|
+
}
|
|
3207
|
+
),
|
|
3208
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3209
|
+
"button",
|
|
3210
|
+
{
|
|
3211
|
+
type: "button",
|
|
3212
|
+
style: parameterButtonStyle,
|
|
3213
|
+
className: parameterButtonClass,
|
|
3214
|
+
disabled: off,
|
|
3215
|
+
onClick: () => onChange(""),
|
|
3216
|
+
"aria-label": `Clear ${name}`,
|
|
3217
|
+
children: "Clear"
|
|
3218
|
+
}
|
|
3219
|
+
)
|
|
3112
3220
|
] })
|
|
3113
3221
|
] })
|
|
3114
3222
|
] }),
|
|
3115
|
-
field2.options && field2.options.length > 0 && /* @__PURE__ */ (0,
|
|
3223
|
+
field2.options && field2.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex flex-wrap gap-1", children: field2.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3116
3224
|
"button",
|
|
3117
3225
|
{
|
|
3118
3226
|
type: "button",
|
|
@@ -3122,14 +3230,14 @@ function ParameterImage({ field: field2, value, onChange, disabled, id, resolveF
|
|
|
3122
3230
|
disabled: off,
|
|
3123
3231
|
onClick: () => onChange(o.url),
|
|
3124
3232
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
3125
|
-
children: /* @__PURE__ */ (0,
|
|
3233
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
3126
3234
|
},
|
|
3127
3235
|
o.url
|
|
3128
3236
|
)) })
|
|
3129
3237
|
] });
|
|
3130
3238
|
}
|
|
3131
3239
|
function ParameterText({ field: field2, value, onChange, disabled, id }) {
|
|
3132
|
-
return /* @__PURE__ */ (0,
|
|
3240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3133
3241
|
ParameterCommitInput,
|
|
3134
3242
|
{
|
|
3135
3243
|
id,
|
|
@@ -3148,24 +3256,24 @@ function ParameterFieldControl({ field: field2, value, onChange, resolveFile, ..
|
|
|
3148
3256
|
switch (field2.type) {
|
|
3149
3257
|
case "number":
|
|
3150
3258
|
case "int":
|
|
3151
|
-
return /* @__PURE__ */ (0,
|
|
3259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterSlider, { field: field2, value, onChange: set, ...rest });
|
|
3152
3260
|
case "boolean":
|
|
3153
|
-
return /* @__PURE__ */ (0,
|
|
3261
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterToggle, { field: field2, value, onChange: set, ...rest });
|
|
3154
3262
|
case "choice":
|
|
3155
|
-
return /* @__PURE__ */ (0,
|
|
3263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterSelect, { field: field2, value, onChange: set, ...rest });
|
|
3156
3264
|
case "color":
|
|
3157
|
-
return /* @__PURE__ */ (0,
|
|
3265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterColor, { field: field2, value, onChange: set, ...rest });
|
|
3158
3266
|
case "vector":
|
|
3159
|
-
return /* @__PURE__ */ (0,
|
|
3267
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterVector, { field: field2, value, onChange: set, ...rest });
|
|
3160
3268
|
case "image":
|
|
3161
|
-
return /* @__PURE__ */ (0,
|
|
3269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterImage, { field: field2, value, onChange: set, resolveFile, ...rest });
|
|
3162
3270
|
case "text":
|
|
3163
|
-
return /* @__PURE__ */ (0,
|
|
3271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterText, { field: field2, value, onChange: set, ...rest });
|
|
3164
3272
|
}
|
|
3165
3273
|
}
|
|
3166
3274
|
|
|
3167
3275
|
// src/effects/EffectParameters.tsx
|
|
3168
|
-
var
|
|
3276
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3169
3277
|
function EffectParameters({
|
|
3170
3278
|
description,
|
|
3171
3279
|
values,
|
|
@@ -3177,56 +3285,75 @@ function EffectParameters({
|
|
|
3177
3285
|
renderControlAddon,
|
|
3178
3286
|
fonts,
|
|
3179
3287
|
disabled = false,
|
|
3180
|
-
className = ""
|
|
3288
|
+
className = "",
|
|
3289
|
+
components
|
|
3181
3290
|
}) {
|
|
3182
|
-
const fields = (0,
|
|
3183
|
-
const idBase = (0,
|
|
3184
|
-
const gesture =
|
|
3185
|
-
const count =
|
|
3186
|
-
|
|
3187
|
-
|
|
3291
|
+
const fields = (0, import_react22.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
3292
|
+
const idBase = (0, import_react22.useId)();
|
|
3293
|
+
const gesture = import_react22.default.useRef(null);
|
|
3294
|
+
const count = import_react22.default.useRef(0);
|
|
3295
|
+
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
3296
|
+
const handlePresetSelect = (name) => {
|
|
3297
|
+
if (!name) return;
|
|
3298
|
+
if (onPresetName) {
|
|
3299
|
+
onPresetName(name);
|
|
3300
|
+
} else if (onPreset) {
|
|
3301
|
+
const preset = description.presets.find((p) => p.name === name);
|
|
3302
|
+
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
3303
|
+
}
|
|
3304
|
+
};
|
|
3305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
3306
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3307
|
+
CustomPresetSelect,
|
|
3308
|
+
{
|
|
3309
|
+
"aria-label": `${description.name} presets`,
|
|
3310
|
+
label: `${description.name} presets`,
|
|
3311
|
+
value: "",
|
|
3312
|
+
disabled,
|
|
3313
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
3314
|
+
style: parameterSelectStyle,
|
|
3315
|
+
options: [
|
|
3316
|
+
{ value: "", label: "Presets\u2026" },
|
|
3317
|
+
...description.presets.map((p) => ({ value: p.name, label: p.name }))
|
|
3318
|
+
],
|
|
3319
|
+
onChange: (name) => handlePresetSelect(String(name))
|
|
3320
|
+
}
|
|
3321
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
3188
3322
|
"select",
|
|
3189
3323
|
{
|
|
3190
|
-
className: "w-full rounded border border-border
|
|
3324
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
3325
|
+
style: parameterSelectStyle,
|
|
3191
3326
|
"aria-label": `${description.name} presets`,
|
|
3192
3327
|
value: "",
|
|
3193
3328
|
disabled,
|
|
3194
|
-
onChange: (e) =>
|
|
3195
|
-
const name = e.currentTarget.value;
|
|
3196
|
-
if (!name) return;
|
|
3197
|
-
if (onPresetName) {
|
|
3198
|
-
onPresetName(name);
|
|
3199
|
-
} else if (onPreset) {
|
|
3200
|
-
const preset = description.presets.find((p) => p.name === name);
|
|
3201
|
-
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
3202
|
-
}
|
|
3203
|
-
},
|
|
3329
|
+
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
3204
3330
|
children: [
|
|
3205
|
-
/* @__PURE__ */ (0,
|
|
3206
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
3331
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
3332
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
3207
3333
|
]
|
|
3208
3334
|
}
|
|
3209
|
-
),
|
|
3335
|
+
)),
|
|
3210
3336
|
fields.map((field2) => {
|
|
3211
3337
|
const label = (0, import_parameters2.parameterLabel)(field2);
|
|
3212
3338
|
const inputId = `${idBase}-${field2.id}`;
|
|
3213
3339
|
const keyed = keyframed?.has(field2.id) ?? false;
|
|
3214
3340
|
const value = (0, import_effects3.effectFieldValue)(field2, values[field2.id]);
|
|
3215
3341
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field2.default);
|
|
3216
|
-
return /* @__PURE__ */ (0,
|
|
3217
|
-
/* @__PURE__ */ (0,
|
|
3218
|
-
/* @__PURE__ */ (0,
|
|
3219
|
-
keyed && /* @__PURE__ */ (0,
|
|
3342
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-1", "data-effect-control": field2.id, children: [
|
|
3343
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
3344
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field2.description, children: label }),
|
|
3345
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
3220
3346
|
renderControlAddon?.(field2.id),
|
|
3221
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
3347
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime18.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" })
|
|
3222
3348
|
] }),
|
|
3223
|
-
/* @__PURE__ */ (0,
|
|
3349
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3224
3350
|
ParameterFieldControl,
|
|
3225
3351
|
{
|
|
3226
3352
|
field: field2,
|
|
3227
3353
|
value,
|
|
3228
3354
|
id: inputId,
|
|
3229
3355
|
disabled: disabled || keyed,
|
|
3356
|
+
components,
|
|
3230
3357
|
onChange: (v) => onChange(field2.id, v, gesture.current),
|
|
3231
3358
|
onGestureStart: () => gesture.current = `${idBase}:${field2.id}:${++count.current}`,
|
|
3232
3359
|
onGestureEnd: () => gesture.current = null
|
|
@@ -3234,14 +3361,14 @@ function EffectParameters({
|
|
|
3234
3361
|
)
|
|
3235
3362
|
] }, field2.id);
|
|
3236
3363
|
}),
|
|
3237
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
3364
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
3238
3365
|
] });
|
|
3239
3366
|
}
|
|
3240
3367
|
|
|
3241
3368
|
// src/effects/useEffectAuthoring.ts
|
|
3242
|
-
var
|
|
3369
|
+
var import_react23 = require("react");
|
|
3243
3370
|
function useEffectAuthoring(session) {
|
|
3244
|
-
return (0,
|
|
3371
|
+
return (0, import_react23.useSyncExternalStore)(
|
|
3245
3372
|
(callback) => {
|
|
3246
3373
|
if (!session) return () => {
|
|
3247
3374
|
};
|
|
@@ -3253,9 +3380,9 @@ function useEffectAuthoring(session) {
|
|
|
3253
3380
|
}
|
|
3254
3381
|
|
|
3255
3382
|
// src/effects/EffectAuthoringEditor.tsx
|
|
3256
|
-
var
|
|
3383
|
+
var import_react24 = require("react");
|
|
3257
3384
|
var import_effects4 = require("@pixerate/editor/effects");
|
|
3258
|
-
var
|
|
3385
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3259
3386
|
function EffectAuthoringEditor({
|
|
3260
3387
|
session,
|
|
3261
3388
|
showSource = true,
|
|
@@ -3264,21 +3391,21 @@ function EffectAuthoringEditor({
|
|
|
3264
3391
|
className = ""
|
|
3265
3392
|
}) {
|
|
3266
3393
|
const state = useEffectAuthoring(session);
|
|
3267
|
-
const canvasRef = (0,
|
|
3268
|
-
const rendererRef = (0,
|
|
3269
|
-
const [rendererReady, setRendererReady] = (0,
|
|
3270
|
-
const renderingRef = (0,
|
|
3271
|
-
const pendingRef = (0,
|
|
3272
|
-
const timeRef = (0,
|
|
3273
|
-
const inputsRef = (0,
|
|
3274
|
-
const [previewError, setPreviewError] = (0,
|
|
3275
|
-
const [savingPreset, setSavingPreset] = (0,
|
|
3276
|
-
const [presetName, setPresetName] = (0,
|
|
3277
|
-
const textareaRef = (0,
|
|
3278
|
-
const gutterRef = (0,
|
|
3279
|
-
const [sourceCode, setSourceCode] = (0,
|
|
3280
|
-
const sourceDebounceRef = (0,
|
|
3281
|
-
(0,
|
|
3394
|
+
const canvasRef = (0, import_react24.useRef)(null);
|
|
3395
|
+
const rendererRef = (0, import_react24.useRef)(null);
|
|
3396
|
+
const [rendererReady, setRendererReady] = (0, import_react24.useState)(0);
|
|
3397
|
+
const renderingRef = (0, import_react24.useRef)(false);
|
|
3398
|
+
const pendingRef = (0, import_react24.useRef)(false);
|
|
3399
|
+
const timeRef = (0, import_react24.useRef)(0);
|
|
3400
|
+
const inputsRef = (0, import_react24.useRef)({});
|
|
3401
|
+
const [previewError, setPreviewError] = (0, import_react24.useState)(null);
|
|
3402
|
+
const [savingPreset, setSavingPreset] = (0, import_react24.useState)(false);
|
|
3403
|
+
const [presetName, setPresetName] = (0, import_react24.useState)("");
|
|
3404
|
+
const textareaRef = (0, import_react24.useRef)(null);
|
|
3405
|
+
const gutterRef = (0, import_react24.useRef)(null);
|
|
3406
|
+
const [sourceCode, setSourceCode] = (0, import_react24.useState)("");
|
|
3407
|
+
const sourceDebounceRef = (0, import_react24.useRef)(null);
|
|
3408
|
+
(0, import_react24.useEffect)(() => {
|
|
3282
3409
|
const canvas = canvasRef.current;
|
|
3283
3410
|
canvas?.getContext("2d")?.clearRect(0, 0, canvas.width, canvas.height);
|
|
3284
3411
|
setPreviewError(null);
|
|
@@ -3312,7 +3439,7 @@ function EffectAuthoringEditor({
|
|
|
3312
3439
|
}
|
|
3313
3440
|
};
|
|
3314
3441
|
}, [session, previewSize.width, previewSize.height]);
|
|
3315
|
-
const pump = (0,
|
|
3442
|
+
const pump = (0, import_react24.useCallback)(async () => {
|
|
3316
3443
|
if (renderingRef.current) {
|
|
3317
3444
|
pendingRef.current = true;
|
|
3318
3445
|
return;
|
|
@@ -3343,26 +3470,26 @@ function EffectAuthoringEditor({
|
|
|
3343
3470
|
}
|
|
3344
3471
|
}, []);
|
|
3345
3472
|
const inputSpecs = state?.description.inputs;
|
|
3346
|
-
(0,
|
|
3473
|
+
(0, import_react24.useEffect)(() => {
|
|
3347
3474
|
inputsRef.current = inputSpecs ? (0, import_effects4.effectSampleInputs)({ inputs: inputSpecs }, previewSize) : {};
|
|
3348
3475
|
}, [inputSpecs, previewSize.width, previewSize.height]);
|
|
3349
|
-
(0,
|
|
3476
|
+
(0, import_react24.useEffect)(() => {
|
|
3350
3477
|
if (!state) return;
|
|
3351
3478
|
timeRef.current = state.time;
|
|
3352
3479
|
void pump();
|
|
3353
3480
|
}, [state, rendererReady, pump]);
|
|
3354
|
-
(0,
|
|
3481
|
+
(0, import_react24.useEffect)(() => {
|
|
3355
3482
|
if (state?.source !== null && state?.source !== void 0) {
|
|
3356
3483
|
setSourceCode(state.source);
|
|
3357
3484
|
}
|
|
3358
3485
|
}, [state?.source]);
|
|
3359
|
-
(0,
|
|
3486
|
+
(0, import_react24.useEffect)(() => {
|
|
3360
3487
|
return () => {
|
|
3361
3488
|
if (sourceDebounceRef.current) clearTimeout(sourceDebounceRef.current);
|
|
3362
3489
|
};
|
|
3363
3490
|
}, []);
|
|
3364
3491
|
if (!session || !state) {
|
|
3365
|
-
return /* @__PURE__ */ (0,
|
|
3492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: `p-4 text-center text-xs text-muted-foreground ${className}`, children: "No effect authoring session is open." });
|
|
3366
3493
|
}
|
|
3367
3494
|
const hasSource = showSource && state.sourceLanguage !== null && typeof session.setSource === "function";
|
|
3368
3495
|
const handleSourceChange = (e) => {
|
|
@@ -3396,10 +3523,10 @@ function EffectAuthoringEditor({
|
|
|
3396
3523
|
const issueLines = new Set(
|
|
3397
3524
|
state.issues.map((i) => i.line).filter((l) => typeof l === "number")
|
|
3398
3525
|
);
|
|
3399
|
-
return /* @__PURE__ */ (0,
|
|
3400
|
-
/* @__PURE__ */ (0,
|
|
3401
|
-
/* @__PURE__ */ (0,
|
|
3402
|
-
/* @__PURE__ */ (0,
|
|
3526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: `space-y-4 rounded border border-border bg-background p-4 text-foreground ${className}`, "data-effect-authoring-editor": state.name, children: [
|
|
3527
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border pb-3", children: [
|
|
3528
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3529
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3403
3530
|
"button",
|
|
3404
3531
|
{
|
|
3405
3532
|
type: "button",
|
|
@@ -3409,15 +3536,15 @@ function EffectAuthoringEditor({
|
|
|
3409
3536
|
children: state.playing ? "Pause" : "Play"
|
|
3410
3537
|
}
|
|
3411
3538
|
),
|
|
3412
|
-
/* @__PURE__ */ (0,
|
|
3539
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "font-mono text-xs text-muted-foreground", "data-time-readout": true, children: [
|
|
3413
3540
|
state.time,
|
|
3414
3541
|
"ms / ",
|
|
3415
3542
|
state.duration,
|
|
3416
3543
|
"ms"
|
|
3417
3544
|
] })
|
|
3418
3545
|
] }),
|
|
3419
|
-
/* @__PURE__ */ (0,
|
|
3420
|
-
/* @__PURE__ */ (0,
|
|
3546
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3547
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3421
3548
|
"button",
|
|
3422
3549
|
{
|
|
3423
3550
|
type: "button",
|
|
@@ -3428,7 +3555,7 @@ function EffectAuthoringEditor({
|
|
|
3428
3555
|
children: "Undo"
|
|
3429
3556
|
}
|
|
3430
3557
|
),
|
|
3431
|
-
/* @__PURE__ */ (0,
|
|
3558
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3432
3559
|
"button",
|
|
3433
3560
|
{
|
|
3434
3561
|
type: "button",
|
|
@@ -3439,8 +3566,8 @@ function EffectAuthoringEditor({
|
|
|
3439
3566
|
children: "Redo"
|
|
3440
3567
|
}
|
|
3441
3568
|
),
|
|
3442
|
-
savingPreset ? /* @__PURE__ */ (0,
|
|
3443
|
-
/* @__PURE__ */ (0,
|
|
3569
|
+
savingPreset ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("form", { onSubmit: handleSavePreset, className: "flex items-center gap-1", children: [
|
|
3570
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3444
3571
|
"input",
|
|
3445
3572
|
{
|
|
3446
3573
|
type: "text",
|
|
@@ -3451,7 +3578,7 @@ function EffectAuthoringEditor({
|
|
|
3451
3578
|
onChange: (e) => setPresetName(e.target.value)
|
|
3452
3579
|
}
|
|
3453
3580
|
),
|
|
3454
|
-
/* @__PURE__ */ (0,
|
|
3581
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3455
3582
|
"button",
|
|
3456
3583
|
{
|
|
3457
3584
|
type: "submit",
|
|
@@ -3459,7 +3586,7 @@ function EffectAuthoringEditor({
|
|
|
3459
3586
|
children: "Save"
|
|
3460
3587
|
}
|
|
3461
3588
|
),
|
|
3462
|
-
/* @__PURE__ */ (0,
|
|
3589
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3463
3590
|
"button",
|
|
3464
3591
|
{
|
|
3465
3592
|
type: "button",
|
|
@@ -3468,7 +3595,7 @@ function EffectAuthoringEditor({
|
|
|
3468
3595
|
children: "Cancel"
|
|
3469
3596
|
}
|
|
3470
3597
|
)
|
|
3471
|
-
] }) : /* @__PURE__ */ (0,
|
|
3598
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3472
3599
|
"button",
|
|
3473
3600
|
{
|
|
3474
3601
|
type: "button",
|
|
@@ -3479,11 +3606,11 @@ function EffectAuthoringEditor({
|
|
|
3479
3606
|
)
|
|
3480
3607
|
] })
|
|
3481
3608
|
] }),
|
|
3482
|
-
/* @__PURE__ */ (0,
|
|
3483
|
-
/* @__PURE__ */ (0,
|
|
3484
|
-
/* @__PURE__ */ (0,
|
|
3485
|
-
/* @__PURE__ */ (0,
|
|
3486
|
-
/* @__PURE__ */ (0,
|
|
3609
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
|
|
3610
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-2", children: [
|
|
3611
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Preview" }),
|
|
3612
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "relative flex aspect-video w-full items-center justify-center overflow-hidden rounded border border-border bg-black", children: [
|
|
3613
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3487
3614
|
"canvas",
|
|
3488
3615
|
{
|
|
3489
3616
|
ref: canvasRef,
|
|
@@ -3493,9 +3620,9 @@ function EffectAuthoringEditor({
|
|
|
3493
3620
|
"aria-label": "Effect preview canvas"
|
|
3494
3621
|
}
|
|
3495
3622
|
),
|
|
3496
|
-
previewError && /* @__PURE__ */ (0,
|
|
3623
|
+
previewError && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "absolute inset-0 flex items-center justify-center p-4 text-center text-xs text-white/80", role: "status", "data-effect-preview-error": true, children: previewError })
|
|
3497
3624
|
] }),
|
|
3498
|
-
state.issues.length > 0 && /* @__PURE__ */ (0,
|
|
3625
|
+
state.issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.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_runtime19.jsxs)(
|
|
3499
3626
|
"div",
|
|
3500
3627
|
{
|
|
3501
3628
|
className: `cursor-pointer ${issue.severity === "error" ? "text-destructive" : "text-amber-500"}`,
|
|
@@ -3508,17 +3635,17 @@ function EffectAuthoringEditor({
|
|
|
3508
3635
|
idx
|
|
3509
3636
|
)) })
|
|
3510
3637
|
] }),
|
|
3511
|
-
hasSource && /* @__PURE__ */ (0,
|
|
3512
|
-
/* @__PURE__ */ (0,
|
|
3638
|
+
hasSource && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-2", "data-effect-source-pane": true, children: [
|
|
3639
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "flex items-center justify-between text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { children: [
|
|
3513
3640
|
"Source (",
|
|
3514
3641
|
state.sourceLanguage,
|
|
3515
3642
|
")"
|
|
3516
3643
|
] }) }),
|
|
3517
|
-
/* @__PURE__ */ (0,
|
|
3518
|
-
/* @__PURE__ */ (0,
|
|
3644
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex h-64 rounded border border-border bg-muted/20 font-mono text-xs", children: [
|
|
3645
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.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) => {
|
|
3519
3646
|
const lineNum = i + 1;
|
|
3520
3647
|
const hasIssue = issueLines.has(lineNum);
|
|
3521
|
-
return /* @__PURE__ */ (0,
|
|
3648
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3522
3649
|
"div",
|
|
3523
3650
|
{
|
|
3524
3651
|
"data-gutter-line": lineNum,
|
|
@@ -3528,7 +3655,7 @@ function EffectAuthoringEditor({
|
|
|
3528
3655
|
i
|
|
3529
3656
|
);
|
|
3530
3657
|
}) }),
|
|
3531
|
-
/* @__PURE__ */ (0,
|
|
3658
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3532
3659
|
"textarea",
|
|
3533
3660
|
{
|
|
3534
3661
|
ref: textareaRef,
|
|
@@ -3546,9 +3673,9 @@ function EffectAuthoringEditor({
|
|
|
3546
3673
|
] })
|
|
3547
3674
|
] })
|
|
3548
3675
|
] }),
|
|
3549
|
-
/* @__PURE__ */ (0,
|
|
3550
|
-
/* @__PURE__ */ (0,
|
|
3551
|
-
/* @__PURE__ */ (0,
|
|
3676
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-2 border-t border-border pt-4", children: [
|
|
3677
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Parameters" }),
|
|
3678
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3552
3679
|
EffectParameters,
|
|
3553
3680
|
{
|
|
3554
3681
|
description: state.description,
|
|
@@ -3560,7 +3687,7 @@ function EffectAuthoringEditor({
|
|
|
3560
3687
|
const track = state.tracks[control];
|
|
3561
3688
|
const isAnimated = Boolean(track && track.length > 0);
|
|
3562
3689
|
const hasKeyframeAtPlayhead = isAnimated && track.some((kf) => kf.time === state.time);
|
|
3563
|
-
return /* @__PURE__ */ (0,
|
|
3690
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3564
3691
|
"button",
|
|
3565
3692
|
{
|
|
3566
3693
|
type: "button",
|
|
@@ -3582,17 +3709,17 @@ function EffectAuthoringEditor({
|
|
|
3582
3709
|
}
|
|
3583
3710
|
)
|
|
3584
3711
|
] }),
|
|
3585
|
-
showTimeline && /* @__PURE__ */ (0,
|
|
3586
|
-
/* @__PURE__ */ (0,
|
|
3587
|
-
/* @__PURE__ */ (0,
|
|
3588
|
-
/* @__PURE__ */ (0,
|
|
3589
|
-
/* @__PURE__ */ (0,
|
|
3590
|
-
/* @__PURE__ */ (0,
|
|
3591
|
-
/* @__PURE__ */ (0,
|
|
3592
|
-
/* @__PURE__ */ (0,
|
|
3712
|
+
showTimeline && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-3 border-t border-border pt-4", "data-effect-timeline": true, children: [
|
|
3713
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-4", children: [
|
|
3714
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Timeline" }),
|
|
3715
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-3 text-xs", children: [
|
|
3716
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
3717
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: "Duration:" }),
|
|
3718
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DurationField, { duration: state.duration, onCommit: (duration) => session.setTiming({ duration }) }),
|
|
3719
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-muted-foreground", children: "ms" })
|
|
3593
3720
|
] }),
|
|
3594
|
-
/* @__PURE__ */ (0,
|
|
3595
|
-
/* @__PURE__ */ (0,
|
|
3721
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: "flex items-center gap-1.5 cursor-pointer", children: [
|
|
3722
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3596
3723
|
"input",
|
|
3597
3724
|
{
|
|
3598
3725
|
type: "checkbox",
|
|
@@ -3601,11 +3728,11 @@ function EffectAuthoringEditor({
|
|
|
3601
3728
|
onChange: (e) => session.setTiming({ loop: e.target.checked })
|
|
3602
3729
|
}
|
|
3603
3730
|
),
|
|
3604
|
-
/* @__PURE__ */ (0,
|
|
3731
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: "Loop" })
|
|
3605
3732
|
] })
|
|
3606
3733
|
] })
|
|
3607
3734
|
] }),
|
|
3608
|
-
/* @__PURE__ */ (0,
|
|
3735
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "space-y-1", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3609
3736
|
"input",
|
|
3610
3737
|
{
|
|
3611
3738
|
type: "range",
|
|
@@ -3617,12 +3744,12 @@ function EffectAuthoringEditor({
|
|
|
3617
3744
|
className: "w-full cursor-pointer accent-primary"
|
|
3618
3745
|
}
|
|
3619
3746
|
) }),
|
|
3620
|
-
Object.entries(state.tracks).length > 0 && /* @__PURE__ */ (0,
|
|
3747
|
+
Object.entries(state.tracks).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "space-y-2 pt-1", children: Object.entries(state.tracks).map(([control, keyframes]) => {
|
|
3621
3748
|
if (!keyframes || keyframes.length === 0) return null;
|
|
3622
|
-
return /* @__PURE__ */ (0,
|
|
3623
|
-
/* @__PURE__ */ (0,
|
|
3624
|
-
/* @__PURE__ */ (0,
|
|
3625
|
-
/* @__PURE__ */ (0,
|
|
3749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-1", "data-track": control, children: [
|
|
3750
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
3751
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "font-medium", children: control }),
|
|
3752
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3626
3753
|
"button",
|
|
3627
3754
|
{
|
|
3628
3755
|
type: "button",
|
|
@@ -3633,12 +3760,12 @@ function EffectAuthoringEditor({
|
|
|
3633
3760
|
}
|
|
3634
3761
|
)
|
|
3635
3762
|
] }),
|
|
3636
|
-
/* @__PURE__ */ (0,
|
|
3763
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "relative h-4 w-full rounded bg-muted/40", children: keyframes.map((kf, i) => {
|
|
3637
3764
|
const leftPct = Math.max(
|
|
3638
3765
|
0,
|
|
3639
3766
|
Math.min(100, kf.time / (state.duration || 1) * 100)
|
|
3640
3767
|
);
|
|
3641
|
-
return /* @__PURE__ */ (0,
|
|
3768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3642
3769
|
"button",
|
|
3643
3770
|
{
|
|
3644
3771
|
type: "button",
|
|
@@ -3658,14 +3785,14 @@ function EffectAuthoringEditor({
|
|
|
3658
3785
|
] });
|
|
3659
3786
|
}
|
|
3660
3787
|
function DurationField({ duration, onCommit }) {
|
|
3661
|
-
const [draft, setDraft] = (0,
|
|
3662
|
-
(0,
|
|
3788
|
+
const [draft, setDraft] = (0, import_react24.useState)(String(duration));
|
|
3789
|
+
(0, import_react24.useEffect)(() => setDraft(String(duration)), [duration]);
|
|
3663
3790
|
const commit = () => {
|
|
3664
3791
|
const next = Number(draft);
|
|
3665
3792
|
if (Number.isFinite(next) && next >= 1 && next !== duration) onCommit(next);
|
|
3666
3793
|
else setDraft(String(duration));
|
|
3667
3794
|
};
|
|
3668
|
-
return /* @__PURE__ */ (0,
|
|
3795
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3669
3796
|
"input",
|
|
3670
3797
|
{
|
|
3671
3798
|
type: "number",
|
|
@@ -3684,9 +3811,9 @@ function DurationField({ duration, onCommit }) {
|
|
|
3684
3811
|
}
|
|
3685
3812
|
|
|
3686
3813
|
// src/video-editor/VideoEffectsPanel.tsx
|
|
3687
|
-
var
|
|
3814
|
+
var import_react25 = require("react");
|
|
3688
3815
|
var import_video_editor11 = require("@pixerate/editor/video-editor");
|
|
3689
|
-
var
|
|
3816
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3690
3817
|
var btn7 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
3691
3818
|
var keyedOf = (values) => new Set(Object.entries(values ?? {}).filter(([, v]) => (0, import_video_editor11.isVideoKeyframes)(v)).map(([k]) => k));
|
|
3692
3819
|
function EffectControls({
|
|
@@ -3699,23 +3826,23 @@ function EffectControls({
|
|
|
3699
3826
|
onPreset
|
|
3700
3827
|
}) {
|
|
3701
3828
|
const { description, error } = useEffectDescription(provider, effect);
|
|
3702
|
-
if (!provider) return /* @__PURE__ */ (0,
|
|
3829
|
+
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
3703
3830
|
'No effects provider: "',
|
|
3704
3831
|
name ?? effect,
|
|
3705
3832
|
'" is kept and shown as a placeholder.'
|
|
3706
3833
|
] });
|
|
3707
|
-
if (error) return /* @__PURE__ */ (0,
|
|
3708
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
3709
|
-
return /* @__PURE__ */ (0,
|
|
3834
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
|
|
3835
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
|
|
3836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectParameters, { description, values: values ?? {}, keyframed: keyedOf(values), disabled, onChange, onReset: (k) => onChange(k, description.defaults[k], null), onPreset });
|
|
3710
3837
|
}
|
|
3711
3838
|
function VideoEffectsPanel({ controller, className = "" }) {
|
|
3712
3839
|
const state = useVideoEditorState(controller);
|
|
3713
3840
|
const provider = state.effectsProvider;
|
|
3714
|
-
const [browse, setBrowse] = (0,
|
|
3715
|
-
const [message, setMessage] = (0,
|
|
3716
|
-
const [open, setOpen] = (0,
|
|
3717
|
-
const [authoring, setAuthoring] = (0,
|
|
3718
|
-
(0,
|
|
3841
|
+
const [browse, setBrowse] = (0, import_react25.useState)(null);
|
|
3842
|
+
const [message, setMessage] = (0, import_react25.useState)(null);
|
|
3843
|
+
const [open, setOpen] = (0, import_react25.useState)(null);
|
|
3844
|
+
const [authoring, setAuthoring] = (0, import_react25.useState)(null);
|
|
3845
|
+
(0, import_react25.useEffect)(() => () => authoring?.dispose(), [authoring]);
|
|
3719
3846
|
const selected = state.selection[0];
|
|
3720
3847
|
const at = selected ? (0, import_video_editor11.findVideoClip)(state.project, selected) : null;
|
|
3721
3848
|
const clip = at?.clip ?? null;
|
|
@@ -3726,18 +3853,18 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
3726
3853
|
if (!track) return setMessage("Add a video track first.");
|
|
3727
3854
|
report(controller.addEffectClip(track, effect, { start: Math.round(state.time), mode: "overwrite" }).then((r) => (r.ok && r.clip && controller.select([r.clip]), r)));
|
|
3728
3855
|
};
|
|
3729
|
-
return /* @__PURE__ */ (0,
|
|
3730
|
-
/* @__PURE__ */ (0,
|
|
3731
|
-
/* @__PURE__ */ (0,
|
|
3732
|
-
/* @__PURE__ */ (0,
|
|
3856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.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: [
|
|
3857
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3858
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h3", { className: "flex-1 font-semibold", children: "Effects" }),
|
|
3859
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn7, disabled: disabled || !provider, onClick: () => setBrowse(browse === "generator" ? null : "generator"), "aria-pressed": browse === "generator", children: "Add effect clip" })
|
|
3733
3860
|
] }),
|
|
3734
|
-
!provider && /* @__PURE__ */ (0,
|
|
3735
|
-
browse === "generator" && /* @__PURE__ */ (0,
|
|
3736
|
-
!clip && /* @__PURE__ */ (0,
|
|
3737
|
-
clip && /* @__PURE__ */ (0,
|
|
3738
|
-
clip.type === "effect" && /* @__PURE__ */ (0,
|
|
3739
|
-
/* @__PURE__ */ (0,
|
|
3740
|
-
/* @__PURE__ */ (0,
|
|
3861
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects in the project are kept and drawn as placeholders." }),
|
|
3862
|
+
browse === "generator" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, uses: ["generator", "title", "overlay"], title: "Generators and titles", onPick: (e) => (setBrowse(null), addEffectClip(e.id)) }),
|
|
3863
|
+
!clip && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Select a clip to see its effects." }),
|
|
3864
|
+
clip && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
3865
|
+
clip.type === "effect" && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1", "data-effect-part": "generator", children: [
|
|
3866
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "font-medium", children: clip.name ?? clip.effect }),
|
|
3867
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3741
3868
|
EffectControls,
|
|
3742
3869
|
{
|
|
3743
3870
|
provider,
|
|
@@ -3750,13 +3877,13 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
3750
3877
|
}
|
|
3751
3878
|
)
|
|
3752
3879
|
] }),
|
|
3753
|
-
/* @__PURE__ */ (0,
|
|
3754
|
-
/* @__PURE__ */ (0,
|
|
3755
|
-
/* @__PURE__ */ (0,
|
|
3756
|
-
clip.transition?.type === "effect" ? /* @__PURE__ */ (0,
|
|
3880
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1", "data-effect-part": "transition", children: [
|
|
3881
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3882
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "flex-1 font-medium", children: "Transition in" }),
|
|
3883
|
+
clip.transition?.type === "effect" ? /* @__PURE__ */ (0, import_jsx_runtime20.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_runtime20.jsx)("button", { type: "button", className: btn7, disabled: disabled || !provider, "aria-pressed": browse === "transition", onClick: () => setBrowse(browse === "transition" ? null : "transition"), children: "Effect transition\u2026" })
|
|
3757
3884
|
] }),
|
|
3758
|
-
browse === "transition" && /* @__PURE__ */ (0,
|
|
3759
|
-
clip.transition?.type === "effect" && clip.transition.effect && /* @__PURE__ */ (0,
|
|
3885
|
+
browse === "transition" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, uses: ["transition"], title: "Transitions", onPick: (e) => (setBrowse(null), report(controller.setEffectTransition(clip.id, e.id))) }),
|
|
3886
|
+
clip.transition?.type === "effect" && clip.transition.effect && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3760
3887
|
EffectControls,
|
|
3761
3888
|
{
|
|
3762
3889
|
provider,
|
|
@@ -3769,19 +3896,19 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
3769
3896
|
}
|
|
3770
3897
|
)
|
|
3771
3898
|
] }),
|
|
3772
|
-
/* @__PURE__ */ (0,
|
|
3773
|
-
/* @__PURE__ */ (0,
|
|
3774
|
-
/* @__PURE__ */ (0,
|
|
3775
|
-
/* @__PURE__ */ (0,
|
|
3899
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1", "data-effect-part": "stack", children: [
|
|
3900
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3901
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "flex-1 font-medium", children: "On this clip" }),
|
|
3902
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn7, disabled: disabled || !provider, "aria-pressed": browse === "clip", onClick: () => setBrowse(browse === "clip" ? null : "clip"), children: "Add effect\u2026" })
|
|
3776
3903
|
] }),
|
|
3777
|
-
browse === "clip" && /* @__PURE__ */ (0,
|
|
3778
|
-
/* @__PURE__ */ (0,
|
|
3779
|
-
/* @__PURE__ */ (0,
|
|
3780
|
-
/* @__PURE__ */ (0,
|
|
3781
|
-
/* @__PURE__ */ (0,
|
|
3782
|
-
/* @__PURE__ */ (0,
|
|
3783
|
-
/* @__PURE__ */ (0,
|
|
3784
|
-
/* @__PURE__ */ (0,
|
|
3904
|
+
browse === "clip" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, uses: ["filter", "overlay"], title: "Filters and overlays", onPick: (e) => (setBrowse(null), report(controller.applyClipEffect(clip.id, e.id))) }),
|
|
3905
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ol", { className: "space-y-1", children: (clip.effects ?? []).map((e, i, all) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("li", { className: "rounded border border-border p-1", "data-clip-effect": e.id, children: [
|
|
3906
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3907
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.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 })) }),
|
|
3908
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.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 }),
|
|
3909
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.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" }),
|
|
3910
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.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" }),
|
|
3911
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3785
3912
|
"button",
|
|
3786
3913
|
{
|
|
3787
3914
|
type: "button",
|
|
@@ -3797,12 +3924,12 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
3797
3924
|
children: "\u270E"
|
|
3798
3925
|
}
|
|
3799
3926
|
),
|
|
3800
|
-
/* @__PURE__ */ (0,
|
|
3927
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn7, disabled, "aria-label": `Remove ${e.name ?? e.effect}`, onClick: () => report(controller.removeClipEffect(clip.id, e.id)), children: "\u2715" })
|
|
3801
3928
|
] }),
|
|
3802
|
-
open === e.id && /* @__PURE__ */ (0,
|
|
3803
|
-
/* @__PURE__ */ (0,
|
|
3804
|
-
/* @__PURE__ */ (0,
|
|
3805
|
-
/* @__PURE__ */ (0,
|
|
3929
|
+
open === e.id && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "mt-1 space-y-2", children: [
|
|
3930
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3931
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "w-14 text-[11px]", children: "Opacity" }),
|
|
3932
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3806
3933
|
"input",
|
|
3807
3934
|
{
|
|
3808
3935
|
type: "range",
|
|
@@ -3817,7 +3944,7 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
3817
3944
|
}
|
|
3818
3945
|
)
|
|
3819
3946
|
] }),
|
|
3820
|
-
/* @__PURE__ */ (0,
|
|
3947
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3821
3948
|
EffectControls,
|
|
3822
3949
|
{
|
|
3823
3950
|
provider,
|
|
@@ -3831,13 +3958,13 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
3831
3958
|
)
|
|
3832
3959
|
] })
|
|
3833
3960
|
] }, e.id)) }),
|
|
3834
|
-
!clip.effects?.length && /* @__PURE__ */ (0,
|
|
3961
|
+
!clip.effects?.length && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects on this clip." })
|
|
3835
3962
|
] })
|
|
3836
3963
|
] }),
|
|
3837
|
-
authoring && /* @__PURE__ */ (0,
|
|
3838
|
-
/* @__PURE__ */ (0,
|
|
3839
|
-
/* @__PURE__ */ (0,
|
|
3840
|
-
/* @__PURE__ */ (0,
|
|
3964
|
+
authoring && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1 rounded border border-border p-1", "data-effect-authoring": authoring.instance, children: [
|
|
3965
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectAuthoringEditor, { session: authoring.session, showSource: false, previewSize: { width: 240, height: 135 } }),
|
|
3966
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex gap-1", children: [
|
|
3967
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3841
3968
|
"button",
|
|
3842
3969
|
{
|
|
3843
3970
|
type: "button",
|
|
@@ -3851,43 +3978,43 @@ function VideoEffectsPanel({ controller, className = "" }) {
|
|
|
3851
3978
|
children: "Apply to clip"
|
|
3852
3979
|
}
|
|
3853
3980
|
),
|
|
3854
|
-
/* @__PURE__ */ (0,
|
|
3981
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn7, onClick: () => setAuthoring(null), children: "Close" })
|
|
3855
3982
|
] })
|
|
3856
3983
|
] }),
|
|
3857
|
-
message && /* @__PURE__ */ (0,
|
|
3984
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
3858
3985
|
] });
|
|
3859
3986
|
}
|
|
3860
3987
|
|
|
3861
3988
|
// src/video-editor/VideoEditor.tsx
|
|
3862
|
-
var
|
|
3989
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3863
3990
|
function VideoEditor({ controller: given, options, editable = true, pxPerSecond, onPxPerSecondChange, resolution, showIssues = true, showTranscript = true, transcriptMode = "panel", showScopes = false, effects, showEffects, className = "", playback, onPlaybackReveal }) {
|
|
3864
3991
|
const { controller, state } = useVideoEditor(given ?? options ?? {});
|
|
3865
3992
|
useEffects(controller, effects);
|
|
3866
3993
|
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")));
|
|
3867
|
-
(0,
|
|
3994
|
+
(0, import_react26.useEffect)(() => {
|
|
3868
3995
|
if (editable) return;
|
|
3869
3996
|
const was = controller.getState().readOnly;
|
|
3870
3997
|
controller.setReadOnly(true);
|
|
3871
3998
|
return () => controller.setReadOnly(was);
|
|
3872
3999
|
}, [controller, editable]);
|
|
3873
4000
|
const { issues } = state;
|
|
3874
|
-
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0,
|
|
3875
|
-
return /* @__PURE__ */ (0,
|
|
3876
|
-
/* @__PURE__ */ (0,
|
|
3877
|
-
editable && /* @__PURE__ */ (0,
|
|
3878
|
-
/* @__PURE__ */ (0,
|
|
3879
|
-
/* @__PURE__ */ (0,
|
|
3880
|
-
/* @__PURE__ */ (0,
|
|
3881
|
-
showScopes && /* @__PURE__ */ (0,
|
|
4001
|
+
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.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_runtime21.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)) });
|
|
4002
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `flex flex-col gap-3 ${className}`, "data-video-editor": "", children: [
|
|
4003
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `grid gap-3 ${editable ? "lg:grid-cols-[16rem_minmax(0,1fr)_18rem]" : ""}`, children: [
|
|
4004
|
+
editable && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(MediaBin, { controller, className: "min-w-0" }),
|
|
4005
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex min-w-0 flex-col gap-2", children: [
|
|
4006
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(VideoPreview, { controller, resolution, className: "rounded-md border border-border" }),
|
|
4007
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(VideoTransport, { controller, editable }),
|
|
4008
|
+
showScopes && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(VideoScopes, { controller })
|
|
3882
4009
|
] }),
|
|
3883
|
-
editable && /* @__PURE__ */ (0,
|
|
3884
|
-
/* @__PURE__ */ (0,
|
|
3885
|
-
effectsShown && /* @__PURE__ */ (0,
|
|
4010
|
+
editable && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex min-w-0 flex-col gap-3", children: [
|
|
4011
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ClipInspector, { controller, className: "min-w-0" }),
|
|
4012
|
+
effectsShown && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(VideoEffectsPanel, { controller, className: "min-w-0" })
|
|
3886
4013
|
] })
|
|
3887
4014
|
] }),
|
|
3888
|
-
/* @__PURE__ */ (0,
|
|
3889
|
-
/* @__PURE__ */ (0,
|
|
3890
|
-
showTranscript && (transcriptMode === "editor" ? /* @__PURE__ */ (0,
|
|
4015
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(VideoTimeline, { controller, editable, pxPerSecond, onPxPerSecondChange, playback, onPlaybackReveal }),
|
|
4016
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(EditPlanPreview, { controller, editable }),
|
|
4017
|
+
showTranscript && (transcriptMode === "editor" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TranscriptEditor, { controller, editable }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TranscriptPanel, { controller, editable })),
|
|
3891
4018
|
issueList
|
|
3892
4019
|
] });
|
|
3893
4020
|
}
|