markstream-svelte 0.0.5 → 0.1.0-beta.2
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.
- package/README.md +14 -17
- package/dist/components/CodeBlockNode.svelte +235 -266
- package/dist/components/CodeBlockNode.svelte.d.ts +6 -5
- package/dist/components/NodeOutlet.svelte +13 -2
- package/dist/components/NodeRenderer.svelte +16 -5
- package/dist/components/PreCodeNode.svelte +1 -1
- package/dist/components/shared/node-helpers.d.ts +14 -13
- package/dist/components/shared/node-helpers.js +1 -1
- package/dist/enhanceRenderedHtml.d.ts +5 -2
- package/dist/enhanceRenderedHtml.js +134 -40
- package/dist/index.css +10 -69
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -3
- package/dist/index.px.css +10 -69
- package/dist/index.tailwind.css +10 -69
- package/dist/optional/{monaco.d.ts → streamDiffs.d.ts} +5 -6
- package/dist/optional/streamDiffs.js +66 -0
- package/dist/types/codeBlock.d.ts +66 -0
- package/dist/utils/languageIcon.d.ts +1 -1
- package/dist/utils/languageIcon.js +7 -5
- package/package.json +6 -10
- package/dist/components/MarkdownCodeBlockNode.svelte +0 -15
- package/dist/components/MarkdownCodeBlockNode.svelte.d.ts +0 -8
- package/dist/optional/monaco.js +0 -84
- package/dist/types/monaco.d.ts +0 -65
- /package/dist/types/{monaco.js → codeBlock.js} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# markstream-svelte
|
|
2
2
|
|
|
3
|
-
Svelte 5 streaming Markdown renderer for AI chat, LLM token streams, SSE/WebSocket output, incomplete Markdown states, long documents, custom components, Mermaid, KaTeX,
|
|
3
|
+
Svelte 5 streaming Markdown renderer for AI chat, LLM token streams, SSE/WebSocket output, incomplete Markdown states, long documents, custom components, Mermaid, KaTeX, stream-diffs code blocks, D2, and Infographic.
|
|
4
|
+
|
|
5
|
+
The coordinated 2.0 family beta will use `markstream-svelte@next`. Before installing, verify that `npm view markstream-svelte@next version` reports `0.1.0-beta.1`. It removes the former Monaco code-block API in favor of `stream-diffs`; read the [coordinated 2.0 family migration guide](https://markstream.simonhe.me/guide/migration-2-0) before upgrading.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add markstream-svelte@next svelte@^5 stream-diffs
|
|
9
|
+
```
|
|
4
10
|
|
|
5
11
|
## When to use it
|
|
6
12
|
|
|
@@ -31,8 +37,6 @@ pnpm add katex mermaid stream-diffs @terrastruct/d2 @antv/infographic
|
|
|
31
37
|
```
|
|
32
38
|
|
|
33
39
|
`stream-diffs` powers the enhanced code blocks (smaller runtime, no `monaco-editor`).
|
|
34
|
-
If you prefer the legacy Monaco-based rendering, install `stream-monaco` instead;
|
|
35
|
-
it is used automatically as a fallback when `stream-diffs` is absent.
|
|
36
40
|
|
|
37
41
|
## Enhanced Code Blocks
|
|
38
42
|
|
|
@@ -40,8 +44,8 @@ it is used automatically as a fallback when `stream-diffs` is absent.
|
|
|
40
44
|
|
|
41
45
|
```svelte
|
|
42
46
|
<script lang="ts">
|
|
47
|
+
import type { CodeBlockOptions } from 'markstream-svelte'
|
|
43
48
|
import { CodeBlockNode } from 'markstream-svelte'
|
|
44
|
-
import type { CodeBlockMonacoOptions } from 'markstream-svelte'
|
|
45
49
|
|
|
46
50
|
const node = {
|
|
47
51
|
type: 'code_block',
|
|
@@ -50,24 +54,17 @@ it is used automatically as a fallback when `stream-diffs` is absent.
|
|
|
50
54
|
raw: 'const answer = 42',
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
lineHeight: 21,
|
|
58
|
-
tabSize: 4,
|
|
59
|
-
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
|
60
|
-
wordWrap: 'off',
|
|
61
|
-
theme: 'vitesse-dark',
|
|
62
|
-
renderSideBySide: true,
|
|
63
|
-
MAX_HEIGHT: 640,
|
|
57
|
+
const codeBlockOptions: CodeBlockOptions = {
|
|
58
|
+
overflow: 'wrap',
|
|
59
|
+
diffStyle: 'unified',
|
|
60
|
+
enableLineSelection: true,
|
|
64
61
|
}
|
|
65
62
|
</script>
|
|
66
63
|
|
|
67
|
-
<CodeBlockNode {node} {
|
|
64
|
+
<CodeBlockNode {node} {codeBlockOptions} isDark showHeader />
|
|
68
65
|
```
|
|
69
66
|
|
|
70
|
-
|
|
67
|
+
Direct `CodeBlockNode` and top-level `MarkdownRender` both accept `codeBlockOptions`. It covers host-managed typography/layout and supported File/FileDiff, interaction, annotation, and callback fields; `maxHeight` and the single symmetric `padding` value use numeric CSS pixels. Use `codeBlockProps` for header/toolbar controls. Theme values are registered names and `themes` is the `[dark, light]` pair. An old Monaco JSON theme is not accepted directly: first convert it to a Shiki `ThemeRegistration`, then call `registerCustomTheme(name, loader)` from `stream-diffs/pierre`; see the [coordinated 2.0 family migration guide](https://markstream.simonhe.me/guide/migration-2-0). When `stream-diffs` is not installed, the block renders as a plain `<pre>`.
|
|
71
68
|
|
|
72
69
|
## Basic Usage
|
|
73
70
|
|