@gradio/imageeditor 0.18.2-dev.0 → 0.18.2-dev.2

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/Index.svelte +122 -159
  3. package/InteractiveImageEditor.svelte +1 -0
  4. package/dist/Example.svelte +7 -4
  5. package/dist/Example.svelte.d.ts +20 -18
  6. package/dist/Index.svelte +152 -136
  7. package/dist/Index.svelte.d.ts +18 -202
  8. package/dist/InteractiveImageEditor.svelte +205 -148
  9. package/dist/InteractiveImageEditor.svelte.d.ts +55 -51
  10. package/dist/shared/Anchor.svelte +210 -136
  11. package/dist/shared/Anchor.svelte.d.ts +18 -16
  12. package/dist/shared/Controls.svelte +55 -36
  13. package/dist/shared/Controls.svelte.d.ts +35 -33
  14. package/dist/shared/IconButton.svelte +19 -17
  15. package/dist/shared/IconButton.svelte.d.ts +34 -32
  16. package/dist/shared/ImageEditor.svelte +673 -466
  17. package/dist/shared/ImageEditor.svelte.d.ts +4 -79
  18. package/dist/shared/Layers.svelte +52 -30
  19. package/dist/shared/Layers.svelte.d.ts +39 -36
  20. package/dist/shared/Resize.svelte +42 -21
  21. package/dist/shared/Resize.svelte.d.ts +29 -27
  22. package/dist/shared/SecondaryToolbar.svelte +17 -5
  23. package/dist/shared/SecondaryToolbar.svelte.d.ts +38 -36
  24. package/dist/shared/Toolbar.svelte +123 -69
  25. package/dist/shared/Toolbar.svelte.d.ts +40 -38
  26. package/dist/shared/brush/BrushOptions.svelte +119 -84
  27. package/dist/shared/brush/BrushOptions.svelte.d.ts +29 -27
  28. package/dist/shared/brush/BrushSize.svelte +12 -7
  29. package/dist/shared/brush/BrushSize.svelte.d.ts +23 -20
  30. package/dist/shared/brush/ColorField.svelte +49 -33
  31. package/dist/shared/brush/ColorField.svelte.d.ts +23 -21
  32. package/dist/shared/brush/ColorPicker.svelte +152 -108
  33. package/dist/shared/brush/ColorPicker.svelte.d.ts +19 -17
  34. package/dist/shared/brush/ColorSwatch.svelte +78 -46
  35. package/dist/shared/brush/ColorSwatch.svelte.d.ts +34 -32
  36. package/dist/types.d.ts +40 -0
  37. package/dist/types.js +25 -0
  38. package/package.json +12 -12
  39. package/shared/ImageEditor.svelte +1 -3
  40. package/shared/brush/BrushOptions.svelte +1 -1
  41. package/shared/brush/ColorPicker.svelte +2 -1
  42. package/types.ts +74 -0
