@gradio/core 0.0.4 → 0.1.0-beta.2

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/dist/src/init.js CHANGED
@@ -3,6 +3,10 @@ import { load_component } from "virtual:component-loader";
3
3
  import { create_loading_status_store } from "./stores";
4
4
  import { _ } from "svelte-i18n";
5
5
  let pending_updates = [];
6
+ const is_browser = typeof window !== "undefined";
7
+ const raf = is_browser
8
+ ? requestAnimationFrame
9
+ : async (fn) => await fn();
6
10
  /**
7
11
  * Create a store with the layout and a map of targets
8
12
  * @returns A store with the layout and a map of targets
@@ -21,7 +25,21 @@ export function create_components() {
21
25
  let app;
22
26
  let keyed_component_values = {};
23
27
  let _rootNode;
24
- function create_layout({ app: _app, components, layout, dependencies, root, options }) {
28
+ function set_event_specific_args(dependencies) {
29
+ dependencies.forEach((dep) => {
30
+ dep.targets.forEach((target) => {
31
+ const instance = instance_map[target[0]];
32
+ if (instance && dep.event_specific_args?.length > 0) {
33
+ dep.event_specific_args?.forEach((arg) => {
34
+ instance.props[arg] = dep[arg];
35
+ });
36
+ }
37
+ });
38
+ });
39
+ }
40
+ async function create_layout({ app: _app, components, layout, dependencies, root, options }) {
41
+ // make sure the state is settled before proceeding
42
+ flush();
25
43
  app = _app;
26
44
  store_keyed_values(_components);
27
45
  _components = components;
@@ -54,9 +72,9 @@ export function create_components() {
54
72
  acc[c.id] = c;
55
73
  return acc;
56
74
  }, {});
57
- walk_layout(layout, root).then(() => {
58
- layout_store.set(_rootNode);
59
- });
75
+ await walk_layout(layout, root);
76
+ layout_store.set(_rootNode);
77
+ set_event_specific_args(dependencies);
60
78
  }
61
79
  /**
62
80
  * Rerender the layout when the config has been modified to attach new components
@@ -105,6 +123,7 @@ export function create_components() {
105
123
  walk_layout(layout, root, current_element.parent).then(() => {
106
124
  layout_store.set(_rootNode);
107
125
  });
126
+ set_event_specific_args(dependencies);
108
127
  }
109
128
  async function walk_layout(node, root, parent) {
110
129
  const instance = instance_map[node.id];
@@ -176,7 +195,7 @@ export function create_components() {
176
195
  if (!update_scheduled) {
177
196
  update_scheduled = true;
178
197
  update_scheduled_store.set(true);
179
- requestAnimationFrame(flush);
198
+ raf(flush);
180
199
  }
181
200
  }
182
201
  function get_data(id) {
@@ -189,14 +208,35 @@ export function create_components() {
189
208
  }
190
209
  return comp.props.value;
191
210
  }
211
+ function modify_stream(id, state) {
212
+ const comp = _component_map.get(id);
213
+ if (comp && comp.instance.modify_stream_state) {
214
+ comp.instance.modify_stream_state(state);
215
+ }
216
+ }
217
+ function get_stream_state(id) {
218
+ const comp = _component_map.get(id);
219
+ if (comp && comp.instance.get_stream_state)
220
+ return comp.instance.get_stream_state();
221
+ return "not_set";
222
+ }
223
+ function set_time_limit(id, time_limit) {
224
+ const comp = _component_map.get(id);
225
+ if (comp && comp.instance.set_time_limit) {
226
+ comp.instance.set_time_limit(time_limit);
227
+ }
228
+ }
192
229
  return {
193
230
  layout: layout_store,
194
231
  targets: target_map,
195
232
  update_value,
196
233
  get_data,
234
+ modify_stream,
235
+ get_stream_state,
236
+ set_time_limit,
197
237
  loading_status,
198
238
  scheduled_updates: update_scheduled_store,
199
- create_layout: (...args) => requestAnimationFrame(() => create_layout(...args)),
239
+ create_layout: create_layout,
200
240
  rerender_layout
201
241
  };
202
242
  }
@@ -16,12 +16,14 @@
16
16
  "record": "Record",
17
17
  "no_microphone": "No microphone found",
18
18
  "pause": "Pause",
19
- "play": "Play"
19
+ "play": "Play",
20
+ "waiting": "Waiting"
20
21
  },
21
22
  "blocks": {
22
23
  "connection_can_break": "On mobile, the connection can break if this tab is unfocused or the device sleeps, losing your position in queue.",
23
24
  "long_requests_queue": "There is a long queue of requests pending. Duplicate this Space to skip.",
24
- "lost_connection": "Lost connection due to leaving page. Rejoining queue..."
25
+ "lost_connection": "Lost connection due to leaving page. Rejoining queue...",
26
+ "waiting_for_inputs": "Waiting for file(s) to finish uploading, please retry."
25
27
  },
26
28
  "checkbox": {
27
29
  "checkbox": "Checkbox",
@@ -112,7 +114,7 @@
112
114
  "drop_file": "Drop File Here",
113
115
  "drop_image": "Drop Image Here",
114
116
  "drop_video": "Drop Video Here",
115
- "drop_gallery": "Drop Image(s) Here",
117
+ "drop_gallery": "Drop Media Here",
116
118
  "paste_clipboard": "Paste from Clipboard"
117
119
  }
118
120
  }
@@ -16,7 +16,8 @@
16
16
  "record": "录制",
17
17
  "no_microphone": "找不到麦克风",
18
18
  "pause": "暂停",
19
- "play": "播放"
19
+ "play": "播放",
20
+ "waiting": "等待"
20
21
  },
21
22
  "blocks": {
22
23
  "connection_can_break": "在移动设备上,如果此标签页失去焦点或设备休眠,连接可能会中断,导致您在队列中失去位置。",
@@ -1,7 +1,7 @@
1
1
  import { type Writable } from "svelte/store";
2
2
  export interface LoadingStatus {
3
3
  eta: number | null;
4
- status: "pending" | "error" | "complete" | "generating";
4
+ status: "pending" | "error" | "complete" | "generating" | "streaming";
5
5
  queue: boolean;
6
6
  queue_position: number | null;
7
7
  queue_size?: number;
@@ -9,6 +9,7 @@ export interface LoadingStatus {
9
9
  message?: string | null;
10
10
  scroll_to_output?: boolean;
11
11
  show_progress?: "full" | "minimal" | "hidden";
12
+ time_limit?: number | null | undefined;
12
13
  progress?: {
13
14
  progress: number | null;
14
15
  index: number | null;
@@ -7,7 +7,7 @@ export function create_loading_status_store() {
7
7
  const pending_inputs = new Map();
8
8
  const inputs_to_update = new Map();
9
9
  const fn_status = {};
10
- function update({ fn_index, status, queue = true, size, position = null, eta = null, message = null, progress }) {
10
+ function update({ fn_index, status, queue = true, size, position = null, eta = null, message = null, progress, time_limit = null }) {
11
11
  const outputs = fn_outputs[fn_index];
12
12
  const inputs = fn_inputs[fn_index];
13
13
  const last_status = fn_status[fn_index];
@@ -64,6 +64,11 @@ export interface Dependency {
64
64
  final_event: Payload | null;
65
65
  show_api: boolean;
66
66
  rendered_in: number | null;
67
+ connection: "stream" | "sse";
68
+ time_limit: number;
69
+ stream_every: number;
70
+ like_user_message: boolean;
71
+ event_specific_args: string[];
67
72
  }
68
73
  interface TypeDescription {
69
74
  input_payload?: string;
package/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { default as Embed } from "./src/Embed.svelte";
2
2
  export { prefix_css, mount_css } from "./src/css";
3
+ export { create_components } from "./src/init";
3
4
  export * from "./src/i18n";
4
5
  export * from "./src/types";
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
1
  {
2
2
  "name": "@gradio/core",
3
- "version": "0.0.4",
3
+ "version": "0.1.0-beta.2",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
- "@gradio/annotatedimage": "^0.7.2",
7
- "@gradio/accordion": "^0.3.23",
8
- "@gradio/atoms": "^0.8.1",
9
- "@gradio/box": "^0.1.25",
10
- "@gradio/button": "^0.2.51",
11
- "@gradio/audio": "^0.13.5",
12
- "@gradio/checkbox": "^0.3.13",
13
- "@gradio/chatbot": "^0.13.1",
14
- "@gradio/checkboxgroup": "^0.5.13",
15
- "@gradio/client": "^1.5.2",
16
- "@gradio/code": "^0.9.1",
17
- "@gradio/colorpicker": "^0.3.13",
18
- "@gradio/column": "^0.1.4",
19
- "@gradio/dataset": "^0.2.5",
20
- "@gradio/dataframe": "^0.10.1",
21
- "@gradio/downloadbutton": "^0.1.28",
22
- "@gradio/datetime": "^0.1.4",
23
- "@gradio/dropdown": "^0.7.13",
24
- "@gradio/fallback": "^0.3.13",
25
- "@gradio/file": "^0.9.4",
26
- "@gradio/fileexplorer": "^0.4.19",
27
- "@gradio/form": "^0.1.25",
28
- "@gradio/gallery": "^0.12.2",
29
- "@gradio/group": "^0.1.3",
30
- "@gradio/highlightedtext": "^0.7.7",
31
- "@gradio/html": "^0.3.6",
32
- "@gradio/icons": "^0.7.2",
33
- "@gradio/image": "^0.15.1",
34
- "@gradio/imageeditor": "^0.10.1",
35
- "@gradio/json": "^0.5.0",
36
- "@gradio/label": "^0.3.13",
37
- "@gradio/markdown": "^0.9.4",
38
- "@gradio/model3d": "^0.12.2",
39
- "@gradio/nativeplot": "^0.3.2",
40
- "@gradio/number": "^0.4.13",
41
- "@gradio/multimodaltextbox": "^0.5.7",
42
- "@gradio/paramviewer": "^0.4.22",
43
- "@gradio/radio": "^0.5.13",
44
- "@gradio/plot": "^0.6.5",
45
- "@gradio/row": "^0.1.5",
46
- "@gradio/simpledropdown": "^0.2.13",
47
- "@gradio/simpleimage": "^0.7.1",
48
- "@gradio/simpletextbox": "^0.2.13",
49
- "@gradio/slider": "^0.4.13",
6
+ "@gradio/accordion": "^0.3.23-beta.2",
7
+ "@gradio/atoms": "^0.9.0-beta.2",
8
+ "@gradio/annotatedimage": "^0.8.0-beta.2",
9
+ "@gradio/audio": "^0.14.0-beta.2",
10
+ "@gradio/box": "^0.2.0-beta.0",
11
+ "@gradio/button": "^0.3.0-beta.2",
12
+ "@gradio/checkbox": "^0.4.0-beta.2",
13
+ "@gradio/chatbot": "^0.14.0-beta.2",
14
+ "@gradio/checkboxgroup": "^0.6.0-beta.2",
15
+ "@gradio/client": "^1.6.0-beta.2",
16
+ "@gradio/code": "^0.10.0-beta.2",
17
+ "@gradio/dataframe": "^0.11.0-beta.2",
18
+ "@gradio/colorpicker": "^0.3.13-beta.2",
19
+ "@gradio/column": "^0.2.0-beta.0",
20
+ "@gradio/dataset": "^0.2.5-beta.2",
21
+ "@gradio/downloadbutton": "^0.1.28-beta.2",
22
+ "@gradio/dropdown": "^0.7.13-beta.2",
23
+ "@gradio/fallback": "^0.3.13-beta.2",
24
+ "@gradio/datetime": "^0.1.4-beta.2",
25
+ "@gradio/fileexplorer": "^0.5.0-beta.2",
26
+ "@gradio/file": "^0.10.0-beta.2",
27
+ "@gradio/form": "^0.1.25-beta.2",
28
+ "@gradio/gallery": "^0.13.0-beta.2",
29
+ "@gradio/group": "^0.2.0-beta.1",
30
+ "@gradio/highlightedtext": "^0.7.7-beta.2",
31
+ "@gradio/html": "^0.4.0-beta.2",
32
+ "@gradio/icons": "^0.8.0-beta.2",
33
+ "@gradio/image": "^0.16.0-beta.2",
34
+ "@gradio/json": "^0.5.0-beta.2",
35
+ "@gradio/imageeditor": "^0.11.0-beta.2",
36
+ "@gradio/model3d": "^0.13.0-beta.2",
37
+ "@gradio/label": "^0.3.13-beta.2",
38
+ "@gradio/multimodaltextbox": "^0.6.0-beta.2",
39
+ "@gradio/markdown": "^0.10.0-beta.2",
40
+ "@gradio/nativeplot": "^0.4.0-beta.2",
41
+ "@gradio/paramviewer": "^0.4.22-beta.2",
42
+ "@gradio/plot": "^0.6.5-beta.2",
43
+ "@gradio/number": "^0.4.13-beta.2",
44
+ "@gradio/row": "^0.2.0-beta.1",
45
+ "@gradio/radio": "^0.6.0-beta.2",
46
+ "@gradio/simpledropdown": "^0.2.13-beta.2",
47
+ "@gradio/simpleimage": "^0.8.0-beta.2",
48
+ "@gradio/simpletextbox": "^0.2.13-beta.2",
49
+ "@gradio/slider": "^0.5.0-beta.2",
50
+ "@gradio/statustracker": "^0.8.0-beta.2",
51
+ "@gradio/tabitem": "^0.3.0-beta.2",
50
52
  "@gradio/state": "^0.1.2",
51
- "@gradio/statustracker": "^0.7.6",
52
- "@gradio/tabitem": "^0.2.15",
53
- "@gradio/tabs": "^0.2.14",
54
- "@gradio/theme": "^0.2.5",
55
- "@gradio/textbox": "^0.7.0",
56
- "@gradio/timer": "^0.3.3",
57
- "@gradio/upload": "^0.12.4",
58
- "@gradio/uploadbutton": "^0.6.19",
59
- "@gradio/utils": "^0.6.1",
60
- "@gradio/video": "^0.10.4",
61
- "@gradio/wasm": "^0.13.1"
53
+ "@gradio/tabs": "^0.3.0-beta.2",
54
+ "@gradio/textbox": "^0.7.0-beta.2",
55
+ "@gradio/timer": "^0.3.3-beta.2",
56
+ "@gradio/theme": "^0.3.0-beta.1",
57
+ "@gradio/upload": "^0.13.0-beta.2",
58
+ "@gradio/uploadbutton": "^0.7.0-beta.2",
59
+ "@gradio/utils": "^0.7.0-beta.2",
60
+ "@gradio/video": "^0.11.0-beta.2",
61
+ "@gradio/wasm": "^0.14.0-beta.2"
62
62
  },
63
63
  "msw": {
64
64
  "workerDirectory": "public"