@gradio/core 0.29.2 → 1.0.0-dev.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 +103 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/src/Blocks.svelte +518 -999
- package/dist/src/Blocks.svelte.d.ts +31 -46
- package/dist/src/Embed.svelte +82 -55
- package/dist/src/Embed.svelte.d.ts +39 -30
- package/dist/src/Login.svelte +33 -29
- package/dist/src/Login.svelte.d.ts +21 -19
- package/dist/src/MountComponents.svelte +19 -25
- package/dist/src/MountComponents.svelte.d.ts +5 -28
- package/dist/src/{init.d.ts → _init.d.ts} +5 -4
- package/dist/src/{init.js → _init.js} +31 -108
- package/dist/src/api_docs/ApiBanner.svelte +12 -8
- package/dist/src/api_docs/ApiBanner.svelte.d.ts +22 -20
- package/dist/src/api_docs/ApiDocs.svelte +338 -246
- package/dist/src/api_docs/ApiDocs.svelte.d.ts +26 -24
- package/dist/src/api_docs/ApiRecorder.svelte +9 -3
- package/dist/src/api_docs/ApiRecorder.svelte.d.ts +19 -17
- package/dist/src/api_docs/CodeSnippet.svelte +60 -30
- package/dist/src/api_docs/CodeSnippet.svelte.d.ts +27 -24
- package/dist/src/api_docs/CopyButton.svelte +69 -13
- package/dist/src/api_docs/CopyButton.svelte.d.ts +18 -16
- package/dist/src/api_docs/CopyMarkdown.svelte +734 -0
- package/dist/src/api_docs/CopyMarkdown.svelte.d.ts +37 -0
- package/dist/src/api_docs/EndpointDetail.svelte +8 -6
- package/dist/src/api_docs/EndpointDetail.svelte.d.ts +20 -18
- package/dist/src/api_docs/IconArrowUpRight.svelte +34 -0
- package/dist/src/api_docs/IconArrowUpRight.svelte.d.ts +20 -0
- package/dist/src/api_docs/IconCaret.svelte +39 -0
- package/dist/src/api_docs/IconCaret.svelte.d.ts +20 -0
- package/dist/src/api_docs/IconHuggingChat.svelte +62 -0
- package/dist/src/api_docs/IconHuggingChat.svelte.d.ts +20 -0
- package/dist/src/api_docs/InputPayload.svelte +17 -11
- package/dist/src/api_docs/InputPayload.svelte.d.ts +25 -23
- package/dist/src/api_docs/InstallSnippet.svelte +9 -6
- package/dist/src/api_docs/InstallSnippet.svelte.d.ts +18 -16
- package/dist/src/api_docs/MCPSnippet.svelte +119 -99
- package/dist/src/api_docs/MCPSnippet.svelte.d.ts +59 -58
- package/dist/src/api_docs/NoApi.svelte +8 -5
- package/dist/src/api_docs/NoApi.svelte.d.ts +20 -18
- package/dist/src/api_docs/ParametersSnippet.svelte +8 -6
- package/dist/src/api_docs/ParametersSnippet.svelte.d.ts +21 -19
- package/dist/src/api_docs/RecordingSnippet.svelte +124 -110
- package/dist/src/api_docs/RecordingSnippet.svelte.d.ts +24 -22
- package/dist/src/api_docs/ResponseSnippet.svelte +7 -5
- package/dist/src/api_docs/ResponseSnippet.svelte.d.ts +21 -19
- package/dist/src/api_docs/Settings.svelte +73 -62
- package/dist/src/api_docs/Settings.svelte.d.ts +25 -23
- package/dist/src/api_docs/SettingsBanner.svelte +11 -8
- package/dist/src/api_docs/SettingsBanner.svelte.d.ts +20 -18
- package/dist/src/api_docs/TryButton.svelte +5 -3
- package/dist/src/api_docs/TryButton.svelte.d.ts +19 -17
- package/dist/src/api_docs/img/IconCheck.svelte +33 -0
- package/dist/src/api_docs/img/IconCheck.svelte.d.ts +26 -0
- package/dist/src/api_docs/img/IconCopy.svelte +40 -0
- package/dist/src/api_docs/img/IconCopy.svelte.d.ts +26 -0
- package/dist/src/api_docs/img/clear.svelte.d.ts +22 -21
- package/dist/src/dependency.d.ts +142 -0
- package/dist/src/dependency.js +653 -0
- package/dist/src/init.svelte.d.ts +78 -0
- package/dist/src/init.svelte.js +469 -0
- package/dist/src/init_utils.d.ts +32 -0
- package/dist/src/init_utils.js +73 -0
- package/dist/src/lang/en.json +10 -1
- package/dist/src/lang/get_lang_names.js +0 -3
- package/dist/src/lang/ru.json +10 -1
- package/dist/src/stores.d.ts +0 -21
- package/dist/src/stories/I18nMultiLanguageTestComponent.svelte +5 -3
- package/dist/src/stories/I18nMultiLanguageTestComponent.svelte.d.ts +16 -14
- package/dist/src/stories/I18nTestSetup.svelte +14 -10
- package/dist/src/stories/I18nTestSetup.svelte.d.ts +18 -16
- package/dist/src/types.d.ts +29 -25
- package/index.ts +1 -1
- package/package.json +59 -59
- package/src/Blocks.svelte +344 -1059
- package/src/MountComponents.svelte +17 -27
- package/src/{init.ts → _init.ts} +49 -126
- package/src/api_docs/ApiDocs.svelte +67 -62
- package/src/api_docs/ApiRecorder.svelte +3 -0
- package/src/api_docs/CodeSnippet.svelte +20 -5
- package/src/api_docs/CopyButton.svelte +61 -7
- package/src/api_docs/CopyMarkdown.svelte +734 -0
- package/src/api_docs/IconArrowUpRight.svelte +34 -0
- package/src/api_docs/IconCaret.svelte +39 -0
- package/src/api_docs/IconHuggingChat.svelte +62 -0
- package/src/api_docs/MCPSnippet.svelte +24 -46
- package/src/api_docs/NoApi.svelte +1 -1
- package/src/api_docs/ParametersSnippet.svelte +1 -1
- package/src/api_docs/ResponseSnippet.svelte +1 -1
- package/src/api_docs/Settings.svelte +11 -11
- package/src/api_docs/img/IconCheck.svelte +33 -0
- package/src/api_docs/img/IconCopy.svelte +40 -0
- package/src/dependency.ts +880 -0
- package/src/init.svelte.ts +717 -0
- package/src/init_utils.ts +99 -0
- package/src/lang/en.json +10 -1
- package/src/lang/get_lang_names.js +0 -3
- package/src/lang/ru.json +10 -1
- package/src/stores.ts +22 -22
- package/src/types.ts +54 -43
- package/dist/src/Render.svelte +0 -105
- package/dist/src/Render.svelte.d.ts +0 -31
- package/dist/src/RenderComponent.svelte +0 -72
- package/dist/src/RenderComponent.svelte.d.ts +0 -33
- package/src/Render.svelte +0 -126
- package/src/RenderComponent.svelte +0 -91
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { load_component } from "virtual:component-loader";
|
|
2
|
+
import type { Dependency, LoadingComponent } from "./types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Load a component given its type and class_id without awaiting it
|
|
6
|
+
* @param type
|
|
7
|
+
* @param class_id
|
|
8
|
+
* @param root
|
|
9
|
+
* @returns the loading component
|
|
10
|
+
*/
|
|
11
|
+
export function get_component(
|
|
12
|
+
type: string,
|
|
13
|
+
class_id: string,
|
|
14
|
+
root: string,
|
|
15
|
+
variant: "component" | "example" | "base" = "component"
|
|
16
|
+
): LoadingComponent {
|
|
17
|
+
if (type === "api") type = "state";
|
|
18
|
+
|
|
19
|
+
return load_component({
|
|
20
|
+
api_url: root,
|
|
21
|
+
name: type,
|
|
22
|
+
id: class_id,
|
|
23
|
+
variant
|
|
24
|
+
}).component;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get all component ids that are an input dependency and all that are an output dependency
|
|
29
|
+
* @param dep the dependency
|
|
30
|
+
* @param inputs the set of inputs
|
|
31
|
+
* @param outputs the set of outputs
|
|
32
|
+
* @returns a tuple of the inputs and outputs
|
|
33
|
+
*/
|
|
34
|
+
export function get_inputs_outputs(
|
|
35
|
+
dependencies: Dependency[]
|
|
36
|
+
): [Set<number>, Set<number>] {
|
|
37
|
+
const inputs = new Set<number>();
|
|
38
|
+
const outputs = new Set<number>();
|
|
39
|
+
for (const dep of dependencies) {
|
|
40
|
+
dep.inputs.forEach((input) => inputs.add(input));
|
|
41
|
+
dep.outputs.forEach((output) => outputs.add(output));
|
|
42
|
+
}
|
|
43
|
+
return [inputs, outputs];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Determines if a component is interactive
|
|
48
|
+
* explicitly set interactive prop takes precedence
|
|
49
|
+
* if not set, then if the component is an input to a dependency, it is interactive
|
|
50
|
+
* if not an input, but has no outputs and no default value, it is interactive (for dev)
|
|
51
|
+
* everything else is not interactive
|
|
52
|
+
* @param id component id
|
|
53
|
+
* @param interactive_prop value of the interactive prop
|
|
54
|
+
* @param value the main value of the component
|
|
55
|
+
* @param dependencies a tuple of sets of input and output component ids
|
|
56
|
+
* @returns if the component is interactive
|
|
57
|
+
*/
|
|
58
|
+
export function determine_interactivity(
|
|
59
|
+
id: number,
|
|
60
|
+
interactive_prop: boolean | undefined,
|
|
61
|
+
value: any,
|
|
62
|
+
dependencies: [Set<number>, Set<number>]
|
|
63
|
+
): boolean {
|
|
64
|
+
const [inputs, outputs] = dependencies;
|
|
65
|
+
|
|
66
|
+
if (interactive_prop === false) {
|
|
67
|
+
return false;
|
|
68
|
+
} else if (interactive_prop === true) {
|
|
69
|
+
return true;
|
|
70
|
+
} else if (
|
|
71
|
+
inputs.has(id) ||
|
|
72
|
+
(!outputs.has(id) && has_no_default_value(value))
|
|
73
|
+
) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Check if a value is not a default value
|
|
82
|
+
* @param value the value to check
|
|
83
|
+
* @returns default value boolean
|
|
84
|
+
*/
|
|
85
|
+
function has_no_default_value(value: any): boolean {
|
|
86
|
+
return (
|
|
87
|
+
(Array.isArray(value) && value.length === 0) ||
|
|
88
|
+
value === "" ||
|
|
89
|
+
value === 0 ||
|
|
90
|
+
!value
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** An async version of 'new Function' */
|
|
95
|
+
export const AsyncFunction: new (
|
|
96
|
+
...args: string[]
|
|
97
|
+
) => (...args: any[]) => Promise<any> = Object.getPrototypeOf(
|
|
98
|
+
async function () {}
|
|
99
|
+
).constructor;
|
package/src/lang/en.json
CHANGED
|
@@ -36,7 +36,16 @@
|
|
|
36
36
|
"cancel": "Cancel",
|
|
37
37
|
"like": "Like",
|
|
38
38
|
"dislike": "Dislike",
|
|
39
|
-
"clear": "Clear"
|
|
39
|
+
"clear": "Clear",
|
|
40
|
+
"copy_message": "Copy message",
|
|
41
|
+
"copied_message": "Copied message"
|
|
42
|
+
},
|
|
43
|
+
"chat_interface": {
|
|
44
|
+
"new_chat": "New chat",
|
|
45
|
+
"message_placeholder": "Type a message...",
|
|
46
|
+
"additional_inputs": "Additional inputs",
|
|
47
|
+
"chatbot": "Chatbot",
|
|
48
|
+
"conversation": "Conversation"
|
|
40
49
|
},
|
|
41
50
|
"checkbox": {
|
|
42
51
|
"checkbox": "Checkbox",
|
package/src/lang/ru.json
CHANGED
|
@@ -150,6 +150,15 @@
|
|
|
150
150
|
"cancel": "Отмена",
|
|
151
151
|
"like": "Нравится",
|
|
152
152
|
"dislike": "Не нравится",
|
|
153
|
-
"clear": "Очистить чат"
|
|
153
|
+
"clear": "Очистить чат",
|
|
154
|
+
"copy_message": "Копировать сообщение",
|
|
155
|
+
"copied_message": "Сообщение скопировано"
|
|
156
|
+
},
|
|
157
|
+
"chat_interface": {
|
|
158
|
+
"new_chat": "Новый чат",
|
|
159
|
+
"message_placeholder": "Введите сообщение...",
|
|
160
|
+
"additional_inputs": "Дополнительные поля",
|
|
161
|
+
"chatbot": "Чат-бот",
|
|
162
|
+
"conversation": "Разговор"
|
|
154
163
|
}
|
|
155
164
|
}
|
package/src/stores.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { type Writable, writable, get } from "svelte/store";
|
|
2
2
|
|
|
3
|
-
export interface LoadingStatus {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type LoadingStatusCollection = Record<number, LoadingStatus>;
|
|
3
|
+
// export interface LoadingStatus {
|
|
4
|
+
// eta: number | null;
|
|
5
|
+
// status: "pending" | "error" | "complete" | "generating" | "streaming";
|
|
6
|
+
// queue: boolean;
|
|
7
|
+
// queue_position: number | null;
|
|
8
|
+
// queue_size?: number;
|
|
9
|
+
// fn_index: number;
|
|
10
|
+
// message?: string | null;
|
|
11
|
+
// scroll_to_output?: boolean;
|
|
12
|
+
// show_progress?: "full" | "minimal" | "hidden";
|
|
13
|
+
// time_limit?: number | null | undefined;
|
|
14
|
+
// progress?: {
|
|
15
|
+
// progress: number | null;
|
|
16
|
+
// index: number | null;
|
|
17
|
+
// length: number | null;
|
|
18
|
+
// unit: string | null;
|
|
19
|
+
// desc: string | null;
|
|
20
|
+
// }[];
|
|
21
|
+
// validation_error?: string | null;
|
|
22
|
+
// }
|
|
23
|
+
|
|
24
|
+
// export type LoadingStatusCollection = Record<number, LoadingStatus>;
|
|
25
25
|
|
|
26
26
|
interface LoadingStatusStore {
|
|
27
27
|
update: (status: LoadingStatus) => void;
|
package/src/types.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Component } from "svelte";
|
|
2
|
+
import type { SharedProps } from "@gradio/utils";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
components?: string[];
|
|
9
|
-
server_fns?: string[];
|
|
10
|
-
interactive: boolean;
|
|
11
|
-
visible: boolean | "hidden";
|
|
12
|
-
[key: string]: unknown;
|
|
13
|
-
}
|
|
4
|
+
export type ServerFunctions = Record<string, (...args: any[]) => Promise<any>>;
|
|
5
|
+
|
|
6
|
+
// import type { I18nFormatter } from "./i18n.js";
|
|
7
|
+
// import type { component_loader } from "./init.js";
|
|
14
8
|
|
|
15
9
|
/** The metadata for a component
|
|
16
10
|
* The non optional fields are what are received from the backend
|
|
@@ -19,19 +13,27 @@ interface SharedProps {
|
|
|
19
13
|
export interface ComponentMeta {
|
|
20
14
|
type: string;
|
|
21
15
|
id: number;
|
|
22
|
-
|
|
23
|
-
props: SharedProps;
|
|
24
|
-
instance: SvelteComponent;
|
|
25
|
-
component: ComponentType<SvelteComponent>;
|
|
16
|
+
props: SharedProps & Record<string, unknown>;
|
|
26
17
|
documentation?: Documentation;
|
|
27
|
-
children?: ComponentMeta[];
|
|
28
|
-
parent?: ComponentMeta;
|
|
29
18
|
value?: any;
|
|
30
19
|
component_class_id: string;
|
|
31
20
|
key: string | number | null;
|
|
32
21
|
rendered_in?: number;
|
|
33
22
|
}
|
|
34
23
|
|
|
24
|
+
export interface ProcessedComponentMeta {
|
|
25
|
+
type: string;
|
|
26
|
+
id: number;
|
|
27
|
+
props: { shared_props: SharedProps; props: Record<string, unknown> };
|
|
28
|
+
component: Component | LoadingComponent | null;
|
|
29
|
+
documentation?: Documentation;
|
|
30
|
+
children: ProcessedComponentMeta[];
|
|
31
|
+
// parent?: ProcessedComponentMeta;
|
|
32
|
+
component_class_id: string; // ?;
|
|
33
|
+
key: string | number | null; // ?;
|
|
34
|
+
rendered_in?: number; // ?;
|
|
35
|
+
}
|
|
36
|
+
|
|
35
37
|
/** Dictates whether a dependency is continous and/or a generator */
|
|
36
38
|
export interface DependencyTypes {
|
|
37
39
|
generator: boolean;
|
|
@@ -54,32 +56,32 @@ export interface Dependency {
|
|
|
54
56
|
inputs: number[];
|
|
55
57
|
outputs: number[];
|
|
56
58
|
backend_fn: boolean;
|
|
57
|
-
js: string | null;
|
|
58
|
-
scroll_to_output: boolean;
|
|
59
|
-
show_progress: "full" | "minimal" | "hidden";
|
|
60
|
-
show_progress_on: number[] | null;
|
|
61
|
-
frontend_fn: ((...args: unknown[]) => Promise<unknown[]>) | null;
|
|
62
|
-
status?: string;
|
|
63
|
-
queue: boolean | null;
|
|
64
|
-
api_name: string | null;
|
|
59
|
+
js: string | null; // frontend fn
|
|
60
|
+
scroll_to_output: boolean; // used by loading_status
|
|
61
|
+
show_progress: "full" | "minimal" | "hidden"; // used by loading_status
|
|
62
|
+
show_progress_on: number[] | null; // used by loading_status
|
|
63
|
+
// frontend_fn: ((...args: unknown[]) => Promise<unknown[]>) | null;
|
|
64
|
+
//status?: string; // I can't find this
|
|
65
|
+
queue: boolean | null; // used by client
|
|
66
|
+
api_name: string | null; // used by client
|
|
65
67
|
cancels: number[];
|
|
66
68
|
types: DependencyTypes;
|
|
67
69
|
collects_event_data: boolean;
|
|
68
|
-
pending_request?: boolean;
|
|
69
|
-
trigger_after?: number;
|
|
70
|
-
trigger_only_on_success?: boolean;
|
|
71
|
-
trigger_only_on_failure?: boolean;
|
|
72
|
-
trigger_mode: "once" | "multiple" | "always_last";
|
|
73
|
-
final_event: Payload | null;
|
|
74
|
-
show_api: boolean;
|
|
75
|
-
rendered_in: number | null;
|
|
76
|
-
render_id: number | null;
|
|
77
|
-
connection: "stream" | "sse";
|
|
78
|
-
time_limit: number;
|
|
79
|
-
stream_every: number;
|
|
80
|
-
like_user_message: boolean;
|
|
81
|
-
event_specific_args:
|
|
82
|
-
js_implementation: string | null;
|
|
70
|
+
//pending_request?: boolean; // added, not received from backend, unneeded
|
|
71
|
+
trigger_after?: number; // then events
|
|
72
|
+
trigger_only_on_success?: boolean; // success events
|
|
73
|
+
trigger_only_on_failure?: boolean; // failure events
|
|
74
|
+
trigger_mode: "once" | "multiple" | "always_last"; // dispatch policy
|
|
75
|
+
// final_event: Payload | null; // added, not received from backend
|
|
76
|
+
show_api: boolean; // use by api_doc
|
|
77
|
+
rendered_in: number | null; // which component the new config should be added to
|
|
78
|
+
render_id: number | null; // dno
|
|
79
|
+
connection: "stream" | "sse"; // dno
|
|
80
|
+
time_limit: number; // time limit for streaming
|
|
81
|
+
stream_every: number; // chunk timeout for media recorder
|
|
82
|
+
like_user_message: boolean; // dno, this shouldnt be here surely
|
|
83
|
+
event_specific_args: ("time_limit" | "stream_every" | "like_user_message")[]; // `click(fn, some_arg=val)`
|
|
84
|
+
js_implementation: string | null; // pythong -> js transpilation
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
interface TypeDescription {
|
|
@@ -108,10 +110,19 @@ export type TargetMap = Record<number, Record<string, number[]>>;
|
|
|
108
110
|
|
|
109
111
|
/** A component that has been loaded via dynamic import */
|
|
110
112
|
export type LoadedComponent = {
|
|
111
|
-
default:
|
|
113
|
+
default: Component;
|
|
112
114
|
};
|
|
113
115
|
|
|
114
116
|
/**A component that is loading */
|
|
115
117
|
export type LoadingComponent = Promise<{
|
|
116
|
-
default:
|
|
118
|
+
default: Component;
|
|
117
119
|
}>;
|
|
120
|
+
|
|
121
|
+
export interface AppConfig {
|
|
122
|
+
root: string;
|
|
123
|
+
theme: string;
|
|
124
|
+
version: string;
|
|
125
|
+
max_file_size?: number;
|
|
126
|
+
autoscroll: boolean;
|
|
127
|
+
api_prefix: string;
|
|
128
|
+
}
|
package/dist/src/Render.svelte
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
<script>import { Gradio, reactive_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
|
-
if (node) {
|
|
30
|
-
node.children = node.children && node.children.filter((v) => {
|
|
31
|
-
const valid_node = node.type !== "statustracker";
|
|
32
|
-
if (!valid_node) {
|
|
33
|
-
filtered_children.push(v);
|
|
34
|
-
}
|
|
35
|
-
return valid_node;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
setContext("BLOCK_KEY", parent);
|
|
40
|
-
$: {
|
|
41
|
-
if (node && node.type === "form") {
|
|
42
|
-
const allChildrenInvisible = node.children?.every(
|
|
43
|
-
(c) => c.props.visible === false || c.props.visible === "hidden"
|
|
44
|
-
);
|
|
45
|
-
if (allChildrenInvisible) {
|
|
46
|
-
const hasHiddenChild = node.children?.some(
|
|
47
|
-
(c) => c.props.visible === "hidden"
|
|
48
|
-
);
|
|
49
|
-
node.props.visible = hasHiddenChild ? "hidden" : false;
|
|
50
|
-
} else {
|
|
51
|
-
node.props.visible = true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
$: node.props.gradio = new Gradio(
|
|
56
|
-
node.id,
|
|
57
|
-
target,
|
|
58
|
-
theme_mode,
|
|
59
|
-
version,
|
|
60
|
-
root,
|
|
61
|
-
autoscroll,
|
|
62
|
-
max_file_size,
|
|
63
|
-
$reactive_formatter,
|
|
64
|
-
client,
|
|
65
|
-
load_component
|
|
66
|
-
);
|
|
67
|
-
</script>
|
|
68
|
-
|
|
69
|
-
{#if node.component}
|
|
70
|
-
<RenderComponent
|
|
71
|
-
_id={node?.id}
|
|
72
|
-
component={node.component}
|
|
73
|
-
bind:instance={node.instance}
|
|
74
|
-
bind:value={node.props.value}
|
|
75
|
-
elem_id={("elem_id" in node.props && node.props.elem_id) ||
|
|
76
|
-
`component-${node.id}`}
|
|
77
|
-
elem_classes={("elem_classes" in node.props && node.props.elem_classes) ||
|
|
78
|
-
[]}
|
|
79
|
-
{target}
|
|
80
|
-
{...node.props}
|
|
81
|
-
{theme_mode}
|
|
82
|
-
{root}
|
|
83
|
-
visible={typeof node.props.visible === "boolean" ||
|
|
84
|
-
node.props.visible === "hidden"
|
|
85
|
-
? node.props.visible
|
|
86
|
-
: true}
|
|
87
|
-
>
|
|
88
|
-
{#if node.children && node.children.length}
|
|
89
|
-
{#each node.children as _node (_node.id)}
|
|
90
|
-
<svelte:self
|
|
91
|
-
node={_node}
|
|
92
|
-
component={_node.component}
|
|
93
|
-
{target}
|
|
94
|
-
id={_node.id}
|
|
95
|
-
{root}
|
|
96
|
-
{theme_mode}
|
|
97
|
-
on:destroy
|
|
98
|
-
on:mount
|
|
99
|
-
{max_file_size}
|
|
100
|
-
{client}
|
|
101
|
-
/>
|
|
102
|
-
{/each}
|
|
103
|
-
{/if}
|
|
104
|
-
</RenderComponent>
|
|
105
|
-
{/if}
|
|
@@ -1,31 +0,0 @@
|
|
|
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;
|
|
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
|
-
exports?: {} | undefined;
|
|
24
|
-
bindings?: string | undefined;
|
|
25
|
-
};
|
|
26
|
-
export type RenderProps = typeof __propDef.props;
|
|
27
|
-
export type RenderEvents = typeof __propDef.events;
|
|
28
|
-
export type RenderSlots = typeof __propDef.slots;
|
|
29
|
-
export default class Render extends SvelteComponent<RenderProps, RenderEvents, RenderSlots> {
|
|
30
|
-
}
|
|
31
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
<svelte:options immutable={true} />
|
|
2
|
-
|
|
3
|
-
<script>import { translate_if_needed } from "./i18n";
|
|
4
|
-
import { bind, binding_callbacks } from "svelte/internal";
|
|
5
|
-
export let root;
|
|
6
|
-
export let component;
|
|
7
|
-
export let target;
|
|
8
|
-
export let theme_mode;
|
|
9
|
-
export let instance;
|
|
10
|
-
export let value;
|
|
11
|
-
export let elem_id;
|
|
12
|
-
export let elem_classes;
|
|
13
|
-
export let _id;
|
|
14
|
-
export let visible;
|
|
15
|
-
const s = (id, p, v) => new CustomEvent("prop_change", { detail: { id, prop: p, value: v } });
|
|
16
|
-
function wrap(component2) {
|
|
17
|
-
const ProxiedMyClass = new Proxy(component2, {
|
|
18
|
-
construct(_target, args) {
|
|
19
|
-
const instance2 = new _target(...args);
|
|
20
|
-
const props = Object.keys(instance2.$$.props);
|
|
21
|
-
function report(props2) {
|
|
22
|
-
return function(propargs) {
|
|
23
|
-
if (!target) return;
|
|
24
|
-
const ev = s(_id, props2, propargs);
|
|
25
|
-
target.dispatchEvent(ev);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
props.forEach((v) => {
|
|
29
|
-
binding_callbacks.push(() => bind(instance2, v, report(v)));
|
|
30
|
-
});
|
|
31
|
-
return instance2;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return ProxiedMyClass;
|
|
35
|
-
}
|
|
36
|
-
let _component = wrap(component);
|
|
37
|
-
const supported_props = [
|
|
38
|
-
"description",
|
|
39
|
-
"info",
|
|
40
|
-
"title",
|
|
41
|
-
"placeholder",
|
|
42
|
-
"value",
|
|
43
|
-
"label"
|
|
44
|
-
];
|
|
45
|
-
function translate_prop(obj) {
|
|
46
|
-
for (const key in obj) {
|
|
47
|
-
if (supported_props.includes(key)) {
|
|
48
|
-
obj[key] = translate_if_needed(obj[key]);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
$: translate_prop($$restProps);
|
|
53
|
-
$: value = translate_if_needed(value);
|
|
54
|
-
</script>
|
|
55
|
-
|
|
56
|
-
{#if visible}
|
|
57
|
-
<svelte:component
|
|
58
|
-
this={_component}
|
|
59
|
-
bind:this={instance}
|
|
60
|
-
bind:value
|
|
61
|
-
on:prop_change
|
|
62
|
-
{elem_id}
|
|
63
|
-
{elem_classes}
|
|
64
|
-
{target}
|
|
65
|
-
{visible}
|
|
66
|
-
{...$$restProps}
|
|
67
|
-
{theme_mode}
|
|
68
|
-
{root}
|
|
69
|
-
>
|
|
70
|
-
<slot />
|
|
71
|
-
</svelte:component>
|
|
72
|
-
{/if}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { ComponentMeta, ThemeMode } from "./types";
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
root: string;
|
|
7
|
-
component: ComponentMeta["component"];
|
|
8
|
-
target: HTMLElement;
|
|
9
|
-
theme_mode: ThemeMode;
|
|
10
|
-
instance: ComponentMeta["instance"];
|
|
11
|
-
value: any;
|
|
12
|
-
elem_id: string;
|
|
13
|
-
elem_classes: string[];
|
|
14
|
-
_id: number;
|
|
15
|
-
visible: boolean | "hidden";
|
|
16
|
-
};
|
|
17
|
-
events: {
|
|
18
|
-
prop_change: any;
|
|
19
|
-
} & {
|
|
20
|
-
[evt: string]: CustomEvent<any>;
|
|
21
|
-
};
|
|
22
|
-
slots: {
|
|
23
|
-
default: {};
|
|
24
|
-
};
|
|
25
|
-
exports?: undefined;
|
|
26
|
-
bindings?: undefined;
|
|
27
|
-
};
|
|
28
|
-
export type RenderComponentProps = typeof __propDef.props;
|
|
29
|
-
export type RenderComponentEvents = typeof __propDef.events;
|
|
30
|
-
export type RenderComponentSlots = typeof __propDef.slots;
|
|
31
|
-
export default class RenderComponent extends SvelteComponent<RenderComponentProps, RenderComponentEvents, RenderComponentSlots> {
|
|
32
|
-
}
|
|
33
|
-
export {};
|