markstream-vue 0.0.4-beta.8 → 0.0.5-beta.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.
package/README.md CHANGED
@@ -17,12 +17,16 @@
17
17
  [![CI](https://github.com/Simon-He95/markstream-vue/actions/workflows/ci.yml/badge.svg)](https://github.com/Simon-He95/markstream-vue/actions/workflows/ci.yml)
18
18
  [![License](https://img.shields.io/npm/l/markstream-vue)](./license)
19
19
 
20
- Looking for Vue 2.6? Use [`markstream-vue2`](./packages/markstream-vue2/README.md) (a baseline port with fewer advanced features).
20
+ Looking for other frameworks?
21
+
22
+ - Vue 2.6: use [`markstream-vue2`](./packages/markstream-vue2/README.md) (a baseline port with fewer advanced features)
23
+ - React: see `packages/markstream-react` at [`packages/markstream-react/README.md`](./packages/markstream-react/README.md) (first-pass port)
21
24
 
22
25
  ## Contents
23
26
 
24
27
  - [TL;DR Highlights](#tldr-highlights)
25
28
  - [Try It Now](#-try-it-now)
29
+ - [Community & support](#-community--support)
26
30
  - [Quick Start](#-quick-start)
27
31
  - [Common commands](#-common-commands)
28
32
  - [Streaming in 30 seconds](#-streaming-in-30-seconds)
@@ -31,17 +35,18 @@ Looking for Vue 2.6? Use [`markstream-vue2`](./packages/markstream-vue2/README.m
31
35
  - [Where it shines](#-where-it-shines)
32
36
  - [FAQ](#-faq-quick-answers)
33
37
  - [Why markstream-vue](#-why-markstream-vue-over-a-typical-markdown-renderer)
38
+ - [Roadmap](#-roadmap-snapshot)
34
39
  - [Releases](#-releases)
35
40
  - [Showcase](#-showcase--examples)
41
+ - [Introduction Video](#-introduction-video)
42
+ - [Features](#features)
36
43
  - [Contributing & community](#-contributing--community)
37
- - [Community & support](#-community--support)
38
44
  - [Troubleshooting](#troubleshooting--common-issues)
39
- > 📖 All detailed documentation, API, examples, and advanced usage have been migrated to the VitePress documentation site:
40
- > https://markstream-vue-docs.simonhe.me/guide/
45
+ - [Thanks](#thanks)
46
+ - [Star History](#star-history)
47
+ - [License](#license)
41
48
 
42
- > Looking for a React renderer? A first-pass port now lives under `packages/markstream-react`. See `packages/markstream-react/README.md` for usage instructions while its documentation is fleshed out.
43
-
44
- > ✅ Looking for a React renderer? A first-pass port now lives under `packages/markstream-react`. See `packages/markstream-react/README.md` for usage instructions while its documentation is fleshed out.
49
+ > 📖 Detailed docs, API, and advanced usage: https://markstream-vue-docs.simonhe.me/guide/
45
50
 
46
51
  ## TL;DR Highlights
47
52
 
@@ -112,6 +117,9 @@ enableMermaid()
112
117
  enableKatex()
113
118
  ```
114
119
 
120
+ <details>
121
+ <summary>Optional: CDN-backed workers (KaTeX / Mermaid)</summary>
122
+
115
123
  If you load KaTeX via CDN and want KaTeX rendering in a Web Worker (no bundler / optional peer not installed), inject a CDN-backed worker:
116
124
 
117
125
  ```ts
@@ -144,7 +152,10 @@ if (worker)
144
152
  setMermaidWorker(worker)
145
153
  ```
146
154
 
147
- ### Nuxt quick drop-in
155
+ </details>
156
+
157
+ <details>
158
+ <summary>Nuxt quick drop-in</summary>
148
159
 
149
160
  ```ts
150
161
  // plugins/markstream-vue.client.ts
@@ -159,6 +170,8 @@ export default defineNuxtPlugin((nuxtApp) => {
159
170
 
160
171
  Then use `<MarkdownRender :content="md" />` in your pages.
161
172
 
173
+ </details>
174
+
162
175
  ## 🛠️ Common commands
163
176
 
164
177
  - `pnpm dev` — playground dev server
@@ -173,11 +186,7 @@ Render streamed Markdown (SSE/websocket) with incremental updates:
173
186
 
174
187
  ```ts
175
188
  import type { ParsedNode } from 'markstream-vue'
176
- import MarkdownRender, {
177
- getMarkdown,
178
-
179
- parseMarkdownToStructure
180
- } from 'markstream-vue'
189
+ import MarkdownRender, { getMarkdown, parseMarkdownToStructure } from 'markstream-vue'
181
190
  import { ref } from 'vue'
182
191
 
183
192
  const nodes = ref<ParsedNode[]>([])
@@ -208,6 +217,9 @@ Switch rendering style per surface:
208
217
  - Virtualized window (default): steady scrolling and memory usage for long docs.
209
218
  - Incremental batches: set `:max-live-nodes="0"` for AI-like “typing” with lightweight placeholders.
210
219
 
220
+ <details>
221
+ <summary>Advanced: SSR / worker / streaming handoff</summary>
222
+
211
223
  ### SSR / Worker usage (deterministic output)
212
224
 
213
225
  Pre-parse Markdown on the server or in a worker and render typed nodes on the client:
@@ -252,6 +264,8 @@ This avoids re-parsing SSR content while letting later SSE/WebSocket chunks cont
252
264
 
253
265
  > Tip: when you know the stream has ended (the message is complete), use `parseMarkdownToStructure(buffer.value, md, { final: true })` or pass `:final="true"` to the component. This disables mid-state (`loading`) parsing so trailing delimiters (like `$$` or an unclosed code fence) won’t get stuck showing perpetual loading.
254
266
 
267
+ </details>
268
+
255
269
  ## ⚙️ Performance presets
256
270
 
257
271
  - **Virtual window (default)** – keep `max-live-nodes` at its default `320` to enable virtualization. Nodes render immediately and the renderer keeps a sliding window of elements mounted so long docs remain responsive without showing skeleton placeholders.
package/README.zh-CN.md CHANGED
@@ -3,6 +3,7 @@
3
3
  > 针对 Vue 3 的高性能、流式友好型 Markdown 渲染组件 — 支持渐进式 Mermaid、流式 diff 代码块以及为大文档优化的实时预览。
4
4
 
5
5
  [![NPM version](https://img.shields.io/npm/v/markstream-vue?color=a1b858&label=)](https://www.npmjs.com/package/markstream-vue)
6
+ [![English](https://img.shields.io/badge/docs-English-blue)](README.md)
6
7
  [![Docs](https://img.shields.io/badge/docs-中文文档-blue)](https://markstream-vue-docs.simonhe.me/zh/guide/)
7
8
  [![Playground](https://img.shields.io/badge/playground-在线体验-34c759)](https://markstream-vue.simonhe.me/)
8
9
  [![Test page](https://img.shields.io/badge/test-可分享复现-0A84FF)](https://markstream-vue.simonhe.me/test)
@@ -16,12 +17,16 @@
16
17
  [![CI](https://github.com/Simon-He95/markstream-vue/actions/workflows/ci.yml/badge.svg)](https://github.com/Simon-He95/markstream-vue/actions/workflows/ci.yml)
17
18
  [![License](https://img.shields.io/npm/l/markstream-vue)](./license)
18
19
 
19
- 需要 Vue 2.6 版本?请使用 [`markstream-vue2`](./packages/markstream-vue2/README.md)(基础移植版,功能更精简)。
20
+ 需要其他框架/版本?
21
+
22
+ - Vue 2.6:请使用 [`markstream-vue2`](./packages/markstream-vue2/README.md)(基础移植版,功能更精简)
23
+ - React:请参考 `packages/markstream-react` 的说明 [`packages/markstream-react/README.md`](./packages/markstream-react/README.md)(初步移植版)
20
24
 
21
25
  ## 目录
22
26
 
23
27
  - [速览](#速览)
24
28
  - [立即试用](#-立即试用)
29
+ - [社区与支持](#-社区与支持)
25
30
  - [快速上手](#-快速上手)
26
31
  - [常用命令](#-常用命令)
27
32
  - [30 秒流式接入](#-30-秒流式接入)
@@ -30,11 +35,17 @@
30
35
  - [适用场景](#-适用场景)
31
36
  - [快问快答](#-快问快答)
32
37
  - [为什么选择 markstream-vue](#-为什么选择-markstream-vue而不是普通-markdown-渲染器)
38
+ - [Roadmap](#-roadmap快照)
33
39
  - [发布](#-发布)
34
40
  - [案例与展示](#-案例与展示)
41
+ - [介绍视频](#介绍视频)
42
+ - [核心特性](#核心特性)
35
43
  - [贡献与社区](#-贡献与社区)
36
- - [社区与支持](#-社区与支持)
37
44
  - [故障排查](#故障排查--常见问题)
45
+ - [鸣谢](#鸣谢)
46
+ - [Star 历史](#star-历史)
47
+ - [许可](#许可)
48
+
38
49
  > 📖 所有详细文档、API、示例和高级用法已迁移至 VitePress 中文文档站点:
39
50
  > https://markstream-vue-docs.simonhe.me/zh/guide/
40
51
 
@@ -107,6 +118,9 @@ enableMermaid()
107
118
  enableKatex()
108
119
  ```
109
120
 
121
+ <details>
122
+ <summary>可选:CDN Worker(KaTeX / Mermaid)</summary>
123
+
110
124
  如果你是用 CDN 引入 KaTeX,并且希望公式在 Web Worker 中渲染(不打包 / 不安装可选 peer),可以注入一个“CDN 加载 KaTeX”的 worker:
111
125
 
112
126
  ```ts
@@ -139,7 +153,10 @@ if (worker)
139
153
  setMermaidWorker(worker)
140
154
  ```
141
155
 
142
- ### Nuxt 快速接入
156
+ </details>
157
+
158
+ <details>
159
+ <summary>Nuxt 快速接入</summary>
143
160
 
144
161
  ```ts
145
162
  // plugins/markstream-vue.client.ts
@@ -154,6 +171,8 @@ export default defineNuxtPlugin((nuxtApp) => {
154
171
 
155
172
  然后在页面中直接使用 `<MarkdownRender :content=\"md\" />`。
156
173
 
174
+ </details>
175
+
157
176
  ## 🛠️ 常用命令
158
177
 
159
178
  - `pnpm dev` — playground 开发
@@ -168,11 +187,7 @@ export default defineNuxtPlugin((nuxtApp) => {
168
187
 
169
188
  ```ts
170
189
  import type { ParsedNode } from 'markstream-vue'
171
- import MarkdownRender, {
172
- getMarkdown,
173
-
174
- parseMarkdownToStructure
175
- } from 'markstream-vue'
190
+ import MarkdownRender, { getMarkdown, parseMarkdownToStructure } from 'markstream-vue'
176
191
  import { ref } from 'vue'
177
192
 
178
193
  const nodes = ref<ParsedNode[]>([])
@@ -203,6 +218,9 @@ eventSource.onmessage = event => addChunk(event.data)
203
218
  - 虚拟化窗口(默认):长文档滚动平稳、内存稳定。
204
219
  - 增量批次:将 `:max-live-nodes="0"`,获得更明显的“打字机”体验与轻量占位。
205
220
 
221
+ <details>
222
+ <summary>进阶:SSR / Worker / 流式续写</summary>
223
+
206
224
  ### SSR / Worker(确定性输出)
207
225
 
208
226
  在服务端或 Worker 预解析 Markdown,前端直接渲染节点:
@@ -247,6 +265,8 @@ function addChunk(chunk: string) {
247
265
 
248
266
  > 提示:当你明确知道流已结束(消息已完整)时,建议用 `parseMarkdownToStructure(buffer.value, md, { final: true })` 或在组件上设置 `:final="true"`,以关闭解析器的中间态(loading)策略,避免末尾残留分隔符(如 `$$`、未闭合 code fence)导致永久 loading。
249
267
 
268
+ </details>
269
+
250
270
  ## ⚙️ 性能模式
251
271
 
252
272
  - **默认虚拟化窗口**:保持 `max-live-nodes` 默认值(`320`),渲染器会立即渲染当前窗口的节点,同时只保留有限数量的 DOM 节点,实现平滑滚动与可控内存,占位骨架极少。