@gradio/core 0.0.2 → 0.0.3
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 +30 -0
- package/dist/blocks.d.ts +1 -0
- package/dist/blocks.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/login.d.ts +1 -0
- package/dist/login.js +1 -0
- package/dist/src/Blocks.svelte +671 -0
- package/dist/src/Blocks.svelte.d.ts +41 -0
- package/dist/src/Embed.svelte +195 -0
- package/dist/src/Embed.svelte.d.ts +26 -0
- package/dist/src/Login.svelte +107 -0
- package/dist/src/Login.svelte.d.ts +19 -0
- package/dist/src/MountComponents.svelte +26 -0
- package/dist/src/MountComponents.svelte.d.ts +26 -0
- package/dist/src/Render.svelte +91 -0
- package/dist/src/Render.svelte.d.ts +29 -0
- package/dist/src/RenderComponent.svelte +51 -0
- package/dist/src/RenderComponent.svelte.d.ts +32 -0
- package/dist/src/api_docs/ApiBanner.svelte +115 -0
- package/dist/src/api_docs/ApiBanner.svelte.d.ts +19 -0
- package/dist/src/api_docs/ApiDocs.svelte +388 -0
- package/dist/src/api_docs/ApiDocs.svelte.d.ts +27 -0
- package/dist/src/api_docs/ApiRecorder.svelte +72 -0
- package/dist/src/api_docs/ApiRecorder.svelte.d.ts +18 -0
- package/dist/src/api_docs/CodeSnippet.svelte +184 -0
- package/dist/src/api_docs/CodeSnippet.svelte.d.ts +24 -0
- package/dist/src/api_docs/CopyButton.svelte +15 -0
- package/dist/src/api_docs/CopyButton.svelte.d.ts +16 -0
- package/dist/src/api_docs/EndpointDetail.svelte +36 -0
- package/dist/src/api_docs/EndpointDetail.svelte.d.ts +18 -0
- package/dist/src/api_docs/InputPayload.svelte +149 -0
- package/dist/src/api_docs/InputPayload.svelte.d.ts +24 -0
- package/dist/src/api_docs/InstallSnippet.svelte +56 -0
- package/dist/src/api_docs/InstallSnippet.svelte.d.ts +16 -0
- package/dist/src/api_docs/NoApi.svelte +71 -0
- package/dist/src/api_docs/NoApi.svelte.d.ts +18 -0
- package/dist/src/api_docs/ParametersSnippet.svelte +104 -0
- package/dist/src/api_docs/ParametersSnippet.svelte.d.ts +19 -0
- package/dist/src/api_docs/RecordingSnippet.svelte +210 -0
- package/dist/src/api_docs/RecordingSnippet.svelte.d.ts +22 -0
- package/dist/src/api_docs/ResponseSnippet.svelte +95 -0
- package/dist/src/api_docs/ResponseSnippet.svelte.d.ts +19 -0
- package/dist/src/api_docs/TryButton.svelte +17 -0
- package/dist/src/api_docs/TryButton.svelte.d.ts +17 -0
- package/dist/src/api_docs/img/api-logo.svg +4 -0
- package/dist/src/api_docs/img/bash.svg +8 -0
- package/dist/src/api_docs/img/clear.svelte +19 -0
- package/dist/src/api_docs/img/clear.svelte.d.ts +23 -0
- package/dist/src/api_docs/img/javascript.svg +16 -0
- package/dist/src/api_docs/img/python.svg +20 -0
- package/dist/src/api_docs/index.d.ts +2 -0
- package/dist/src/api_docs/index.js +2 -0
- package/dist/src/api_docs/utils.d.ts +2 -0
- package/dist/src/api_docs/utils.js +135 -0
- package/dist/src/css.d.ts +2 -0
- package/dist/src/css.js +93 -0
- package/dist/src/gradio_helper.js +4 -0
- package/dist/src/i18n.d.ts +6 -0
- package/dist/src/i18n.js +22 -0
- package/dist/src/images/lightning.svg +2 -0
- package/dist/src/images/logo.svg +19 -0
- package/dist/src/images/play.svg +2 -0
- package/dist/src/images/spaces.svg +7 -0
- package/dist/src/init.d.ts +107 -0
- package/dist/src/init.js +377 -0
- package/dist/src/lang/BCP47_codes.d.ts +2 -0
- package/dist/src/lang/BCP47_codes.js +58 -0
- package/dist/src/lang/ar.json +16 -0
- package/dist/src/lang/ca.json +19 -0
- package/dist/src/lang/ckb.json +108 -0
- package/dist/src/lang/de.json +16 -0
- package/dist/src/lang/en.json +118 -0
- package/dist/src/lang/es.json +17 -0
- package/dist/src/lang/eu.json +16 -0
- package/dist/src/lang/fa.json +16 -0
- package/dist/src/lang/fr.json +30 -0
- package/dist/src/lang/he.json +16 -0
- package/dist/src/lang/hi.json +16 -0
- package/dist/src/lang/ja.json +16 -0
- package/dist/src/lang/ko.json +16 -0
- package/dist/src/lang/lt.json +16 -0
- package/dist/src/lang/nl.json +16 -0
- package/dist/src/lang/pl.json +16 -0
- package/dist/src/lang/pt-BR.json +19 -0
- package/dist/src/lang/ru.json +118 -0
- package/dist/src/lang/ta.json +16 -0
- package/dist/src/lang/tr.json +16 -0
- package/dist/src/lang/uk.json +16 -0
- package/dist/src/lang/ur.json +16 -0
- package/dist/src/lang/uz.json +15 -0
- package/dist/src/lang/zh-CN.json +115 -0
- package/dist/src/lang/zh-TW.json +16 -0
- package/dist/src/s-blocks.d.ts +1 -0
- package/dist/src/s-blocks.js +1 -0
- package/dist/src/s-login.d.ts +1 -0
- package/dist/src/s-login.js +1 -0
- package/dist/src/stores.d.ts +30 -0
- package/dist/src/stores.js +93 -0
- package/dist/src/types.d.ts +95 -0
- package/dist/src/types.js +1 -0
- package/dist/src/vite-env-override.d.ts +20 -0
- package/package.json +71 -60
- package/src/Render.svelte +3 -1
- package/src/api_docs/ApiDocs.svelte +1 -1
- package/src/api_docs/ApiRecorder.svelte +1 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<script>import space_logo from "./images/spaces.svg";
|
|
2
|
+
import { _ } from "svelte-i18n";
|
|
3
|
+
export let wrapper;
|
|
4
|
+
export let version;
|
|
5
|
+
export let initial_height;
|
|
6
|
+
export let fill_width;
|
|
7
|
+
export let is_embed;
|
|
8
|
+
export let space;
|
|
9
|
+
export let display;
|
|
10
|
+
export let info;
|
|
11
|
+
export let loaded;
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div
|
|
15
|
+
bind:this={wrapper}
|
|
16
|
+
class:app={!display && !is_embed}
|
|
17
|
+
class:fill_width
|
|
18
|
+
class:embed-container={display}
|
|
19
|
+
class:with-info={info}
|
|
20
|
+
class="gradio-container gradio-container-{version}"
|
|
21
|
+
style:min-height={loaded ? "initial" : initial_height}
|
|
22
|
+
style:flex-grow={!display ? "1" : "auto"}
|
|
23
|
+
data-iframe-height
|
|
24
|
+
>
|
|
25
|
+
<div class="main">
|
|
26
|
+
<slot />
|
|
27
|
+
</div>
|
|
28
|
+
{#if display && space && info}
|
|
29
|
+
<div class="info">
|
|
30
|
+
<span>
|
|
31
|
+
<a href="https://huggingface.co/spaces/{space}" class="title">{space}</a
|
|
32
|
+
>
|
|
33
|
+
</span>
|
|
34
|
+
<span>
|
|
35
|
+
{$_("common.built_with")}
|
|
36
|
+
<a class="gradio" href="https://gradio.app">Gradio</a>.
|
|
37
|
+
</span>
|
|
38
|
+
<span>
|
|
39
|
+
{$_("common.hosted_on")}
|
|
40
|
+
<a class="hf" href="https://huggingface.co/spaces"
|
|
41
|
+
><span class="space-logo">
|
|
42
|
+
<img src={space_logo} alt="Hugging Face Space" />
|
|
43
|
+
</span> Spaces</a
|
|
44
|
+
>
|
|
45
|
+
</span>
|
|
46
|
+
</div>
|
|
47
|
+
{/if}
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
.gradio-container {
|
|
52
|
+
display: flex;
|
|
53
|
+
position: relative;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
padding: 0;
|
|
56
|
+
min-height: 1px;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
color: var(--button-secondary-text-color);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.embed-container {
|
|
62
|
+
margin: var(--size-4) 0px;
|
|
63
|
+
border: 1px solid var(--button-secondary-border-color);
|
|
64
|
+
border-radius: var(--embed-radius);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.with-info {
|
|
68
|
+
padding-bottom: var(--size-7);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.embed-container > .main {
|
|
72
|
+
padding: var(--size-4);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.app > .main {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-grow: 1;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.app {
|
|
82
|
+
position: relative;
|
|
83
|
+
margin: auto;
|
|
84
|
+
padding: var(--size-4) var(--size-8);
|
|
85
|
+
width: 100%;
|
|
86
|
+
height: 100%;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@media (--screen-sm) {
|
|
90
|
+
.app:not(.fill_width) {
|
|
91
|
+
max-width: 640px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
@media (--screen-md) {
|
|
95
|
+
.app:not(.fill_width) {
|
|
96
|
+
max-width: 768px;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
@media (--screen-lg) {
|
|
100
|
+
.app:not(.fill_width) {
|
|
101
|
+
max-width: 1024px;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
@media (--screen-xl) {
|
|
105
|
+
.app:not(.fill_width) {
|
|
106
|
+
max-width: 1280px;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
@media (--screen-xxl) {
|
|
110
|
+
.app:not(.fill_width) {
|
|
111
|
+
max-width: 1536px;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.info {
|
|
116
|
+
display: flex;
|
|
117
|
+
position: absolute;
|
|
118
|
+
bottom: 0;
|
|
119
|
+
justify-content: flex-start;
|
|
120
|
+
border-top: 1px solid var(--button-secondary-border-color);
|
|
121
|
+
padding: var(--size-1) var(--size-5);
|
|
122
|
+
width: 100%;
|
|
123
|
+
color: var(--body-text-color-subdued);
|
|
124
|
+
font-size: var(--text-md);
|
|
125
|
+
white-space: nowrap;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.info > span {
|
|
129
|
+
word-wrap: break-word;
|
|
130
|
+
-break: keep-all;
|
|
131
|
+
display: block;
|
|
132
|
+
word-break: keep-all;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.info > span:nth-child(1) {
|
|
136
|
+
margin-right: 4px;
|
|
137
|
+
min-width: 0px;
|
|
138
|
+
max-width: max-content;
|
|
139
|
+
overflow: hidden;
|
|
140
|
+
color: var(--body-text-color);
|
|
141
|
+
text-overflow: ellipsis;
|
|
142
|
+
white-space: nowrap;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.info > span:nth-child(2) {
|
|
146
|
+
margin-right: 3px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.info > span:nth-child(2),
|
|
150
|
+
.info > span:nth-child(3) {
|
|
151
|
+
width: max-content;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.info > span:nth-child(3) {
|
|
155
|
+
align-self: flex-end;
|
|
156
|
+
justify-self: flex-end;
|
|
157
|
+
margin-left: auto;
|
|
158
|
+
text-align: right;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.info > span:nth-child(1) {
|
|
162
|
+
flex-shrink: 9;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.hidden-title {
|
|
166
|
+
position: absolute;
|
|
167
|
+
left: var(--size-5);
|
|
168
|
+
opacity: 0;
|
|
169
|
+
background: var(--button-secondary-background-fill);
|
|
170
|
+
padding-right: 4px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.info a {
|
|
174
|
+
color: var(--body-text-color);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.title {
|
|
178
|
+
font-size: var(--text-sm);
|
|
179
|
+
font-family: var(--font-mono);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.hf {
|
|
183
|
+
margin-left: 5px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.space-logo img {
|
|
187
|
+
display: inline-block;
|
|
188
|
+
margin-bottom: 4px;
|
|
189
|
+
height: 12px;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
a:hover {
|
|
193
|
+
text-decoration: underline;
|
|
194
|
+
}
|
|
195
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
wrapper: HTMLDivElement;
|
|
5
|
+
version: string;
|
|
6
|
+
initial_height: string;
|
|
7
|
+
fill_width: boolean;
|
|
8
|
+
is_embed: boolean;
|
|
9
|
+
space: string | null;
|
|
10
|
+
display: boolean;
|
|
11
|
+
info: boolean;
|
|
12
|
+
loaded: boolean;
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {
|
|
18
|
+
default: {};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type EmbedProps = typeof __propDef.props;
|
|
22
|
+
export type EmbedEvents = typeof __propDef.events;
|
|
23
|
+
export type EmbedSlots = typeof __propDef.slots;
|
|
24
|
+
export default class Embed extends SvelteComponent<EmbedProps, EmbedEvents, EmbedSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script>import Form from "@gradio/form";
|
|
2
|
+
import { BaseTextbox as Textbox } from "@gradio/textbox";
|
|
3
|
+
import { BaseButton } from "@gradio/button";
|
|
4
|
+
import Column from "@gradio/column";
|
|
5
|
+
import { Block } from "@gradio/atoms";
|
|
6
|
+
import { _ } from "svelte-i18n";
|
|
7
|
+
export let root;
|
|
8
|
+
export let auth_message;
|
|
9
|
+
export let app_mode;
|
|
10
|
+
export let space_id;
|
|
11
|
+
let username = "";
|
|
12
|
+
let password = "";
|
|
13
|
+
let incorrect_credentials = false;
|
|
14
|
+
const submit = async () => {
|
|
15
|
+
const formData = new FormData();
|
|
16
|
+
formData.append("username", username);
|
|
17
|
+
formData.append("password", password);
|
|
18
|
+
let response = await fetch(root + "/login", {
|
|
19
|
+
method: "POST",
|
|
20
|
+
body: formData
|
|
21
|
+
});
|
|
22
|
+
if (response.status === 400) {
|
|
23
|
+
incorrect_credentials = true;
|
|
24
|
+
username = "";
|
|
25
|
+
password = "";
|
|
26
|
+
} else if (response.status == 200) {
|
|
27
|
+
location.reload();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<div class="wrap" class:min-h-screen={app_mode}>
|
|
33
|
+
<Column variant="panel" min_width={480}>
|
|
34
|
+
<h2>{$_("login.login")}</h2>
|
|
35
|
+
{#if auth_message}
|
|
36
|
+
<p class="auth">{@html auth_message}</p>
|
|
37
|
+
{/if}
|
|
38
|
+
{#if space_id}
|
|
39
|
+
<p class="auth">
|
|
40
|
+
{$_("login.enable_cookies")}
|
|
41
|
+
</p>
|
|
42
|
+
{/if}
|
|
43
|
+
{#if incorrect_credentials}
|
|
44
|
+
<p class="creds">{$_("login.incorrect_credentials")}</p>
|
|
45
|
+
{/if}
|
|
46
|
+
<Form>
|
|
47
|
+
<Block>
|
|
48
|
+
<Textbox
|
|
49
|
+
label="username"
|
|
50
|
+
lines={1}
|
|
51
|
+
show_label={true}
|
|
52
|
+
max_lines={1}
|
|
53
|
+
on:submit={submit}
|
|
54
|
+
bind:value={username}
|
|
55
|
+
/>
|
|
56
|
+
</Block>
|
|
57
|
+
|
|
58
|
+
<Block>
|
|
59
|
+
<Textbox
|
|
60
|
+
label="password"
|
|
61
|
+
lines={1}
|
|
62
|
+
show_label={true}
|
|
63
|
+
max_lines={1}
|
|
64
|
+
type="password"
|
|
65
|
+
on:submit={submit}
|
|
66
|
+
bind:value={password}
|
|
67
|
+
/>
|
|
68
|
+
</Block>
|
|
69
|
+
</Form>
|
|
70
|
+
|
|
71
|
+
<BaseButton size="lg" variant="primary" on:click={submit}
|
|
72
|
+
>{$_("login.login")}</BaseButton
|
|
73
|
+
>
|
|
74
|
+
</Column>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<style>
|
|
78
|
+
.wrap {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
align-items: center;
|
|
83
|
+
margin-top: var(--size-3);
|
|
84
|
+
background: var(--background-fill-primary);
|
|
85
|
+
width: var(--size-full);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
h2 {
|
|
89
|
+
margin-bottom: var(--size-3);
|
|
90
|
+
color: var(--body-text-color);
|
|
91
|
+
font-weight: var(--section-header-text-weight);
|
|
92
|
+
font-size: var(--text-xl);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.auth {
|
|
96
|
+
margin-top: var(--size-1);
|
|
97
|
+
margin-bottom: var(--size-1);
|
|
98
|
+
color: var(--body-text-color);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.creds {
|
|
102
|
+
margin-top: var(--size-4);
|
|
103
|
+
margin-bottom: var(--size-4);
|
|
104
|
+
color: var(--error-text-color);
|
|
105
|
+
font-weight: var(--weight-semibold);
|
|
106
|
+
}
|
|
107
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
root: string;
|
|
5
|
+
auth_message: string | null;
|
|
6
|
+
app_mode: boolean;
|
|
7
|
+
space_id: string | null;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export type LoginProps = typeof __propDef.props;
|
|
15
|
+
export type LoginEvents = typeof __propDef.events;
|
|
16
|
+
export type LoginSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Login extends SvelteComponent<LoginProps, LoginEvents, LoginSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script>import { onMount, createEventDispatcher } from "svelte";
|
|
2
|
+
import Render from "./Render.svelte";
|
|
3
|
+
export let rootNode;
|
|
4
|
+
export let root;
|
|
5
|
+
export let target;
|
|
6
|
+
export let theme_mode;
|
|
7
|
+
export let version;
|
|
8
|
+
export let autoscroll;
|
|
9
|
+
export let max_file_size = null;
|
|
10
|
+
export let client;
|
|
11
|
+
const dispatch = createEventDispatcher();
|
|
12
|
+
onMount(() => {
|
|
13
|
+
dispatch("mount");
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<Render
|
|
18
|
+
node={rootNode}
|
|
19
|
+
{root}
|
|
20
|
+
{target}
|
|
21
|
+
{theme_mode}
|
|
22
|
+
{version}
|
|
23
|
+
{autoscroll}
|
|
24
|
+
{max_file_size}
|
|
25
|
+
{client}
|
|
26
|
+
/>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Client } from "@gradio/client";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
rootNode: any;
|
|
6
|
+
root: any;
|
|
7
|
+
target: any;
|
|
8
|
+
theme_mode: any;
|
|
9
|
+
version: any;
|
|
10
|
+
autoscroll: boolean;
|
|
11
|
+
max_file_size?: (number | null) | undefined;
|
|
12
|
+
client: Client;
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
mount?: CustomEvent<undefined> | undefined;
|
|
16
|
+
} & {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {};
|
|
20
|
+
};
|
|
21
|
+
export type MountComponentsProps = typeof __propDef.props;
|
|
22
|
+
export type MountComponentsEvents = typeof __propDef.events;
|
|
23
|
+
export type MountComponentsSlots = typeof __propDef.slots;
|
|
24
|
+
export default class MountComponents extends SvelteComponent<MountComponentsProps, MountComponentsEvents, MountComponentsSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script>import { Gradio, formatter } from "./gradio_helper";
|
|
2
|
+
import { onMount, createEventDispatcher, setContext } from "svelte";
|
|
3
|
+
import RenderComponent from "./RenderComponent.svelte";
|
|
4
|
+
import { load_component } from "virtual:component-loader";
|
|
5
|
+
export let root;
|
|
6
|
+
export let node;
|
|
7
|
+
export let parent = null;
|
|
8
|
+
export let target;
|
|
9
|
+
export let theme_mode;
|
|
10
|
+
export let version;
|
|
11
|
+
export let autoscroll;
|
|
12
|
+
export let max_file_size;
|
|
13
|
+
export let client;
|
|
14
|
+
const dispatch = createEventDispatcher();
|
|
15
|
+
let filtered_children = [];
|
|
16
|
+
onMount(() => {
|
|
17
|
+
dispatch("mount", node.id);
|
|
18
|
+
for (const child of filtered_children) {
|
|
19
|
+
dispatch("mount", child.id);
|
|
20
|
+
}
|
|
21
|
+
return () => {
|
|
22
|
+
dispatch("destroy", node.id);
|
|
23
|
+
for (const child of filtered_children) {
|
|
24
|
+
dispatch("mount", child.id);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
$:
|
|
29
|
+
node.children = node.children && node.children.filter((v) => {
|
|
30
|
+
const valid_node = node.type !== "statustracker";
|
|
31
|
+
if (!valid_node) {
|
|
32
|
+
filtered_children.push(v);
|
|
33
|
+
}
|
|
34
|
+
return valid_node;
|
|
35
|
+
});
|
|
36
|
+
setContext("BLOCK_KEY", parent);
|
|
37
|
+
$: {
|
|
38
|
+
if (node.type === "form") {
|
|
39
|
+
if (node.children?.every((c) => !c.props.visible)) {
|
|
40
|
+
node.props.visible = false;
|
|
41
|
+
} else {
|
|
42
|
+
node.props.visible = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
$:
|
|
47
|
+
gradio_class = new Gradio(
|
|
48
|
+
node.id,
|
|
49
|
+
target,
|
|
50
|
+
theme_mode,
|
|
51
|
+
version,
|
|
52
|
+
root,
|
|
53
|
+
autoscroll,
|
|
54
|
+
max_file_size,
|
|
55
|
+
formatter,
|
|
56
|
+
client,
|
|
57
|
+
load_component
|
|
58
|
+
);
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<RenderComponent
|
|
62
|
+
_id={node.id}
|
|
63
|
+
component={node.component}
|
|
64
|
+
bind:instance={node.instance}
|
|
65
|
+
bind:value={node.props.value}
|
|
66
|
+
elem_id={("elem_id" in node.props && node.props.elem_id) ||
|
|
67
|
+
`component-${node.id}`}
|
|
68
|
+
elem_classes={("elem_classes" in node.props && node.props.elem_classes) || []}
|
|
69
|
+
{target}
|
|
70
|
+
{...node.props}
|
|
71
|
+
{theme_mode}
|
|
72
|
+
{root}
|
|
73
|
+
gradio={gradio_class}
|
|
74
|
+
>
|
|
75
|
+
{#if node.children && node.children.length}
|
|
76
|
+
{#each node.children as _node (_node.id)}
|
|
77
|
+
<svelte:self
|
|
78
|
+
node={_node}
|
|
79
|
+
component={_node.component}
|
|
80
|
+
{target}
|
|
81
|
+
id={_node.id}
|
|
82
|
+
{root}
|
|
83
|
+
{theme_mode}
|
|
84
|
+
on:destroy
|
|
85
|
+
on:mount
|
|
86
|
+
{max_file_size}
|
|
87
|
+
{client}
|
|
88
|
+
/>
|
|
89
|
+
{/each}
|
|
90
|
+
{/if}
|
|
91
|
+
</RenderComponent>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ComponentMeta, ThemeMode } from "./types";
|
|
3
|
+
import type { Client } from "@gradio/client";
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
root: string;
|
|
7
|
+
node: ComponentMeta;
|
|
8
|
+
parent?: (string | null) | undefined;
|
|
9
|
+
target: HTMLElement;
|
|
10
|
+
theme_mode: ThemeMode;
|
|
11
|
+
version: string;
|
|
12
|
+
autoscroll: boolean;
|
|
13
|
+
max_file_size: number | null;
|
|
14
|
+
client: Client;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
mount: CustomEvent<number>;
|
|
18
|
+
destroy: CustomEvent<number>;
|
|
19
|
+
} & {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
};
|
|
22
|
+
slots: {};
|
|
23
|
+
};
|
|
24
|
+
export type RenderProps = typeof __propDef.props;
|
|
25
|
+
export type RenderEvents = typeof __propDef.events;
|
|
26
|
+
export type RenderSlots = typeof __propDef.slots;
|
|
27
|
+
export default class Render extends SvelteComponent<RenderProps, RenderEvents, RenderSlots> {
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<svelte:options immutable={true} />
|
|
2
|
+
|
|
3
|
+
<script>import { bind, binding_callbacks } from "svelte/internal";
|
|
4
|
+
export let root;
|
|
5
|
+
export let component;
|
|
6
|
+
export let target;
|
|
7
|
+
export let theme_mode;
|
|
8
|
+
export let instance;
|
|
9
|
+
export let value;
|
|
10
|
+
export let gradio;
|
|
11
|
+
export let elem_id;
|
|
12
|
+
export let elem_classes;
|
|
13
|
+
export let _id;
|
|
14
|
+
const s = (id, p, v) => new CustomEvent("prop_change", { detail: { id, prop: p, value: v } });
|
|
15
|
+
function wrap(component2) {
|
|
16
|
+
const ProxiedMyClass = new Proxy(component2, {
|
|
17
|
+
construct(_target, args) {
|
|
18
|
+
const instance2 = new _target(...args);
|
|
19
|
+
const props = Object.keys(instance2.$$.props);
|
|
20
|
+
function report(props2) {
|
|
21
|
+
return function(propargs) {
|
|
22
|
+
const ev = s(_id, props2, propargs);
|
|
23
|
+
target.dispatchEvent(ev);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
props.forEach((v) => {
|
|
27
|
+
binding_callbacks.push(() => bind(instance2, v, report(v)));
|
|
28
|
+
});
|
|
29
|
+
return instance2;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return ProxiedMyClass;
|
|
33
|
+
}
|
|
34
|
+
const _component = wrap(component);
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<svelte:component
|
|
38
|
+
this={_component}
|
|
39
|
+
bind:this={instance}
|
|
40
|
+
bind:value
|
|
41
|
+
on:prop_change
|
|
42
|
+
{elem_id}
|
|
43
|
+
{elem_classes}
|
|
44
|
+
{target}
|
|
45
|
+
{...$$restProps}
|
|
46
|
+
{theme_mode}
|
|
47
|
+
{root}
|
|
48
|
+
{gradio}
|
|
49
|
+
>
|
|
50
|
+
<slot />
|
|
51
|
+
</svelte:component>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Gradio } from "./gradio_helper";
|
|
3
|
+
import type { ComponentMeta, ThemeMode } from "./types";
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
[x: string]: any;
|
|
7
|
+
root: string;
|
|
8
|
+
component: ComponentMeta["component"];
|
|
9
|
+
target: HTMLElement;
|
|
10
|
+
theme_mode: ThemeMode;
|
|
11
|
+
instance: ComponentMeta["instance"];
|
|
12
|
+
value: any;
|
|
13
|
+
gradio: Gradio;
|
|
14
|
+
elem_id: string;
|
|
15
|
+
elem_classes: string[];
|
|
16
|
+
_id: number;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
prop_change: any;
|
|
20
|
+
} & {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
};
|
|
23
|
+
slots: {
|
|
24
|
+
default: {};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type RenderComponentProps = typeof __propDef.props;
|
|
28
|
+
export type RenderComponentEvents = typeof __propDef.events;
|
|
29
|
+
export type RenderComponentSlots = typeof __propDef.slots;
|
|
30
|
+
export default class RenderComponent extends SvelteComponent<RenderComponentProps, RenderComponentEvents, RenderComponentSlots> {
|
|
31
|
+
}
|
|
32
|
+
export {};
|