@gradio/imageeditor 0.16.5 → 0.17.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/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @gradio/imageeditor
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Features
6
+
7
+ - [#11858](https://github.com/gradio-app/gradio/pull/11858) [`3f8ea13`](https://github.com/gradio-app/gradio/commit/3f8ea13a8ca92abf0ad34392e403a449fda3c6c2) - remove lite. Thanks @pngwn!
8
+
9
+ ### Fixes
10
+
11
+ - [#11784](https://github.com/gradio-app/gradio/pull/11784) [`d9dd3f5`](https://github.com/gradio-app/gradio/commit/d9dd3f54b7fb34cf7118e549d39fc63937ca3489) - Add "hidden" option to component's `visible` kwarg to render but visually hide the component. Thanks @pngwn!
12
+
13
+ ### Dependency updates
14
+
15
+ - @gradio/statustracker@0.11.1
16
+ - @gradio/atoms@0.18.0
17
+ - @gradio/client@1.19.0
18
+ - @gradio/upload@0.17.0
19
+ - @gradio/image@0.23.0
20
+
21
+ ## 0.16.6
22
+
23
+ ### Dependency updates
24
+
25
+ - @gradio/client@1.18.0
26
+ - @gradio/icons@0.14.0
27
+ - @gradio/atoms@0.17.0
28
+ - @gradio/statustracker@0.11.0
29
+ - @gradio/upload@0.16.17
30
+ - @gradio/image@0.22.18
31
+
32
+ ## 0.16.5
33
+
34
+ ### Dependency updates
35
+
36
+ - @gradio/statustracker@0.10.18
37
+
38
+ ## 0.16.5
39
+
40
+ ### Dependency updates
41
+
42
+ - @gradio/icons@0.13.1
43
+ - @gradio/upload@0.16.16
44
+
3
45
  ## 0.16.5
4
46
 
5
47
  ### Dependency updates
package/Index.svelte CHANGED
@@ -23,7 +23,7 @@
23
23
 
24
24
  export let elem_id = "";
25
25
  export let elem_classes: string[] = [];
26
- export let visible = true;
26
+ export let visible: boolean | "hidden" = true;
27
27
  export let value: EditorData | null = {
28
28
  background: null,
29
29
  layers: [],
@@ -4,12 +4,14 @@ declare const __propDef: {
4
4
  props: {
5
5
  value: EditorData;
6
6
  type: "gallery" | "table";
7
- selected?: boolean | undefined;
7
+ selected?: boolean;
8
8
  };
9
9
  events: {
10
10
  [evt: string]: CustomEvent<any>;
11
11
  };
12
12
  slots: {};
13
+ exports?: {} | undefined;
14
+ bindings?: string | undefined;
13
15
  };
14
16
  export type ExampleProps = typeof __propDef.props;
15
17
  export type ExampleEvents = typeof __propDef.events;
package/dist/Index.svelte CHANGED
@@ -56,8 +56,7 @@ export async function get_value() {
56
56
  return blobs;
57
57
  }
58
58
  let is_dragging;
59
- $:
60
- value && handle_change();
59
+ $: value && handle_change();
61
60
  const is_browser = typeof window !== "undefined";
62
61
  const raf = is_browser ? window.requestAnimationFrame : (cb) => cb();
63
62
  function wait_for_next_frame() {
@@ -81,14 +80,10 @@ function handle_history_change() {
81
80
  tick().then((_) => value_is_output = false);
82
81
  }
83
82
  }
84
- $:
85
- has_value = value?.background || value?.layers?.length || value?.composite;
86
- $:
87
- normalised_background = value?.background ? new FileData(value.background) : null;
88
- $:
89
- normalised_composite = value?.composite ? new FileData(value.composite) : null;
90
- $:
91
- normalised_layers = value?.layers?.map((layer) => new FileData(layer)) || [];
83
+ $: has_value = value?.background || value?.layers?.length || value?.composite;
84
+ $: normalised_background = value?.background ? new FileData(value.background) : null;
85
+ $: normalised_composite = value?.composite ? new FileData(value.composite) : null;
86
+ $: normalised_layers = value?.layers?.map((layer) => new FileData(layer)) || [];
92
87
  </script>
93
88
 
94
89
  {#if !interactive}
@@ -7,38 +7,38 @@ import type { LayerOptions, Transform, Source, WebcamOptions } from "./shared/ty
7
7
  import type { CommandNode } from "./shared/core/commands";
8
8
  declare const __propDef: {
9
9
  props: {
10
- elem_id?: string | undefined;
11
- elem_classes?: string[] | undefined;
12
- visible?: boolean | undefined;
13
- value?: (EditorData | null) | undefined;
10
+ elem_id?: string;
11
+ elem_classes?: string[];
12
+ visible?: boolean | "hidden";
13
+ value?: EditorData | null;
14
14
  label: string;
15
15
  show_label: boolean;
16
16
  show_download_button: boolean;
17
17
  root: string;
18
- value_is_output?: boolean | undefined;
19
- height?: number | undefined;
18
+ value_is_output?: boolean;
19
+ height?: number;
20
20
  width: number | undefined;
21
- _selectable?: boolean | undefined;
22
- container?: boolean | undefined;
23
- scale?: (number | null) | undefined;
21
+ _selectable?: boolean;
22
+ container?: boolean;
23
+ scale?: number | null;
24
24
  min_width?: number | undefined;
25
25
  loading_status: LoadingStatus;
26
- show_share_button?: boolean | undefined;
27
- sources?: Source[] | undefined;
26
+ show_share_button?: boolean;
27
+ sources?: Source[];
28
28
  interactive: boolean;
29
29
  placeholder: string | undefined;
30
30
  brush: Brush;
31
31
  eraser: Eraser;
32
- transforms?: Transform[] | undefined;
32
+ transforms?: Transform[];
33
33
  layers: LayerOptions;
34
- attached_events?: string[] | undefined;
34
+ attached_events?: string[];
35
35
  server: {
36
36
  accept_blobs: (a: any) => void;
37
37
  };
38
38
  canvas_size: [number, number];
39
- fixed_canvas?: boolean | undefined;
40
- show_fullscreen_button?: boolean | undefined;
41
- full_history?: (CommandNode | null) | undefined;
39
+ fixed_canvas?: boolean;
40
+ show_fullscreen_button?: boolean;
41
+ full_history?: CommandNode | null;
42
42
  gradio: Gradio<{
43
43
  change: never;
44
44
  error: string;
@@ -52,12 +52,12 @@ declare const __propDef: {
52
52
  share: ShareData;
53
53
  clear_status: LoadingStatus;
54
54
  }>;
55
- border_region?: number | undefined;
55
+ border_region?: number;
56
56
  webcam_options: WebcamOptions;
57
57
  theme_mode: "dark" | "light";
58
- get_value?: (() => Promise<ImageBlobs | {
58
+ get_value?: () => Promise<ImageBlobs | {
59
59
  id: string;
60
- }>) | undefined;
60
+ }>;
61
61
  };
62
62
  events: {
63
63
  error: CustomEvent<any>;
@@ -65,6 +65,8 @@ declare const __propDef: {
65
65
  [evt: string]: CustomEvent<any>;
66
66
  };
67
67
  slots: {};
68
+ exports?: {} | undefined;
69
+ bindings?: string | undefined;
68
70
  };
69
71
  export type IndexProps = typeof __propDef.props;
70
72
  export type IndexEvents = typeof __propDef.events;
@@ -79,9 +81,9 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
79
81
  get elem_classes(): string[] | undefined;
80
82
  /**accessor*/
81
83
  set elem_classes(_: string[] | undefined);
82
- get visible(): boolean | undefined;
84
+ get visible(): boolean | "hidden" | undefined;
83
85
  /**accessor*/
84
- set visible(_: boolean | undefined);
86
+ set visible(_: boolean | "hidden" | undefined);
85
87
  get value(): EditorData | null | undefined;
86
88
  /**accessor*/
87
89
  set value(_: EditorData | null | undefined);
@@ -46,9 +46,7 @@ function is_not_null(o) {
46
46
  function is_file_data(o) {
47
47
  return !!o;
48
48
  }
49
- $:
50
- if (background_image)
51
- dispatch("upload");
49
+ $: if (background_image) dispatch("upload");
52
50
  export async function get_data() {
53
51
  let blobs;
54
52
  try {
@@ -79,15 +77,13 @@ export async function get_data() {
79
77
  };
80
78
  }
81
79
  function handle_value(value) {
82
- if (!editor)
83
- return;
80
+ if (!editor) return;
84
81
  if (value == null) {
85
82
  editor.handle_remove();
86
83
  dispatch("receive_null");
87
84
  }
88
85
  }
89
- $:
90
- handle_value({ layers, composite, background });
86
+ $: handle_value({ layers, composite, background });
91
87
  let background_image = false;
92
88
  let can_undo;
93
89
  export let image_id = null;
@@ -97,8 +93,7 @@ function nextframe() {
97
93
  let uploading = false;
98
94
  let pending = false;
99
95
  async function handle_change(e) {
100
- if (!realtime)
101
- return;
96
+ if (!realtime) return;
102
97
  if (uploading) {
103
98
  pending = true;
104
99
  return;
@@ -149,8 +144,7 @@ async function handle_change(e) {
149
144
  handle_change(e);
150
145
  }
151
146
  }
152
- $:
153
- [heading, paragraph] = placeholder ? inject(placeholder) : [false, false];
147
+ $: [heading, paragraph] = placeholder ? inject(placeholder) : [false, false];
154
148
  let current_tool;
155
149
  </script>
156
150
 
@@ -23,7 +23,7 @@ declare const __propDef: {
23
23
  root: string;
24
24
  label?: string | undefined;
25
25
  show_label: boolean;
26
- changeable?: boolean | undefined;
26
+ changeable?: boolean;
27
27
  theme_mode: "dark" | "light";
28
28
  layers: FileData[];
29
29
  composite: FileData | null;
@@ -32,17 +32,17 @@ declare const __propDef: {
32
32
  transforms: Transform[];
33
33
  accept_blobs: (a: any) => void;
34
34
  canvas_size: [number, number];
35
- fixed_canvas?: boolean | undefined;
35
+ fixed_canvas?: boolean;
36
36
  realtime: boolean;
37
37
  upload: Client["upload"];
38
38
  is_dragging: boolean;
39
39
  placeholder?: string | undefined;
40
40
  border_region: number;
41
- full_history?: (CommandNode | null) | undefined;
41
+ full_history?: CommandNode | null;
42
42
  webcam_options: WebcamOptions;
43
- show_download_button?: boolean | undefined;
44
- get_data?: (() => Promise<ImageBlobs>) | undefined;
45
- image_id?: (null | string) | undefined;
43
+ show_download_button?: boolean;
44
+ get_data?: () => Promise<ImageBlobs>;
45
+ image_id?: null | string;
46
46
  };
47
47
  events: {
48
48
  history: CustomEvent<any>;
@@ -56,6 +56,8 @@ declare const __propDef: {
56
56
  [evt: string]: CustomEvent<any>;
57
57
  };
58
58
  slots: {};
59
+ exports?: {} | undefined;
60
+ bindings?: string | undefined;
59
61
  };
60
62
  export type InteractiveImageEditorProps = typeof __propDef.props;
61
63
  export type InteractiveImageEditorEvents = typeof __propDef.events;
@@ -34,8 +34,7 @@ async function handle_box_hover(i) {
34
34
  }
35
35
  let last_pos = 0;
36
36
  async function handle_box_click(i, stagger = false) {
37
- if (expanded && stagger)
38
- return;
37
+ if (expanded && stagger) return;
39
38
  const y = Math.floor(i / 3);
40
39
  const x = i % 3;
41
40
  const [initial_arrows, eventual_arrows] = get_valid_offsets({
@@ -1,14 +1,14 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
- props: {
4
- [x: string]: never;
5
- };
3
+ props: Record<string, never>;
6
4
  events: {
7
5
  position: CustomEvent<"center" | "left" | "right" | "top-left" | "top" | "top-right" | "bottom-left" | "bottom" | "bottom-right">;
8
6
  } & {
9
7
  [evt: string]: CustomEvent<any>;
10
8
  };
11
9
  slots: {};
10
+ exports?: {} | undefined;
11
+ bindings?: string | undefined;
12
12
  };
13
13
  export type AnchorProps = typeof __propDef.props;
14
14
  export type AnchorEvents = typeof __propDef.events;
@@ -33,8 +33,7 @@ function handle_zoom_keydown(e) {
33
33
  handle_zoom_change(current_zoom);
34
34
  }
35
35
  }
36
- $:
37
- formatted_zoom = Math.round(current_zoom * 100);
36
+ $: formatted_zoom = Math.round(current_zoom * 100);
38
37
  </script>
39
38
 
40
39
  <IconButtonWrapper>
@@ -1,12 +1,12 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- can_save?: boolean | undefined;
5
- changeable?: boolean | undefined;
6
- current_zoom?: number | undefined;
4
+ can_save?: boolean;
5
+ changeable?: boolean;
6
+ current_zoom?: number;
7
7
  tool: string;
8
- min_zoom?: boolean | undefined;
9
- enable_download?: boolean | undefined;
8
+ min_zoom?: boolean;
9
+ enable_download?: boolean;
10
10
  can_undo: boolean;
11
11
  can_redo: boolean;
12
12
  };
@@ -24,6 +24,8 @@ declare const __propDef: {
24
24
  [evt: string]: CustomEvent<any>;
25
25
  };
26
26
  slots: {};
27
+ exports?: {} | undefined;
28
+ bindings?: string | undefined;
27
29
  };
28
30
  export type ControlsProps = typeof __propDef.props;
29
31
  export type ControlsEvents = typeof __propDef.events;
@@ -14,8 +14,7 @@ export let background = "var(--background-fill-primary)";
14
14
  export let offset = 0;
15
15
  export let label_position = "left";
16
16
  export let roundedness = "quite";
17
- $:
18
- _color = highlight ? "var(--color-accent)" : color.toString();
17
+ $: _color = highlight ? "var(--color-accent)" : color.toString();
19
18
  </script>
20
19
 
21
20
  <button
@@ -4,20 +4,20 @@ import type { ColorInput } from "tinycolor2";
4
4
  declare const __propDef: {
5
5
  props: {
6
6
  Icon: ComponentType;
7
- label?: string | undefined;
8
- show_label?: boolean | undefined;
9
- pending?: boolean | undefined;
10
- size?: ("small" | "large" | "medium") | undefined;
11
- padded?: boolean | undefined;
12
- highlight?: boolean | undefined;
13
- disabled?: boolean | undefined;
14
- hasPopup?: boolean | undefined;
15
- color?: (string | ColorInput) | undefined;
16
- transparent?: boolean | undefined;
17
- background?: string | undefined;
18
- offset?: number | undefined;
19
- label_position?: ("left" | "right") | undefined;
20
- roundedness?: ("quite" | "very") | undefined;
7
+ label?: string;
8
+ show_label?: boolean;
9
+ pending?: boolean;
10
+ size?: "small" | "large" | "medium";
11
+ padded?: boolean;
12
+ highlight?: boolean;
13
+ disabled?: boolean;
14
+ hasPopup?: boolean;
15
+ color?: string | ColorInput;
16
+ transparent?: boolean;
17
+ background?: string;
18
+ offset?: number;
19
+ label_position?: "left" | "right";
20
+ roundedness?: "quite" | "very";
21
21
  };
22
22
  events: {
23
23
  click: MouseEvent;
@@ -25,6 +25,8 @@ declare const __propDef: {
25
25
  [evt: string]: CustomEvent<any>;
26
26
  };
27
27
  slots: {};
28
+ exports?: {} | undefined;
29
+ bindings?: string | undefined;
28
30
  };
29
31
  export type IconButtonProps = typeof __propDef.props;
30
32
  export type IconButtonEvents = typeof __propDef.events;
@@ -46,29 +46,25 @@ export let theme_mode;
46
46
  export let full_history = null;
47
47
  let pixi_target;
48
48
  let pixi_target_crop;
49
- $:
50
- if (layer_options) {
51
- if (check_if_should_init()) {
52
- editor.set_layer_options(layer_options);
53
- refresh_tools();
54
- }
49
+ $: if (layer_options) {
50
+ if (check_if_should_init()) {
51
+ editor.set_layer_options(layer_options);
52
+ refresh_tools();
55
53
  }
54
+ }
56
55
  function refresh_tools() {
57
- if (!editor || !ready)
58
- return;
56
+ if (!editor || !ready) return;
59
57
  editor.set_tool(current_tool);
60
58
  editor.set_subtool(current_subtool);
61
59
  }
62
- $:
63
- if (editor && ready && editor.layers) {
64
- const current_layers = get(editor.layers);
65
- if (current_layers.layers.length > 0 && !current_layers.active_layer) {
66
- refresh_tools_for_layer_changes(current_layers);
67
- }
60
+ $: if (editor && ready && editor.layers) {
61
+ const current_layers = get(editor.layers);
62
+ if (current_layers.layers.length > 0 && !current_layers.active_layer) {
63
+ refresh_tools_for_layer_changes(current_layers);
68
64
  }
65
+ }
69
66
  function refresh_tools_for_layer_changes(current_layers) {
70
- if (!editor || !ready)
71
- return;
67
+ if (!editor || !ready) return;
72
68
  if (current_layers.layers.length > 0 && !current_layers.active_layer) {
73
69
  editor.set_layer(current_layers.layers[0].id);
74
70
  }
@@ -87,8 +83,7 @@ function check_if_should_init() {
87
83
  }
88
84
  export let has_drawn = false;
89
85
  export async function get_blobs() {
90
- if (!editor)
91
- return { background: null, layers: [], composite: null };
86
+ if (!editor) return { background: null, layers: [], composite: null };
92
87
  if (!background_image && !has_drawn && !layers.length)
93
88
  return { background: null, layers: [], composite: null };
94
89
  const blobs = await editor.get_blobs();
@@ -100,8 +95,7 @@ export function add_image(image) {
100
95
  }
101
96
  let pending_bg;
102
97
  export async function add_image_from_url(source) {
103
- if (!editor || !source || !check_if_should_init())
104
- return;
98
+ if (!editor || !source || !check_if_should_init()) return;
105
99
  let url;
106
100
  if (typeof source === "string") {
107
101
  url = source;
@@ -126,8 +120,7 @@ export async function add_image_from_url(source) {
126
120
  }
127
121
  }
128
122
  export async function add_layers_from_url(source) {
129
- if (!editor || !source.length || !check_if_should_init())
130
- return;
123
+ if (!editor || !source.length || !check_if_should_init()) return;
131
124
  if (Array.isArray(source) && source.every((item) => item?.meta?._type === "gradio.FileData")) {
132
125
  try {
133
126
  await pending_bg;
@@ -147,8 +140,7 @@ let mounted = false;
147
140
  let min_zoom = true;
148
141
  let last_dimensions = { width: 0, height: 0 };
149
142
  async function handle_visibility_change() {
150
- if (!editor || !ready || !zoom)
151
- return;
143
+ if (!editor || !ready || !zoom) return;
152
144
  await tick();
153
145
  const is_visible = pixi_target.offsetParent !== null;
154
146
  if (is_visible) {
@@ -199,8 +191,7 @@ onMount(() => {
199
191
  };
200
192
  });
201
193
  function refresh_tools_after_history() {
202
- if (!editor || !ready)
203
- return;
194
+ if (!editor || !ready) return;
204
195
  const current_layers = get(editor.layers);
205
196
  if (current_layers.layers.length > 0 && !current_layers.active_layer) {
206
197
  editor.set_layer(current_layers.layers[0].id);
@@ -288,21 +279,17 @@ async function init_image_editor() {
288
279
  }
289
280
  refresh_tools();
290
281
  }
291
- $:
292
- if (background == null && layers.length == 0 && composite == null && editor && ready) {
293
- editor.reset_canvas();
294
- zoom.set_zoom("fit");
295
- handle_tool_change({ tool: "image" });
296
- background_image = false;
297
- has_drawn = false;
298
- }
299
- $:
300
- current_tool === "image" && current_subtool === "crop" && crop_zoom.set_zoom("fit");
282
+ $: if (background == null && layers.length == 0 && composite == null && editor && ready) {
283
+ editor.reset_canvas();
284
+ zoom.set_zoom("fit");
285
+ handle_tool_change({ tool: "image" });
286
+ background_image = false;
287
+ has_drawn = false;
288
+ }
289
+ $: current_tool === "image" && current_subtool === "crop" && crop_zoom.set_zoom("fit");
301
290
  async function handle_files(files) {
302
- if (files == null)
303
- return;
304
- if (!sources.includes("upload"))
305
- return;
291
+ if (files == null) return;
292
+ if (!sources.includes("upload")) return;
306
293
  editor.reset_canvas();
307
294
  const _file = Array.isArray(files) ? files[0] : files;
308
295
  await editor.add_image({ image: _file });
@@ -315,8 +302,7 @@ async function handle_files(files) {
315
302
  dispatch("input");
316
303
  dispatch("change");
317
304
  }
318
- $:
319
- background_image = can_undo && editor.command_manager.contains("AddImage");
305
+ $: background_image = can_undo && editor.command_manager.contains("AddImage");
320
306
  function handle_tool_change({ tool }) {
321
307
  editor.set_tool(tool);
322
308
  current_tool = tool;
@@ -388,37 +374,31 @@ function update_eraser_options() {
388
374
  }
389
375
  let brush_size_visible = false;
390
376
  let brush_color_visible = false;
391
- $:
392
- brush?.set_brush_color(
393
- (() => {
394
- let color_value;
395
- if (selected_color === "auto") {
396
- const default_color = brush_options.colors.find(
397
- (color) => Array.isArray(color) ? color[0] === brush_options.default_color : color === brush_options.default_color
398
- ) || brush_options.colors[0];
399
- color_value = Array.isArray(default_color) ? default_color[0] : default_color;
400
- } else {
401
- color_value = selected_color;
402
- }
403
- return color_value;
404
- })()
405
- );
406
- $:
407
- brush?.set_brush_size(
408
- typeof selected_size === "number" ? selected_size : 25
409
- );
410
- $:
411
- brush?.set_eraser_size(
412
- typeof selected_eraser_size === "number" ? selected_eraser_size : 25
413
- );
414
- $:
415
- disable_click = current_tool !== "image" || current_tool === "image" && background_image || current_tool === "image" && current_subtool === "webcam" || !sources.includes("upload");
377
+ $: brush?.set_brush_color(
378
+ (() => {
379
+ let color_value;
380
+ if (selected_color === "auto") {
381
+ const default_color = brush_options.colors.find(
382
+ (color) => Array.isArray(color) ? color[0] === brush_options.default_color : color === brush_options.default_color
383
+ ) || brush_options.colors[0];
384
+ color_value = Array.isArray(default_color) ? default_color[0] : default_color;
385
+ } else {
386
+ color_value = selected_color;
387
+ }
388
+ return color_value;
389
+ })()
390
+ );
391
+ $: brush?.set_brush_size(
392
+ typeof selected_size === "number" ? selected_size : 25
393
+ );
394
+ $: brush?.set_eraser_size(
395
+ typeof selected_eraser_size === "number" ? selected_eraser_size : 25
396
+ );
397
+ $: disable_click = current_tool !== "image" || current_tool === "image" && background_image || current_tool === "image" && current_subtool === "webcam" || !sources.includes("upload");
416
398
  let current_subtool = null;
417
399
  let preview = false;
418
- $:
419
- brush?.preview_brush(preview);
420
- $:
421
- brush?.set_brush_opacity(selected_opacity);
400
+ $: brush?.preview_brush(preview);
401
+ $: brush?.set_brush_opacity(selected_opacity);
422
402
  function handle_zoom_change(zoom_level2) {
423
403
  zoom.set_zoom(zoom_level2);
424
404
  }
@@ -446,14 +426,11 @@ function handle_capture(e) {
446
426
  function handle_save() {
447
427
  dispatch("save");
448
428
  }
449
- $:
450
- add_image_from_url(composite || background);
451
- $:
452
- add_layers_from_url(layers);
429
+ $: add_image_from_url(composite || background);
430
+ $: add_layers_from_url(layers);
453
431
  async function handle_crop_confirm() {
454
432
  const { image } = await crop.get_crop_bounds();
455
- if (!image)
456
- return;
433
+ if (!image) return;
457
434
  await editor.add_image({
458
435
  image,
459
436
  resize: false
@@ -10,40 +10,40 @@ import type { LayerOptions, Source, Transform, WebcamOptions } from "./types";
10
10
  import { type ImageBlobs } from "./types";
11
11
  declare const __propDef: {
12
12
  props: {
13
- antialias?: true | undefined;
14
- changeable?: boolean | undefined;
15
- sources?: Source[] | undefined;
16
- transforms?: Transform[] | undefined;
13
+ antialias?: true;
14
+ changeable?: boolean;
15
+ sources?: Source[];
16
+ transforms?: Transform[];
17
17
  canvas_size: [number, number];
18
- is_dragging?: boolean | undefined;
19
- background_image?: boolean | undefined;
18
+ is_dragging?: boolean;
19
+ background_image?: boolean;
20
20
  brush_options: Brush;
21
21
  eraser_options: Eraser;
22
- fixed_canvas?: boolean | undefined;
22
+ fixed_canvas?: boolean;
23
23
  root: string;
24
24
  i18n: I18nFormatter;
25
25
  upload: Client["upload"];
26
26
  composite: FileData | null;
27
27
  layers: FileData[];
28
28
  background: FileData | null;
29
- border_region?: number | undefined;
29
+ border_region?: number;
30
30
  layer_options: LayerOptions;
31
31
  current_tool: ToolbarTool;
32
32
  webcam_options: WebcamOptions;
33
- show_download_button?: boolean | undefined;
33
+ show_download_button?: boolean;
34
34
  theme_mode: "dark" | "light";
35
- full_history?: (CommandNode | null) | undefined;
36
- has_drawn?: boolean | undefined;
37
- get_blobs?: (() => Promise<ImageBlobs>) | undefined;
38
- add_image?: ((image: Blob | File) => void) | undefined;
39
- add_image_from_url?: ((source: string | {
35
+ full_history?: CommandNode | null;
36
+ has_drawn?: boolean;
37
+ get_blobs?: () => Promise<ImageBlobs>;
38
+ add_image?: (image: Blob | File) => void;
39
+ add_image_from_url?: (source: string | {
40
40
  url: string;
41
41
  meta: {
42
42
  _type: string;
43
43
  };
44
- } | any) => Promise<void>) | undefined;
45
- add_layers_from_url?: ((source: FileData[] | any) => Promise<void>) | undefined;
46
- can_undo?: boolean | undefined;
44
+ } | any) => Promise<void>;
45
+ add_layers_from_url?: (source: FileData[] | any) => Promise<void>;
46
+ can_undo?: boolean;
47
47
  };
48
48
  events: {
49
49
  error: CustomEvent<string>;
@@ -60,6 +60,8 @@ declare const __propDef: {
60
60
  slots: {
61
61
  default: {};
62
62
  };
63
+ exports?: {} | undefined;
64
+ bindings?: string | undefined;
63
65
  };
64
66
  export type ImageEditorProps = typeof __propDef.props;
65
67
  export type ImageEditorEvents = typeof __propDef.events;
@@ -11,9 +11,9 @@ declare const __propDef: {
11
11
  visible: boolean;
12
12
  }[];
13
13
  }>;
14
- enable_additional_layers?: boolean | undefined;
15
- enable_layers?: boolean | undefined;
16
- show_layers?: boolean | undefined;
14
+ enable_additional_layers?: boolean;
15
+ enable_layers?: boolean;
16
+ show_layers?: boolean;
17
17
  };
18
18
  events: {
19
19
  new_layer: CustomEvent<void>;
@@ -28,6 +28,8 @@ declare const __propDef: {
28
28
  [evt: string]: CustomEvent<any>;
29
29
  };
30
30
  slots: {};
31
+ exports?: {} | undefined;
32
+ bindings?: string | undefined;
31
33
  };
32
34
  export type LayersProps = typeof __propDef.props;
33
35
  export type LayersEvents = typeof __propDef.events;
@@ -20,6 +20,8 @@ declare const __propDef: {
20
20
  [evt: string]: CustomEvent<any>;
21
21
  };
22
22
  slots: {};
23
+ exports?: {} | undefined;
24
+ bindings?: string | undefined;
23
25
  };
24
26
  export type ResizeProps = typeof __propDef.props;
25
27
  export type ResizeEvents = typeof __propDef.events;
@@ -11,9 +11,9 @@ declare const __propDef: {
11
11
  visible: boolean;
12
12
  }[];
13
13
  }>;
14
- enable_additional_layers?: boolean | undefined;
15
- enable_layers?: boolean | undefined;
16
- show_layers?: boolean | undefined;
14
+ enable_additional_layers?: boolean;
15
+ enable_layers?: boolean;
16
+ show_layers?: boolean;
17
17
  };
18
18
  events: {
19
19
  new_layer: CustomEvent<void>;
@@ -28,6 +28,8 @@ declare const __propDef: {
28
28
  [evt: string]: CustomEvent<any>;
29
29
  };
30
30
  slots: {};
31
+ exports?: {} | undefined;
32
+ bindings?: string | undefined;
31
33
  };
32
34
  export type SecondaryToolbarProps = typeof __propDef.props;
33
35
  export type SecondaryToolbarEvents = typeof __propDef.events;
@@ -60,22 +60,14 @@ function handle_subtool_click(e, _subtool) {
60
60
  e.stopPropagation();
61
61
  dispatch("subtool_change", { tool, subtool: _subtool });
62
62
  }
63
- $:
64
- show_brush_size = tool === "draw" && subtool === "size";
65
- $:
66
- show_brush_color = tool === "draw" && subtool === "color";
67
- $:
68
- show_eraser_size = tool === "erase" && subtool === "size";
69
- $:
70
- can_crop = transforms.includes("crop");
71
- $:
72
- can_resize = transforms.includes("resize");
73
- $:
74
- can_upload = sources.includes("upload");
75
- $:
76
- can_webcam = sources.includes("webcam");
77
- $:
78
- can_paste = sources.includes("clipboard");
63
+ $: show_brush_size = tool === "draw" && subtool === "size";
64
+ $: show_brush_color = tool === "draw" && subtool === "color";
65
+ $: show_eraser_size = tool === "erase" && subtool === "size";
66
+ $: can_crop = transforms.includes("crop");
67
+ $: can_resize = transforms.includes("resize");
68
+ $: can_upload = sources.includes("upload");
69
+ $: can_webcam = sources.includes("webcam");
70
+ $: can_paste = sources.includes("clipboard");
79
71
  </script>
80
72
 
81
73
  <div class="toolbar-wrap">
@@ -5,19 +5,19 @@ import type { Source, Transform } from "./types";
5
5
  import { type Brush as BrushType, type Eraser as EraserType } from "./brush/types";
6
6
  declare const __propDef: {
7
7
  props: {
8
- tool?: Tool | undefined;
9
- subtool?: Subtool | undefined;
10
- background?: boolean | undefined;
8
+ tool?: Tool;
9
+ subtool?: Subtool;
10
+ background?: boolean;
11
11
  brush_options: BrushType | false;
12
- selected_size?: number | undefined;
12
+ selected_size?: number;
13
13
  eraser_options: EraserType;
14
- selected_eraser_size?: number | undefined;
14
+ selected_eraser_size?: number;
15
15
  selected_color?: any;
16
16
  selected_opacity?: any;
17
- preview?: boolean | undefined;
18
- show_brush_color?: boolean | undefined;
19
- show_brush_size?: boolean | undefined;
20
- show_eraser_size?: boolean | undefined;
17
+ preview?: boolean;
18
+ show_brush_color?: boolean;
19
+ show_brush_size?: boolean;
20
+ show_eraser_size?: boolean;
21
21
  sources: Source[];
22
22
  transforms: Transform[];
23
23
  };
@@ -33,6 +33,8 @@ declare const __propDef: {
33
33
  [evt: string]: CustomEvent<any>;
34
34
  };
35
35
  slots: {};
36
+ exports?: {} | undefined;
37
+ bindings?: string | undefined;
36
38
  };
37
39
  export type ToolbarProps = typeof __propDef.props;
38
40
  export type ToolbarEvents = typeof __propDef.events;
@@ -27,8 +27,7 @@ function handle_color_selection({
27
27
  editing_index = index;
28
28
  color_picker = true;
29
29
  }
30
- if (!color)
31
- return;
30
+ if (!color) return;
32
31
  selected_color = color;
33
32
  if (opacity !== void 0) {
34
33
  selected_opacity = opacity;
@@ -38,12 +37,10 @@ function handle_color_selection({
38
37
  }
39
38
  }
40
39
  function handle_color_change(color) {
41
- if (editing_index === null)
42
- return;
40
+ if (editing_index === null) return;
43
41
  recent_colors[editing_index] = color;
44
42
  }
45
- $:
46
- handle_color_change(selected_color);
43
+ $: handle_color_change(selected_color);
47
44
  let width = 0;
48
45
  let height = 0;
49
46
  function debounce(func, delay) {
@@ -66,8 +63,7 @@ function handle_close_preview() {
66
63
  preview = false;
67
64
  }
68
65
  const debounced_close_preview = debounce(handle_close_preview, 1e3);
69
- $:
70
- selected_size, selected_color, handle_preview();
66
+ $: selected_size, selected_color, handle_preview();
71
67
  function handle_select(color) {
72
68
  selected_color = color;
73
69
  }
@@ -6,13 +6,13 @@ declare const __propDef: {
6
6
  colors: (ColorInput | ColorTuple)[];
7
7
  selected_color: any;
8
8
  color_mode?: Brush["color_mode"] | undefined;
9
- recent_colors?: (ColorInput | ColorTuple)[] | undefined;
9
+ recent_colors?: (ColorInput | ColorTuple)[];
10
10
  selected_size: number;
11
11
  selected_opacity: number;
12
12
  show_swatch: boolean;
13
13
  show_size: boolean;
14
- mode?: ("brush" | "eraser") | undefined;
15
- preview?: boolean | undefined;
14
+ mode?: "brush" | "eraser";
15
+ preview?: boolean;
16
16
  };
17
17
  events: {
18
18
  click_outside: CustomEvent<void>;
@@ -20,6 +20,8 @@ declare const __propDef: {
20
20
  [evt: string]: CustomEvent<any>;
21
21
  };
22
22
  slots: {};
23
+ exports?: {} | undefined;
24
+ bindings?: string | undefined;
23
25
  };
24
26
  export type BrushOptionsProps = typeof __propDef.props;
25
27
  export type BrushOptionsEvents = typeof __propDef.events;
@@ -11,6 +11,8 @@ declare const __propDef: {
11
11
  [evt: string]: CustomEvent<any>;
12
12
  };
13
13
  slots: {};
14
+ exports?: {} | undefined;
15
+ bindings?: string | undefined;
14
16
  };
15
17
  export type BrushSizeProps = typeof __propDef.props;
16
18
  export type BrushSizeEvents = typeof __propDef.events;
@@ -18,10 +18,8 @@ function format_color(color2, mode) {
18
18
  }
19
19
  return tinycolor(color2).toHslString();
20
20
  }
21
- $:
22
- color_string = format_color(color, current_mode);
23
- $:
24
- color_string && dispatch("selected", color_string);
21
+ $: color_string = format_color(color, current_mode);
22
+ $: color_string && dispatch("selected", color_string);
25
23
  function request_eyedropper() {
26
24
  const eyeDropper = new EyeDropper();
27
25
  eyeDropper.open().then((result) => {
@@ -2,7 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  color: string;
5
- current_mode?: ("hex" | "rgb" | "hsl") | undefined;
5
+ current_mode?: "hex" | "rgb" | "hsl";
6
6
  };
7
7
  events: {
8
8
  selected: CustomEvent<string>;
@@ -12,6 +12,8 @@ declare const __propDef: {
12
12
  [evt: string]: CustomEvent<any>;
13
13
  };
14
14
  slots: {};
15
+ exports?: {} | undefined;
16
+ bindings?: string | undefined;
15
17
  };
16
18
  export type ColorFieldProps = typeof __propDef.props;
17
19
  export type ColorFieldEvents = typeof __propDef.events;
@@ -17,8 +17,7 @@ function handle_hue_down(event) {
17
17
  update_hue_from_mouse(event.clientX);
18
18
  }
19
19
  function update_hue_from_mouse(x) {
20
- if (!hue_rect)
21
- return;
20
+ if (!hue_rect) return;
22
21
  const _x = clamp(x - hue_rect.left, 0, hue_rect.width);
23
22
  hue_marker_pos = _x;
24
23
  const _hue = _x / hue_rect.width * 360;
@@ -41,8 +40,7 @@ function hsva_to_rgba(hsva) {
41
40
  return `rgba(${red * 255}, ${green * 255}, ${blue * 255}, ${hsva.a})`;
42
41
  }
43
42
  function update_color_from_mouse(x, y) {
44
- if (!sl_rect)
45
- return;
43
+ if (!sl_rect) return;
46
44
  const _x = clamp(x - sl_rect.left, 0, sl_rect.width);
47
45
  const _y = clamp(y - sl_rect.top, 0, sl_rect.height);
48
46
  sl_marker_pos = [_x, _y];
@@ -61,27 +59,19 @@ function handle_sl_down(event) {
61
59
  update_color_from_mouse(event.clientX, event.clientY);
62
60
  }
63
61
  function handle_move(event) {
64
- if (sl_moving)
65
- update_color_from_mouse(event.clientX, event.clientY);
66
- if (hue_moving)
67
- update_hue_from_mouse(event.clientX);
68
- if (opacity_moving)
69
- update_opacity_from_mouse(event.clientX);
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);
70
65
  }
71
66
  function handle_end() {
72
- if (sl_moving)
73
- sl_moving = false;
74
- if (hue_moving)
75
- hue_moving = false;
76
- if (opacity_moving)
77
- opacity_moving = false;
67
+ if (sl_moving) sl_moving = false;
68
+ if (hue_moving) hue_moving = false;
69
+ if (opacity_moving) opacity_moving = false;
78
70
  }
79
71
  async function update_mouse_from_color(color2) {
80
- if (sl_moving || hue_moving)
81
- return;
72
+ if (sl_moving || hue_moving) return;
82
73
  await tick();
83
- if (!color2)
84
- return;
74
+ if (!color2) return;
85
75
  if (!sl_rect) {
86
76
  sl_rect = sl_wrap.getBoundingClientRect();
87
77
  }
@@ -96,8 +86,7 @@ async function update_mouse_from_color(color2) {
96
86
  hue = hsva.h;
97
87
  hue_marker_pos = hsva.h / 360 * hue_rect.width;
98
88
  }
99
- $:
100
- update_mouse_from_color(color);
89
+ $: update_mouse_from_color(color);
101
90
  let sl_wrap;
102
91
  let hue_wrap;
103
92
  export let opacity = 1;
@@ -109,8 +98,7 @@ function handle_opacity_down(event) {
109
98
  }
110
99
  let opacity_rect = null;
111
100
  function update_opacity_from_mouse(x) {
112
- if (!opacity_rect)
113
- return;
101
+ if (!opacity_rect) return;
114
102
  const _x = clamp(x - opacity_rect.left, 0, opacity_rect.width);
115
103
  opacity = _x / opacity_rect.width;
116
104
  }
@@ -1,13 +1,15 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- color?: string | undefined;
5
- opacity?: number | undefined;
4
+ color?: string;
5
+ opacity?: number;
6
6
  };
7
7
  events: {
8
8
  [evt: string]: CustomEvent<any>;
9
9
  };
10
10
  slots: {};
11
+ exports?: {} | undefined;
12
+ bindings?: string | undefined;
11
13
  };
12
14
  export type ColorPickerProps = typeof __propDef.props;
13
15
  export type ColorPickerEvents = typeof __propDef.events;
@@ -9,8 +9,7 @@ export let show_empty = false;
9
9
  export let current_mode = "hex";
10
10
  export let color_picker = false;
11
11
  const dispatch = createEventDispatcher();
12
- $:
13
- _colors = show_empty ? colors : colors.filter((c) => c);
12
+ $: _colors = show_empty ? colors : colors.filter((c) => c);
14
13
  function get_color(color_input) {
15
14
  if (Array.isArray(color_input)) {
16
15
  return color_input[0];
@@ -36,8 +35,7 @@ function get_formatted_color(color, mode) {
36
35
  let current_index = `select-${colors.findIndex(
37
36
  (c) => get_formatted_color(c, current_mode) === get_formatted_color(selected_color, current_mode)
38
37
  )}`;
39
- $:
40
- selected_opacity = get_opacity(selected_color);
38
+ $: selected_opacity = get_opacity(selected_color);
41
39
  function handle_select(type, detail) {
42
40
  current_index = `${type}-${detail.index}`;
43
41
  dispatch(type, detail);
@@ -5,10 +5,10 @@ declare const __propDef: {
5
5
  props: {
6
6
  selected_color: string;
7
7
  colors: (ColorInput | ColorTuple)[];
8
- user_colors?: ((ColorInput | ColorTuple)[] | null) | undefined;
9
- show_empty?: boolean | undefined;
10
- current_mode?: ("hex" | "rgb" | "hsl") | undefined;
11
- color_picker?: boolean | undefined;
8
+ user_colors?: (ColorInput | ColorTuple)[] | null;
9
+ show_empty?: boolean;
10
+ current_mode?: "hex" | "rgb" | "hsl";
11
+ color_picker?: boolean;
12
12
  };
13
13
  events: {
14
14
  select: CustomEvent<{
@@ -25,6 +25,8 @@ declare const __propDef: {
25
25
  [evt: string]: CustomEvent<any>;
26
26
  };
27
27
  slots: {};
28
+ exports?: {} | undefined;
29
+ bindings?: string | undefined;
28
30
  };
29
31
  export type ColorSwatchProps = typeof __propDef.props;
30
32
  export type ColorSwatchEvents = typeof __propDef.events;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/imageeditor",
3
- "version": "0.16.5",
3
+ "version": "0.17.0",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -11,14 +11,13 @@
11
11
  "pixi-filters": "^6.1.0",
12
12
  "pixi.js": "^8.7.3",
13
13
  "tinycolor2": "^1.6.0",
14
- "@gradio/atoms": "^0.16.5",
15
- "@gradio/client": "^1.17.1",
16
- "@gradio/image": "^0.22.17",
17
- "@gradio/statustracker": "^0.10.17",
18
- "@gradio/upload": "^0.16.15",
14
+ "@gradio/atoms": "^0.18.0",
15
+ "@gradio/icons": "^0.14.0",
16
+ "@gradio/client": "^1.19.0",
17
+ "@gradio/image": "^0.23.0",
18
+ "@gradio/upload": "^0.17.0",
19
19
  "@gradio/utils": "^0.10.2",
20
- "@gradio/icons": "^0.13.0",
21
- "@gradio/wasm": "^0.18.1"
20
+ "@gradio/statustracker": "^0.11.1"
22
21
  },
23
22
  "devDependencies": {
24
23
  "@gradio/preview": "^0.14.0"