@pixerate/editor-react 0.188.0 → 0.189.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@ export * from './StickerPanel.cjs';
12
12
  export * from './StickerPicker.cjs';
13
13
  export * from './StrokePanel.cjs';
14
14
  export * from './PathStrokePanel.cjs';
15
+ export * from './EvolutionPanel.cjs';
15
16
  export * from './PaintEditor.cjs';
16
17
  export { PaintSlider } from './shared.cjs';
17
18
  export * from './PaintGradientEditor.cjs';
@@ -12,6 +12,7 @@ export * from './StickerPanel.js';
12
12
  export * from './StickerPicker.js';
13
13
  export * from './StrokePanel.js';
14
14
  export * from './PathStrokePanel.js';
15
+ export * from './EvolutionPanel.js';
15
16
  export * from './PaintEditor.js';
16
17
  export { PaintSlider } from './shared.js';
17
18
  export * from './PaintGradientEditor.js';
@@ -1373,17 +1373,189 @@ var PathStrokePanel = ({ controller, className }) => {
1373
1373
  ] });
1374
1374
  };
1375
1375
 
1376
+ // src/paint-editor/EvolutionPanel.tsx
1377
+ import { useState as useState8, useSyncExternalStore as useSyncExternalStore3 } from "react";
1378
+ import {
1379
+ EVOLUTION_SLIDERS,
1380
+ exportProposalContactSheetPng,
1381
+ liveStrokeRefusal as liveStrokeRefusal2,
1382
+ normalizeMutationRates,
1383
+ paintProposalGhost as paintProposalGhost2,
1384
+ proposalGenomeStrokes
1385
+ } from "@pixerate/editor/paint-editor";
1386
+ import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1387
+ var EvolutionPanel = ({ controller, proposals, className }) => {
1388
+ const state = usePaintEditorState(controller);
1389
+ const store = proposals ?? controller.proposals;
1390
+ const proposalState = useSyncExternalStore3(store.subscribe, store.getState, store.getState);
1391
+ const [error, attempt] = useAttempt();
1392
+ const [selectedStrokes, setSelectedStrokes] = useState8([]);
1393
+ const [selectedProposals, setSelectedProposals] = useState8([]);
1394
+ const [count, setCount] = useState8(4);
1395
+ const [seed, setSeed] = useState8(1);
1396
+ const [mutation, setMutation] = useState8(() => normalizeMutationRates());
1397
+ const [contactSheetUrl, setContactSheetUrl] = useState8(null);
1398
+ const eligibleStrokes = state.document.strokes.filter((s) => !liveStrokeRefusal2(s.brush));
1399
+ const activeStrokeIds = selectedStrokes.filter((id) => eligibleStrokes.some((s) => s.id === id));
1400
+ const effectiveStrokeIds = activeStrokeIds.length > 0 ? activeStrokeIds : state.selectedStroke && eligibleStrokes.some((s) => s.id === state.selectedStroke) ? [state.selectedStroke] : eligibleStrokes.length > 0 ? [eligibleStrokes[eligibleStrokes.length - 1].id] : [];
1401
+ const variants = proposalState.proposals.filter((p) => proposalGenomeStrokes(p).length > 0);
1402
+ const activeProposalIds = selectedProposals.filter((id) => variants.some((v) => v.id === id));
1403
+ const toggleStroke = (id) => {
1404
+ setSelectedStrokes((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-15), id]);
1405
+ };
1406
+ const toggleProposal = (id) => {
1407
+ setSelectedProposals((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-1), id]);
1408
+ };
1409
+ return /* @__PURE__ */ jsxs12("div", { className: `${panel} ${className ?? ""}`, "data-testid": "evolution-panel", children: [
1410
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between", children: [
1411
+ /* @__PURE__ */ jsxs12("span", { className: "font-medium text-slate-300", children: [
1412
+ "Evolution (",
1413
+ eligibleStrokes.length,
1414
+ ")"
1415
+ ] }),
1416
+ /* @__PURE__ */ jsx13("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1 text-[11px] text-slate-400", children: [
1417
+ /* @__PURE__ */ jsx13("span", { children: "Count" }),
1418
+ /* @__PURE__ */ jsx13(
1419
+ "input",
1420
+ {
1421
+ type: "number",
1422
+ "aria-label": "Variant count",
1423
+ min: 2,
1424
+ max: 12,
1425
+ value: count,
1426
+ onChange: (e) => setCount(Math.max(2, Math.min(12, Number(e.target.value) || 4))),
1427
+ className: "w-11 rounded bg-slate-800 px-1 py-0.5 text-right font-mono text-slate-200"
1428
+ }
1429
+ )
1430
+ ] }) })
1431
+ ] }),
1432
+ eligibleStrokes.length > 0 && /* @__PURE__ */ jsx13("div", { className: "flex max-h-20 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Parent strokes", children: eligibleStrokes.map((s, i) => {
1433
+ const on = effectiveStrokeIds.includes(s.id);
1434
+ return /* @__PURE__ */ jsx13(
1435
+ "button",
1436
+ {
1437
+ type: "button",
1438
+ role: "option",
1439
+ "aria-selected": on,
1440
+ title: `${i + 1}. ${s.brush.name} (${s.id})`,
1441
+ className: `h-5 w-5 rounded ring-1 ${on ? "ring-indigo-400" : "ring-slate-700"}`,
1442
+ style: { background: s.color },
1443
+ onClick: () => toggleStroke(s.id)
1444
+ },
1445
+ s.id
1446
+ );
1447
+ }) }),
1448
+ EVOLUTION_SLIDERS.map((c) => {
1449
+ const key = c.path;
1450
+ return /* @__PURE__ */ jsx13(
1451
+ PaintSlider,
1452
+ {
1453
+ control: c,
1454
+ value: mutation[key],
1455
+ onChange: (v) => setMutation((prev) => ({ ...prev, [key]: v }))
1456
+ },
1457
+ c.path
1458
+ );
1459
+ }),
1460
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap gap-1", children: [
1461
+ /* @__PURE__ */ jsx13(
1462
+ "button",
1463
+ {
1464
+ type: "button",
1465
+ className: button,
1466
+ disabled: effectiveStrokeIds.length === 0 || state.stroking,
1467
+ onClick: () => attempt(() => {
1468
+ controller.breedStrokes({ strokeIds: effectiveStrokeIds, count, mutation, seed });
1469
+ setSeed((s) => s + 1);
1470
+ }),
1471
+ children: "Breed strokes"
1472
+ }
1473
+ ),
1474
+ activeProposalIds.length === 2 && /* @__PURE__ */ jsx13(
1475
+ "button",
1476
+ {
1477
+ type: "button",
1478
+ className: button,
1479
+ disabled: state.stroking,
1480
+ onClick: () => attempt(() => {
1481
+ controller.breedProposal({ proposalIds: activeProposalIds, count, mutation, seed });
1482
+ setSeed((s) => s + 1);
1483
+ }),
1484
+ children: "Cross over (2)"
1485
+ }
1486
+ ),
1487
+ variants.length > 0 && /* @__PURE__ */ jsx13(
1488
+ "button",
1489
+ {
1490
+ type: "button",
1491
+ className: button,
1492
+ onClick: () => attempt(() => {
1493
+ const sheet = exportProposalContactSheetPng(controller, variants);
1494
+ setContactSheetUrl(`data:image/png;base64,${sheet.base64}`);
1495
+ }),
1496
+ children: "Contact sheet"
1497
+ }
1498
+ )
1499
+ ] }),
1500
+ variants.length > 0 && /* @__PURE__ */ jsx13("div", { className: "grid grid-cols-2 gap-1.5", "data-testid": "evolution-grid", children: variants.map((p) => {
1501
+ const g = paintProposalGhost2(p);
1502
+ const picked = activeProposalIds.includes(p.id);
1503
+ return /* @__PURE__ */ jsxs12(
1504
+ "div",
1505
+ {
1506
+ "data-testid": `evolution-variant-${p.id}`,
1507
+ className: `flex flex-col gap-1 rounded border p-1.5 ${picked ? "border-indigo-500 bg-slate-800/90" : "border-slate-800 bg-slate-950/60"}`,
1508
+ children: [
1509
+ /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsx13(
1510
+ "button",
1511
+ {
1512
+ type: "button",
1513
+ "aria-pressed": picked,
1514
+ className: chip(picked),
1515
+ onClick: () => toggleProposal(p.id),
1516
+ children: p.title
1517
+ }
1518
+ ) }),
1519
+ g && /* @__PURE__ */ jsx13("div", { className: "flex h-16 items-center justify-center overflow-hidden rounded bg-slate-900/80 p-1", children: /* @__PURE__ */ jsx13(PixelCanvas, { pixels: g, label: p.title, className: "max-h-full max-w-full object-contain" }) }),
1520
+ p.rationale && /* @__PURE__ */ jsx13("span", { className: "line-clamp-2 text-[10px] text-slate-400", title: p.rationale, children: p.rationale }),
1521
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap gap-1", children: [
1522
+ /* @__PURE__ */ jsx13(
1523
+ "button",
1524
+ {
1525
+ type: "button",
1526
+ className: button,
1527
+ disabled: state.stroking,
1528
+ onClick: () => attempt(() => {
1529
+ controller.breedProposal({ proposalIds: [p.id], count, mutation, seed });
1530
+ setSeed((s) => s + 1);
1531
+ }),
1532
+ children: "Breed from"
1533
+ }
1534
+ ),
1535
+ /* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => store.accept(p.id)), children: "Accept" }),
1536
+ /* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => store.reject(p.id)), children: "Dismiss" })
1537
+ ] })
1538
+ ]
1539
+ },
1540
+ p.id
1541
+ );
1542
+ }) }),
1543
+ contactSheetUrl && /* @__PURE__ */ jsx13("img", { src: contactSheetUrl, alt: "Variant contact sheet", className: "w-full rounded border border-slate-800", "data-testid": "evolution-contact-sheet" }),
1544
+ /* @__PURE__ */ jsx13(ErrorLine, { error })
1545
+ ] });
1546
+ };
1547
+
1376
1548
  // src/paint-editor/PaintEditor.tsx
1377
- import { useRef as useRef7, useState as useState9 } from "react";
1549
+ import { useRef as useRef7, useState as useState10 } from "react";
1378
1550
  import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
1379
1551
 
1380
1552
  // src/paint-editor/PaintEffectsPanel.tsx
1381
- import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState8 } from "react";
1553
+ import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState9 } from "react";
1382
1554
  import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
