@gradio/core 0.1.0-beta.4 → 0.1.0-beta.6

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 CHANGED
@@ -1,5 +1,90 @@
1
1
  # @gradio/core
2
2
 
3
+ ## 0.1.0-beta.6
4
+
5
+ ### Features
6
+
7
+ - [#9590](https://github.com/gradio-app/gradio/pull/9590) [`e853c41`](https://github.com/gradio-app/gradio/commit/e853c413583d91186aef3aceb0849d0ec0494834) - SSR e2e + fixes. Thanks @pngwn!
8
+ - [#9575](https://github.com/gradio-app/gradio/pull/9575) [`4ec2feb`](https://github.com/gradio-app/gradio/commit/4ec2feb04e452d2c77482c09543c59948567be67) - Update gr.Dataframe UI with action popover. Thanks @hannahblair!
9
+ - [#9576](https://github.com/gradio-app/gradio/pull/9576) [`430a26a`](https://github.com/gradio-app/gradio/commit/430a26a4fbcbabb5e9ddb6173bf658a00960e88e) - Fix reload mode. Thanks @freddyaboulton!
10
+
11
+ ### Dependency updates
12
+
13
+ - @gradio/upload@0.13.0-beta.7
14
+ - @gradio/statustracker@0.8.0-beta.5
15
+ - @gradio/code@0.10.0-beta.8
16
+ - @gradio/paramviewer@0.4.22-beta.5
17
+ - @gradio/tabitem@0.3.0-beta.4
18
+ - @gradio/tabs@0.3.0-beta.3
19
+ - @gradio/icons@0.8.0-beta.4
20
+ - @gradio/atoms@0.9.0-beta.5
21
+ - @gradio/image@0.16.0-beta.7
22
+ - @gradio/video@0.11.0-beta.7
23
+ - @gradio/button@0.3.0-beta.7
24
+ - @gradio/markdown@0.10.0-beta.5
25
+ - @gradio/gallery@0.13.0-beta.7
26
+ - @gradio/plot@0.7.0-beta.6
27
+ - @gradio/column@0.2.0-beta.2
28
+ - @gradio/textbox@0.7.0-beta.5
29
+ - @gradio/checkbox@0.4.0-beta.5
30
+ - @gradio/file@0.10.0-beta.7
31
+
32
+ ## 0.1.0-beta.5
33
+
34
+ ### Features
35
+
36
+ - [#9483](https://github.com/gradio-app/gradio/pull/9483) [`8dc7c12`](https://github.com/gradio-app/gradio/commit/8dc7c12389311b60efcde1b9d3e3668a34d2dc00) - Send Streaming data over Websocket if possible. Also support base64 output format for images. Thanks @freddyaboulton!
37
+ - [#9521](https://github.com/gradio-app/gradio/pull/9521) [`06ef22e`](https://github.com/gradio-app/gradio/commit/06ef22e83cdd27e7afb381396d153d9db3dea16e) - Allow `info=` to render markdown. Thanks @dawoodkhan82!
38
+
39
+ ### Dependency updates
40
+
41
+ - @gradio/tabitem@0.3.0-beta.4
42
+ - @gradio/code@0.10.0-beta.7
43
+ - @gradio/paramviewer@0.4.22-beta.4
44
+ - @gradio/video@0.11.0-beta.6
45
+ - @gradio/statustracker@0.8.0-beta.4
46
+ - @gradio/atoms@0.9.0-beta.4
47
+ - @gradio/client@1.6.0-beta.4
48
+ - @gradio/upload@0.13.0-beta.6
49
+ - @gradio/image@0.16.0-beta.6
50
+ - @gradio/gallery@0.13.0-beta.6
51
+ - @gradio/markdown@0.10.0-beta.4
52
+ - @gradio/plot@0.7.0-beta.5
53
+ - @gradio/column@0.2.0-beta.2
54
+ - @gradio/button@0.3.0-beta.6
55
+ - @gradio/textbox@0.7.0-beta.4
56
+ - @gradio/checkbox@0.4.0-beta.4
57
+ - @gradio/file@0.10.0-beta.6
58
+
59
+ ## 0.1.0-beta.4
60
+
61
+ ### Dependency updates
62
+
63
+ - @gradio/code@0.10.0-beta.6
64
+
65
+ ## 0.1.0-beta.4
66
+
67
+ ### Dependency updates
68
+
69
+ - @gradio/upload@0.13.0-beta.5
70
+ - @gradio/statustracker@0.8.0-beta.3
71
+ - @gradio/video@0.11.0-beta.5
72
+ - @gradio/tabs@0.3.0-beta.3
73
+ - @gradio/column@0.2.0-beta.1
74
+ - @gradio/tabitem@0.3.0-beta.3
75
+ - @gradio/code@0.10.0-beta.5
76
+ - @gradio/paramviewer@0.4.22-beta.3
77
+ - @gradio/icons@0.8.0-beta.3
78
+ - @gradio/atoms@0.9.0-beta.3
79
+ - @gradio/button@0.3.0-beta.5
80
+ - @gradio/markdown@0.10.0-beta.3
81
+ - @gradio/gallery@0.13.0-beta.5
82
+ - @gradio/plot@0.7.0-beta.4
83
+ - @gradio/file@0.10.0-beta.5
84
+ - @gradio/checkbox@0.4.0-beta.3
85
+ - @gradio/image@0.16.0-beta.5
86
+ - @gradio/textbox@0.7.0-beta.3
87
+
3
88
  ## 0.1.0-beta.4
4
89
 
5
90
  ### Features
@@ -118,6 +203,13 @@
118
203
 
119
204
  ## 0.0.4
120
205
 
206
+ ### Dependency updates
207
+
208
+ - @gradio/code@0.9.1
209
+ - @gradio/paramviewer@0.4.22
210
+
211
+ ## 0.0.4
212
+
121
213
  ### Fixes
122
214
 
123
215
  - [#9188](https://github.com/gradio-app/gradio/pull/9188) [`8f8e1c6`](https://github.com/gradio-app/gradio/commit/8f8e1c6a0b09b0d1985b8377d94d693cb00f8a18) - Fix multiple trigger bug when function has js. Thanks @freddyaboulton!
@@ -5,6 +5,7 @@ import { setupi18n } from "./i18n";
5
5
  import { ApiDocs, ApiRecorder } from "./api_docs/";
6
6
  import { Toast } from "@gradio/statustracker";
7
7
  import MountComponents from "./MountComponents.svelte";
8
+ import { prefix_css } from "./css";
8
9
  import logo from "./images/logo.svg";
9
10
  import api_logo from "./api_docs/img/api-logo.svg";
10
11
  import { create_components, AsyncFunction } from "./init";
@@ -31,6 +32,7 @@ export let username;
31
32
  export let api_prefix = "";
32
33
  export let max_file_size = void 0;
33
34
  export let initial_layout = void 0;
35
+ export let css = null;
34
36
  let {
35
37
  layout: _layout,
36
38
  targets,
@@ -43,8 +45,7 @@ let {
43
45
  scheduled_updates,
44
46
  create_layout,
45
47
  rerender_layout
46
- } = create_components();
47
- $_layout = initial_layout;
48
+ } = create_components(initial_layout);
48
49
  $:
49
50
  components, layout, dependencies, root, app, fill_height, target, run();
50
51
  $: {
@@ -151,8 +152,10 @@ function wait_then_trigger_api_call(dep_index, trigger_id = null, event_data = n
151
152
  if ($scheduled_updates) {
152
153
  _unsub = scheduled_updates.subscribe((updating) => {
153
154
  if (!updating) {
154
- trigger_api_call(dep_index, trigger_id, event_data);
155
- unsub();
155
+ tick().then(() => {
156
+ trigger_api_call(dep_index, trigger_id, event_data);
157
+ unsub();
158
+ });
156
159
  }
157
160
  });
158
161
  } else {
@@ -242,7 +245,7 @@ async function trigger_api_call(dep_index, trigger_id = null, event_data = null)
242
245
  } else if (submit_map.has(dep_index) && dep.inputs.some((id) => get_stream_state(id) === "waiting")) {
243
246
  return;
244
247
  } else if (submit_map.has(dep_index) && dep.inputs.some((id) => get_stream_state(id) === "open")) {
245
- await app.post_data(
248
+ await app.send_ws_message(
246
249
  // @ts-ignore
247
250
  `${app.config.root + app.config.api_prefix}/stream/${submit_map.get(dep_index).event_id()}`,
248
251
  { ...payload2, session_hash: app.session_hash }
@@ -483,11 +486,9 @@ async function handle_mount() {
483
486
  const deps = $targets[id]?.[data];
484
487
  deps?.forEach((dep_id) => {
485
488
  if (submit_map.has(dep_id)) {
486
- app.post_data(
487
- // @ts-ignore
488
- `${app.config.root + app.config.api_prefix}/stream/${submit_map.get(dep_id).event_id()}/close`,
489
- {}
490
- );
489
+ const url = `${app.config.root + app.config.api_prefix}/stream/${submit_map.get(dep_id).event_id()}`;
490
+ app.post_data(`${url}/close`, {});
491
+ app.close_ws(url);
491
492
  }
492
493
  });
493
494
  } else {
@@ -561,23 +562,26 @@ onMount(() => {
561
562
  {#if control_page_title}
562
563
  <title>{title}</title>
563
564
  {/if}
565
+ {#if css}
566
+ {@html `\<style\>${prefix_css(css, version)}</style>`}
567
+ {/if}
564
568
  </svelte:head>
565
569
 
566
570
  <div class="wrap" style:min-height={app_mode ? "100%" : "auto"}>
567
571
  <div class="contain" style:flex-grow={app_mode ? "1" : "auto"}>
568
- <!-- {#if $_layout} -->
569
- <MountComponents
570
- rootNode={$_layout}
571
- {root}
572
- {target}
573
- {theme_mode}
574
- on:mount={handle_mount}
575
- {version}
576
- {autoscroll}
577
- {max_file_size}
578
- client={app}
579
- />
580
- <!-- {/if} -->
572
+ {#if $_layout && app.config}
573
+ <MountComponents
574
+ rootNode={$_layout}
575
+ {root}
576
+ {target}
577
+ {theme_mode}
578
+ on:mount={handle_mount}
579
+ {version}
580
+ {autoscroll}
581
+ {max_file_size}
582
+ client={app}
583
+ />
584
+ {/if}
581
585
  </div>
582
586
 
583
587
  {#if show_footer}
@@ -26,7 +26,8 @@ declare const __propDef: {
26
26
  username: string | null;
27
27
  api_prefix?: string | undefined;
28
28
  max_file_size?: number | undefined;
29
- initial_layout?: LayoutNode | undefined;
29
+ initial_layout?: ComponentMeta | undefined;
30
+ css?: string | null | undefined;
30
31
  search_params: URLSearchParams;
31
32
  render_complete?: boolean | undefined;
32
33
  add_new_message?: ((message: string, type: ToastMessage["type"]) => void) | undefined;
@@ -46,6 +46,7 @@ const submit = async () => {
46
46
  <Form>
47
47
  <Block>
48
48
  <Textbox
49
+ {root}
49
50
  label="username"
50
51
  lines={1}
51
52
  show_label={true}
@@ -57,6 +58,7 @@ const submit = async () => {
57
58
 
58
59
  <Block>
59
60
  <Textbox
61
+ {root}
60
62
  label="password"
61
63
  lines={1}
62
64
  show_label={true}
@@ -39,7 +39,7 @@ export let current_language;
39
39
  The input value that is provided in the "{label}" <!--
40
40
  -->{component}
41
41
  component<!--
42
- -->.
42
+ -->. {python_type.description}
43
43
  </p>
44
44
  </div>
45
45
  {/each}
package/dist/src/css.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare function mount_css(url: string, target: HTMLElement): Promise<void>;
2
- export declare function prefix_css(string: string, version: string, style_element?: HTMLStyleElement): HTMLStyleElement | null;
2
+ export declare function prefix_css(string: string, version: string, style_element?: HTMLStyleElement): string | null;
package/dist/src/css.js CHANGED
@@ -26,9 +26,12 @@ export function mount_css(url, target) {
26
26
  target.appendChild(link);
27
27
  });
28
28
  }
29
- export function prefix_css(string, version, style_element = document.createElement("style")) {
29
+ export function prefix_css(string, version, style_element) {
30
30
  if (!supports_adopted_stylesheets)
31
- return null;
31
+ return string;
32
+ if (!style_element) {
33
+ style_element = document.createElement("style");
34
+ }
32
35
  style_element.remove();
33
36
  const stylesheet = new CSSStyleSheet();
34
37
  stylesheet.replaceSync(string);
@@ -39,7 +42,7 @@ export function prefix_css(string, version, style_element = document.createEleme
39
42
  });
40
43
  const rules = stylesheet.cssRules;
41
44
  let css_string = "";
42
- let gradio_css_infix = `gradio-app .gradio-container.gradio-container-${version} .contain `;
45
+ let gradio_css_infix = `.gradio-container.gradio-container-${version} .contain `;
43
46
  for (let i = 0; i < rules.length; i++) {
44
47
  const rule = rules[i];
45
48
  let is_dark_rule = rule.cssText.includes(".dark");
@@ -87,8 +90,5 @@ export function prefix_css(string, version, style_element = document.createEleme
87
90
  css_string += `@font-face { ${rule.style.cssText} }`;
88
91
  }
89
92
  }
90
- css_string = importString + css_string;
91
- style_element.textContent = css_string;
92
- document.head.appendChild(style_element);
93
- return style_element;
93
+ return importString + css_string;
94
94
  }
@@ -11,7 +11,7 @@ export interface UpdateTransaction {
11
11
  * Create a store with the layout and a map of targets
12
12
  * @returns A store with the layout and a map of targets
13
13
  */
14
- export declare function create_components(): {
14
+ export declare function create_components(initial_layout: ComponentMeta | undefined): {
15
15
  layout: Writable<ComponentMeta>;
16
16
  targets: Writable<TargetMap>;
17
17
  update_value: (updates: UpdateTransaction[]) => void;
package/dist/src/init.js CHANGED
@@ -11,7 +11,7 @@ const raf = is_browser
11
11
  * Create a store with the layout and a map of targets
12
12
  * @returns A store with the layout and a map of targets
13
13
  */
14
- export function create_components() {
14
+ export function create_components(initial_layout) {
15
15
  let _component_map;
16
16
  let target_map = writable({});
17
17
  let _target_map = {};
@@ -20,7 +20,7 @@ export function create_components() {
20
20
  let constructor_map;
21
21
  let instance_map;
22
22
  let loading_status = create_loading_status_store();
23
- const layout_store = writable();
23
+ const layout_store = writable(initial_layout);
24
24
  let _components = [];
25
25
  let app;
26
26
  let keyed_component_values = {};
@@ -199,7 +199,11 @@ export function create_components() {
199
199
  }
200
200
  }
201
201
  function get_data(id) {
202
- const comp = _component_map.get(id);
202
+ let comp = _component_map.get(id);
203
+ if (!comp) {
204
+ const layout = get(layout_store);
205
+ comp = findComponentById(layout, id);
206
+ }
203
207
  if (!comp) {
204
208
  return null;
205
209
  }
@@ -208,6 +212,20 @@ export function create_components() {
208
212
  }
209
213
  return comp.props.value;
210
214
  }
215
+ function findComponentById(node, id) {
216
+ if (node.id === id) {
217
+ return node;
218
+ }
219
+ if (node.children) {
220
+ for (const child of node.children) {
221
+ const result = findComponentById(child, id);
222
+ if (result) {
223
+ return result;
224
+ }
225
+ }
226
+ }
227
+ return undefined;
228
+ }
211
229
  function modify_stream(id, state) {
212
230
  const comp = _component_map.get(id);
213
231
  if (comp && comp.instance.modify_stream_state) {
@@ -55,8 +55,12 @@
55
55
  },
56
56
  "dataframe": {
57
57
  "incorrect_format": "Incorrect format, only CSV and TSV files are supported",
58
- "new_column": "New column",
59
- "new_row": "New row"
58
+ "new_column": "Add column",
59
+ "new_row": "New row",
60
+ "add_row_above": "Add row above",
61
+ "add_row_below": "Add row below",
62
+ "add_column_left": "Add column to the left",
63
+ "add_column_right": "Add column to the right"
60
64
  },
61
65
  "dropdown": {
62
66
  "dropdown": "Dropdown"
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
1
  {
2
2
  "name": "@gradio/core",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.0-beta.6",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
- "@gradio/accordion": "^0.3.23-beta.2",
7
- "@gradio/annotatedimage": "^0.8.0-beta.4",
8
- "@gradio/atoms": "^0.9.0-beta.2",
9
- "@gradio/audio": "^0.14.0-beta.5",
10
- "@gradio/button": "^0.3.0-beta.4",
11
- "@gradio/box": "^0.2.0-beta.0",
12
- "@gradio/chatbot": "^0.14.0-beta.5",
13
- "@gradio/checkbox": "^0.4.0-beta.2",
14
- "@gradio/checkboxgroup": "^0.6.0-beta.2",
15
- "@gradio/code": "^0.10.0-beta.4",
16
- "@gradio/column": "^0.2.0-beta.0",
17
- "@gradio/colorpicker": "^0.3.13-beta.2",
18
- "@gradio/dataframe": "^0.11.0-beta.5",
19
- "@gradio/client": "^1.6.0-beta.3",
20
- "@gradio/dataset": "^0.2.5-beta.4",
21
- "@gradio/datetime": "^0.1.4-beta.2",
22
- "@gradio/downloadbutton": "^0.1.28-beta.4",
23
- "@gradio/dropdown": "^0.7.13-beta.2",
24
- "@gradio/fallback": "^0.3.13-beta.2",
25
- "@gradio/file": "^0.10.0-beta.4",
26
- "@gradio/fileexplorer": "^0.5.0-beta.4",
27
- "@gradio/form": "^0.1.25-beta.2",
6
+ "@gradio/annotatedimage": "^0.8.0-beta.7",
7
+ "@gradio/accordion": "^0.3.23-beta.5",
8
+ "@gradio/audio": "^0.14.0-beta.8",
9
+ "@gradio/atoms": "^0.9.0-beta.5",
10
+ "@gradio/box": "^0.2.0-beta.3",
11
+ "@gradio/button": "^0.3.0-beta.7",
12
+ "@gradio/chatbot": "^0.14.0-beta.8",
13
+ "@gradio/checkboxgroup": "^0.6.0-beta.5",
14
+ "@gradio/checkbox": "^0.4.0-beta.5",
15
+ "@gradio/client": "^1.6.0-beta.4",
16
+ "@gradio/code": "^0.10.0-beta.8",
17
+ "@gradio/dataframe": "^0.11.0-beta.8",
18
+ "@gradio/colorpicker": "^0.4.0-beta.5",
19
+ "@gradio/datetime": "^0.2.0-beta.5",
20
+ "@gradio/column": "^0.2.0-beta.2",
21
+ "@gradio/downloadbutton": "^0.1.28-beta.7",
22
+ "@gradio/dataset": "^0.2.5-beta.7",
23
+ "@gradio/dropdown": "^0.8.0-beta.6",
24
+ "@gradio/fallback": "^0.3.13-beta.5",
25
+ "@gradio/file": "^0.10.0-beta.7",
26
+ "@gradio/fileexplorer": "^0.5.0-beta.7",
27
+ "@gradio/form": "^0.2.0-beta.5",
28
+ "@gradio/gallery": "^0.13.0-beta.7",
29
+ "@gradio/highlightedtext": "^0.7.7-beta.5",
28
30
  "@gradio/group": "^0.2.0-beta.1",
29
- "@gradio/gallery": "^0.13.0-beta.4",
30
- "@gradio/highlightedtext": "^0.7.7-beta.2",
31
- "@gradio/icons": "^0.8.0-beta.2",
32
- "@gradio/image": "^0.16.0-beta.4",
33
- "@gradio/html": "^0.4.0-beta.2",
34
- "@gradio/imageeditor": "^0.11.0-beta.4",
35
- "@gradio/label": "^0.3.13-beta.2",
36
- "@gradio/json": "^0.5.0-beta.2",
37
- "@gradio/multimodaltextbox": "^0.6.0-beta.4",
38
- "@gradio/model3d": "^0.13.0-beta.4",
39
- "@gradio/markdown": "^0.10.0-beta.2",
40
- "@gradio/nativeplot": "^0.4.0-beta.3",
41
- "@gradio/number": "^0.4.13-beta.2",
42
- "@gradio/paramviewer": "^0.4.22-beta.2",
43
- "@gradio/plot": "^0.7.0-beta.3",
44
- "@gradio/radio": "^0.6.0-beta.2",
45
- "@gradio/row": "^0.2.0-beta.1",
46
- "@gradio/simpledropdown": "^0.2.13-beta.2",
47
- "@gradio/simpleimage": "^0.8.0-beta.4",
48
- "@gradio/simpletextbox": "^0.2.13-beta.2",
31
+ "@gradio/icons": "^0.8.0-beta.4",
32
+ "@gradio/image": "^0.16.0-beta.7",
33
+ "@gradio/imageeditor": "^0.11.0-beta.7",
34
+ "@gradio/json": "^0.5.0-beta.5",
35
+ "@gradio/label": "^0.3.13-beta.5",
36
+ "@gradio/html": "^0.4.0-beta.5",
37
+ "@gradio/markdown": "^0.10.0-beta.5",
38
+ "@gradio/model3d": "^0.13.0-beta.7",
39
+ "@gradio/multimodaltextbox": "^0.6.0-beta.7",
40
+ "@gradio/nativeplot": "^0.4.0-beta.7",
41
+ "@gradio/number": "^0.5.0-beta.5",
42
+ "@gradio/paramviewer": "^0.4.22-beta.5",
43
+ "@gradio/row": "^0.2.0-beta.3",
44
+ "@gradio/radio": "^0.6.0-beta.5",
45
+ "@gradio/simpledropdown": "^0.3.0-beta.5",
46
+ "@gradio/simpleimage": "^0.8.0-beta.7",
47
+ "@gradio/plot": "^0.7.0-beta.6",
48
+ "@gradio/simpletextbox": "^0.3.0-beta.5",
49
49
  "@gradio/state": "^0.1.2",
50
- "@gradio/statustracker": "^0.8.0-beta.2",
51
- "@gradio/slider": "^0.5.0-beta.2",
52
- "@gradio/tabitem": "^0.3.0-beta.2",
53
- "@gradio/tabs": "^0.3.0-beta.2",
54
- "@gradio/textbox": "^0.7.0-beta.2",
50
+ "@gradio/slider": "^0.5.0-beta.5",
51
+ "@gradio/statustracker": "^0.8.0-beta.5",
52
+ "@gradio/tabitem": "^0.3.0-beta.4",
53
+ "@gradio/tabs": "^0.3.0-beta.3",
55
54
  "@gradio/theme": "^0.3.0-beta.1",
56
- "@gradio/upload": "^0.13.0-beta.4",
55
+ "@gradio/textbox": "^0.7.0-beta.5",
57
56
  "@gradio/timer": "^0.3.3-beta.2",
58
- "@gradio/uploadbutton": "^0.7.0-beta.4",
59
57
  "@gradio/utils": "^0.7.0-beta.2",
60
- "@gradio/video": "^0.11.0-beta.4",
58
+ "@gradio/upload": "^0.13.0-beta.7",
59
+ "@gradio/uploadbutton": "^0.7.0-beta.7",
60
+ "@gradio/video": "^0.11.0-beta.7",
61
61
  "@gradio/wasm": "^0.14.0-beta.3"
62
62
  },
63
63
  "msw": {
package/src/Blocks.svelte CHANGED
@@ -14,6 +14,7 @@
14
14
  import type { ToastMessage } from "@gradio/statustracker";
15
15
  import type { ShareData, ValueData } from "@gradio/utils";
16
16
  import MountComponents from "./MountComponents.svelte";
17
+ import { prefix_css } from "./css";
17
18
 
18
19
  import logo from "./images/logo.svg";
19
20
  import api_logo from "./api_docs/img/api-logo.svg";
@@ -47,8 +48,8 @@
47
48
  export let username: string | null;
48
49
  export let api_prefix = "";
49
50
  export let max_file_size: number | undefined = undefined;
50
- export let initial_layout: LayoutNode | undefined = undefined;
51
-
51
+ export let initial_layout: ComponentMeta | undefined = undefined;
52
+ export let css: string | null | undefined = null;
52
53
  let {
53
54
  layout: _layout,
54
55
  targets,
@@ -61,10 +62,7 @@
61
62
  scheduled_updates,
62
63
  create_layout,
63
64
  rerender_layout
64
- } = create_components();
65
-
66
- // @ts-ignore
67
- $_layout = initial_layout;
65
+ } = create_components(initial_layout);
68
66
 
69
67
  $: components, layout, dependencies, root, app, fill_height, target, run();
70
68
 
@@ -207,8 +205,10 @@
207
205
  if ($scheduled_updates) {
208
206
  _unsub = scheduled_updates.subscribe((updating) => {
209
207
  if (!updating) {
210
- trigger_api_call(dep_index, trigger_id, event_data);
211
- unsub();
208
+ tick().then(() => {
209
+ trigger_api_call(dep_index, trigger_id, event_data);
210
+ unsub();
211
+ });
212
212
  }
213
213
  });
214
214
  } else {
@@ -329,7 +329,7 @@
329
329
  submit_map.has(dep_index) &&
330
330
  dep.inputs.some((id) => get_stream_state(id) === "open")
331
331
  ) {
332
- await app.post_data(
332
+ await app.send_ws_message(
333
333
  // @ts-ignore
334
334
  `${app.config.root + app.config.api_prefix}/stream/${submit_map.get(dep_index).event_id()}`,
335
335
  { ...payload, session_hash: app.session_hash }
@@ -620,11 +620,10 @@
620
620
  const deps = $targets[id]?.[data];
621
621
  deps?.forEach((dep_id) => {
622
622
  if (submit_map.has(dep_id)) {
623
- app.post_data(
624
- // @ts-ignore
625
- `${app.config.root + app.config.api_prefix}/stream/${submit_map.get(dep_id).event_id()}/close`,
626
- {}
627
- );
623
+ // @ts-ignore
624
+ const url = `${app.config.root + app.config.api_prefix}/stream/${submit_map.get(dep_id).event_id()}`;
625
+ app.post_data(`${url}/close`, {});
626
+ app.close_ws(url);
628
627
  }
629
628
  });
630
629
  } else {
@@ -716,23 +715,26 @@
716
715
  {#if control_page_title}
717
716
  <title>{title}</title>
718
717
  {/if}
718
+ {#if css}
719
+ {@html `\<style\>${prefix_css(css, version)}</style>`}
720
+ {/if}
719
721
  </svelte:head>
720
722
 
721
723
  <div class="wrap" style:min-height={app_mode ? "100%" : "auto"}>
722
724
  <div class="contain" style:flex-grow={app_mode ? "1" : "auto"}>
723
- <!-- {#if $_layout} -->
724
- <MountComponents
725
- rootNode={$_layout}
726
- {root}
727
- {target}
728
- {theme_mode}
729
- on:mount={handle_mount}
730
- {version}
731
- {autoscroll}
732
- {max_file_size}
733
- client={app}
734
- />
735
- <!-- {/if} -->
725
+ {#if $_layout && app.config}
726
+ <MountComponents
727
+ rootNode={$_layout}
728
+ {root}
729
+ {target}
730
+ {theme_mode}
731
+ on:mount={handle_mount}
732
+ {version}
733
+ {autoscroll}
734
+ {max_file_size}
735
+ client={app}
736
+ />
737
+ {/if}
736
738
  </div>
737
739
 
738
740
  {#if show_footer}
package/src/Login.svelte CHANGED
@@ -50,6 +50,7 @@
50
50
  <Form>
51
51
  <Block>
52
52
  <Textbox
53
+ {root}
53
54
  label="username"
54
55
  lines={1}
55
56
  show_label={true}
@@ -61,6 +62,7 @@
61
62
 
62
63
  <Block>
63
64
  <Textbox
65
+ {root}
64
66
  label="password"
65
67
  lines={1}
66
68
  show_label={true}
@@ -41,7 +41,7 @@
41
41
  The input value that is provided in the "{label}" <!--
42
42
  -->{component}
43
43
  component<!--
44
- -->.
44
+ -->. {python_type.description}
45
45
  </p>
46
46
  </div>
47
47
  {/each}
package/src/css.ts CHANGED
@@ -36,9 +36,12 @@ export function mount_css(url: string, target: HTMLElement): Promise<void> {
36
36
  export function prefix_css(
37
37
  string: string,
38
38
  version: string,
39
- style_element = document.createElement("style")
40
- ): HTMLStyleElement | null {
41
- if (!supports_adopted_stylesheets) return null;
39
+ style_element?: HTMLStyleElement
40
+ ): string | null {
41
+ if (!supports_adopted_stylesheets) return string;
42
+ if (!style_element) {
43
+ style_element = document.createElement("style");
44
+ }
42
45
  style_element.remove();
43
46
 
44
47
  const stylesheet = new CSSStyleSheet();
@@ -53,7 +56,7 @@ export function prefix_css(
53
56
  const rules = stylesheet.cssRules;
54
57
 
55
58
  let css_string = "";
56
- let gradio_css_infix = `gradio-app .gradio-container.gradio-container-${version} .contain `;
59
+ let gradio_css_infix = `.gradio-container.gradio-container-${version} .contain `;
57
60
 
58
61
  for (let i = 0; i < rules.length; i++) {
59
62
  const rule = rules[i];
@@ -109,9 +112,5 @@ export function prefix_css(
109
112
  css_string += `@font-face { ${rule.style.cssText} }`;
110
113
  }
111
114
  }
112
- css_string = importString + css_string;
113
- style_element.textContent = css_string;
114
-
115
- document.head.appendChild(style_element);
116
- return style_element;
115
+ return importString + css_string;
117
116
  }
package/src/init.test.ts CHANGED
@@ -481,14 +481,17 @@ describe("get_component", () => {
481
481
  const id = "test-random";
482
482
  const variant = "component";
483
483
  const handlers = [
484
- http.get(`${api_url}/custom_component/${id}/${variant}/style.css`, () => {
485
- return new HttpResponse('console.log("boo")', {
486
- status: 200,
487
- headers: {
488
- "Content-Type": "text/css"
489
- }
490
- });
491
- })
484
+ http.get(
485
+ `${api_url}/custom_component/${id}/client/${variant}/style.css`,
486
+ () => {
487
+ return new HttpResponse('console.log("boo")', {
488
+ status: 200,
489
+ headers: {
490
+ "Content-Type": "text/css"
491
+ }
492
+ });
493
+ }
494
+ )
492
495
  ];
493
496
 
494
497
  // vi.mock calls are always hoisted out of the test function to the top of the file
@@ -498,7 +501,7 @@ describe("get_component", () => {
498
501
  });
499
502
 
500
503
  vi.mock(
501
- `example.com/custom_component/test-random/component/index.js`,
504
+ `example.com/custom_component/test-random/client/component/index.js`,
502
505
  async () => {
503
506
  mock();
504
507
  return {
package/src/init.ts CHANGED
@@ -27,7 +27,7 @@ const raf = is_browser
27
27
  * Create a store with the layout and a map of targets
28
28
  * @returns A store with the layout and a map of targets
29
29
  */
30
- export function create_components(): {
30
+ export function create_components(initial_layout: ComponentMeta | undefined): {
31
31
  layout: Writable<ComponentMeta>;
32
32
  targets: Writable<TargetMap>;
33
33
  update_value: (updates: UpdateTransaction[]) => void;
@@ -65,7 +65,7 @@ export function create_components(): {
65
65
  let instance_map: { [id: number]: ComponentMeta };
66
66
  let loading_status: ReturnType<typeof create_loading_status_store> =
67
67
  create_loading_status_store();
68
- const layout_store: Writable<ComponentMeta> = writable();
68
+ const layout_store: Writable<ComponentMeta> = writable(initial_layout);
69
69
  let _components: ComponentMeta[] = [];
70
70
  let app: client_return;
71
71
  let keyed_component_values: Record<string | number, any> = {};
@@ -341,9 +341,12 @@ export function create_components(): {
341
341
  raf(flush);
342
342
  }
343
343
  }
344
-
345
344
  function get_data(id: number): any | Promise<any> {
346
- const comp = _component_map.get(id);
345
+ let comp = _component_map.get(id);
346
+ if (!comp) {
347
+ const layout = get(layout_store);
348
+ comp = findComponentById(layout, id);
349
+ }
347
350
  if (!comp) {
348
351
  return null;
349
352
  }
@@ -353,6 +356,24 @@ export function create_components(): {
353
356
  return comp.props.value;
354
357
  }
355
358
 
359
+ function findComponentById(
360
+ node: ComponentMeta,
361
+ id: number
362
+ ): ComponentMeta | undefined {
363
+ if (node.id === id) {
364
+ return node;
365
+ }
366
+ if (node.children) {
367
+ for (const child of node.children) {
368
+ const result = findComponentById(child, id);
369
+ if (result) {
370
+ return result;
371
+ }
372
+ }
373
+ }
374
+ return undefined;
375
+ }
376
+
356
377
  function modify_stream(
357
378
  id: number,
358
379
  state: "open" | "closed" | "waiting"
package/src/lang/en.json CHANGED
@@ -55,8 +55,12 @@
55
55
  },
56
56
  "dataframe": {
57
57
  "incorrect_format": "Incorrect format, only CSV and TSV files are supported",
58
- "new_column": "New column",
59
- "new_row": "New row"
58
+ "new_column": "Add column",
59
+ "new_row": "New row",
60
+ "add_row_above": "Add row above",
61
+ "add_row_below": "Add row below",
62
+ "add_column_left": "Add column to the left",
63
+ "add_column_right": "Add column to the right"
60
64
  },
61
65
  "dropdown": {
62
66
  "dropdown": "Dropdown"