@pixerate/editor-react 0.179.0 → 0.181.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/brushes/BrushEditor.d.cts +40 -0
- package/dist/brushes/BrushEditor.d.ts +40 -0
- package/dist/brushes/BrushLibraryEditor.d.cts +31 -0
- package/dist/brushes/BrushLibraryEditor.d.ts +31 -0
- package/dist/brushes/index.cjs +292 -20
- package/dist/brushes/index.d.cts +2 -0
- package/dist/brushes/index.d.ts +2 -0
- package/dist/brushes/index.js +6 -2
- package/dist/chunk-THMOZMEE.js +122 -0
- package/dist/{chunk-UR4KL7WE.js → chunk-WCSMREA4.js} +26 -6
- package/dist/chunk-XORL5PGL.js +263 -0
- package/dist/image-editor/BrushOptionsBar.d.cts +6 -1
- package/dist/image-editor/BrushOptionsBar.d.ts +6 -1
- package/dist/image-editor/index.cjs +1181 -894
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +1722 -1435
- package/dist/index.js +3 -3
- package/dist/paint-editor/index.cjs +22 -24
- package/dist/paint-editor/index.d.cts +1 -1
- package/dist/paint-editor/index.d.ts +1 -1
- package/dist/paint-editor/index.js +415 -610
- package/dist/vector/VectorAppearancePanel.d.cts +8 -2
- package/dist/vector/VectorAppearancePanel.d.ts +8 -2
- package/dist/vector/index.cjs +1113 -748
- package/dist/vector/index.js +90 -59
- package/package.json +3 -3
- package/dist/chunk-62FMEDGG.js +0 -54
- package/dist/chunk-PQK2UMAY.js +0 -23
- package/dist/paint-editor/BrushEditor.d.cts +0 -29
- package/dist/paint-editor/BrushEditor.d.ts +0 -29
package/dist/vector/index.js
CHANGED
|
@@ -12,6 +12,13 @@ import {
|
|
|
12
12
|
useAgentPlayback,
|
|
13
13
|
usePlaybackSurface
|
|
14
14
|
} from "../chunk-W5CMGX3I.js";
|
|
15
|
+
import {
|
|
16
|
+
BrushLibraryEditor,
|
|
17
|
+
useBrushLibrary
|
|
18
|
+
} from "../chunk-THMOZMEE.js";
|
|
19
|
+
import {
|
|
20
|
+
BrushLibraryBrowser
|
|
21
|
+
} from "../chunk-XORL5PGL.js";
|
|
15
22
|
|
|
16
23
|
// src/vector/useVectorEditor.ts
|
|
17
24
|
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
@@ -865,7 +872,7 @@ function VectorCanvas({
|
|
|
865
872
|
}
|
|
866
873
|
|
|
867
874
|
// src/vector/VectorToolbar.tsx
|
|
868
|
-
import
|
|
875
|
+
import React11 from "react";
|
|
869
876
|
import {
|
|
870
877
|
VECTOR_TOOLS,
|
|
871
878
|
VECTOR_DISTORT_BRUSH_MODES,
|
|
@@ -1049,6 +1056,8 @@ function VectorEffectsPanel({ controller, className }) {
|
|
|
1049
1056
|
}
|
|
1050
1057
|
|
|
1051
1058
|
// src/vector/VectorAppearancePanel.tsx
|
|
1059
|
+
import { useState as useState3 } from "react";
|
|
1060
|
+
import { isBrushLibrary, VECTOR_PROFILE } from "@pixerate/editor/brushes";
|
|
1052
1061
|
import {
|
|
1053
1062
|
VECTOR_BLEND_MODE_MENU,
|
|
1054
1063
|
VECTOR_FILTER_MENU,
|
|
@@ -1062,8 +1071,11 @@ var numberClass2 = "h-7 w-14 rounded border border-border bg-background px-1.5 t
|
|
|
1062
1071
|
var selectClass2 = "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1 text-xs";
|
|
1063
1072
|
var headingClass = "text-[11px] font-medium uppercase tracking-wide text-muted-foreground";
|
|
1064
1073
|
var labelClass2 = "w-full truncate text-[11px] text-muted-foreground";
|
|
1065
|
-
function VectorAppearancePanel({ controller, className }) {
|
|
1074
|
+
function VectorAppearancePanel({ controller, renderBrushPreview, className }) {
|
|
1066
1075
|
const state = useVectorEditorState(controller);
|
|
1076
|
+
const [brushUi, setBrushUi] = useState3(null);
|
|
1077
|
+
const library = controller.brushLibrary;
|
|
1078
|
+
const entries = useBrushLibrary(brushUi ? library : null, { profile: VECTOR_PROFILE });
|
|
1067
1079
|
const panel = getVectorAppearancePanel(state);
|
|
1068
1080
|
if (!panel) return null;
|
|
1069
1081
|
const end = () => controller.endMergedEdit();
|
|
@@ -1072,42 +1084,61 @@ function VectorAppearancePanel({ controller, className }) {
|
|
|
1072
1084
|
const layerRow = (l, count) => {
|
|
1073
1085
|
const name = `${l.kind === "fill" ? "Fill" : "Stroke"} ${l.index + 1}`;
|
|
1074
1086
|
if (l.brushstroke)
|
|
1075
|
-
return /* @__PURE__ */
|
|
1076
|
-
/* @__PURE__ */
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
"input",
|
|
1081
|
-
{
|
|
1082
|
-
type: "number",
|
|
1083
|
-
min: 0.5,
|
|
1084
|
-
step: 0.5,
|
|
1085
|
-
"aria-label": `${name} brush size`,
|
|
1086
|
-
title: "Brush size",
|
|
1087
|
-
className: numberClass2,
|
|
1088
|
-
value: l.brushstroke.size,
|
|
1089
|
-
onChange: (e) => {
|
|
1090
|
-
const n = parseFloat(e.target.value);
|
|
1091
|
-
if (Number.isFinite(n) && n > 0) controller.setBrushstroke(l.index, { size: Math.min(500, n) }, { ids, merge: true });
|
|
1092
|
-
},
|
|
1093
|
-
onBlur: end
|
|
1094
|
-
}
|
|
1095
|
-
),
|
|
1096
|
-
/* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-0.5 text-[11px]", title: "Brush character: seeded jitter and paper grain", children: [
|
|
1087
|
+
return /* @__PURE__ */ jsxs4("div", { className: "space-y-1 rounded border border-border p-1", "data-vector-layer": `${l.kind}-${l.index}`, "data-vector-brushstroke": "", children: [
|
|
1088
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1", children: [
|
|
1089
|
+
/* @__PURE__ */ jsx4("input", { type: "checkbox", "aria-label": `${name} visible`, title: "Show", checked: l.visible, onChange: (e) => update(l, { visible: e.target.checked }) }),
|
|
1090
|
+
/* @__PURE__ */ jsx4("input", { type: "color", "aria-label": `${name} colour`, className: "h-7 w-10 cursor-pointer rounded border border-border bg-background", value: l.color ?? "#000000", onChange: (e) => controller.setBrushstroke(l.index, { color: e.target.value }, { ids, merge: true }), onBlur: end }),
|
|
1091
|
+
/* @__PURE__ */ jsx4("select", { "aria-label": `${name} brush`, className: selectClass2, value: l.brushstroke.brushId, onChange: (e) => controller.setBrushstroke(l.index, { brushId: e.target.value }, { ids }), children: controller.listBrushstrokeBrushes().map((b) => /* @__PURE__ */ jsx4("option", { value: b.id, children: b.name }, b.id)) }),
|
|
1097
1092
|
/* @__PURE__ */ jsx4(
|
|
1098
1093
|
"input",
|
|
1099
1094
|
{
|
|
1100
|
-
type: "
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1095
|
+
type: "number",
|
|
1096
|
+
min: 0.5,
|
|
1097
|
+
step: 0.5,
|
|
1098
|
+
"aria-label": `${name} brush size`,
|
|
1099
|
+
title: "Brush size",
|
|
1100
|
+
className: numberClass2,
|
|
1101
|
+
value: l.brushstroke.size,
|
|
1102
|
+
onChange: (e) => {
|
|
1103
|
+
const n = parseFloat(e.target.value);
|
|
1104
|
+
if (Number.isFinite(n) && n > 0) controller.setBrushstroke(l.index, { size: Math.min(500, n) }, { ids, merge: true });
|
|
1105
|
+
},
|
|
1106
|
+
onBlur: end
|
|
1105
1107
|
}
|
|
1106
1108
|
),
|
|
1107
|
-
"
|
|
1109
|
+
/* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-0.5 text-[11px]", title: "Brush character: seeded jitter and paper grain", children: [
|
|
1110
|
+
/* @__PURE__ */ jsx4(
|
|
1111
|
+
"input",
|
|
1112
|
+
{
|
|
1113
|
+
type: "checkbox",
|
|
1114
|
+
"aria-label": `${name} grain`,
|
|
1115
|
+
"data-vector-brushstroke-grain": "",
|
|
1116
|
+
checked: l.brushstroke.grain,
|
|
1117
|
+
onChange: (e) => controller.setBrushstroke(l.index, e.target.checked ? { paper: {}, ...l.brushstroke.seed === void 0 ? { seed: randomVectorBrushstrokeSeed() } : {} } : { paper: null }, { ids })
|
|
1118
|
+
}
|
|
1119
|
+
),
|
|
1120
|
+
"Grain"
|
|
1121
|
+
] }),
|
|
1122
|
+
/* @__PURE__ */ jsx4("button", { type: "button", className: buttonClass2, title: "Remove", "aria-label": `Remove ${name}`, onClick: () => controller.removePaintLayer("stroke", l.index, { ids }), children: "\xD7" })
|
|
1123
|
+
] }),
|
|
1124
|
+
library && /* @__PURE__ */ jsxs4("div", { className: "flex gap-1", children: [
|
|
1125
|
+
/* @__PURE__ */ jsx4("button", { type: "button", className: buttonClass2, "aria-expanded": brushUi?.index === l.index && brushUi.mode === "pick", title: "Pick a brush from the brush library", onClick: () => setBrushUi((u) => u?.index === l.index && u.mode === "pick" ? null : { index: l.index, mode: "pick" }), children: "Brush\u2026" }),
|
|
1126
|
+
isBrushLibrary(library) && /* @__PURE__ */ jsx4("button", { type: "button", className: buttonClass2, "aria-expanded": brushUi?.index === l.index && brushUi.mode === "edit", title: "Edit this brush, or make a new one, in the shared brush library", onClick: () => setBrushUi((u) => u?.index === l.index && u.mode === "edit" ? null : { index: l.index, mode: "edit" }), children: "Edit brush\u2026" })
|
|
1108
1127
|
] }),
|
|
1109
|
-
/* @__PURE__ */ jsx4(
|
|
1110
|
-
|
|
1128
|
+
brushUi?.index === l.index && brushUi.mode === "pick" && /* @__PURE__ */ jsx4(BrushLibraryBrowser, { entries, activeId: l.brushstroke.brushId, profile: VECTOR_PROFILE, onSelect: (id) => controller.setBrushstroke(l.index, { brushId: id }, { ids }) }),
|
|
1129
|
+
brushUi?.index === l.index && brushUi.mode === "edit" && isBrushLibrary(library) && /* @__PURE__ */ jsx4(
|
|
1130
|
+
BrushLibraryEditor,
|
|
1131
|
+
{
|
|
1132
|
+
library,
|
|
1133
|
+
brushId: l.brushstroke.brushId,
|
|
1134
|
+
profile: VECTOR_PROFILE,
|
|
1135
|
+
renderPreview: renderBrushPreview ?? controller.brushPreview ?? void 0,
|
|
1136
|
+
className: "rounded border border-border bg-slate-950 p-2",
|
|
1137
|
+
onSaved: (saved) => void controller.refreshBrushes().then(() => controller.setBrushstroke(l.index, { brushId: saved.id, keepColour: true }, { ids })),
|
|
1138
|
+
onClose: () => setBrushUi(null)
|
|
1139
|
+
}
|
|
1140
|
+
)
|
|
1141
|
+
] }, `${l.kind}-${l.index}`);
|
|
1111
1142
|
if (l.unknownKind)
|
|
1112
1143
|
return /* @__PURE__ */ jsxs4("div", { className: "text-[11px] text-muted-foreground", "data-vector-layer": `${l.kind}-${l.index}`, children: [
|
|
1113
1144
|
name,
|
|
@@ -1301,7 +1332,7 @@ function VectorAppearancePanel({ controller, className }) {
|
|
|
1301
1332
|
}
|
|
1302
1333
|
|
|
1303
1334
|
// src/vector/VectorEnvelopePanel.tsx
|
|
1304
|
-
import
|
|
1335
|
+
import React4 from "react";
|
|
1305
1336
|
import { VECTOR_ENVELOPE_STYLE_OPTIONS, getVectorEnvelopePanel } from "@pixerate/editor/vector";
|
|
1306
1337
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1307
1338
|
var buttonClass3 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40";
|
|
@@ -1316,7 +1347,7 @@ var SLIDERS = [
|
|
|
1316
1347
|
function VectorEnvelopePanel({ controller, className }) {
|
|
1317
1348
|
const state = useVectorEditorState(controller);
|
|
1318
1349
|
const panel = getVectorEnvelopePanel(state);
|
|
1319
|
-
const [size, setSize] =
|
|
1350
|
+
const [size, setSize] = React4.useState({ rows: 2, columns: 2 });
|
|
1320
1351
|
if (!panel) return null;
|
|
1321
1352
|
const env = panel.envelope;
|
|
1322
1353
|
const ids = panel.nodeId ? [panel.nodeId] : void 0;
|
|
@@ -1752,7 +1783,7 @@ function VectorTextPanel({ controller, className }) {
|
|
|
1752
1783
|
}
|
|
1753
1784
|
|
|
1754
1785
|
// src/vector/VectorSymbolsPanel.tsx
|
|
1755
|
-
import { useId as useId3, useState as
|
|
1786
|
+
import { useId as useId3, useState as useState4 } from "react";
|
|
1756
1787
|
import { getVectorSymbolsPanel, vectorPaintToHex as vectorPaintToHex2 } from "@pixerate/editor/vector";
|
|
1757
1788
|
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1758
1789
|
var buttonClass6 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40 aria-pressed:bg-primary aria-pressed:text-primary-foreground";
|
|
@@ -1762,7 +1793,7 @@ function VectorSymbolsPanel({ controller, className }) {
|
|
|
1762
1793
|
const state = useVectorEditorState(controller);
|
|
1763
1794
|
const uid = useId3().replace(/:/g, "");
|
|
1764
1795
|
const panel = getVectorSymbolsPanel(state, { idPrefix: `vsym${uid}-` });
|
|
1765
|
-
const [error, setError] =
|
|
1796
|
+
const [error, setError] = useState4(null);
|
|
1766
1797
|
const report = (r) => setError(r.ok ? null : r.message ?? null);
|
|
1767
1798
|
const inst = panel.instance;
|
|
1768
1799
|
return /* @__PURE__ */ jsxs8("div", { className: `space-y-2 ${className ?? ""}`, "data-vector-symbols-panel": "", "aria-label": "Symbols", children: [
|
|
@@ -1820,7 +1851,7 @@ function VectorSymbolsPanel({ controller, className }) {
|
|
|
1820
1851
|
}
|
|
1821
1852
|
|
|
1822
1853
|
// src/vector/VectorConstraintsPanel.tsx
|
|
1823
|
-
import { useState as
|
|
1854
|
+
import { useState as useState5 } from "react";
|
|
1824
1855
|
import { getVectorConstraintPanel } from "@pixerate/editor/vector";
|
|
1825
1856
|
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1826
1857
|
var buttonClass7 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40";
|
|
@@ -1829,8 +1860,8 @@ var labelClass6 = "w-16 text-[11px] font-medium uppercase tracking-wide text-mut
|
|
|
1829
1860
|
function VectorConstraintsPanel({ controller, className }) {
|
|
1830
1861
|
const state = useVectorEditorState(controller);
|
|
1831
1862
|
const panel = getVectorConstraintPanel(state);
|
|
1832
|
-
const [error, setError] =
|
|
1833
|
-
const [param, setParam] =
|
|
1863
|
+
const [error, setError] = useState5(null);
|
|
1864
|
+
const [param, setParam] = useState5({ name: "", value: "" });
|
|
1834
1865
|
const report = (r) => setError(r.ok ? null : r.message ?? null);
|
|
1835
1866
|
const add = (a) => report(controller.addConstraint({ kind: a.kind, refs: a.refs }));
|
|
1836
1867
|
if (!panel.actions.length && !panel.constraints.length && !state.document.constraints?.length && state.tool !== "direct") return null;
|
|
@@ -2127,15 +2158,15 @@ function VectorConnectorPanel({ controller, className }) {
|
|
|
2127
2158
|
}
|
|
2128
2159
|
|
|
2129
2160
|
// src/vector/VectorShadingPanel.tsx
|
|
2130
|
-
import { useState as
|
|
2161
|
+
import { useState as useState6 } from "react";
|
|
2131
2162
|
import { isVectorFreeformGradient, isVectorMeshGradient, vectorPaintToHex as vectorPaintToHex4 } from "@pixerate/editor/vector";
|
|
2132
2163
|
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2133
2164
|
var buttonClass11 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40";
|
|
2134
2165
|
var numberClass6 = "h-7 w-12 rounded border border-border bg-background px-1.5 text-xs";
|
|
2135
2166
|
function VectorShadingPanel({ controller, className }) {
|
|
2136
2167
|
const state = useVectorEditorState(controller);
|
|
2137
|
-
const [rows, setRows] =
|
|
2138
|
-
const [columns, setColumns] =
|
|
2168
|
+
const [rows, setRows] = useState6(2);
|
|
2169
|
+
const [columns, setColumns] = useState6(2);
|
|
2139
2170
|
const path = state.selection.map((id) => controller.getNode(id)).find((n) => n?.type === "path");
|
|
2140
2171
|
if (!path) return null;
|
|
2141
2172
|
const fill = path.fill;
|
|
@@ -2179,7 +2210,7 @@ function VectorShadingPanel({ controller, className }) {
|
|
|
2179
2210
|
}
|
|
2180
2211
|
|
|
2181
2212
|
// src/vector/VectorTracePanel.tsx
|
|
2182
|
-
import { useRef as useRef4, useState as
|
|
2213
|
+
import { useRef as useRef4, useState as useState7 } from "react";
|
|
2183
2214
|
import { VECTOR_STYLIZE_LABELS, VECTOR_STYLIZE_STYLES } from "@pixerate/editor/vector";
|
|
2184
2215
|
import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2185
2216
|
var buttonClass12 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40";
|
|
@@ -2199,9 +2230,9 @@ async function filePixels(file, max = 1e6) {
|
|
|
2199
2230
|
}
|
|
2200
2231
|
function VectorTracePanel({ controller, className }) {
|
|
2201
2232
|
const input = useRef4(null);
|
|
2202
|
-
const [mode, setMode] =
|
|
2203
|
-
const [colors, setColors] =
|
|
2204
|
-
const [message, setMessage] =
|
|
2233
|
+
const [mode, setMode] = useState7("threshold");
|
|
2234
|
+
const [colors, setColors] = useState7(6);
|
|
2235
|
+
const [message, setMessage] = useState7(null);
|
|
2205
2236
|
const trace = async (file) => {
|
|
2206
2237
|
try {
|
|
2207
2238
|
const pixels = await filePixels(file);
|
|
@@ -2281,7 +2312,7 @@ function VectorSymmetryPanel({ controller, className }) {
|
|
|
2281
2312
|
}
|
|
2282
2313
|
|
|
2283
2314
|
// src/vector/VectorPerspectivePanel.tsx
|
|
2284
|
-
import
|
|
2315
|
+
import React10 from "react";
|
|
2285
2316
|
import { vectorPerspectivePlanes, vectorPerspectivePreset } from "@pixerate/editor/vector";
|
|
2286
2317
|
import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2287
2318
|
var buttonClass14 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40 aria-pressed:bg-primary aria-pressed:text-primary-foreground";
|
|
@@ -2291,7 +2322,7 @@ function VectorPerspectivePanel({ controller, className }) {
|
|
|
2291
2322
|
const state = useVectorEditorState(controller);
|
|
2292
2323
|
const grid = state.document.perspective ?? null;
|
|
2293
2324
|
const planes = grid ? vectorPerspectivePlanes(grid) : [];
|
|
2294
|
-
const [attachTo, setAttachTo] =
|
|
2325
|
+
const [attachTo, setAttachTo] = React10.useState("");
|
|
2295
2326
|
const target = (state.perspectivePlane ?? attachTo) || planes[0];
|
|
2296
2327
|
const add = (n) => controller.setPerspective(vectorPerspectivePreset(n, state.document.width, state.document.height));
|
|
2297
2328
|
return /* @__PURE__ */ jsxs16("div", { className: `space-y-2 ${className ?? ""}`, "data-vector-perspective-panel": "", "aria-label": "Perspective", children: [
|
|
@@ -2580,7 +2611,7 @@ function VectorToolbar({
|
|
|
2580
2611
|
const editing = state.editing;
|
|
2581
2612
|
const groupSelected = state.selection.some((id) => controller.getNode(id)?.type === "group");
|
|
2582
2613
|
const maskSelected = state.selection.some((id) => isVectorMaskGroup(controller.getNode(id)));
|
|
2583
|
-
const [live, setLive] =
|
|
2614
|
+
const [live, setLive] = React11.useState(false);
|
|
2584
2615
|
const booleanDisabled = live ? count < 1 : count < 2;
|
|
2585
2616
|
const act = (label, title, run, disabled = false) => /* @__PURE__ */ jsx19("button", { type: "button", className: buttonClass16, title, "aria-label": title, disabled, onClick: () => void run(), children: label }, label);
|
|
2586
2617
|
return /* @__PURE__ */ jsxs19("div", { role: "toolbar", "aria-label": "Vector tools", className: `flex flex-wrap items-center gap-1 ${className ?? ""}`, children: [
|
|
@@ -3085,14 +3116,14 @@ function VectorStylePanel({ controller, className }) {
|
|
|
3085
3116
|
}
|
|
3086
3117
|
|
|
3087
3118
|
// src/vector/VectorProviderEffectsPanel.tsx
|
|
3088
|
-
import { useState as
|
|
3119
|
+
import { useState as useState8, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
3089
3120
|
import { Fragment as Fragment7, jsx as jsx20, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3090
3121
|
var btn = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
3091
3122
|
function Controls({ controller, group }) {
|
|
3092
3123
|
const provider = controller.effectsProvider;
|
|
3093
3124
|
const tag = group.providerEffect;
|
|
3094
3125
|
const { description, error } = useEffectDescription(provider, tag.effect);
|
|
3095
|
-
const [message, setMessage] =
|
|
3126
|
+
const [message, setMessage] = useState8(null);
|
|
3096
3127
|
const run = (work) => void work.then(() => setMessage(null), (e) => setMessage(e instanceof Error ? e.message : String(e)));
|
|
3097
3128
|
if (!provider) return /* @__PURE__ */ jsx20("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider: the shapes are kept as they are." });
|
|
3098
3129
|
if (error) return /* @__PURE__ */ jsx20("p", { className: "text-[11px] text-amber-500", children: error });
|
|
@@ -3118,8 +3149,8 @@ function VectorProviderEffectsPanel({ controller, className = "" }) {
|
|
|
3118
3149
|
() => controller.effects.provider,
|
|
3119
3150
|
() => controller.effects.provider
|
|
3120
3151
|
);
|
|
3121
|
-
const [browse, setBrowse] =
|
|
3122
|
-
const [message, setMessage] =
|
|
3152
|
+
const [browse, setBrowse] = useState8(false);
|
|
3153
|
+
const [message, setMessage] = useState8(null);
|
|
3123
3154
|
void state;
|
|
3124
3155
|
const groups = controller.vectorEffectGroups();
|
|
3125
3156
|
const selected = groups.filter((g) => state.selection.includes(g.id));
|
|
@@ -3168,7 +3199,7 @@ function VectorEditor({ controller, tools, showStylePanel = true, height = 520,
|
|
|
3168
3199
|
}
|
|
3169
3200
|
|
|
3170
3201
|
// src/vector/VectorGeneratePanel.tsx
|
|
3171
|
-
import { useState as
|
|
3202
|
+
import { useState as useState9 } from "react";
|
|
3172
3203
|
import { VECTOR_GENERATED_IMAGE_AS, generateVectorArt, vectorArtModels } from "@pixerate/editor/vector";
|
|
3173
3204
|
import { jsx as jsx22, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3174
3205
|
var buttonClass17 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40";
|
|
@@ -3176,11 +3207,11 @@ var selectClass15 = "h-7 min-w-0 flex-1 rounded border border-border bg-backgrou
|
|
|
3176
3207
|
var AS_LABELS = { color: "Traced in colour", threshold: "Traced in one colour", mosaic: "Mosaic", halftone: "Halftone", lowPoly: "Low poly", hatch: "Engraving" };
|
|
3177
3208
|
function VectorGeneratePanel({ controller, models, generate, className }) {
|
|
3178
3209
|
const usable = vectorArtModels(models);
|
|
3179
|
-
const [prompt, setPrompt] =
|
|
3180
|
-
const [model, setModel] =
|
|
3181
|
-
const [as, setAs] =
|
|
3182
|
-
const [busy, setBusy] =
|
|
3183
|
-
const [message, setMessage] =
|
|
3210
|
+
const [prompt, setPrompt] = useState9("");
|
|
3211
|
+
const [model, setModel] = useState9("");
|
|
3212
|
+
const [as, setAs] = useState9("color");
|
|
3213
|
+
const [busy, setBusy] = useState9(false);
|
|
3214
|
+
const [message, setMessage] = useState9(null);
|
|
3184
3215
|
const chosen = usable.find((m) => m.id === model) ?? usable[0];
|
|
3185
3216
|
if (!usable.length) return null;
|
|
3186
3217
|
const run = async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.181.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -277,7 +277,7 @@
|
|
|
277
277
|
"dependencies": {},
|
|
278
278
|
"peerDependencies": {
|
|
279
279
|
"@dagrejs/dagre": "^1.1.8",
|
|
280
|
-
"@pixerate/editor": ">=0.
|
|
280
|
+
"@pixerate/editor": ">=0.265.0 <1.0.0-0",
|
|
281
281
|
"@tiptap/core": "^2.27.3",
|
|
282
282
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
283
283
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
@@ -328,7 +328,7 @@
|
|
|
328
328
|
"tsup": "^9.0.0",
|
|
329
329
|
"typescript": "^5.7.3",
|
|
330
330
|
"vitest": "^5.0.5",
|
|
331
|
-
"@pixerate/editor": "0.
|
|
331
|
+
"@pixerate/editor": "0.265.0"
|
|
332
332
|
},
|
|
333
333
|
"scripts": {
|
|
334
334
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|
package/dist/chunk-62FMEDGG.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// src/brushes/BrushLibraryBrowser.tsx
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { brushLibraryGroups } from "@pixerate/editor/brushes";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
var Thumbnail = ({ image, label, style }) => {
|
|
6
|
-
const ref = useRef(null);
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
const canvas = ref.current;
|
|
9
|
-
const ctx = canvas?.getContext("2d");
|
|
10
|
-
if (!canvas || !ctx || !image || typeof image === "string" || typeof ctx.createImageData !== "function") return;
|
|
11
|
-
canvas.width = image.width;
|
|
12
|
-
canvas.height = image.height;
|
|
13
|
-
const img = ctx.createImageData(image.width, image.height);
|
|
14
|
-
img.data.set(image.data);
|
|
15
|
-
ctx.putImageData(img, 0, 0);
|
|
16
|
-
}, [image]);
|
|
17
|
-
if (typeof image === "string") return /* @__PURE__ */ jsx("img", { src: image, alt: label, className: "rounded object-contain", style });
|
|
18
|
-
return /* @__PURE__ */ jsx("canvas", { ref, role: "img", "aria-label": label, className: "rounded", style, width: image?.width, height: image?.height });
|
|
19
|
-
};
|
|
20
|
-
var BrushLibraryBrowser = ({ entries, activeId, onSelect, profile, thumbnail, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
|
|
21
|
-
const [text, setText] = useState("");
|
|
22
|
-
const groups = useMemo(() => brushLibraryGroups(entries, { text, profile }), [entries, text, profile]);
|
|
23
|
-
return /* @__PURE__ */ jsxs("div", { className: `flex flex-col gap-1 ${className ?? ""}`, "data-testid": "brush-library", children: [
|
|
24
|
-
/* @__PURE__ */ jsx("input", { type: "search", value: text, placeholder: "Find a brush", "aria-label": "Find a brush", onChange: (e) => setText(e.target.value), className: "rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
25
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", role: "listbox", "aria-label": "Brushes", children: [
|
|
26
|
-
groups.map((g) => /* @__PURE__ */ jsxs("div", { role: "group", "aria-label": g.title, className: "flex flex-col gap-0.5", children: [
|
|
27
|
-
/* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wide text-slate-500", children: g.title }),
|
|
28
|
-
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-1", children: g.varieties.flatMap(
|
|
29
|
-
(v) => v.entries.map((e) => /* @__PURE__ */ jsxs(
|
|
30
|
-
"button",
|
|
31
|
-
{
|
|
32
|
-
type: "button",
|
|
33
|
-
role: "option",
|
|
34
|
-
"aria-selected": activeId === e.brush.id,
|
|
35
|
-
title: [e.brush.name, v.title.toLowerCase() === e.brush.name.toLowerCase() ? "" : v.title, e.builtin ? "" : "saved"].filter(Boolean).join(" \xB7 "),
|
|
36
|
-
className: `flex flex-col items-start gap-0.5 rounded p-1 text-left ${activeId === e.brush.id ? "bg-indigo-600/30 ring-1 ring-indigo-500" : "bg-slate-900 hover:bg-slate-800"}`,
|
|
37
|
-
onClick: () => onSelect(e.brush.id),
|
|
38
|
-
children: [
|
|
39
|
-
thumbnail && /* @__PURE__ */ jsx(Thumbnail, { image: thumbnail(e.brush.id) ?? null, label: `${e.brush.name} thumbnail`, style: { width: "100%", aspectRatio: `${thumbnailWidth} / ${thumbnailHeight}` } }),
|
|
40
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[10px] text-slate-300", children: e.brush.name })
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
e.brush.id
|
|
44
|
-
))
|
|
45
|
-
) })
|
|
46
|
-
] }, g.id)),
|
|
47
|
-
!groups.length && /* @__PURE__ */ jsx("span", { className: "text-slate-500", children: "No brush matches." })
|
|
48
|
-
] })
|
|
49
|
-
] });
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export {
|
|
53
|
-
BrushLibraryBrowser
|
|
54
|
-
};
|
package/dist/chunk-PQK2UMAY.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// src/brushes/useBrushLibrary.ts
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
function useBrushLibrary(library, filter = {}) {
|
|
4
|
-
const [entries, setEntries] = useState([]);
|
|
5
|
-
const { profile, ...rest } = filter;
|
|
6
|
-
const key = `${profile?.id ?? ""}:${JSON.stringify(rest)}`;
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
if (!library) return;
|
|
9
|
-
let live = true;
|
|
10
|
-
const read = () => void library.list(filter).then((list) => live && setEntries(list), () => void 0);
|
|
11
|
-
read();
|
|
12
|
-
const unsubscribe = library.subscribe(read);
|
|
13
|
-
return () => {
|
|
14
|
-
live = false;
|
|
15
|
-
unsubscribe();
|
|
16
|
-
};
|
|
17
|
-
}, [library, key]);
|
|
18
|
-
return entries;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
useBrushLibrary
|
|
23
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type Brush, type BrushHostProfile } from '@pixerate/editor/brushes';
|
|
3
|
-
type Pixels = {
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
data: Uint8ClampedArray;
|
|
7
|
-
};
|
|
8
|
-
export interface BrushEditorProps {
|
|
9
|
-
/** The brush being edited, as facets. */
|
|
10
|
-
brush: Brush;
|
|
11
|
-
/** What the host renders (default the paint editor): other controls are left out. */
|
|
12
|
-
profile?: BrushHostProfile;
|
|
13
|
-
/** Called with the whole brush after each change (normalised). */
|
|
14
|
-
onChange: (brush: Brush) => void;
|
|
15
|
-
/** A live preview stroke of `brush` (e.g. `controller.brushThumbnail`). */
|
|
16
|
-
preview?: Pixels | null;
|
|
17
|
-
/** With it, a name field and "Save brush" save the brush under that name. */
|
|
18
|
-
onSaveAs?: (name: string) => unknown;
|
|
19
|
-
/** Extra controls a host adds to a section (e.g. the sticker picker for stamps). */
|
|
20
|
-
renderExtra?: (section: string) => React.ReactNode;
|
|
21
|
-
className?: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Edits a brush by its facets (`brushEditorSections`): Medium, Shape, Marks, Feel, Behaviour,
|
|
25
|
-
* Light, Motion and Colour, each control a facet, with a live preview stroke and "Save as". Only
|
|
26
|
-
* what the host profile renders is shown; settings it paints without carry a note.
|
|
27
|
-
*/
|
|
28
|
-
export declare const BrushEditor: React.FC<BrushEditorProps>;
|
|
29
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type Brush, type BrushHostProfile } from '@pixerate/editor/brushes';
|
|
3
|
-
type Pixels = {
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
data: Uint8ClampedArray;
|
|
7
|
-
};
|
|
8
|
-
export interface BrushEditorProps {
|
|
9
|
-
/** The brush being edited, as facets. */
|
|
10
|
-
brush: Brush;
|
|
11
|
-
/** What the host renders (default the paint editor): other controls are left out. */
|
|
12
|
-
profile?: BrushHostProfile;
|
|
13
|
-
/** Called with the whole brush after each change (normalised). */
|
|
14
|
-
onChange: (brush: Brush) => void;
|
|
15
|
-
/** A live preview stroke of `brush` (e.g. `controller.brushThumbnail`). */
|
|
16
|
-
preview?: Pixels | null;
|
|
17
|
-
/** With it, a name field and "Save brush" save the brush under that name. */
|
|
18
|
-
onSaveAs?: (name: string) => unknown;
|
|
19
|
-
/** Extra controls a host adds to a section (e.g. the sticker picker for stamps). */
|
|
20
|
-
renderExtra?: (section: string) => React.ReactNode;
|
|
21
|
-
className?: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Edits a brush by its facets (`brushEditorSections`): Medium, Shape, Marks, Feel, Behaviour,
|
|
25
|
-
* Light, Motion and Colour, each control a facet, with a live preview stroke and "Save as". Only
|
|
26
|
-
* what the host profile renders is shown; settings it paints without carry a note.
|
|
27
|
-
*/
|
|
28
|
-
export declare const BrushEditor: React.FC<BrushEditorProps>;
|
|
29
|
-
export {};
|