@pixerate/editor-svelte 0.157.0 → 0.158.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.
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ImageEditorController, MaskEdgeReport, MaskEdgeTarget, SelectionMask } from '@pixerate/editor/image-editor';
|
|
3
|
+
import { MASK_EDGE_THRESHOLDS } from '@pixerate/editor/image-editor';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Check Edge: measures the selection's (or a mask's) edge, as the `inspect_mask_edge` tool does,
|
|
7
|
+
* and lists the scores (flagged past the thresholds), holes, islands and findings with fixes.
|
|
8
|
+
*/
|
|
9
|
+
interface Props {
|
|
10
|
+
controller: ImageEditorController;
|
|
11
|
+
/** The current selection (`state.selection`): a report on an older selection is cleared. */
|
|
12
|
+
selection?: SelectionMask | null;
|
|
13
|
+
/** What to check (default the selection); masks need `layerId`. */
|
|
14
|
+
target?: MaskEdgeTarget;
|
|
15
|
+
layerId?: string;
|
|
16
|
+
class?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let { controller, selection, target = 'selection', layerId, class: className = '' }: Props = $props();
|
|
20
|
+
|
|
21
|
+
const button =
|
|
22
|
+
'px-2 py-1 rounded-md border border-border bg-background text-[11px] text-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40';
|
|
23
|
+
const sel = $derived(selection === undefined ? controller.getSelection() : selection);
|
|
24
|
+
let result = $state<{ report: MaskEdgeReport; for: SelectionMask | null } | null>(null);
|
|
25
|
+
let error = $state<string | null>(null);
|
|
26
|
+
const report = $derived(result && (target !== 'selection' || result.for === sel) ? result.report : null);
|
|
27
|
+
const T = MASK_EDGE_THRESHOLDS;
|
|
28
|
+
const rows = $derived(
|
|
29
|
+
report
|
|
30
|
+
? [
|
|
31
|
+
{ label: 'Halo', value: report.haloScore, bad: report.haloScore >= T.halo },
|
|
32
|
+
{ label: 'Edge alignment', value: report.edgeAlignment, bad: report.edgeAlignment < T.alignment },
|
|
33
|
+
{ label: 'Jaggedness', value: report.jaggedness, bad: report.jaggedness >= T.jaggedness },
|
|
34
|
+
{ label: 'Soft edge', value: report.softFraction, bad: report.softFraction >= T.soft },
|
|
35
|
+
]
|
|
36
|
+
: []
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
function check() {
|
|
40
|
+
error = null;
|
|
41
|
+
try {
|
|
42
|
+
result = { report: controller.inspectMaskEdge(target, { layerId }), for: sel };
|
|
43
|
+
} catch (err) {
|
|
44
|
+
result = null;
|
|
45
|
+
error = err instanceof Error ? err.message : String(err);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<div data-testid="mask-edge-check" class="flex flex-col gap-1.5 text-xs {className}">
|
|
51
|
+
<button type="button" class="{button} self-start" disabled={target === 'selection' && !sel} onclick={check}>Check Edge</button>
|
|
52
|
+
{#if report}
|
|
53
|
+
<dl class="grid grid-cols-[1fr_auto] gap-x-2 gap-y-0.5">
|
|
54
|
+
{#each rows as r (r.label)}
|
|
55
|
+
<dt class="text-muted-foreground">{r.label}</dt>
|
|
56
|
+
<dd class="font-mono text-right {r.bad ? 'text-destructive' : 'text-foreground'}">{r.value}</dd>
|
|
57
|
+
{/each}
|
|
58
|
+
<dt class="text-muted-foreground">Holes / islands</dt>
|
|
59
|
+
<dd class="font-mono text-right {report.holes.count || report.islands.count ? 'text-destructive' : 'text-foreground'}">
|
|
60
|
+
{report.holes.count} / {report.islands.count}
|
|
61
|
+
</dd>
|
|
62
|
+
</dl>
|
|
63
|
+
{#if report.issues.length}
|
|
64
|
+
<ul data-testid="mask-edge-issues" class="list-disc pl-4 flex flex-col gap-1 text-foreground">
|
|
65
|
+
{#each report.issues as s (s)}
|
|
66
|
+
<li>{s}</li>
|
|
67
|
+
{/each}
|
|
68
|
+
</ul>
|
|
69
|
+
{:else}
|
|
70
|
+
<p class="text-muted-foreground">The edge looks clean.</p>
|
|
71
|
+
{/if}
|
|
72
|
+
{/if}
|
|
73
|
+
{#if error}
|
|
74
|
+
<p role="alert" class="text-destructive">{error}</p>
|
|
75
|
+
{/if}
|
|
76
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ImageEditorController, MaskEdgeTarget, SelectionMask } from '@pixerate/editor/image-editor';
|
|
2
|
+
/**
|
|
3
|
+
* Check Edge: measures the selection's (or a mask's) edge, as the `inspect_mask_edge` tool does,
|
|
4
|
+
* and lists the scores (flagged past the thresholds), holes, islands and findings with fixes.
|
|
5
|
+
*/
|
|
6
|
+
interface Props {
|
|
7
|
+
controller: ImageEditorController;
|
|
8
|
+
/** The current selection (`state.selection`): a report on an older selection is cleared. */
|
|
9
|
+
selection?: SelectionMask | null;
|
|
10
|
+
/** What to check (default the selection); masks need `layerId`. */
|
|
11
|
+
target?: MaskEdgeTarget;
|
|
12
|
+
layerId?: string;
|
|
13
|
+
class?: string;
|
|
14
|
+
}
|
|
15
|
+
declare const MaskEdgeCheck: import("svelte").Component<Props, {}, "">;
|
|
16
|
+
type MaskEdgeCheck = ReturnType<typeof MaskEdgeCheck>;
|
|
17
|
+
export default MaskEdgeCheck;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { imageRangeClass, imageSectionTitleClass } from './styles.js';
|
|
3
|
+
import MaskEdgeCheck from './MaskEdgeCheck.svelte';
|
|
3
4
|
import type {
|
|
4
5
|
AdjustmentKind,
|
|
5
6
|
AdjustmentLayer,
|
|
@@ -157,6 +158,7 @@
|
|
|
157
158
|
{#if error}
|
|
158
159
|
<p role="alert" class="text-destructive">{error}</p>
|
|
159
160
|
{/if}
|
|
161
|
+
<MaskEdgeCheck {controller} selection={sel} />
|
|
160
162
|
|
|
161
163
|
<span class="font-semibold text-foreground uppercase tracking-wider text-[11px] mt-2">Layer Mask</span>
|
|
162
164
|
<div class="flex gap-1 items-center">
|
|
@@ -8,6 +8,7 @@ import type CurvesEditorComponent from "./CurvesEditor.svelte";
|
|
|
8
8
|
import type ControlSliderComponent from "./ControlSlider.svelte";
|
|
9
9
|
import type SelectionOptionsBarComponent from "./SelectionOptionsBar.svelte";
|
|
10
10
|
import type RefineEdgePanelComponent from "./RefineEdgePanel.svelte";
|
|
11
|
+
import type MaskEdgeCheckComponent from "./MaskEdgeCheck.svelte";
|
|
11
12
|
import type PathsPanelComponent from "./PathsPanel.svelte";
|
|
12
13
|
import type SelectAndMaskWorkspaceComponent from "./SelectAndMaskWorkspace.svelte";
|
|
13
14
|
import type ContentAwareFillWorkspaceComponent from "./ContentAwareFillWorkspace.svelte";
|
|
@@ -35,6 +36,7 @@ export { default as CurvesEditor } from './CurvesEditor.svelte';
|
|
|
35
36
|
export { default as ControlSlider } from './ControlSlider.svelte';
|
|
36
37
|
export { default as SelectionOptionsBar } from './SelectionOptionsBar.svelte';
|
|
37
38
|
export { default as RefineEdgePanel } from './RefineEdgePanel.svelte';
|
|
39
|
+
export { default as MaskEdgeCheck } from './MaskEdgeCheck.svelte';
|
|
38
40
|
export { default as PathsPanel } from './PathsPanel.svelte';
|
|
39
41
|
export { default as SelectAndMaskWorkspace } from './SelectAndMaskWorkspace.svelte';
|
|
40
42
|
export { default as ContentAwareFillWorkspace } from './ContentAwareFillWorkspace.svelte';
|
|
@@ -64,6 +66,7 @@ export type CurvesEditorProps = ComponentProps<typeof CurvesEditorComponent>;
|
|
|
64
66
|
export type ControlSliderProps = ComponentProps<typeof ControlSliderComponent>;
|
|
65
67
|
export type SelectionOptionsBarProps = ComponentProps<typeof SelectionOptionsBarComponent>;
|
|
66
68
|
export type RefineEdgePanelProps = ComponentProps<typeof RefineEdgePanelComponent>;
|
|
69
|
+
export type MaskEdgeCheckProps = ComponentProps<typeof MaskEdgeCheckComponent>;
|
|
67
70
|
export type PathsPanelProps = ComponentProps<typeof PathsPanelComponent>;
|
|
68
71
|
export type SelectAndMaskWorkspaceProps = ComponentProps<typeof SelectAndMaskWorkspaceComponent>;
|
|
69
72
|
export type ContentAwareFillWorkspaceProps = ComponentProps<typeof ContentAwareFillWorkspaceComponent>;
|
|
@@ -10,6 +10,7 @@ export { default as CurvesEditor } from './CurvesEditor.svelte';
|
|
|
10
10
|
export { default as ControlSlider } from './ControlSlider.svelte';
|
|
11
11
|
export { default as SelectionOptionsBar } from './SelectionOptionsBar.svelte';
|
|
12
12
|
export { default as RefineEdgePanel } from './RefineEdgePanel.svelte';
|
|
13
|
+
export { default as MaskEdgeCheck } from './MaskEdgeCheck.svelte';
|
|
13
14
|
export { default as PathsPanel } from './PathsPanel.svelte';
|
|
14
15
|
export { default as SelectAndMaskWorkspace } from './SelectAndMaskWorkspace.svelte';
|
|
15
16
|
export { default as ContentAwareFillWorkspace } from './ContentAwareFillWorkspace.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.158.0",
|
|
4
4
|
"description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
"**/*.css"
|
|
166
166
|
],
|
|
167
167
|
"dependencies": {
|
|
168
|
-
"@pixerate/editor": "0.
|
|
168
|
+
"@pixerate/editor": "0.214.0"
|
|
169
169
|
},
|
|
170
170
|
"peerDependencies": {
|
|
171
171
|
"@dagrejs/dagre": "^1.1.4",
|