sveltekit-ui 1.0.40 → 1.0.42
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/dist/Components/ImageEditor/Panels/AI/index.svelte +3 -1
- package/dist/Components/ImageEditor/index.svelte.js +35 -14
- package/dist/client/docs/index.js +7 -3
- package/package.json +2 -2
- package/src/lib/Components/ImageEditor/Panels/AI/index.svelte +3 -1
- package/src/lib/Components/ImageEditor/index.svelte.js +35 -14
- package/src/lib/client/docs/index.js +7 -3
- package/src/routes/[component]/Showcase/ImageEditor/index.svelte +5 -4
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
import InfoBox from "../../../InfoBox/index.svelte"
|
|
4
4
|
import Dropdown from "../../../Dropdown/index.svelte"
|
|
5
5
|
import TextInput from "../../../TextInput/index.svelte"
|
|
6
|
+
import FileInput from "../../../FileInput/index.svelte"
|
|
6
7
|
|
|
7
8
|
let { manager } = $props()
|
|
8
9
|
</script>
|
|
9
10
|
|
|
10
11
|
<div>
|
|
11
12
|
<Dropdown manager={manager?.ai_tab_dropdown_manager} />
|
|
12
|
-
{#if manager?.ai_tab_dropdown_manager?.val == "
|
|
13
|
+
{#if manager?.ai_tab_dropdown_manager?.val == "image_generator"}
|
|
13
14
|
<div style="padding-top: .5rem;">
|
|
14
15
|
<TextInput manager={manager?.ai_generate_image_from_text_text_input_manager} />
|
|
16
|
+
<FileInput manager={manager?.ai_generate_image_images_prompt_file_input_manager} />
|
|
15
17
|
<Button manager={manager?.ai_generate_image_from_text_button_manager} />
|
|
16
18
|
</div>
|
|
17
19
|
{:else if manager?.ai_tab_dropdown_manager?.val == "remove_background"}
|
|
@@ -108,8 +108,9 @@ export function create_image_editor_manager(config) {
|
|
|
108
108
|
let file_quality_slider_manager = $state(null)
|
|
109
109
|
|
|
110
110
|
let ai_tab_dropdown_manager = $state(null)
|
|
111
|
-
let
|
|
111
|
+
let ai_image_generator_is_loading = $state(null)
|
|
112
112
|
let ai_generate_image_from_text_text_input_manager = $state(null)
|
|
113
|
+
let ai_generate_image_images_prompt_file_input_manager = $state(null)
|
|
113
114
|
let ai_generate_image_from_text_button_manager = $state(null)
|
|
114
115
|
let ai_remove_background_is_loading = $state(false)
|
|
115
116
|
let ai_restore_resolution_is_loading = $state(false)
|
|
@@ -786,14 +787,14 @@ export function create_image_editor_manager(config) {
|
|
|
786
787
|
|
|
787
788
|
// ai ↓↓↓
|
|
788
789
|
|
|
789
|
-
async function
|
|
790
|
+
async function ai_image_generator(input) {
|
|
790
791
|
ai_error_message = null
|
|
791
|
-
if (typeof config?.
|
|
792
|
-
ai_error_message = "
|
|
792
|
+
if (typeof config?.ai_image_generator !== "function") {
|
|
793
|
+
ai_error_message = "ai_image_generator function not provided to config"
|
|
793
794
|
return
|
|
794
795
|
}
|
|
795
|
-
|
|
796
|
-
const res = await config?.
|
|
796
|
+
ai_image_generator_is_loading = true
|
|
797
|
+
const res = await config?.ai_image_generator(input)
|
|
797
798
|
if (res?.is_success) {
|
|
798
799
|
try {
|
|
799
800
|
const data_url = `data:image/webp;base64,${res?.data?.b64_json}`
|
|
@@ -810,7 +811,7 @@ export function create_image_editor_manager(config) {
|
|
|
810
811
|
} else {
|
|
811
812
|
ai_error_message = res?.error_message ?? "Error generating image"
|
|
812
813
|
}
|
|
813
|
-
|
|
814
|
+
ai_image_generator_is_loading = false
|
|
814
815
|
}
|
|
815
816
|
|
|
816
817
|
async function ai_remove_background(input) {
|
|
@@ -1113,7 +1114,12 @@ export function create_image_editor_manager(config) {
|
|
|
1113
1114
|
set_file_data_base()
|
|
1114
1115
|
}
|
|
1115
1116
|
|
|
1117
|
+
function set_is_popover(input) {
|
|
1118
|
+
is_popover = !!input
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1116
1121
|
async function init(config) {
|
|
1122
|
+
is_popover = !!config?.is_popover
|
|
1117
1123
|
popover_manager = create_popover_manager({
|
|
1118
1124
|
min_width: 320,
|
|
1119
1125
|
target_width: 900,
|
|
@@ -1492,27 +1498,38 @@ export function create_image_editor_manager(config) {
|
|
|
1492
1498
|
})
|
|
1493
1499
|
ai_tab_dropdown_manager = create_dropdown_manager({
|
|
1494
1500
|
type: "horiz_selector",
|
|
1495
|
-
val: "
|
|
1501
|
+
val: "image_generator",
|
|
1496
1502
|
options: [
|
|
1497
|
-
{ key: "
|
|
1503
|
+
{ key: "image_generator", name: "Image Generator" },
|
|
1498
1504
|
{ key: "remove_background", name: "Remove Background" },
|
|
1499
1505
|
{ key: "restore_resolution", name: "Restore Resolution" },
|
|
1500
1506
|
{ key: "restore_face", name: "Restore Face" },
|
|
1501
1507
|
],
|
|
1502
1508
|
})
|
|
1503
1509
|
ai_generate_image_from_text_text_input_manager = create_text_input_manager({
|
|
1510
|
+
label: "Text Prompt",
|
|
1504
1511
|
type: "text_area",
|
|
1505
1512
|
rows: 3,
|
|
1506
1513
|
placeholder: "Describe what you want your image to be of",
|
|
1507
|
-
is_disabled: () =>
|
|
1514
|
+
is_disabled: () => ai_image_generator_is_loading,
|
|
1515
|
+
})
|
|
1516
|
+
ai_generate_image_images_prompt_file_input_manager = create_file_input_manager({
|
|
1517
|
+
label: "Image Prompt",
|
|
1518
|
+
is_multiselect: true,
|
|
1519
|
+
is_drop_zone: false,
|
|
1520
|
+
accept: ["image/png", "image/jpeg", "image/webp"],
|
|
1508
1521
|
})
|
|
1509
1522
|
ai_generate_image_from_text_button_manager = create_button_manager({
|
|
1510
1523
|
text: "Generate Image From text",
|
|
1511
1524
|
is_compressed: true,
|
|
1512
1525
|
mt: 1,
|
|
1513
|
-
is_loading: () =>
|
|
1526
|
+
is_loading: () => ai_image_generator_is_loading,
|
|
1514
1527
|
is_disabled: () => is_disabled,
|
|
1515
|
-
on_click: () =>
|
|
1528
|
+
on_click: () =>
|
|
1529
|
+
ai_image_generator({
|
|
1530
|
+
text_prompt: ai_generate_image_from_text_text_input_manager?.val,
|
|
1531
|
+
images_prompt: ai_generate_image_images_prompt_file_input_manager?.val,
|
|
1532
|
+
}),
|
|
1516
1533
|
})
|
|
1517
1534
|
ai_remove_bg_button_manager = create_button_manager({
|
|
1518
1535
|
text: "Remove Background",
|
|
@@ -1837,12 +1854,15 @@ export function create_image_editor_manager(config) {
|
|
|
1837
1854
|
get ai_tab_dropdown_manager() {
|
|
1838
1855
|
return ai_tab_dropdown_manager
|
|
1839
1856
|
},
|
|
1840
|
-
get
|
|
1841
|
-
return
|
|
1857
|
+
get ai_image_generator_is_loading() {
|
|
1858
|
+
return ai_image_generator_is_loading
|
|
1842
1859
|
},
|
|
1843
1860
|
get ai_generate_image_from_text_text_input_manager() {
|
|
1844
1861
|
return ai_generate_image_from_text_text_input_manager
|
|
1845
1862
|
},
|
|
1863
|
+
get ai_generate_image_images_prompt_file_input_manager() {
|
|
1864
|
+
return ai_generate_image_images_prompt_file_input_manager
|
|
1865
|
+
},
|
|
1846
1866
|
get ai_generate_image_from_text_button_manager() {
|
|
1847
1867
|
return ai_generate_image_from_text_button_manager
|
|
1848
1868
|
},
|
|
@@ -1903,5 +1923,6 @@ export function create_image_editor_manager(config) {
|
|
|
1903
1923
|
download_image,
|
|
1904
1924
|
set_file_from_inputs,
|
|
1905
1925
|
drop_handler,
|
|
1926
|
+
set_is_popover,
|
|
1906
1927
|
}
|
|
1907
1928
|
}
|
|
@@ -4070,7 +4070,7 @@ export const definitions = {
|
|
|
4070
4070
|
default: null,
|
|
4071
4071
|
description: "invoked when the user taps 'Finish', receives the final edited file",
|
|
4072
4072
|
},
|
|
4073
|
-
|
|
4073
|
+
ai_image_generator: {
|
|
4074
4074
|
type: "function",
|
|
4075
4075
|
default: null,
|
|
4076
4076
|
description:
|
|
@@ -4527,13 +4527,17 @@ export const definitions = {
|
|
|
4527
4527
|
type: "object",
|
|
4528
4528
|
description: "dropdown manager to switch among AI-related tasks",
|
|
4529
4529
|
},
|
|
4530
|
-
|
|
4530
|
+
ai_image_generator_is_loading: {
|
|
4531
4531
|
type: "boolean",
|
|
4532
4532
|
description: "true if the text-to-image AI call is in progress",
|
|
4533
4533
|
},
|
|
4534
4534
|
ai_generate_image_from_text_text_input_manager: {
|
|
4535
4535
|
type: "object",
|
|
4536
|
-
description: "text input manager containing the user’s text prompt for AI generation",
|
|
4536
|
+
description: "text input manager containing the user’s text prompt for AI image generation",
|
|
4537
|
+
},
|
|
4538
|
+
ai_generate_image_images_prompt_file_input_manager: {
|
|
4539
|
+
type: "object",
|
|
4540
|
+
description: "text input manager containing the user’s image prompt for AI image generation",
|
|
4537
4541
|
},
|
|
4538
4542
|
ai_generate_image_from_text_button_manager: {
|
|
4539
4543
|
type: "object",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sveltekit-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
4
4
|
"description": "A SvelteKit UI component library for building modern web applications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@sveltejs/vite-plugin-svelte": "^6.1.3",
|
|
32
32
|
"@vercel/analytics": "^1.5.0",
|
|
33
33
|
"typescript": "^5.9.2",
|
|
34
|
-
"vite": "^7.1.
|
|
34
|
+
"vite": "^7.1.4"
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://www.sveltekit-ui.com",
|
|
37
37
|
"keywords": [
|
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
import InfoBox from "$lib/Components/InfoBox/index.svelte"
|
|
4
4
|
import Dropdown from "$lib/Components/Dropdown/index.svelte"
|
|
5
5
|
import TextInput from "$lib/Components/TextInput/index.svelte"
|
|
6
|
+
import FileInput from "$lib/Components/FileInput/index.svelte"
|
|
6
7
|
|
|
7
8
|
let { manager } = $props()
|
|
8
9
|
</script>
|
|
9
10
|
|
|
10
11
|
<div>
|
|
11
12
|
<Dropdown manager={manager?.ai_tab_dropdown_manager} />
|
|
12
|
-
{#if manager?.ai_tab_dropdown_manager?.val == "
|
|
13
|
+
{#if manager?.ai_tab_dropdown_manager?.val == "image_generator"}
|
|
13
14
|
<div style="padding-top: .5rem;">
|
|
14
15
|
<TextInput manager={manager?.ai_generate_image_from_text_text_input_manager} />
|
|
16
|
+
<FileInput manager={manager?.ai_generate_image_images_prompt_file_input_manager} />
|
|
15
17
|
<Button manager={manager?.ai_generate_image_from_text_button_manager} />
|
|
16
18
|
</div>
|
|
17
19
|
{:else if manager?.ai_tab_dropdown_manager?.val == "remove_background"}
|
|
@@ -108,8 +108,9 @@ export function create_image_editor_manager(config) {
|
|
|
108
108
|
let file_quality_slider_manager = $state(null)
|
|
109
109
|
|
|
110
110
|
let ai_tab_dropdown_manager = $state(null)
|
|
111
|
-
let
|
|
111
|
+
let ai_image_generator_is_loading = $state(null)
|
|
112
112
|
let ai_generate_image_from_text_text_input_manager = $state(null)
|
|
113
|
+
let ai_generate_image_images_prompt_file_input_manager = $state(null)
|
|
113
114
|
let ai_generate_image_from_text_button_manager = $state(null)
|
|
114
115
|
let ai_remove_background_is_loading = $state(false)
|
|
115
116
|
let ai_restore_resolution_is_loading = $state(false)
|
|
@@ -786,14 +787,14 @@ export function create_image_editor_manager(config) {
|
|
|
786
787
|
|
|
787
788
|
// ai ↓↓↓
|
|
788
789
|
|
|
789
|
-
async function
|
|
790
|
+
async function ai_image_generator(input) {
|
|
790
791
|
ai_error_message = null
|
|
791
|
-
if (typeof config?.
|
|
792
|
-
ai_error_message = "
|
|
792
|
+
if (typeof config?.ai_image_generator !== "function") {
|
|
793
|
+
ai_error_message = "ai_image_generator function not provided to config"
|
|
793
794
|
return
|
|
794
795
|
}
|
|
795
|
-
|
|
796
|
-
const res = await config?.
|
|
796
|
+
ai_image_generator_is_loading = true
|
|
797
|
+
const res = await config?.ai_image_generator(input)
|
|
797
798
|
if (res?.is_success) {
|
|
798
799
|
try {
|
|
799
800
|
const data_url = `data:image/webp;base64,${res?.data?.b64_json}`
|
|
@@ -810,7 +811,7 @@ export function create_image_editor_manager(config) {
|
|
|
810
811
|
} else {
|
|
811
812
|
ai_error_message = res?.error_message ?? "Error generating image"
|
|
812
813
|
}
|
|
813
|
-
|
|
814
|
+
ai_image_generator_is_loading = false
|
|
814
815
|
}
|
|
815
816
|
|
|
816
817
|
async function ai_remove_background(input) {
|
|
@@ -1113,7 +1114,12 @@ export function create_image_editor_manager(config) {
|
|
|
1113
1114
|
set_file_data_base()
|
|
1114
1115
|
}
|
|
1115
1116
|
|
|
1117
|
+
function set_is_popover(input) {
|
|
1118
|
+
is_popover = !!input
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1116
1121
|
async function init(config) {
|
|
1122
|
+
is_popover = !!config?.is_popover
|
|
1117
1123
|
popover_manager = create_popover_manager({
|
|
1118
1124
|
min_width: 320,
|
|
1119
1125
|
target_width: 900,
|
|
@@ -1492,27 +1498,38 @@ export function create_image_editor_manager(config) {
|
|
|
1492
1498
|
})
|
|
1493
1499
|
ai_tab_dropdown_manager = create_dropdown_manager({
|
|
1494
1500
|
type: "horiz_selector",
|
|
1495
|
-
val: "
|
|
1501
|
+
val: "image_generator",
|
|
1496
1502
|
options: [
|
|
1497
|
-
{ key: "
|
|
1503
|
+
{ key: "image_generator", name: "Image Generator" },
|
|
1498
1504
|
{ key: "remove_background", name: "Remove Background" },
|
|
1499
1505
|
{ key: "restore_resolution", name: "Restore Resolution" },
|
|
1500
1506
|
{ key: "restore_face", name: "Restore Face" },
|
|
1501
1507
|
],
|
|
1502
1508
|
})
|
|
1503
1509
|
ai_generate_image_from_text_text_input_manager = create_text_input_manager({
|
|
1510
|
+
label: "Text Prompt",
|
|
1504
1511
|
type: "text_area",
|
|
1505
1512
|
rows: 3,
|
|
1506
1513
|
placeholder: "Describe what you want your image to be of",
|
|
1507
|
-
is_disabled: () =>
|
|
1514
|
+
is_disabled: () => ai_image_generator_is_loading,
|
|
1515
|
+
})
|
|
1516
|
+
ai_generate_image_images_prompt_file_input_manager = create_file_input_manager({
|
|
1517
|
+
label: "Image Prompt",
|
|
1518
|
+
is_multiselect: true,
|
|
1519
|
+
is_drop_zone: false,
|
|
1520
|
+
accept: ["image/png", "image/jpeg", "image/webp"],
|
|
1508
1521
|
})
|
|
1509
1522
|
ai_generate_image_from_text_button_manager = create_button_manager({
|
|
1510
1523
|
text: "Generate Image From text",
|
|
1511
1524
|
is_compressed: true,
|
|
1512
1525
|
mt: 1,
|
|
1513
|
-
is_loading: () =>
|
|
1526
|
+
is_loading: () => ai_image_generator_is_loading,
|
|
1514
1527
|
is_disabled: () => is_disabled,
|
|
1515
|
-
on_click: () =>
|
|
1528
|
+
on_click: () =>
|
|
1529
|
+
ai_image_generator({
|
|
1530
|
+
text_prompt: ai_generate_image_from_text_text_input_manager?.val,
|
|
1531
|
+
images_prompt: ai_generate_image_images_prompt_file_input_manager?.val,
|
|
1532
|
+
}),
|
|
1516
1533
|
})
|
|
1517
1534
|
ai_remove_bg_button_manager = create_button_manager({
|
|
1518
1535
|
text: "Remove Background",
|
|
@@ -1837,12 +1854,15 @@ export function create_image_editor_manager(config) {
|
|
|
1837
1854
|
get ai_tab_dropdown_manager() {
|
|
1838
1855
|
return ai_tab_dropdown_manager
|
|
1839
1856
|
},
|
|
1840
|
-
get
|
|
1841
|
-
return
|
|
1857
|
+
get ai_image_generator_is_loading() {
|
|
1858
|
+
return ai_image_generator_is_loading
|
|
1842
1859
|
},
|
|
1843
1860
|
get ai_generate_image_from_text_text_input_manager() {
|
|
1844
1861
|
return ai_generate_image_from_text_text_input_manager
|
|
1845
1862
|
},
|
|
1863
|
+
get ai_generate_image_images_prompt_file_input_manager() {
|
|
1864
|
+
return ai_generate_image_images_prompt_file_input_manager
|
|
1865
|
+
},
|
|
1846
1866
|
get ai_generate_image_from_text_button_manager() {
|
|
1847
1867
|
return ai_generate_image_from_text_button_manager
|
|
1848
1868
|
},
|
|
@@ -1903,5 +1923,6 @@ export function create_image_editor_manager(config) {
|
|
|
1903
1923
|
download_image,
|
|
1904
1924
|
set_file_from_inputs,
|
|
1905
1925
|
drop_handler,
|
|
1926
|
+
set_is_popover,
|
|
1906
1927
|
}
|
|
1907
1928
|
}
|
|
@@ -4070,7 +4070,7 @@ export const definitions = {
|
|
|
4070
4070
|
default: null,
|
|
4071
4071
|
description: "invoked when the user taps 'Finish', receives the final edited file",
|
|
4072
4072
|
},
|
|
4073
|
-
|
|
4073
|
+
ai_image_generator: {
|
|
4074
4074
|
type: "function",
|
|
4075
4075
|
default: null,
|
|
4076
4076
|
description:
|
|
@@ -4527,13 +4527,17 @@ export const definitions = {
|
|
|
4527
4527
|
type: "object",
|
|
4528
4528
|
description: "dropdown manager to switch among AI-related tasks",
|
|
4529
4529
|
},
|
|
4530
|
-
|
|
4530
|
+
ai_image_generator_is_loading: {
|
|
4531
4531
|
type: "boolean",
|
|
4532
4532
|
description: "true if the text-to-image AI call is in progress",
|
|
4533
4533
|
},
|
|
4534
4534
|
ai_generate_image_from_text_text_input_manager: {
|
|
4535
4535
|
type: "object",
|
|
4536
|
-
description: "text input manager containing the user’s text prompt for AI generation",
|
|
4536
|
+
description: "text input manager containing the user’s text prompt for AI image generation",
|
|
4537
|
+
},
|
|
4538
|
+
ai_generate_image_images_prompt_file_input_manager: {
|
|
4539
|
+
type: "object",
|
|
4540
|
+
description: "text input manager containing the user’s image prompt for AI image generation",
|
|
4537
4541
|
},
|
|
4538
4542
|
ai_generate_image_from_text_button_manager: {
|
|
4539
4543
|
type: "object",
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import ImageEditor from "$lib/Components/ImageEditor/index.svelte"
|
|
5
5
|
import { create_image_editor_manager } from "$lib/Components/ImageEditor/index.svelte.js"
|
|
6
6
|
|
|
7
|
-
// async function
|
|
7
|
+
// async function ai_image_generator(input) {
|
|
8
8
|
// try {
|
|
9
|
-
// const response = await fetch("/api/
|
|
9
|
+
// const response = await fetch("/api/tools/generate", {
|
|
10
10
|
// method: "POST",
|
|
11
11
|
// body: JSON.stringify({ prompt: input }),
|
|
12
12
|
// })
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
// let res = await fetch(input)
|
|
39
39
|
// let blob = await res.blob()
|
|
40
40
|
// form_data.append("file", blob, rand_name)
|
|
41
|
-
// let response = await fetch("/api/
|
|
41
|
+
// let response = await fetch("/api/tools/remove_background", {
|
|
42
42
|
// method: "POST",
|
|
43
43
|
// body: form_data,
|
|
44
44
|
// })
|
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
// }
|
|
67
67
|
|
|
68
68
|
let image_editor_manager = create_image_editor_manager({
|
|
69
|
-
|
|
69
|
+
is_popover: false,
|
|
70
|
+
// ai_image_generator: ai_image_generator,
|
|
70
71
|
// ai_remove_image_background: ai_remove_image_background,
|
|
71
72
|
// ai_restore_resolution: ai_restore_resolution,
|
|
72
73
|
// ai_restore_face: ai_restore_face,
|