@pixerate/editor-react 0.137.0 → 0.139.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/{chunk-6GWWDUEF.js → chunk-7M3PJKFN.js} +56 -22
- package/dist/image-editor/index.cjs +47 -13
- package/dist/image-editor/index.js +1 -1
- package/dist/index.cjs +47 -13
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -190,7 +190,7 @@ function useImageEffectsTools(registry, controller, options = {}) {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
// src/image-editor/ImageEditor.tsx
|
|
193
|
-
import React17, { useRef as
|
|
193
|
+
import React17, { useRef as useRef10, useEffect as useEffect15, useState as useState18 } from "react";
|
|
194
194
|
import {
|
|
195
195
|
normalizeProcessVersion,
|
|
196
196
|
LATEST_PROCESS_VERSION,
|
|
@@ -2663,7 +2663,7 @@ var ColorProfilePanel = ({ controller, className }) => {
|
|
|
2663
2663
|
};
|
|
2664
2664
|
|
|
2665
2665
|
// src/image-editor/SelectionOptionsBar.tsx
|
|
2666
|
-
import { useState as useState12 } from "react";
|
|
2666
|
+
import { useRef as useRef8, useState as useState12 } from "react";
|
|
2667
2667
|
import {
|
|
2668
2668
|
COLOR_RANGE_PRESETS,
|
|
2669
2669
|
COLOR_RANGE_PRESET_LABELS,
|
|
@@ -2759,7 +2759,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
2759
2759
|
panFrom.current = null;
|
|
2760
2760
|
session.end();
|
|
2761
2761
|
};
|
|
2762
|
-
const toLayer = settings.output
|
|
2762
|
+
const toLayer = settings.output !== "selection" && settings.output !== "layer-mask";
|
|
2763
2763
|
const brushTool = settings.tool === "quick-select" || settings.tool === "brush" || settings.tool === "refine-brush";
|
|
2764
2764
|
return /* @__PURE__ */ jsxs13(
|
|
2765
2765
|
"div",
|
|
@@ -2799,7 +2799,8 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
2799
2799
|
/* @__PURE__ */ jsxs13("span", { className: "font-mono text-muted-foreground", children: [
|
|
2800
2800
|
Math.round(zoom * 100),
|
|
2801
2801
|
"%"
|
|
2802
|
-
] })
|
|
2802
|
+
] }),
|
|
2803
|
+
session.computing && /* @__PURE__ */ jsx15("span", { role: "status", className: "text-muted-foreground", children: "Updating preview\u2026" })
|
|
2803
2804
|
] }),
|
|
2804
2805
|
/* @__PURE__ */ jsx15("div", { className: "flex-1 overflow-hidden flex items-center justify-center bg-muted/30", children: /* @__PURE__ */ jsx15(
|
|
2805
2806
|
"canvas",
|
|
@@ -2895,7 +2896,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
2895
2896
|
/* @__PURE__ */ jsxs13("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
2896
2897
|
/* @__PURE__ */ jsxs13("span", { children: [
|
|
2897
2898
|
"Decontaminate Colors",
|
|
2898
|
-
toLayer ? "" : " (new layer outputs)"
|
|
2899
|
+
toLayer ? "" : " (new layer or document outputs)"
|
|
2899
2900
|
] }),
|
|
2900
2901
|
/* @__PURE__ */ jsxs13("span", { className: "font-mono", children: [
|
|
2901
2902
|
settings.decontaminate,
|
|
@@ -2911,7 +2912,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
2911
2912
|
{
|
|
2912
2913
|
label: "Output to",
|
|
2913
2914
|
value: settings.output,
|
|
2914
|
-
options: REFINE_OUTPUTS.map((o) => ({ value: o.id, label: o.label })),
|
|
2915
|
+
options: REFINE_OUTPUTS.filter((o) => !o.needsDocuments || controller.canOpenDocuments).map((o) => ({ value: o.id, label: o.label })),
|
|
2915
2916
|
onChange: (v) => set({ output: v })
|
|
2916
2917
|
}
|
|
2917
2918
|
)
|
|
@@ -2999,6 +3000,19 @@ var SelectionOptionsBar = ({
|
|
|
2999
3000
|
setRangeStatus(err instanceof Error ? err.message : String(err));
|
|
3000
3001
|
}
|
|
3001
3002
|
};
|
|
3003
|
+
const [task, setTask] = useState12(null);
|
|
3004
|
+
const taskAbort = useRef8(null);
|
|
3005
|
+
const tracked = () => {
|
|
3006
|
+
const abort = new AbortController();
|
|
3007
|
+
taskAbort.current = abort;
|
|
3008
|
+
setTask({ stage: "Starting", fraction: 0 });
|
|
3009
|
+
return { signal: abort.signal, onProgress: (fraction, stage) => setTask({ stage, fraction }) };
|
|
3010
|
+
};
|
|
3011
|
+
const untrack = () => {
|
|
3012
|
+
taskAbort.current = null;
|
|
3013
|
+
setTask(null);
|
|
3014
|
+
};
|
|
3015
|
+
const failure = (err) => err?.name === "AbortError" ? "Cancelled." : err instanceof Error ? err.message : String(err);
|
|
3002
3016
|
const [subject, setSubject] = useState12("");
|
|
3003
3017
|
const [segmenting, setSegmenting] = useState12(false);
|
|
3004
3018
|
const [subjectStatus, setSubjectStatus] = useState12(null);
|
|
@@ -3009,11 +3023,12 @@ var SelectionOptionsBar = ({
|
|
|
3009
3023
|
setSegmenting(true);
|
|
3010
3024
|
setSubjectStatus(null);
|
|
3011
3025
|
try {
|
|
3012
|
-
const { segments, method, note } = await controller.selectSubject(canSegment ? target : "", { mode: options.mode });
|
|
3026
|
+
const { segments, method, note } = await controller.selectSubject(canSegment ? target : "", { mode: options.mode, ...tracked() });
|
|
3013
3027
|
setSubjectStatus(segments.length ? null : method === "saliency" ? note ?? "Nothing stands out from the background." : `Nothing matching \u201C${target}\u201D was found.`);
|
|
3014
3028
|
} catch (err) {
|
|
3015
|
-
setSubjectStatus(
|
|
3029
|
+
setSubjectStatus(failure(err));
|
|
3016
3030
|
} finally {
|
|
3031
|
+
untrack();
|
|
3017
3032
|
setSegmenting(false);
|
|
3018
3033
|
}
|
|
3019
3034
|
};
|
|
@@ -3025,11 +3040,12 @@ var SelectionOptionsBar = ({
|
|
|
3025
3040
|
setSkying(true);
|
|
3026
3041
|
setSkyStatus(null);
|
|
3027
3042
|
try {
|
|
3028
|
-
const { note } = await controller.selectSky({ mode: options.mode });
|
|
3043
|
+
const { note } = await controller.selectSky({ mode: options.mode, ...tracked() });
|
|
3029
3044
|
setSkyStatus(note ?? null);
|
|
3030
3045
|
} catch (err) {
|
|
3031
|
-
setSkyStatus(
|
|
3046
|
+
setSkyStatus(failure(err));
|
|
3032
3047
|
} finally {
|
|
3048
|
+
untrack();
|
|
3033
3049
|
setSkying(false);
|
|
3034
3050
|
}
|
|
3035
3051
|
};
|
|
@@ -3044,12 +3060,14 @@ var SelectionOptionsBar = ({
|
|
|
3044
3060
|
range: options.focusRange ?? 50,
|
|
3045
3061
|
noise: options.focusNoise ?? 0,
|
|
3046
3062
|
softness: options.focusSoftness ?? 4,
|
|
3047
|
-
mode: options.mode
|
|
3063
|
+
mode: options.mode,
|
|
3064
|
+
...tracked()
|
|
3048
3065
|
});
|
|
3049
3066
|
setFocusStatus(selection2 ? null : "No part of the image stands out as in focus.");
|
|
3050
3067
|
} catch (err) {
|
|
3051
|
-
setFocusStatus(
|
|
3068
|
+
setFocusStatus(failure(err));
|
|
3052
3069
|
} finally {
|
|
3070
|
+
untrack();
|
|
3053
3071
|
setFocusing(false);
|
|
3054
3072
|
}
|
|
3055
3073
|
};
|
|
@@ -3313,6 +3331,22 @@ var SelectionOptionsBar = ({
|
|
|
3313
3331
|
]
|
|
3314
3332
|
}
|
|
3315
3333
|
),
|
|
3334
|
+
task && /* @__PURE__ */ jsxs14("div", { "data-testid": "selection-progress", className: "flex items-center gap-2", children: [
|
|
3335
|
+
/* @__PURE__ */ jsx16(
|
|
3336
|
+
"div",
|
|
3337
|
+
{
|
|
3338
|
+
role: "progressbar",
|
|
3339
|
+
"aria-label": task.stage,
|
|
3340
|
+
"aria-valuemin": 0,
|
|
3341
|
+
"aria-valuemax": 100,
|
|
3342
|
+
"aria-valuenow": Math.round(task.fraction * 100),
|
|
3343
|
+
className: "flex-1 h-1.5 rounded bg-muted overflow-hidden",
|
|
3344
|
+
children: /* @__PURE__ */ jsx16("div", { className: "h-full bg-primary", style: { width: `${Math.round(task.fraction * 100)}%` } })
|
|
3345
|
+
}
|
|
3346
|
+
),
|
|
3347
|
+
/* @__PURE__ */ jsx16("span", { className: "text-muted-foreground", children: task.stage }),
|
|
3348
|
+
/* @__PURE__ */ jsx16("button", { type: "button", className: btn(false), onClick: () => taskAbort.current?.abort(), children: "Cancel" })
|
|
3349
|
+
] }),
|
|
3316
3350
|
/* @__PURE__ */ jsx16("button", { type: "button", className: btn(false), onClick: () => setWorkspace(true), children: "Select and Mask\u2026" }),
|
|
3317
3351
|
workspace && /* @__PURE__ */ jsx16(SelectAndMaskWorkspace, { controller, onClose: () => setWorkspace(false) }),
|
|
3318
3352
|
/* @__PURE__ */ jsxs14("div", { "data-testid": "select-sky", className: "flex flex-col gap-1", children: [
|
|
@@ -3456,7 +3490,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
3456
3490
|
const [decontaminate, setDecontaminate] = useState13(0);
|
|
3457
3491
|
const [objectAware, setObjectAware] = useState13(false);
|
|
3458
3492
|
const canObject = Boolean(controller.segmentationProvider);
|
|
3459
|
-
const toLayer = output
|
|
3493
|
+
const toLayer = output !== "selection" && output !== "layer-mask";
|
|
3460
3494
|
const sel = selection === void 0 ? controller.getSelection() : selection;
|
|
3461
3495
|
const list = layers ?? controller.getAdjustmentLayers();
|
|
3462
3496
|
const target = list.find((l) => l.id === layerId) ?? list[list.length - 1];
|
|
@@ -3515,7 +3549,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
3515
3549
|
value: output,
|
|
3516
3550
|
onChange: (e) => setOutput(e.target.value),
|
|
3517
3551
|
className: "flex-1 bg-background border border-border rounded px-1 py-1 text-foreground",
|
|
3518
|
-
children: REFINE_OUTPUTS2.map((o) => /* @__PURE__ */ jsx17("option", { value: o.id, children: o.label }, o.id))
|
|
3552
|
+
children: REFINE_OUTPUTS2.filter((o) => !o.needsDocuments || controller.canOpenDocuments).map((o) => /* @__PURE__ */ jsx17("option", { value: o.id, children: o.label }, o.id))
|
|
3519
3553
|
}
|
|
3520
3554
|
)
|
|
3521
3555
|
] }),
|
|
@@ -3523,7 +3557,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
3523
3557
|
/* @__PURE__ */ jsxs15("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
3524
3558
|
/* @__PURE__ */ jsxs15("span", { children: [
|
|
3525
3559
|
"Decontaminate colors",
|
|
3526
|
-
toLayer ? "" : " (new layer outputs)"
|
|
3560
|
+
toLayer ? "" : " (new layer or document outputs)"
|
|
3527
3561
|
] }),
|
|
3528
3562
|
/* @__PURE__ */ jsxs15("span", { className: "font-mono", children: [
|
|
3529
3563
|
decontaminate,
|
|
@@ -3643,12 +3677,12 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
3643
3677
|
};
|
|
3644
3678
|
|
|
3645
3679
|
// src/image-editor/ChannelsPanel.tsx
|
|
3646
|
-
import { useEffect as useEffect11, useRef as
|
|
3680
|
+
import { useEffect as useEffect11, useRef as useRef9, useState as useState14 } from "react";
|
|
3647
3681
|
import { MASK_FILE_ACCEPT, channelThumbnail, downloadMaskImage, openMaskFile, selectionModeFromModifiers } from "@pixerate/editor/image-editor";
|
|
3648
3682
|
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3649
3683
|
var btn2 = (on = false) => `px-2 py-1 rounded-md border text-[11px] transition-colors disabled:opacity-40 ${on ? "bg-primary border-primary text-primary-foreground" : "bg-background border-border text-foreground hover:bg-accent hover:text-accent-foreground"}`;
|
|
3650
3684
|
var ChannelThumb = ({ channel, size }) => {
|
|
3651
|
-
const ref =
|
|
3685
|
+
const ref = useRef9(null);
|
|
3652
3686
|
useEffect11(() => {
|
|
3653
3687
|
const canvas = ref.current;
|
|
3654
3688
|
const ctx = canvas?.getContext("2d");
|
|
@@ -3668,7 +3702,7 @@ var ChannelsPanel = ({ controller, thumbnailSize = 32, className = "" }) => {
|
|
|
3668
3702
|
const [activeId, setActiveId] = useState14(null);
|
|
3669
3703
|
const [renaming, setRenaming] = useState14(null);
|
|
3670
3704
|
const [error, setError] = useState14(null);
|
|
3671
|
-
const fileInput =
|
|
3705
|
+
const fileInput = useRef9(null);
|
|
3672
3706
|
const channels = controller.getChannels();
|
|
3673
3707
|
const active = channels.find((c) => c.id === activeId) ?? null;
|
|
3674
3708
|
const hasSelection = Boolean(controller.getSelection());
|
|
@@ -4167,9 +4201,9 @@ var ImageEditor = ({
|
|
|
4167
4201
|
});
|
|
4168
4202
|
const legacyProcess = normalizeProcessVersion(state.adjustments.process) < LATEST_PROCESS_VERSION;
|
|
4169
4203
|
const [activeTab, setActiveTab] = useState18("crop");
|
|
4170
|
-
const rootRef =
|
|
4204
|
+
const rootRef = useRef10(null);
|
|
4171
4205
|
const canvasMode = activeTab === "crop" || activeTab === "select" || activeTab === "paint" || activeTab === "annotate" ? activeTab : "none";
|
|
4172
|
-
const activeTabRef =
|
|
4206
|
+
const activeTabRef = useRef10(activeTab);
|
|
4173
4207
|
activeTabRef.current = activeTab;
|
|
4174
4208
|
const openPanel = async (ref) => {
|
|
4175
4209
|
if (ref.kind !== "panel" || activeTabRef.current === ref.id) return;
|
|
@@ -4190,8 +4224,8 @@ var ImageEditor = ({
|
|
|
4190
4224
|
else setShapeTypeError(message);
|
|
4191
4225
|
};
|
|
4192
4226
|
const finishTyping = () => setTypeSession(null);
|
|
4193
|
-
const transformToolRef =
|
|
4194
|
-
const transformControllerRef =
|
|
4227
|
+
const transformToolRef = useRef10(null);
|
|
4228
|
+
const transformControllerRef = useRef10(controller);
|
|
4195
4229
|
if (!transformToolRef.current || transformControllerRef.current !== controller) {
|
|
4196
4230
|
transformToolRef.current?.cancel();
|
|
4197
4231
|
transformToolRef.current = new FreeTransformTool2(controller, {
|
|
@@ -4691,7 +4691,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
4691
4691
|
panFrom.current = null;
|
|
4692
4692
|
session.end();
|
|
4693
4693
|
};
|
|
4694
|
-
const toLayer = settings.output
|
|
4694
|
+
const toLayer = settings.output !== "selection" && settings.output !== "layer-mask";
|
|
4695
4695
|
const brushTool = settings.tool === "quick-select" || settings.tool === "brush" || settings.tool === "refine-brush";
|
|
4696
4696
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
4697
4697
|
"div",
|
|
@@ -4731,7 +4731,8 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
4731
4731
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "font-mono text-muted-foreground", children: [
|
|
4732
4732
|
Math.round(zoom * 100),
|
|
4733
4733
|
"%"
|
|
4734
|
-
] })
|
|
4734
|
+
] }),
|
|
4735
|
+
session.computing && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { role: "status", className: "text-muted-foreground", children: "Updating preview\u2026" })
|
|
4735
4736
|
] }),
|
|
4736
4737
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex-1 overflow-hidden flex items-center justify-center bg-muted/30", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4737
4738
|
"canvas",
|
|
@@ -4827,7 +4828,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
4827
4828
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
4828
4829
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { children: [
|
|
4829
4830
|
"Decontaminate Colors",
|
|
4830
|
-
toLayer ? "" : " (new layer outputs)"
|
|
4831
|
+
toLayer ? "" : " (new layer or document outputs)"
|
|
4831
4832
|
] }),
|
|
4832
4833
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "font-mono", children: [
|
|
4833
4834
|
settings.decontaminate,
|
|
@@ -4843,7 +4844,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
4843
4844
|
{
|
|
4844
4845
|
label: "Output to",
|
|
4845
4846
|
value: settings.output,
|
|
4846
|
-
options: import_image_editor14.REFINE_OUTPUTS.map((o) => ({ value: o.id, label: o.label })),
|
|
4847
|
+
options: import_image_editor14.REFINE_OUTPUTS.filter((o) => !o.needsDocuments || controller.canOpenDocuments).map((o) => ({ value: o.id, label: o.label })),
|
|
4847
4848
|
onChange: (v) => set({ output: v })
|
|
4848
4849
|
}
|
|
4849
4850
|
)
|
|
@@ -4931,6 +4932,19 @@ var SelectionOptionsBar = ({
|
|
|
4931
4932
|
setRangeStatus(err instanceof Error ? err.message : String(err));
|
|
4932
4933
|
}
|
|
4933
4934
|
};
|
|
4935
|
+
const [task, setTask] = (0, import_react26.useState)(null);
|
|
4936
|
+
const taskAbort = (0, import_react26.useRef)(null);
|
|
4937
|
+
const tracked = () => {
|
|
4938
|
+
const abort = new AbortController();
|
|
4939
|
+
taskAbort.current = abort;
|
|
4940
|
+
setTask({ stage: "Starting", fraction: 0 });
|
|
4941
|
+
return { signal: abort.signal, onProgress: (fraction, stage) => setTask({ stage, fraction }) };
|
|
4942
|
+
};
|
|
4943
|
+
const untrack = () => {
|
|
4944
|
+
taskAbort.current = null;
|
|
4945
|
+
setTask(null);
|
|
4946
|
+
};
|
|
4947
|
+
const failure = (err) => err?.name === "AbortError" ? "Cancelled." : err instanceof Error ? err.message : String(err);
|
|
4934
4948
|
const [subject, setSubject] = (0, import_react26.useState)("");
|
|
4935
4949
|
const [segmenting, setSegmenting] = (0, import_react26.useState)(false);
|
|
4936
4950
|
const [subjectStatus, setSubjectStatus] = (0, import_react26.useState)(null);
|
|
@@ -4941,11 +4955,12 @@ var SelectionOptionsBar = ({
|
|
|
4941
4955
|
setSegmenting(true);
|
|
4942
4956
|
setSubjectStatus(null);
|
|
4943
4957
|
try {
|
|
4944
|
-
const { segments, method, note } = await controller.selectSubject(canSegment ? target : "", { mode: options.mode });
|
|
4958
|
+
const { segments, method, note } = await controller.selectSubject(canSegment ? target : "", { mode: options.mode, ...tracked() });
|
|
4945
4959
|
setSubjectStatus(segments.length ? null : method === "saliency" ? note ?? "Nothing stands out from the background." : `Nothing matching \u201C${target}\u201D was found.`);
|
|
4946
4960
|
} catch (err) {
|
|
4947
|
-
setSubjectStatus(
|
|
4961
|
+
setSubjectStatus(failure(err));
|
|
4948
4962
|
} finally {
|
|
4963
|
+
untrack();
|
|
4949
4964
|
setSegmenting(false);
|
|
4950
4965
|
}
|
|
4951
4966
|
};
|
|
@@ -4957,11 +4972,12 @@ var SelectionOptionsBar = ({
|
|
|
4957
4972
|
setSkying(true);
|
|
4958
4973
|
setSkyStatus(null);
|
|
4959
4974
|
try {
|
|
4960
|
-
const { note } = await controller.selectSky({ mode: options.mode });
|
|
4975
|
+
const { note } = await controller.selectSky({ mode: options.mode, ...tracked() });
|
|
4961
4976
|
setSkyStatus(note ?? null);
|
|
4962
4977
|
} catch (err) {
|
|
4963
|
-
setSkyStatus(
|
|
4978
|
+
setSkyStatus(failure(err));
|
|
4964
4979
|
} finally {
|
|
4980
|
+
untrack();
|
|
4965
4981
|
setSkying(false);
|
|
4966
4982
|
}
|
|
4967
4983
|
};
|
|
@@ -4976,12 +4992,14 @@ var SelectionOptionsBar = ({
|
|
|
4976
4992
|
range: options.focusRange ?? 50,
|
|
4977
4993
|
noise: options.focusNoise ?? 0,
|
|
4978
4994
|
softness: options.focusSoftness ?? 4,
|
|
4979
|
-
mode: options.mode
|
|
4995
|
+
mode: options.mode,
|
|
4996
|
+
...tracked()
|
|
4980
4997
|
});
|
|
4981
4998
|
setFocusStatus(selection2 ? null : "No part of the image stands out as in focus.");
|
|
4982
4999
|
} catch (err) {
|
|
4983
|
-
setFocusStatus(
|
|
5000
|
+
setFocusStatus(failure(err));
|
|
4984
5001
|
} finally {
|
|
5002
|
+
untrack();
|
|
4985
5003
|
setFocusing(false);
|
|
4986
5004
|
}
|
|
4987
5005
|
};
|
|
@@ -5245,6 +5263,22 @@ var SelectionOptionsBar = ({
|
|
|
5245
5263
|
]
|
|
5246
5264
|
}
|
|
5247
5265
|
),
|
|
5266
|
+
task && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { "data-testid": "selection-progress", className: "flex items-center gap-2", children: [
|
|
5267
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
5268
|
+
"div",
|
|
5269
|
+
{
|
|
5270
|
+
role: "progressbar",
|
|
5271
|
+
"aria-label": task.stage,
|
|
5272
|
+
"aria-valuemin": 0,
|
|
5273
|
+
"aria-valuemax": 100,
|
|
5274
|
+
"aria-valuenow": Math.round(task.fraction * 100),
|
|
5275
|
+
className: "flex-1 h-1.5 rounded bg-muted overflow-hidden",
|
|
5276
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "h-full bg-primary", style: { width: `${Math.round(task.fraction * 100)}%` } })
|
|
5277
|
+
}
|
|
5278
|
+
),
|
|
5279
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-muted-foreground", children: task.stage }),
|
|
5280
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", className: btn(false), onClick: () => taskAbort.current?.abort(), children: "Cancel" })
|
|
5281
|
+
] }),
|
|
5248
5282
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { type: "button", className: btn(false), onClick: () => setWorkspace(true), children: "Select and Mask\u2026" }),
|
|
5249
5283
|
workspace && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SelectAndMaskWorkspace, { controller, onClose: () => setWorkspace(false) }),
|
|
5250
5284
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { "data-testid": "select-sky", className: "flex flex-col gap-1", children: [
|
|
@@ -5382,7 +5416,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
5382
5416
|
const [decontaminate, setDecontaminate] = (0, import_react27.useState)(0);
|
|
5383
5417
|
const [objectAware, setObjectAware] = (0, import_react27.useState)(false);
|
|
5384
5418
|
const canObject = Boolean(controller.segmentationProvider);
|
|
5385
|
-
const toLayer = output
|
|
5419
|
+
const toLayer = output !== "selection" && output !== "layer-mask";
|
|
5386
5420
|
const sel = selection === void 0 ? controller.getSelection() : selection;
|
|
5387
5421
|
const list = layers ?? controller.getAdjustmentLayers();
|
|
5388
5422
|
const target = list.find((l) => l.id === layerId) ?? list[list.length - 1];
|
|
@@ -5441,7 +5475,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
5441
5475
|
value: output,
|
|
5442
5476
|
onChange: (e) => setOutput(e.target.value),
|
|
5443
5477
|
className: "flex-1 bg-background border border-border rounded px-1 py-1 text-foreground",
|
|
5444
|
-
children: import_image_editor16.REFINE_OUTPUTS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: o.id, children: o.label }, o.id))
|
|
5478
|
+
children: import_image_editor16.REFINE_OUTPUTS.filter((o) => !o.needsDocuments || controller.canOpenDocuments).map((o) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: o.id, children: o.label }, o.id))
|
|
5445
5479
|
}
|
|
5446
5480
|
)
|
|
5447
5481
|
] }),
|
|
@@ -5449,7 +5483,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
5449
5483
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
5450
5484
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { children: [
|
|
5451
5485
|
"Decontaminate colors",
|
|
5452
|
-
toLayer ? "" : " (new layer outputs)"
|
|
5486
|
+
toLayer ? "" : " (new layer or document outputs)"
|
|
5453
5487
|
] }),
|
|
5454
5488
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "font-mono", children: [
|
|
5455
5489
|
decontaminate,
|
package/dist/index.cjs
CHANGED
|
@@ -8405,7 +8405,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
8405
8405
|
panFrom.current = null;
|
|
8406
8406
|
session.end();
|
|
8407
8407
|
};
|
|
8408
|
-
const toLayer = settings.output
|
|
8408
|
+
const toLayer = settings.output !== "selection" && settings.output !== "layer-mask";
|
|
8409
8409
|
const brushTool = settings.tool === "quick-select" || settings.tool === "brush" || settings.tool === "refine-brush";
|
|
8410
8410
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
8411
8411
|
"div",
|
|
@@ -8445,7 +8445,8 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
8445
8445
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { className: "font-mono text-muted-foreground", children: [
|
|
8446
8446
|
Math.round(zoom * 100),
|
|
8447
8447
|
"%"
|
|
8448
|
-
] })
|
|
8448
|
+
] }),
|
|
8449
|
+
session.computing && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { role: "status", className: "text-muted-foreground", children: "Updating preview\u2026" })
|
|
8449
8450
|
] }),
|
|
8450
8451
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "flex-1 overflow-hidden flex items-center justify-center bg-muted/30", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8451
8452
|
"canvas",
|
|
@@ -8541,7 +8542,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
8541
8542
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
8542
8543
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { children: [
|
|
8543
8544
|
"Decontaminate Colors",
|
|
8544
|
-
toLayer ? "" : " (new layer outputs)"
|
|
8545
|
+
toLayer ? "" : " (new layer or document outputs)"
|
|
8545
8546
|
] }),
|
|
8546
8547
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { className: "font-mono", children: [
|
|
8547
8548
|
settings.decontaminate,
|
|
@@ -8557,7 +8558,7 @@ var SelectAndMaskWorkspace = ({ controller, onClose, className = "" }) => {
|
|
|
8557
8558
|
{
|
|
8558
8559
|
label: "Output to",
|
|
8559
8560
|
value: settings.output,
|
|
8560
|
-
options: import_image_editor14.REFINE_OUTPUTS.map((o) => ({ value: o.id, label: o.label })),
|
|
8561
|
+
options: import_image_editor14.REFINE_OUTPUTS.filter((o) => !o.needsDocuments || controller.canOpenDocuments).map((o) => ({ value: o.id, label: o.label })),
|
|
8561
8562
|
onChange: (v) => set({ output: v })
|
|
8562
8563
|
}
|
|
8563
8564
|
)
|
|
@@ -8645,6 +8646,19 @@ var SelectionOptionsBar = ({
|
|
|
8645
8646
|
setRangeStatus(err instanceof Error ? err.message : String(err));
|
|
8646
8647
|
}
|
|
8647
8648
|
};
|
|
8649
|
+
const [task, setTask] = (0, import_react62.useState)(null);
|
|
8650
|
+
const taskAbort = (0, import_react62.useRef)(null);
|
|
8651
|
+
const tracked = () => {
|
|
8652
|
+
const abort = new AbortController();
|
|
8653
|
+
taskAbort.current = abort;
|
|
8654
|
+
setTask({ stage: "Starting", fraction: 0 });
|
|
8655
|
+
return { signal: abort.signal, onProgress: (fraction, stage) => setTask({ stage, fraction }) };
|
|
8656
|
+
};
|
|
8657
|
+
const untrack = () => {
|
|
8658
|
+
taskAbort.current = null;
|
|
8659
|
+
setTask(null);
|
|
8660
|
+
};
|
|
8661
|
+
const failure = (err) => err?.name === "AbortError" ? "Cancelled." : err instanceof Error ? err.message : String(err);
|
|
8648
8662
|
const [subject, setSubject] = (0, import_react62.useState)("");
|
|
8649
8663
|
const [segmenting, setSegmenting] = (0, import_react62.useState)(false);
|
|
8650
8664
|
const [subjectStatus, setSubjectStatus] = (0, import_react62.useState)(null);
|
|
@@ -8655,11 +8669,12 @@ var SelectionOptionsBar = ({
|
|
|
8655
8669
|
setSegmenting(true);
|
|
8656
8670
|
setSubjectStatus(null);
|
|
8657
8671
|
try {
|
|
8658
|
-
const { segments, method, note } = await controller.selectSubject(canSegment ? target : "", { mode: options.mode });
|
|
8672
|
+
const { segments, method, note } = await controller.selectSubject(canSegment ? target : "", { mode: options.mode, ...tracked() });
|
|
8659
8673
|
setSubjectStatus(segments.length ? null : method === "saliency" ? note ?? "Nothing stands out from the background." : `Nothing matching \u201C${target}\u201D was found.`);
|
|
8660
8674
|
} catch (err) {
|
|
8661
|
-
setSubjectStatus(
|
|
8675
|
+
setSubjectStatus(failure(err));
|
|
8662
8676
|
} finally {
|
|
8677
|
+
untrack();
|
|
8663
8678
|
setSegmenting(false);
|
|
8664
8679
|
}
|
|
8665
8680
|
};
|
|
@@ -8671,11 +8686,12 @@ var SelectionOptionsBar = ({
|
|
|
8671
8686
|
setSkying(true);
|
|
8672
8687
|
setSkyStatus(null);
|
|
8673
8688
|
try {
|
|
8674
|
-
const { note } = await controller.selectSky({ mode: options.mode });
|
|
8689
|
+
const { note } = await controller.selectSky({ mode: options.mode, ...tracked() });
|
|
8675
8690
|
setSkyStatus(note ?? null);
|
|
8676
8691
|
} catch (err) {
|
|
8677
|
-
setSkyStatus(
|
|
8692
|
+
setSkyStatus(failure(err));
|
|
8678
8693
|
} finally {
|
|
8694
|
+
untrack();
|
|
8679
8695
|
setSkying(false);
|
|
8680
8696
|
}
|
|
8681
8697
|
};
|
|
@@ -8690,12 +8706,14 @@ var SelectionOptionsBar = ({
|
|
|
8690
8706
|
range: options.focusRange ?? 50,
|
|
8691
8707
|
noise: options.focusNoise ?? 0,
|
|
8692
8708
|
softness: options.focusSoftness ?? 4,
|
|
8693
|
-
mode: options.mode
|
|
8709
|
+
mode: options.mode,
|
|
8710
|
+
...tracked()
|
|
8694
8711
|
});
|
|
8695
8712
|
setFocusStatus(selection2 ? null : "No part of the image stands out as in focus.");
|
|
8696
8713
|
} catch (err) {
|
|
8697
|
-
setFocusStatus(
|
|
8714
|
+
setFocusStatus(failure(err));
|
|
8698
8715
|
} finally {
|
|
8716
|
+
untrack();
|
|
8699
8717
|
setFocusing(false);
|
|
8700
8718
|
}
|
|
8701
8719
|
};
|
|
@@ -8959,6 +8977,22 @@ var SelectionOptionsBar = ({
|
|
|
8959
8977
|
]
|
|
8960
8978
|
}
|
|
8961
8979
|
),
|
|
8980
|
+
task && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { "data-testid": "selection-progress", className: "flex items-center gap-2", children: [
|
|
8981
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8982
|
+
"div",
|
|
8983
|
+
{
|
|
8984
|
+
role: "progressbar",
|
|
8985
|
+
"aria-label": task.stage,
|
|
8986
|
+
"aria-valuemin": 0,
|
|
8987
|
+
"aria-valuemax": 100,
|
|
8988
|
+
"aria-valuenow": Math.round(task.fraction * 100),
|
|
8989
|
+
className: "flex-1 h-1.5 rounded bg-muted overflow-hidden",
|
|
8990
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "h-full bg-primary", style: { width: `${Math.round(task.fraction * 100)}%` } })
|
|
8991
|
+
}
|
|
8992
|
+
),
|
|
8993
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "text-muted-foreground", children: task.stage }),
|
|
8994
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", className: btn(false), onClick: () => taskAbort.current?.abort(), children: "Cancel" })
|
|
8995
|
+
] }),
|
|
8962
8996
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", className: btn(false), onClick: () => setWorkspace(true), children: "Select and Mask\u2026" }),
|
|
8963
8997
|
workspace && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SelectAndMaskWorkspace, { controller, onClose: () => setWorkspace(false) }),
|
|
8964
8998
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { "data-testid": "select-sky", className: "flex flex-col gap-1", children: [
|
|
@@ -9096,7 +9130,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
9096
9130
|
const [decontaminate, setDecontaminate] = (0, import_react63.useState)(0);
|
|
9097
9131
|
const [objectAware, setObjectAware] = (0, import_react63.useState)(false);
|
|
9098
9132
|
const canObject = Boolean(controller.segmentationProvider);
|
|
9099
|
-
const toLayer = output
|
|
9133
|
+
const toLayer = output !== "selection" && output !== "layer-mask";
|
|
9100
9134
|
const sel = selection === void 0 ? controller.getSelection() : selection;
|
|
9101
9135
|
const list = layers ?? controller.getAdjustmentLayers();
|
|
9102
9136
|
const target = list.find((l) => l.id === layerId) ?? list[list.length - 1];
|
|
@@ -9155,7 +9189,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
9155
9189
|
value: output,
|
|
9156
9190
|
onChange: (e) => setOutput(e.target.value),
|
|
9157
9191
|
className: "flex-1 bg-background border border-border rounded px-1 py-1 text-foreground",
|
|
9158
|
-
children: import_image_editor16.REFINE_OUTPUTS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("option", { value: o.id, children: o.label }, o.id))
|
|
9192
|
+
children: import_image_editor16.REFINE_OUTPUTS.filter((o) => !o.needsDocuments || controller.canOpenDocuments).map((o) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("option", { value: o.id, children: o.label }, o.id))
|
|
9159
9193
|
}
|
|
9160
9194
|
)
|
|
9161
9195
|
] }),
|
|
@@ -9163,7 +9197,7 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
9163
9197
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
|
|
9164
9198
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { children: [
|
|
9165
9199
|
"Decontaminate colors",
|
|
9166
|
-
toLayer ? "" : " (new layer outputs)"
|
|
9200
|
+
toLayer ? "" : " (new layer or document outputs)"
|
|
9167
9201
|
] }),
|
|
9168
9202
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { className: "font-mono", children: [
|
|
9169
9203
|
decontaminate,
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.139.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
"dependencies": {},
|
|
255
255
|
"peerDependencies": {
|
|
256
256
|
"@dagrejs/dagre": "^1.1.8",
|
|
257
|
-
"@pixerate/editor": ">=0.
|
|
257
|
+
"@pixerate/editor": ">=0.209.0 <1.0.0-0",
|
|
258
258
|
"@tiptap/core": "^2.27.3",
|
|
259
259
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
260
260
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
"tsup": "^9.0.0",
|
|
306
306
|
"typescript": "^5.7.3",
|
|
307
307
|
"vitest": "^5.0.5",
|
|
308
|
-
"@pixerate/editor": "0.
|
|
308
|
+
"@pixerate/editor": "0.209.0"
|
|
309
309
|
},
|
|
310
310
|
"scripts": {
|
|
311
311
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|