@pixerate/editor-react 0.189.0 → 0.190.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 +75 -13
- package/dist/paint-editor/index.js +108 -46
- 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) => {
|
|
@@ -4320,7 +4381,7 @@ var PAINT_CONTROLS = {
|
|
|
4320
4381
|
lighting: '[data-testid="light-panel"]',
|
|
4321
4382
|
symmetry: '[aria-label="Symmetry"]'
|
|
4322
4383
|
};
|
|
4323
|
-
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
4384
|
+
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, deviceTilt, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
4324
4385
|
const [tool, setTool] = (0, import_react31.useState)("brush");
|
|
4325
4386
|
const [fillOptions, setFillOptions] = (0, import_react31.useState)({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
|
|
4326
4387
|
const [tab, setTab] = (0, import_react31.useState)("color");
|
|
@@ -4392,7 +4453,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4392
4453
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
4393
4454
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
4394
4455
|
/* @__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" }),
|
|
4456
|
+
/* @__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
4457
|
error && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
4397
4458
|
] }),
|
|
4398
4459
|
/* @__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 +4495,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
4434
4495
|
StickerPicker,
|
|
4435
4496
|
StrokePanel,
|
|
4436
4497
|
WetPanel,
|
|
4498
|
+
useMutationRequests,
|
|
4437
4499
|
usePaintChangeFeed,
|
|
4438
4500
|
usePaintDirector,
|
|
4439
4501
|
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) => {
|
|
@@ -1343,14 +1404,14 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1343
1404
|
};
|
|
1344
1405
|
|
|
1345
1406
|
// src/paint-editor/PathStrokePanel.tsx
|
|
1346
|
-
import { useState as
|
|
1407
|
+
import { useState as useState8 } from "react";
|
|
1347
1408
|
import { PATH_STROKE_TAPERS } from "@pixerate/editor/paint-editor";
|
|
1348
1409
|
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1349
1410
|
var PathStrokePanel = ({ controller, className }) => {
|
|
1350
1411
|
const state = usePaintEditorState(controller);
|
|
1351
1412
|
const [error, attempt] = useAttempt();
|
|
1352
|
-
const [path, setPath] =
|
|
1353
|
-
const [taper, setTaper] =
|
|
1413
|
+
const [path, setPath] = useState8("");
|
|
1414
|
+
const [taper, setTaper] = useState8(PATH_STROKE_TAPERS[0].id);
|
|
1354
1415
|
const pressure = PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
|
|
1355
1416
|
return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "path-stroke-panel", children: [
|
|
1356
1417
|
/* @__PURE__ */ jsx12("span", { className: "font-medium text-slate-300", children: "Brush a path" }),
|
|
@@ -1374,7 +1435,7 @@ var PathStrokePanel = ({ controller, className }) => {
|
|
|
1374
1435
|
};
|
|
1375
1436
|
|
|
1376
1437
|
// src/paint-editor/EvolutionPanel.tsx
|
|
1377
|
-
import { useState as
|
|
1438
|
+
import { useState as useState9, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
1378
1439
|
import {
|
|
1379
1440
|
EVOLUTION_SLIDERS,
|
|
1380
1441
|
exportProposalContactSheetPng,
|
|
@@ -1389,12 +1450,12 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1389
1450
|
const store = proposals ?? controller.proposals;
|
|
1390
1451
|
const proposalState = useSyncExternalStore3(store.subscribe, store.getState, store.getState);
|
|
1391
1452
|
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] =
|
|
1453
|
+
const [selectedStrokes, setSelectedStrokes] = useState9([]);
|
|
1454
|
+
const [selectedProposals, setSelectedProposals] = useState9([]);
|
|
1455
|
+
const [count, setCount] = useState9(4);
|
|
1456
|
+
const [seed, setSeed] = useState9(1);
|
|
1457
|
+
const [mutation, setMutation] = useState9(() => normalizeMutationRates());
|
|
1458
|
+
const [contactSheetUrl, setContactSheetUrl] = useState9(null);
|
|
1398
1459
|
const eligibleStrokes = state.document.strokes.filter((s) => !liveStrokeRefusal2(s.brush));
|
|
1399
1460
|
const activeStrokeIds = selectedStrokes.filter((id) => eligibleStrokes.some((s) => s.id === id));
|
|
1400
1461
|
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 +1607,17 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1546
1607
|
};
|
|
1547
1608
|
|
|
1548
1609
|
// src/paint-editor/PaintEditor.tsx
|
|
1549
|
-
import { useRef as useRef7, useState as
|
|
1610
|
+
import { useRef as useRef7, useState as useState11 } from "react";
|
|
1550
1611
|
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
1551
1612
|
|
|
1552
1613
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1553
|
-
import { useEffect as
|
|
1614
|
+
import { useEffect as useEffect5, useMemo as useMemo6, useRef as useRef6, useState as useState10 } from "react";
|
|
1554
1615
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1555
1616
|
import { pathControlsOf } from "@pixerate/editor/effects";
|
|
1556
1617
|
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1557
1618
|
function usePaintEffectsProvider(controller) {
|
|
1558
|
-
const [provider, setProvider] =
|
|
1559
|
-
|
|
1619
|
+
const [provider, setProvider] = useState10(controller.effectsProvider);
|
|
1620
|
+
useEffect5(() => {
|
|
1560
1621
|
setProvider(controller.effectsProvider);
|
|
1561
1622
|
return controller.effects.subscribe(setProvider);
|
|
1562
1623
|
}, [controller]);
|
|
@@ -1564,7 +1625,7 @@ function usePaintEffectsProvider(controller) {
|
|
|
1564
1625
|
}
|
|
1565
1626
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
1566
1627
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
1567
|
-
|
|
1628
|
+
useEffect5(() => {
|
|
1568
1629
|
if (!registry) return;
|
|
1569
1630
|
return registry.register(createPaintEffectsToolProvider(controller, { id, namespace, readOnly, playbackSurface }));
|
|
1570
1631
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
@@ -1606,8 +1667,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1606
1667
|
const state = usePaintEditorState(controller);
|
|
1607
1668
|
const provider = usePaintEffectsProvider(controller);
|
|
1608
1669
|
const [error, attempt] = useAttempt();
|
|
1609
|
-
const [browse, setBrowse] =
|
|
1610
|
-
const [busy, setBusy] =
|
|
1670
|
+
const [browse, setBrowse] = useState10(null);
|
|
1671
|
+
const [busy, setBusy] = useState10(false);
|
|
1611
1672
|
const paper = controller.getPaperEffect();
|
|
1612
1673
|
const activeId = state.document.activeLayerId;
|
|
1613
1674
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -1772,14 +1833,14 @@ var PAINT_CONTROLS = {
|
|
|
1772
1833
|
lighting: '[data-testid="light-panel"]',
|
|
1773
1834
|
symmetry: '[aria-label="Symmetry"]'
|
|
1774
1835
|
};
|
|
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] =
|
|
1836
|
+
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, deviceTilt, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1837
|
+
const [tool, setTool] = useState11("brush");
|
|
1838
|
+
const [fillOptions, setFillOptions] = useState11({ reference: "all", tolerance: 32, closeGap: 4, expand: 1, antialias: true });
|
|
1839
|
+
const [tab, setTab] = useState11("color");
|
|
1779
1840
|
const tabRef = useRef7(tab);
|
|
1780
1841
|
tabRef.current = tab;
|
|
1781
1842
|
const rootRef = useRef7(null);
|
|
1782
|
-
const [ownPresence] =
|
|
1843
|
+
const [ownPresence] = useState11(() => new PaintPresence2());
|
|
1783
1844
|
const ambientPlayback = useAgentPlayback();
|
|
1784
1845
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
1785
1846
|
const viewBox = () => {
|
|
@@ -1835,7 +1896,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1835
1896
|
const box = rootRef.current?.getBoundingClientRect();
|
|
1836
1897
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
1837
1898
|
};
|
|
1838
|
-
const [error, setError] =
|
|
1899
|
+
const [error, setError] = useState11(null);
|
|
1839
1900
|
const effects = usePaintEffectsProvider(controller);
|
|
1840
1901
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1841
1902
|
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 +1905,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1844
1905
|
/* @__PURE__ */ jsxs14("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1845
1906
|
/* @__PURE__ */ jsx15(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1846
1907
|
/* @__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" }),
|
|
1908
|
+
/* @__PURE__ */ jsx15(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, deviceTilt, className: "flex-1 rounded-lg" }),
|
|
1848
1909
|
error && /* @__PURE__ */ jsx15("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1849
1910
|
] }),
|
|
1850
1911
|
/* @__PURE__ */ jsxs14("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
@@ -1885,6 +1946,7 @@ export {
|
|
|
1885
1946
|
StickerPicker,
|
|
1886
1947
|
StrokePanel,
|
|
1887
1948
|
WetPanel,
|
|
1949
|
+
useMutationRequests,
|
|
1888
1950
|
usePaintChangeFeed,
|
|
1889
1951
|
usePaintDirector,
|
|
1890
1952
|
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.190.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.275.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.275.0"
|
|
338
338
|
},
|
|
339
339
|
"scripts": {
|
|
340
340
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|