gradio-pr-bot commited on
Commit
0e162c5
·
verified ·
1 Parent(s): a36ab56

Upload folder using huggingface_hub

Browse files
6.21.1/paramviewer/ParamViewer.svelte CHANGED
@@ -1,7 +1,34 @@
1
  <script module lang="ts">
2
- import * as Prism from "prismjs";
3
- import "prismjs/components/prism-python";
4
- import "prismjs/components/prism-typescript";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  </script>
6
 
7
  <script lang="ts">
 
1
  <script module lang="ts">
2
+ import Prism from "prismjs";
3
+
4
+ // `prismjs/components/*` are side-effect scripts: each does
5
+ // `Prism.languages.x = ...` against a bare global and declares no imports of
6
+ // its own, so nothing in the module graph orders them after prismjs. As
7
+ // *static* imports the bundler is free to hoist them into a chunk that
8
+ // evaluates before the assignment below, and rolldown compounds it by
9
+ // emitting prismjs as a lazily-invoked CommonJS factory — so importing it
10
+ // does not initialise it either, and `window.Prism` stayed undefined. Every
11
+ // docs page then died during hydration on `ReferenceError: Prism is not
12
+ // defined` (#13677).
13
+ //
14
+ // Dynamic imports are not hoisted, so the global below is guaranteed to be in
15
+ // place before any grammar runs.
16
+ (globalThis as any).Prism = Prism;
17
+
18
+ // Awaited here rather than gated behind a promise: the component must not
19
+ // render before the grammars are registered. prismjs schedules its own
20
+ // `highlightAll()` on a rAF as soon as it loads, and without a grammar
21
+ // `highlightElement` overwrites the element with `encode(textContent)` —
22
+ // which strips the server's highlighting *and* the hydration comments the
23
+ // `{@html}` blocks own. Anything derived later then repaints into detached
24
+ // nodes, so the types stay plain until the component is recreated.
25
+ try {
26
+ await import("prismjs/components/prism-python");
27
+ await import("prismjs/components/prism-typescript");
28
+ } catch (e) {
29
+ // `highlight` already falls back to plain text without a grammar.
30
+ console.error("failed to load Prism grammars", e);
31
+ }
32
  </script>
33
 
34
  <script lang="ts">
6.21.1/paramviewer/package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "@gradio/paramviewer",
3
- "version": "0.11.0",
4
  "description": "Gradio UI packages",
5
  "type": "module",
6
  "author": "",
 
1
  {
2
  "name": "@gradio/paramviewer",
3
+ "version": "0.11.1",
4
  "description": "Gradio UI packages",
5
  "type": "module",
6
  "author": "",