svelte-streamdown 1.0.9 → 2.0.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/README.md +144 -135
  2. package/dist/Block.svelte +14 -54
  3. package/dist/Elements/Alert.svelte +1 -2
  4. package/dist/Elements/Code.svelte +2 -4
  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 +27 -19
  21. package/dist/marked/marked-alert.d.ts +2 -2
  22. package/dist/marked/marked-alert.js +6 -19
  23. package/dist/marked/marked-footnotes.js +1 -2
  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 +59 -0
  30. package/dist/marked/marked-table.js +495 -0
  31. package/dist/theme.d.ts +24 -6
  32. package/dist/theme.js +22 -10
  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
@@ -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 {};
@@ -1 +1,19 @@
1
- export {};
1
+ import { getContext, setContext } from 'svelte';
2
+ export class StreamdownContext {
3
+ footnotes = {
4
+ refs: new Map(),
5
+ footnotes: new Map()
6
+ };
7
+ constructor(props) {
8
+ bind(this, props);
9
+ setContext('streamdown', this);
10
+ }
11
+ }
12
+ export const useStreamdown = () => {
13
+ const context = getContext('streamdown');
14
+ if (!context) {
15
+ throw new Error('Streamdown context not found');
16
+ }
17
+ return context;
18
+ };
19
+ import { bind } from './utils/bind.js';
@@ -1,42 +1,10 @@
1
- <script lang="ts" module>
2
- import { getContext, setContext } from 'svelte';
3
-
4
- export interface StreamdownContext
5
- extends Omit<StreamdownProps, keyof Snippets | 'class' | 'theme' | 'shikiTheme'> {
6
- snippets: Snippets;
7
- shikiTheme: BundledTheme;
8
- theme: Theme;
9
- }
10
- export class StreamdownContext {
11
- footnotes = {
12
- refs: new Map<string, FootnoteRef>(),
13
- footnotes: new Map<string, Footnote>()
14
- };
15
- constructor(props: Omit<StreamdownProps, keyof Snippets | 'class'> & { snippets: Snippets }) {
16
- bind(this, props);
17
- setContext('streamdown', this);
18
- }
19
- }
20
- export const useStreamdown = () => {
21
- const context = getContext<StreamdownContext>('streamdown');
22
- if (!context) {
23
- throw new Error('Streamdown context not found');
24
- }
25
- return context;
26
- };
27
- </script>
28
-
29
1
  <script lang="ts">
30
2
  import Block from './Block.svelte';
31
- import type { Snippets, StreamdownProps } from './Streamdown.js';
32
- import { bind } from './utils/bind.js';
3
+ import { StreamdownContext, type StreamdownProps } from './Streamdown.js';
33
4
  import 'katex/dist/katex.min.css';
34
- import { mergeTheme, type Theme, shadcnTheme } from './theme.js';
35
- import type { BundledTheme } from 'shiki';
5
+ import { mergeTheme, shadcnTheme } from './theme.js';
36
6
  import { parseBlocks } from './marked/index.js';
37
- import { SvelteMap } from 'svelte/reactivity';
38
- import type { FootnoteRef } from './marked/marked-footnotes.js';
39
- import type { Footnote } from './marked/marked-footnotes.js';
7
+
40
8
  let {
41
9
  content = '',
42
10
  class: className,
@@ -52,13 +20,10 @@
52
20
  translations,
53
21
  baseTheme,
54
22
  mergeTheme: shouldMergeTheme = true,
55
- customElements,
56
23
  streamdown = $bindable(),
57
24
  ...snippets
58
25
  }: StreamdownProps = $props();
59
26
 
60
- console.log('render');
61
-
62
27
  streamdown = new StreamdownContext({
63
28
  get content() {
64
29
  return content;
@@ -98,9 +63,6 @@
98
63
  get translations() {
99
64
  return translations;
100
65
  },
101
- get customElements() {
102
- return customElements;
103
- },
104
66
  get shikiPreloadThemes() {
105
67
  return shikiPreloadThemes;
106
68
  }
@@ -1,24 +1,5 @@
1
- export interface StreamdownContext extends Omit<StreamdownProps, keyof Snippets | 'class' | 'theme' | 'shikiTheme'> {
2
- snippets: Snippets;
3
- shikiTheme: BundledTheme;
4
- theme: Theme;
5
- }
6
- export declare class StreamdownContext {
7
- footnotes: {
8
- refs: Map<string, FootnoteRef>;
9
- footnotes: Map<string, Footnote>;
10
- };
11
- constructor(props: Omit<StreamdownProps, keyof Snippets | 'class'> & {
12
- snippets: Snippets;
13
- });
14
- }
15
- export declare const useStreamdown: () => StreamdownContext;
16
- import type { Snippets, StreamdownProps } from './Streamdown.js';
1
+ import { type StreamdownProps } from './Streamdown.js';
17
2
  import 'katex/dist/katex.min.css';
18
- import { type Theme } from './theme.js';
19
- import type { BundledTheme } from 'shiki';
20
- import type { FootnoteRef } from './marked/marked-footnotes.js';
21
- import type { Footnote } from './marked/marked-footnotes.js';
22
3
  declare const Streamdown: import("svelte").Component<StreamdownProps, {}, "streamdown">;
23
4
  type Streamdown = ReturnType<typeof Streamdown>;
24
5
  export default Streamdown;
@@ -4,26 +4,9 @@ import { type FootnoteToken } from './marked-footnotes.js';
4
4
  import { type MathToken } from './marked-math.js';
5
5
  import { type SubSupToken } from './marked-subsup.js';
6
6
  import { type ListItemToken, type ListToken } from './marked-list.js';
7
- export type StreamdownToken = Exclude<MarkedToken, Tokens.List | Tokens.ListItem> | ListToken | ListItemToken | MathToken | AlertToken | FootnoteToken | SubSupToken | TableRow | TD | TH | TableHead;
8
- export type TD = Tokens.TableCell & {
9
- type: 'td';
10
- raw: string;
11
- };
12
- export type TH = Tokens.TableCell & {
13
- type: 'th';
14
- raw: string;
15
- };
16
- export type TableRow = {
17
- type: 'tableRow';
18
- raw: string;
19
- tokens: (TD | TH)[];
20
- isHeader: boolean;
21
- };
22
- export type TableHead = {
23
- type: 'tableHead';
24
- raw: string;
25
- tokens: TableRow[];
26
- };
7
+ import { type TableToken, type THead, type TBody, type TFoot, type THeadRow, type TRow, type TH, type TD } from './marked-table.js';
8
+ export type StreamdownToken = Exclude<MarkedToken, Tokens.List | Tokens.ListItem | Tokens.Table> | ListToken | ListItemToken | MathToken | AlertToken | FootnoteToken | SubSupToken | TableToken | THead | TBody | TFoot | THeadRow | TRow | TH | TD;
9
+ export type { TableToken, THead, TBody, TFoot, THeadRow, TRow, TH, TD } from './marked-table.js';
27
10
  export declare const lex: (markdown: string) => StreamdownToken[];
28
11
  export declare const parseBlocks: (markdown: string) => string[];
29
12
  export type { MathToken, AlertToken, FootnoteToken, SubSupToken };