@@ -1,110 +1,153 @@
1
- <script>import { onMount, tick } from "svelte";
2
- import tinycolor from "tinycolor2";
3
- import { clamp } from "../utils/pixi";
4
- export let color = "rgb(255, 255, 255)";
5
- let sl_marker_pos = [0, 0];
6
- let sl_rect = null;
7
- let sl_moving = false;
8
- let sl = [0, 0];
9
- let hue = 0;
10
- let hue_marker_pos = 0;
11
- let hue_rect = null;
12
- let hue_moving = false;
13
- let opacity_moving = false;
14
- function handle_hue_down(event) {
15
- hue_rect = event.currentTarget.getBoundingClientRect();
16
- hue_moving = true;
17
- update_hue_from_mouse(event.clientX);
18
- }
19
- function update_hue_from_mouse(x) {
20
- if (!hue_rect) return;
21
- const _x = clamp(x - hue_rect.left, 0, hue_rect.width);
22
- hue_marker_pos = _x;
23
- const _hue = _x / hue_rect.width * 360;
24
- hue = _hue;
25
- color = hsva_to_rgba({ h: _hue, s: sl[0], v: sl[1], a: 1 });
26
- }
27
- function hsva_to_rgba(hsva) {
28
- const saturation = hsva.s;
29
- const value = hsva.v;
30
- let chroma = saturation * value;
31
- const hue_by_60 = hsva.h / 60;
32
- let x = chroma * (1 - Math.abs(hue_by_60 % 2 - 1));
33
- const m = value - chroma;
34
- chroma = chroma + m;
35
- x = x + m;
36
- const index = Math.floor(hue_by_60) % 6;
37
- const red = [chroma, x, m, m, x, chroma][index];
38
- const green = [x, chroma, chroma, x, m, m][index];
39
- const blue = [m, m, x, chroma, chroma, x][index];
40
- return `rgba(${red * 255}, ${green * 255}, ${blue * 255}, ${hsva.a})`;
41
- }
42
- function update_color_from_mouse(x, y) {
43
- if (!sl_rect) return;
44
- const _x = clamp(x - sl_rect.left, 0, sl_rect.width);
45
- const _y = clamp(y - sl_rect.top, 0, sl_rect.height);
46
- sl_marker_pos = [_x, _y];
47
- const _hsva = {
48
- h: hue * 1,
49
- s: _x / sl_rect.width,
50
- v: 1 - _y / sl_rect.height,
51
- a: 1
52
- };
53
- sl = [_hsva.s, _hsva.v];
54
- color = hsva_to_rgba(_hsva);
55
- }
56
- function handle_sl_down(event) {
57
- sl_moving = true;
58
- sl_rect = event.currentTarget.getBoundingClientRect();
59
- update_color_from_mouse(event.clientX, event.clientY);
60
- }
61
- function handle_move(event) {
62
- if (sl_moving) update_color_from_mouse(event.clientX, event.clientY);
63
- if (hue_moving) update_hue_from_mouse(event.clientX);
64
- if (opacity_moving) update_opacity_from_mouse(event.clientX);
65
- }
66
- function handle_end() {
67
- if (sl_moving) sl_moving = false;
68
- if (hue_moving) hue_moving = false;
69
- if (opacity_moving) opacity_moving = false;
70
- }
71
- async function update_mouse_from_color(color2) {
72
- if (sl_moving || hue_moving) return;
73
- await tick();
74
- if (!color2) return;
75
- if (!sl_rect) {
76
- sl_rect = sl_wrap.getBoundingClientRect();
77
- }
78
- if (!hue_rect) {
79
- hue_rect = hue_wrap.getBoundingClientRect();
80
- }
81
- const hsva = tinycolor(color2).toHsv();
82
- const _x = hsva.s * sl_rect.width;
83
- const _y = (1 - hsva.v) * sl_rect.height;
84
- sl_marker_pos = [_x, _y];
85
- sl = [hsva.s, hsva.v];
86
- hue = hsva.h;
87
- hue_marker_pos = hsva.h / 360 * hue_rect.width;
88
- }
89
- $: update_mouse_from_color(color);
90
- let sl_wrap;
91
- let hue_wrap;
92
- export let opacity = 1;
93
- let opacity_wrap;
94
- function handle_opacity_down(event) {
95
- opacity_rect = event.currentTarget.getBoundingClientRect();
96
- opacity_moving = true;
97
- update_opacity_from_mouse(event.clientX);
98
- }
99
- let opacity_rect = null;
100
- function update_opacity_from_mouse(x) {
101
- if (!opacity_rect) return;
102
- const _x = clamp(x - opacity_rect.left, 0, opacity_rect.width);
103
- opacity = _x / opacity_rect.width;
104
- }
105
- onMount(() => {
106
- opacity_rect = opacity_wrap.getBoundingClientRect();
107
- });
1
+ <script lang="ts">
2
+ import { onMount, tick } from "svelte";
3
+ import tinycolor from "tinycolor2";
4
+ import { clamp } from "../utils/pixi";
5
+
6
+ export let color = "rgb(255, 255, 255)";
7
+
8
+ let sl_marker_pos = [0, 0];
9
+ let sl_rect: DOMRect | null = null;
10
+ let sl_moving = false;
11
+ let sl = [0, 0];
12
+
13
+ let hue = 0;
14
+ let hue_marker_pos = 0;
15
+ let hue_rect: DOMRect | null = null;
16
+ let hue_moving = false;
17
+
18
+ let opacity_moving = false;
19
+
20
+ function handle_hue_down(
21
+ event: MouseEvent & { currentTarget: HTMLDivElement }
22
+ ): void {
23
+ hue_rect = event.currentTarget.getBoundingClientRect();
24
+
25
+ hue_moving = true;
26
+ update_hue_from_mouse(event.clientX);
27
+ }
28
+
29
+ function update_hue_from_mouse(x: number): void {
30
+ if (!hue_rect) return;
31
+ const _x = clamp(x - hue_rect.left, 0, hue_rect.width); // get the x-coordinate relative to the box
32
+ hue_marker_pos = _x;
33
+ const _hue = (_x / hue_rect.width) * 360; // scale the x position to a hue value (0-360)
34
+
35
+ hue = _hue;
36
+
37
+ color = hsva_to_rgba({ h: _hue, s: sl[0], v: sl[1], a: 1 });
38
+ }
39
+
40
+ function hsva_to_rgba(hsva: {
41
+ h: number;
42
+ s: number;
43
+ v: number;
44
+ a: number;
45
+ }): string {
46
+ const saturation = hsva.s;
47
+ const value = hsva.v;
48
+ let chroma = saturation * value;
49
+ const hue_by_60 = hsva.h / 60;
50
+ let x = chroma * (1 - Math.abs((hue_by_60 % 2) - 1));
51
+ const m = value - chroma;
52
+
53
+ chroma = chroma + m;
54
+ x = x + m;
55
+
56
+ const index = Math.floor(hue_by_60) % 6;
57
+ const red = [chroma, x, m, m, x, chroma][index];
58
+ const green = [x, chroma, chroma, x, m, m][index];
59
+ const blue = [m, m, x, chroma, chroma, x][index];
60
+
61
+ return `rgba(${red * 255}, ${green * 255}, ${blue * 255}, ${hsva.a})`;
62
+ }
63
+
64
+ function update_color_from_mouse(x: number, y: number): void {
65
+ if (!sl_rect) return;
66
+ const _x = clamp(x - sl_rect.left, 0, sl_rect.width);
67
+ const _y = clamp(y - sl_rect.top, 0, sl_rect.height);
68
+ sl_marker_pos = [_x, _y];
69
+ const _hsva = {
70
+ h: hue * 1,
71
+ s: _x / sl_rect.width,
72
+ v: 1 - _y / sl_rect.height,
73
+ a: 1
74
+ };
75
+
76
+ sl = [_hsva.s, _hsva.v];
77
+
78
+ color = hsva_to_rgba(_hsva);
79
+ }
80
+
81
+ function handle_sl_down(
82
+ event: MouseEvent & { currentTarget: HTMLDivElement }
83
+ ): void {
84
+ sl_moving = true;
85
+ sl_rect = event.currentTarget.getBoundingClientRect();
86
+ update_color_from_mouse(event.clientX, event.clientY);
87
+ }
88
+
89
+ function handle_move(
90
+ event: MouseEvent & { currentTarget: EventTarget & Window }
91
+ ): void {
92
+ if (sl_moving) update_color_from_mouse(event.clientX, event.clientY);
93
+ if (hue_moving) update_hue_from_mouse(event.clientX);
94
+ if (opacity_moving) update_opacity_from_mouse(event.clientX);
95
+ }
96
+
97
+ function handle_end(): void {
98
+ if (sl_moving) sl_moving = false;
99
+ if (hue_moving) hue_moving = false;
100
+ if (opacity_moving) opacity_moving = false;
101
+ }
102
+
103
+ async function update_mouse_from_color(color: string): Promise<void> {
104
+ if (sl_moving || hue_moving) return;
105
+ await tick();
106
+ if (!color) return;
107
+ if (!sl_rect) {
108
+ sl_rect = sl_wrap.getBoundingClientRect();
109
+ }
110
+
111
+ if (!hue_rect) {
112
+ hue_rect = hue_wrap.getBoundingClientRect();
113
+ }
114
+
115
+ const hsva = tinycolor(color).toHsv();
116
+ const _x = hsva.s * sl_rect!.width;
117
+ const _y = (1 - hsva.v) * sl_rect!.height;
118
+ sl_marker_pos = [_x, _y];
119
+ sl = [hsva.s, hsva.v];
120
+ hue = hsva.h;
121
+ hue_marker_pos = (hsva.h / 360) * hue_rect!.width;
122
+ }
123
+
124
+ $: update_mouse_from_color(color);
125
+
126
+ let sl_wrap: HTMLDivElement;
127
+ let hue_wrap: HTMLDivElement;
128
+
129
+ export let opacity = 1;
130
+
131
+ let opacity_wrap: HTMLDivElement;
132
+
133
+ function handle_opacity_down(
134
+ event: MouseEvent & { currentTarget: HTMLDivElement }
135
+ ): void {
136
+ opacity_rect = event.currentTarget.getBoundingClientRect();
137
+ opacity_moving = true;
138
+ update_opacity_from_mouse(event.clientX);
139
+ }
140
+ let opacity_rect: DOMRect | null = null;
141
+
142
+ function update_opacity_from_mouse(x: number): void {
143
+ if (!opacity_rect) return;
144
+ const _x = clamp(x - opacity_rect.left, 0, opacity_rect.width);
145
+ opacity = _x / opacity_rect.width;
146
+ }
147
+
148
+ onMount(() => {
149
+ opacity_rect = opacity_wrap.getBoundingClientRect();
150
+ });
108
151
  </script>
