Upload folder using huggingface_hub
Browse files
6.0.0-dev.6/html/Index.svelte
CHANGED
|
@@ -76,6 +76,7 @@
|
|
| 76 |
visible={gradio.shared.visible}
|
| 77 |
autoscroll={gradio.shared.autoscroll}
|
| 78 |
apply_default_css={gradio.props.apply_default_css}
|
|
|
|
| 79 |
on:event={(e) => {
|
| 80 |
gradio.dispatch(e.detail.type, e.detail.data);
|
| 81 |
}}
|
|
|
|
| 76 |
visible={gradio.shared.visible}
|
| 77 |
autoscroll={gradio.shared.autoscroll}
|
| 78 |
apply_default_css={gradio.props.apply_default_css}
|
| 79 |
+
component_class_name={gradio.props.component_class_name}
|
| 80 |
on:event={(e) => {
|
| 81 |
gradio.dispatch(e.detail.type, e.detail.data);
|
| 82 |
}}
|
6.0.0-dev.6/html/shared/HTML.svelte
CHANGED
|
@@ -10,7 +10,8 @@
|
|
| 10 |
js_on_load = null,
|
| 11 |
visible = true,
|
| 12 |
autoscroll = false,
|
| 13 |
-
apply_default_css = true
|
|
|
|
| 14 |
} = $props();
|
| 15 |
|
| 16 |
let old_props = $state(props);
|
|
@@ -36,6 +37,7 @@
|
|
| 36 |
let currentCss = $state("");
|
| 37 |
let renderScheduled = $state(false);
|
| 38 |
let mounted = $state(false);
|
|
|
|
| 39 |
|
| 40 |
function get_scrollable_parent(element: HTMLElement): HTMLElement | null {
|
| 41 |
let parent = element.parentElement;
|
|
@@ -102,10 +104,12 @@
|
|
| 102 |
...propKeys,
|
| 103 |
`return \`${handlebarsRendered}\`;`
|
| 104 |
);
|
|
|
|
| 105 |
return templateFunc(...propValues);
|
| 106 |
} catch (e) {
|
| 107 |
console.error("Error evaluating template:", e);
|
| 108 |
-
|
|
|
|
| 109 |
}
|
| 110 |
}
|
| 111 |
|
|
@@ -314,17 +318,54 @@
|
|
| 314 |
});
|
| 315 |
</script>
|
| 316 |
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
|
| 326 |
<style>
|
| 327 |
.hide {
|
| 328 |
display: none;
|
| 329 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
</style>
|
|
|
|
| 10 |
js_on_load = null,
|
| 11 |
visible = true,
|
| 12 |
autoscroll = false,
|
| 13 |
+
apply_default_css = true,
|
| 14 |
+
component_class_name = "HTML"
|
| 15 |
} = $props();
|
| 16 |
|
| 17 |
let old_props = $state(props);
|
|
|
|
| 37 |
let currentCss = $state("");
|
| 38 |
let renderScheduled = $state(false);
|
| 39 |
let mounted = $state(false);
|
| 40 |
+
let error_message: string | null = $state(null);
|
| 41 |
|
| 42 |
function get_scrollable_parent(element: HTMLElement): HTMLElement | null {
|
| 43 |
let parent = element.parentElement;
|
|
|
|
| 104 |
...propKeys,
|
| 105 |
`return \`${handlebarsRendered}\`;`
|
| 106 |
);
|
| 107 |
+
error_message = null;
|
| 108 |
return templateFunc(...propValues);
|
| 109 |
} catch (e) {
|
| 110 |
console.error("Error evaluating template:", e);
|
| 111 |
+
error_message = e instanceof Error ? e.message : String(e);
|
| 112 |
+
return "";
|
| 113 |
}
|
| 114 |
}
|
| 115 |
|
|
|
|
| 318 |
});
|
| 319 |
</script>
|
| 320 |
|
| 321 |
+
{#if error_message}
|
| 322 |
+
<div class="error-container">
|
| 323 |
+
<strong class="error-title"
|
| 324 |
+
>Error rendering <code class="error-component-name"
|
| 325 |
+
>{component_class_name}</code
|
| 326 |
+
>:</strong
|
| 327 |
+
>
|
| 328 |
+
<code class="error-message">{error_message}</code>
|
| 329 |
+
</div>
|
| 330 |
+
{:else}
|
| 331 |
+
<div
|
| 332 |
+
bind:this={element}
|
| 333 |
+
id={random_id}
|
| 334 |
+
class="{apply_default_css ? 'prose gradio-style' : ''} {elem_classes.join(
|
| 335 |
+
' '
|
| 336 |
+
)}"
|
| 337 |
+
class:hide={!visible}
|
| 338 |
+
></div>
|
| 339 |
+
{/if}
|
| 340 |
|
| 341 |
<style>
|
| 342 |
.hide {
|
| 343 |
display: none;
|
| 344 |
}
|
| 345 |
+
|
| 346 |
+
.error-container {
|
| 347 |
+
padding: 12px;
|
| 348 |
+
background-color: #fee;
|
| 349 |
+
border: 1px solid #fcc;
|
| 350 |
+
border-radius: 4px;
|
| 351 |
+
color: #c33;
|
| 352 |
+
font-family: monospace;
|
| 353 |
+
font-size: 13px;
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
.error-title {
|
| 357 |
+
display: block;
|
| 358 |
+
margin-bottom: 8px;
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
.error-component-name {
|
| 362 |
+
background-color: #fdd;
|
| 363 |
+
padding: 2px 4px;
|
| 364 |
+
border-radius: 2px;
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
.error-message {
|
| 368 |
+
white-space: pre-wrap;
|
| 369 |
+
word-break: break-word;
|
| 370 |
+
}
|
| 371 |
</style>
|
6.0.0-dev.6/html/types.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface HTMLProps {
|
|
| 8 |
min_height: number | undefined;
|
| 9 |
max_height: number | undefined;
|
| 10 |
props: Record<string, any>;
|
|
|
|
| 11 |
}
|
| 12 |
|
| 13 |
export interface HTMLEvents {
|
|
|
|
| 8 |
min_height: number | undefined;
|
| 9 |
max_height: number | undefined;
|
| 10 |
props: Record<string, any>;
|
| 11 |
+
component_class_name: string;
|
| 12 |
}
|
| 13 |
|
| 14 |
export interface HTMLEvents {
|