@gradio/core 0.0.2 → 0.0.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 +30 -0
- package/dist/blocks.d.ts +1 -0
- package/dist/blocks.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/login.d.ts +1 -0
- package/dist/login.js +1 -0
- package/dist/src/Blocks.svelte +671 -0
- package/dist/src/Blocks.svelte.d.ts +41 -0
- package/dist/src/Embed.svelte +195 -0
- package/dist/src/Embed.svelte.d.ts +26 -0
- package/dist/src/Login.svelte +107 -0
- package/dist/src/Login.svelte.d.ts +19 -0
- package/dist/src/MountComponents.svelte +26 -0
- package/dist/src/MountComponents.svelte.d.ts +26 -0
- package/dist/src/Render.svelte +91 -0
- package/dist/src/Render.svelte.d.ts +29 -0
- package/dist/src/RenderComponent.svelte +51 -0
- package/dist/src/RenderComponent.svelte.d.ts +32 -0
- package/dist/src/api_docs/ApiBanner.svelte +115 -0
- package/dist/src/api_docs/ApiBanner.svelte.d.ts +19 -0
- package/dist/src/api_docs/ApiDocs.svelte +388 -0
- package/dist/src/api_docs/ApiDocs.svelte.d.ts +27 -0
- package/dist/src/api_docs/ApiRecorder.svelte +72 -0
- package/dist/src/api_docs/ApiRecorder.svelte.d.ts +18 -0
- package/dist/src/api_docs/CodeSnippet.svelte +184 -0
- package/dist/src/api_docs/CodeSnippet.svelte.d.ts +24 -0
- package/dist/src/api_docs/CopyButton.svelte +15 -0
- package/dist/src/api_docs/CopyButton.svelte.d.ts +16 -0
- package/dist/src/api_docs/EndpointDetail.svelte +36 -0
- package/dist/src/api_docs/EndpointDetail.svelte.d.ts +18 -0
- package/dist/src/api_docs/InputPayload.svelte +149 -0
- package/dist/src/api_docs/InputPayload.svelte.d.ts +24 -0
- package/dist/src/api_docs/InstallSnippet.svelte +56 -0
- package/dist/src/api_docs/InstallSnippet.svelte.d.ts +16 -0
- package/dist/src/api_docs/NoApi.svelte +71 -0
- package/dist/src/api_docs/NoApi.svelte.d.ts +18 -0
- package/dist/src/api_docs/ParametersSnippet.svelte +104 -0
- package/dist/src/api_docs/ParametersSnippet.svelte.d.ts +19 -0
- package/dist/src/api_docs/RecordingSnippet.svelte +210 -0
- package/dist/src/api_docs/RecordingSnippet.svelte.d.ts +22 -0
- package/dist/src/api_docs/ResponseSnippet.svelte +95 -0
- package/dist/src/api_docs/ResponseSnippet.svelte.d.ts +19 -0
- package/dist/src/api_docs/TryButton.svelte +17 -0
- package/dist/src/api_docs/TryButton.svelte.d.ts +17 -0
- package/dist/src/api_docs/img/api-logo.svg +4 -0
- package/dist/src/api_docs/img/bash.svg +8 -0
- package/dist/src/api_docs/img/clear.svelte +19 -0
- package/dist/src/api_docs/img/clear.svelte.d.ts +23 -0
- package/dist/src/api_docs/img/javascript.svg +16 -0
- package/dist/src/api_docs/img/python.svg +20 -0
- package/dist/src/api_docs/index.d.ts +2 -0
- package/dist/src/api_docs/index.js +2 -0
- package/dist/src/api_docs/utils.d.ts +2 -0
- package/dist/src/api_docs/utils.js +135 -0
- package/dist/src/css.d.ts +2 -0
- package/dist/src/css.js +93 -0
- package/dist/src/gradio_helper.js +4 -0
- package/dist/src/i18n.d.ts +6 -0
- package/dist/src/i18n.js +22 -0
- package/dist/src/images/lightning.svg +2 -0
- package/dist/src/images/logo.svg +19 -0
- package/dist/src/images/play.svg +2 -0
- package/dist/src/images/spaces.svg +7 -0
- package/dist/src/init.d.ts +107 -0
- package/dist/src/init.js +377 -0
- package/dist/src/lang/BCP47_codes.d.ts +2 -0
- package/dist/src/lang/BCP47_codes.js +58 -0
- package/dist/src/lang/ar.json +16 -0
- package/dist/src/lang/ca.json +19 -0
- package/dist/src/lang/ckb.json +108 -0
- package/dist/src/lang/de.json +16 -0
- package/dist/src/lang/en.json +118 -0
- package/dist/src/lang/es.json +17 -0
- package/dist/src/lang/eu.json +16 -0
- package/dist/src/lang/fa.json +16 -0
- package/dist/src/lang/fr.json +30 -0
- package/dist/src/lang/he.json +16 -0
- package/dist/src/lang/hi.json +16 -0
- package/dist/src/lang/ja.json +16 -0
- package/dist/src/lang/ko.json +16 -0
- package/dist/src/lang/lt.json +16 -0
- package/dist/src/lang/nl.json +16 -0
- package/dist/src/lang/pl.json +16 -0
- package/dist/src/lang/pt-BR.json +19 -0
- package/dist/src/lang/ru.json +118 -0
- package/dist/src/lang/ta.json +16 -0
- package/dist/src/lang/tr.json +16 -0
- package/dist/src/lang/uk.json +16 -0
- package/dist/src/lang/ur.json +16 -0
- package/dist/src/lang/uz.json +15 -0
- package/dist/src/lang/zh-CN.json +115 -0
- package/dist/src/lang/zh-TW.json +16 -0
- package/dist/src/s-blocks.d.ts +1 -0
- package/dist/src/s-blocks.js +1 -0
- package/dist/src/s-login.d.ts +1 -0
- package/dist/src/s-login.js +1 -0
- package/dist/src/stores.d.ts +30 -0
- package/dist/src/stores.js +93 -0
- package/dist/src/types.d.ts +95 -0
- package/dist/src/types.js +1 -0
- package/dist/src/vite-env-override.d.ts +20 -0
- package/package.json +71 -60
- package/src/Render.svelte +3 -1
- package/src/api_docs/ApiDocs.svelte +1 -1
- package/src/api_docs/ApiRecorder.svelte +1 -1
package/dist/src/init.js
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { writable, get } from "svelte/store";
|
|
2
|
+
import { load_component } from "virtual:component-loader";
|
|
3
|
+
import { create_loading_status_store } from "./stores";
|
|
4
|
+
import { _ } from "svelte-i18n";
|
|
5
|
+
let pending_updates = [];
|
|
6
|
+
/**
|
|
7
|
+
* Create a store with the layout and a map of targets
|
|
8
|
+
* @returns A store with the layout and a map of targets
|
|
9
|
+
*/
|
|
10
|
+
export function create_components() {
|
|
11
|
+
let _component_map;
|
|
12
|
+
let target_map = writable({});
|
|
13
|
+
let _target_map = {};
|
|
14
|
+
let inputs;
|
|
15
|
+
let outputs;
|
|
16
|
+
let constructor_map;
|
|
17
|
+
let instance_map;
|
|
18
|
+
let loading_status = create_loading_status_store();
|
|
19
|
+
const layout_store = writable();
|
|
20
|
+
let _components = [];
|
|
21
|
+
let app;
|
|
22
|
+
let keyed_component_values = {};
|
|
23
|
+
let _rootNode;
|
|
24
|
+
function create_layout({ app: _app, components, layout, dependencies, root, options }) {
|
|
25
|
+
app = _app;
|
|
26
|
+
store_keyed_values(_components);
|
|
27
|
+
_components = components;
|
|
28
|
+
inputs = new Set();
|
|
29
|
+
outputs = new Set();
|
|
30
|
+
pending_updates = [];
|
|
31
|
+
constructor_map = new Map();
|
|
32
|
+
_component_map = new Map();
|
|
33
|
+
instance_map = {};
|
|
34
|
+
_rootNode = {
|
|
35
|
+
id: layout.id,
|
|
36
|
+
type: "column",
|
|
37
|
+
props: { interactive: false, scale: options.fill_height ? 1 : null },
|
|
38
|
+
has_modes: false,
|
|
39
|
+
instance: null,
|
|
40
|
+
component: null,
|
|
41
|
+
component_class_id: "",
|
|
42
|
+
key: null
|
|
43
|
+
};
|
|
44
|
+
components.push(_rootNode);
|
|
45
|
+
dependencies.forEach((dep) => {
|
|
46
|
+
loading_status.register(dep.id, dep.inputs, dep.outputs);
|
|
47
|
+
dep.frontend_fn = process_frontend_fn(dep.js, !!dep.backend_fn, dep.inputs.length, dep.outputs.length);
|
|
48
|
+
create_target_meta(dep.targets, dep.id, _target_map);
|
|
49
|
+
get_inputs_outputs(dep, inputs, outputs);
|
|
50
|
+
});
|
|
51
|
+
target_map.set(_target_map);
|
|
52
|
+
constructor_map = preload_all_components(components, root);
|
|
53
|
+
instance_map = components.reduce((acc, c) => {
|
|
54
|
+
acc[c.id] = c;
|
|
55
|
+
return acc;
|
|
56
|
+
}, {});
|
|
57
|
+
walk_layout(layout, root).then(() => {
|
|
58
|
+
layout_store.set(_rootNode);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Rerender the layout when the config has been modified to attach new components
|
|
63
|
+
*/
|
|
64
|
+
function rerender_layout({ render_id, components, layout, root, dependencies }) {
|
|
65
|
+
let _constructor_map = preload_all_components(components, root);
|
|
66
|
+
_constructor_map.forEach((v, k) => {
|
|
67
|
+
constructor_map.set(k, v);
|
|
68
|
+
});
|
|
69
|
+
_target_map = {};
|
|
70
|
+
dependencies.forEach((dep) => {
|
|
71
|
+
loading_status.register(dep.id, dep.inputs, dep.outputs);
|
|
72
|
+
dep.frontend_fn = process_frontend_fn(dep.js, !!dep.backend_fn, dep.inputs.length, dep.outputs.length);
|
|
73
|
+
create_target_meta(dep.targets, dep.id, _target_map);
|
|
74
|
+
get_inputs_outputs(dep, inputs, outputs);
|
|
75
|
+
});
|
|
76
|
+
target_map.set(_target_map);
|
|
77
|
+
let current_element = instance_map[layout.id];
|
|
78
|
+
let all_current_children = [];
|
|
79
|
+
const add_to_current_children = (component) => {
|
|
80
|
+
all_current_children.push(component);
|
|
81
|
+
if (component.children) {
|
|
82
|
+
component.children.forEach((child) => {
|
|
83
|
+
add_to_current_children(child);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
add_to_current_children(current_element);
|
|
88
|
+
store_keyed_values(all_current_children);
|
|
89
|
+
Object.entries(instance_map).forEach(([id, component]) => {
|
|
90
|
+
let _id = Number(id);
|
|
91
|
+
if (component.rendered_in === render_id) {
|
|
92
|
+
delete instance_map[_id];
|
|
93
|
+
if (_component_map.has(_id)) {
|
|
94
|
+
_component_map.delete(_id);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
components.forEach((c) => {
|
|
99
|
+
instance_map[c.id] = c;
|
|
100
|
+
_component_map.set(c.id, c);
|
|
101
|
+
});
|
|
102
|
+
if (current_element.parent) {
|
|
103
|
+
current_element.parent.children[current_element.parent.children.indexOf(current_element)] = instance_map[layout.id];
|
|
104
|
+
}
|
|
105
|
+
walk_layout(layout, root, current_element.parent).then(() => {
|
|
106
|
+
layout_store.set(_rootNode);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
async function walk_layout(node, root, parent) {
|
|
110
|
+
const instance = instance_map[node.id];
|
|
111
|
+
instance.component = (await constructor_map.get(instance.component_class_id || instance.type))?.default;
|
|
112
|
+
instance.parent = parent;
|
|
113
|
+
if (instance.type === "dataset") {
|
|
114
|
+
instance.props.component_map = get_component(instance.type, instance.component_class_id, root, _components, instance.props.components).example_components;
|
|
115
|
+
}
|
|
116
|
+
if (_target_map[instance.id]) {
|
|
117
|
+
instance.props.attached_events = Object.keys(_target_map[instance.id]);
|
|
118
|
+
}
|
|
119
|
+
instance.props.interactive = determine_interactivity(instance.id, instance.props.interactive, instance.props.value, inputs, outputs);
|
|
120
|
+
instance.props.server = process_server_fn(instance.id, instance.props.server_fns, app);
|
|
121
|
+
if (instance.key != null &&
|
|
122
|
+
keyed_component_values[instance.key] !== undefined) {
|
|
123
|
+
instance.props.value = keyed_component_values[instance.key];
|
|
124
|
+
}
|
|
125
|
+
_component_map.set(instance.id, instance);
|
|
126
|
+
if (node.children) {
|
|
127
|
+
instance.children = await Promise.all(node.children.map((v) => walk_layout(v, root, instance)));
|
|
128
|
+
}
|
|
129
|
+
return instance;
|
|
130
|
+
}
|
|
131
|
+
let update_scheduled = false;
|
|
132
|
+
let update_scheduled_store = writable(false);
|
|
133
|
+
function store_keyed_values(components) {
|
|
134
|
+
components.forEach((c) => {
|
|
135
|
+
if (c.key != null) {
|
|
136
|
+
keyed_component_values[c.key] = c.props.value;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function flush() {
|
|
141
|
+
layout_store.update((layout) => {
|
|
142
|
+
for (let i = 0; i < pending_updates.length; i++) {
|
|
143
|
+
for (let j = 0; j < pending_updates[i].length; j++) {
|
|
144
|
+
const update = pending_updates[i][j];
|
|
145
|
+
if (!update)
|
|
146
|
+
continue;
|
|
147
|
+
const instance = instance_map[update.id];
|
|
148
|
+
if (!instance)
|
|
149
|
+
continue;
|
|
150
|
+
let new_value;
|
|
151
|
+
if (update.value instanceof Map)
|
|
152
|
+
new_value = new Map(update.value);
|
|
153
|
+
else if (update.value instanceof Set)
|
|
154
|
+
new_value = new Set(update.value);
|
|
155
|
+
else if (Array.isArray(update.value))
|
|
156
|
+
new_value = [...update.value];
|
|
157
|
+
else if (update.value === null)
|
|
158
|
+
new_value = null;
|
|
159
|
+
else if (typeof update.value === "object")
|
|
160
|
+
new_value = { ...update.value };
|
|
161
|
+
else
|
|
162
|
+
new_value = update.value;
|
|
163
|
+
instance.props[update.prop] = new_value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return layout;
|
|
167
|
+
});
|
|
168
|
+
pending_updates = [];
|
|
169
|
+
update_scheduled = false;
|
|
170
|
+
update_scheduled_store.set(false);
|
|
171
|
+
}
|
|
172
|
+
function update_value(updates) {
|
|
173
|
+
if (!updates)
|
|
174
|
+
return;
|
|
175
|
+
pending_updates.push(updates);
|
|
176
|
+
if (!update_scheduled) {
|
|
177
|
+
update_scheduled = true;
|
|
178
|
+
update_scheduled_store.set(true);
|
|
179
|
+
requestAnimationFrame(flush);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function get_data(id) {
|
|
183
|
+
const comp = _component_map.get(id);
|
|
184
|
+
if (!comp) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
if (comp.instance.get_value) {
|
|
188
|
+
return comp.instance.get_value();
|
|
189
|
+
}
|
|
190
|
+
return comp.props.value;
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
layout: layout_store,
|
|
194
|
+
targets: target_map,
|
|
195
|
+
update_value,
|
|
196
|
+
get_data,
|
|
197
|
+
loading_status,
|
|
198
|
+
scheduled_updates: update_scheduled_store,
|
|
199
|
+
create_layout: (...args) => requestAnimationFrame(() => create_layout(...args)),
|
|
200
|
+
rerender_layout
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/** An async version of 'new Function' */
|
|
204
|
+
export const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
|
|
205
|
+
/**
|
|
206
|
+
* Takes a string of source code and returns a function that can be called with arguments
|
|
207
|
+
* @param source the source code
|
|
208
|
+
* @param backend_fn if there is also a backend function
|
|
209
|
+
* @param input_length the number of inputs
|
|
210
|
+
* @param output_length the number of outputs
|
|
211
|
+
* @returns The function, or null if the source code is invalid or missing
|
|
212
|
+
*/
|
|
213
|
+
export function process_frontend_fn(source, backend_fn, input_length, output_length) {
|
|
214
|
+
if (!source)
|
|
215
|
+
return null;
|
|
216
|
+
const wrap = backend_fn ? input_length === 1 : output_length === 1;
|
|
217
|
+
try {
|
|
218
|
+
return new AsyncFunction("__fn_args", ` let result = await (${source})(...__fn_args);
|
|
219
|
+
if (typeof result === "undefined") return [];
|
|
220
|
+
return (${wrap} && !Array.isArray(result)) ? [result] : result;`);
|
|
221
|
+
}
|
|
222
|
+
catch (e) {
|
|
223
|
+
console.error("Could not parse custom js method.");
|
|
224
|
+
console.error(e);
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* `Dependency.targets` is an array of `[id, trigger]` pairs with the ids as the `fn_id`.
|
|
230
|
+
* This function take a single list of `Dependency.targets` and add those to the target_map.
|
|
231
|
+
* @param targets the targets array
|
|
232
|
+
* @param fn_id the function index
|
|
233
|
+
* @param target_map the target map
|
|
234
|
+
* @returns the tagert map
|
|
235
|
+
*/
|
|
236
|
+
export function create_target_meta(targets, fn_id, target_map) {
|
|
237
|
+
targets.forEach(([id, trigger]) => {
|
|
238
|
+
if (!target_map[id]) {
|
|
239
|
+
target_map[id] = {};
|
|
240
|
+
}
|
|
241
|
+
if (target_map[id]?.[trigger] &&
|
|
242
|
+
!target_map[id]?.[trigger].includes(fn_id)) {
|
|
243
|
+
target_map[id][trigger].push(fn_id);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
target_map[id][trigger] = [fn_id];
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
return target_map;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Get all component ids that are an input or output of a dependency
|
|
253
|
+
* @param dep the dependency
|
|
254
|
+
* @param inputs the set of inputs
|
|
255
|
+
* @param outputs the set of outputs
|
|
256
|
+
* @returns a tuple of the inputs and outputs
|
|
257
|
+
*/
|
|
258
|
+
export function get_inputs_outputs(dep, inputs, outputs) {
|
|
259
|
+
dep.inputs.forEach((input) => inputs.add(input));
|
|
260
|
+
dep.outputs.forEach((output) => outputs.add(output));
|
|
261
|
+
return [inputs, outputs];
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Check if a value is not a default value
|
|
265
|
+
* @param value the value to check
|
|
266
|
+
* @returns default value boolean
|
|
267
|
+
*/
|
|
268
|
+
function has_no_default_value(value) {
|
|
269
|
+
return ((Array.isArray(value) && value.length === 0) ||
|
|
270
|
+
value === "" ||
|
|
271
|
+
value === 0 ||
|
|
272
|
+
!value);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Determines if a component is interactive
|
|
276
|
+
* @param id component id
|
|
277
|
+
* @param interactive_prop value of the interactive prop
|
|
278
|
+
* @param value the main value of the component
|
|
279
|
+
* @param inputs set of ids that are inputs to a dependency
|
|
280
|
+
* @param outputs set of ids that are outputs to a dependency
|
|
281
|
+
* @returns if the component is interactive
|
|
282
|
+
*/
|
|
283
|
+
export function determine_interactivity(id, interactive_prop, value, inputs, outputs) {
|
|
284
|
+
if (interactive_prop === false) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
else if (interactive_prop === true) {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
else if (inputs.has(id) ||
|
|
291
|
+
(!outputs.has(id) && has_no_default_value(value))) {
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Process the server function names and return a dictionary of functions
|
|
298
|
+
* @param id the component id
|
|
299
|
+
* @param server_fns the server function names
|
|
300
|
+
* @param app the client instance
|
|
301
|
+
* @returns the actual server functions
|
|
302
|
+
*/
|
|
303
|
+
export function process_server_fn(id, server_fns, app) {
|
|
304
|
+
if (!server_fns) {
|
|
305
|
+
return {};
|
|
306
|
+
}
|
|
307
|
+
return server_fns.reduce((acc, fn) => {
|
|
308
|
+
acc[fn] = async (...args) => {
|
|
309
|
+
if (args.length === 1) {
|
|
310
|
+
args = args[0];
|
|
311
|
+
}
|
|
312
|
+
const result = await app.component_server(id, fn, args);
|
|
313
|
+
return result;
|
|
314
|
+
};
|
|
315
|
+
return acc;
|
|
316
|
+
}, {});
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Get a component from the backend
|
|
320
|
+
* @param type the type of the component
|
|
321
|
+
* @param class_id the class id of the component
|
|
322
|
+
* @param root the root url of the app
|
|
323
|
+
* @param components the list of component metadata
|
|
324
|
+
* @param example_components the list of example components
|
|
325
|
+
* @returns the component and its name
|
|
326
|
+
*/
|
|
327
|
+
export function get_component(type, class_id, root, components, example_components) {
|
|
328
|
+
let example_component_map = new Map();
|
|
329
|
+
if (type === "dataset" && example_components) {
|
|
330
|
+
example_components.forEach((name) => {
|
|
331
|
+
if (example_component_map.has(name)) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
let _c;
|
|
335
|
+
const matching_component = components.find((c) => c.type === name);
|
|
336
|
+
if (matching_component) {
|
|
337
|
+
_c = load_component({
|
|
338
|
+
api_url: root,
|
|
339
|
+
name,
|
|
340
|
+
id: matching_component.component_class_id,
|
|
341
|
+
variant: "example"
|
|
342
|
+
});
|
|
343
|
+
example_component_map.set(name, _c.component);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
const _c = load_component({
|
|
348
|
+
api_url: root,
|
|
349
|
+
name: type,
|
|
350
|
+
id: class_id,
|
|
351
|
+
variant: "component"
|
|
352
|
+
});
|
|
353
|
+
return {
|
|
354
|
+
component: _c.component,
|
|
355
|
+
name: _c.name,
|
|
356
|
+
example_components: example_component_map.size > 0 ? example_component_map : undefined
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Preload all components
|
|
361
|
+
* @param components A list of component metadata
|
|
362
|
+
* @param root The root url of the app
|
|
363
|
+
* @returns A map of component ids to their constructors
|
|
364
|
+
*/
|
|
365
|
+
export function preload_all_components(components, root) {
|
|
366
|
+
let constructor_map = new Map();
|
|
367
|
+
components.forEach((c) => {
|
|
368
|
+
const { component, example_components } = get_component(c.type, c.component_class_id, root, components);
|
|
369
|
+
constructor_map.set(c.component_class_id || c.type, component);
|
|
370
|
+
if (example_components) {
|
|
371
|
+
for (const [name, example_component] of example_components) {
|
|
372
|
+
constructor_map.set(name, example_component);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
return constructor_map;
|
|
377
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// BCP47 locales are used to identify language variants + are composed of a ISO 639x language code and a region code
|
|
2
|
+
const BCP47_codes = [
|
|
3
|
+
"ar-SA",
|
|
4
|
+
"bn-BD",
|
|
5
|
+
"bn-IN",
|
|
6
|
+
"cs-CZ",
|
|
7
|
+
"da-DK",
|
|
8
|
+
"de-AT",
|
|
9
|
+
"de-CH",
|
|
10
|
+
"de-DE",
|
|
11
|
+
"el-GR",
|
|
12
|
+
"en-AU",
|
|
13
|
+
"en-CA",
|
|
14
|
+
"en-GB",
|
|
15
|
+
"en-IE",
|
|
16
|
+
"en-IN",
|
|
17
|
+
"en-NZ",
|
|
18
|
+
"en-US",
|
|
19
|
+
"en-ZA",
|
|
20
|
+
"es-AR",
|
|
21
|
+
"es-CL",
|
|
22
|
+
"es-CO",
|
|
23
|
+
"es-ES",
|
|
24
|
+
"es-MX",
|
|
25
|
+
"es-US",
|
|
26
|
+
"fi-FI",
|
|
27
|
+
"fr-BE",
|
|
28
|
+
"fr-CA",
|
|
29
|
+
"fr-CH",
|
|
30
|
+
"fr-FR",
|
|
31
|
+
"he-IL",
|
|
32
|
+
"hi-IN",
|
|
33
|
+
"hu-HU",
|
|
34
|
+
"id-ID",
|
|
35
|
+
"it-CH",
|
|
36
|
+
"it-IT",
|
|
37
|
+
"ja-JP",
|
|
38
|
+
"ko-KR",
|
|
39
|
+
"nl-BE",
|
|
40
|
+
"nl-NL",
|
|
41
|
+
"no-NO",
|
|
42
|
+
"pl-PL",
|
|
43
|
+
"pt-BR",
|
|
44
|
+
"pt-PT",
|
|
45
|
+
"ro-RO",
|
|
46
|
+
"ru-RU",
|
|
47
|
+
"sk-SK",
|
|
48
|
+
"sv-SE",
|
|
49
|
+
"ta-IN",
|
|
50
|
+
"ta-LK",
|
|
51
|
+
"th-TH",
|
|
52
|
+
"tr-TR",
|
|
53
|
+
"zh-CN",
|
|
54
|
+
"zh-HK",
|
|
55
|
+
"zh-TW"
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
export default BCP47_codes;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"common": {
|
|
3
|
+
"built_with_gradio": "تم الإنشاء بإستخدام Gradio",
|
|
4
|
+
"clear": "أمسح",
|
|
5
|
+
"or": "أو",
|
|
6
|
+
"submit": "أرسل"
|
|
7
|
+
},
|
|
8
|
+
"upload_text": {
|
|
9
|
+
"click_to_upload": "إضغط للتحميل",
|
|
10
|
+
"drop_audio": "أسقط الملف الصوتي هنا",
|
|
11
|
+
"drop_csv": "أسقط ملف البيانات هنا",
|
|
12
|
+
"drop_file": "أسقط الملف هنا",
|
|
13
|
+
"drop_image": "أسقط الصورة هنا",
|
|
14
|
+
"drop_video": "أسقط الفيديو هنا"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"common": {
|
|
3
|
+
"built_with_gradio": "Construït amb gradio",
|
|
4
|
+
"clear": "Neteja",
|
|
5
|
+
"empty": "Buit",
|
|
6
|
+
"error": "Error",
|
|
7
|
+
"loading": "S'està carregant",
|
|
8
|
+
"or": "o",
|
|
9
|
+
"submit": "Envia"
|
|
10
|
+
},
|
|
11
|
+
"upload_text": {
|
|
12
|
+
"click_to_upload": "Feu clic per pujar",
|
|
13
|
+
"drop_audio": "Deixeu anar l'àudio aquí",
|
|
14
|
+
"drop_csv": "Deixeu anar el CSV aquí",
|
|
15
|
+
"drop_file": "Deixeu anar el fitxer aquí",
|
|
16
|
+
"drop_image": "Deixeu anar la imatge aquí",
|
|
17
|
+
"drop_video": "Deixeu anar el vídeo aquí"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"3D_model": {
|
|
3
|
+
"3d_model": "مۆدێلی سێ ڕەهەندی"
|
|
4
|
+
},
|
|
5
|
+
"annotated_image": {
|
|
6
|
+
"annotated_image": "وێنەی نیشانە کراو"
|
|
7
|
+
},
|
|
8
|
+
"audio": {
|
|
9
|
+
"allow_recording_access": "تکایە ڕێگە بدە بە بەکارهێنانی مایکرۆفۆنەکە بۆ تۆمارکردن.",
|
|
10
|
+
"audio": "دەنگ",
|
|
11
|
+
"record_from_microphone": "تۆمارکردن لە مایکەوە",
|
|
12
|
+
"stop_recording": "تۆمارکردن بوەستێنە"
|
|
13
|
+
},
|
|
14
|
+
"blocks": {
|
|
15
|
+
"connection_can_break": "لە مۆبایلدا، پەیوەندییەکە دەکرێت بپچڕێت ئەگەر ئەم تابە چالاک نەبێت یان ئامێرەکە بچێتە دۆخی پشوو، ئەمەش شوێنی خۆت لە ڕیزدا لەدەست دەدات.",
|
|
16
|
+
"long_requests_queue": "ڕیزێکی درێژی داواکاری هەیە. ئەم سپەیسە دووباد بکە بۆی چاوەڕوان نەبیت.",
|
|
17
|
+
"lost_connection": "پەیوەندی پچڕا بەهۆی جێهێشتنی پەیج. "
|
|
18
|
+
},
|
|
19
|
+
"checkbox": {
|
|
20
|
+
"checkbox": "بۆکسی هەڵبژاردن",
|
|
21
|
+
"checkbox_group": "گروپی بۆکسی هەڵبژاردن"
|
|
22
|
+
},
|
|
23
|
+
"code": {
|
|
24
|
+
"code": "کۆد"
|
|
25
|
+
},
|
|
26
|
+
"color_picker": {
|
|
27
|
+
"color_picker": "ڕەنگ هەڵبژاردە"
|
|
28
|
+
},
|
|
29
|
+
"common": {
|
|
30
|
+
"built_with": "دروستکراوە لەگەڵ...",
|
|
31
|
+
"built_with_gradio": "Gradio دروستکراوە بە",
|
|
32
|
+
"clear": "خاوێنکردنەوە",
|
|
33
|
+
"download": "دابەزاندن",
|
|
34
|
+
"edit": "بژارکردن",
|
|
35
|
+
"empty": "بەتاڵ",
|
|
36
|
+
"error": "هەڵە",
|
|
37
|
+
"hosted_on": "میوانداری کراوە لە",
|
|
38
|
+
"loading": "بارکردن",
|
|
39
|
+
"logo": "لۆگۆ",
|
|
40
|
+
"or": "یان",
|
|
41
|
+
"remove": "لابردن",
|
|
42
|
+
"share": "هاوبەشکردن",
|
|
43
|
+
"submit": "پێشکەشکردن",
|
|
44
|
+
"undo": "پووچکردنەوە"
|
|
45
|
+
},
|
|
46
|
+
"dataframe": {
|
|
47
|
+
"incorrect_format": "فۆرماتێکی هەڵە، تەنها فایلەکانی CSV و TSV پشتگیری دەکرێن",
|
|
48
|
+
"new_column": "ستوونی نوێ",
|
|
49
|
+
"new_row": "ڕیزێکی نوێ"
|
|
50
|
+
},
|
|
51
|
+
"dropdown": {
|
|
52
|
+
"dropdown": "فڕێدانە خوار"
|
|
53
|
+
},
|
|
54
|
+
"errors": {
|
|
55
|
+
"build_error": "هەڵەی دروستکردن هەیە",
|
|
56
|
+
"config_error": "هەڵەی ڕێکخستن هەیە",
|
|
57
|
+
"contact_page_author": "تکایە پەیوەندی بە نووسەری پەیجەوە بکەن بۆ ئەوەی ئاگاداریان بکەنەوە.",
|
|
58
|
+
"no_app_file": "هیچ فایلێکی ئەپ نییە",
|
|
59
|
+
"runtime_error": "هەڵەیەکی runtime هەیە",
|
|
60
|
+
"space_not_working": "\"سپەیسەکە کارناکات چونکە\" {0}",
|
|
61
|
+
"space_paused": "فەزاکە وەستاوە",
|
|
62
|
+
"use_via_api": "لە ڕێگەی API بەکاری بهێنە"
|
|
63
|
+
},
|
|
64
|
+
"file": {
|
|
65
|
+
"uploading": "بارکردن..."
|
|
66
|
+
},
|
|
67
|
+
"highlighted_text": {
|
|
68
|
+
"highlighted_text": "دەقی ڕۆشن کراو"
|
|
69
|
+
},
|
|
70
|
+
"image": {
|
|
71
|
+
"allow_webcam_access": "تکایە ڕێگە بدە بە بەکارهێنانی وێبکامەکە بۆ تۆمارکردن.",
|
|
72
|
+
"brush_color": "ڕەنگی فڵچە",
|
|
73
|
+
"brush_radius": "تیژڕەوی فڵچە",
|
|
74
|
+
"image": "وێنە",
|
|
75
|
+
"remove_image": "لابردنی وێنە",
|
|
76
|
+
"select_brush_color": "ڕەنگی فڵچە هەڵبژێرە",
|
|
77
|
+
"start_drawing": "دەست بکە بە وێنەکێشان",
|
|
78
|
+
"use_brush": "فڵچە بەکاربهێنە"
|
|
79
|
+
},
|
|
80
|
+
"label": {
|
|
81
|
+
"label": "لەیبڵ"
|
|
82
|
+
},
|
|
83
|
+
"login": {
|
|
84
|
+
"enable_cookies": "ئەگەر تۆ سەردانی HuggingFace Space دەکەیت لە دۆخی نادیاردا، پێویستە کووکی لایەنی سێیەم چالاک بکەیت.",
|
|
85
|
+
"incorrect_credentials": "بڕوانامەی هەڵە",
|
|
86
|
+
"login": "چونه ژوورهوه"
|
|
87
|
+
},
|
|
88
|
+
"number": {
|
|
89
|
+
"number": "ژمارە"
|
|
90
|
+
},
|
|
91
|
+
"plot": {
|
|
92
|
+
"plot": "هێڵکاری"
|
|
93
|
+
},
|
|
94
|
+
"radio": {
|
|
95
|
+
"radio": "ڕادیۆ"
|
|
96
|
+
},
|
|
97
|
+
"slider": {
|
|
98
|
+
"slider": "خلیسکە"
|
|
99
|
+
},
|
|
100
|
+
"upload_text": {
|
|
101
|
+
"click_to_upload": "کلیک بکە بۆ بارکردن",
|
|
102
|
+
"drop_audio": "دەنگ لێرە دابنێ",
|
|
103
|
+
"drop_csv": "لێرەدا CSV دابنێ",
|
|
104
|
+
"drop_file": "فایل لێرە دابنێ",
|
|
105
|
+
"drop_image": "وێنە لێرەدا دابنێ",
|
|
106
|
+
"drop_video": "ڤیدیۆ لێرە دابنێ"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"common": {
|
|
3
|
+
"built_with_gradio": "Mit Gradio erstellt",
|
|
4
|
+
"clear": "Löschen",
|
|
5
|
+
"or": "oder",
|
|
6
|
+
"submit": "Absenden"
|
|
7
|
+
},
|
|
8
|
+
"upload_text": {
|
|
9
|
+
"click_to_upload": "Hochladen",
|
|
10
|
+
"drop_audio": "Audio hier ablegen",
|
|
11
|
+
"drop_csv": "CSV Datei hier ablegen",
|
|
12
|
+
"drop_file": "Datei hier ablegen",
|
|
13
|
+
"drop_image": "Bild hier ablegen",
|
|
14
|
+
"drop_video": "Video hier ablegen"
|
|
15
|
+
}
|
|
16
|
+
}
|