@gradio/core 0.27.1 → 0.28.0

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/src/Blocks.svelte +80 -2
  3. package/dist/src/Embed.svelte +45 -4
  4. package/dist/src/Embed.svelte.d.ts +1 -0
  5. package/dist/src/api_docs/ApiDocs.svelte +18 -3
  6. package/dist/src/api_docs/CodeSnippet.svelte +38 -36
  7. package/dist/src/api_docs/CodeSnippet.svelte.d.ts +1 -0
  8. package/dist/src/api_docs/EndpointDetail.svelte +23 -1
  9. package/dist/src/api_docs/EndpointDetail.svelte.d.ts +1 -0
  10. package/dist/src/api_docs/MCPSnippet.svelte +39 -0
  11. package/dist/src/api_docs/MCPSnippet.svelte.d.ts +3 -0
  12. package/dist/src/api_docs/utils.d.ts +2 -0
  13. package/dist/src/api_docs/utils.js +14 -0
  14. package/dist/src/i18n.d.ts +2 -1
  15. package/dist/src/i18n.js +3 -3
  16. package/dist/src/init.js +19 -15
  17. package/dist/src/lang/id.json +154 -0
  18. package/dist/src/navbar_store.d.ts +6 -0
  19. package/dist/src/navbar_store.js +2 -0
  20. package/dist/src/stores.d.ts +2 -0
  21. package/dist/src/stores.js +10 -0
  22. package/dist/src/stories/I18nMultiLanguageTest.stories.d.ts +0 -1
  23. package/dist/src/stories/I18nMultiLanguageTest.stories.js +1 -1
  24. package/package.json +57 -52
  25. package/src/Blocks.svelte +102 -2
  26. package/src/Embed.svelte +69 -4
  27. package/src/api_docs/ApiDocs.svelte +24 -3
  28. package/src/api_docs/CodeSnippet.svelte +38 -36
  29. package/src/api_docs/EndpointDetail.svelte +24 -1
  30. package/src/api_docs/MCPSnippet.svelte +40 -0
  31. package/src/api_docs/utils.ts +14 -0
  32. package/src/i18n.ts +5 -3
  33. package/src/init.ts +23 -15
  34. package/src/lang/id.json +154 -0
  35. package/src/navbar_store.ts +9 -0
  36. package/src/stores.ts +19 -0
  37. package/src/stories/I18nMultiLanguageTest.stories.ts +1 -1
package/src/init.ts CHANGED
@@ -12,6 +12,7 @@ import { load_component } from "virtual:component-loader";
12
12
  import type { client_return } from "@gradio/client";
13
13
  import { create_loading_status_store } from "./stores";
14
14
  import { _ } from "svelte-i18n";
15
+ import { i18n_marker } from "./i18n";
15
16
 
