@pixerate/editor-react 0.189.0 → 0.191.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/paint-editor/PaintCanvas.d.cts +2 -0
- package/dist/paint-editor/PaintCanvas.d.ts +2 -0
- package/dist/paint-editor/PaintEditor.d.cts +2 -0
- package/dist/paint-editor/PaintEditor.d.ts +2 -0
- package/dist/paint-editor/index.cjs +109 -13
- package/dist/paint-editor/index.js +143 -47
- package/dist/paint-editor/usePaintEditor.d.cts +15 -1
- package/dist/paint-editor/usePaintEditor.d.ts +15 -1
- package/package.json +3 -3
|
@@ -18,6 +18,8 @@ export interface PaintCanvasProps {
|
|
|
18
18
|
proposals?: PaintProposals;
|
|
19
19
|
/** Strokes an agent is painting live alongside the user's, drawn as soft lines (see `createPaintAgentStrokes`). */
|
|
20
20
|
agentStrokes?: PaintAgentStrokes;
|
|
21
|
+
/** Follow device orientation (gyroscope tilt on iPhone and iPad) for thin-film iridescence view tilt. */
|
|
22
|
+
deviceTilt?: boolean;
|
|
21
23
|
className?: string;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
@@ -18,6 +18,8 @@ export interface PaintCanvasProps {
|
|
|
18
18
|
proposals?: PaintProposals;
|
|
19
19
|
/** Strokes an agent is painting live alongside the user's, drawn as soft lines (see `createPaintAgentStrokes`). */
|
|
20
20
|
agentStrokes?: PaintAgentStrokes;
|
|
21
|
+
/** Follow device orientation (gyroscope tilt on iPhone and iPad) for thin-film iridescence view tilt. */
|
|
22
|
+
deviceTilt?: boolean;
|
|
21
23
|
className?: string;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
@@ -13,6 +13,8 @@ export interface PaintEditorProps {
|
|
|
13
13
|
proposals?: PaintProposals;
|
|
14
14
|
/** Strokes an agent is painting live alongside the user's (see `createPaintAgentStrokes`). */
|
|
15
15
|
agentStrokes?: PaintAgentStrokes;
|
|
16
|
+
/** Follow device orientation (gyroscope tilt on iPhone and iPad) for thin-film iridescence view tilt. */
|
|
17
|
+
deviceTilt?: boolean;
|
|
16
18
|
className?: string;
|
|
17
19
|
/**
|
|
18
20
|
* Agent playback: act out the paint tools' calls here with the agent's cursor, opening the panel
|
|
@@ -13,6 +13,8 @@ export interface PaintEditorProps {
|
|
|
13
13
|
proposals?: PaintProposals;
|
|
14
14
|
/** Strokes an agent is painting live alongside the user's (see `createPaintAgentStrokes`). */
|
|
15
15
|
agentStrokes?: PaintAgentStrokes;
|
|
16
|
+
/** Follow device orientation (gyroscope tilt on iPhone and iPad) for thin-film iridescence view tilt. */
|
|
17
|
+
deviceTilt?: boolean;
|
|
16
18
|
className?: string;
|
|
17
19
|
/**
|
|
18
20
|
* Agent playback: act out the paint tools' calls here with the agent's cursor, opening the panel
|
|
@@ -51,6 +51,7 @@ __export(paint_editor_exports, {
|
|
|
51
51
|
StickerPicker: () => StickerPicker,
|
|
52
52
|
StrokePanel: () => StrokePanel,
|
|
53
53
|
WetPanel: () => WetPanel,
|
|
54
|
+
useMutationRequests: () => useMutationRequests,
|
|
54
55
|
usePaintChangeFeed: () => usePaintChangeFeed,
|
|
55
56
|
usePaintDirector: () => usePaintDirector,
|
|
56
57
|
usePaintEditor: () => usePaintEditor,
|
|
@@ -83,8 +84,30 @@ function usePaintDirector(controller, options = {}) {
|
|
|
83
84
|
const presence = new import_paint_editor.PaintPresence();
|
|
84
85
|
return { presence, director: new import_paint_editor.PaintDirector(controller, presence, options) };
|
|
85
86
|
});
|
|
87
|
+
(0, import_react.useEffect)(() => {
|
|
88
|
+
controller.setMutationDirector(value.director);
|
|
89
|
+
return () => controller.setMutationDirector(null);
|
|
90
|
+
}, [controller, value.director]);
|
|
86
91
|
return value;
|
|
87
92
|
}
|
|
93
|
+
function useMutationRequests(controller, onRequest) {
|
|
94
|
+
const state = usePaintEditorState(controller);
|
|
95
|
+
const cbRef = (0, import_react.useRef)(onRequest);
|
|
96
|
+
cbRef.current = onRequest;
|
|
97
|
+
const [last, setLast] = (0, import_react.useState)(null);
|
|
98
|
+
(0, import_react.useEffect)(() => {
|
|
99
|
+
return controller.onMutationRequest((m) => {
|
|
100
|
+
setLast(m);
|
|
101
|
+
cbRef.current?.(m);
|
|
102
|
+
});
|
|
103
|
+
}, [controller]);
|
|
104
|
+
const pending = (0, import_react.useMemo)(() => state.mutations.filter((m) => m.state === "pending"), [state.mutations]);
|
|
105
|
+
return {
|
|
106
|
+
pending,
|
|
107
|
+
mutations: state.mutations,
|
|
108
|
+
last: last && state.mutations.some((m) => m.id === last.id && m.state === "pending") ? last : pending[pending.length - 1] ?? null
|
|
109
|
+
};
|
|
110
|
+
}
|
|
88
111
|
function usePaintProposals(controller, options = {}) {
|
|
89
112
|
const [store] = (0, import_react.useState)(() => (0, import_paint_editor.createPaintProposals)({ ...options, controller }));
|
|
90
113
|
const state = (0, import_react.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
|
|
@@ -111,7 +134,7 @@ function usePaintChangeFeed(controller, options = {}) {
|
|
|
111
134
|
var import_react2 = require("react");
|
|
112
135
|
var import_paint_editor2 = require("@pixerate/editor/paint-editor");
|
|
113
136
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
114
|
-
var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
|
|
137
|
+
var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, deviceTilt = false, className }) => {
|
|
115
138
|
const state = usePaintEditorState(controller);
|
|
116
139
|
const viewport = (0, import_react2.useRef)(null);
|
|
117
140
|
const canvas = (0, import_react2.useRef)(null);
|
|
@@ -158,6 +181,7 @@ var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true,
|
|
|
158
181
|
else controller.takeDirty();
|
|
159
182
|
}, [state, presenter, controller]);
|
|
160
183
|
(0, import_react2.useEffect)(() => (0, import_paint_editor2.startWetClock)(controller), [controller]);
|
|
184
|
+
(0, import_react2.useEffect)(() => deviceTilt ? (0, import_paint_editor2.startDeviceTilt)(controller) : void 0, [controller, deviceTilt]);
|
|
161
185
|
(0, import_react2.useEffect)(() => {
|
|
162
186
|
const ctx = water.current?.getContext("2d");
|
|
163
187
|
if (ctx && typeof ctx.createImageData === "function") (0, import_paint_editor2.drawWaterOverlay)(controller, ctx);
|
|
@@ -1163,7 +1187,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
1163
1187
|
const carried = (0, import_paint_editor5.brushLoadColor)(state.mixerLoad);
|
|
1164
1188
|
const palette = (spec.colour?.palette ?? []).flatMap((c) => (0, import_brushes3.brushColourHex)(c, state.colorScheme) ?? []);
|
|
1165
1189
|
const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
|
|
1166
|
-
const loads = (["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint") && !brush.ghost;
|
|
1190
|
+
const loads = (["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint") && !brush.ghost && !brush.mutation;
|
|
1167
1191
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
|
|
1168
1192
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(BrushLibraryBrowser, { entries, activeId: brush.id, onSelect: (id) => controller.setBrush({ id }), thumbnail: (id) => thumbs.get(id) ?? null, thumbnailWidth, thumbnailHeight }),
|
|
1169
1193
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
@@ -1179,12 +1203,15 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
1179
1203
|
renderExtra: (section) => {
|
|
1180
1204
|
if (section === "shape" && brush.engine === "sticker")
|
|
1181
1205
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(StickerPicker, { controller, label: "Sticker stamps", selected: brush.sticker.stamps, onPick: (ref) => controller.setBrush({ sticker: { stamps: (0, import_paint_editor5.toggleStickerRef)(brush.sticker.stamps, ref) } }) });
|
|
1182
|
-
if (section === "behaviour"
|
|
1183
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1184
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("
|
|
1185
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.
|
|
1186
|
-
|
|
1187
|
-
|
|
1206
|
+
if (section === "behaviour")
|
|
1207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
1208
|
+
brush.mutation && !state.hasMutationAgent && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-[11px] text-amber-400", role: "status", "data-paint-mutation-unconnected": true, children: "No agent is connected \u2014 mutation strokes will stay as ordinary paint." }),
|
|
1209
|
+
loads && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1210
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-slate-400", children: "Carries" }),
|
|
1211
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "aria-label": "Brush load", title: carried ?? "Clean", className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: carried ?? "transparent" } }),
|
|
1212
|
+
brush.engine === "mixer" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
|
|
1213
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
|
|
1214
|
+
] })
|
|
1188
1215
|
] });
|
|
1189
1216
|
if (section === "colour")
|
|
1190
1217
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
@@ -1236,6 +1263,8 @@ var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
|
1236
1263
|
var PaperPanel = ({ controller, className }) => {
|
|
1237
1264
|
const state = usePaintEditorState(controller);
|
|
1238
1265
|
const [error, attempt] = useAttempt();
|
|
1266
|
+
const [tiltFollow, setTiltFollow] = (0, import_react11.useState)(false);
|
|
1267
|
+
(0, import_react11.useEffect)(() => tiltFollow ? (0, import_paint_editor6.startDeviceTilt)(controller) : void 0, [controller, tiltFollow]);
|
|
1239
1268
|
const paper = state.document.paper;
|
|
1240
1269
|
const previews = (0, import_react11.useMemo)(() => new Map(import_paint_editor6.PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: (0, import_paint_editor6.renderPaper)({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
1241
1270
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
@@ -1271,9 +1300,41 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
1271
1300
|
] }),
|
|
1272
1301
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.setPaper({ seed: paper.seed + 1 })), children: "New sheet" }),
|
|
1273
1302
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
1274
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "font-medium text-slate-300", children: "Light (thick paint, metallic paper)" }),
|
|
1303
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "font-medium text-slate-300", children: "Light (thick paint, iridescence, metallic paper)" }),
|
|
1275
1304
|
import_paint_editor6.LIGHT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor6.readPath)(controller.getLighting(), c.path), onChange: (v) => attempt(() => controller.setLighting({ [c.path]: v })) }, c.path)),
|
|
1276
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1305
|
+
import_paint_editor6.VIEW_TILT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor6.readPath)(state.viewTilt, c.path), onChange: (v) => attempt(() => controller.setViewTilt({ [c.path]: v })) }, c.path)),
|
|
1306
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1307
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1308
|
+
"button",
|
|
1309
|
+
{
|
|
1310
|
+
type: "button",
|
|
1311
|
+
"aria-pressed": tiltFollow,
|
|
1312
|
+
className: chip(tiltFollow),
|
|
1313
|
+
onClick: () => attempt(async () => {
|
|
1314
|
+
if (!tiltFollow && !await (0, import_paint_editor6.requestDeviceTiltPermission)()) return;
|
|
1315
|
+
setTiltFollow((v) => !v);
|
|
1316
|
+
}),
|
|
1317
|
+
children: "Device tilt"
|
|
1318
|
+
}
|
|
1319
|
+
),
|
|
1320
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.flattenRelief()), children: "Flatten relief" })
|
|
1321
|
+
] })
|
|
1322
|
+
] }),
|
|
1323
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "uv-heat-panel", children: [
|
|
1324
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "font-medium text-slate-300", children: "UV blacklight & heat" }),
|
|
1325
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
1326
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("input", { type: "checkbox", checked: state.uvLight.on, onChange: (e) => attempt(() => controller.setUvLight({ on: e.target.checked })) }),
|
|
1327
|
+
" UV blacklight"
|
|
1328
|
+
] }),
|
|
1329
|
+
import_paint_editor6.UV_LIGHT_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor6.readPath)(state.uvLight, c.path), onChange: (v) => attempt(() => controller.setUvLight({ [c.path]: v })) }, c.path)),
|
|
1330
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
1331
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.advanceHeat(10)), children: "Step heat" }),
|
|
1332
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.clearHeat()), children: "Cool canvas" }),
|
|
1333
|
+
state.heat.hotCells > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "text-[11px] text-amber-400", children: [
|
|
1334
|
+
Math.round(state.heat.max * 100),
|
|
1335
|
+
"% warm"
|
|
1336
|
+
] })
|
|
1337
|
+
] })
|
|
1277
1338
|
] }),
|
|
1278
1339
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ErrorLine, { error })
|
|
1279
1340
|
] });
|
|
@@ -1735,7 +1796,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1735
1796
|
usePaintEditorState(controller);
|
|
1736
1797
|
const [error, attempt] = useAttempt();
|
|
1737
1798
|
const [renaming, setRenaming] = (0, import_react15.useState)(null);
|
|
1738
|
-
const layers = controller.listLayers();
|
|
1799
|
+
const layers = controller.listLayers().filter((l) => !l.temporary);
|
|
1739
1800
|
const active = layers.find((l) => l.active) ?? null;
|
|
1740
1801
|
const light = active?.type === "pixel" ? controller.lightOf(active.id) : null;
|
|
1741
1802
|
const move = (delta) => {
|
|
@@ -1865,6 +1926,7 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1865
1926
|
const wet = state.wet;
|
|
1866
1927
|
const layerId = state.document.activeLayerId;
|
|
1867
1928
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1929
|
+
const livePattern = layerId ? controller.getLivePatterns(layerId).layers[0] ?? null : null;
|
|
1868
1930
|
const backend = controller.wetState();
|
|
1869
1931
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
1870
1932
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
@@ -1899,6 +1961,39 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1899
1961
|
}
|
|
1900
1962
|
)
|
|
1901
1963
|
] }),
|
|
1964
|
+
livePattern && layerId && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-live-patterns", children: [
|
|
1965
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1966
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "font-medium text-slate-300", children: "Live patterns" }),
|
|
1967
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1968
|
+
"button",
|
|
1969
|
+
{
|
|
1970
|
+
type: "button",
|
|
1971
|
+
className: button,
|
|
1972
|
+
onClick: () => attempt(async () => {
|
|
1973
|
+
await controller.wetIdle();
|
|
1974
|
+
const cx = Math.round(state.document.canvas.width / 2);
|
|
1975
|
+
const cy = Math.round(state.document.canvas.height / 2);
|
|
1976
|
+
controller.seedLivePatterns({ layerId, points: [{ x: cx, y: cy }] });
|
|
1977
|
+
}),
|
|
1978
|
+
children: "Seed pattern"
|
|
1979
|
+
}
|
|
1980
|
+
)
|
|
1981
|
+
] }),
|
|
1982
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1983
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-slate-400", children: "Pattern" }),
|
|
1984
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1985
|
+
"select",
|
|
1986
|
+
{
|
|
1987
|
+
"aria-label": "Live pattern",
|
|
1988
|
+
value: livePattern.settings.pattern,
|
|
1989
|
+
onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { pattern: e.target.value }))),
|
|
1990
|
+
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
1991
|
+
children: import_paint_editor10.LIVE_PATTERN_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: k, children: import_paint_editor10.LIVE_PATTERN_LABELS[k] }, k))
|
|
1992
|
+
}
|
|
1993
|
+
)
|
|
1994
|
+
] }),
|
|
1995
|
+
import_paint_editor10.LIVE_PATTERN_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor10.readPath)(livePattern.settings, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { [c.path]: v }))) }, c.path))
|
|
1996
|
+
] }),
|
|
1902
1997
|
backend.message && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
1903
1998
|
backend.backend && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-[10px] text-slate-500", children: backend.backend.kind === "wasm-threads" ? `WebAssembly, ${backend.backend.threads} threads` : backend.backend.kind === "wasm" ? "WebAssembly, one thread" : "JavaScript" }),
|
|
1904
1999
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center justify-between gap-2", children: [
|
|
@@ -4320,7 +4415,7 @@ var PAINT_CONTROLS = {
|
|
|
4320
4415
|
lighting: '[data-testid="light-panel"]',
|
|
4321
4416
|
symmetry: '[aria-label="Symmetry"]'
|
|
4322
4417
|
};
|
|
4323
|
-
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
4418
|
+
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, deviceTilt, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
4324
4419
|
const [tool, setTool] = (0, import_react31.useState)("brush");
|
|
4325
4420
|
const [fillOptions, setFillOptions] = (0, import_react31.useState)({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
|
|
4326
4421
|
const [tab, setTab] = (0, import_react31.useState)("color");
|
|
@@ -4392,7 +4487,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4392
4487
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
4393
4488
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
4394
4489
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
4395
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
|
|
4490
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, deviceTilt, className: "flex-1 rounded-lg" }),
|
|
4396
4491
|
error && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
4397
4492
|
] }),
|
|
4398
4493
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
@@ -4434,6 +4529,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4434
4529
|
StickerPicker,
|
|
4435
4530
|
StrokePanel,
|
|
4436
4531
|
WetPanel,
|
|
4532
|
+
useMutationRequests,
|
|
4437
4533
|
usePaintChangeFeed,
|
|
4438
4534
|
usePaintDirector,
|
|
4439
4535
|
usePaintEditor,
|
|
@@ -60,8 +60,30 @@ function usePaintDirector(controller, options = {}) {
|
|
|
60
60
|
const presence = new PaintPresence();
|
|
61
61
|
return { presence, director: new PaintDirector(controller, presence, options) };
|
|
62
62
|
});
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
controller.setMutationDirector(value.director);
|
|
65
|
+
return () => controller.setMutationDirector(null);
|
|
66
|
+
}, [controller, value.director]);
|
|
63
67
|
return value;
|
|
64
68
|
}
|
|
69
|
+
function useMutationRequests(controller, onRequest) {
|
|
70
|
+
const state = usePaintEditorState(controller);
|
|
71
|
+
const cbRef = useRef(onRequest);
|
|
72
|
+
cbRef.current = onRequest;
|
|
73
|
+
const [last, setLast] = useState(null);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
return controller.onMutationRequest((m) => {
|
|
76
|
+
setLast(m);
|
|
77
|
+
cbRef.current?.(m);
|
|
78
|
+
});
|
|
79
|
+
}, [controller]);
|
|
80
|
+
const pending = useMemo(() => state.mutations.filter((m) => m.state === "pending"), [state.mutations]);
|
|
81
|
+
return {
|
|
82
|
+
pending,
|
|
83
|
+
mutations: state.mutations,
|
|
84
|
+
last: last && state.mutations.some((m) => m.id === last.id && m.state === "pending") ? last : pending[pending.length - 1] ?? null
|
|
85
|
+
};
|
|
86
|
+
}
|
|
65
87
|
function usePaintProposals(controller, options = {}) {
|
|
66
88
|
const [store] = useState(() => createPaintProposals({ ...options, controller }));
|
|
67
89
|
const state = useSyncExternalStore(store.subscribe, store.getState, store.getState);
|
|
@@ -91,6 +113,7 @@ import {
|
|
|
91
113
|
PaintGesture,
|
|
92
114
|
documentToScreen,
|
|
93
115
|
drawWaterOverlay,
|
|
116
|
+
startDeviceTilt,
|
|
94
117
|
startWetClock,
|
|
95
118
|
fitZoom,
|
|
96
119
|
guideOverlay,
|
|
@@ -100,7 +123,7 @@ import {
|
|
|
100
123
|
paintProposalGhost
|
|
101
124
|
} from "@pixerate/editor/paint-editor";
|
|
102
125
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
103
|
-
var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, className }) => {
|
|
126
|
+
var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true, fitOnMount = true, onError, presence, proposals, agentStrokes, deviceTilt = false, className }) => {
|
|
104
127
|
const state = usePaintEditorState(controller);
|
|
105
128
|
const viewport = useRef2(null);
|
|
106
129
|
const canvas = useRef2(null);
|
|
@@ -147,6 +170,7 @@ var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true,
|
|
|
147
170
|
else controller.takeDirty();
|
|
148
171
|
}, [state, presenter, controller]);
|
|
149
172
|
useEffect2(() => startWetClock(controller), [controller]);
|
|
173
|
+
useEffect2(() => deviceTilt ? startDeviceTilt(controller) : void 0, [controller, deviceTilt]);
|
|
150
174
|
useEffect2(() => {
|
|
151
175
|
const ctx = water.current?.getContext("2d");
|
|
152
176
|
if (ctx && typeof ctx.createImageData === "function") drawWaterOverlay(controller, ctx);
|
|
@@ -685,7 +709,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
685
709
|
const carried = brushLoadColor(state.mixerLoad);
|
|
686
710
|
const palette = (spec.colour?.palette ?? []).flatMap((c) => brushColourHex(c, state.colorScheme) ?? []);
|
|
687
711
|
const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
|
|
688
|
-
const loads = (["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint") && !brush.ghost;
|
|
712
|
+
const loads = (["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint") && !brush.ghost && !brush.mutation;
|
|
689
713
|
return /* @__PURE__ */ jsxs4("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
|
|
690
714
|
/* @__PURE__ */ jsx5(BrushLibraryBrowser, { entries, activeId: brush.id, onSelect: (id) => controller.setBrush({ id }), thumbnail: (id) => thumbs.get(id) ?? null, thumbnailWidth, thumbnailHeight }),
|
|
691
715
|
/* @__PURE__ */ jsx5(
|
|
@@ -701,12 +725,15 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
701
725
|
renderExtra: (section) => {
|
|
702
726
|
if (section === "shape" && brush.engine === "sticker")
|
|
703
727
|
return /* @__PURE__ */ jsx5(StickerPicker, { controller, label: "Sticker stamps", selected: brush.sticker.stamps, onPick: (ref) => controller.setBrush({ sticker: { stamps: toggleStickerRef(brush.sticker.stamps, ref) } }) });
|
|
704
|
-
if (section === "behaviour"
|
|
705
|
-
return /* @__PURE__ */ jsxs4(
|
|
706
|
-
/* @__PURE__ */ jsx5("
|
|
707
|
-
/* @__PURE__ */
|
|
708
|
-
|
|
709
|
-
|
|
728
|
+
if (section === "behaviour")
|
|
729
|
+
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
730
|
+
brush.mutation && !state.hasMutationAgent && /* @__PURE__ */ jsx5("p", { className: "text-[11px] text-amber-400", role: "status", "data-paint-mutation-unconnected": true, children: "No agent is connected \u2014 mutation strokes will stay as ordinary paint." }),
|
|
731
|
+
loads && /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1", children: [
|
|
732
|
+
/* @__PURE__ */ jsx5("span", { className: "text-slate-400", children: "Carries" }),
|
|
733
|
+
/* @__PURE__ */ jsx5("span", { "aria-label": "Brush load", title: carried ?? "Clean", className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: carried ?? "transparent" } }),
|
|
734
|
+
brush.engine === "mixer" && /* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
|
|
735
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
|
|
736
|
+
] })
|
|
710
737
|
] });
|
|
711
738
|
if (section === "colour")
|
|
712
739
|
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
@@ -751,13 +778,15 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
751
778
|
};
|
|
752
779
|
|
|
753
780
|
// src/paint-editor/PaperPanel.tsx
|
|
754
|
-
import { useMemo as useMemo4 } from "react";
|
|
755
|
-
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, patchPath, readPath, renderPaper } from "@pixerate/editor/paint-editor";
|
|
781
|
+
import { useEffect as useEffect4, useMemo as useMemo4, useState as useState5 } from "react";
|
|
782
|
+
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, UV_LIGHT_SLIDERS, VIEW_TILT_SLIDERS, patchPath, readPath, renderPaper, requestDeviceTiltPermission, startDeviceTilt as startDeviceTilt2 } from "@pixerate/editor/paint-editor";
|
|
756
783
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
757
784
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
758
785
|
var PaperPanel = ({ controller, className }) => {
|
|
759
786
|
const state = usePaintEditorState(controller);
|
|
760
787
|
const [error, attempt] = useAttempt();
|
|
788
|
+
const [tiltFollow, setTiltFollow] = useState5(false);
|
|
789
|
+
useEffect4(() => tiltFollow ? startDeviceTilt2(controller) : void 0, [controller, tiltFollow]);
|
|
761
790
|
const paper = state.document.paper;
|
|
762
791
|
const previews = useMemo4(() => new Map(PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: renderPaper({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
763
792
|
return /* @__PURE__ */ jsxs5("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
@@ -793,16 +822,48 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
793
822
|
] }),
|
|
794
823
|
/* @__PURE__ */ jsx6("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.setPaper({ seed: paper.seed + 1 })), children: "New sheet" }),
|
|
795
824
|
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
796
|
-
/* @__PURE__ */ jsx6("span", { className: "font-medium text-slate-300", children: "Light (thick paint, metallic paper)" }),
|
|
825
|
+
/* @__PURE__ */ jsx6("span", { className: "font-medium text-slate-300", children: "Light (thick paint, iridescence, metallic paper)" }),
|
|
797
826
|
LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx6(PaintSlider, { control: c, value: readPath(controller.getLighting(), c.path), onChange: (v) => attempt(() => controller.setLighting({ [c.path]: v })) }, c.path)),
|
|
798
|
-
/* @__PURE__ */ jsx6(
|
|
827
|
+
VIEW_TILT_SLIDERS.map((c) => /* @__PURE__ */ jsx6(PaintSlider, { control: c, value: readPath(state.viewTilt, c.path), onChange: (v) => attempt(() => controller.setViewTilt({ [c.path]: v })) }, c.path)),
|
|
828
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
829
|
+
/* @__PURE__ */ jsx6(
|
|
830
|
+
"button",
|
|
831
|
+
{
|
|
832
|
+
type: "button",
|
|
833
|
+
"aria-pressed": tiltFollow,
|
|
834
|
+
className: chip(tiltFollow),
|
|
835
|
+
onClick: () => attempt(async () => {
|
|
836
|
+
if (!tiltFollow && !await requestDeviceTiltPermission()) return;
|
|
837
|
+
setTiltFollow((v) => !v);
|
|
838
|
+
}),
|
|
839
|
+
children: "Device tilt"
|
|
840
|
+
}
|
|
841
|
+
),
|
|
842
|
+
/* @__PURE__ */ jsx6("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.flattenRelief()), children: "Flatten relief" })
|
|
843
|
+
] })
|
|
844
|
+
] }),
|
|
845
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1.5", "data-testid": "uv-heat-panel", children: [
|
|
846
|
+
/* @__PURE__ */ jsx6("span", { className: "font-medium text-slate-300", children: "UV blacklight & heat" }),
|
|
847
|
+
/* @__PURE__ */ jsxs5("label", { className: "flex items-center gap-2", children: [
|
|
848
|
+
/* @__PURE__ */ jsx6("input", { type: "checkbox", checked: state.uvLight.on, onChange: (e) => attempt(() => controller.setUvLight({ on: e.target.checked })) }),
|
|
849
|
+
" UV blacklight"
|
|
850
|
+
] }),
|
|
851
|
+
UV_LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx6(PaintSlider, { control: c, value: readPath(state.uvLight, c.path), onChange: (v) => attempt(() => controller.setUvLight({ [c.path]: v })) }, c.path)),
|
|
852
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1.5", children: [
|
|
853
|
+
/* @__PURE__ */ jsx6("button", { type: "button", className: "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.advanceHeat(10)), children: "Step heat" }),
|
|
854
|
+
/* @__PURE__ */ jsx6("button", { type: "button", className: "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.clearHeat()), children: "Cool canvas" }),
|
|
855
|
+
state.heat.hotCells > 0 && /* @__PURE__ */ jsxs5("span", { className: "text-[11px] text-amber-400", children: [
|
|
856
|
+
Math.round(state.heat.max * 100),
|
|
857
|
+
"% warm"
|
|
858
|
+
] })
|
|
859
|
+
] })
|
|
799
860
|
] }),
|
|
800
861
|
/* @__PURE__ */ jsx6(ErrorLine, { error })
|
|
801
862
|
] });
|
|
802
863
|
};
|
|
803
864
|
|
|
804
865
|
// src/paint-editor/ColorPanel.tsx
|
|
805
|
-
import { useMemo as useMemo5, useRef as useRef5, useState as
|
|
866
|
+
import { useMemo as useMemo5, useRef as useRef5, useState as useState6 } from "react";
|
|
806
867
|
import {
|
|
807
868
|
HARMONY_KINDS,
|
|
808
869
|
MIXING_PAD_HEIGHT,
|
|
@@ -823,12 +884,12 @@ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
|
823
884
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
824
885
|
const state = usePaintEditorState(controller);
|
|
825
886
|
const [error, attempt] = useAttempt();
|
|
826
|
-
const [wheel, setWheel] =
|
|
827
|
-
const [kind, setKind] =
|
|
828
|
-
const [padTool, setPadTool] =
|
|
829
|
-
const [sample, setSample] =
|
|
830
|
-
const [parts, setParts] =
|
|
831
|
-
const [padName, setPadName] =
|
|
887
|
+
const [wheel, setWheel] = useState6("ryb");
|
|
888
|
+
const [kind, setKind] = useState6("complementary");
|
|
889
|
+
const [padTool, setPadTool] = useState6("paint");
|
|
890
|
+
const [sample, setSample] = useState6(3);
|
|
891
|
+
const [parts, setParts] = useState6([1, 1]);
|
|
892
|
+
const [padName, setPadName] = useState6("");
|
|
832
893
|
const padPoints = useRef5(null);
|
|
833
894
|
const ring = useMemo5(() => renderColorWheel(wheelSize, wheel), [wheelSize, wheel]);
|
|
834
895
|
const color = state.color;
|
|
@@ -1023,7 +1084,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1023
1084
|
};
|
|
1024
1085
|
|
|
1025
1086
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1026
|
-
import { useState as
|
|
1087
|
+
import { useState as useState7 } from "react";
|
|
1027
1088
|
import { BLEND_MENU_GROUPS } from "@pixerate/editor/paint-editor";
|
|
1028
1089
|
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1029
1090
|
function siblingIndex(layers, l) {
|
|
@@ -1033,8 +1094,8 @@ function siblingIndex(layers, l) {
|
|
|
1033
1094
|
var PaintLayersPanel = ({ controller, className }) => {
|
|
1034
1095
|
usePaintEditorState(controller);
|
|
1035
1096
|
const [error, attempt] = useAttempt();
|
|
1036
|
-
const [renaming, setRenaming] =
|
|
1037
|
-
const layers = controller.listLayers();
|
|
1097
|
+
const [renaming, setRenaming] = useState7(null);
|
|
1098
|
+
const layers = controller.listLayers().filter((l) => !l.temporary);
|
|
1038
1099
|
const active = layers.find((l) => l.active) ?? null;
|
|
1039
1100
|
const light = active?.type === "pixel" ? controller.lightOf(active.id) : null;
|
|
1040
1101
|
const move = (delta) => {
|
|
@@ -1155,7 +1216,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1155
1216
|
};
|
|
1156
1217
|
|
|
1157
1218
|
// src/paint-editor/WetPanel.tsx
|
|
1158
|
-
import { WET_FLOW_KINDS, WET_GPU_OPTIONS, WET_PARAM_SLIDERS, WET_SPEED_SLIDER, WET_TILT_SLIDERS, readPath as readPath2, wetEngineSummary } from "@pixerate/editor/paint-editor";
|
|
1219
|
+
import { LIVE_PATTERN_KINDS, LIVE_PATTERN_LABELS, LIVE_PATTERN_SLIDERS, WET_FLOW_KINDS, WET_GPU_OPTIONS, WET_PARAM_SLIDERS, WET_SPEED_SLIDER, WET_TILT_SLIDERS, readPath as readPath2, wetEngineSummary } from "@pixerate/editor/paint-editor";
|
|
1159
1220
|
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1160
1221
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1161
1222
|
var WetPanel = ({ controller, className }) => {
|
|
@@ -1164,6 +1225,7 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1164
1225
|
const wet = state.wet;
|
|
1165
1226
|
const layerId = state.document.activeLayerId;
|
|
1166
1227
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1228
|
+
const livePattern = layerId ? controller.getLivePatterns(layerId).layers[0] ?? null : null;
|
|
1167
1229
|
const backend = controller.wetState();
|
|
1168
1230
|
return /* @__PURE__ */ jsxs8("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
1169
1231
|
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
|
|
@@ -1198,6 +1260,39 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1198
1260
|
}
|
|
1199
1261
|
)
|
|
1200
1262
|
] }),
|
|
1263
|
+
livePattern && layerId && /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-live-patterns", children: [
|
|
1264
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
|
|
1265
|
+
/* @__PURE__ */ jsx9("span", { className: "font-medium text-slate-300", children: "Live patterns" }),
|
|
1266
|
+
/* @__PURE__ */ jsx9(
|
|
1267
|
+
"button",
|
|
1268
|
+
{
|
|
1269
|
+
type: "button",
|
|
1270
|
+
className: button,
|
|
1271
|
+
onClick: () => attempt(async () => {
|
|
1272
|
+
await controller.wetIdle();
|
|
1273
|
+
const cx = Math.round(state.document.canvas.width / 2);
|
|
1274
|
+
const cy = Math.round(state.document.canvas.height / 2);
|
|
1275
|
+
controller.seedLivePatterns({ layerId, points: [{ x: cx, y: cy }] });
|
|
1276
|
+
}),
|
|
1277
|
+
children: "Seed pattern"
|
|
1278
|
+
}
|
|
1279
|
+
)
|
|
1280
|
+
] }),
|
|
1281
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1282
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Pattern" }),
|
|
1283
|
+
/* @__PURE__ */ jsx9(
|
|
1284
|
+
"select",
|
|
1285
|
+
{
|
|
1286
|
+
"aria-label": "Live pattern",
|
|
1287
|
+
value: livePattern.settings.pattern,
|
|
1288
|
+
onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { pattern: e.target.value }))),
|
|
1289
|
+
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
1290
|
+
children: LIVE_PATTERN_KINDS.map((k) => /* @__PURE__ */ jsx9("option", { value: k, children: LIVE_PATTERN_LABELS[k] }, k))
|
|
1291
|
+
}
|
|
1292
|
+
)
|
|
1293
|
+
] }),
|
|
1294
|
+
LIVE_PATTERN_SLIDERS.map((c) => /* @__PURE__ */ jsx9(PaintSlider, { control: c, value: readPath2(livePattern.settings, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { [c.path]: v }))) }, c.path))
|
|
1295
|
+
] }),
|
|
1201
1296
|
backend.message && /* @__PURE__ */ jsx9("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
1202
1297
|
backend.backend && /* @__PURE__ */ jsx9("p", { className: "text-[10px] text-slate-500", children: backend.backend.kind === "wasm-threads" ? `WebAssembly, ${backend.backend.threads} threads` : backend.backend.kind === "wasm" ? "WebAssembly, one thread" : "JavaScript" }),
|
|
1203
1298
|
/* @__PURE__ */ jsxs8("label", { className: "flex items-center justify-between gap-2", children: [
|
|
@@ -1343,14 +1438,14 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1343
1438
|
};
|
|
1344
1439
|
|
|
1345
1440
|
// src/paint-editor/PathStrokePanel.tsx
|
|
1346
|
-
import { useState as
|
|
1441
|
+
import { useState as useState8 } from "react";
|
|
1347
1442
|
import { PATH_STROKE_TAPERS } from "@pixerate/editor/paint-editor";
|
|
1348
1443
|
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1349
1444
|
var PathStrokePanel = ({ controller, className }) => {
|
|
1350
1445
|
const state = usePaintEditorState(controller);
|
|
1351
1446
|
const [error, attempt] = useAttempt();
|
|
1352
|
-
const [path, setPath] =
|
|
1353
|
-
const [taper, setTaper] =
|
|
1447
|
+
const [path, setPath] = useState8("");
|
|
1448
|
+
const [taper, setTaper] = useState8(PATH_STROKE_TAPERS[0].id);
|
|
1354
1449
|
const pressure = PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
|
|
1355
1450
|
return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "path-stroke-panel", children: [
|
|
1356
1451
|
/* @__PURE__ */ jsx12("span", { className: "font-medium text-slate-300", children: "Brush a path" }),
|
|
@@ -1374,7 +1469,7 @@ var PathStrokePanel = ({ controller, className }) => {
|
|
|
1374
1469
|
};
|
|
1375
1470
|
|
|
1376
1471
|
// src/paint-editor/EvolutionPanel.tsx
|
|
1377
|
-
import { useState as
|
|
1472
|
+
import { useState as useState9, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
1378
1473
|
import {
|
|
1379
1474
|
EVOLUTION_SLIDERS,
|
|
1380
1475
|
exportProposalContactSheetPng,
|
|
@@ -1389,12 +1484,12 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1389
1484
|
const store = proposals ?? controller.proposals;
|
|
1390
1485
|
const proposalState = useSyncExternalStore3(store.subscribe, store.getState, store.getState);
|
|
1391
1486
|
const [error, attempt] = useAttempt();
|
|
1392
|
-
const [selectedStrokes, setSelectedStrokes] =
|
|
1393
|
-
const [selectedProposals, setSelectedProposals] =
|
|
1394
|
-
const [count, setCount] =
|
|
1395
|
-
const [seed, setSeed] =
|
|
1396
|
-
const [mutation, setMutation] =
|
|
1397
|
-
const [contactSheetUrl, setContactSheetUrl] =
|
|
1487
|
+
const [selectedStrokes, setSelectedStrokes] = useState9([]);
|
|
1488
|
+
const [selectedProposals, setSelectedProposals] = useState9([]);
|
|
1489
|
+
const [count, setCount] = useState9(4);
|
|
1490
|
+
const [seed, setSeed] = useState9(1);
|
|
1491
|
+
const [mutation, setMutation] = useState9(() => normalizeMutationRates());
|
|
1492
|
+
const [contactSheetUrl, setContactSheetUrl] = useState9(null);
|
|
1398
1493
|
const eligibleStrokes = state.document.strokes.filter((s) => !liveStrokeRefusal2(s.brush));
|
|
1399
1494
|
const activeStrokeIds = selectedStrokes.filter((id) => eligibleStrokes.some((s) => s.id === id));
|
|
1400
1495
|
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] : [];
|
|
@@ -1546,17 +1641,17 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1546
1641
|
};
|
|
1547
1642
|
|
|
1548
1643
|
// src/paint-editor/PaintEditor.tsx
|
|
1549
|
-
import { useRef as useRef7, useState as
|
|
1644
|
+
import { useRef as useRef7, useState as useState11 } from "react";
|
|
1550
1645
|
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
1551
1646
|
|
|
1552
1647
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1553
|
-
import { useEffect as
|
|
1648
|
+
import { useEffect as useEffect5, useMemo as useMemo6, useRef as useRef6, useState as useState10 } from "react";
|
|
1554
1649
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1555
1650
|
import { pathControlsOf } from "@pixerate/editor/effects";
|
|
1556
1651
|
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1557
1652
|
function usePaintEffectsProvider(controller) {
|
|
1558
|
-
const [provider, setProvider] =
|
|
1559
|
-
|
|
1653
|
+
const [provider, setProvider] = useState10(controller.effectsProvider);
|
|
1654
|
+
useEffect5(() => {
|
|
1560
1655
|
setProvider(controller.effectsProvider);
|
|
1561
1656
|
return controller.effects.subscribe(setProvider);
|
|
1562
1657
|
}, [controller]);
|
|
@@ -1564,7 +1659,7 @@ function usePaintEffectsProvider(controller) {
|
|
|
1564
1659
|
}
|
|
1565
1660
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
1566
1661
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
1567
|
-
|
|
1662
|
+
useEffect5(() => {
|
|
1568
1663
|
if (!registry) return;
|
|
1569
1664
|
return registry.register(createPaintEffectsToolProvider(controller, { id, namespace, readOnly, playbackSurface }));
|
|
1570
1665
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
@@ -1606,8 +1701,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1606
1701
|
const state = usePaintEditorState(controller);
|
|
1607
1702
|
const provider = usePaintEffectsProvider(controller);
|
|
1608
1703
|
const [error, attempt] = useAttempt();
|
|
1609
|
-
const [browse, setBrowse] =
|
|
1610
|
-
const [busy, setBusy] =
|
|
1704
|
+
const [browse, setBrowse] = useState10(null);
|
|
1705
|
+
const [busy, setBusy] = useState10(false);
|
|
1611
1706
|
const paper = controller.getPaperEffect();
|
|
1612
1707
|
const activeId = state.document.activeLayerId;
|
|
1613
1708
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -1772,14 +1867,14 @@ var PAINT_CONTROLS = {
|
|
|
1772
1867
|
lighting: '[data-testid="light-panel"]',
|
|
1773
1868
|
symmetry: '[aria-label="Symmetry"]'
|
|
1774
1869
|
};
|
|
1775
|
-
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1776
|
-
const [tool, setTool] =
|
|
1777
|
-
const [fillOptions, setFillOptions] =
|
|
1778
|
-
const [tab, setTab] =
|
|
1870
|
+
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, deviceTilt, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1871
|
+
const [tool, setTool] = useState11("brush");
|
|
1872
|
+
const [fillOptions, setFillOptions] = useState11({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
|
|
1873
|
+
const [tab, setTab] = useState11("color");
|
|
1779
1874
|
const tabRef = useRef7(tab);
|
|
1780
1875
|
tabRef.current = tab;
|
|
1781
1876
|
const rootRef = useRef7(null);
|
|
1782
|
-
const [ownPresence] =
|
|
1877
|
+
const [ownPresence] = useState11(() => new PaintPresence2());
|
|
1783
1878
|
const ambientPlayback = useAgentPlayback();
|
|
1784
1879
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
1785
1880
|
const viewBox = () => {
|
|
@@ -1835,7 +1930,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1835
1930
|
const box = rootRef.current?.getBoundingClientRect();
|
|
1836
1931
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
1837
1932
|
};
|
|
1838
|
-
const [error, setError] =
|
|
1933
|
+
const [error, setError] = useState11(null);
|
|
1839
1934
|
const effects = usePaintEffectsProvider(controller);
|
|
1840
1935
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1841
1936
|
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: [
|
|
@@ -1844,7 +1939,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1844
1939
|
/* @__PURE__ */ jsxs14("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1845
1940
|
/* @__PURE__ */ jsx15(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1846
1941
|
/* @__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" }),
|
|
1942
|
+
/* @__PURE__ */ jsx15(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, deviceTilt, className: "flex-1 rounded-lg" }),
|
|
1848
1943
|
error && /* @__PURE__ */ jsx15("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1849
1944
|
] }),
|
|
1850
1945
|
/* @__PURE__ */ jsxs14("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
@@ -1885,6 +1980,7 @@ export {
|
|
|
1885
1980
|
StickerPicker,
|
|
1886
1981
|
StrokePanel,
|
|
1887
1982
|
WetPanel,
|
|
1983
|
+
useMutationRequests,
|
|
1888
1984
|
usePaintChangeFeed,
|
|
1889
1985
|
usePaintDirector,
|
|
1890
1986
|
usePaintEditor,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PaintDirector, PaintEditorController, PaintPresence, type PaintChange, type PaintChangeFeed, type PaintDirectorOptions, type PaintEditorOptions, type PaintEditorState, type PaintProposal, type PaintProposals, type PaintProposalsOptions, type SerializedPaintDocument } from '@pixerate/editor/paint-editor';
|
|
1
|
+
import { PaintDirector, PaintEditorController, PaintPresence, type PaintChange, type PaintChangeFeed, type PaintDirectorOptions, type PaintEditorOptions, type PaintEditorState, type PaintMutationInfo, type PaintMutationRequestListener, type PaintProposal, type PaintProposals, type PaintProposalsOptions, type SerializedPaintDocument } from '@pixerate/editor/paint-editor';
|
|
2
2
|
import type { EditorDocument } from '@pixerate/editor/persistence';
|
|
3
3
|
export interface UsePaintEditorReturn {
|
|
4
4
|
controller: PaintEditorController;
|
|
@@ -23,6 +23,20 @@ export declare function usePaintDirector(controller: PaintEditorController, opti
|
|
|
23
23
|
presence: PaintPresence;
|
|
24
24
|
director: PaintDirector;
|
|
25
25
|
};
|
|
26
|
+
export interface UseMutationRequestsReturn {
|
|
27
|
+
/** Pending mutations waiting for an agent to claim them (`state === 'pending'`). */
|
|
28
|
+
pending: readonly PaintMutationInfo[];
|
|
29
|
+
/** Every active or completed mutation in the session. */
|
|
30
|
+
mutations: readonly PaintMutationInfo[];
|
|
31
|
+
/** The most recently raised pending mutation, or `null`. */
|
|
32
|
+
last: PaintMutationInfo | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Subscribes to mutation requests raised when a user finishes a stroke with a `mutation` brush
|
|
36
|
+
* and pauses for `settle` seconds. While mounted, marks an agent listener as connected on the
|
|
37
|
+
* controller so the brush panel does not warn that no agent is listening.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useMutationRequests(controller: PaintEditorController, onRequest?: PaintMutationRequestListener): UseMutationRequestsReturn;
|
|
26
40
|
export interface PaintProposalsHandle {
|
|
27
41
|
/** The framework-free store (for `createPaintProposalToolProvider` and agents). */
|
|
28
42
|
readonly store: PaintProposals;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PaintDirector, PaintEditorController, PaintPresence, type PaintChange, type PaintChangeFeed, type PaintDirectorOptions, type PaintEditorOptions, type PaintEditorState, type PaintProposal, type PaintProposals, type PaintProposalsOptions, type SerializedPaintDocument } from '@pixerate/editor/paint-editor';
|
|
1
|
+
import { PaintDirector, PaintEditorController, PaintPresence, type PaintChange, type PaintChangeFeed, type PaintDirectorOptions, type PaintEditorOptions, type PaintEditorState, type PaintMutationInfo, type PaintMutationRequestListener, type PaintProposal, type PaintProposals, type PaintProposalsOptions, type SerializedPaintDocument } from '@pixerate/editor/paint-editor';
|
|
2
2
|
import type { EditorDocument } from '@pixerate/editor/persistence';
|
|
3
3
|
export interface UsePaintEditorReturn {
|
|
4
4
|
controller: PaintEditorController;
|
|
@@ -23,6 +23,20 @@ export declare function usePaintDirector(controller: PaintEditorController, opti
|
|
|
23
23
|
presence: PaintPresence;
|
|
24
24
|
director: PaintDirector;
|
|
25
25
|
};
|
|
26
|
+
export interface UseMutationRequestsReturn {
|
|
27
|
+
/** Pending mutations waiting for an agent to claim them (`state === 'pending'`). */
|
|
28
|
+
pending: readonly PaintMutationInfo[];
|
|
29
|
+
/** Every active or completed mutation in the session. */
|
|
30
|
+
mutations: readonly PaintMutationInfo[];
|
|
31
|
+
/** The most recently raised pending mutation, or `null`. */
|
|
32
|
+
last: PaintMutationInfo | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Subscribes to mutation requests raised when a user finishes a stroke with a `mutation` brush
|
|
36
|
+
* and pauses for `settle` seconds. While mounted, marks an agent listener as connected on the
|
|
37
|
+
* controller so the brush panel does not warn that no agent is listening.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useMutationRequests(controller: PaintEditorController, onRequest?: PaintMutationRequestListener): UseMutationRequestsReturn;
|
|
26
40
|
export interface PaintProposalsHandle {
|
|
27
41
|
/** The framework-free store (for `createPaintProposalToolProvider` and agents). */
|
|
28
42
|
readonly store: PaintProposals;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.191.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.
|
|
286
|
+
"@pixerate/editor": ">=0.276.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.
|
|
337
|
+
"@pixerate/editor": "0.276.0"
|
|
338
338
|
},
|
|
339
339
|
"scripts": {
|
|
340
340
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|