Upload folder using huggingface_hub
Browse files
6.22.0/paramviewer/ParamViewer.svelte
CHANGED
|
@@ -1,33 +1,34 @@
|
|
| 1 |
<script module lang="ts">
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
| 31 |
}
|
| 32 |
</script>
|
| 33 |
|
|
@@ -60,8 +61,23 @@
|
|
| 60 |
let component_root: HTMLElement;
|
| 61 |
let all_open = $state(false);
|
| 62 |
let lang: "python" | "typescript" = "python";
|
|
|
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
function create_slug(name: string, anchor_links: string | boolean): string {
|
| 67 |
let prefix = "param-";
|
|
@@ -72,8 +88,8 @@
|
|
| 72 |
}
|
| 73 |
|
| 74 |
function highlight(code: string, lang: "python" | "typescript"): string {
|
| 75 |
-
let highlighted =
|
| 76 |
-
?
|
| 77 |
: code;
|
| 78 |
|
| 79 |
for (const link of linkify) {
|
|
@@ -88,7 +104,8 @@
|
|
| 88 |
|
| 89 |
function highlight_code(
|
| 90 |
_docs: typeof docs,
|
| 91 |
-
lang: "python" | "typescript"
|
|
|
|
| 92 |
): Param[] {
|
| 93 |
if (!_docs) {
|
| 94 |
return [];
|
|
|
|
| 1 |
<script module lang="ts">
|
| 2 |
+
type PrismApi = typeof import("prismjs");
|
| 3 |
+
|
| 4 |
+
let prism: PrismApi | null = null;
|
| 5 |
+
let prism_languages: Promise<PrismApi> | null = null;
|
| 6 |
+
|
| 7 |
+
function load_prism_languages(): Promise<PrismApi> {
|
| 8 |
+
if (prism_languages) return prism_languages;
|
| 9 |
+
|
| 10 |
+
prism_languages = (async () => {
|
| 11 |
+
// Prism checks this pre-existing global while its module evaluates.
|
| 12 |
+
// Manual mode prevents its scheduled highlightAll() from rewriting
|
| 13 |
+
// Svelte's hydration markers before the grammars are ready.
|
| 14 |
+
(globalThis as any).Prism = { manual: true };
|
| 15 |
+
const prism_module = await import("prismjs");
|
| 16 |
+
const loaded_prism =
|
| 17 |
+
(
|
| 18 |
+
prism_module as unknown as {
|
| 19 |
+
default?: PrismApi;
|
| 20 |
+
}
|
| 21 |
+
).default ?? (prism_module as PrismApi);
|
| 22 |
+
loaded_prism.manual = true;
|
| 23 |
+
(globalThis as any).Prism = loaded_prism;
|
| 24 |
+
// @ts-expect-error Prism component modules do not ship declarations.
|
| 25 |
+
await import("prismjs/components/prism-python");
|
| 26 |
+
// @ts-expect-error Prism component modules do not ship declarations.
|
| 27 |
+
await import("prismjs/components/prism-typescript");
|
| 28 |
+
prism = loaded_prism;
|
| 29 |
+
return loaded_prism;
|
| 30 |
+
})();
|
| 31 |
+
return prism_languages;
|
| 32 |
}
|
| 33 |
</script>
|
| 34 |
|
|
|
|
| 61 |
let component_root: HTMLElement;
|
| 62 |
let all_open = $state(false);
|
| 63 |
let lang: "python" | "typescript" = "python";
|
| 64 |
+
let prism_ready = $state(prism !== null);
|
| 65 |
|
| 66 |
+
$effect(() => {
|
| 67 |
+
let active = true;
|
| 68 |
+
load_prism_languages()
|
| 69 |
+
.then(() => {
|
| 70 |
+
if (active) prism_ready = true;
|
| 71 |
+
})
|
| 72 |
+
.catch((e) => {
|
| 73 |
+
console.error("failed to load Prism grammars", e);
|
| 74 |
+
});
|
| 75 |
+
return () => {
|
| 76 |
+
active = false;
|
| 77 |
+
};
|
| 78 |
+
});
|
| 79 |
+
|
| 80 |
+
let _docs = $derived(highlight_code(docs, lang, prism_ready));
|
| 81 |
|
| 82 |
function create_slug(name: string, anchor_links: string | boolean): string {
|
| 83 |
let prefix = "param-";
|
|
|
|
| 88 |
}
|
| 89 |
|
| 90 |
function highlight(code: string, lang: "python" | "typescript"): string {
|
| 91 |
+
let highlighted = prism?.languages[lang]
|
| 92 |
+
? prism.highlight(code, prism.languages[lang], lang)
|
| 93 |
: code;
|
| 94 |
|
| 95 |
for (const link of linkify) {
|
|
|
|
| 104 |
|
| 105 |
function highlight_code(
|
| 106 |
_docs: typeof docs,
|
| 107 |
+
lang: "python" | "typescript",
|
| 108 |
+
_prism_ready: boolean
|
| 109 |
): Param[] {
|
| 110 |
if (!_docs) {
|
| 111 |
return [];
|
6.22.0/paramviewer/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/paramviewer",
|
| 3 |
-
"version": "0.
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/paramviewer",
|
| 3 |
+
"version": "0.12.0",
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|