16
17
  export interface UpdateTransaction {
17
18
  id: number;
@@ -95,7 +96,7 @@ export function create_components(
95
96
  function set_event_specific_args(dependencies: Dependency[]): void {
96
97
  dependencies.forEach((dep) => {
97
98
  dep.targets.forEach((target) => {
98
- const instance = instance_map[target[0]];
99
+ const instance = instance_map?.[target[0]];
99
100
  if (instance && dep.event_specific_args?.length > 0) {
100
101
  dep.event_specific_args?.forEach((arg: string) => {
101
102
  instance.props[arg] = dep[arg as keyof Dependency];
@@ -257,7 +258,7 @@ export function create_components(
257
258
 
258
259
  target_map.set(_target_map);
259
260
 
260
- let current_element = instance_map[layout.id];
261
+ let current_element = instance_map?.[layout.id];
261
262
  let all_current_children: ComponentMeta[] = [];
262
263
  const add_to_current_children = (component: ComponentMeta): void => {
263
264
  all_current_children.push(component);
@@ -276,7 +277,7 @@ export function create_components(
276
277
  (c) => c.key === component.key
277
278
  );
278
279
  if (component.key != null && replacement_component !== undefined) {
279
- const instance = instance_map[component.id];
280
+ const instance = instance_map?.[component.id];
280
281
  for (const prop in replacement_component.props) {
281
282
  if (
282
283
  !(
@@ -289,7 +290,7 @@ export function create_components(
289
290
  }
290
291
  }
291
292
  } else {
292
- delete instance_map[_id];
293
+ if (instance_map) delete instance_map[_id];
293
294
  if (_component_map.has(_id)) {
294
295
  _component_map.delete(_id);
295
296
  }
@@ -298,17 +299,18 @@ export function create_components(
298
299
  });
299
300
 
300
301
  const components_to_add = new_components.concat(
301
- replacement_components.filter((c) => !instance_map[c.id])
302
+ replacement_components.filter((c) => !instance_map?.[c.id])
302
303
  );
303
304
 
304
305
  components_to_add.forEach((c) => {
305
306
  instance_map[c.id] = c;
307
+
306
308
  _component_map.set(c.id, c);
307
309
  });
308
310
  if (current_element.parent) {
309
311
  current_element.parent.children![
310
312
  current_element.parent.children!.indexOf(current_element)
311
- ] = instance_map[layout.id];
313
+ ] = instance_map?.[layout.id];
312
314
  }
313
315
 
314
316
  walk_layout(
@@ -332,7 +334,7 @@ export function create_components(
332
334
  components: ComponentMeta[],
333
335
  parent?: ComponentMeta
334
336
  ): Promise<ComponentMeta> {
335
- const instance = instance_map[node.id];
337
+ const instance = instance_map?.[node.id];
336
338
  if (!instance.component) {
337
339
  const constructor_key = instance.component_class_id || instance.type;
338
340
  let component_constructor = constructor_map.get(constructor_key);
@@ -379,10 +381,13 @@ export function create_components(
379
381
  );
380
382
  }
381
383
 
382
- if (instance.type === "tabs" && !instance.props.initial_tabs) {
384
+ if (
385
+ (instance.type === "tabs" && !instance.props.initial_tabs) ||
386
+ (instance.type === "walkthrough" && !instance.props.initial_tabs)
387
+ ) {
383
388
  const tab_items_props =
384
389
  node.children?.map((c, i) => {
385
- const instance = instance_map[c.id];
390
+ const instance = instance_map?.[c.id];
386
391
  instance.props.id ??= c.id;
387
392
  return {
388
393
  type: instance.type,
@@ -394,12 +399,15 @@ export function create_components(
394
399
  };
395
400
  }) || [];
396
401
 
402
+ const _type =
403
+ instance.type === "walkthrough" ? "walkthroughstep" : "tabitem";
404
+
397
405
  const child_tab_items = tab_items_props.filter(
398
- (child) => child.type === "tabitem"
406
+ (child) => child.type === _type
399
407
  );
400
408
 
401
409
  instance.props.initial_tabs = child_tab_items?.map((child) => ({
402
- label: child.props.label,
410
+ label: child.props.label.includes(i18n_marker) ? "" : child.props.label,
403
411
  id: child.props.id,
404
412
  visible:
405
413
  typeof child.props.visible === "boolean" ? child.props.visible : true,
@@ -408,9 +416,9 @@ export function create_components(
408
416
  }));
409
417
  }
410
418
 
411
- if (instance.type === "tabs") {
419
+ if (instance.type === "tabs" || instance.type === "walkthrough") {
412
420
  node.children?.forEach((c, i) => {
413
- const child = instance_map[c.id];
421
+ const child = instance_map?.[c.id];
414
422
  child.props.order = i;
415
423
  });
416
424
  }
@@ -476,7 +484,7 @@ export function create_components(
476
484
  function has_visibility_changes(updates: UpdateTransaction[][]): boolean {
477
485
  return updates.some((update_batch) =>
478
486
  update_batch.some((update) => {
479
- const instance = instance_map[update.id];
487
+ const instance = instance_map?.[update.id];
480
488
  if (!instance) return false;
481
489
 
482
490
  // Check for visibility property changes
@@ -510,7 +518,7 @@ export function create_components(
510
518
  for (let j = 0; j < pending_updates[i].length; j++) {
511
519
  const update = pending_updates[i][j];
512
520
  if (!update) continue;
513
- const instance = instance_map[update.id];
521
+ const instance = instance_map?.[update.id];
514
522
  if (!instance) continue;
515
523
  let new_value;
516
524
  const old_value = instance.props[update.prop];
@@ -0,0 +1,154 @@
1
+ {
2
+ "_name": "Bahasa Indonesia",
3
+ "3D_model": {
4
+ "3d_model": "Model 3D",
5
+ "drop_to_upload": "Letakkan file model 3D (.obj, .glb, .stl, .gltf, .splat, atau .ply) di sini untuk mengunggah"
6
+ },
7
+ "annotated_image": {
8
+ "annotated_image": "Gambar Beranotasi"
9
+ },
10
+ "audio": {
11
+ "allow_recording_access": "Mohon izinkan akses ke mikrofon untuk merekam.",
12
+ "audio": "Audio",
13
+ "record_from_microphone": "Rekam dari mikrofon",
14
+ "stop_recording": "Hentikan rekaman",
15
+ "no_device_support": "Perangkat media tidak dapat diakses. Pastikan Anda menjalankan dari sumber yang aman (https) atau localhost (atau Anda telah meneruskan sertifikat SSL yang valid ke ssl_verify), dan Anda telah mengizinkan akses browser ke perangkat Anda.",
16
+ "stop": "Berhenti",
17
+ "resume": "Lanjutkan",
18
+ "record": "Rekam",
19
+ "no_microphone": "Tidak ada mikrofon yang ditemukan",
20
+ "pause": "Jeda",
21
+ "play": "Putar",
22
+ "waiting": "Menunggu",
23
+ "drop_to_upload": "Letakkan file audio di sini untuk mengunggah"
24
+ },
25
+ "blocks": {
26
+ "connection_can_break": "Di perangkat seluler, koneksi dapat terputus jika tab ini tidak dalam fokus atau perangkat dalam mode tidur, sehingga Anda kehilangan posisi dalam antrian.",
27
+ "long_requests_queue": "Ada antrian panjang dari permintaan yang tertunda. Gandakan Ruang ini untuk melompati antrian.",
28
+ "lost_connection": "Koneksi terputus karena meninggalkan halaman. Bergabung kembali ke antrian...",
29
+ "waiting_for_inputs": "Menunggu file selesai diunggah, mohon coba lagi."
30
+ },
31
+ "checkbox": {
32
+ "checkbox": "Kotak centang",
33
+ "checkbox_group": "Grup kotak centang"
34
+ },
35
+ "code": {
36
+ "code": "Kode"
37
+ },
38
+ "color_picker": {
39
+ "color_picker": "Pemilih Warna"
40
+ },
41
+ "common": {
42
+ "built_with": "dibuat dengan",
43
+ "built_with_gradio": "Dibuat dengan Gradio",
44
+ "clear": "Bersihkan",
45
+ "download": "Unduh",
46
+ "edit": "Edit",
47
+ "empty": "Kosong",
48
+ "error": "Error",
49
+ "hosted_on": "Di-hosting di",
50
+ "loading": "Memuat",
51
+ "logo": "logo",
52
+ "or": "atau",
53
+ "remove": "Hapus",
54
+ "settings": "Pengaturan",
55
+ "share": "Bagikan",
56
+ "submit": "Kirim",
57
+ "undo": "Urungkan",
58
+ "no_devices": "Tidak ada perangkat yang ditemukan",
59
+ "language": "Bahasa",
60
+ "display_theme": "Tema Tampilan",
61
+ "pwa": "Aplikasi Web Progresif"
62
+ },
63
+ "dataframe": {
64
+ "incorrect_format": "Format salah, hanya file CSV dan TSV yang didukung",
65
+ "new_column": "Tambah kolom",
66
+ "new_row": "Baris baru",
67
+ "add_row_above": "Tambah baris di atas",
68
+ "add_row_below": "Tambah baris di bawah",
69
+ "add_column_left": "Tambah kolom ke kiri",
70
+ "add_column_right": "Tambah kolom ke kanan",
71
+ "delete_row": "Hapus baris",
72
+ "delete_column": "Hapus kolom",
73
+ "sort_column": "Urutkan kolom",
74
+ "sort_ascending": "Urutkan menaik",
75
+ "sort_descending": "Urutkan menurun",
76
+ "drop_to_upload": "Letakkan file CSV atau TSV di sini untuk mengimpor data ke dataframe",
77
+ "clear_sort": "Bersihkan pengurutan"
78
+ },
79
+ "dropdown": {
80
+ "dropdown": "Dropdown"
81
+ },
82
+ "errors": {
83
+ "build_error": "ada error saat membangun",
84
+ "config_error": "ada error konfigurasi",
85
+ "contact_page_author": "Mohon hubungi penulis halaman untuk memberitahu mereka.",
86
+ "no_app_file": "tidak ada file aplikasi",
87
+ "runtime_error": "ada error runtime",
88
+ "space_not_working": "\"Ruang tidak berfungsi karena\" {0}",
89
+ "space_paused": "ruang sedang dijeda",
90
+ "use_via_api": "Gunakan melalui API"
91
+ },
92
+ "file": {
93
+ "uploading": "Mengunggah..."
94
+ },
95
+ "highlighted_text": {
96
+ "highlighted_text": "Teks yang Disorot"
97
+ },
98
+ "image": {
99
+ "allow_webcam_access": "Mohon izinkan akses ke webcam untuk merekam.",
100
+ "brush_color": "Warna kuas",
101
+ "brush_radius": "Radius kuas",
102
+ "image": "Gambar",
103
+ "remove_image": "Hapus Gambar",
104
+ "select_brush_color": "Pilih warna kuas",
105
+ "start_drawing": "Mulai menggambar",
106
+ "use_brush": "Gunakan kuas",
107
+ "drop_to_upload": "Letakkan file gambar di sini untuk mengunggah"
108
+ },
109
+ "label": {
110
+ "label": "Label"
111
+ },
112
+ "login": {
113
+ "enable_cookies": "Jika Anda mengunjungi Ruang HuggingFace dalam mode Penyamaran, Anda harus mengaktifkan cookie pihak ketiga.",
114
+ "incorrect_credentials": "Kredensial salah",
115
+ "username": "nama pengguna",
116
+ "password": "kata sandi",
117
+ "login": "Masuk"
118
+ },
119
+ "number": {
120
+ "number": "Nomor"
121
+ },
122
+ "plot": {
123
+ "plot": "Plot"
124
+ },
125
+ "radio": {
126
+ "radio": "Tombol Radio"
127
+ },
128
+ "slider": {
129
+ "slider": "Penggeser"
130
+ },
131
+ "upload_text": {
132
+ "click_to_upload": "Klik untuk Mengunggah",
133
+ "drop_audio": "Letakkan Audio di Sini",
134
+ "drop_csv": "Letakkan CSV di Sini",
135
+ "drop_file": "Letakkan File di Sini",
136
+ "drop_image": "Letakkan Gambar di Sini",
137
+ "drop_video": "Letakkan Video di Sini",
138
+ "drop_gallery": "Letakkan Media di Sini",
139
+ "paste_clipboard": "Tempel dari Papan Klip"
140
+ },
141
+ "video": {
142
+ "drop_to_upload": "Letakkan file video di sini untuk mengunggah"
143
+ },
144
+ "chatbot": {
145
+ "edit": "Edit",
146
+ "retry": "Coba lagi",
147
+ "undo": "Urungkan",
148
+ "submit": "Kirim",
149
+ "cancel": "Batal",
150
+ "like": "Suka",
151
+ "dislike": "Tidak Suka",
152
+ "clear": "Bersihkan obrolan"
153
+ }
154
+ }
@@ -0,0 +1,9 @@
1
+ import { writable } from "svelte/store";
2
+
3
+ export interface NavbarConfig {
4
+ visible?: boolean;
5
+ main_page_name?: string | false;
6
+ value?: [string, string][] | null;
7
+ }
8
+
9
+ export const navbar_config = writable<NavbarConfig | null>(null);
package/src/stores.ts CHANGED
@@ -18,6 +18,7 @@ export interface LoadingStatus {
18
18
  unit: string | null;
19
19
  desc: string | null;
20
20
  }[];
21
+ validation_error?: string | null;
21
22
  }
22
23
 
23
24
  export type LoadingStatusCollection = Record<number, LoadingStatus>;
@@ -28,6 +29,10 @@ interface LoadingStatusStore {
28
29
  register: (index: number, inputs: number[], outputs: number[]) => void;
29
30
  get_status_for_fn: (i: number) => LoadingStatus["status"];
30
31
  get_inputs_to_update: () => Map<number, string>;
32
+ update_component_status: (
33
+ index: number,
34
+ status: Partial<LoadingStatus>
35
+ ) => void;
31
36
  }
32
37
 
33
38
  export function create_loading_status_store(): LoadingStatusStore {
@@ -152,8 +157,22 @@ export function create_loading_status_store(): LoadingStatusStore {
152
157
  fn_outputs[index] = outputs;
153
158
  }
154
159
 
160
+ function update_component_status(
161
+ index: number,
162
+ status: Partial<LoadingStatus>
163
+ ): void {
164
+ store.update((outputs: LoadingStatusCollection) => {
165
+ outputs[index] = {
166
+ ...outputs[index],
167
+ ...status
168
+ };
169
+ return outputs;
170
+ });
171
+ }
172
+
155
173
  return {
156
174
  update,
175
+ update_component_status,
157
176
  register,
158
177
  subscribe: store.subscribe,
159
178
  get_status_for_fn(i: number) {
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from "@storybook/svelte";
2
2
  import I18nMultiLanguageTestComponent from "./I18nMultiLanguageTestComponent.svelte";
3
3
 
4
4
  const meta = {
5
- title: "Core/I18n Multi-Language Test",
5
+ // title: "Core/I18n Multi-Language Test",
6
6
  component: I18nMultiLanguageTestComponent,
7
7
  parameters: {
8
8
  layout: "centered"