1383
1555
  import { pathControlsOf } from "@pixerate/editor/effects";
1384
- import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1556
+ import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
1385
1557
  function usePaintEffectsProvider(controller) {
1386
- const [provider, setProvider] = useState8(controller.effectsProvider);
1558
+ const [provider, setProvider] = useState9(controller.effectsProvider);
1387
1559
  useEffect4(() => {
1388
1560
  setProvider(controller.effectsProvider);
1389
1561
  return controller.effects.subscribe(setProvider);
@@ -1400,19 +1572,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
1400
1572
  function Controls({ provider, effect, name, values, apply }) {
1401
1573
  const { description, error } = useEffectDescription(provider, effect);
1402
1574
  const drags = useRef6(/* @__PURE__ */ new Set());
1403
- if (!provider) return /* @__PURE__ */ jsxs12("p", { className: "text-[11px] text-slate-400", children: [
1575
+ if (!provider) return /* @__PURE__ */ jsxs13("p", { className: "text-[11px] text-slate-400", children: [
1404
1576
  'No effects provider: "',
1405
1577
  name ?? effect,
1406
1578
  '" is kept as it was drawn.'
1407
1579
  ] });
1408
- if (error) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-amber-400", children: error });
1409
- if (!description) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
1580
+ if (error) return /* @__PURE__ */ jsx14("p", { className: "text-[11px] text-amber-400", children: error });
1581
+ if (!description) return /* @__PURE__ */ jsx14("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
1410
1582
  const commit = (gesture) => {
1411
1583
  if (!gesture || drags.current.has(gesture)) return !gesture;
1412
1584
  drags.current.add(gesture);
1413
1585
  return true;
1414
1586
  };
1415
- return /* @__PURE__ */ jsx13(
1587
+ return /* @__PURE__ */ jsx14(
1416
1588
  EffectParameters,
1417
1589
  {
1418
1590
  description,
@@ -1434,8 +1606,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
1434
1606
  const state = usePaintEditorState(controller);
1435
1607
  const provider = usePaintEffectsProvider(controller);
1436
1608
  const [error, attempt] = useAttempt();
1437
- const [browse, setBrowse] = useState8(null);
1438
- const [busy, setBusy] = useState8(false);
1609
+ const [browse, setBrowse] = useState9(null);
1610
+ const [busy, setBusy] = useState9(false);
1439
1611
  const paper = controller.getPaperEffect();
1440
1612
  const activeId = state.document.activeLayerId;
1441
1613
  const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
@@ -1465,28 +1637,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
1465
1637
  };
1466
1638
  const toggle = (b) => setBrowse(browse === b ? null : b);
1467
1639
  const pixel = active?.type === "pixel";
1468
- return /* @__PURE__ */ jsxs12("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
1469
- /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-1", children: [
1470
- /* @__PURE__ */ jsx13("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
1471
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
1472
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
1473
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
1474
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" }),
1475
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
1640
+ return /* @__PURE__ */ jsxs13("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
1641
+ /* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-1", children: [
1642
+ /* @__PURE__ */ jsx14("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
1643
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
1644
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
1645
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
1646
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" }),
1647
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
1476
1648
  ] }),
1477
- !provider && /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
1478
- browse && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
1479
- paper && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
1480
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
1481
- /* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
1649
+ !provider && /* @__PURE__ */ jsx14("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
1650
+ browse && /* @__PURE__ */ jsx14(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
1651
+ paper && /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
1652
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1", children: [
1653
+ /* @__PURE__ */ jsxs13("span", { className: "flex-1 truncate", children: [
1482
1654
  "Paper: ",
1483
1655
  paper.name ?? paper.effect
1484
1656
  ] }),
1485
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
1657
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
1486
1658
  ] }),
1487
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
1488
- /* @__PURE__ */ jsx13("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
1489
- /* @__PURE__ */ jsx13(
1659
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", children: [
1660
+ /* @__PURE__ */ jsx14("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
1661
+ /* @__PURE__ */ jsx14(
1490
1662
  "input",
1491
1663
  {
1492
1664
  type: "range",
@@ -1508,43 +1680,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
1508
1680
  `o${paper.opacity}`
1509
1681
  )
1510
1682
  ] }),
1511
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
1512
- /* @__PURE__ */ jsx13("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
1513
- /* @__PURE__ */ jsx13("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
1683
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", children: [
1684
+ /* @__PURE__ */ jsx14("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
1685
+ /* @__PURE__ */ jsx14("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
1514
1686
  const blend = e.currentTarget.value;
1515
1687
  run(() => controller.updatePaperEffect({ blend }));
1516
- }, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx13("option", { value: b, children: b }, b)) })
1688
+ }, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx14("option", { value: b, children: b }, b)) })
1517
1689
  ] }),
1518
- /* @__PURE__ */ jsx13(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
1690
+ /* @__PURE__ */ jsx14(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
1519
1691
  ] }),
1520
- effectPaint && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
1521
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
1522
- thumbnail ? /* @__PURE__ */ jsx13("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
1523
- /* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
1692
+ effectPaint && /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
1693
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1", children: [
1694
+ thumbnail ? /* @__PURE__ */ jsx14("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
1695
+ /* @__PURE__ */ jsxs13("span", { className: "flex-1 truncate", children: [
1524
1696
  "Paint: ",
1525
1697
  effectPaint.effect,
1526
1698
  state.effectPaintRendering ? " (rendering\u2026)" : ""
1527
1699
  ] }),
1528
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
1700
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
1529
1701
  ] }),
1530
- /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
1531
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
1532
- /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: effectPaint.map?.by === "stroke", onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
1702
+ /* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
1703
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
1704
+ /* @__PURE__ */ jsx14("input", { type: "checkbox", checked: effectPaint.map?.by === "stroke", onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
1533
1705
  "Along the stroke"
1534
1706
  ] }),
1535
- hasPathControl && /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Pass each stroke's centreline to the effect's own path control", children: [
1536
- /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: effectPaint.map?.by === "path", onChange: (e) => repaint({ map: e.target.checked ? { by: "path" } : { by: "canvas" } }) }),
1707
+ hasPathControl && /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", title: "Pass each stroke's centreline to the effect's own path control", children: [
1708
+ /* @__PURE__ */ jsx14("input", { type: "checkbox", checked: effectPaint.map?.by === "path", onChange: (e) => repaint({ map: e.target.checked ? { by: "path" } : { by: "canvas" } }) }),
1537
1709
  "Along the stroke (native)"
