svelte-streamdown 1.0.9 → 2.0.1

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/README.md +160 -143
  2. package/dist/Block.svelte +12 -72
  3. package/dist/Elements/Alert.svelte +1 -2
  4. package/dist/Elements/Code.svelte +7 -7
  5. package/dist/Elements/Code.svelte.d.ts +0 -2
  6. package/dist/Elements/Element.svelte +70 -25
  7. package/dist/Elements/FootnoteRef.svelte +19 -6
  8. package/dist/Elements/Image.svelte +1 -1
  9. package/dist/Elements/Link.svelte +1 -1
  10. package/dist/Elements/Math.svelte +13 -25
  11. package/dist/Elements/Math.svelte.d.ts +0 -2
  12. package/dist/Elements/Mermaid.svelte +105 -115
  13. package/dist/Elements/Mermaid.svelte.d.ts +0 -2
  14. package/dist/Elements/Table.svelte +1 -1
  15. package/dist/Streamdown.d.ts +52 -10
  16. package/dist/Streamdown.js +19 -1
  17. package/dist/Streamdown.svelte +3 -41
  18. package/dist/Streamdown.svelte.d.ts +1 -20
  19. package/dist/marked/index.d.ts +3 -20
  20. package/dist/marked/index.js +24 -19
  21. package/dist/marked/marked-alert.d.ts +2 -2
  22. package/dist/marked/marked-alert.js +7 -21
  23. package/dist/marked/marked-footnotes.js +2 -3
  24. package/dist/marked/marked-list.d.ts +2 -2
  25. package/dist/marked/marked-list.js +28 -11
  26. package/dist/marked/marked-math.js +1 -1
  27. package/dist/marked/marked-subsup.d.ts +1 -1
  28. package/dist/marked/marked-subsup.js +2 -1
  29. package/dist/marked/marked-table.d.ts +66 -0
  30. package/dist/marked/marked-table.js +495 -0
  31. package/dist/theme.d.ts +24 -6
  32. package/dist/theme.js +26 -14
  33. package/dist/utils/panzoom.svelte.d.ts +17 -18
  34. package/dist/utils/panzoom.svelte.js +0 -2
  35. package/dist/utils/useClickOutside.svelte.js +0 -1
  36. package/dist/utils/useKeyDown.svelte.js +4 -1
  37. package/package.json +1 -2
@@ -3,13 +3,12 @@
3
3
  import Link from './Link.svelte';
4
4
  import Code from './Code.svelte';
5
5
  import Image from './Image.svelte';
6
- import Table from './Table.svelte';
7
6
  import Mermaid from './Mermaid.svelte';
8
7
  import Math from './Math.svelte';
9
8
  import Alert from './Alert.svelte';
10
9
  import type { StreamdownToken } from '../marked/index.js';
11
10
  import Slot from './Slot.svelte';
12
- import { useStreamdown } from '../Streamdown.svelte';
11
+ import { useStreamdown } from '../Streamdown.js';
13
12
  import FootnoteRef from './FootnoteRef.svelte';
14
13
  let { token, children }: { token: StreamdownToken; children: Snippet } = $props();
15
14
  const id = $props.id();
@@ -43,9 +42,13 @@
43
42
  </blockquote>
44
43
  </Slot>
45
44
  {:else if token.type === 'code' && token.lang === 'mermaid'}
46
- <Mermaid {token} {children} />
45
+ <Slot props={{ children, token }} render={streamdown.snippets.code}>
46
+ <Mermaid {token} />
47
+ </Slot>
47
48
  {:else if token.type === 'code'}
48
- <Code {token} {children} />
49
+ <Slot props={{ children, token }} render={streamdown.snippets.code}>
50
+ <Code {token} />
51
+ </Slot>
49
52
  {:else if token.type === 'codespan'}
50
53
  <Slot props={{ children, token }} render={streamdown.snippets.codespan}>
51
54
  <code class={streamdown.theme.codespan.base}>
@@ -54,8 +57,6 @@
54
57
  </Slot>
55
58
  {:else if token.type === 'list'}
