@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
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { writable
|
|
1
|
+
import { writable } from "svelte/store";
|
|
2
2
|
import { dequal } from "dequal";
|
|
3
3
|
import { load_component } from "virtual:component-loader";
|
|
4
4
|
import { create_loading_status_store } from "./stores";
|
|
5
5
|
import { _ } from "svelte-i18n";
|
|
6
6
|
import { i18n_marker } from "./i18n";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const shared_props = [
|
|
8
|
+
"elem_id",
|
|
9
|
+
"elem_classes",
|
|
10
|
+
"components",
|
|
11
|
+
"visible",
|
|
12
|
+
"interactive",
|
|
13
|
+
"server_fns"
|
|
14
|
+
];
|
|
12
15
|
/**
|
|
13
16
|
* Create a store with the layout and a map of targets
|
|
14
17
|
* @returns A store with the layout and a map of targets
|
|
@@ -29,13 +32,15 @@ export function create_components({ initial_layout = undefined } = {
|
|
|
29
32
|
let app;
|
|
30
33
|
let keys_per_render_id = {};
|
|
31
34
|
let _rootNode;
|
|
32
|
-
let value_change_cb = null;
|
|
33
|
-
function value_change(cb) {
|
|
34
|
-
value_change_cb = cb;
|
|
35
|
-
}
|
|
36
35
|
let current_layout;
|
|
37
36
|
let current_root;
|
|
38
|
-
|
|
37
|
+
const get_callbacks = new Map();
|
|
38
|
+
const set_callbacks = new Map();
|
|
39
|
+
function register_component(id, _set_data, _get_data) {
|
|
40
|
+
set_callbacks.set(id, _set_data);
|
|
41
|
+
get_callbacks.set(id, _get_data);
|
|
42
|
+
}
|
|
43
|
+
function get_event_specific_args(dependencies) {
|
|
39
44
|
dependencies.forEach((dep) => {
|
|
40
45
|
dep.targets.forEach((target) => {
|
|
41
46
|
const instance = instance_map?.[target[0]];
|
|
@@ -48,7 +53,6 @@ export function create_components({ initial_layout = undefined } = {
|
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
async function create_layout({ app: _app, components, layout, dependencies, root, options }) {
|
|
51
|
-
flush();
|
|
52
56
|
app = _app;
|
|
53
57
|
if (instance_map) {
|
|
54
58
|
components.forEach((c) => {
|
|
@@ -58,12 +62,13 @@ export function create_components({ initial_layout = undefined } = {
|
|
|
58
62
|
c.props.value = matching_instance.props.value;
|
|
59
63
|
}
|
|
60
64
|
}
|
|
65
|
+
const { shared_props, props } = gather_props(c.props);
|
|
66
|
+
c.props = { props, shared_props };
|
|
61
67
|
});
|
|
62
68
|
}
|
|
63
69
|
_components = components;
|
|
64
70
|
inputs = new Set();
|
|
65
71
|
outputs = new Set();
|
|
66
|
-
pending_updates = [];
|
|
67
72
|
constructor_map = new Map();
|
|
68
73
|
_component_map = new Map();
|
|
69
74
|
instance_map = {};
|
|
@@ -104,13 +109,13 @@ export function create_components({ initial_layout = undefined } = {
|
|
|
104
109
|
* Rerender the layout when the config has been modified to attach new components
|
|
105
110
|
*/
|
|
106
111
|
function rerender_layout({ render_id, components, layout, root, dependencies }) {
|
|
107
|
-
components.forEach((c) => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
});
|
|
112
|
+
// components.forEach((c) => {
|
|
113
|
+
// for (const prop in c.props) {
|
|
114
|
+
// if (c.props[prop] === null) {
|
|
115
|
+
// c.props[prop] = undefined;
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
// });
|
|
114
119
|
let replacement_components = [];
|
|
115
120
|
let new_components = [];
|
|
116
121
|
components.forEach((c) => {
|
|
@@ -238,8 +243,6 @@ export function create_components({ initial_layout = undefined } = {
|
|
|
238
243
|
}
|
|
239
244
|
return instance;
|
|
240
245
|
}
|
|
241
|
-
let update_scheduled = false;
|
|
242
|
-
let update_scheduled_store = writable(false);
|
|
243
246
|
/**
|
|
244
247
|
* Load newly visible components after visibility changes
|
|
245
248
|
* @param newly_visible_ids Set of component IDs that are now visible
|
|
@@ -286,90 +289,11 @@ export function create_components({ initial_layout = undefined } = {
|
|
|
286
289
|
return false;
|
|
287
290
|
}));
|
|
288
291
|
}
|
|
289
|
-
function
|
|
290
|
-
|
|
291
|
-
let previous_visible_ids;
|
|
292
|
-
const all_components = _component_map
|
|
293
|
-
? [..._component_map.values()]
|
|
294
|
-
: _components;
|
|
295
|
-
if (had_visibility_changes && current_layout) {
|
|
296
|
-
previous_visible_ids = determine_visible_components(current_layout, all_components);
|
|
297
|
-
}
|
|
298
|
-
layout_store.update((layout) => {
|
|
299
|
-
for (let i = 0; i < pending_updates.length; i++) {
|
|
300
|
-
for (let j = 0; j < pending_updates[i].length; j++) {
|
|
301
|
-
const update = pending_updates[i][j];
|
|
302
|
-
if (!update)
|
|
303
|
-
continue;
|
|
304
|
-
const instance = instance_map?.[update.id];
|
|
305
|
-
if (!instance)
|
|
306
|
-
continue;
|
|
307
|
-
let new_value;
|
|
308
|
-
const old_value = instance.props[update.prop];
|
|
309
|
-
if (update.value instanceof Map)
|
|
310
|
-
new_value = new Map(update.value);
|
|
311
|
-
else if (update.value instanceof Set)
|
|
312
|
-
new_value = new Set(update.value);
|
|
313
|
-
else if (Array.isArray(update.value))
|
|
314
|
-
new_value = [...update.value];
|
|
315
|
-
else if (update.value == null)
|
|
316
|
-
new_value = null;
|
|
317
|
-
else if (typeof update.value === "object")
|
|
318
|
-
new_value = { ...update.value };
|
|
319
|
-
else
|
|
320
|
-
new_value = update.value;
|
|
321
|
-
instance.props[update.prop] = new_value;
|
|
322
|
-
if (update.prop === "value" &&
|
|
323
|
-
!is_visible(instance) &&
|
|
324
|
-
!dequal(old_value, new_value)) {
|
|
325
|
-
value_change_cb?.(update.id, new_value);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
return layout;
|
|
330
|
-
});
|
|
331
|
-
if (had_visibility_changes && current_layout && previous_visible_ids) {
|
|
332
|
-
raf(async () => {
|
|
333
|
-
const new_visible_ids = determine_visible_components(current_layout, all_components);
|
|
334
|
-
const newly_visible_ids = new Set();
|
|
335
|
-
for (const id of new_visible_ids) {
|
|
336
|
-
if (!previous_visible_ids.has(id)) {
|
|
337
|
-
newly_visible_ids.add(id);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
await load_newly_visible_components(newly_visible_ids, all_components);
|
|
341
|
-
if (newly_visible_ids.size > 0) {
|
|
342
|
-
layout_store.update((layout) => layout);
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
pending_updates = [];
|
|
347
|
-
update_scheduled = false;
|
|
348
|
-
update_scheduled_store.set(false);
|
|
349
|
-
}
|
|
350
|
-
function update_value(updates) {
|
|
351
|
-
if (!updates)
|
|
352
|
-
return;
|
|
353
|
-
pending_updates.push(updates);
|
|
354
|
-
if (!update_scheduled) {
|
|
355
|
-
update_scheduled = true;
|
|
356
|
-
update_scheduled_store.set(true);
|
|
357
|
-
raf(flush);
|
|
358
|
-
}
|
|
292
|
+
async function get_data(id) {
|
|
293
|
+
return get_callbacks.get(id)?.();
|
|
359
294
|
}
|
|
360
|
-
function
|
|
361
|
-
|
|
362
|
-
if (!comp) {
|
|
363
|
-
const layout = get(layout_store);
|
|
364
|
-
comp = findComponentById(layout, id);
|
|
365
|
-
}
|
|
366
|
-
if (!comp) {
|
|
367
|
-
return null;
|
|
368
|
-
}
|
|
369
|
-
if (comp.instance?.get_value) {
|
|
370
|
-
return comp.instance.get_value();
|
|
371
|
-
}
|
|
372
|
-
return comp.props.value;
|
|
295
|
+
function set_data(id, data) {
|
|
296
|
+
set_callbacks.get(id)?.(data);
|
|
373
297
|
}
|
|
374
298
|
function findComponentById(node, id) {
|
|
375
299
|
if (node.id === id) {
|
|
@@ -406,16 +330,15 @@ export function create_components({ initial_layout = undefined } = {
|
|
|
406
330
|
return {
|
|
407
331
|
layout: layout_store,
|
|
408
332
|
targets: target_map,
|
|
409
|
-
update_value,
|
|
410
333
|
get_data,
|
|
334
|
+
set_data,
|
|
411
335
|
modify_stream,
|
|
412
336
|
get_stream_state,
|
|
413
337
|
set_time_limit,
|
|
414
338
|
loading_status,
|
|
415
|
-
scheduled_updates: update_scheduled_store,
|
|
416
339
|
create_layout: create_layout,
|
|
417
340
|
rerender_layout,
|
|
418
|
-
|
|
341
|
+
register_component
|
|
419
342
|
};
|
|
420
343
|
}
|
|
421
344
|
/** An async version of 'new Function' */
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
import api_logo from "./img/api-logo.svg";
|
|
4
|
+
import Clear from "./img/clear.svelte";
|
|
5
|
+
import { BaseButton } from "@gradio/button";
|
|
6
|
+
|
|
7
|
+
export let root: string;
|
|
8
|
+
export let api_count: number;
|
|
9
|
+
export let current_language: "python" | "javascript" | "bash" | "mcp" =
|
|
10
|
+
"python";
|
|
11
|
+
|
|
12
|
+
const dispatch = createEventDispatcher();
|
|
9
13
|
</script>
|
|
10
14
|
|
|
11
15
|
<h2>
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
7
11
|
};
|
|
8
|
-
|
|
9
|
-
close: CustomEvent<any>;
|
|
10
|
-
} & {
|
|
11
|
-
[evt: string]: CustomEvent<any>;
|
|
12
|
-
};
|
|
13
|
-
slots: {};
|
|
14
|
-
exports?: {} | undefined;
|
|
15
|
-
bindings?: string | undefined;
|
|
16
|
-
};
|
|
17
|
-
export type ApiBannerProps = typeof __propDef.props;
|
|
18
|
-
export type ApiBannerEvents = typeof __propDef.events;
|
|
19
|
-
export type ApiBannerSlots = typeof __propDef.slots;
|
|
20
|
-
export default class ApiBanner extends SvelteComponent<ApiBannerProps, ApiBannerEvents, ApiBannerSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
21
13
|
}
|
|
22
|
-
|
|
14
|
+
declare const ApiBanner: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
root: string;
|
|
16
|
+
api_count: number;
|
|
17
|
+
current_language?: "python" | "javascript" | "bash" | "mcp";
|
|
18
|
+
}, {
|
|
19
|
+
close: CustomEvent<any>;
|
|
20
|
+
} & {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
}, {}, {}, string>;
|
|
23
|
+
type ApiBanner = InstanceType<typeof ApiBanner>;
|
|
24
|
+
export default ApiBanner;
|