@pixerate/editor-react 0.114.2 → 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/{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/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 +1388 -1217
- package/dist/index.js +3 -3
- 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
package/dist/effects/index.cjs
CHANGED
|
@@ -178,12 +178,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
// src/effects/EffectParameters.tsx
|
|
181
|
-
var
|
|
181
|
+
var import_react9 = __toESM(require("react"), 1);
|
|
182
182
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
183
183
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
184
184
|
|
|
185
185
|
// src/parameters/fields.tsx
|
|
186
|
-
var
|
|
186
|
+
var import_react8 = require("react");
|
|
187
187
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
188
188
|
|
|
189
189
|
// src/color/index.ts
|
|
@@ -1225,18 +1225,57 @@ function useResolvedColor(value, scheme) {
|
|
|
1225
1225
|
// src/color/index.ts
|
|
1226
1226
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
1227
1227
|
|
|
1228
|
-
// src/parameters/
|
|
1228
|
+
// src/parameters/controls.tsx
|
|
1229
|
+
var import_react7 = require("react");
|
|
1229
1230
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1231
|
+
var ParameterComponentsContext = (0, import_react7.createContext)({});
|
|
1232
|
+
function useParameterComponents() {
|
|
1233
|
+
return (0, import_react7.useContext)(ParameterComponentsContext);
|
|
1234
|
+
}
|
|
1235
|
+
function resolveParameterComponents(explicit, context) {
|
|
1236
|
+
return {
|
|
1237
|
+
input: explicit?.input ?? context?.input,
|
|
1238
|
+
slider: explicit?.slider ?? context?.slider,
|
|
1239
|
+
select: explicit?.select ?? context?.select
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
// src/parameters/fields.tsx
|
|
1244
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1245
|
+
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
1246
|
+
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
1247
|
+
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
1248
|
+
var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
|
|
1230
1249
|
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";
|
|
1231
1250
|
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";
|
|
1232
1251
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
1233
|
-
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
|
|
1252
|
+
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
1253
|
+
const inputRef = (0, import_react8.useRef)(null);
|
|
1254
|
+
const lastCommitted = (0, import_react8.useRef)(null);
|
|
1255
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
1256
|
+
lastCommitted.current = null;
|
|
1257
|
+
const el = inputRef.current;
|
|
1258
|
+
if (el && el.value !== value) el.value = value;
|
|
1259
|
+
}, [value]);
|
|
1234
1260
|
const commit = (el) => {
|
|
1235
|
-
|
|
1261
|
+
const text = el.value;
|
|
1262
|
+
if (text === value || text === lastCommitted.current) return;
|
|
1263
|
+
onCommit(text, el);
|
|
1264
|
+
lastCommitted.current = el.value === text ? text : null;
|
|
1236
1265
|
};
|
|
1266
|
+
const commitRef = (0, import_react8.useRef)(commit);
|
|
1267
|
+
commitRef.current = commit;
|
|
1268
|
+
(0, import_react8.useEffect)(() => {
|
|
1269
|
+
const el = inputRef.current;
|
|
1270
|
+
if (!el) return;
|
|
1271
|
+
const change = () => commitRef.current(el);
|
|
1272
|
+
el.addEventListener("change", change);
|
|
1273
|
+
return () => el.removeEventListener("change", change);
|
|
1274
|
+
}, [multiline]);
|
|
1237
1275
|
const keyDown = (e) => {
|
|
1238
1276
|
onKeyDown?.(e);
|
|
1239
1277
|
if (e.defaultPrevented) return;
|
|
1278
|
+
if (e.key === "Tab") commit(e.currentTarget);
|
|
1240
1279
|
if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
|
|
1241
1280
|
e.preventDefault();
|
|
1242
1281
|
commit(e.currentTarget);
|
|
@@ -1246,86 +1285,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
1246
1285
|
const props = {
|
|
1247
1286
|
defaultValue: value,
|
|
1248
1287
|
className: className ?? parameterInputClass,
|
|
1288
|
+
style: { ...parameterInputStyle, ...style },
|
|
1249
1289
|
onBlur: (e) => commit(e.currentTarget),
|
|
1250
1290
|
onKeyDown: keyDown,
|
|
1251
1291
|
...rest
|
|
1252
1292
|
};
|
|
1253
|
-
|
|
1293
|
+
const forwarded = rest.ref;
|
|
1294
|
+
const setRef = (el) => {
|
|
1295
|
+
inputRef.current = el;
|
|
1296
|
+
if (typeof forwarded === "function") forwarded(el);
|
|
1297
|
+
else if (forwarded) forwarded.current = el;
|
|
1298
|
+
};
|
|
1299
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
1254
1300
|
}
|
|
1255
1301
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
1256
|
-
function ParameterNumberInput({
|
|
1257
|
-
field,
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1302
|
+
function ParameterNumberInput(props) {
|
|
1303
|
+
const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
|
|
1304
|
+
const ctx = useParameterComponents();
|
|
1305
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
1306
|
+
const CustomInput = resolved.input;
|
|
1307
|
+
const plain = plainNumber(field, value);
|
|
1308
|
+
const handleCommit = (text, input) => {
|
|
1309
|
+
const n = (0, import_parameters.parseParameterNumberInput)(field, text);
|
|
1310
|
+
if (n === null || n === value) {
|
|
1311
|
+
if (input) input.value = plain;
|
|
1312
|
+
} else {
|
|
1313
|
+
onChange(n);
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
const handleKeyDown = (e) => {
|
|
1317
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
1318
|
+
e.preventDefault();
|
|
1319
|
+
const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
|
|
1320
|
+
onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
|
|
1321
|
+
};
|
|
1322
|
+
const inputProps = {
|
|
1323
|
+
id,
|
|
1324
|
+
inputMode: "decimal",
|
|
1325
|
+
"aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
|
|
1326
|
+
value: plain,
|
|
1327
|
+
disabled: disabled || field.readOnly,
|
|
1328
|
+
className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
|
|
1329
|
+
style: parameterInputStyle,
|
|
1330
|
+
onCommit: handleCommit,
|
|
1331
|
+
onKeyDown: handleKeyDown
|
|
1332
|
+
};
|
|
1333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
1334
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
1335
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
1288
1336
|
] });
|
|
1289
1337
|
}
|
|
1290
1338
|
function ParameterSlider(props) {
|
|
1291
|
-
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
1292
|
-
const
|
|
1339
|
+
const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
|
|
1340
|
+
const ctx = useParameterComponents();
|
|
1341
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
1342
|
+
const CustomSlider = resolved.slider;
|
|
1343
|
+
const dragging = (0, import_react8.useRef)(false);
|
|
1344
|
+
const start = () => {
|
|
1345
|
+
if (dragging.current) return;
|
|
1346
|
+
dragging.current = true;
|
|
1347
|
+
onGestureStart?.();
|
|
1348
|
+
};
|
|
1293
1349
|
const end = () => {
|
|
1294
1350
|
if (!dragging.current) return;
|
|
1295
1351
|
dragging.current = false;
|
|
1296
1352
|
onGestureEnd?.();
|
|
1297
1353
|
};
|
|
1298
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
1354
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterNumberInput, { ...props });
|
|
1299
1355
|
const step = (0, import_parameters.parameterStep)(field);
|
|
1300
|
-
|
|
1301
|
-
|
|
1356
|
+
const sliderProps = {
|
|
1357
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
1358
|
+
"aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
|
|
1359
|
+
// A `control: 'slider'` field may leave out a bound: the range input's own defaults.
|
|
1360
|
+
min: field.min ?? 0,
|
|
1361
|
+
max: field.max ?? 100,
|
|
1362
|
+
step,
|
|
1363
|
+
value,
|
|
1364
|
+
disabled: disabled || field.readOnly,
|
|
1365
|
+
className: rangeClass,
|
|
1366
|
+
style: parameterRangeStyle
|
|
1367
|
+
};
|
|
1368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1369
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1370
|
+
CustomSlider,
|
|
1371
|
+
{
|
|
1372
|
+
...sliderProps,
|
|
1373
|
+
id: props.id ? `${props.id}-slider` : void 0,
|
|
1374
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
1375
|
+
onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field, v)),
|
|
1376
|
+
onGestureStart: start,
|
|
1377
|
+
onGestureEnd: end
|
|
1378
|
+
}
|
|
1379
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1302
1380
|
"input",
|
|
1303
1381
|
{
|
|
1304
1382
|
type: "range",
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
min: field.min,
|
|
1308
|
-
max: field.max,
|
|
1309
|
-
step,
|
|
1310
|
-
value,
|
|
1311
|
-
disabled: disabled || field.readOnly,
|
|
1312
|
-
className: rangeClass,
|
|
1313
|
-
onPointerDown: () => {
|
|
1314
|
-
if (dragging.current) return;
|
|
1315
|
-
dragging.current = true;
|
|
1316
|
-
onGestureStart?.();
|
|
1317
|
-
},
|
|
1383
|
+
...sliderProps,
|
|
1384
|
+
onPointerDown: start,
|
|
1318
1385
|
onPointerUp: end,
|
|
1319
1386
|
onPointerCancel: end,
|
|
1320
1387
|
onBlur: end,
|
|
1321
1388
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
1322
1389
|
}
|
|
1323
1390
|
),
|
|
1324
|
-
/* @__PURE__ */ (0,
|
|
1391
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
1325
1392
|
] });
|
|
1326
1393
|
}
|
|
1327
1394
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
1328
|
-
return /* @__PURE__ */ (0,
|
|
1395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1329
1396
|
"button",
|
|
1330
1397
|
{
|
|
1331
1398
|
type: "button",
|
|
@@ -1336,7 +1403,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
1336
1403
|
disabled: disabled || field.readOnly,
|
|
1337
1404
|
onClick: () => onChange(!value),
|
|
1338
1405
|
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"}`,
|
|
1339
|
-
children: /* @__PURE__ */ (0,
|
|
1406
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1340
1407
|
"span",
|
|
1341
1408
|
{
|
|
1342
1409
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -1345,11 +1412,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
1345
1412
|
}
|
|
1346
1413
|
);
|
|
1347
1414
|
}
|
|
1348
|
-
function ParameterSelect(
|
|
1415
|
+
function ParameterSelect(props) {
|
|
1416
|
+
const { field, value, onChange, disabled, id, components } = props;
|
|
1417
|
+
const ctx = useParameterComponents();
|
|
1418
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
1419
|
+
const CustomSelect = resolved.select;
|
|
1349
1420
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
1350
1421
|
const off = disabled || field.readOnly;
|
|
1351
1422
|
if (field.control === "segmented") {
|
|
1352
|
-
return /* @__PURE__ */ (0,
|
|
1423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1353
1424
|
"button",
|
|
1354
1425
|
{
|
|
1355
1426
|
type: "button",
|
|
@@ -1364,8 +1435,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1364
1435
|
String(o.value)
|
|
1365
1436
|
)) });
|
|
1366
1437
|
}
|
|
1438
|
+
if (CustomSelect) {
|
|
1439
|
+
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
1440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1441
|
+
CustomSelect,
|
|
1442
|
+
{
|
|
1443
|
+
id,
|
|
1444
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
1445
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
1446
|
+
value,
|
|
1447
|
+
options: customOptions,
|
|
1448
|
+
disabled: off,
|
|
1449
|
+
className: parameterInputClass,
|
|
1450
|
+
style: parameterSelectStyle,
|
|
1451
|
+
onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
|
|
1452
|
+
}
|
|
1453
|
+
);
|
|
1454
|
+
}
|
|
1367
1455
|
const index = options.findIndex((o) => o.value === value);
|
|
1368
|
-
return /* @__PURE__ */ (0,
|
|
1456
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1369
1457
|
"select",
|
|
1370
1458
|
{
|
|
1371
1459
|
id,
|
|
@@ -1377,22 +1465,23 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1377
1465
|
if (option) onChange(option.value);
|
|
1378
1466
|
},
|
|
1379
1467
|
className: parameterInputClass,
|
|
1380
|
-
|
|
1468
|
+
style: parameterSelectStyle,
|
|
1469
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
1381
1470
|
}
|
|
1382
1471
|
);
|
|
1383
1472
|
}
|
|
1384
1473
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
1385
|
-
const [open, setOpen] = (0,
|
|
1386
|
-
const containerRef = (0,
|
|
1387
|
-
const buttonRef = (0,
|
|
1388
|
-
const popoverRef = (0,
|
|
1474
|
+
const [open, setOpen] = (0, import_react8.useState)(false);
|
|
1475
|
+
const containerRef = (0, import_react8.useRef)(null);
|
|
1476
|
+
const buttonRef = (0, import_react8.useRef)(null);
|
|
1477
|
+
const popoverRef = (0, import_react8.useRef)(null);
|
|
1389
1478
|
const alpha = !!field.alpha;
|
|
1390
1479
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
1391
1480
|
const rgb = hex.slice(0, 7);
|
|
1392
1481
|
const shown = alpha ? hex : rgb;
|
|
1393
1482
|
const off = disabled || field.readOnly;
|
|
1394
1483
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
1395
|
-
(0,
|
|
1484
|
+
(0, import_react8.useEffect)(() => {
|
|
1396
1485
|
if (!open) return;
|
|
1397
1486
|
const onPointerDown = (e) => {
|
|
1398
1487
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -1413,9 +1502,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1413
1502
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
1414
1503
|
};
|
|
1415
1504
|
}, [open]);
|
|
1416
|
-
return /* @__PURE__ */ (0,
|
|
1417
|
-
/* @__PURE__ */ (0,
|
|
1418
|
-
/* @__PURE__ */ (0,
|
|
1505
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
1506
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1507
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1419
1508
|
"button",
|
|
1420
1509
|
{
|
|
1421
1510
|
ref: buttonRef,
|
|
@@ -1426,10 +1515,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1426
1515
|
disabled: off,
|
|
1427
1516
|
onClick: () => setOpen((prev) => !prev),
|
|
1428
1517
|
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",
|
|
1429
|
-
children: /* @__PURE__ */ (0,
|
|
1518
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
1430
1519
|
}
|
|
1431
1520
|
),
|
|
1432
|
-
/* @__PURE__ */ (0,
|
|
1521
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1433
1522
|
ParameterCommitInput,
|
|
1434
1523
|
{
|
|
1435
1524
|
id,
|
|
@@ -1445,7 +1534,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1445
1534
|
}
|
|
1446
1535
|
)
|
|
1447
1536
|
] }),
|
|
1448
|
-
open && /* @__PURE__ */ (0,
|
|
1537
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1449
1538
|
"div",
|
|
1450
1539
|
{
|
|
1451
1540
|
ref: popoverRef,
|
|
@@ -1459,7 +1548,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1459
1548
|
},
|
|
1460
1549
|
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",
|
|
1461
1550
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
1462
|
-
children: /* @__PURE__ */ (0,
|
|
1551
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1463
1552
|
ColorPicker,
|
|
1464
1553
|
{
|
|
1465
1554
|
value: shown,
|
|
@@ -1475,13 +1564,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1475
1564
|
)
|
|
1476
1565
|
] });
|
|
1477
1566
|
}
|
|
1478
|
-
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
1567
|
+
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
1479
1568
|
const size = (0, import_parameters.vectorSize)(field);
|
|
1480
|
-
return /* @__PURE__ */ (0,
|
|
1569
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
1481
1570
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
1482
|
-
return /* @__PURE__ */ (0,
|
|
1483
|
-
/* @__PURE__ */ (0,
|
|
1484
|
-
/* @__PURE__ */ (0,
|
|
1571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
1572
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
1573
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1485
1574
|
ParameterNumberInput,
|
|
1486
1575
|
{
|
|
1487
1576
|
field: component,
|
|
@@ -1489,6 +1578,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
1489
1578
|
id: i === 0 ? id : void 0,
|
|
1490
1579
|
"aria-label": `${(0, import_parameters.parameterLabel)(field)} ${component.label}`,
|
|
1491
1580
|
disabled: disabled || field.readOnly,
|
|
1581
|
+
components,
|
|
1492
1582
|
onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
|
|
1493
1583
|
}
|
|
1494
1584
|
)
|
|
@@ -1498,11 +1588,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
1498
1588
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
1499
1589
|
const off = disabled || field.readOnly;
|
|
1500
1590
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
1501
|
-
return /* @__PURE__ */ (0,
|
|
1502
|
-
/* @__PURE__ */ (0,
|
|
1503
|
-
/* @__PURE__ */ (0,
|
|
1504
|
-
/* @__PURE__ */ (0,
|
|
1505
|
-
/* @__PURE__ */ (0,
|
|
1591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-1.5", children: [
|
|
1592
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1593
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.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_runtime6.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
1594
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
1595
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1506
1596
|
ParameterCommitInput,
|
|
1507
1597
|
{
|
|
1508
1598
|
id,
|
|
@@ -1513,30 +1603,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
1513
1603
|
onCommit: (text) => onChange(text.trim())
|
|
1514
1604
|
}
|
|
1515
1605
|
),
|
|
1516
|
-
/* @__PURE__ */ (0,
|
|
1517
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
1518
|
-
"
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
{
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1606
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex gap-1", children: [
|
|
1607
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1608
|
+
"label",
|
|
1609
|
+
{
|
|
1610
|
+
style: parameterButtonStyle,
|
|
1611
|
+
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
1612
|
+
children: [
|
|
1613
|
+
"Choose file\u2026",
|
|
1614
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1615
|
+
"input",
|
|
1616
|
+
{
|
|
1617
|
+
type: "file",
|
|
1618
|
+
className: "sr-only",
|
|
1619
|
+
accept: field.accept ?? "image/*",
|
|
1620
|
+
disabled: off,
|
|
1621
|
+
"aria-label": `${name} file`,
|
|
1622
|
+
onChange: async (e) => {
|
|
1623
|
+
const file = e.target.files?.[0];
|
|
1624
|
+
e.target.value = "";
|
|
1625
|
+
if (file) onChange(await resolveFile(file));
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
)
|
|
1629
|
+
]
|
|
1630
|
+
}
|
|
1631
|
+
),
|
|
1632
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1633
|
+
"button",
|
|
1634
|
+
{
|
|
1635
|
+
type: "button",
|
|
1636
|
+
style: parameterButtonStyle,
|
|
1637
|
+
className: parameterButtonClass,
|
|
1638
|
+
disabled: off,
|
|
1639
|
+
onClick: () => onChange(""),
|
|
1640
|
+
"aria-label": `Clear ${name}`,
|
|
1641
|
+
children: "Clear"
|
|
1642
|
+
}
|
|
1643
|
+
)
|
|
1536
1644
|
] })
|
|
1537
1645
|
] })
|
|
1538
1646
|
] }),
|
|
1539
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
1647
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1540
1648
|
"button",
|
|
1541
1649
|
{
|
|
1542
1650
|
type: "button",
|
|
@@ -1546,14 +1654,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
1546
1654
|
disabled: off,
|
|
1547
1655
|
onClick: () => onChange(o.url),
|
|
1548
1656
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
1549
|
-
children: /* @__PURE__ */ (0,
|
|
1657
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
1550
1658
|
},
|
|
1551
1659
|
o.url
|
|
1552
1660
|
)) })
|
|
1553
1661
|
] });
|
|
1554
1662
|
}
|
|
1555
1663
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
1556
|
-
return /* @__PURE__ */ (0,
|
|
1664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1557
1665
|
ParameterCommitInput,
|
|
1558
1666
|
{
|
|
1559
1667
|
id,
|
|
@@ -1572,24 +1680,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
1572
1680
|
switch (field.type) {
|
|
1573
1681
|
case "number":
|
|
1574
1682
|
case "int":
|
|
1575
|
-
return /* @__PURE__ */ (0,
|
|
1683
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
1576
1684
|
case "boolean":
|
|
1577
|
-
return /* @__PURE__ */ (0,
|
|
1685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
1578
1686
|
case "choice":
|
|
1579
|
-
return /* @__PURE__ */ (0,
|
|
1687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
1580
1688
|
case "color":
|
|
1581
|
-
return /* @__PURE__ */ (0,
|
|
1689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
1582
1690
|
case "vector":
|
|
1583
|
-
return /* @__PURE__ */ (0,
|
|
1691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
1584
1692
|
case "image":
|
|
1585
|
-
return /* @__PURE__ */ (0,
|
|
1693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
1586
1694
|
case "text":
|
|
1587
|
-
return /* @__PURE__ */ (0,
|
|
1695
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
1588
1696
|
}
|
|
1589
1697
|
}
|
|
1590
1698
|
|
|
1591
1699
|
// src/effects/EffectParameters.tsx
|
|
1592
|
-
var
|
|
1700
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1593
1701
|
function EffectParameters({
|
|
1594
1702
|
description,
|
|
1595
1703
|
values,
|
|
@@ -1601,56 +1709,75 @@ function EffectParameters({
|
|
|
1601
1709
|
renderControlAddon,
|
|
1602
1710
|
fonts,
|
|
1603
1711
|
disabled = false,
|
|
1604
|
-
className = ""
|
|
1712
|
+
className = "",
|
|
1713
|
+
components
|
|
1605
1714
|
}) {
|
|
1606
|
-
const fields = (0,
|
|
1607
|
-
const idBase = (0,
|
|
1608
|
-
const gesture =
|
|
1609
|
-
const count =
|
|
1610
|
-
|
|
1611
|
-
|
|
1715
|
+
const fields = (0, import_react9.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
1716
|
+
const idBase = (0, import_react9.useId)();
|
|
1717
|
+
const gesture = import_react9.default.useRef(null);
|
|
1718
|
+
const count = import_react9.default.useRef(0);
|
|
1719
|
+
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
1720
|
+
const handlePresetSelect = (name) => {
|
|
1721
|
+
if (!name) return;
|
|
1722
|
+
if (onPresetName) {
|
|
1723
|
+
onPresetName(name);
|
|
1724
|
+
} else if (onPreset) {
|
|
1725
|
+
const preset = description.presets.find((p) => p.name === name);
|
|
1726
|
+
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
1727
|
+
}
|
|
1728
|
+
};
|
|
1729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
1730
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1731
|
+
CustomPresetSelect,
|
|
1732
|
+
{
|
|
1733
|
+
"aria-label": `${description.name} presets`,
|
|
1734
|
+
label: `${description.name} presets`,
|
|
1735
|
+
value: "",
|
|
1736
|
+
disabled,
|
|
1737
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
1738
|
+
style: parameterSelectStyle,
|
|
1739
|
+
options: [
|
|
1740
|
+
{ value: "", label: "Presets\u2026" },
|
|
1741
|
+
...description.presets.map((p) => ({ value: p.name, label: p.name }))
|
|
1742
|
+
],
|
|
1743
|
+
onChange: (name) => handlePresetSelect(String(name))
|
|
1744
|
+
}
|
|
1745
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1612
1746
|
"select",
|
|
1613
1747
|
{
|
|
1614
|
-
className: "w-full rounded border border-border
|
|
1748
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
1749
|
+
style: parameterSelectStyle,
|
|
1615
1750
|
"aria-label": `${description.name} presets`,
|
|
1616
1751
|
value: "",
|
|
1617
1752
|
disabled,
|
|
1618
|
-
onChange: (e) =>
|
|
1619
|
-
const name = e.currentTarget.value;
|
|
1620
|
-
if (!name) return;
|
|
1621
|
-
if (onPresetName) {
|
|
1622
|
-
onPresetName(name);
|
|
1623
|
-
} else if (onPreset) {
|
|
1624
|
-
const preset = description.presets.find((p) => p.name === name);
|
|
1625
|
-
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
1626
|
-
}
|
|
1627
|
-
},
|
|
1753
|
+
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
1628
1754
|
children: [
|
|
1629
|
-
/* @__PURE__ */ (0,
|
|
1630
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
1755
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
1756
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
1631
1757
|
]
|
|
1632
1758
|
}
|
|
1633
|
-
),
|
|
1759
|
+
)),
|
|
1634
1760
|
fields.map((field) => {
|
|
1635
1761
|
const label = (0, import_parameters2.parameterLabel)(field);
|
|
1636
1762
|
const inputId = `${idBase}-${field.id}`;
|
|
1637
1763
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
1638
1764
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
1639
1765
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
1640
|
-
return /* @__PURE__ */ (0,
|
|
1641
|
-
/* @__PURE__ */ (0,
|
|
1642
|
-
/* @__PURE__ */ (0,
|
|
1643
|
-
keyed && /* @__PURE__ */ (0,
|
|
1766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
1767
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
1768
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
1769
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
1644
1770
|
renderControlAddon?.(field.id),
|
|
1645
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
1771
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
|
|
1646
1772
|
] }),
|
|
1647
|
-
/* @__PURE__ */ (0,
|
|
1773
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1648
1774
|
ParameterFieldControl,
|
|
1649
1775
|
{
|
|
1650
1776
|
field,
|
|
1651
1777
|
value,
|
|
1652
1778
|
id: inputId,
|
|
1653
1779
|
disabled: disabled || keyed,
|
|
1780
|
+
components,
|
|
1654
1781
|
onChange: (v) => onChange(field.id, v, gesture.current),
|
|
1655
1782
|
onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
|
|
1656
1783
|
onGestureEnd: () => gesture.current = null
|
|
@@ -1658,14 +1785,14 @@ function EffectParameters({
|
|
|
1658
1785
|
)
|
|
1659
1786
|
] }, field.id);
|
|
1660
1787
|
}),
|
|
1661
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
1788
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
1662
1789
|
] });
|
|
1663
1790
|
}
|
|
1664
1791
|
|
|
1665
1792
|
// src/effects/useEffectAuthoring.ts
|
|
1666
|
-
var
|
|
1793
|
+
var import_react10 = require("react");
|
|
1667
1794
|
function useEffectAuthoring(session) {
|
|
1668
|
-
return (0,
|
|
1795
|
+
return (0, import_react10.useSyncExternalStore)(
|
|
1669
1796
|
(callback) => {
|
|
1670
1797
|
if (!session) return () => {
|
|
1671
1798
|
};
|
|
@@ -1677,9 +1804,9 @@ function useEffectAuthoring(session) {
|
|
|
1677
1804
|
}
|
|
1678
1805
|
|
|
1679
1806
|
// src/effects/EffectAuthoringEditor.tsx
|
|
1680
|
-
var
|
|
1807
|
+
var import_react11 = require("react");
|
|
1681
1808
|
var import_effects4 = require("@pixerate/editor/effects");
|
|
1682
|
-
var
|
|
1809
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1683
1810
|
function EffectAuthoringEditor({
|
|
1684
1811
|
session,
|
|
1685
1812
|
showSource = true,
|
|
@@ -1688,21 +1815,21 @@ function EffectAuthoringEditor({
|
|
|
1688
1815
|
className = ""
|
|
1689
1816
|
}) {
|
|
1690
1817
|
const state = useEffectAuthoring(session);
|
|
1691
|
-
const canvasRef = (0,
|
|
1692
|
-
const rendererRef = (0,
|
|
1693
|
-
const [rendererReady, setRendererReady] = (0,
|
|
1694
|
-
const renderingRef = (0,
|
|
1695
|
-
const pendingRef = (0,
|
|
1696
|
-
const timeRef = (0,
|
|
1697
|
-
const inputsRef = (0,
|
|
1698
|
-
const [previewError, setPreviewError] = (0,
|
|
1699
|
-
const [savingPreset, setSavingPreset] = (0,
|
|
1700
|
-
const [presetName, setPresetName] = (0,
|
|
1701
|
-
const textareaRef = (0,
|
|
1702
|
-
const gutterRef = (0,
|
|
1703
|
-
const [sourceCode, setSourceCode] = (0,
|
|
1704
|
-
const sourceDebounceRef = (0,
|
|
1705
|
-
(0,
|
|
1818
|
+
const canvasRef = (0, import_react11.useRef)(null);
|
|
1819
|
+
const rendererRef = (0, import_react11.useRef)(null);
|
|
1820
|
+
const [rendererReady, setRendererReady] = (0, import_react11.useState)(0);
|
|
1821
|
+
const renderingRef = (0, import_react11.useRef)(false);
|
|
1822
|
+
const pendingRef = (0, import_react11.useRef)(false);
|
|
1823
|
+
const timeRef = (0, import_react11.useRef)(0);
|
|
1824
|
+
const inputsRef = (0, import_react11.useRef)({});
|
|
1825
|
+
const [previewError, setPreviewError] = (0, import_react11.useState)(null);
|
|
1826
|
+
const [savingPreset, setSavingPreset] = (0, import_react11.useState)(false);
|
|
1827
|
+
const [presetName, setPresetName] = (0, import_react11.useState)("");
|
|
1828
|
+
const textareaRef = (0, import_react11.useRef)(null);
|
|
1829
|
+
const gutterRef = (0, import_react11.useRef)(null);
|
|
1830
|
+
const [sourceCode, setSourceCode] = (0, import_react11.useState)("");
|
|
1831
|
+
const sourceDebounceRef = (0, import_react11.useRef)(null);
|
|
1832
|
+
(0, import_react11.useEffect)(() => {
|
|
1706
1833
|
const canvas = canvasRef.current;
|
|
1707
1834
|
canvas?.getContext("2d")?.clearRect(0, 0, canvas.width, canvas.height);
|
|
1708
1835
|
setPreviewError(null);
|
|
@@ -1736,7 +1863,7 @@ function EffectAuthoringEditor({
|
|
|
1736
1863
|
}
|
|
1737
1864
|
};
|
|
1738
1865
|
}, [session, previewSize.width, previewSize.height]);
|
|
1739
|
-
const pump = (0,
|
|
1866
|
+
const pump = (0, import_react11.useCallback)(async () => {
|
|
1740
1867
|
if (renderingRef.current) {
|
|
1741
1868
|
pendingRef.current = true;
|
|
1742
1869
|
return;
|
|
@@ -1767,26 +1894,26 @@ function EffectAuthoringEditor({
|
|
|
1767
1894
|
}
|
|
1768
1895
|
}, []);
|
|
1769
1896
|
const inputSpecs = state?.description.inputs;
|
|
1770
|
-
(0,
|
|
1897
|
+
(0, import_react11.useEffect)(() => {
|
|
1771
1898
|
inputsRef.current = inputSpecs ? (0, import_effects4.effectSampleInputs)({ inputs: inputSpecs }, previewSize) : {};
|
|
1772
1899
|
}, [inputSpecs, previewSize.width, previewSize.height]);
|
|
1773
|
-
(0,
|
|
1900
|
+
(0, import_react11.useEffect)(() => {
|
|
1774
1901
|
if (!state) return;
|
|
1775
1902
|
timeRef.current = state.time;
|
|
1776
1903
|
void pump();
|
|
1777
1904
|
}, [state, rendererReady, pump]);
|
|
1778
|
-
(0,
|
|
1905
|
+
(0, import_react11.useEffect)(() => {
|
|
1779
1906
|
if (state?.source !== null && state?.source !== void 0) {
|
|
1780
1907
|
setSourceCode(state.source);
|
|
1781
1908
|
}
|
|
1782
1909
|
}, [state?.source]);
|
|
1783
|
-
(0,
|
|
1910
|
+
(0, import_react11.useEffect)(() => {
|
|
1784
1911
|
return () => {
|
|
1785
1912
|
if (sourceDebounceRef.current) clearTimeout(sourceDebounceRef.current);
|
|
1786
1913
|
};
|
|
1787
1914
|
}, []);
|
|
1788
1915
|
if (!session || !state) {
|
|
1789
|
-
return /* @__PURE__ */ (0,
|
|
1916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `p-4 text-center text-xs text-muted-foreground ${className}`, children: "No effect authoring session is open." });
|
|
1790
1917
|
}
|
|
1791
1918
|
const hasSource = showSource && state.sourceLanguage !== null && typeof session.setSource === "function";
|
|
1792
1919
|
const handleSourceChange = (e) => {
|
|
@@ -1820,10 +1947,10 @@ function EffectAuthoringEditor({
|
|
|
1820
1947
|
const issueLines = new Set(
|
|
1821
1948
|
state.issues.map((i) => i.line).filter((l) => typeof l === "number")
|
|
1822
1949
|
);
|
|
1823
|
-
return /* @__PURE__ */ (0,
|
|
1824
|
-
/* @__PURE__ */ (0,
|
|
1825
|
-
/* @__PURE__ */ (0,
|
|
1826
|
-
/* @__PURE__ */ (0,
|
|
1950
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `space-y-4 rounded border border-border bg-background p-4 text-foreground ${className}`, "data-effect-authoring-editor": state.name, children: [
|
|
1951
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border pb-3", children: [
|
|
1952
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1953
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1827
1954
|
"button",
|
|
1828
1955
|
{
|
|
1829
1956
|
type: "button",
|
|
@@ -1833,15 +1960,15 @@ function EffectAuthoringEditor({
|
|
|
1833
1960
|
children: state.playing ? "Pause" : "Play"
|
|
1834
1961
|
}
|
|
1835
1962
|
),
|
|
1836
|
-
/* @__PURE__ */ (0,
|
|
1963
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "font-mono text-xs text-muted-foreground", "data-time-readout": true, children: [
|
|
1837
1964
|
state.time,
|
|
1838
1965
|
"ms / ",
|
|
1839
1966
|
state.duration,
|
|
1840
1967
|
"ms"
|
|
1841
1968
|
] })
|
|
1842
1969
|
] }),
|
|
1843
|
-
/* @__PURE__ */ (0,
|
|
1844
|
-
/* @__PURE__ */ (0,
|
|
1970
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1971
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1845
1972
|
"button",
|
|
1846
1973
|
{
|
|
1847
1974
|
type: "button",
|
|
@@ -1852,7 +1979,7 @@ function EffectAuthoringEditor({
|
|
|
1852
1979
|
children: "Undo"
|
|
1853
1980
|
}
|
|
1854
1981
|
),
|
|
1855
|
-
/* @__PURE__ */ (0,
|
|
1982
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1856
1983
|
"button",
|
|
1857
1984
|
{
|
|
1858
1985
|
type: "button",
|
|
@@ -1863,8 +1990,8 @@ function EffectAuthoringEditor({
|
|
|
1863
1990
|
children: "Redo"
|
|
1864
1991
|
}
|
|
1865
1992
|
),
|
|
1866
|
-
savingPreset ? /* @__PURE__ */ (0,
|
|
1867
|
-
/* @__PURE__ */ (0,
|
|
1993
|
+
savingPreset ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { onSubmit: handleSavePreset, className: "flex items-center gap-1", children: [
|
|
1994
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1868
1995
|
"input",
|
|
1869
1996
|
{
|
|
1870
1997
|
type: "text",
|
|
@@ -1875,7 +2002,7 @@ function EffectAuthoringEditor({
|
|
|
1875
2002
|
onChange: (e) => setPresetName(e.target.value)
|
|
1876
2003
|
}
|
|
1877
2004
|
),
|
|
1878
|
-
/* @__PURE__ */ (0,
|
|
2005
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1879
2006
|
"button",
|
|
1880
2007
|
{
|
|
1881
2008
|
type: "submit",
|
|
@@ -1883,7 +2010,7 @@ function EffectAuthoringEditor({
|
|
|
1883
2010
|
children: "Save"
|
|
1884
2011
|
}
|
|
1885
2012
|
),
|
|
1886
|
-
/* @__PURE__ */ (0,
|
|
2013
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1887
2014
|
"button",
|
|
1888
2015
|
{
|
|
1889
2016
|
type: "button",
|
|
@@ -1892,7 +2019,7 @@ function EffectAuthoringEditor({
|
|
|
1892
2019
|
children: "Cancel"
|
|
1893
2020
|
}
|
|
1894
2021
|
)
|
|
1895
|
-
] }) : /* @__PURE__ */ (0,
|
|
2022
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1896
2023
|
"button",
|
|
1897
2024
|
{
|
|
1898
2025
|
type: "button",
|
|
@@ -1903,11 +2030,11 @@ function EffectAuthoringEditor({
|
|
|
1903
2030
|
)
|
|
1904
2031
|
] })
|
|
1905
2032
|
] }),
|
|
1906
|
-
/* @__PURE__ */ (0,
|
|
1907
|
-
/* @__PURE__ */ (0,
|
|
1908
|
-
/* @__PURE__ */ (0,
|
|
1909
|
-
/* @__PURE__ */ (0,
|
|
1910
|
-
/* @__PURE__ */ (0,
|
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
|
|
2034
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-2", children: [
|
|
2035
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Preview" }),
|
|
2036
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative flex aspect-video w-full items-center justify-center overflow-hidden rounded border border-border bg-black", children: [
|
|
2037
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1911
2038
|
"canvas",
|
|
1912
2039
|
{
|
|
1913
2040
|
ref: canvasRef,
|
|
@@ -1917,9 +2044,9 @@ function EffectAuthoringEditor({
|
|
|
1917
2044
|
"aria-label": "Effect preview canvas"
|
|
1918
2045
|
}
|
|
1919
2046
|
),
|
|
1920
|
-
previewError && /* @__PURE__ */ (0,
|
|
2047
|
+
previewError && /* @__PURE__ */ (0, import_jsx_runtime8.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 })
|
|
1921
2048
|
] }),
|
|
1922
|
-
state.issues.length > 0 && /* @__PURE__ */ (0,
|
|
2049
|
+
state.issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.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_runtime8.jsxs)(
|
|
1923
2050
|
"div",
|
|
1924
2051
|
{
|
|
1925
2052
|
className: `cursor-pointer ${issue.severity === "error" ? "text-destructive" : "text-amber-500"}`,
|
|
@@ -1932,17 +2059,17 @@ function EffectAuthoringEditor({
|
|
|
1932
2059
|
idx
|
|
1933
2060
|
)) })
|
|
1934
2061
|
] }),
|
|
1935
|
-
hasSource && /* @__PURE__ */ (0,
|
|
1936
|
-
/* @__PURE__ */ (0,
|
|
2062
|
+
hasSource && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-2", "data-effect-source-pane": true, children: [
|
|
2063
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex items-center justify-between text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
|
|
1937
2064
|
"Source (",
|
|
1938
2065
|
state.sourceLanguage,
|
|
1939
2066
|
")"
|
|
1940
2067
|
] }) }),
|
|
1941
|
-
/* @__PURE__ */ (0,
|
|
1942
|
-
/* @__PURE__ */ (0,
|
|
2068
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex h-64 rounded border border-border bg-muted/20 font-mono text-xs", children: [
|
|
2069
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.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) => {
|
|
1943
2070
|
const lineNum = i + 1;
|
|
1944
2071
|
const hasIssue = issueLines.has(lineNum);
|
|
1945
|
-
return /* @__PURE__ */ (0,
|
|
2072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1946
2073
|
"div",
|
|
1947
2074
|
{
|
|
1948
2075
|
"data-gutter-line": lineNum,
|
|
@@ -1952,7 +2079,7 @@ function EffectAuthoringEditor({
|
|
|
1952
2079
|
i
|
|
1953
2080
|
);
|
|
1954
2081
|
}) }),
|
|
1955
|
-
/* @__PURE__ */ (0,
|
|
2082
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1956
2083
|
"textarea",
|
|
1957
2084
|
{
|
|
1958
2085
|
ref: textareaRef,
|
|
@@ -1970,9 +2097,9 @@ function EffectAuthoringEditor({
|
|
|
1970
2097
|
] })
|
|
1971
2098
|
] })
|
|
1972
2099
|
] }),
|
|
1973
|
-
/* @__PURE__ */ (0,
|
|
1974
|
-
/* @__PURE__ */ (0,
|
|
1975
|
-
/* @__PURE__ */ (0,
|
|
2100
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-2 border-t border-border pt-4", children: [
|
|
2101
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Parameters" }),
|
|
2102
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1976
2103
|
EffectParameters,
|
|
1977
2104
|
{
|
|
1978
2105
|
description: state.description,
|
|
@@ -1984,7 +2111,7 @@ function EffectAuthoringEditor({
|
|
|
1984
2111
|
const track = state.tracks[control];
|
|
1985
2112
|
const isAnimated = Boolean(track && track.length > 0);
|
|
1986
2113
|
const hasKeyframeAtPlayhead = isAnimated && track.some((kf) => kf.time === state.time);
|
|
1987
|
-
return /* @__PURE__ */ (0,
|
|
2114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1988
2115
|
"button",
|
|
1989
2116
|
{
|
|
1990
2117
|
type: "button",
|
|
@@ -2006,17 +2133,17 @@ function EffectAuthoringEditor({
|
|
|
2006
2133
|
}
|
|
2007
2134
|
)
|
|
2008
2135
|
] }),
|
|
2009
|
-
showTimeline && /* @__PURE__ */ (0,
|
|
2010
|
-
/* @__PURE__ */ (0,
|
|
2011
|
-
/* @__PURE__ */ (0,
|
|
2012
|
-
/* @__PURE__ */ (0,
|
|
2013
|
-
/* @__PURE__ */ (0,
|
|
2014
|
-
/* @__PURE__ */ (0,
|
|
2015
|
-
/* @__PURE__ */ (0,
|
|
2016
|
-
/* @__PURE__ */ (0,
|
|
2136
|
+
showTimeline && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-3 border-t border-border pt-4", "data-effect-timeline": true, children: [
|
|
2137
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-4", children: [
|
|
2138
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Timeline" }),
|
|
2139
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-3 text-xs", children: [
|
|
2140
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
2141
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: "Duration:" }),
|
|
2142
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DurationField, { duration: state.duration, onCommit: (duration) => session.setTiming({ duration }) }),
|
|
2143
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-muted-foreground", children: "ms" })
|
|
2017
2144
|
] }),
|
|
2018
|
-
/* @__PURE__ */ (0,
|
|
2019
|
-
/* @__PURE__ */ (0,
|
|
2145
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex items-center gap-1.5 cursor-pointer", children: [
|
|
2146
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2020
2147
|
"input",
|
|
2021
2148
|
{
|
|
2022
2149
|
type: "checkbox",
|
|
@@ -2025,11 +2152,11 @@ function EffectAuthoringEditor({
|
|
|
2025
2152
|
onChange: (e) => session.setTiming({ loop: e.target.checked })
|
|
2026
2153
|
}
|
|
2027
2154
|
),
|
|
2028
|
-
/* @__PURE__ */ (0,
|
|
2155
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: "Loop" })
|
|
2029
2156
|
] })
|
|
2030
2157
|
] })
|
|
2031
2158
|
] }),
|
|
2032
|
-
/* @__PURE__ */ (0,
|
|
2159
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "space-y-1", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2033
2160
|
"input",
|
|
2034
2161
|
{
|
|
2035
2162
|
type: "range",
|
|
@@ -2041,12 +2168,12 @@ function EffectAuthoringEditor({
|
|
|
2041
2168
|
className: "w-full cursor-pointer accent-primary"
|
|
2042
2169
|
}
|
|
2043
2170
|
) }),
|
|
2044
|
-
Object.entries(state.tracks).length > 0 && /* @__PURE__ */ (0,
|
|
2171
|
+
Object.entries(state.tracks).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "space-y-2 pt-1", children: Object.entries(state.tracks).map(([control, keyframes]) => {
|
|
2045
2172
|
if (!keyframes || keyframes.length === 0) return null;
|
|
2046
|
-
return /* @__PURE__ */ (0,
|
|
2047
|
-
/* @__PURE__ */ (0,
|
|
2048
|
-
/* @__PURE__ */ (0,
|
|
2049
|
-
/* @__PURE__ */ (0,
|
|
2173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-1", "data-track": control, children: [
|
|
2174
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
2175
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "font-medium", children: control }),
|
|
2176
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2050
2177
|
"button",
|
|
2051
2178
|
{
|
|
2052
2179
|
type: "button",
|
|
@@ -2057,12 +2184,12 @@ function EffectAuthoringEditor({
|
|
|
2057
2184
|
}
|
|
2058
2185
|
)
|
|
2059
2186
|
] }),
|
|
2060
|
-
/* @__PURE__ */ (0,
|
|
2187
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "relative h-4 w-full rounded bg-muted/40", children: keyframes.map((kf, i) => {
|
|
2061
2188
|
const leftPct = Math.max(
|
|
2062
2189
|
0,
|
|
2063
2190
|
Math.min(100, kf.time / (state.duration || 1) * 100)
|
|
2064
2191
|
);
|
|
2065
|
-
return /* @__PURE__ */ (0,
|
|
2192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2066
2193
|
"button",
|
|
2067
2194
|
{
|
|
2068
2195
|
type: "button",
|
|
@@ -2082,14 +2209,14 @@ function EffectAuthoringEditor({
|
|
|
2082
2209
|
] });
|
|
2083
2210
|
}
|
|
2084
2211
|
function DurationField({ duration, onCommit }) {
|
|
2085
|
-
const [draft, setDraft] = (0,
|
|
2086
|
-
(0,
|
|
2212
|
+
const [draft, setDraft] = (0, import_react11.useState)(String(duration));
|
|
2213
|
+
(0, import_react11.useEffect)(() => setDraft(String(duration)), [duration]);
|
|
2087
2214
|
const commit = () => {
|
|
2088
2215
|
const next = Number(draft);
|
|
2089
2216
|
if (Number.isFinite(next) && next >= 1 && next !== duration) onCommit(next);
|
|
2090
2217
|
else setDraft(String(duration));
|
|
2091
2218
|
};
|
|
2092
|
-
return /* @__PURE__ */ (0,
|
|
2219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2093
2220
|
"input",
|
|
2094
2221
|
{
|
|
2095
2222
|
type: "number",
|