@gradio/imageeditor 0.12.14 → 0.14.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 +36 -0
- package/Example.svelte +1 -1
- package/IMAGE_EDITOR_OVERVIEW.md +224 -0
- package/ImageEditor.stories.svelte +13 -5
- package/Index.svelte +46 -45
- package/{shared/InteractiveImageEditor.svelte → InteractiveImageEditor.svelte} +65 -103
- package/README.md +2 -0
- package/dist/Example.svelte.d.ts +1 -1
- package/dist/Index.svelte +35 -33
- package/dist/Index.svelte.d.ts +25 -16
- package/dist/{shared/InteractiveImageEditor.svelte → InteractiveImageEditor.svelte} +54 -88
- package/dist/{shared/InteractiveImageEditor.svelte.d.ts → InteractiveImageEditor.svelte.d.ts} +17 -15
- package/dist/shared/Anchor.svelte +311 -0
- package/dist/shared/Anchor.svelte.d.ts +18 -0
- package/dist/shared/Controls.svelte +169 -18
- package/dist/shared/Controls.svelte.d.ts +9 -2
- package/dist/shared/{tools/IconButton.svelte → IconButton.svelte} +19 -3
- package/dist/shared/{tools/IconButton.svelte.d.ts → IconButton.svelte.d.ts} +4 -1
- package/dist/shared/ImageEditor.svelte +572 -289
- package/dist/shared/ImageEditor.svelte.d.ts +54 -56
- package/dist/shared/Layers.svelte +260 -0
- package/dist/shared/Layers.svelte.d.ts +37 -0
- package/dist/shared/Resize.svelte +218 -0
- package/dist/shared/Resize.svelte.d.ts +29 -0
- package/dist/shared/SecondaryToolbar.svelte +55 -0
- package/dist/shared/SecondaryToolbar.svelte.d.ts +37 -0
- package/dist/shared/Toolbar.svelte +337 -0
- package/dist/shared/Toolbar.svelte.d.ts +42 -0
- package/dist/shared/{tools → brush}/BrushOptions.svelte +68 -64
- package/dist/shared/{tools → brush}/BrushOptions.svelte.d.ts +9 -9
- package/dist/shared/{tools → brush}/BrushSize.svelte +2 -27
- package/dist/shared/{tools → brush}/ColorField.svelte +2 -1
- package/dist/shared/{tools → brush}/ColorField.svelte.d.ts +1 -0
- package/dist/shared/{tools → brush}/ColorPicker.svelte +81 -9
- package/dist/shared/{tools → brush}/ColorPicker.svelte.d.ts +1 -0
- package/dist/shared/{tools → brush}/ColorSwatch.svelte +78 -38
- package/dist/shared/{tools → brush}/ColorSwatch.svelte.d.ts +6 -2
- package/dist/shared/brush/brush-cursor.d.ts +101 -0
- package/dist/shared/brush/brush-cursor.js +327 -0
- package/dist/shared/brush/brush-textures.d.ts +65 -0
- package/dist/shared/brush/brush-textures.js +385 -0
- package/dist/shared/brush/brush-utils.d.ts +32 -0
- package/dist/shared/brush/brush-utils.js +59 -0
- package/dist/shared/brush/brush.d.ts +152 -0
- package/dist/shared/brush/brush.js +397 -0
- package/dist/shared/brush/types.d.ts +37 -0
- package/dist/shared/brush/types.js +1 -0
- package/dist/shared/core/editor.d.ts +261 -0
- package/dist/shared/core/editor.js +1264 -0
- package/dist/shared/crop/crop.d.ts +201 -0
- package/dist/shared/crop/crop.js +727 -0
- package/dist/shared/image/image.d.ts +89 -0
- package/dist/shared/image/image.js +183 -0
- package/dist/shared/resize/resize.d.ts +270 -0
- package/dist/shared/resize/resize.js +1413 -0
- package/dist/shared/types.d.ts +16 -0
- package/dist/shared/utils/pixi.d.ts +16 -57
- package/dist/shared/utils/pixi.js +15 -113
- package/dist/shared/zoom/zoom.d.ts +136 -0
- package/dist/shared/zoom/zoom.js +548 -0
- package/package.json +8 -7
- package/shared/Anchor.svelte +384 -0
- package/shared/Controls.svelte +178 -37
- package/shared/{tools/IconButton.svelte → IconButton.svelte} +21 -4
- package/shared/ImageEditor.svelte +712 -350
- package/shared/Layers.svelte +282 -0
- package/shared/Resize.svelte +239 -0
- package/shared/SecondaryToolbar.svelte +67 -0
- package/shared/Toolbar.svelte +386 -0
- package/shared/brush/BRUSH_TOOL.md +134 -0
- package/shared/brush/BrushOptions.svelte +200 -0
- package/shared/{tools → brush}/BrushSize.svelte +2 -30
- package/shared/{tools → brush}/ColorField.svelte +3 -1
- package/shared/{tools → brush}/ColorPicker.svelte +86 -9
- package/shared/{tools → brush}/ColorSwatch.svelte +95 -42
- package/shared/brush/brush-cursor.ts +408 -0
- package/shared/brush/brush-textures.ts +485 -0
- package/shared/brush/brush-utils.ts +76 -0
- package/shared/brush/brush.ts +510 -0
- package/shared/brush/types.ts +41 -0
- package/shared/core/EDITOR.md +182 -0
- package/shared/core/editor.ts +1788 -0
- package/shared/crop/CROP.md +139 -0
- package/shared/crop/crop.ts +1027 -0
- package/shared/image/IMAGE.md +135 -0
- package/shared/image/image.ts +298 -0
- package/shared/resize/resize.ts +1894 -0
- package/shared/types.ts +19 -0
- package/shared/utils/pixi.ts +19 -246
- package/shared/zoom/zoom.ts +729 -0
- package/dist/shared/layers/Layers.svelte +0 -231
- package/dist/shared/layers/Layers.svelte.d.ts +0 -18
- package/dist/shared/layers/utils.d.ts +0 -73
- package/dist/shared/layers/utils.js +0 -156
- package/dist/shared/tools/Brush.svelte +0 -215
- package/dist/shared/tools/Brush.svelte.d.ts +0 -29
- package/dist/shared/tools/Crop.svelte +0 -155
- package/dist/shared/tools/Crop.svelte.d.ts +0 -16
- package/dist/shared/tools/Cropper.svelte +0 -271
- package/dist/shared/tools/Cropper.svelte.d.ts +0 -41
- package/dist/shared/tools/Handle.svelte +0 -260
- package/dist/shared/tools/Handle.svelte.d.ts +0 -29
- package/dist/shared/tools/Sources.svelte +0 -257
- package/dist/shared/tools/Sources.svelte.d.ts +0 -34
- package/dist/shared/tools/Tools.svelte +0 -102
- package/dist/shared/tools/Tools.svelte.d.ts +0 -48
- package/dist/shared/tools/brush.d.ts +0 -62
- package/dist/shared/tools/brush.js +0 -133
- package/dist/shared/tools/crop.d.ts +0 -15
- package/dist/shared/tools/crop.js +0 -154
- package/dist/shared/tools/index.d.ts +0 -5
- package/dist/shared/tools/index.js +0 -5
- package/dist/shared/tools/sources.d.ts +0 -46
- package/dist/shared/tools/sources.js +0 -121
- package/dist/shared/tools/types.d.ts +0 -1
- package/shared/layers/Layers.svelte +0 -250
- package/shared/layers/utils.ts +0 -294
- package/shared/tools/Brush.svelte +0 -280
- package/shared/tools/BrushOptions.svelte +0 -180
- package/shared/tools/Crop.svelte +0 -189
- package/shared/tools/Cropper.svelte +0 -346
- package/shared/tools/Handle.svelte +0 -289
- package/shared/tools/Sources.svelte +0 -283
- package/shared/tools/Tools.svelte +0 -162
- package/shared/tools/brush.ts +0 -247
- package/shared/tools/crop.ts +0 -213
- package/shared/tools/index.ts +0 -5
- package/shared/tools/sources.ts +0 -195
- package/shared/tools/types.ts +0 -1
- /package/dist/shared/{tools → brush}/BrushSize.svelte.d.ts +0 -0
- /package/dist/shared/{tools/types.js → types.js} +0 -0
|
@@ -16,50 +16,53 @@
|
|
|
16
16
|
import { createEventDispatcher } from "svelte";
|
|
17
17
|
import { type I18nFormatter } from "@gradio/utils";
|
|
18
18
|
import { prepare_files, type FileData, type Client } from "@gradio/client";
|
|
19
|
-
import { type CommandNode } from "./utils/commands";
|
|
20
|
-
import ImageEditor from "./ImageEditor.svelte";
|
|
21
|
-
import Layers from "./layers/Layers.svelte";
|
|
22
|
-
import { type Brush as IBrush } from "./
|
|
23
|
-
import { type Eraser } from "./tools/Brush.svelte";
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
import { type CommandNode } from "./shared/utils/commands";
|
|
20
|
+
import ImageEditor from "./shared/ImageEditor.svelte";
|
|
21
|
+
// import Layers from "./layers/Layers.svelte";
|
|
22
|
+
import { type Brush as IBrush, type Eraser } from "./shared/brush/types";
|
|
23
|
+
// import { type Eraser } from "./tools/Brush.svelte";
|
|
24
|
+
import { type Tool as ToolbarTool } from "./shared/Toolbar.svelte";
|
|
25
|
+
|
|
26
|
+
// import { Tools, Crop, Brush, Sources } from "./tools";
|
|
26
27
|
import { BlockLabel } from "@gradio/atoms";
|
|
27
28
|
import { Image as ImageIcon } from "@gradio/icons";
|
|
28
|
-
import { inject } from "./utils/parse_placeholder";
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
import { inject } from "./shared/utils/parse_placeholder";
|
|
30
|
+
// import Sources from "./shared/image/Sources.svelte";
|
|
31
|
+
import {
|
|
32
|
+
type LayerOptions,
|
|
33
|
+
type Transform,
|
|
34
|
+
type Source,
|
|
35
|
+
type WebcamOptions
|
|
36
|
+
} from "./shared/types";
|
|
37
|
+
|
|
38
|
+
export let brush: IBrush;
|
|
39
|
+
export let eraser: Eraser;
|
|
40
|
+
export let sources: Source[];
|
|
34
41
|
export let i18n: I18nFormatter;
|
|
35
42
|
export let root: string;
|
|
36
43
|
export let label: string | undefined = undefined;
|
|
37
44
|
export let show_label: boolean;
|
|
38
45
|
export let changeable = false;
|
|
39
|
-
export let
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export let
|
|
46
|
+
export let theme_mode: "dark" | "light";
|
|
47
|
+
|
|
48
|
+
export let layers: FileData[];
|
|
49
|
+
export let composite: FileData | null;
|
|
50
|
+
export let background: FileData | null;
|
|
51
|
+
|
|
52
|
+
export let layer_options: LayerOptions;
|
|
53
|
+
export let transforms: Transform[];
|
|
46
54
|
export let accept_blobs: (a: any) => void;
|
|
47
|
-
|
|
48
|
-
| "pending"
|
|
49
|
-
| "complete"
|
|
50
|
-
| "error"
|
|
51
|
-
| "generating"
|
|
52
|
-
| "streaming" = "complete";
|
|
55
|
+
|
|
53
56
|
export let canvas_size: [number, number];
|
|
54
57
|
export let fixed_canvas = false;
|
|
55
58
|
export let realtime: boolean;
|
|
56
59
|
export let upload: Client["upload"];
|
|
57
|
-
export let
|
|
58
|
-
export let dragging: boolean;
|
|
60
|
+
export let is_dragging: boolean;
|
|
59
61
|
export let placeholder: string | undefined = undefined;
|
|
60
|
-
export let
|
|
61
|
-
export let height;
|
|
62
|
+
export let border_region: number;
|
|
62
63
|
export let full_history: CommandNode | null = null;
|
|
64
|
+
export let webcam_options: WebcamOptions;
|
|
65
|
+
export let show_download_button = false;
|
|
63
66
|
|
|
64
67
|
const dispatch = createEventDispatcher<{
|
|
65
68
|
clear?: never;
|
|
@@ -69,6 +72,7 @@
|
|
|
69
72
|
}>();
|
|
70
73
|
|
|
71
74
|
let editor: ImageEditor;
|
|
75
|
+
let has_drawn = false;
|
|
72
76
|
|
|
73
77
|
function is_not_null(o: Blob | null): o is Blob {
|
|
74
78
|
return !!o;
|
|
@@ -78,7 +82,7 @@
|
|
|
78
82
|
return !!o;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
$: if (
|
|
85
|
+
$: if (background_image) dispatch("upload");
|
|
82
86
|
|
|
83
87
|
export async function get_data(): Promise<ImageBlobs> {
|
|
84
88
|
let blobs;
|
|
@@ -131,19 +135,13 @@
|
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
|
|
134
|
-
$: handle_value(
|
|
135
|
-
|
|
136
|
-
let
|
|
138
|
+
$: handle_value({ layers, composite, background });
|
|
139
|
+
|
|
140
|
+
let background_image = false;
|
|
137
141
|
let history = false;
|
|
138
142
|
|
|
139
143
|
export let image_id: null | string = null;
|
|
140
144
|
|
|
141
|
-
$: editor &&
|
|
142
|
-
editor.set_tool &&
|
|
143
|
-
(sources && sources.length
|
|
144
|
-
? editor.set_tool("bg")
|
|
145
|
-
: editor.set_tool("draw"));
|
|
146
|
-
|
|
147
145
|
type BinaryImages = [string, string, File, number | null][];
|
|
148
146
|
|
|
149
147
|
function nextframe(): Promise<void> {
|
|
@@ -158,16 +156,11 @@
|
|
|
158
156
|
pending = true;
|
|
159
157
|
return;
|
|
160
158
|
}
|
|
161
|
-
|
|
162
159
|
uploading = true;
|
|
163
|
-
|
|
164
160
|
await nextframe();
|
|
165
161
|
const blobs = await editor.get_blobs();
|
|
166
|
-
|
|
167
162
|
const images: BinaryImages = [];
|
|
168
|
-
|
|
169
163
|
let id = Math.random().toString(36).substring(2);
|
|
170
|
-
|
|
171
164
|
if (blobs.background)
|
|
172
165
|
images.push([
|
|
173
166
|
id,
|
|
@@ -191,7 +184,6 @@
|
|
|
191
184
|
i
|
|
192
185
|
]);
|
|
193
186
|
});
|
|
194
|
-
|
|
195
187
|
await Promise.all(
|
|
196
188
|
images.map(async ([image_id, type, data, index]) => {
|
|
197
189
|
return accept_blobs({
|
|
@@ -202,7 +194,6 @@
|
|
|
202
194
|
);
|
|
203
195
|
image_id = id;
|
|
204
196
|
dispatch("change");
|
|
205
|
-
|
|
206
197
|
await nextframe();
|
|
207
198
|
uploading = false;
|
|
208
199
|
if (pending) {
|
|
@@ -212,14 +203,9 @@
|
|
|
212
203
|
}
|
|
213
204
|
}
|
|
214
205
|
|
|
215
|
-
let active_mode: "webcam" | "color" | null = null;
|
|
216
|
-
let editor_height = height - 100;
|
|
217
|
-
|
|
218
|
-
let _dynamic_height: number;
|
|
219
|
-
|
|
220
|
-
$: dynamic_height = _dynamic_height;
|
|
221
|
-
|
|
222
206
|
$: [heading, paragraph] = placeholder ? inject(placeholder) : [false, false];
|
|
207
|
+
|
|
208
|
+
let current_tool: ToolbarTool;
|
|
223
209
|
</script>
|
|
224
210
|
|
|
225
211
|
<BlockLabel
|
|
@@ -228,60 +214,38 @@
|
|
|
228
214
|
label={label || i18n("image.image")}
|
|
229
215
|
/>
|
|
230
216
|
<ImageEditor
|
|
217
|
+
{transforms}
|
|
218
|
+
{composite}
|
|
219
|
+
{layers}
|
|
220
|
+
{background}
|
|
231
221
|
on:history
|
|
232
222
|
{canvas_size}
|
|
233
|
-
crop_size={Array.isArray(crop_size) ? crop_size : undefined}
|
|
234
223
|
bind:this={editor}
|
|
235
|
-
bind:height={editor_height}
|
|
236
|
-
bind:canvas_height={_dynamic_height}
|
|
237
|
-
parent_height={height}
|
|
238
224
|
{changeable}
|
|
239
225
|
on:save
|
|
240
226
|
on:change={handle_change}
|
|
241
227
|
on:clear={() => dispatch("clear")}
|
|
242
|
-
|
|
243
|
-
bind:bg
|
|
228
|
+
on:download_error
|
|
244
229
|
{sources}
|
|
245
|
-
crop_constraint={!!crop_constraint}
|
|
246
230
|
{full_history}
|
|
231
|
+
bind:background_image
|
|
232
|
+
bind:current_tool
|
|
233
|
+
brush_options={brush}
|
|
234
|
+
eraser_options={eraser}
|
|
235
|
+
{fixed_canvas}
|
|
236
|
+
{border_region}
|
|
237
|
+
{layer_options}
|
|
238
|
+
{i18n}
|
|
239
|
+
{root}
|
|
240
|
+
{upload}
|
|
241
|
+
bind:is_dragging
|
|
242
|
+
bind:has_drawn
|
|
243
|
+
{webcam_options}
|
|
244
|
+
{show_download_button}
|
|
245
|
+
{theme_mode}
|
|
247
246
|
>
|
|
248
|
-
|
|
249
|
-
<
|
|
250
|
-
|
|
251
|
-
<Sources
|
|
252
|
-
bind:dragging
|
|
253
|
-
{i18n}
|
|
254
|
-
{root}
|
|
255
|
-
{sources}
|
|
256
|
-
{upload}
|
|
257
|
-
{stream_handler}
|
|
258
|
-
{canvas_size}
|
|
259
|
-
bind:bg
|
|
260
|
-
bind:active_mode
|
|
261
|
-
background_file={value?.background || value?.composite || null}
|
|
262
|
-
{fixed_canvas}
|
|
263
|
-
></Sources>
|
|
264
|
-
|
|
265
|
-
{#if transforms.includes("crop")}
|
|
266
|
-
<Crop {crop_constraint} />
|
|
267
|
-
{/if}
|
|
268
|
-
{#if brush}
|
|
269
|
-
<Brush
|
|
270
|
-
color_mode={brush.color_mode}
|
|
271
|
-
default_color={brush.default_color}
|
|
272
|
-
default_size={brush.default_size}
|
|
273
|
-
colors={brush.colors}
|
|
274
|
-
mode="draw"
|
|
275
|
-
/>
|
|
276
|
-
{/if}
|
|
277
|
-
|
|
278
|
-
{#if brush && eraser}
|
|
279
|
-
<Brush default_size={eraser.default_size} mode="erase" />
|
|
280
|
-
{/if}
|
|
281
|
-
</Tools>
|
|
282
|
-
|
|
283
|
-
{#if !bg && !history && active_mode !== "webcam" && status !== "error"}
|
|
284
|
-
<div class="empty wrap" style:height={`${editor_height}px`}>
|
|
247
|
+
{#if !background_image && current_tool === "image" && !has_drawn}
|
|
248
|
+
<div class="empty wrap">
|
|
285
249
|
{#if sources && sources.length}
|
|
286
250
|
{#if heading || paragraph}
|
|
287
251
|
{#if heading}
|
|
@@ -326,10 +290,10 @@
|
|
|
326
290
|
left: 0;
|
|
327
291
|
right: 0;
|
|
328
292
|
margin: auto;
|
|
329
|
-
z-index: var(--layer-
|
|
293
|
+
z-index: var(--layer-1);
|
|
330
294
|
text-align: center;
|
|
331
|
-
color: var(--
|
|
332
|
-
|
|
295
|
+
color: var(--color-grey-500) !important;
|
|
296
|
+
cursor: pointer;
|
|
333
297
|
}
|
|
334
298
|
|
|
335
299
|
.wrap {
|
|
@@ -337,10 +301,8 @@
|
|
|
337
301
|
flex-direction: column;
|
|
338
302
|
justify-content: center;
|
|
339
303
|
align-items: center;
|
|
340
|
-
color: var(--block-label-text-color);
|
|
341
304
|
line-height: var(--line-md);
|
|
342
305
|
font-size: var(--text-md);
|
|
343
|
-
pointer-events: none;
|
|
344
306
|
}
|
|
345
307
|
|
|
346
308
|
.or {
|
package/README.md
CHANGED
package/dist/Example.svelte.d.ts
CHANGED
package/dist/Index.svelte
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<svelte:options accessors={true} immutable={true} />
|
|
2
2
|
|
|
3
|
-
<script>import {
|
|
4
|
-
import
|
|
3
|
+
<script>import { FileData } from "@gradio/client";
|
|
4
|
+
import { BaseStaticImage as StaticImage } from "@gradio/image";
|
|
5
|
+
import InteractiveImageEditor from "./InteractiveImageEditor.svelte";
|
|
5
6
|
import { Block } from "@gradio/atoms";
|
|
6
7
|
import { StatusTracker } from "@gradio/statustracker";
|
|
7
8
|
import { tick } from "svelte";
|
|
@@ -18,7 +19,7 @@ export let show_label;
|
|
|
18
19
|
export let show_download_button;
|
|
19
20
|
export let root;
|
|
20
21
|
export let value_is_output = false;
|
|
21
|
-
export let height;
|
|
22
|
+
export let height = 350;
|
|
22
23
|
export let width;
|
|
23
24
|
export let _selectable = false;
|
|
24
25
|
export let container = true;
|
|
@@ -26,18 +27,13 @@ export let scale = null;
|
|
|
26
27
|
export let min_width = void 0;
|
|
27
28
|
export let loading_status;
|
|
28
29
|
export let show_share_button = false;
|
|
29
|
-
export let sources = [
|
|
30
|
-
"upload",
|
|
31
|
-
"clipboard",
|
|
32
|
-
"webcam"
|
|
33
|
-
];
|
|
30
|
+
export let sources = [];
|
|
34
31
|
export let interactive;
|
|
35
32
|
export let placeholder;
|
|
36
33
|
export let brush;
|
|
37
34
|
export let eraser;
|
|
38
|
-
export let
|
|
39
|
-
export let
|
|
40
|
-
export let layers = true;
|
|
35
|
+
export let transforms = [];
|
|
36
|
+
export let layers;
|
|
41
37
|
export let attached_events = [];
|
|
42
38
|
export let server;
|
|
43
39
|
export let canvas_size;
|
|
@@ -45,6 +41,9 @@ export let fixed_canvas = false;
|
|
|
45
41
|
export let show_fullscreen_button = true;
|
|
46
42
|
export let full_history = null;
|
|
47
43
|
export let gradio;
|
|
44
|
+
export let border_region = 0;
|
|
45
|
+
export let webcam_options;
|
|
46
|
+
export let theme_mode;
|
|
48
47
|
let editor_instance;
|
|
49
48
|
let image_id = null;
|
|
50
49
|
export async function get_value() {
|
|
@@ -56,7 +55,7 @@ export async function get_value() {
|
|
|
56
55
|
const blobs = await editor_instance.get_data();
|
|
57
56
|
return blobs;
|
|
58
57
|
}
|
|
59
|
-
let
|
|
58
|
+
let is_dragging;
|
|
60
59
|
$:
|
|
61
60
|
value && handle_change();
|
|
62
61
|
const is_browser = typeof window !== "undefined";
|
|
@@ -82,28 +81,28 @@ function handle_history_change() {
|
|
|
82
81
|
tick().then((_) => value_is_output = false);
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
|
-
let dynamic_height = void 0;
|
|
86
|
-
let safe_height_initial = Math.max(
|
|
87
|
-
canvas_size[1] / (is_browser ? window.devicePixelRatio : 1),
|
|
88
|
-
250
|
|
89
|
-
);
|
|
90
|
-
$:
|
|
91
|
-
safe_height = Math.max((dynamic_height ?? safe_height_initial) + 100, 250);
|
|
92
84
|
$:
|
|
93
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)) || [];
|
|
94
92
|
</script>
|
|
95
93
|
|
|
96
94
|
{#if !interactive}
|
|
97
95
|
<Block
|
|
98
96
|
{visible}
|
|
99
97
|
variant={"solid"}
|
|
100
|
-
border_mode={
|
|
98
|
+
border_mode={is_dragging ? "focus" : "base"}
|
|
101
99
|
padding={false}
|
|
102
100
|
{elem_id}
|
|
103
101
|
{elem_classes}
|
|
104
102
|
{height}
|
|
105
103
|
{width}
|
|
106
|
-
allow_overflow={
|
|
104
|
+
allow_overflow={true}
|
|
105
|
+
overflow_behavior="visible"
|
|
107
106
|
{container}
|
|
108
107
|
{scale}
|
|
109
108
|
{min_width}
|
|
@@ -132,13 +131,14 @@ $:
|
|
|
132
131
|
<Block
|
|
133
132
|
{visible}
|
|
134
133
|
variant={has_value ? "solid" : "dashed"}
|
|
135
|
-
border_mode={
|
|
134
|
+
border_mode={is_dragging ? "focus" : "base"}
|
|
136
135
|
padding={false}
|
|
137
136
|
{elem_id}
|
|
138
137
|
{elem_classes}
|
|
139
|
-
|
|
138
|
+
{height}
|
|
140
139
|
{width}
|
|
141
|
-
allow_overflow={
|
|
140
|
+
allow_overflow={true}
|
|
141
|
+
overflow_behavior="visible"
|
|
142
142
|
{container}
|
|
143
143
|
{scale}
|
|
144
144
|
{min_width}
|
|
@@ -151,25 +151,25 @@ $:
|
|
|
151
151
|
/>
|
|
152
152
|
|
|
153
153
|
<InteractiveImageEditor
|
|
154
|
+
{border_region}
|
|
154
155
|
on:history={(e) => (full_history = e.detail)}
|
|
155
|
-
bind:
|
|
156
|
+
bind:is_dragging
|
|
156
157
|
{canvas_size}
|
|
157
158
|
on:change={() => handle_history_change()}
|
|
158
159
|
bind:image_id
|
|
159
|
-
{
|
|
160
|
-
{
|
|
160
|
+
layers={normalised_layers}
|
|
161
|
+
composite={normalised_composite}
|
|
162
|
+
background={normalised_background}
|
|
161
163
|
bind:this={editor_instance}
|
|
162
|
-
bind:dynamic_height
|
|
163
164
|
{root}
|
|
164
165
|
{sources}
|
|
165
166
|
{label}
|
|
166
167
|
{show_label}
|
|
167
|
-
{height}
|
|
168
168
|
{fixed_canvas}
|
|
169
169
|
on:save={(e) => handle_save()}
|
|
170
170
|
on:edit={() => gradio.dispatch("edit")}
|
|
171
171
|
on:clear={() => gradio.dispatch("clear")}
|
|
172
|
-
on:drag={({ detail }) => (
|
|
172
|
+
on:drag={({ detail }) => (is_dragging = detail)}
|
|
173
173
|
on:upload={() => gradio.dispatch("upload")}
|
|
174
174
|
on:share={({ detail }) => gradio.dispatch("share", detail)}
|
|
175
175
|
on:error={({ detail }) => {
|
|
@@ -192,12 +192,14 @@ $:
|
|
|
192
192
|
i18n={gradio.i18n}
|
|
193
193
|
{transforms}
|
|
194
194
|
accept_blobs={server.accept_blobs}
|
|
195
|
-
{layers}
|
|
196
|
-
status={loading_status?.status}
|
|
195
|
+
layer_options={layers}
|
|
197
196
|
upload={(...args) => gradio.client.upload(...args)}
|
|
198
|
-
stream_handler={(...args) => gradio.client.stream(...args)}
|
|
199
197
|
{placeholder}
|
|
200
198
|
{full_history}
|
|
199
|
+
{webcam_options}
|
|
200
|
+
{show_download_button}
|
|
201
|
+
{theme_mode}
|
|
202
|
+
on:download_error={(e) => gradio.dispatch("error", e.detail)}
|
|
201
203
|
></InteractiveImageEditor>
|
|
202
204
|
</Block>
|
|
203
205
|
{/if}
|
package/dist/Index.svelte.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { Brush, Eraser } from "./shared/
|
|
3
|
-
import type { EditorData, ImageBlobs } from "./
|
|
2
|
+
import type { Brush, Eraser } from "./shared/brush/types";
|
|
3
|
+
import type { EditorData, ImageBlobs } from "./InteractiveImageEditor.svelte";
|
|
4
4
|
import type { Gradio, SelectData } from "@gradio/utils";
|
|
5
5
|
import type { LoadingStatus } from "@gradio/statustracker";
|
|
6
|
+
import type { LayerOptions, Transform, Source, WebcamOptions } from "./shared/types";
|
|
6
7
|
declare const __propDef: {
|
|
7
8
|
props: {
|
|
8
9
|
elem_id?: string | undefined;
|
|
@@ -14,7 +15,7 @@ declare const __propDef: {
|
|
|
14
15
|
show_download_button: boolean;
|
|
15
16
|
root: string;
|
|
16
17
|
value_is_output?: boolean | undefined;
|
|
17
|
-
height
|
|
18
|
+
height?: number | undefined;
|
|
18
19
|
width: number | undefined;
|
|
19
20
|
_selectable?: boolean | undefined;
|
|
20
21
|
container?: boolean | undefined;
|
|
@@ -22,14 +23,13 @@ declare const __propDef: {
|
|
|
22
23
|
min_width?: number | undefined;
|
|
23
24
|
loading_status: LoadingStatus;
|
|
24
25
|
show_share_button?: boolean | undefined;
|
|
25
|
-
sources?:
|
|
26
|
+
sources?: Source[] | undefined;
|
|
26
27
|
interactive: boolean;
|
|
27
28
|
placeholder: string | undefined;
|
|
28
29
|
brush: Brush;
|
|
29
30
|
eraser: Eraser;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
layers?: boolean | undefined;
|
|
31
|
+
transforms?: Transform[] | undefined;
|
|
32
|
+
layers: LayerOptions;
|
|
33
33
|
attached_events?: string[] | undefined;
|
|
34
34
|
server: {
|
|
35
35
|
accept_blobs: (a: any) => void;
|
|
@@ -51,6 +51,9 @@ declare const __propDef: {
|
|
|
51
51
|
share: ShareData;
|
|
52
52
|
clear_status: LoadingStatus;
|
|
53
53
|
}>;
|
|
54
|
+
border_region?: number | undefined;
|
|
55
|
+
webcam_options: WebcamOptions;
|
|
56
|
+
theme_mode: "dark" | "light";
|
|
54
57
|
get_value?: (() => Promise<ImageBlobs | {
|
|
55
58
|
id: string;
|
|
56
59
|
}>) | undefined;
|
|
@@ -120,9 +123,9 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
|
|
|
120
123
|
get show_share_button(): boolean | undefined;
|
|
121
124
|
/**accessor*/
|
|
122
125
|
set show_share_button(_: boolean | undefined);
|
|
123
|
-
get sources():
|
|
126
|
+
get sources(): Source[] | undefined;
|
|
124
127
|
/**accessor*/
|
|
125
|
-
set sources(_:
|
|
128
|
+
set sources(_: Source[] | undefined);
|
|
126
129
|
get interactive(): boolean;
|
|
127
130
|
/**accessor*/
|
|
128
131
|
set interactive(_: boolean);
|
|
@@ -135,15 +138,12 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
|
|
|
135
138
|
get eraser(): Eraser;
|
|
136
139
|
/**accessor*/
|
|
137
140
|
set eraser(_: Eraser);
|
|
138
|
-
get
|
|
141
|
+
get transforms(): Transform[] | undefined;
|
|
139
142
|
/**accessor*/
|
|
140
|
-
set
|
|
141
|
-
get
|
|
143
|
+
set transforms(_: Transform[] | undefined);
|
|
144
|
+
get layers(): LayerOptions;
|
|
142
145
|
/**accessor*/
|
|
143
|
-
set
|
|
144
|
-
get layers(): boolean | undefined;
|
|
145
|
-
/**accessor*/
|
|
146
|
-
set layers(_: boolean | undefined);
|
|
146
|
+
set layers(_: LayerOptions);
|
|
147
147
|
get attached_events(): string[] | undefined;
|
|
148
148
|
/**accessor*/
|
|
149
149
|
set attached_events(_: string[] | undefined);
|
|
@@ -193,6 +193,15 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
|
|
|
193
193
|
share: ShareData;
|
|
194
194
|
clear_status: LoadingStatus;
|
|
195
195
|
}>);
|
|
196
|
+
get border_region(): number | undefined;
|
|
197
|
+
/**accessor*/
|
|
198
|
+
set border_region(_: number | undefined);
|
|
199
|
+
get webcam_options(): WebcamOptions;
|
|
200
|
+
/**accessor*/
|
|
201
|
+
set webcam_options(_: WebcamOptions);
|
|
202
|
+
get theme_mode(): "light" | "dark";
|
|
203
|
+
/**accessor*/
|
|
204
|
+
set theme_mode(_: "light" | "dark");
|
|
196
205
|
get undefined(): any;
|
|
197
206
|
/**accessor*/
|
|
198
207
|
set undefined(_: any);
|