@pixerate/editor-svelte 0.160.0 → 0.161.1

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.
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { imageRangeClass, imageSectionTitleClass } from './styles.js';
3
3
  import MaskEdgeCheck from './MaskEdgeCheck.svelte';
4
+ import SelectionChangeCheck from './SelectionChangeCheck.svelte';
4
5
  import type {
5
6
  AdjustmentKind,
6
7
  AdjustmentLayer,
@@ -168,6 +169,7 @@
168
169
  <p role="alert" class="text-destructive">{error}</p>
169
170
  {/if}
170
171
  <MaskEdgeCheck {controller} selection={sel} />
172
+ <SelectionChangeCheck {controller} selection={sel} />
171
173
 
172
174
  <span class="font-semibold text-foreground uppercase tracking-wider text-[11px] mt-2">Layer Mask</span>
173
175
  <div class="flex gap-1 items-center">
@@ -0,0 +1,50 @@
1
+ <script lang="ts">
2
+ import type { ImageEditorController, SelectionDiff, SelectionMask } from '@pixerate/editor/image-editor';
3
+
4
+ /**
5
+ * Show Last Change: what the last step did to the selection, as the `compare_selections` tool
6
+ * reports it, with the added area tinted green and the removed red on the canvas until the
7
+ * selection changes again.
8
+ */
9
+ interface Props {
10
+ controller: ImageEditorController;
11
+ /** The current selection (`state.selection`): the summary clears when it changes. */
12
+ selection?: SelectionMask | null;
13
+ class?: string;
14
+ }
15
+
16
+ let { controller, selection, class: className = '' }: Props = $props();
17
+
18
+ const button =
19
+ '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';
20
+ const sel = $derived(selection === undefined ? controller.getSelection() : selection);
21
+ let result = $state<{ diff: SelectionDiff; for: SelectionMask | null } | null>(null);
22
+ let error = $state<string | null>(null);
23
+ const diff = $derived(result && result.for === sel ? result.diff : null);
24
+
25
+ function show() {
26
+ error = null;
27
+ try {
28
+ result = { diff: controller.compareSelections(), for: sel };
29
+ } catch (err) {
30
+ result = null;
31
+ error = err instanceof Error ? err.message : String(err);
32
+ }
33
+ }
34
+ </script>
35
+
36
+ <div data-testid="selection-change-check" class="flex flex-col gap-1 text-xs {className}">
37
+ <button type="button" class="{button} self-start" onclick={show}>Show Last Change</button>
38
+ {#if diff}
39
+ <p data-testid="selection-change-summary" class="text-foreground">
40
+ {#if diff.identical}
41
+ The last step did not change the selection.
42
+ {:else}
43
+ <span class="text-green-600">+{diff.added.area} px</span> <span class="text-destructive">−{diff.removed.area} px</span>, overlap {Math.round(diff.iou * 100)}%
44
+ {/if}
45
+ </p>
46
+ {/if}
47
+ {#if error}
48
+ <p role="alert" class="text-destructive">{error}</p>
49
+ {/if}
50
+ </div>
@@ -0,0 +1,15 @@
1
+ import type { ImageEditorController, SelectionMask } from '@pixerate/editor/image-editor';
2
+ /**
3
+ * Show Last Change: what the last step did to the selection, as the `compare_selections` tool
4
+ * reports it, with the added area tinted green and the removed red on the canvas until the
5
+ * selection changes again.
6
+ */
7
+ interface Props {
8
+ controller: ImageEditorController;
9
+ /** The current selection (`state.selection`): the summary clears when it changes. */
10
+ selection?: SelectionMask | null;
11
+ class?: string;
12
+ }
13
+ declare const SelectionChangeCheck: import("svelte").Component<Props, {}, "">;
14
+ type SelectionChangeCheck = ReturnType<typeof SelectionChangeCheck>;
15
+ export default SelectionChangeCheck;
@@ -9,6 +9,7 @@ import type ControlSliderComponent from "./ControlSlider.svelte";
9
9
  import type SelectionOptionsBarComponent from "./SelectionOptionsBar.svelte";
10
10
  import type RefineEdgePanelComponent from "./RefineEdgePanel.svelte";
11
11
  import type MaskEdgeCheckComponent from "./MaskEdgeCheck.svelte";
12
+ import type SelectionChangeCheckComponent from "./SelectionChangeCheck.svelte";
12
13
  import type PathsPanelComponent from "./PathsPanel.svelte";
13
14
  import type SelectAndMaskWorkspaceComponent from "./SelectAndMaskWorkspace.svelte";
14
15
  import type ContentAwareFillWorkspaceComponent from "./ContentAwareFillWorkspace.svelte";
@@ -38,6 +39,7 @@ export { default as ControlSlider } from './ControlSlider.svelte';
38
39
  export { default as SelectionOptionsBar } from './SelectionOptionsBar.svelte';
39
40
  export { default as RefineEdgePanel } from './RefineEdgePanel.svelte';
40
41
  export { default as MaskEdgeCheck } from './MaskEdgeCheck.svelte';
42
+ export { default as SelectionChangeCheck } from './SelectionChangeCheck.svelte';
41
43
  export { default as PathsPanel } from './PathsPanel.svelte';
42
44
  export { default as SelectAndMaskWorkspace } from './SelectAndMaskWorkspace.svelte';
43
45
  export { default as ContentAwareFillWorkspace } from './ContentAwareFillWorkspace.svelte';
@@ -69,6 +71,7 @@ export type ControlSliderProps = ComponentProps<typeof ControlSliderComponent>;
69
71
  export type SelectionOptionsBarProps = ComponentProps<typeof SelectionOptionsBarComponent>;
70
72
  export type RefineEdgePanelProps = ComponentProps<typeof RefineEdgePanelComponent>;
71
73
  export type MaskEdgeCheckProps = ComponentProps<typeof MaskEdgeCheckComponent>;
74
+ export type SelectionChangeCheckProps = ComponentProps<typeof SelectionChangeCheckComponent>;
72
75
  export type PathsPanelProps = ComponentProps<typeof PathsPanelComponent>;
73
76
  export type SelectAndMaskWorkspaceProps = ComponentProps<typeof SelectAndMaskWorkspaceComponent>;
74
77
  export type ContentAwareFillWorkspaceProps = ComponentProps<typeof ContentAwareFillWorkspaceComponent>;
@@ -11,6 +11,7 @@ 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
13
  export { default as MaskEdgeCheck } from './MaskEdgeCheck.svelte';
14
+ export { default as SelectionChangeCheck } from './SelectionChangeCheck.svelte';
14
15
  export { default as PathsPanel } from './PathsPanel.svelte';
15
16
  export { default as SelectAndMaskWorkspace } from './SelectAndMaskWorkspace.svelte';
16
17
  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.160.0",
3
+ "version": "0.161.1",
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.216.0"
168
+ "@pixerate/editor": "0.218.0"
169
169
  },
170
170
  "peerDependencies": {
171
171
  "@dagrejs/dagre": "^1.1.4",