@gradio/core 1.0.0-dev.0 → 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 +79 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/src/Blocks.svelte +518 -1001
- package/dist/src/Blocks.svelte.d.ts +31 -45
- 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 +337 -245
- 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 +7 -4
- 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 +30 -26
- package/index.ts +1 -1
- package/package.json +59 -59
- package/src/Blocks.svelte +344 -1063
- package/src/MountComponents.svelte +17 -27
- package/src/{init.ts → _init.ts} +49 -126
- package/src/api_docs/ApiDocs.svelte +65 -60
- 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/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
package/src/Blocks.svelte
CHANGED
|
@@ -1,130 +1,233 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { tick, onMount } from "svelte";
|
|
2
|
+
import { tick, onMount, setContext, settled, untrack } from "svelte";
|
|
3
3
|
import { _ } from "svelte-i18n";
|
|
4
4
|
import { Client } from "@gradio/client";
|
|
5
5
|
import { writable } from "svelte/store";
|
|
6
6
|
|
|
7
|
-
import type { LoadingStatus, LoadingStatusCollection } from "./stores";
|
|
7
|
+
// import type { LoadingStatus, LoadingStatusCollection } from "./stores";
|
|
8
8
|
|
|
9
|
-
import type {
|
|
10
|
-
|
|
9
|
+
import type {
|
|
10
|
+
ComponentMeta,
|
|
11
|
+
Dependency as IDependency,
|
|
12
|
+
LayoutNode
|
|
13
|
+
} from "./types";
|
|
14
|
+
// import type { UpdateTransaction } from "./_init";
|
|
11
15
|
import { setupi18n } from "./i18n";
|
|
12
16
|
import type { ThemeMode, Payload } from "./types";
|
|
13
17
|
import { Toast } from "@gradio/statustracker";
|
|
14
18
|
import type { ToastMessage } from "@gradio/statustracker";
|
|
15
|
-
import type
|
|
19
|
+
import { type ShareData, type ValueData, GRADIO_ROOT } from "@gradio/utils";
|
|
20
|
+
|
|
16
21
|
import MountComponents from "./MountComponents.svelte";
|
|
17
22
|
import { prefix_css } from "./css";
|
|
23
|
+
import { reactive_formatter } from "./gradio_helper";
|
|
18
24
|
|
|
19
|
-
import type
|
|
20
|
-
import type
|
|
21
|
-
import type
|
|
22
|
-
import type { ComponentType } from "svelte";
|
|
25
|
+
import type ApiDocsInterface from "./api_docs/ApiDocs.svelte";
|
|
26
|
+
import type ApiRecorderInterface from "./api_docs/ApiRecorder.svelte";
|
|
27
|
+
import type SettingsInterface from "./api_docs/Settings.svelte";
|
|
28
|
+
// import type { ComponentType } from "svelte";
|
|
23
29
|
|
|
24
30
|
import logo from "./images/logo.svg";
|
|
25
31
|
import api_logo from "./api_docs/img/api-logo.svg";
|
|
26
32
|
import settings_logo from "./api_docs/img/settings-logo.svg";
|
|
27
33
|
import record_stop from "./api_docs/img/record-stop.svg";
|
|
28
|
-
import {
|
|
29
|
-
import type {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} from "@gradio/client";
|
|
34
|
+
import { AppTree } from "./init.svelte";
|
|
35
|
+
// import type {
|
|
36
|
+
// LogMessage,
|
|
37
|
+
// RenderMessage,
|
|
38
|
+
// StatusMessage,
|
|
39
|
+
// } from "@gradio/client";
|
|
34
40
|
import * as screen_recorder from "./screen_recorder";
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
export let components: ComponentMeta[];
|
|
38
|
-
export let layout: LayoutNode;
|
|
39
|
-
export let dependencies: Dependency[];
|
|
40
|
-
export let title = "Gradio";
|
|
41
|
-
export let target: HTMLElement;
|
|
42
|
-
export let autoscroll: boolean;
|
|
43
|
-
export let footer_links = ["gradio", "settings", "api"];
|
|
44
|
-
export let control_page_title = false;
|
|
45
|
-
export let app_mode: boolean;
|
|
46
|
-
export let theme_mode: ThemeMode;
|
|
47
|
-
export let app: Awaited<ReturnType<typeof Client.connect>>;
|
|
48
|
-
export let space_id: string | null;
|
|
49
|
-
export let version: string;
|
|
50
|
-
export let js: string | null;
|
|
51
|
-
export let fill_height = false;
|
|
52
|
-
export let ready: boolean;
|
|
53
|
-
export let username: string | null;
|
|
54
|
-
export let api_prefix = "";
|
|
55
|
-
export let max_file_size: number | undefined = undefined;
|
|
56
|
-
export let initial_layout: ComponentMeta | undefined = undefined;
|
|
57
|
-
export let css: string | null | undefined = null;
|
|
58
|
-
export let vibe_mode = false;
|
|
59
|
-
let broken_connection = false;
|
|
42
|
+
import { DependencyManager } from "./dependency";
|
|
60
43
|
|
|
61
44
|
let {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
45
|
+
root,
|
|
46
|
+
components,
|
|
47
|
+
layout,
|
|
48
|
+
dependencies,
|
|
49
|
+
title,
|
|
50
|
+
target,
|
|
51
|
+
autoscroll,
|
|
52
|
+
footer_links,
|
|
53
|
+
control_page_title,
|
|
54
|
+
app_mode,
|
|
55
|
+
theme_mode,
|
|
56
|
+
app,
|
|
57
|
+
space_id,
|
|
58
|
+
version,
|
|
59
|
+
js,
|
|
60
|
+
fill_height,
|
|
61
|
+
username,
|
|
62
|
+
api_prefix,
|
|
63
|
+
max_file_size,
|
|
64
|
+
initial_layout,
|
|
65
|
+
css,
|
|
66
|
+
vibe_mode,
|
|
67
|
+
search_params,
|
|
68
|
+
render_complete = false,
|
|
69
|
+
ready = $bindable(false),
|
|
70
|
+
reload_count = $bindable(0)
|
|
71
|
+
}: {
|
|
72
|
+
root: string;
|
|
73
|
+
components: ComponentMeta[];
|
|
74
|
+
layout: LayoutNode;
|
|
75
|
+
dependencies: IDependency[];
|
|
76
|
+
title: string;
|
|
77
|
+
target: HTMLElement;
|
|
78
|
+
autoscroll: boolean;
|
|
79
|
+
footer_links: string[];
|
|
80
|
+
control_page_title: boolean;
|
|
81
|
+
app_mode: boolean;
|
|
82
|
+
theme_mode: ThemeMode;
|
|
83
|
+
app: Awaited<ReturnType<typeof Client.connect>>;
|
|
84
|
+
space_id: string | null;
|
|
85
|
+
version: string;
|
|
86
|
+
js: string | null;
|
|
87
|
+
fill_height: boolean;
|
|
88
|
+
username: string | null;
|
|
89
|
+
api_prefix: string;
|
|
90
|
+
max_file_size: number | undefined;
|
|
91
|
+
initial_layout: ComponentMeta | undefined;
|
|
92
|
+
css: string | null | undefined;
|
|
93
|
+
vibe_mode: boolean;
|
|
94
|
+
search_params: URLSearchParams;
|
|
95
|
+
render_complete: boolean;
|
|
96
|
+
ready: boolean;
|
|
97
|
+
reload_count: number;
|
|
98
|
+
} = $props();
|
|
99
|
+
|
|
100
|
+
components.forEach((comp) => {
|
|
101
|
+
if (!comp.props.i18n) {
|
|
102
|
+
comp.props.i18n = $reactive_formatter;
|
|
103
|
+
}
|
|
76
104
|
});
|
|
77
105
|
|
|
78
|
-
|
|
106
|
+
let app_tree = new AppTree(
|
|
107
|
+
components,
|
|
108
|
+
layout,
|
|
109
|
+
dependencies,
|
|
110
|
+
{
|
|
111
|
+
root,
|
|
112
|
+
theme: theme_mode,
|
|
113
|
+
version,
|
|
114
|
+
api_prefix,
|
|
115
|
+
max_file_size,
|
|
116
|
+
autoscroll
|
|
117
|
+
},
|
|
118
|
+
app,
|
|
119
|
+
$reactive_formatter
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
setContext(GRADIO_ROOT, {
|
|
123
|
+
register: app_tree.register_component.bind(app_tree),
|
|
124
|
+
dispatcher: gradio_event_dispatcher
|
|
125
|
+
});
|
|
79
126
|
|
|
80
|
-
|
|
81
|
-
ready = !!$_layout;
|
|
82
|
-
}
|
|
127
|
+
let messages: (ToastMessage & { fn_index: number })[] = $state([]);
|
|
83
128
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
129
|
+
function gradio_event_dispatcher(
|
|
130
|
+
id: number,
|
|
131
|
+
event: string,
|
|
132
|
+
data: unknown
|
|
133
|
+
): void {
|
|
134
|
+
if (event === "share") {
|
|
135
|
+
const { title, description } = data as ShareData;
|
|
136
|
+
// trigger_share(title, description);
|
|
137
|
+
// TODO: lets combine all of the into a log type with levels
|
|
138
|
+
} else if (event === "error") {
|
|
139
|
+
new_message("Error", data, -1, event, 10, true);
|
|
140
|
+
} else if (event === "warning") {
|
|
141
|
+
new_message("Warning", data, -1, event, 10, true);
|
|
142
|
+
} else if (event === "info") {
|
|
143
|
+
new_message("Info", data, -1, event, 10, true);
|
|
144
|
+
} else if (event == "clear_status") {
|
|
145
|
+
app_tree.update_state(
|
|
146
|
+
id,
|
|
147
|
+
{
|
|
148
|
+
loading_status: {}
|
|
149
|
+
},
|
|
150
|
+
false
|
|
151
|
+
);
|
|
152
|
+
dep_manager.clear_loading_status(id);
|
|
153
|
+
// TODO: the loading_status store should handle this via a method
|
|
154
|
+
// update_status(id, "complete", data);
|
|
155
|
+
} else if (event == "close_stream") {
|
|
156
|
+
dep_manager.close_stream(id);
|
|
157
|
+
} else {
|
|
158
|
+
// Tabs are a bit weird. The Tabs component dispatches 'select' events
|
|
159
|
+
// but the target id corresponds to the child Tab component that was selected.
|
|
160
|
+
// So the id we get from the dispatcher belongs to the Tabs,
|
|
161
|
+
// so we need to pull out the correct id here.
|
|
162
|
+
if (event === "select" && id in app_tree.initial_tabs) {
|
|
163
|
+
// this is the id of the selected tab
|
|
164
|
+
id = data.id;
|
|
165
|
+
}
|
|
166
|
+
dep_manager.dispatch({
|
|
167
|
+
type: "event",
|
|
168
|
+
event_name: event,
|
|
169
|
+
target_id: id,
|
|
170
|
+
event_data: data
|
|
171
|
+
});
|
|
172
|
+
}
|
|
93
173
|
}
|
|
94
174
|
|
|
95
|
-
let
|
|
175
|
+
let api_calls: Payload[] = $state([]);
|
|
176
|
+
// We need a callback to add to api_calls from the DependencyManager
|
|
177
|
+
// We can't update a state variable from inside the DependencyManager because
|
|
178
|
+
// svelte won't see it and won't update the UI.
|
|
179
|
+
let add_to_api_calls = (payload: Payload): void => {
|
|
180
|
+
api_calls = [...api_calls, payload];
|
|
181
|
+
};
|
|
96
182
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
183
|
+
let dep_manager = new DependencyManager(
|
|
184
|
+
dependencies,
|
|
185
|
+
app,
|
|
186
|
+
app_tree.update_state.bind(app_tree),
|
|
187
|
+
app_tree.get_state.bind(app_tree),
|
|
188
|
+
app_tree.rerender.bind(app_tree),
|
|
189
|
+
new_message,
|
|
190
|
+
add_to_api_calls
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
$effect(() => {
|
|
194
|
+
reload_count;
|
|
195
|
+
untrack(() => {
|
|
196
|
+
app_tree.reload(components, layout, dependencies, {
|
|
197
|
+
root,
|
|
198
|
+
theme: theme_mode,
|
|
199
|
+
version,
|
|
200
|
+
api_prefix,
|
|
201
|
+
max_file_size,
|
|
202
|
+
autoscroll
|
|
203
|
+
});
|
|
204
|
+
dep_manager.reload(
|
|
205
|
+
dependencies,
|
|
206
|
+
app_tree.update_state.bind(app_tree),
|
|
207
|
+
app_tree.get_state.bind(app_tree),
|
|
208
|
+
app_tree.rerender.bind(app_tree),
|
|
209
|
+
app
|
|
210
|
+
);
|
|
110
211
|
});
|
|
111
|
-
|
|
112
|
-
}
|
|
212
|
+
});
|
|
113
213
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
let
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
214
|
+
let vibe_editor_width = 350;
|
|
215
|
+
|
|
216
|
+
// export let
|
|
217
|
+
let api_docs_visible = $derived(
|
|
218
|
+
search_params.get("view") === "api" && footer_links.includes("api")
|
|
219
|
+
);
|
|
220
|
+
let settings_visible = $derived(search_params.get("view") === "settings");
|
|
221
|
+
let api_recorder_visible = $derived(
|
|
222
|
+
search_params.get("view") === "api-recorder" && footer_links.includes("api")
|
|
223
|
+
);
|
|
121
224
|
let allow_zoom = true;
|
|
122
225
|
let allow_video_trim = true;
|
|
123
226
|
|
|
124
227
|
// Lazy component loading state
|
|
125
|
-
let ApiDocs: ComponentType<
|
|
126
|
-
let ApiRecorder: ComponentType<
|
|
127
|
-
let Settings: ComponentType<
|
|
228
|
+
let ApiDocs: ComponentType<ApiDocsInterface> | null = null;
|
|
229
|
+
let ApiRecorder: ComponentType<ApiRecorderInterface> | null = null;
|
|
230
|
+
let Settings: ComponentType<SettingsInterface> | null = null;
|
|
128
231
|
let VibeEditor: ComponentType | null = null;
|
|
129
232
|
|
|
130
233
|
async function loadApiDocs(): Promise<void> {
|
|
@@ -186,104 +289,19 @@
|
|
|
186
289
|
settings_visible = !settings_visible;
|
|
187
290
|
}
|
|
188
291
|
|
|
189
|
-
let api_calls: Payload[] = [];
|
|
190
|
-
|
|
191
292
|
let layout_creating = false;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
async function handle_update(data: any, fn_index: number): Promise<void> {
|
|
195
|
-
const dep = dependencies.find((dep) => dep.id === fn_index);
|
|
196
|
-
const input_type = components.find(
|
|
197
|
-
(comp) => comp.id === dep?.inputs[0]
|
|
198
|
-
)?.type;
|
|
199
|
-
if (allow_zoom && dep && input_type !== "dataset") {
|
|
200
|
-
if (dep && dep.inputs && dep.inputs.length > 0 && $is_screen_recording) {
|
|
201
|
-
screen_recorder.zoom(true, dep.inputs, 1.0);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (
|
|
205
|
-
dep &&
|
|
206
|
-
dep.outputs &&
|
|
207
|
-
dep.outputs.length > 0 &&
|
|
208
|
-
$is_screen_recording
|
|
209
|
-
) {
|
|
210
|
-
screen_recorder.zoom(false, dep.outputs, 2.0);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (!dep) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
const outputs = dep.outputs;
|
|
218
|
-
const meta_updates = data?.map((value: any, i: number) => {
|
|
219
|
-
return {
|
|
220
|
-
id: outputs[i],
|
|
221
|
-
prop: "value_is_output",
|
|
222
|
-
value: true
|
|
223
|
-
};
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
update_value(meta_updates);
|
|
227
|
-
|
|
228
|
-
await tick();
|
|
229
|
-
|
|
230
|
-
const updates: UpdateTransaction[] = [];
|
|
231
|
-
|
|
232
|
-
data?.forEach((value: any, i: number) => {
|
|
233
|
-
if (
|
|
234
|
-
typeof value === "object" &&
|
|
235
|
-
value !== null &&
|
|
236
|
-
value.__type__ === "update"
|
|
237
|
-
) {
|
|
238
|
-
for (const [update_key, update_value] of Object.entries(value)) {
|
|
239
|
-
if (update_key === "__type__") {
|
|
240
|
-
continue;
|
|
241
|
-
} else {
|
|
242
|
-
updates.push({
|
|
243
|
-
id: outputs[i],
|
|
244
|
-
prop: update_key,
|
|
245
|
-
value: update_value
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
} else {
|
|
250
|
-
updates.push({
|
|
251
|
-
id: outputs[i],
|
|
252
|
-
prop: "value",
|
|
253
|
-
value
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
update_value(updates);
|
|
258
|
-
|
|
259
|
-
// Handle navbar updates separately since they need to be updated in the store.
|
|
260
|
-
updates.forEach((update) => {
|
|
261
|
-
const component = components.find((comp) => comp.id === update.id);
|
|
262
|
-
if (component && component.type === "navbar") {
|
|
263
|
-
import("./navbar_store").then(({ navbar_config }) => {
|
|
264
|
-
navbar_config.update((current) => ({
|
|
265
|
-
...current,
|
|
266
|
-
[update.prop]: update.value
|
|
267
|
-
}));
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
});
|
|
293
|
+
//
|
|
271
294
|
|
|
272
|
-
await tick();
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
let submit_map: Map<number, ReturnType<typeof app.submit>> = new Map();
|
|
276
|
-
|
|
277
|
-
let messages: (ToastMessage & { fn_index: number })[] = [];
|
|
278
295
|
function new_message(
|
|
279
296
|
title: string,
|
|
280
297
|
message: string,
|
|
281
298
|
fn_index: number,
|
|
282
299
|
type: ToastMessage["type"],
|
|
283
300
|
duration: number | null = 10,
|
|
284
|
-
visible =
|
|
285
|
-
):
|
|
286
|
-
return
|
|
301
|
+
visible = false
|
|
302
|
+
): void {
|
|
303
|
+
if (!visible) return;
|
|
304
|
+
messages.push({
|
|
287
305
|
title,
|
|
288
306
|
message,
|
|
289
307
|
fn_index,
|
|
@@ -291,15 +309,7 @@
|
|
|
291
309
|
id: ++_error_id,
|
|
292
310
|
duration,
|
|
293
311
|
visible
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export function add_new_message(
|
|
298
|
-
title: string,
|
|
299
|
-
message: string,
|
|
300
|
-
type: ToastMessage["type"]
|
|
301
|
-
): void {
|
|
302
|
-
messages = [new_message(title, message, -1, type), ...messages];
|
|
312
|
+
});
|
|
303
313
|
}
|
|
304
314
|
|
|
305
315
|
let _error_id = -1;
|
|
@@ -324,742 +334,9 @@
|
|
|
324
334
|
let inputs_waiting: number[] = [];
|
|
325
335
|
|
|
326
336
|
// as state updates are not synchronous, we need to ensure updates are flushed before triggering any requests
|
|
327
|
-
function wait_then_trigger_api_call(
|
|
328
|
-
dep_index: number,
|
|
329
|
-
trigger_id: number | null = null,
|
|
330
|
-
event_data: unknown = null
|
|
331
|
-
): void {
|
|
332
|
-
let _unsub = (): void => {};
|
|
333
|
-
function unsub(): void {
|
|
334
|
-
_unsub();
|
|
335
|
-
}
|
|
336
|
-
if ($scheduled_updates) {
|
|
337
|
-
_unsub = scheduled_updates.subscribe((updating) => {
|
|
338
|
-
if (!updating) {
|
|
339
|
-
tick().then(() => {
|
|
340
|
-
trigger_api_call(dep_index, trigger_id, event_data);
|
|
341
|
-
unsub();
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
} else {
|
|
346
|
-
trigger_api_call(dep_index, trigger_id, event_data);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
async function get_component_value_or_event_data(
|
|
351
|
-
component_id: number,
|
|
352
|
-
trigger_id: number | null,
|
|
353
|
-
event_data: unknown
|
|
354
|
-
): Promise<any> {
|
|
355
|
-
if (
|
|
356
|
-
component_id === trigger_id &&
|
|
357
|
-
event_data &&
|
|
358
|
-
(event_data as ValueData).is_value_data === true
|
|
359
|
-
) {
|
|
360
|
-
// @ts-ignore
|
|
361
|
-
return event_data.value;
|
|
362
|
-
}
|
|
363
|
-
return get_data(component_id);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
async function trigger_api_call(
|
|
367
|
-
dep_index: number,
|
|
368
|
-
trigger_id: number | null = null,
|
|
369
|
-
event_data: unknown = null
|
|
370
|
-
): Promise<void> {
|
|
371
|
-
const _dep = dependencies.find((dep) => dep.id === dep_index);
|
|
372
|
-
if (_dep === undefined) {
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
const dep = _dep;
|
|
376
|
-
if (inputs_waiting.length > 0) {
|
|
377
|
-
for (const input of inputs_waiting) {
|
|
378
|
-
if (dep.inputs.includes(input)) {
|
|
379
|
-
add_new_message("Warning", WAITING_FOR_INPUTS_MESSAGE, "warning");
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
const current_status = loading_status.get_status_for_fn(dep_index);
|
|
385
|
-
messages = messages.filter(({ fn_index }) => fn_index !== dep_index);
|
|
386
|
-
if (current_status === "pending" || current_status === "generating") {
|
|
387
|
-
dep.pending_request = true;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
let payload: Payload = {
|
|
391
|
-
fn_index: dep_index,
|
|
392
|
-
data: await Promise.all(
|
|
393
|
-
dep.inputs.map((id) =>
|
|
394
|
-
get_component_value_or_event_data(id, trigger_id, event_data)
|
|
395
|
-
)
|
|
396
|
-
),
|
|
397
|
-
event_data: dep.collects_event_data ? event_data : null,
|
|
398
|
-
trigger_id: trigger_id
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
if (dep.frontend_fn && typeof dep.frontend_fn !== "boolean") {
|
|
402
|
-
dep
|
|
403
|
-
.frontend_fn(
|
|
404
|
-
payload.data.concat(
|
|
405
|
-
await Promise.all(dep.outputs.map((id) => get_data(id)))
|
|
406
|
-
)
|
|
407
|
-
)
|
|
408
|
-
.then((v: unknown[]) => {
|
|
409
|
-
if (dep.backend_fn) {
|
|
410
|
-
payload.data = v;
|
|
411
|
-
trigger_prediction(dep, payload);
|
|
412
|
-
} else {
|
|
413
|
-
handle_update(v, dep_index);
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
} else if (dep.types.cancel && dep.cancels) {
|
|
417
|
-
await Promise.all(
|
|
418
|
-
dep.cancels.map(async (fn_index) => {
|
|
419
|
-
const submission = submit_map.get(fn_index);
|
|
420
|
-
submission?.cancel();
|
|
421
|
-
return submission;
|
|
422
|
-
})
|
|
423
|
-
);
|
|
424
|
-
} else {
|
|
425
|
-
if (dep.backend_fn) {
|
|
426
|
-
if (dep.js_implementation) {
|
|
427
|
-
let js_fn = new AsyncFunction(
|
|
428
|
-
`let result = await (${dep.js_implementation})(...arguments);
|
|
429
|
-
return (!Array.isArray(result)) ? [result] : result;`
|
|
430
|
-
);
|
|
431
|
-
js_fn(...payload.data)
|
|
432
|
-
.then((js_result) => {
|
|
433
|
-
handle_update(js_result, dep_index);
|
|
434
|
-
payload.js_implementation = true;
|
|
435
|
-
})
|
|
436
|
-
.catch((error) => {
|
|
437
|
-
console.error(error);
|
|
438
|
-
payload.js_implementation = false;
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
trigger_prediction(dep, payload);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
function trigger_prediction(dep: Dependency, payload: Payload): void {
|
|
446
|
-
if (dep.trigger_mode === "once") {
|
|
447
|
-
if (!dep.pending_request)
|
|
448
|
-
make_prediction(payload, dep.connection == "stream");
|
|
449
|
-
} else if (dep.trigger_mode === "multiple") {
|
|
450
|
-
make_prediction(payload, dep.connection == "stream");
|
|
451
|
-
} else if (dep.trigger_mode === "always_last") {
|
|
452
|
-
if (!dep.pending_request) {
|
|
453
|
-
make_prediction(payload, dep.connection == "stream");
|
|
454
|
-
} else {
|
|
455
|
-
dep.final_event = payload;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
async function reconnect(): Promise<void> {
|
|
461
|
-
const connection_status = await app.reconnect();
|
|
462
|
-
if (connection_status === "broken") {
|
|
463
|
-
setTimeout(reconnect, 1000);
|
|
464
|
-
} else if (connection_status === "changed") {
|
|
465
|
-
broken_connection = false;
|
|
466
|
-
messages = [
|
|
467
|
-
new_message(
|
|
468
|
-
"Changed Connection",
|
|
469
|
-
CHANGED_CONNECTION_MESSAGE,
|
|
470
|
-
-1,
|
|
471
|
-
"info",
|
|
472
|
-
3,
|
|
473
|
-
true
|
|
474
|
-
),
|
|
475
|
-
...messages.map((m) =>
|
|
476
|
-
m.message === LOST_CONNECTION_MESSAGE ? { ...m, visible: false } : m
|
|
477
|
-
)
|
|
478
|
-
];
|
|
479
|
-
} else if (connection_status === "connected") {
|
|
480
|
-
broken_connection = false;
|
|
481
|
-
messages = [
|
|
482
|
-
new_message(
|
|
483
|
-
"Reconnected",
|
|
484
|
-
RECONNECTION_MESSAGE,
|
|
485
|
-
-1,
|
|
486
|
-
"success",
|
|
487
|
-
null,
|
|
488
|
-
true
|
|
489
|
-
),
|
|
490
|
-
...messages.map((m) =>
|
|
491
|
-
m.message === LOST_CONNECTION_MESSAGE ? { ...m, visible: false } : m
|
|
492
|
-
)
|
|
493
|
-
];
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
async function make_prediction(
|
|
498
|
-
payload: Payload,
|
|
499
|
-
streaming = false
|
|
500
|
-
): Promise<void> {
|
|
501
|
-
if (allow_video_trim) {
|
|
502
|
-
screen_recorder.markRemoveSegmentStart();
|
|
503
|
-
}
|
|
504
|
-
if (api_recorder_visible) {
|
|
505
|
-
api_calls = [...api_calls, JSON.parse(JSON.stringify(payload))];
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
let submission: ReturnType<typeof app.submit>;
|
|
509
|
-
app.set_current_payload(payload);
|
|
510
|
-
if (streaming) {
|
|
511
|
-
if (!submit_map.has(dep_index)) {
|
|
512
|
-
dep.inputs.forEach((id) => modify_stream(id, "waiting"));
|
|
513
|
-
} else if (
|
|
514
|
-
submit_map.has(dep_index) &&
|
|
515
|
-
dep.inputs.some((id) => get_stream_state(id) === "waiting")
|
|
516
|
-
) {
|
|
517
|
-
return;
|
|
518
|
-
} else if (
|
|
519
|
-
submit_map.has(dep_index) &&
|
|
520
|
-
dep.inputs.some((id) => get_stream_state(id) === "open")
|
|
521
|
-
) {
|
|
522
|
-
await app.post_data(
|
|
523
|
-
// @ts-ignore
|
|
524
|
-
`${app.config.root + app.config.api_prefix}/stream/${submit_map.get(dep_index).event_id()}`,
|
|
525
|
-
{ ...payload, session_hash: app.session_hash }
|
|
526
|
-
);
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
try {
|
|
531
|
-
submission = app.submit(
|
|
532
|
-
payload.fn_index,
|
|
533
|
-
payload.data as unknown[],
|
|
534
|
-
payload.event_data,
|
|
535
|
-
payload.trigger_id
|
|
536
|
-
);
|
|
537
|
-
} catch (e) {
|
|
538
|
-
const fn_index = 0; // Mock value for fn_index
|
|
539
|
-
if (app.closed) return; // when a user navigates away in multipage app.
|
|
540
|
-
messages = [
|
|
541
|
-
new_message("Error", String(e), fn_index, "error"),
|
|
542
|
-
...messages
|
|
543
|
-
];
|
|
544
|
-
loading_status.update({
|
|
545
|
-
status: "error",
|
|
546
|
-
fn_index,
|
|
547
|
-
eta: 0,
|
|
548
|
-
queue: false,
|
|
549
|
-
queue_position: null
|
|
550
|
-
});
|
|
551
|
-
set_status($loading_status);
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
submit_map.set(dep_index, submission);
|
|
556
|
-
|
|
557
|
-
for await (const message of submission) {
|
|
558
|
-
if (payload.js_implementation) {
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
if (message.type === "data") {
|
|
562
|
-
handle_data(message);
|
|
563
|
-
} else if (message.type === "render") {
|
|
564
|
-
handle_render(message);
|
|
565
|
-
} else if (message.type === "status") {
|
|
566
|
-
handle_status_update(message);
|
|
567
|
-
} else if (message.type === "log") {
|
|
568
|
-
handle_log(message);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
function handle_data(message: Payload): void {
|
|
573
|
-
const { data, fn_index } = message;
|
|
574
|
-
if (dep.pending_request && dep.final_event) {
|
|
575
|
-
dep.pending_request = false;
|
|
576
|
-
make_prediction(dep.final_event, dep.connection == "stream");
|
|
577
|
-
}
|
|
578
|
-
dep.pending_request = false;
|
|
579
|
-
handle_update(data, fn_index);
|
|
580
|
-
set_status($loading_status);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
function handle_render(message: RenderMessage): void {
|
|
584
|
-
const { data } = message;
|
|
585
|
-
let _components: ComponentMeta[] = data.components;
|
|
586
|
-
let render_layout: LayoutNode = data.layout;
|
|
587
|
-
let _dependencies: Dependency[] = data.dependencies;
|
|
588
|
-
let render_id = data.render_id;
|
|
589
|
-
|
|
590
|
-
let deps_to_remove: number[] = [];
|
|
591
|
-
dependencies.forEach((old_dep, i) => {
|
|
592
|
-
if (old_dep.rendered_in === dep.render_id) {
|
|
593
|
-
deps_to_remove.push(i);
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
|
-
deps_to_remove.reverse().forEach((i) => {
|
|
597
|
-
dependencies.splice(i, 1);
|
|
598
|
-
});
|
|
599
|
-
_dependencies.forEach((dep) => {
|
|
600
|
-
dependencies.push(dep);
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
rerender_layout({
|
|
604
|
-
components: _components,
|
|
605
|
-
layout: render_layout,
|
|
606
|
-
root: root + api_prefix,
|
|
607
|
-
dependencies: dependencies,
|
|
608
|
-
render_id: render_id
|
|
609
|
-
});
|
|
610
|
-
_dependencies.forEach((dep) => {
|
|
611
|
-
if (dep.targets.some((dep) => dep[1] === "load")) {
|
|
612
|
-
wait_then_trigger_api_call(dep.id);
|
|
613
|
-
}
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
function handle_log(msg: LogMessage): void {
|
|
618
|
-
const { title, log, fn_index, level, duration, visible } = msg;
|
|
619
|
-
messages = [
|
|
620
|
-
new_message(title, log, fn_index, level, duration, visible),
|
|
621
|
-
...messages
|
|
622
|
-
];
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
function open_stream_events(
|
|
626
|
-
status: StatusMessage,
|
|
627
|
-
id: number,
|
|
628
|
-
dep: Dependency
|
|
629
|
-
): void {
|
|
630
|
-
if (
|
|
631
|
-
status.original_msg === "process_starts" &&
|
|
632
|
-
dep.connection === "stream"
|
|
633
|
-
) {
|
|
634
|
-
modify_stream(id, "open");
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
/* eslint-disable complexity */
|
|
639
|
-
function handle_status_update(message: StatusMessage): void {
|
|
640
|
-
if (message.code === "validation_error") {
|
|
641
|
-
const dep = dependencies.find((dep) => dep.id === message.fn_index);
|
|
642
|
-
if (
|
|
643
|
-
dep === undefined ||
|
|
644
|
-
message.message === undefined ||
|
|
645
|
-
typeof message.message === "string"
|
|
646
|
-
) {
|
|
647
|
-
return;
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
const validation_error_data: {
|
|
651
|
-
id: number;
|
|
652
|
-
prop: string;
|
|
653
|
-
value: unknown;
|
|
654
|
-
}[] = [];
|
|
655
|
-
|
|
656
|
-
message.message.forEach((message, i) => {
|
|
657
|
-
if (message.is_valid) {
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
validation_error_data.push({
|
|
661
|
-
id: dep.inputs[i],
|
|
662
|
-
prop: "validation_error",
|
|
663
|
-
value: message.message
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
validation_error_data.push({
|
|
667
|
-
id: dep.inputs[i],
|
|
668
|
-
prop: "loading_status",
|
|
669
|
-
value: { validation_error: message.message }
|
|
670
|
-
});
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
if (validation_error_data.length > 0) {
|
|
674
|
-
update_value(validation_error_data);
|
|
675
|
-
loading_status.update({
|
|
676
|
-
status: "complete",
|
|
677
|
-
fn_index: message.fn_index,
|
|
678
|
-
eta: 0,
|
|
679
|
-
queue: false,
|
|
680
|
-
queue_position: null
|
|
681
|
-
});
|
|
682
|
-
set_status($loading_status);
|
|
683
|
-
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
if (message.broken && !broken_connection) {
|
|
688
|
-
messages = [
|
|
689
|
-
new_message(
|
|
690
|
-
"Broken Connection",
|
|
691
|
-
LOST_CONNECTION_MESSAGE,
|
|
692
|
-
-1,
|
|
693
|
-
"error",
|
|
694
|
-
null,
|
|
695
|
-
true
|
|
696
|
-
),
|
|
697
|
-
...messages
|
|
698
|
-
];
|
|
699
|
-
|
|
700
|
-
broken_connection = true;
|
|
701
|
-
setTimeout(reconnect, 1000);
|
|
702
|
-
}
|
|
703
|
-
if (message.session_not_found) {
|
|
704
|
-
messages = [
|
|
705
|
-
new_message(
|
|
706
|
-
"Session Not Found",
|
|
707
|
-
SESSION_NOT_FOUND_MESSAGE,
|
|
708
|
-
-1,
|
|
709
|
-
"error",
|
|
710
|
-
null,
|
|
711
|
-
true
|
|
712
|
-
),
|
|
713
|
-
...messages
|
|
714
|
-
];
|
|
715
|
-
}
|
|
716
|
-
const { fn_index, ...status } = message;
|
|
717
|
-
if (status.stage === "streaming" && status.time_limit) {
|
|
718
|
-
dep.inputs.forEach((id) => {
|
|
719
|
-
set_time_limit(id, status.time_limit);
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
dep.inputs.forEach((id) => {
|
|
723
|
-
open_stream_events(message, id, dep);
|
|
724
|
-
});
|
|
725
|
-
//@ts-ignore
|
|
726
|
-
loading_status.update({
|
|
727
|
-
...status,
|
|
728
|
-
time_limit: status.time_limit,
|
|
729
|
-
status: status.stage,
|
|
730
|
-
progress: status.progress_data,
|
|
731
|
-
fn_index
|
|
732
|
-
});
|
|
733
|
-
set_status($loading_status);
|
|
734
|
-
if (
|
|
735
|
-
!showed_duplicate_message &&
|
|
736
|
-
space_id !== null &&
|
|
737
|
-
status.position !== undefined &&
|
|
738
|
-
status.position >= 2 &&
|
|
739
|
-
status.eta !== undefined &&
|
|
740
|
-
status.eta > SHOW_DUPLICATE_MESSAGE_ON_ETA
|
|
741
|
-
) {
|
|
742
|
-
showed_duplicate_message = true;
|
|
743
|
-
messages = [
|
|
744
|
-
new_message("Warning", DUPLICATE_MESSAGE, fn_index, "warning"),
|
|
745
|
-
...messages
|
|
746
|
-
];
|
|
747
|
-
}
|
|
748
|
-
if (
|
|
749
|
-
!showed_mobile_warning &&
|
|
750
|
-
is_mobile_device &&
|
|
751
|
-
status.eta !== undefined &&
|
|
752
|
-
status.eta > SHOW_MOBILE_QUEUE_WARNING_ON_ETA
|
|
753
|
-
) {
|
|
754
|
-
showed_mobile_warning = true;
|
|
755
|
-
messages = [
|
|
756
|
-
new_message("Warning", MOBILE_QUEUE_WARNING, fn_index, "warning"),
|
|
757
|
-
...messages
|
|
758
|
-
];
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
if (status.stage === "complete" || status.stage === "generating") {
|
|
762
|
-
const deps_triggered_by_state: Set<Dependency> = new Set();
|
|
763
|
-
status.changed_state_ids?.forEach((id) => {
|
|
764
|
-
dependencies
|
|
765
|
-
.filter((dep) => dep.targets.some(([_id, _]) => _id === id))
|
|
766
|
-
.forEach((dep) => {
|
|
767
|
-
deps_triggered_by_state.add(dep);
|
|
768
|
-
});
|
|
769
|
-
});
|
|
770
|
-
deps_triggered_by_state.forEach((dep) => {
|
|
771
|
-
wait_then_trigger_api_call(dep.id, payload.trigger_id);
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
if (status.stage === "complete") {
|
|
775
|
-
dependencies.forEach(async (dep) => {
|
|
776
|
-
if (
|
|
777
|
-
dep.trigger_after === fn_index &&
|
|
778
|
-
!dep.trigger_only_on_failure
|
|
779
|
-
) {
|
|
780
|
-
wait_then_trigger_api_call(dep.id, payload.trigger_id);
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
dep.inputs.forEach((id) => {
|
|
784
|
-
modify_stream(id, "closed");
|
|
785
|
-
});
|
|
786
|
-
submit_map.delete(dep_index);
|
|
787
|
-
}
|
|
788
|
-
if (
|
|
789
|
-
status.stage === "error" &&
|
|
790
|
-
!broken_connection &&
|
|
791
|
-
!message.session_not_found
|
|
792
|
-
) {
|
|
793
|
-
if (status.message && typeof status.message === "string") {
|
|
794
|
-
const _message = status.message.replace(
|
|
795
|
-
MESSAGE_QUOTE_RE,
|
|
796
|
-
(_, b) => b
|
|
797
|
-
);
|
|
798
|
-
const _title = status.title ?? "Error";
|
|
799
|
-
messages = [
|
|
800
|
-
new_message(
|
|
801
|
-
_title,
|
|
802
|
-
_message,
|
|
803
|
-
fn_index,
|
|
804
|
-
"error",
|
|
805
|
-
status.duration,
|
|
806
|
-
status.visible
|
|
807
|
-
),
|
|
808
|
-
...messages
|
|
809
|
-
];
|
|
810
|
-
}
|
|
811
|
-
dependencies.map(async (dep) => {
|
|
812
|
-
if (
|
|
813
|
-
dep.trigger_after === fn_index &&
|
|
814
|
-
(!dep.trigger_only_on_success || dep.trigger_only_on_failure)
|
|
815
|
-
) {
|
|
816
|
-
wait_then_trigger_api_call(dep.id, payload.trigger_id);
|
|
817
|
-
}
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
if (allow_video_trim) {
|
|
822
|
-
screen_recorder.markRemoveSegmentEnd();
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
/* eslint-enable complexity */
|
|
827
|
-
|
|
828
|
-
function trigger_share(title: string | undefined, description: string): void {
|
|
829
|
-
if (space_id === null) {
|
|
830
|
-
return;
|
|
831
|
-
}
|
|
832
|
-
const discussion_url = new URL(
|
|
833
|
-
`https://huggingface.co/spaces/${space_id}/discussions/new`
|
|
834
|
-
);
|
|
835
|
-
if (title !== undefined && title.length > 0) {
|
|
836
|
-
discussion_url.searchParams.set("title", title);
|
|
837
|
-
}
|
|
838
|
-
discussion_url.searchParams.set("description", description);
|
|
839
|
-
window.open(discussion_url.toString(), "_blank");
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
function handle_error_close(e: Event & { detail: number }): void {
|
|
843
|
-
const _id = e.detail;
|
|
844
|
-
messages = messages.filter((m) => m.id !== _id);
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
const is_external_url = (link: string | null): boolean =>
|
|
848
|
-
!!(link && new URL(link, location.href).origin !== location.origin);
|
|
849
|
-
|
|
850
|
-
async function handle_mount(): Promise<void> {
|
|
851
|
-
if (js) {
|
|
852
|
-
let blocks_frontend_fn = new AsyncFunction(
|
|
853
|
-
`let result = await (${js})();
|
|
854
|
-
return (!Array.isArray(result)) ? [result] : result;`
|
|
855
|
-
);
|
|
856
|
-
await blocks_frontend_fn();
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
await tick();
|
|
860
|
-
|
|
861
|
-
var a = target.getElementsByTagName("a");
|
|
862
|
-
|
|
863
|
-
for (var i = 0; i < a.length; i++) {
|
|
864
|
-
const _target = a[i].getAttribute("target");
|
|
865
|
-
const _link = a[i].getAttribute("href");
|
|
866
|
-
|
|
867
|
-
// only target anchor tags with external links
|
|
868
|
-
if (is_external_url(_link) && _target !== "_blank")
|
|
869
|
-
a[i].setAttribute("target", "_blank");
|
|
870
|
-
}
|
|
871
|
-
handle_load_triggers();
|
|
872
|
-
|
|
873
|
-
if (!target || render_complete) return;
|
|
874
|
-
|
|
875
|
-
target.addEventListener("prop_change", (e: Event) => {
|
|
876
|
-
if (!isCustomEvent(e)) throw new Error("not a custom event");
|
|
877
|
-
const { id, prop, value } = e.detail;
|
|
878
|
-
if (prop === "value") {
|
|
879
|
-
update_value([
|
|
880
|
-
{
|
|
881
|
-
id,
|
|
882
|
-
prop: "loading_status",
|
|
883
|
-
value: { validation_error: undefined }
|
|
884
|
-
}
|
|
885
|
-
]);
|
|
886
|
-
}
|
|
887
|
-
update_value([{ id, prop, value }]);
|
|
888
|
-
if (prop === "input_ready" && value === false) {
|
|
889
|
-
inputs_waiting.push(id);
|
|
890
|
-
}
|
|
891
|
-
if (prop === "input_ready" && value === true) {
|
|
892
|
-
inputs_waiting = inputs_waiting.filter((item) => item !== id);
|
|
893
|
-
}
|
|
894
|
-
});
|
|
895
|
-
target.addEventListener("gradio", (e: Event) => {
|
|
896
|
-
if (!isCustomEvent(e)) throw new Error("not a custom event");
|
|
897
|
-
|
|
898
|
-
const { id, event, data } = e.detail;
|
|
899
|
-
|
|
900
|
-
if (event === "share") {
|
|
901
|
-
const { title, description } = data as ShareData;
|
|
902
|
-
trigger_share(title, description);
|
|
903
|
-
} else if (event === "error") {
|
|
904
|
-
messages = [new_message("Error", data, -1, event), ...messages];
|
|
905
|
-
} else if (event === "warning") {
|
|
906
|
-
messages = [new_message("Warning", data, -1, event), ...messages];
|
|
907
|
-
} else if (event === "info") {
|
|
908
|
-
messages = [new_message("Info", data, -1, event), ...messages];
|
|
909
|
-
} else if (event == "clear_status") {
|
|
910
|
-
update_status(id, "complete", data);
|
|
911
|
-
} else if (event == "close_stream") {
|
|
912
|
-
const deps = $targets[id]?.[data];
|
|
913
|
-
deps?.forEach((dep_id) => {
|
|
914
|
-
if (submit_map.has(dep_id)) {
|
|
915
|
-
// @ts-ignore
|
|
916
|
-
const url = `${app.config.root + app.config.api_prefix}/stream/${submit_map.get(dep_id).event_id()}`;
|
|
917
|
-
app.post_data(`${url}/close`, {});
|
|
918
|
-
}
|
|
919
|
-
});
|
|
920
|
-
} else {
|
|
921
|
-
const deps = $targets[id]?.[event];
|
|
922
|
-
|
|
923
|
-
deps?.forEach((dep_id) => {
|
|
924
|
-
requestAnimationFrame(() => {
|
|
925
|
-
wait_then_trigger_api_call(dep_id, id, data);
|
|
926
|
-
});
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
});
|
|
930
|
-
|
|
931
|
-
render_complete = true;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
value_change((id, value) => {
|
|
935
|
-
const deps = $targets[id]?.["change"];
|
|
936
|
-
|
|
937
|
-
deps?.forEach((dep_id) => {
|
|
938
|
-
requestAnimationFrame(() => {
|
|
939
|
-
wait_then_trigger_api_call(dep_id, id, value);
|
|
940
|
-
});
|
|
941
|
-
});
|
|
942
|
-
});
|
|
943
|
-
|
|
944
|
-
const handle_load_triggers = (): void => {
|
|
945
|
-
dependencies.forEach((dep) => {
|
|
946
|
-
if (dep.targets.some((dep) => dep[1] === "load")) {
|
|
947
|
-
wait_then_trigger_api_call(dep.id);
|
|
948
|
-
}
|
|
949
|
-
});
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
$: set_status($loading_status);
|
|
953
|
-
|
|
954
|
-
function update_status(
|
|
955
|
-
id: number,
|
|
956
|
-
status: "error" | "complete" | "pending",
|
|
957
|
-
data: LoadingStatus
|
|
958
|
-
): void {
|
|
959
|
-
data.status = status;
|
|
960
|
-
update_value([
|
|
961
|
-
{
|
|
962
|
-
id,
|
|
963
|
-
prop: "loading_status",
|
|
964
|
-
value: data
|
|
965
|
-
}
|
|
966
|
-
]);
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
function set_status(statuses: LoadingStatusCollection): void {
|
|
970
|
-
let updates: {
|
|
971
|
-
id: number;
|
|
972
|
-
prop: string;
|
|
973
|
-
value: LoadingStatus;
|
|
974
|
-
}[] = [];
|
|
975
|
-
Object.entries(statuses).forEach(([id, loading_status]) => {
|
|
976
|
-
if (app.closed && loading_status.status === "error") {
|
|
977
|
-
// when a user navigates away in multipage app.
|
|
978
|
-
return;
|
|
979
|
-
}
|
|
980
|
-
let dependency = dependencies.find(
|
|
981
|
-
(dep) => dep.id == loading_status.fn_index
|
|
982
|
-
);
|
|
983
|
-
if (dependency === undefined) {
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
loading_status.scroll_to_output = dependency.scroll_to_output;
|
|
987
|
-
loading_status.show_progress = dependency.show_progress;
|
|
988
|
-
updates.push({
|
|
989
|
-
id: parseInt(id),
|
|
990
|
-
prop: "loading_status",
|
|
991
|
-
value: loading_status
|
|
992
|
-
});
|
|
993
|
-
});
|
|
994
|
-
|
|
995
|
-
const inputs_to_update = loading_status.get_inputs_to_update();
|
|
996
|
-
const additional_updates = Array.from(inputs_to_update).map(
|
|
997
|
-
([id, pending_status]) => {
|
|
998
|
-
return {
|
|
999
|
-
id,
|
|
1000
|
-
prop: "pending",
|
|
1001
|
-
value: pending_status === "pending"
|
|
1002
|
-
};
|
|
1003
|
-
}
|
|
1004
|
-
);
|
|
1005
|
-
|
|
1006
|
-
update_value([...updates, ...additional_updates]);
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
function isCustomEvent(event: Event): event is CustomEvent {
|
|
1010
|
-
return "detail" in event;
|
|
1011
|
-
}
|
|
1012
337
|
|
|
1013
338
|
let is_screen_recording = writable(false);
|
|
1014
339
|
|
|
1015
|
-
onMount(() => {
|
|
1016
|
-
is_mobile_device =
|
|
1017
|
-
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
1018
|
-
navigator.userAgent
|
|
1019
|
-
);
|
|
1020
|
-
|
|
1021
|
-
screen_recorder.initialize(
|
|
1022
|
-
root,
|
|
1023
|
-
(title, message, type) => {
|
|
1024
|
-
add_new_message(title, message, type);
|
|
1025
|
-
},
|
|
1026
|
-
(isRecording) => {
|
|
1027
|
-
$is_screen_recording = isRecording;
|
|
1028
|
-
}
|
|
1029
|
-
);
|
|
1030
|
-
|
|
1031
|
-
const handleVibeEditorResize = (event: CustomEvent): void => {
|
|
1032
|
-
vibe_editor_width = event.detail.width;
|
|
1033
|
-
};
|
|
1034
|
-
|
|
1035
|
-
window.addEventListener(
|
|
1036
|
-
"vibeEditorResize",
|
|
1037
|
-
handleVibeEditorResize as EventListener
|
|
1038
|
-
);
|
|
1039
|
-
|
|
1040
|
-
// Load components if they should be visible on initial page load
|
|
1041
|
-
if (api_docs_visible) {
|
|
1042
|
-
loadApiDocs();
|
|
1043
|
-
}
|
|
1044
|
-
if (api_recorder_visible) {
|
|
1045
|
-
loadApiRecorder();
|
|
1046
|
-
}
|
|
1047
|
-
if (settings_visible) {
|
|
1048
|
-
loadSettings();
|
|
1049
|
-
}
|
|
1050
|
-
if (vibe_mode) {
|
|
1051
|
-
loadVibeEditor();
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
|
|
1055
|
-
function screen_recording(): void {
|
|
1056
|
-
if ($is_screen_recording) {
|
|
1057
|
-
screen_recorder.stopRecording();
|
|
1058
|
-
} else {
|
|
1059
|
-
screen_recorder.startRecording();
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
340
|
let footer_height = 0;
|
|
1064
341
|
|
|
1065
342
|
let root_container: HTMLElement;
|
|
@@ -1077,7 +354,20 @@
|
|
|
1077
354
|
}
|
|
1078
355
|
}
|
|
1079
356
|
|
|
357
|
+
function screen_recording(): void {
|
|
358
|
+
if ($is_screen_recording) {
|
|
359
|
+
screen_recorder.stopRecording();
|
|
360
|
+
} else {
|
|
361
|
+
screen_recorder.startRecording();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
1080
365
|
onMount(() => {
|
|
366
|
+
is_mobile_device =
|
|
367
|
+
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
368
|
+
navigator.userAgent
|
|
369
|
+
);
|
|
370
|
+
|
|
1081
371
|
if ("parentIFrame" in window) {
|
|
1082
372
|
window.parentIFrame?.autoResize(false);
|
|
1083
373
|
}
|
|
@@ -1090,14 +380,22 @@
|
|
|
1090
380
|
subtree: true,
|
|
1091
381
|
attributes: true
|
|
1092
382
|
});
|
|
1093
|
-
|
|
1094
383
|
res.observe(root_container);
|
|
1095
384
|
|
|
385
|
+
app_tree.ready.then(() => {
|
|
386
|
+
ready = true;
|
|
387
|
+
dep_manager.dispatch_load_events();
|
|
388
|
+
});
|
|
389
|
+
|
|
1096
390
|
return () => {
|
|
1097
391
|
mut.disconnect();
|
|
1098
392
|
res.disconnect();
|
|
1099
393
|
};
|
|
1100
394
|
});
|
|
395
|
+
|
|
396
|
+
function handle_close(id: number): void {
|
|
397
|
+
messages = messages.filter((m) => m.id !== id);
|
|
398
|
+
}
|
|
1101
399
|
</script>
|
|
1102
400
|
|
|
1103
401
|
<svelte:head>
|
|
@@ -1116,167 +414,150 @@
|
|
|
1116
414
|
bind:this={root_container}
|
|
1117
415
|
style:margin-right={vibe_mode ? `${vibe_editor_width}px` : "0"}
|
|
1118
416
|
>
|
|
1119
|
-
{
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
{
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
417
|
+
<MountComponents node={app_tree.root} />
|
|
418
|
+
|
|
419
|
+
{#if footer_links.length > 0}
|
|
420
|
+
<footer bind:clientHeight={footer_height}>
|
|
421
|
+
{#if footer_links.includes("api")}
|
|
422
|
+
<button
|
|
423
|
+
on:click={() => {
|
|
424
|
+
set_api_docs_visible(!api_docs_visible);
|
|
425
|
+
}}
|
|
426
|
+
on:mouseenter={() => {
|
|
427
|
+
loadApiDocs();
|
|
428
|
+
loadApiRecorder();
|
|
429
|
+
}}
|
|
430
|
+
class="show-api"
|
|
431
|
+
>
|
|
432
|
+
{#if app.config?.mcp_server}
|
|
433
|
+
{$_("errors.use_via_api_or_mcp")}
|
|
434
|
+
{:else}
|
|
435
|
+
{$_("errors.use_via_api")}
|
|
436
|
+
{/if}
|
|
437
|
+
<img src={api_logo} alt={$_("common.logo")} />
|
|
438
|
+
</button>
|
|
439
|
+
{/if}
|
|
440
|
+
{#if footer_links.includes("gradio")}
|
|
441
|
+
<div class="divider show-api-divider">·</div>
|
|
442
|
+
<a
|
|
443
|
+
href="https://gradio.app"
|
|
444
|
+
class="built-with"
|
|
445
|
+
target="_blank"
|
|
446
|
+
rel="noreferrer"
|
|
447
|
+
>
|
|
448
|
+
{$_("common.built_with_gradio")}
|
|
449
|
+
<img src={logo} alt={$_("common.logo")} />
|
|
450
|
+
</a>
|
|
451
|
+
{/if}
|
|
1137
452
|
<button
|
|
453
|
+
class:hidden={!$is_screen_recording}
|
|
1138
454
|
on:click={() => {
|
|
1139
|
-
|
|
455
|
+
screen_recording();
|
|
1140
456
|
}}
|
|
1141
|
-
|
|
1142
|
-
loadApiDocs();
|
|
1143
|
-
loadApiRecorder();
|
|
1144
|
-
}}
|
|
1145
|
-
class="show-api"
|
|
457
|
+
class="record"
|
|
1146
458
|
>
|
|
1147
|
-
{
|
|
1148
|
-
|
|
1149
|
-
{:else}
|
|
1150
|
-
{$_("errors.use_via_api")}
|
|
1151
|
-
{/if}
|
|
1152
|
-
<img src={api_logo} alt={$_("common.logo")} />
|
|
459
|
+
{$_("common.stop_recording")}
|
|
460
|
+
<img src={record_stop} alt={$_("common.stop_recording")} />
|
|
1153
461
|
</button>
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
class="record"
|
|
1173
|
-
>
|
|
1174
|
-
{$_("common.stop_recording")}
|
|
1175
|
-
<img src={record_stop} alt={$_("common.stop_recording")} />
|
|
1176
|
-
</button>
|
|
1177
|
-
<div class="divider">·</div>
|
|
1178
|
-
{#if footer_links.includes("settings")}
|
|
1179
|
-
<div class="divider" class:hidden={!$is_screen_recording}>·</div>
|
|
1180
|
-
<button
|
|
1181
|
-
on:click={() => {
|
|
1182
|
-
set_settings_visible(!settings_visible);
|
|
1183
|
-
}}
|
|
1184
|
-
on:mouseenter={() => {
|
|
1185
|
-
loadSettings();
|
|
1186
|
-
}}
|
|
1187
|
-
class="settings"
|
|
1188
|
-
>
|
|
1189
|
-
{$_("common.settings")}
|
|
1190
|
-
<img src={settings_logo} alt={$_("common.settings")} />
|
|
1191
|
-
</button>
|
|
1192
|
-
{/if}
|
|
1193
|
-
</footer>
|
|
1194
|
-
{/if}
|
|
1195
|
-
</div>
|
|
1196
|
-
|
|
1197
|
-
{#if api_recorder_visible && ApiRecorder}
|
|
1198
|
-
<!-- TODO: fix -->
|
|
1199
|
-
<!-- svelte-ignore a11y-click-events-have-key-events-->
|
|
1200
|
-
<!-- svelte-ignore a11y-no-static-element-interactions-->
|
|
1201
|
-
<div
|
|
1202
|
-
id="api-recorder-container"
|
|
1203
|
-
on:click={() => {
|
|
1204
|
-
set_api_docs_visible(true);
|
|
1205
|
-
api_recorder_visible = false;
|
|
1206
|
-
}}
|
|
1207
|
-
>
|
|
1208
|
-
<svelte:component this={ApiRecorder} {api_calls} {dependencies} />
|
|
462
|
+
<div class="divider">·</div>
|
|
463
|
+
{#if footer_links.includes("settings")}
|
|
464
|
+
<div class="divider" class:hidden={!$is_screen_recording}>·</div>
|
|
465
|
+
<button
|
|
466
|
+
on:click={() => {
|
|
467
|
+
set_settings_visible(!settings_visible);
|
|
468
|
+
}}
|
|
469
|
+
on:mouseenter={() => {
|
|
470
|
+
loadSettings();
|
|
471
|
+
}}
|
|
472
|
+
class="settings"
|
|
473
|
+
>
|
|
474
|
+
{$_("common.settings")}
|
|
475
|
+
<img src={settings_logo} alt={$_("common.settings")} />
|
|
476
|
+
</button>
|
|
477
|
+
{/if}
|
|
478
|
+
</footer>
|
|
479
|
+
{/if}
|
|
1209
480
|
</div>
|
|
1210
|
-
{
|
|
1211
|
-
|
|
1212
|
-
{#if api_docs_visible && $_layout && ApiDocs}
|
|
1213
|
-
<div class="api-docs">
|
|
481
|
+
{#if api_recorder_visible && ApiRecorder}
|
|
1214
482
|
<!-- TODO: fix -->
|
|
1215
483
|
<!-- svelte-ignore a11y-click-events-have-key-events-->
|
|
1216
484
|
<!-- svelte-ignore a11y-no-static-element-interactions-->
|
|
1217
485
|
<div
|
|
1218
|
-
|
|
486
|
+
id="api-recorder-container"
|
|
1219
487
|
on:click={() => {
|
|
1220
|
-
set_api_docs_visible(
|
|
488
|
+
set_api_docs_visible(true);
|
|
489
|
+
api_recorder_visible = false;
|
|
1221
490
|
}}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
491
|
+
>
|
|
492
|
+
<svelte:component this={ApiRecorder} {api_calls} {dependencies} />
|
|
493
|
+
</div>
|
|
494
|
+
{/if}
|
|
495
|
+
|
|
496
|
+
{#if api_docs_visible && app_tree.root && ApiDocs}
|
|
497
|
+
<div class="api-docs">
|
|
498
|
+
<!-- TODO: fix -->
|
|
499
|
+
<!-- svelte-ignore a11y-click-events-have-key-events-->
|
|
500
|
+
<!-- svelte-ignore a11y-no-static-element-interactions-->
|
|
501
|
+
<div
|
|
502
|
+
class="backdrop"
|
|
503
|
+
on:click={() => {
|
|
1228
504
|
set_api_docs_visible(false);
|
|
1229
|
-
api_calls = [];
|
|
1230
|
-
api_recorder_visible = api_recorder_visible =
|
|
1231
|
-
event.detail?.api_recorder_visible;
|
|
1232
505
|
}}
|
|
1233
|
-
{dependencies}
|
|
1234
|
-
{root}
|
|
1235
|
-
{app}
|
|
1236
|
-
{space_id}
|
|
1237
|
-
{api_calls}
|
|
1238
|
-
{username}
|
|
1239
506
|
/>
|
|
507
|
+
<div class="api-docs-wrap">
|
|
508
|
+
<svelte:component
|
|
509
|
+
this={ApiDocs}
|
|
510
|
+
root_node={app_tree.root}
|
|
511
|
+
on:close={(event) => {
|
|
512
|
+
set_api_docs_visible(false);
|
|
513
|
+
api_calls = [];
|
|
514
|
+
api_recorder_visible = api_recorder_visible =
|
|
515
|
+
event.detail?.api_recorder_visible;
|
|
516
|
+
}}
|
|
517
|
+
{dependencies}
|
|
518
|
+
{root}
|
|
519
|
+
{app}
|
|
520
|
+
{space_id}
|
|
521
|
+
{api_calls}
|
|
522
|
+
{username}
|
|
523
|
+
/>
|
|
524
|
+
</div>
|
|
1240
525
|
</div>
|
|
1241
|
-
|
|
1242
|
-
{/if}
|
|
526
|
+
{/if}
|
|
1243
527
|
|
|
1244
|
-
{#if settings_visible &&
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
set_settings_visible(false);
|
|
1253
|
-
}}
|
|
1254
|
-
/>
|
|
1255
|
-
<div class="api-docs-wrap">
|
|
1256
|
-
<svelte:component
|
|
1257
|
-
this={Settings}
|
|
1258
|
-
bind:allow_zoom
|
|
1259
|
-
bind:allow_video_trim
|
|
1260
|
-
on:close={() => {
|
|
528
|
+
{#if settings_visible && app.config && app_tree.root && Settings}
|
|
529
|
+
<div class="api-docs">
|
|
530
|
+
<!-- TODO: fix -->
|
|
531
|
+
<!-- svelte-ignore a11y-click-events-have-key-events-->
|
|
532
|
+
<!-- svelte-ignore a11y-no-static-element-interactions-->
|
|
533
|
+
<div
|
|
534
|
+
class="backdrop"
|
|
535
|
+
on:click={() => {
|
|
1261
536
|
set_settings_visible(false);
|
|
1262
537
|
}}
|
|
1263
|
-
on:start_recording={() => {
|
|
1264
|
-
screen_recording();
|
|
1265
|
-
}}
|
|
1266
|
-
pwa_enabled={app.config.pwa}
|
|
1267
|
-
{root}
|
|
1268
|
-
{space_id}
|
|
1269
538
|
/>
|
|
539
|
+
<div class="api-docs-wrap">
|
|
540
|
+
<svelte:component
|
|
541
|
+
this={Settings}
|
|
542
|
+
bind:allow_zoom
|
|
543
|
+
bind:allow_video_trim
|
|
544
|
+
on:close={() => {
|
|
545
|
+
set_settings_visible(false);
|
|
546
|
+
}}
|
|
547
|
+
on:start_recording={() => {
|
|
548
|
+
screen_recording();
|
|
549
|
+
}}
|
|
550
|
+
pwa_enabled={app.config.pwa}
|
|
551
|
+
{root}
|
|
552
|
+
{space_id}
|
|
553
|
+
/>
|
|
554
|
+
</div>
|
|
1270
555
|
</div>
|
|
1271
|
-
|
|
1272
|
-
|
|
556
|
+
{/if}
|
|
557
|
+
</div>
|
|
1273
558
|
|
|
1274
559
|
{#if messages}
|
|
1275
|
-
<Toast {messages}
|
|
1276
|
-
{/if}
|
|
1277
|
-
|
|
1278
|
-
{#if vibe_mode && VibeEditor}
|
|
1279
|
-
<svelte:component this={VibeEditor} {app} {root} />
|
|
560
|
+
<Toast {messages} on_close={handle_close} />
|
|
1280
561
|
{/if}
|
|
1281
562
|
|
|
1282
563
|
<style>
|