1538
1710
  ] }),
1539
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
1540
- /* @__PURE__ */ jsx13("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
1711
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
1712
+ /* @__PURE__ */ jsx14("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
1541
1713
  "Live"
1542
1714
  ] })
1543
1715
  ] }),
1544
- effectPaint.map?.by === "stroke" && /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", children: [
1545
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
1546
- /* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Length" }),
1547
- /* @__PURE__ */ jsx13(
1716
+ effectPaint.map?.by === "stroke" && /* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-2", children: [
1717
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", children: [
1718
+ /* @__PURE__ */ jsx14("span", { className: "text-slate-400", children: "Length" }),
1719
+ /* @__PURE__ */ jsx14(
1548
1720
  "input",
1549
1721
  {
1550
1722
  type: "number",
@@ -1558,56 +1730,56 @@ var PaintEffectsPanel = ({ controller, className }) => {
1558
1730
  effectPaint.map.length
1559
1731
  )
1560
1732
  ] }),
1561
- /* @__PURE__ */ jsxs12("select", { "aria-label": "Effect repeat", value: effectPaint.map.repeat, onChange: (e) => repaint({ map: { ...effectPaint.map, repeat: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: [
1562
- /* @__PURE__ */ jsx13("option", { value: "repeat", children: "Repeat" }),
1563
- /* @__PURE__ */ jsx13("option", { value: "mirror", children: "Mirror" }),
1564
- /* @__PURE__ */ jsx13("option", { value: "clamp", children: "Clamp" })
1733
+ /* @__PURE__ */ jsxs13("select", { "aria-label": "Effect repeat", value: effectPaint.map.repeat, onChange: (e) => repaint({ map: { ...effectPaint.map, repeat: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: [
1734
+ /* @__PURE__ */ jsx14("option", { value: "repeat", children: "Repeat" }),
1735
+ /* @__PURE__ */ jsx14("option", { value: "mirror", children: "Mirror" }),
1736
+ /* @__PURE__ */ jsx14("option", { value: "clamp", children: "Clamp" })
1565
1737
  ] })
1566
1738
  ] }),
1567
- /* @__PURE__ */ jsx13(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
1739
+ /* @__PURE__ */ jsx14(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
1568
1740
  ] }),
1569
- animation && /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
1570
- /* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
1741
+ animation && /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
1742
+ /* @__PURE__ */ jsxs13("span", { className: "flex-1 truncate", children: [
1571
1743
  "Live paint: ",
1572
1744
  animation.strokes,
1573
1745
  " ",
1574
1746
  animation.strokes === 1 ? "stroke" : "strokes"
1575
1747
  ] }),
1576
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
1577
- /* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
1578
- /* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "fps" }),
1579
- /* @__PURE__ */ jsx13("input", { type: "number", "aria-label": "Live paint frame rate", min: 1, max: 60, value: playback.fps, onChange: (e) => attempt(() => controller.setEffectPlayback({ fps: Math.round(Number(e.target.value)) })), className: "w-12 rounded bg-slate-800 px-1 py-0.5" })
1748
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
1749
+ /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1", children: [
1750
+ /* @__PURE__ */ jsx14("span", { className: "text-slate-400", children: "fps" }),
1751
+ /* @__PURE__ */ jsx14("input", { type: "number", "aria-label": "Live paint frame rate", min: 1, max: 60, value: playback.fps, onChange: (e) => attempt(() => controller.setEffectPlayback({ fps: Math.round(Number(e.target.value)) })), className: "w-12 rounded bg-slate-800 px-1 py-0.5" })
1580
1752
  ] })
1581
1753
  ] }),
