@gradio/core 1.0.0-dev.3 → 1.0.1
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 +43 -0
- package/dist/src/Blocks.svelte +25 -10
- package/dist/src/Blocks.svelte.d.ts +2 -1
- package/dist/src/Login.svelte +13 -13
- package/dist/src/Login.svelte.d.ts +1 -0
- package/dist/src/api_docs/ApiDocs.svelte +19 -2
- package/dist/src/api_docs/ApiDocs.svelte.d.ts +1 -0
- package/dist/src/api_docs/ApiRecorder.svelte +0 -3
- package/dist/src/api_docs/CodeSnippet.svelte +63 -19
- package/dist/src/api_docs/CodeSnippet.svelte.d.ts +2 -1
- package/dist/src/api_docs/EndpointDetail.svelte +73 -17
- package/dist/src/api_docs/EndpointDetail.svelte.d.ts +3 -0
- package/dist/src/api_docs/MCPSnippet.svelte +21 -28
- package/dist/src/api_docs/MCPSnippet.svelte.d.ts +1 -0
- package/dist/src/api_docs/PercentileChart.svelte +125 -0
- package/dist/src/api_docs/PercentileChart.svelte.d.ts +22 -0
- package/dist/src/dependency.d.ts +14 -7
- package/dist/src/dependency.js +37 -19
- package/dist/src/init.svelte.d.ts +2 -2
- package/dist/src/init.svelte.js +26 -20
- package/dist/src/types.d.ts +2 -0
- package/package.json +60 -61
- package/src/Blocks.svelte +25 -10
- package/src/Login.svelte +13 -13
- package/src/api_docs/ApiDocs.svelte +19 -2
- package/src/api_docs/ApiRecorder.svelte +0 -3
- package/src/api_docs/CodeSnippet.svelte +63 -19
- package/src/api_docs/EndpointDetail.svelte +73 -17
- package/src/api_docs/MCPSnippet.svelte +21 -28
- package/src/api_docs/PercentileChart.svelte +125 -0
- package/src/dependency.ts +116 -72
- package/src/init.svelte.ts +24 -35
- package/src/types.ts +2 -0
package/src/init.svelte.ts
CHANGED
|
@@ -77,7 +77,7 @@ export class AppTree {
|
|
|
77
77
|
components: ComponentMeta[],
|
|
78
78
|
layout: LayoutNode,
|
|
79
79
|
dependencies: Dependency[],
|
|
80
|
-
config: AppConfig,
|
|
80
|
+
config: Omit<AppConfig, "api_url">,
|
|
81
81
|
app: client_return,
|
|
82
82
|
reactive_formatter: (str: string) => string
|
|
83
83
|
) {
|
|
@@ -85,8 +85,10 @@ export class AppTree {
|
|
|
85
85
|
this.ready_resolve = resolve;
|
|
86
86
|
});
|
|
87
87
|
this.reactive_formatter = reactive_formatter;
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
this.#config = {
|
|
89
|
+
...config,
|
|
90
|
+
api_url: new URL(config.api_prefix, config.root).toString()
|
|
91
|
+
};
|
|
90
92
|
this.#component_payload = components;
|
|
91
93
|
this.#layout_payload = layout;
|
|
92
94
|
this.#dependency_payload = dependencies;
|
|
@@ -129,11 +131,14 @@ export class AppTree {
|
|
|
129
131
|
components: ComponentMeta[],
|
|
130
132
|
layout: LayoutNode,
|
|
131
133
|
dependencies: Dependency[],
|
|
132
|
-
config: AppConfig
|
|
134
|
+
config: Omit<AppConfig, "api_url">
|
|
133
135
|
) {
|
|
134
136
|
this.#layout_payload = layout;
|
|
135
137
|
this.#component_payload = components;
|
|
136
|
-
this.#config =
|
|
138
|
+
this.#config = {
|
|
139
|
+
...config,
|
|
140
|
+
api_url: new URL(config.api_prefix, config.root).toString()
|
|
141
|
+
};
|
|
137
142
|
this.#dependency_payload = dependencies;
|
|
138
143
|
|
|
139
144
|
this.root = this.create_node(
|
|
@@ -203,21 +208,15 @@ export class AppTree {
|
|
|
203
208
|
|
|
204
209
|
postprocess(tree: ProcessedComponentMeta) {
|
|
205
210
|
this.root = this.traverse(tree, [
|
|
206
|
-
(node) => handle_visibility(node, this.#config.
|
|
211
|
+
(node) => handle_visibility(node, this.#config.api_url),
|
|
207
212
|
(node) =>
|
|
208
213
|
untrack_children_of_invisible_parents(
|
|
209
214
|
node,
|
|
210
|
-
this.#config.root,
|
|
211
215
|
this.components_to_register
|
|
212
216
|
),
|
|
213
|
-
(node) =>
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
this.#config.root,
|
|
217
|
-
this.components_to_register
|
|
218
|
-
),
|
|
219
|
-
(node) => translate_props(node, this.#config.root),
|
|
220
|
-
(node) => apply_initial_tabs(node, this.#config.root, this.initial_tabs),
|
|
217
|
+
(node) => handle_empty_forms(node, this.components_to_register),
|
|
218
|
+
(node) => translate_props(node),
|
|
219
|
+
(node) => apply_initial_tabs(node, this.initial_tabs),
|
|
221
220
|
(node) => this.find_attached_events(node, this.#dependency_payload)
|
|
222
221
|
]);
|
|
223
222
|
}
|
|
@@ -317,6 +316,7 @@ export class AppTree {
|
|
|
317
316
|
component.props,
|
|
318
317
|
[this.#input_ids, this.#output_ids],
|
|
319
318
|
this.client,
|
|
319
|
+
this.#config.api_url,
|
|
320
320
|
{ ...this.#config }
|
|
321
321
|
);
|
|
322
322
|
|
|
@@ -335,7 +335,7 @@ export class AppTree {
|
|
|
335
335
|
? get_component(
|
|
336
336
|
component.type,
|
|
337
337
|
component.component_class_id,
|
|
338
|
-
this.#config.
|
|
338
|
+
this.#config.api_url || ""
|
|
339
339
|
)
|
|
340
340
|
: null,
|
|
341
341
|
key: component.key,
|
|
@@ -391,7 +391,7 @@ export class AppTree {
|
|
|
391
391
|
this.root = this.traverse(this.root!, [
|
|
392
392
|
//@ts-ignore
|
|
393
393
|
(n) => set_visibility_for_updated_node(n, id, new_state.visible),
|
|
394
|
-
(n) => handle_visibility(n, this.#config.
|
|
394
|
+
(n) => handle_visibility(n, this.#config.api_url)
|
|
395
395
|
]);
|
|
396
396
|
already_updated_visibility = true;
|
|
397
397
|
}
|
|
@@ -403,7 +403,7 @@ export class AppTree {
|
|
|
403
403
|
// otherwise there could be
|
|
404
404
|
await tick();
|
|
405
405
|
this.root = this.traverse(this.root!, (n) =>
|
|
406
|
-
handle_visibility(n, this.#config.
|
|
406
|
+
handle_visibility(n, this.#config.api_url)
|
|
407
407
|
);
|
|
408
408
|
}
|
|
409
409
|
|
|
@@ -464,6 +464,7 @@ function gather_props(
|
|
|
464
464
|
props: ComponentMeta["props"],
|
|
465
465
|
dependencies: [Set<number>, Set<number>],
|
|
466
466
|
client: client_return,
|
|
467
|
+
api_url: string,
|
|
467
468
|
additional: Record<string, unknown> = {}
|
|
468
469
|
): {
|
|
469
470
|
shared_props: SharedProps;
|
|
@@ -508,13 +509,7 @@ function gather_props(
|
|
|
508
509
|
_shared_props.load_component = (
|
|
509
510
|
name: string,
|
|
510
511
|
variant: "base" | "component" | "example"
|
|
511
|
-
) =>
|
|
512
|
-
get_component(
|
|
513
|
-
name,
|
|
514
|
-
"",
|
|
515
|
-
_shared_props.root || "",
|
|
516
|
-
variant
|
|
517
|
-
) as LoadingComponent;
|
|
512
|
+
) => get_component(name, "", api_url, variant) as LoadingComponent;
|
|
518
513
|
|
|
519
514
|
_shared_props.visible =
|
|
520
515
|
_shared_props.visible === undefined ? true : _shared_props.visible;
|
|
@@ -525,19 +520,19 @@ function gather_props(
|
|
|
525
520
|
|
|
526
521
|
function handle_visibility(
|
|
527
522
|
node: ProcessedComponentMeta,
|
|
528
|
-
|
|
523
|
+
api_url: string
|
|
529
524
|
): ProcessedComponentMeta {
|
|
530
525
|
// Check if the node is visible
|
|
531
526
|
if (node.props.shared_props.visible && !node.component) {
|
|
532
527
|
const result: ProcessedComponentMeta = {
|
|
533
528
|
...node,
|
|
534
|
-
component: get_component(node.type, node.component_class_id,
|
|
529
|
+
component: get_component(node.type, node.component_class_id, api_url),
|
|
535
530
|
children: []
|
|
536
531
|
};
|
|
537
532
|
|
|
538
533
|
if (node.children) {
|
|
539
534
|
result.children = node.children.map((child) =>
|
|
540
|
-
handle_visibility(child,
|
|
535
|
+
handle_visibility(child, api_url)
|
|
541
536
|
);
|
|
542
537
|
}
|
|
543
538
|
return result;
|
|
@@ -570,7 +565,6 @@ function _untrack(
|
|
|
570
565
|
|
|
571
566
|
function untrack_children_of_invisible_parents(
|
|
572
567
|
node: ProcessedComponentMeta,
|
|
573
|
-
root: string,
|
|
574
568
|
components_to_register: Set<number>
|
|
575
569
|
): ProcessedComponentMeta {
|
|
576
570
|
// Check if the node is visible
|
|
@@ -582,7 +576,6 @@ function untrack_children_of_invisible_parents(
|
|
|
582
576
|
|
|
583
577
|
function handle_empty_forms(
|
|
584
578
|
node: ProcessedComponentMeta,
|
|
585
|
-
root: string,
|
|
586
579
|
components_to_register: Set<number>
|
|
587
580
|
): ProcessedComponentMeta {
|
|
588
581
|
// Check if the node is visible
|
|
@@ -601,10 +594,7 @@ function handle_empty_forms(
|
|
|
601
594
|
return node;
|
|
602
595
|
}
|
|
603
596
|
|
|
604
|
-
function translate_props(
|
|
605
|
-
node: ProcessedComponentMeta,
|
|
606
|
-
root: string
|
|
607
|
-
): ProcessedComponentMeta {
|
|
597
|
+
function translate_props(node: ProcessedComponentMeta): ProcessedComponentMeta {
|
|
608
598
|
const supported_props = [
|
|
609
599
|
"description",
|
|
610
600
|
"info",
|
|
@@ -631,7 +621,6 @@ function translate_props(
|
|
|
631
621
|
|
|
632
622
|
function apply_initial_tabs(
|
|
633
623
|
node: ProcessedComponentMeta,
|
|
634
|
-
root: string,
|
|
635
624
|
initial_tabs: Record<number, Tab[]>
|
|
636
625
|
): ProcessedComponentMeta {
|
|
637
626
|
if (node.type === "tabs" && node.id in initial_tabs) {
|
package/src/types.ts
CHANGED
|
@@ -82,6 +82,7 @@ export interface Dependency {
|
|
|
82
82
|
like_user_message: boolean; // dno, this shouldnt be here surely
|
|
83
83
|
event_specific_args: ("time_limit" | "stream_every" | "like_user_message")[]; // `click(fn, some_arg=val)`
|
|
84
84
|
js_implementation: string | null; // pythong -> js transpilation
|
|
85
|
+
component_prop_inputs: number[]; // inputs that request all component props
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
interface TypeDescription {
|
|
@@ -125,4 +126,5 @@ export interface AppConfig {
|
|
|
125
126
|
max_file_size?: number;
|
|
126
127
|
autoscroll: boolean;
|
|
127
128
|
api_prefix: string;
|
|
129
|
+
api_url: string;
|
|
128
130
|
}
|