109
152
 
110
153
  <svelte:window on:mousemove={handle_move} on:mouseup={handle_end} />
@@ -204,7 +247,8 @@ onMount(() => {
204
247
  position: relative;
205
248
  --hue: white;
206
249
 
207
- background: linear-gradient(rgba(0, 0, 0, 0), #000),
250
+ background:
251
+ linear-gradient(rgba(0, 0, 0, 0), #000),
208
252
  linear-gradient(90deg, #fff, hsl(var(--hue), 100%, 50%));
209
253
  width: 100%;
210
254
  height: 150px;
@@ -1,19 +1,21 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- color?: string;
5
- opacity?: number;
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
6
11
  };
7
- events: {
8
- [evt: string]: CustomEvent<any>;
9
- };
10
- slots: {};
11
- exports?: {} | undefined;
12
- bindings?: string | undefined;
13
- };
14
- export type ColorPickerProps = typeof __propDef.props;
15
- export type ColorPickerEvents = typeof __propDef.events;
16
- export type ColorPickerSlots = typeof __propDef.slots;
17
- export default class ColorPicker extends SvelteComponent<ColorPickerProps, ColorPickerEvents, ColorPickerSlots> {
12
+ z_$$bindings?: Bindings;
18
13
  }
19
- export {};
14
+ declare const ColorPicker: $$__sveltets_2_IsomorphicComponent<{
15
+ color?: string;
16
+ opacity?: number;
17
+ }, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type ColorPicker = InstanceType<typeof ColorPicker>;
21
+ export default ColorPicker;
@@ -1,49 +1,81 @@
1
- <script>import tinycolor from "tinycolor2";
2
- import { createEventDispatcher } from "svelte";
3
- import IconButton from "../IconButton.svelte";
4
- import { Plus } from "@gradio/icons";
5
- export let selected_color;
6
- export let colors;
7
- export let user_colors = [];
8
- export let show_empty = false;
9
- export let current_mode = "hex";
10
- export let color_picker = false;
11
- const dispatch = createEventDispatcher();
12
- $: _colors = show_empty ? colors : colors.filter((c) => c);
13
- function get_color(color_input) {
14
- if (Array.isArray(color_input)) {
15
- return color_input[0];
16
- }
17
- return color_input;
18
- }
19
- function get_opacity(color_input) {
20
- if (Array.isArray(color_input)) {
21
- return color_input[1];
22
- }
23
- const color = tinycolor(color_input);
24
- return color.getAlpha();
25
- }
26
- function get_formatted_color(color, mode) {
27
- const color_value = get_color(color);
28
- if (mode === "hex") {
29
- return tinycolor(color_value).toHexString();
30
- } else if (mode === "rgb") {
31
- return tinycolor(color_value).toRgbString();
32
- }
33
- return tinycolor(color_value).toHslString();
34
- }
35
- let current_index = `select-${colors.findIndex(
36
- (c) => get_formatted_color(c, current_mode) === get_formatted_color(selected_color, current_mode)
37
- )}`;
38
- $: selected_opacity = get_opacity(selected_color);
39
- function handle_select(type, detail) {
40
- current_index = `${type}-${detail.index}`;
41
- dispatch(type, detail);
42
- }
43
- function handle_picker_click() {
44
- dispatch("select", { index: null, color: selected_color });
45
- color_picker = !color_picker;
46
- }
1
+ <script lang="ts">
2
+ import tinycolor from "tinycolor2";
3
+ import { createEventDispatcher } from "svelte";
4
+ import type { ColorTuple } from "./types";
5
+ import type { ColorInput } from "tinycolor2";
6
+ import IconButton from "../IconButton.svelte";
7
+ import { Plus } from "@gradio/icons";
8
+
9
+ export let selected_color: string;
10
+ export let colors: (ColorInput | ColorTuple)[];
11
+ export let user_colors: (ColorInput | ColorTuple)[] | null = [];
12
+
13
+ export let show_empty = false;
14
+ export let current_mode: "hex" | "rgb" | "hsl" = "hex";
15
+ export let color_picker = false;
16
+ const dispatch = createEventDispatcher<{
17
+ select: { index: number | null; color: string | null; opacity?: number };
18
+ edit: { index: number; color: string | null };
19
+ add_color: void;
20
+ }>();
21
+
22
+ $: _colors = show_empty ? colors : colors.filter((c) => c);
23
+
24
+ function get_color(color_input: ColorInput | ColorTuple): string {
25
+ if (Array.isArray(color_input)) {
26
+ return color_input[0] as string;
27
+ }
28
+ return color_input as string;
29
+ }
30
+
31
+ function get_opacity(
32
+ color_input: ColorInput | ColorTuple
33
+ ): number | undefined {
34
+ if (Array.isArray(color_input)) {
35
+ return color_input[1];
36
+ }
37
+
38
+ const color = tinycolor(color_input);
39
+ return color.getAlpha();
40
+ }
41
+
42
+ function get_formatted_color(
43
+ color: ColorInput | ColorTuple,
44
+ mode: "hex" | "rgb" | "hsl"
45
+ ): string {
46
+ const color_value = get_color(color);
47
+ if (mode === "hex") {
48
+ return tinycolor(color_value).toHexString();
49
+ } else if (mode === "rgb") {
50
+ return tinycolor(color_value).toRgbString();
51
+ }
52
+ return tinycolor(color_value).toHslString();
53
+ }
54
+
55
+ let current_index = `select-${colors.findIndex(
56
+ (c) =>
57
+ get_formatted_color(c, current_mode) ===
58
+ get_formatted_color(selected_color, current_mode)
59
+ )}`;
60
+
61
+ $: selected_opacity = get_opacity(selected_color);
62
+
63
+ function handle_select(
64
+ type: "edit" | "select",
65
+ detail: {
66
+ index: number;
67
+ color: string | null;
68
+ opacity?: number;
69
+ }
70
+ ): void {
71
+ current_index = `${type}-${detail.index}`;
72
+ dispatch(type, detail);
73
+ }
74
+
75
+ function handle_picker_click(): void {
76
+ dispatch("select", { index: null, color: selected_color });
77
+ color_picker = !color_picker;
78
+ }
47
79
  </script>
48
80
 
49
81
  {#if !color_picker}
@@ -1,36 +1,38 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { ColorTuple } from "./types";
3
2
  import type { ColorInput } from "tinycolor2";
4
- declare const __propDef: {
5
- props: {
6
- selected_color: string;
7
- colors: (ColorInput | ColorTuple)[];
8
- user_colors?: (ColorInput | ColorTuple)[] | null;
9
- show_empty?: boolean;
10
- current_mode?: "hex" | "rgb" | "hsl";
11
- color_picker?: boolean;
3
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
4
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
5
+ $$bindings?: Bindings;
6
+ } & Exports;
7
+ (internal: unknown, props: Props & {
8
+ $$events?: Events;
9
+ $$slots?: Slots;
10
+ }): Exports & {
11
+ $set?: any;
12
+ $on?: any;
12
13
  };
13
- events: {
14
- select: CustomEvent<{
15
- index: number | null;
16
- color: string | null;
17
- opacity?: number;
18
- }>;
19
- edit: CustomEvent<{
20
- index: number;
21
- color: string | null;
22
- }>;
23
- add_color: CustomEvent<void>;
24
- } & {
25
- [evt: string]: CustomEvent<any>;
26
- };
27
- slots: {};
28
- exports?: {} | undefined;
29
- bindings?: string | undefined;
30
- };
31
- export type ColorSwatchProps = typeof __propDef.props;
32
- export type ColorSwatchEvents = typeof __propDef.events;
33
- export type ColorSwatchSlots = typeof __propDef.slots;
34
- export default class ColorSwatch extends SvelteComponent<ColorSwatchProps, ColorSwatchEvents, ColorSwatchSlots> {
14
+ z_$$bindings?: Bindings;
35
15
  }
36
- export {};
16
+ declare const ColorSwatch: $$__sveltets_2_IsomorphicComponent<{
17
+ selected_color: string;
18
+ colors: (ColorInput | ColorTuple)[];
19
+ user_colors?: (ColorInput | ColorTuple)[] | null;
20
+ show_empty?: boolean;
21
+ current_mode?: "hex" | "rgb" | "hsl";
22
+ color_picker?: boolean;
23
+ }, {
24
+ select: CustomEvent<{
25
+ index: number | null;
26
+ color: string | null;
27
+ opacity?: number;
28
+ }>;
29
+ edit: CustomEvent<{
30
+ index: number;
31
+ color: string | null;
32
+ }>;
33
+ add_color: CustomEvent<void>;
34
+ } & {
35
+ [evt: string]: CustomEvent<any>;
36
+ }, {}, {}, string>;
37
+ type ColorSwatch = InstanceType<typeof ColorSwatch>;
38
+ export default ColorSwatch;
@@ -0,0 +1,40 @@
1
+ import type { SelectData, ShareData } from "@gradio/utils";
2
+ import type { LoadingStatus } from "@gradio/statustracker";
3
+ import type { CommandNode } from "./shared/core/commands";
4
+ import type { LayerOptions, Source, Transform, WebcamOptions } from "./shared/types";
5
+ import type { Brush, Eraser } from "./shared/brush/types";
6
+ import type { EditorData } from "./InteractiveImageEditor.svelte";
7
+ export interface ImageEditorEvents {
8
+ change: never;
9
+ error: string;
10
+ input: never;
11
+ edit: never;
12
+ drag: never;
13
+ apply: never;
14
+ upload: never;
15
+ clear: never;
16
+ select: SelectData;
17
+ share: ShareData;
18
+ clear_status: LoadingStatus;
19
+ }
20
+ export interface ImageEditorProps {
21
+ border_region?: number;
22
+ webcam_options?: WebcamOptions;
23
+ value?: EditorData | null;
24
+ buttons?: string[] | null;
25
+ height?: number;
26
+ width?: number;
27
+ _selectable?: boolean;
28
+ sources?: Source[];
29
+ placeholder?: string | undefined;
30
+ brush?: Brush;
31
+ eraser?: Eraser;
32
+ transforms?: Transform[];
33
+ layers?: LayerOptions;
34
+ server?: {
35
+ accept_blobs: (a: any) => void;
36
+ };
37
+ canvas_size?: [number, number];
38
+ fixed_canvas?: boolean;
39
+ full_history?: CommandNode | null;
40
+ }
package/dist/types.js ADDED
@@ -0,0 +1,25 @@
1
+ export {};
2
+ // export let border_region = 0;
3
+ // export let webcam_options: WebcamOptions;
4
+ // export let value: EditorData | null = {
5
+ // background: null,
6
+ // layers: [],
7
+ // composite: null,
8
+ // };
9
+ // export let buttons: string[] | null = null;
10
+ // export let height = 350;
11
+ // export let width: number | undefined;
12
+ // export let _selectable = false;
13
+ // export let sources: Source[] = [];
14
+ // export let placeholder: string | undefined;
15
+ // export let brush: Brush;
16
+ // export let eraser: Eraser;
17
+ // export let transforms: Transform[] = [];
18
+ // export let layers: LayerOptions;
19
+ // export let attached_events: string[] = [];
20
+ // export let server: {
21
+ // accept_blobs: (a: any) => void;
22
+ // };
23
+ // export let canvas_size: [number, number];
24
+ // export let fixed_canvas = false;
25
+ // export let full_history: CommandNode | null = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/imageeditor",
3
- "version": "0.18.2-dev.0",
3
+ "version": "0.18.2-dev.2",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -8,19 +8,19 @@
8
8
  "private": false,
9
9
  "dependencies": {
10
10
  "@types/tinycolor2": "^1.4.6",
11
- "pixi-filters": "^6.1.0",
12
- "pixi.js": "^8.7.3",
11
+ "pixi-filters": "^6.1.4",
12
+ "pixi.js": "^8.14.0",
13
13
  "tinycolor2": "^1.6.0",
14
- "@gradio/atoms": "^0.18.1",
15
- "@gradio/client": "^2.0.0-dev.0",
16
- "@gradio/icons": "^0.14.0",
17
- "@gradio/upload": "^0.17.2-dev.0",
18
- "@gradio/image": "^0.23.2-dev.0",
19
- "@gradio/statustracker": "^0.11.1",
20
- "@gradio/utils": "^0.10.2"
14
+ "@gradio/atoms": "^0.19.0-dev.1",
15
+ "@gradio/icons": "^0.15.0-dev.0",
16
+ "@gradio/client": "^2.0.0-dev.2",
17
+ "@gradio/image": "^0.24.0-dev.2",
18
+ "@gradio/statustracker": "^0.12.0-dev.1",
19
+ "@gradio/upload": "^0.17.2-dev.2",
20
+ "@gradio/utils": "^0.10.3-dev.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@gradio/preview": "^0.14.0"
23
+ "@gradio/preview": "^0.15.0-dev.0"
24
24
  },
25
25
  "main_changeset": true,
26
26
  "main": "./Index.svelte",
@@ -38,7 +38,7 @@
38
38
  "./package.json": "./package.json"
39
39
  },
40
40
  "peerDependencies": {
41
- "svelte": "^4.0.0"
41
+ "svelte": "^5.43.4"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",
@@ -199,7 +199,6 @@
199
199
  ) {
200
200
  try {
201
201
  await pending_bg;
202
-
203
202
  await editor.add_layers_from_url(source.map((item) => item.url));
204
203
  dispatch("change");
205
204
  dispatch("input");
@@ -380,6 +379,7 @@
380
379
 
381
380
  editor.on("change", () => {
382
381
  dispatch("change");
382
+ dispatch("input");
383
383
  full_history = editor.command_manager.history;
384
384
  });
385
385
 
@@ -436,8 +436,6 @@
436
436
  zoom.set_zoom("fit");
437
437
  handle_tool_change({ tool: "draw" });
438
438
  dispatch("upload");
439
- dispatch("input");
440
- dispatch("change");
441
439
  }
442
440
 
443
441
  $: background_image = can_undo && editor.command_manager.contains("AddImage");
@@ -92,7 +92,7 @@
92
92
 
93
93
  const debounced_close_preview = debounce(handle_close_preview, 1000);
94
94
 
95
- $: selected_size, selected_color, handle_preview();
95
+ $: (selected_size, selected_color, handle_preview());
96
96
 
97
97
  function handle_select(color: string): void {
98
98
  selected_color = color;