1582
- layerEffect && activeId && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
1583
- /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
1584
- /* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
1754
+ layerEffect && activeId && /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
1755
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1", children: [
1756
+ /* @__PURE__ */ jsxs13("span", { className: "flex-1 truncate", children: [
1585
1757
  "Layer: ",
1586
1758
  layerEffect.name ?? layerEffect.effect
1587
1759
  ] }),
1588
- /* @__PURE__ */ jsx13("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
1760
+ /* @__PURE__ */ jsx14("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
1589
1761
  ] }),
1590
- /* @__PURE__ */ jsx13(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
1762
+ /* @__PURE__ */ jsx14(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
1591
1763
  ] }),
1592
- /* @__PURE__ */ jsx13(ErrorLine, { error })
1764
+ /* @__PURE__ */ jsx14(ErrorLine, { error })
1593
1765
  ] });
1594
1766
  };
1595
1767
 
1596
1768
  // src/paint-editor/PaintEditor.tsx
1597
- import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
1769
+ import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
1598
1770
  var PAINT_CONTROLS = {
1599
1771
  "mixing-pad": '[data-testid="mixing-pad"]',
1600
1772
  lighting: '[data-testid="light-panel"]',
1601
1773
  symmetry: '[aria-label="Symmetry"]'
1602
1774
  };