56
59
  {#if token.ordered}
57
- {@const firstItemValue = token.items[0]?.value || 1}
58
- {@const counterName = `counter-${id}`}
59
60
  <Slot props={{ children, token }} render={streamdown.snippets.ol}>
60
61
  <ol style:list-style-type={token.listType} class={streamdown.theme.ol.base}>
61
62
  {@render children()}
@@ -72,7 +73,7 @@
72
73
  <Slot props={{ children, token }} render={streamdown.snippets.li}>
73
74
  <li
74
75
  style:list-style-type={token.task ? 'none' : undefined}
75
- value={token.value}
76
+ {...token.value && !token.task ? { value: token.value } : {}}
76
77
  class={streamdown.theme.li.base}
77
78
  >
78
79
  {#if token.task}
@@ -87,31 +88,67 @@
87
88
  </li>
88
89
  </Slot>
89
90
  {:else if token.type === 'table'}
90
- <Table {token} {children} />
91
- {:else if token.type === 'tableRow'}
92
- <Slot props={{ token, children }} render={streamdown.snippets.tableRow}>
93
- <tr class={streamdown.theme.tableRow.base}>
94
- {@render children?.()}
95
- </tr>
91
+ <Slot props={{ token, children }} render={streamdown.snippets.table}>
92
+ <div class={streamdown.theme.table.base}>
93
+ <table class={streamdown.theme.table.table}>
94
+ {@render children()}
95
+ </table>
96
+ </div>
96
97
  </Slot>
97
- {:else if token.type === 'tableHead'}
98
- <Slot props={{ token, children }} render={streamdown.snippets.tableHead}>
99
- <thead class={streamdown.theme.tableHead.base}>
98
+ {:else if token.type === 'thead'}
99
+ <Slot props={{ token, children }} render={streamdown.snippets.thead}>
100
+ <thead class={streamdown.theme.thead.base}>
100
101
  {@render children?.()}
101
102
  </thead>
102
103
  </Slot>
103
- {:else if token.type === 'td'}
104
- <Slot props={{ children, token }} render={streamdown.snippets.td}>
105
- <td class={streamdown.theme.td.base}>
104
+ {:else if token.type === 'tbody'}
105
+ <Slot props={{ token, children }} render={streamdown.snippets.tbody}>
106
+ <tbody class={streamdown.theme.tbody.base}>
106
107
  {@render children?.()}
107
- </td>
108
+ </tbody>
108
109
  </Slot>
109
- {:else if token.type === 'th'}
110
- <Slot props={{ children, token }} render={streamdown.snippets.th}>
111
- <th class={streamdown.theme.th.base}>
110
+ {:else if token.type === 'tfoot'}
111
+ <Slot props={{ token, children }} render={streamdown.snippets.tfoot}>
112
+ <tfoot class={streamdown.theme.tfoot.base}>
113
+ {@render children?.()}
114
+ </tfoot>
115
+ </Slot>
116
+ {:else if token.type === 'tr'}
117
+ <Slot props={{ token, children }} render={streamdown.snippets.tr}>
118
+ <tr class={streamdown.theme.tr.base}>
112
119
  {@render children?.()}
113
- </th>
120
+ </tr>
114
121
  </Slot>
122
+ {:else if token.type === 'td'}
123
+ {#if token.rowspan > 0}
124
+ <Slot props={{ children, token }} render={streamdown.snippets.td}>
125
+ <td
126
+ class={streamdown.theme.td.base}
127
+ {...token.colspan > 1 ? { colspan: token.colspan } : {}}
128
+ {...token.rowspan > 1 ? { rowspan: token.rowspan } : {}}
129
+ {...token.align && ['left', 'center', 'right', 'justify', 'char'].includes(token.align)
130
+ ? { align: token.align as 'left' | 'center' | 'right' | 'justify' | 'char' }
131
+ : { align: 'left' }}
132
+ >
133
+ {@render children?.()}
134
+ </td>
135
+ </Slot>
136
+ {/if}
137
+ {:else if token.type === 'th'}
138
+ {#if token.rowspan > 0}
139
+ <Slot props={{ children, token }} render={streamdown.snippets.th}>
140
+ <th
141
+ class={streamdown.theme.th.base}
142
+ {...token.colspan > 1 ? { colspan: token.colspan } : {}}
143
+ {...token.rowspan > 1 ? { rowspan: token.rowspan } : {}}
144
+ {...token.align && ['left', 'center', 'right', 'justify', 'char'].includes(token.align)
145
+ ? { align: token.align as 'left' | 'center' | 'right' | 'justify' | 'char' }
146
+ : { align: 'left' }}
147
+ >
148
+ {@render children?.()}
149
+ </th>
150
+ </Slot>
151
+ {/if}
115
152
  {:else if token.type === 'image'}
116
153
  <Image {token} {children} />
117
154
  {:else if token.type === 'link'}
@@ -153,7 +190,15 @@
153
190
  {:else if token.type === 'br'}
154
191
  <br />
155
192
  {:else if token.type === 'math'}
156
- <Math {token} {children} />
193
+ <Slot
194
+ props={{
195
+ children,
196
+ token
197
+ }}
198
+ render={streamdown.snippets.math}
199
+ >
200
+ <Math {token} />
201
+ </Slot>
157
202
  {:else if token.type === 'alert'}
158
203
  <Alert {token} {children} />
159
204
  {:else if token.type === 'footnoteRef'}
@@ -1,8 +1,15 @@
1
1
  <script lang="ts">
2
- import { useStreamdown } from '../Streamdown.svelte';
2
+ import { useStreamdown } from '../Streamdown.js';
3
3
  import Slot from './Slot.svelte';
4
4
  import type { FootnoteRef } from '../marked/marked-footnotes.js';
5
- import { autoPlacement, computePosition, hide, offset, shift, size } from '@floating-ui/dom';
5
+ import {
6
+ autoPlacement,
7
+ computePosition,
8
+ autoUpdate,
9
+ hide,
10
+ offset,
11
+ shift
12
+ } from '@floating-ui/dom';
6
13
  import { useClickOutside } from '../utils/useClickOutside.svelte.js';
7
14
  import { scale } from 'svelte/transition';
8
15
  import Block from '../Block.svelte';
@@ -16,6 +23,7 @@
16
23
  token: FootnoteRef;
17
24
  } = $props();
18
25
 
26
+ const id = $props.id();
19
27
  let isOpen = $state(false);
20
28
 
21
29
  let reference = $state<HTMLButtonElement>();
@@ -44,13 +52,13 @@
44
52
  const middleware = [
45
53
  hide(),
46
54
  offset(0),
55
+ ,
47
56
  shift({
48
57
  mainAxis: true
49
58
  }),
50
59
  autoPlacement({
51
60
  allowedPlacements: ['top', 'top-end', 'top-start', 'bottom', 'bottom-end', 'bottom-start']
52
- }),
53
- size()
61
+ })
54
62
  ];
55
63
  const { x, y, strategy, placement, middlewareData } = await computePosition(reference!, node, {
56
64
  strategy: 'fixed',
@@ -67,9 +75,9 @@
67
75
  const popoverAttachment = (node: HTMLDialogElement) => {
68
76
  content = node;
69
77
  void place(node);
70
-
78
+ const off = autoUpdate(reference!, node, () => place(node));
71
79
  return () => {
72
- //
80
+ off();
73
81
  };
74
82
  };
75
83
  </script>
@@ -83,6 +91,8 @@
83
91
  render={streamdown.snippets.footnotePopover}
84
92
  >
85
93
  <dialog
94
+ id={'footnote-popover-' + id}
95
+ aria-modal="false"
86
96
  transition:scale|global={{ start: 0.95, duration: 100 }}
87
97
  {@attach clickOutside.attachment}
88
98
  {@attach popoverAttachment}
@@ -106,6 +116,9 @@
106
116
  bind:this={reference}
107
117
  class={streamdown.theme.footnoteRef.base}
108
118
  onclick={() => (isOpen = !isOpen)}
119
+ aria-expanded={isOpen}
120
+ aria-haspopup="dialog"
121
+ aria-controls={'footnote-popover-' + id}
109
122
  {@attach clickOutside.attachment}
110
123
  >
111
124
  {token.label.replace('^', '')}
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { useStreamdown } from '../Streamdown.svelte';
2
+ import { useStreamdown } from '../Streamdown.js';
3
3
  import { transformUrl } from '../utils/url.js';
4
4
  import Slot from './Slot.svelte';
5
5
  import type { Tokens } from 'marked';
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { useStreamdown } from '../Streamdown.svelte';
2
+ import { useStreamdown } from '../Streamdown.js';
3
3
  import { transformUrl } from '../utils/url.js';
4
4
  import Slot from './Slot.svelte';
5
5
  import type { Tokens } from 'marked';
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { onMount, untrack } from 'svelte';
3
- import { useStreamdown } from '../Streamdown.svelte';
3
+ import { useStreamdown } from '../Streamdown.js';
4
4
  import Slot from './Slot.svelte';
5
5
  import type { MathToken } from '../marked/index.js';
6
6
  import type { Snippet } from 'svelte';
@@ -10,17 +10,13 @@
10
10
  const streamdown = useStreamdown();
11
11
 
12
12
  const {
13
- children,
14
13
  token
15
14
  }: {
16
- children: Snippet;
17
15
  token: MathToken;
18
16
  } = $props();
19
17
 
20
18
  const isInline = $derived(token.isInline);
21
19
 
22
- console.log({ token });
23
-
24
20
  let katexInstance = $state<typeof import('katex') | null>(null);
25
21
 
26
22
  onMount(() => {
@@ -42,7 +38,7 @@
42
38
  : streamdown.katexConfig || {})
43
39
  };
44
40
  const code = token.text;
45
- console.log({ code });
41
+
46
42
  try {
47
43
  return katexInstance.renderToString(code, config);
48
44
  } catch (error) {
@@ -53,24 +49,16 @@
53
49
  });
54
50
  </script>
55
51
 
56
- <Slot
57
- props={{
58
- children,
59
- token
60
- }}
61
- render={streamdown.snippets.math}
62
- >
63
- {#if isInline}
64
- <span bind:this={inner} class={streamdown.theme.math.inline}>
65
- {@html html}
66
- </span>
67
- {:else}
68
- <div class="h-fit w-full">
69
- <div class="overflow-x-auto">
70
- <div bind:this={inner} class={streamdown.theme.math.block}>
71
- {@html html}
72
- </div>
52
+ {#if isInline}
53
+ <span bind:this={inner} class={streamdown.theme.math.inline}>
54
+ {@html html}
55
+ </span>
56
+ {:else}
57
+ <div class="h-fit w-full">
58
+ <div class="overflow-x-auto">
59
+ <div bind:this={inner} class={streamdown.theme.math.block}>
60
+ {@html html}
73
61
  </div>
74
62
  </div>
75
- {/if}
76
- </Slot>
63
+ </div>
64
+ {/if}
@@ -1,8 +1,6 @@
1
1
  import type { MathToken } from '../marked/index.js';
2
- import type { Snippet } from 'svelte';
3
2
  import 'katex/dist/katex.min.css';
4
3
  type $$ComponentProps = {
5
- children: Snippet;
6
4
  token: MathToken;
7
5
  };
8
6
  declare const Math: import("svelte").Component<$$ComponentProps, {}, "">;
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { onMount } from 'svelte';
3
- import { useStreamdown } from '../Streamdown.svelte';
3
+ import { useStreamdown } from '../Streamdown.js';
4
4
  import Slot from './Slot.svelte';
5
5
  import type { Tokens } from 'marked';
6
6
  import type { Snippet } from 'svelte';
@@ -11,10 +11,8 @@
11
11
  const streamdown = useStreamdown();
12
12
 
13
13
  const {
14
- children,
15
14
  token
16
15
  }: {
17
- children: Snippet;
18
16
  token: Tokens.Code;
19
17
  } = $props();
20
18
 
@@ -117,121 +115,113 @@
117
115
  };
118
116
  </script>
119
117
 
120
- <Slot
121
- props={{
122
- children,
123
- token
124
- }}
125
- render={streamdown.snippets.mermaid}
126
- >
127
- {#if mermaid}
128
- <div
129
- class={streamdown.theme.mermaid.base}
130
- {@attach (node) => renderMermaid(code, node)}
131
- {@attach insider.attach}
132
- data-expanded={'false'}
133
- >
134
- <div class={streamdown.theme.mermaid.buttons}>
135
- <button
136
- class={streamdown.theme.mermaid.button}
137
- aria-label="Zoom to fit"
138
- onclick={() => panzoom.zoomToFit()}
139
- data-panzoom-ignore
140
- >
141
- <svg
142
- class={streamdown.theme.mermaid.icon}
143
- xmlns="http://www.w3.org/2000/svg"
144
- viewBox="0 0 24 24"
145
- fill="none"
146
- stroke="currentColor"
147
- stroke-width="2"
148
- stroke-linecap="round"
149
- stroke-linejoin="round"
150
- ><path d="M3 7V5a2 2 0 0 1 2-2h2" /><path d="M17 3h2a2 2 0 0 1 2 2v2" /><path
151
- d="M21 17v2a2 2 0 0 1-2 2h-2"
152
- /><path d="M7 21H5a2 2 0 0 1-2-2v-2" /><rect
153
- width="10"
154
- height="8"
155
- x="7"
156
- y="8"
157
- rx="1"
158
- /></svg
159
- >
160
- </button>
161
- <button
162
- class={streamdown.theme.mermaid.button}
163
- aria-label="Zoom in"
164
- onclick={() => panzoom.zoomIn()}
165
- data-panzoom-ignore
118
+ {#if mermaid}
119
+ <div
120
+ class={streamdown.theme.mermaid.base}
121
+ {@attach (node) => renderMermaid(code, node)}
122
+ {@attach insider.attach}
123
+ data-expanded={'false'}
124
+ >
125
+ <div class={streamdown.theme.mermaid.buttons}>
126
+ <button
127
+ class={streamdown.theme.mermaid.button}
128
+ aria-label="Zoom to fit"
129
+ onclick={() => panzoom.zoomToFit()}
130
+ data-panzoom-ignore
131
+ >
132
+ <svg
133
+ class={streamdown.theme.mermaid.icon}
134
+ xmlns="http://www.w3.org/2000/svg"
135
+ viewBox="0 0 24 24"
136
+ fill="none"
137
+ stroke="currentColor"
138
+ stroke-width="2"
139
+ stroke-linecap="round"
140
+ stroke-linejoin="round"
141
+ ><path d="M3 7V5a2 2 0 0 1 2-2h2" /><path d="M17 3h2a2 2 0 0 1 2 2v2" /><path
142
+ d="M21 17v2a2 2 0 0 1-2 2h-2"
143
+ /><path d="M7 21H5a2 2 0 0 1-2-2v-2" /><rect
144
+ width="10"
145
+ height="8"
146
+ x="7"
147
+ y="8"
148
+ rx="1"
149
+ /></svg
166
150
  >
167
- <svg
168
- class={streamdown.theme.mermaid.icon}
169
- xmlns="http://www.w3.org/2000/svg"
170
- viewBox="0 0 24 24"
171
- fill="none"
172
- stroke="currentColor"
173
- stroke-width="2"
174
- stroke-linecap="round"
175
- stroke-linejoin="round"
176
- ><circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line
177
- x1="11"
178
- x2="11"
179
- y1="8"
180
- y2="14"
181
- /><line x1="8" x2="14" y1="11" y2="11" /></svg
182
- >
183
- </button>
184
- <button
185
- class={streamdown.theme.mermaid.button}
186
- aria-label="Zoom out"
187
- onclick={() => panzoom.zoomOut()}
188
- data-panzoom-ignore
189
- ><svg
190
- class={streamdown.theme.mermaid.icon}
191
- xmlns="http://www.w3.org/2000/svg"
192
- viewBox="0 0 24 24"
193
- fill="none"
194
- stroke="currentColor"
195
- stroke-width="2"
196
- stroke-linecap="round"
197
- stroke-linejoin="round"
198
- ><circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line
199
- x1="8"
200
- x2="14"
201
- y1="11"
202
- y2="11"
203
- /></svg
204
- ></button
151
+ </button>
152
+ <button
153
+ class={streamdown.theme.mermaid.button}
154
+ aria-label="Zoom in"
155
+ onclick={() => panzoom.zoomIn()}
156
+ data-panzoom-ignore
157
+ >
158
+ <svg
159
+ class={streamdown.theme.mermaid.icon}
160
+ xmlns="http://www.w3.org/2000/svg"
161
+ viewBox="0 0 24 24"
162
+ fill="none"
163
+ stroke="currentColor"
164
+ stroke-width="2"
165
+ stroke-linecap="round"
166
+ stroke-linejoin="round"
167
+ ><circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line
168
+ x1="11"
169
+ x2="11"
170
+ y1="8"
171
+ y2="14"
172
+ /><line x1="8" x2="14" y1="11" y2="11" /></svg
205
173
  >
206
- <button
207
- class={streamdown.theme.mermaid.button}
208
- aria-label="Toggle expand"
209
- onclick={() => panzoom.toggleExpand()}
210
- data-panzoom-ignore
174
+ </button>
175
+ <button
176
+ class={streamdown.theme.mermaid.button}
177
+ aria-label="Zoom out"
178
+ onclick={() => panzoom.zoomOut()}
179
+ data-panzoom-ignore
180
+ ><svg
181
+ class={streamdown.theme.mermaid.icon}
182
+ xmlns="http://www.w3.org/2000/svg"
183
+ viewBox="0 0 24 24"
184
+ fill="none"
185
+ stroke="currentColor"
186
+ stroke-width="2"
187
+ stroke-linecap="round"
188
+ stroke-linejoin="round"
189
+ ><circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line
190
+ x1="8"
191
+ x2="14"
192
+ y1="11"
193
+ y2="11"
194
+ /></svg
195
+ ></button
196
+ >
197
+ <button
198
+ class={streamdown.theme.mermaid.button}
199
+ aria-label="Toggle expand"
200
+ onclick={() => panzoom.toggleExpand()}
201
+ data-panzoom-ignore
202
+ >
203
+ <svg
204
+ class={streamdown.theme.mermaid.icon}
205
+ xmlns="http://www.w3.org/2000/svg"
206
+ viewBox="0 0 24 24"
207
+ fill="none"
208
+ stroke="currentColor"
209
+ stroke-width="2"
210
+ stroke-linecap="round"
211
+ stroke-linejoin="round"
212
+ ><path d="m15 15 6 6" /><path d="m15 9 6-6" /><path d="M21 16v5h-5" /><path
213
+ d="M21 8V3h-5"
214
+ /><path d="M3 16v5h5" /><path d="m3 21 6-6" /><path d="M3 8V3h5" /><path
215
+ d="M9 9 3 3"
216
+ /></svg
211
217
  >
212
- <svg
213
- class={streamdown.theme.mermaid.icon}
214
- xmlns="http://www.w3.org/2000/svg"
215
- viewBox="0 0 24 24"
216
- fill="none"
217
- stroke="currentColor"
218
- stroke-width="2"
219
- stroke-linecap="round"
220
- stroke-linejoin="round"
221
- ><path d="m15 15 6 6" /><path d="m15 9 6-6" /><path d="M21 16v5h-5" /><path
222
- d="M21 8V3h-5"
223
- /><path d="M3 16v5h5" /><path d="m3 21 6-6" /><path d="M3 8V3h5" /><path
224
- d="M9 9 3 3"
225
- /></svg
226
- >
227
- </button>
228
- </div>
229
- <svg {@attach panzoom.attach} data-mermaid-svg></svg>
218
+ </button>
230
219
  </div>
231
- {:else}
232
- <div class={streamdown.theme.mermaid.base}></div>
233
- {/if}
234
- </Slot>
220
+ <svg {@attach panzoom.attach} data-mermaid-svg></svg>
221
+ </div>
222
+ {:else}
223
+ <div class={streamdown.theme.mermaid.base}></div>
224
+ {/if}
235
225
 
236
226
  <style>
237
227
  /* View Transition styles for zoom effect */
@@ -269,7 +259,7 @@
269
259
  }
270
260
  }
271
261
 
272
- [data-expanded='true'] {
262
+ :global([data-expanded='true']) {
273
263
  ::view-transition-old(panzoom-element),
274
264
  ::view-transition-new(panzoom-element) {
275
265
  animation-duration: 0.3s;
@@ -1,7 +1,5 @@
1
1
  import type { Tokens } from 'marked';
2
- import type { Snippet } from 'svelte';
3
2
  type $$ComponentProps = {
4
- children: Snippet;
5
3
  token: Tokens.Code;
6
4
  };
7
5
  declare const Mermaid: import("svelte").Component<$$ComponentProps, {}, "">;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { useStreamdown } from '../Streamdown.svelte';
2
+ import { useStreamdown } from '../Streamdown.js';
3
3
  import Slot from './Slot.svelte';
4
4
  import type { Tokens } from 'marked';
5
5
  import type { Snippet } from 'svelte';
@@ -3,14 +3,62 @@ import type { Snippet } from 'svelte';
3
3
  import type { Theme } from './theme.js';
4
4
  import type { MermaidConfig } from 'mermaid';
5
5
  import type { KatexOptions } from 'katex';
6
- import type { StreamdownContext } from './Streamdown.svelte';
7
- import type { StreamdownToken } from './marked/index.js';
8
- type PredefinedElements = 'heading' | 'paragraph' | 'blockquote' | 'code' | 'codespan' | 'ul' | 'ol' | 'li' | 'table' | 'tableRow' | 'tableHead' | 'td' | 'th' | 'image' | 'link' | 'strong' | 'em' | 'del' | 'hr' | 'br' | 'math' | 'alert' | 'mermaid' | 'footnoteRef' | 'footnotePopover' | 'sup' | 'sub';
6
+ export interface StreamdownContext extends Omit<StreamdownProps, keyof Snippets | 'class' | 'theme' | 'shikiTheme'> {
7
+ snippets: Snippets;
8
+ shikiTheme: BundledTheme;
9
+ theme: Theme;
10
+ }
11
+ export declare class StreamdownContext {
12
+ footnotes: {
13
+ refs: Map<string, FootnoteRef>;
14
+ footnotes: Map<string, Footnote>;
15
+ };
16
+ constructor(props: Omit<StreamdownProps, keyof Snippets | 'class'> & {
17
+ snippets: Snippets;
18
+ });
19
+ }
20
+ export declare const useStreamdown: () => StreamdownContext;
21
+ import type { AlertToken, MathToken, SubSupToken, TableToken, THead, TBody, TFoot, THeadRow, TRow, TD, TH } from './marked/index.js';
22
+ import type { Tokens } from 'marked';
23
+ import type { ListItemToken, ListToken } from './marked/marked-list.js';
24
+ import type { Footnote, FootnoteRef, FootnoteToken } from './marked/marked-footnotes.js';
25
+ type TokenSnippet = {
26
+ heading: Tokens.Heading;
27
+ paragraph: Tokens.Paragraph;
28
+ blockquote: Tokens.Blockquote;
29
+ code: Tokens.Code;
30
+ codespan: Tokens.Codespan;
31
+ ul: ListToken;
32
+ ol: ListToken;
33
+ li: ListItemToken;
34
+ table: TableToken;
35
+ thead: THead;
36
+ tbody: TBody;
37
+ tfoot: TFoot;
38
+ tr: THeadRow | TRow;
39
+ td: TD;
40
+ th: TH;
41
+ image: Tokens.Image;
42
+ link: Tokens.Link;
43
+ strong: Tokens.Strong;
44
+ em: Tokens.Em;
45
+ del: Tokens.Del;
46
+ hr: Tokens.Hr;
47
+ br: Tokens.Br;
48
+ math: MathToken;
49
+ alert: AlertToken;
50
+ mermaid: Tokens.Code;
51
+ footnoteRef: FootnoteRef;
52
+ footnotePopover: FootnoteToken;
53
+ sup: SubSupToken;
54
+ sub: SubSupToken;
55
+ };
56
+ type PredefinedElements = keyof TokenSnippet;
9
57
  export type Snippets = {
10
58
  [K in PredefinedElements]?: Snippet<[
11
59
  {
12
60
  children: Snippet;
13
- token: StreamdownToken;
61
+ token: TokenSnippet[K];
14
62
  }
15
63
  ]>;
16
64
  };
@@ -38,11 +86,5 @@ export type StreamdownProps = {
38
86
  important?: string;
39
87
  };
40
88
  };
41
- customElements?: Record<string, Snippet<[
42
- {
43
- children: Snippet;
44
- token: StreamdownToken;
45
- }
46
- ]>>;
47
89
  } & Partial<Snippets>;
48
90
  export {};