1603
1775
  var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
1604
- const [tool, setTool] = useState9("brush");
1605
- const [fillOptions, setFillOptions] = useState9({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
1606
- const [tab, setTab] = useState9("color");
1776
+ const [tool, setTool] = useState10("brush");
1777
+ const [fillOptions, setFillOptions] = useState10({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
1778
+ const [tab, setTab] = useState10("color");
1607
1779
  const tabRef = useRef7(tab);
1608
1780
  tabRef.current = tab;
1609
1781
  const rootRef = useRef7(null);
1610
- const [ownPresence] = useState9(() => new PaintPresence2());
1782
+ const [ownPresence] = useState10(() => new PaintPresence2());
1611
1783
  const ambientPlayback = useAgentPlayback();
1612
1784
  const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
1613
1785
  const viewBox = () => {
@@ -1663,29 +1835,30 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
1663
1835
  const box = rootRef.current?.getBoundingClientRect();
1664
1836
  return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
1665
1837
  };
1666
- const [error, setError] = useState9(null);
1838
+ const [error, setError] = useState10(null);
1667
1839
  const effects = usePaintEffectsProvider(controller);
1668
1840
  const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
1669
- return /* @__PURE__ */ jsxs13("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
1670
- playing && /* @__PURE__ */ jsx14(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
1671
- /* @__PURE__ */ jsx14(PaintToolbar, { controller, tool, onToolChange: setTool, fillOptions, onFillOptionsChange: setFillOptions, fileName }),
1672
- /* @__PURE__ */ jsxs13("div", { className: "flex min-h-0 flex-1 gap-2", children: [
1673
- /* @__PURE__ */ jsx14(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
1674
- /* @__PURE__ */ jsxs13("div", { className: "flex min-w-0 flex-1 flex-col", children: [
1675
- /* @__PURE__ */ jsx14(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
1676
- error && /* @__PURE__ */ jsx14("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
1841
+ return /* @__PURE__ */ jsxs14("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
1842
+ playing && /* @__PURE__ */ jsx15(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
1843
+ /* @__PURE__ */ jsx15(PaintToolbar, { controller, tool, onToolChange: setTool, fillOptions, onFillOptionsChange: setFillOptions, fileName }),
1844
+ /* @__PURE__ */ jsxs14("div", { className: "flex min-h-0 flex-1 gap-2", children: [
1845
+ /* @__PURE__ */ jsx15(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
1846
+ /* @__PURE__ */ jsxs14("div", { className: "flex min-w-0 flex-1 flex-col", children: [
1847
+ /* @__PURE__ */ jsx15(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
1848
+ error && /* @__PURE__ */ jsx15("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
1677
1849
  ] }),
1678
- /* @__PURE__ */ jsxs13("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
1679
- /* @__PURE__ */ jsx14("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx14("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
1680
- /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
1681
- tab === "color" && /* @__PURE__ */ jsx14(ColorPanel, { controller }),
1682
- tab === "wet" && /* @__PURE__ */ jsx14(WetPanel, { controller }),
1683
- tab === "paper" && /* @__PURE__ */ jsx14(PaperPanel, { controller }),
1684
- tab === "layers" && /* @__PURE__ */ jsx14(PaintLayersPanel, { controller }),
1685
- tab === "layers" && /* @__PURE__ */ jsx14(StrokePanel, { controller }),
1686
- tab === "layers" && /* @__PURE__ */ jsx14(PathStrokePanel, { controller }),
1687
- tab === "layers" && /* @__PURE__ */ jsx14(StickerPanel, { controller }),
1688
- tab === "effects" && effects && /* @__PURE__ */ jsx14(PaintEffectsPanel, { controller })
1850
+ /* @__PURE__ */ jsxs14("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
1851
+ /* @__PURE__ */ jsx15("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx15("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
1852
+ /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
1853
+ tab === "color" && /* @__PURE__ */ jsx15(ColorPanel, { controller }),
1854
+ tab === "wet" && /* @__PURE__ */ jsx15(WetPanel, { controller }),
1855
+ tab === "paper" && /* @__PURE__ */ jsx15(PaperPanel, { controller }),
1856
+ tab === "layers" && /* @__PURE__ */ jsx15(PaintLayersPanel, { controller }),
1857
+ tab === "layers" && /* @__PURE__ */ jsx15(StrokePanel, { controller }),
1858
+ tab === "layers" && /* @__PURE__ */ jsx15(PathStrokePanel, { controller }),
1859
+ tab === "layers" && /* @__PURE__ */ jsx15(EvolutionPanel, { controller, proposals }),
1860
+ tab === "layers" && /* @__PURE__ */ jsx15(StickerPanel, { controller }),
1861
+ tab === "effects" && effects && /* @__PURE__ */ jsx15(PaintEffectsPanel, { controller })
1689
1862
  ] })
1690
1863
  ] })
1691
1864
  ] })
@@ -1696,6 +1869,7 @@ export {
1696
1869
  BrushLibraryBrowser,
1697
1870
  BrushPanel,
1698
1871
  ColorPanel,
1872
+ EvolutionPanel,
1699
1873
  PaintCanvas,
1700
1874
  PaintEditor,
1701
1875
  PaintEffectsPanel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.188.0",
3
+ "version": "0.189.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -283,7 +283,7 @@
283
283
  "dependencies": {},
284
284
  "peerDependencies": {
285
285
  "@dagrejs/dagre": "^1.1.8",
286
- "@pixerate/editor": ">=0.273.0 <1.0.0-0",
286
+ "@pixerate/editor": ">=0.274.0 <1.0.0-0",
287
287
  "@tiptap/core": "^2.27.3",
288
288
  "@tiptap/extension-bubble-menu": "^2.27.3",
289
289
  "@tiptap/extension-placeholder": "^2.27.3",
@@ -334,7 +334,7 @@
334
334
  "tsup": "^9.0.0",
335
335
  "typescript": "^5.7.3",
336
336
  "vitest": "^5.0.5",
337
- "@pixerate/editor": "0.273.0"
337
+ "@pixerate/editor": "0.274.0"
338
338
  },
339
339
  "scripts": {
340
340
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",