reactive-md 0.6.0 → 0.6.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.
- package/CHANGELOG-ch.md +203 -194
- package/CHANGELOG.md +203 -194
- package/CONTRIBUTING-ch.md +67 -67
- package/CONTRIBUTING.md +69 -69
- package/README-ch.md +157 -157
- package/README-en.md +184 -184
- package/README.md +184 -184
- package/SECURITY-ch.md +81 -81
- package/SECURITY.md +81 -81
- package/THIRD_PARTY_NOTICES.md +313 -209
- package/bin/reactive-md.mjs +39 -39
- package/cli/args.mjs +181 -181
- package/cli/assets.mjs +390 -390
- package/cli/build.mjs +268 -268
- package/cli/document.mjs +130 -130
- package/cli/errors.mjs +61 -61
- package/cli/fs-utils.mjs +133 -133
- package/cli/glob.mjs +203 -203
- package/cli/help.mjs +138 -138
- package/cli/lint.mjs +177 -177
- package/cli/main.mjs +55 -55
- package/cli/migrate.mjs +368 -368
- package/cli/package.mjs +210 -210
- package/dist-library/{authoring-DSC0VsNK.js → authoring-BEVyth5X.js} +1 -1
- package/dist-library/compiler-Cm3ppMxG.js +46044 -0
- package/dist-library/{react-Dk94rcOp.js → react-Bh7_oxZp.js} +20110 -20113
- package/dist-library/reactive-md-authoring.js +2 -2
- package/dist-library/reactive-md-print.css +284 -284
- package/dist-library/reactive-md-react-unstyled.js +1 -1
- package/dist-library/reactive-md-react.js +1 -1
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +3 -3
- package/dist-library/{runtime-D8KbnCd0.js → runtime-DlFYQ4s_.js} +1 -1
- package/dist-library/types/local/math-display.d.ts +22 -23
- package/dist-library/types/local/math-view.d.ts +6 -7
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +318 -62
- package/docs/compatibility/compatibility-ch.md +121 -119
- package/docs/compatibility/compatibility-en.md +121 -119
- package/docs/compatibility/source-versioning-ch.md +159 -159
- package/docs/compatibility/source-versioning-en.md +159 -159
- package/docs/development/component-development-ch.md +210 -210
- package/docs/development/component-development-en.md +210 -210
- package/docs/development/component-protocol-ch.md +747 -747
- package/docs/development/component-protocol-en.md +747 -747
- package/docs/development/performance-ch.md +76 -76
- package/docs/development/performance-en.md +76 -76
- package/docs/development/releasing-ch.md +108 -108
- package/docs/development/releasing-en.md +108 -108
- package/docs/integration/author-tools-ch.md +62 -62
- package/docs/integration/author-tools-en.md +62 -62
- package/docs/integration/shareable-export-ch.md +209 -209
- package/docs/integration/shareable-export-en.md +211 -211
- package/docs/reference/computations-formatting-ch.md +87 -87
- package/docs/reference/computations-formatting-en.md +87 -87
- package/docs/reference/constraints-collections-ch.md +84 -84
- package/docs/reference/constraints-collections-en.md +84 -84
- package/docs/reference/diagnostics-counting-ch.md +104 -104
- package/docs/reference/diagnostics-counting-en.md +104 -104
- package/docs/reference/local-components-v2-ch.md +138 -138
- package/docs/reference/local-components-v2-en.md +104 -104
- package/docs/reference/local-interaction-syntax-ch.md +515 -511
- package/docs/reference/local-interaction-syntax-en.md +511 -507
- package/docs/reference/theme-protocol-ch.md +107 -107
- package/docs/reference/theme-protocol-en.md +107 -107
- package/docs/releases/release-0.4.0-ch.md +89 -89
- package/docs/releases/release-0.4.0-en.md +89 -89
- package/docs/releases/release-0.4.1-ch.md +23 -23
- package/docs/releases/release-0.4.1-en.md +23 -23
- package/docs/releases/release-0.6.1-ch.md +27 -0
- package/docs/releases/release-0.6.1-en.md +27 -0
- package/examples/conformance/README.md +53 -53
- package/examples/conformance/component-protocol-1.json +482 -482
- package/examples/conformance/component-protocol-1.schema.json +76 -76
- package/examples/conformance/local-draft-1.json +50 -50
- package/examples/conformance/local-draft-2.json +212 -212
- package/examples/integration/README.md +47 -47
- package/examples/integration/core/index.mjs +32 -32
- package/examples/integration/worker/index.html +19 -19
- package/examples/integration/worker/main.js +61 -61
- package/examples/integration/worker/package.json +13 -13
- package/examples/integration/worker/worker.js +3 -3
- package/examples/local/README.md +74 -74
- package/examples/local/charts.reactive.md +73 -73
- package/examples/local/recipes/invoice-zh.reactive.md +36 -36
- package/examples/local/recipes/invoice.reactive.md +36 -36
- package/examples/local/recipes/workshop-zh.reactive.md +33 -33
- package/examples/local/recipes/workshop.reactive.md +33 -33
- package/examples/local/showcase/README.md +25 -25
- package/examples/local/showcase/explore.reactive.md +102 -102
- package/examples/local/showcase/flow.reactive.md +86 -86
- package/examples/local/showcase/forms.reactive.md +126 -126
- package/examples/local/showcase/functions.reactive.md +119 -119
- package/examples/local/showcase/layout.reactive.md +100 -100
- package/examples/local/showcase/statistics.reactive.md +108 -108
- package/examples/local/showcase/tasks.reactive.md +89 -89
- package/examples/local/showcase/zh/explore.reactive.md +102 -102
- package/examples/local/showcase/zh/flow.reactive.md +86 -86
- package/examples/local/showcase/zh/forms.reactive.md +126 -126
- package/examples/local/showcase/zh/functions.reactive.md +119 -119
- package/examples/local/showcase/zh/layout.reactive.md +100 -100
- package/examples/local/showcase/zh/statistics.reactive.md +108 -108
- package/examples/local/showcase/zh/tasks.reactive.md +89 -89
- package/package.json +152 -152
- package/dist-library/compiler-CRD88BMt.js +0 -24964
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
# 性能测量
|
|
2
|
-
|
|
3
|
-
在源码仓库根目录构建语言包,然后运行:
|
|
4
|
-
|
|
5
|
-
```sh
|
|
6
|
-
npm run build
|
|
7
|
-
npm run benchmark
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
脚本对每个场景预热 3 次、测量 20 次,报告中位数和 P95,原始结果写入 `artifacts/benchmark.json`。可用 `npm run benchmark -- --iterations 50 --output artifacts/benchmark-50.json` 改变次数和输出位置。报告包含包版本、Node 版本、操作系统和 CPU 信息。
|
|
11
|
-
|
|
12
|
-
## 本地基线
|
|
13
|
-
|
|
14
|
-
2026-10-22,Reactive MD 0.3.0,Node 22.17.0,Windows x64,Intel Core Ultra 5 125H。测量时机器上也有其他开发进程运行。该基线早于 0.4.0 发布;作为发布对比前应重新运行基准。
|
|
15
|
-
|
|
16
|
-
| 场景 | 中位数 | P95 |
|
|
17
|
-
| --- | ---: | ---: |
|
|
18
|
-
| 编译费用示例,378 字符 | 2.51 ms | 5.83 ms |
|
|
19
|
-
| 编译 250 行响应式表格,7,161 字符 | 17.04 ms | 28.05 ms |
|
|
20
|
-
| 编译 100 节文章,15,550 字符 | 45.34 ms | 59.81 ms |
|
|
21
|
-
| 连续 100 次状态写入与表达式求值 | 0.20 ms | 0.34 ms |
|
|
22
|
-
| 三条曲线,每条 200 个采样点 | 0.55 ms | 1.61 ms |
|
|
23
|
-
|
|
24
|
-
计时包含正确性断言,运行时场景的一次测量包含 100 次更新。绘图场景包含正常函数与非网格渐近线的断点检查。
|
|
25
|
-
|
|
26
|
-
这些数据测量 Node 中的编译、求值和采样,不包含浏览器排版、绘制或输入到画面的延迟。数值用于同条件下比较版本,不设置跨机器通过阈值,也不代表源码上限内的所有文档都有相同耗时。CI 保存 Node 24 的测量报告;[首轮 CI](https://github.com/yao1145/ReactiveMD/actions/runs/39782886373) 已通过并生成报告。
|
|
27
|
-
|
|
28
|
-
## 宿主中的大文档
|
|
29
|
-
|
|
30
|
-
文档源码上限为 1,000,000 个 UTF-16 代码单元,绘图和表达式还有独立计算预算,详见[安全策略](../../SECURITY-ch.md)。资源上限控制工作量,编译 API 仍是同步调用。编辑器可以合并连续输入触发的编译;处理来源不可信或较大的文档时,可以在宿主 Worker 或独立进程中编译,并由宿主控制并发和超时。
|
|
31
|
-
|
|
32
|
-
语法节点预算默认 10,000,宿主可用 `compileLocal(source, { limits: { maxSyntaxNodes: 50_000 } })` 按次调整,见[核心 API](../integration/local-integration-ch.md#核心-api)。提高预算后应同时测量编译、内存和最终预览渲染成本。
|
|
33
|
-
|
|
34
|
-
## 渲染优化契约
|
|
35
|
-
|
|
36
|
-
参考渲染器使用编译器产出的依赖信息,跳过不可能读取已变化参数的子树。这是内部渲染优化,不是作者可见功能,也不是新的公开 API。
|
|
37
|
-
|
|
38
|
-
- 公开契约是语义等价:状态值、渲染文字、诊断、可访问属性、静态 SSR 输出和交互行为与不做条件渲染时一致,只有重新计算的范围变化。
|
|
39
|
-
- `document.dependencies` 是冻结、可序列化的内部映射。无法静态判断读取范围的子树标记为 `null`,对这些子树保守渲染。宿主和其他渲染器不得依赖其结构,可以完全忽略。
|
|
40
|
-
- 源码变化、实例销毁、面板重置,以及可能改变隐藏状态的可见性变化,仍会更新受影响的子树。优化不会抑制诊断或校验提示。
|
|
41
|
-
- `npm run verify:memo` 在相同文档和状态修订上比较优化渲染与无条件基线;`npm run verify:release` 包含该检查。只有两者产生等价的可观察输出,渲染优化才可接受。
|
|
42
|
-
|
|
43
|
-
## Playground 实时编辑
|
|
44
|
-
|
|
45
|
-
Playground 在独立的模块 Worker 中调用公开的 `compileLocal`,将连续 150 ms 内的编辑合并。调度器最多保留一个正在编译的任务和一份最新待编译源码;过期结果不会替换当前预览或诊断。输入框和导出始终使用最新源码,等待编译时显示“编译中”并保留上一次预览。预览组件复用相同文档,避免每次按键重建整个预览。
|
|
46
|
-
|
|
47
|
-
源码保存延后执行,切换示例或离开页面时保存待写入的内容。Worker 无法使用或运行失败时,页面提示降级,并合并编辑后在主线程编译;该模式仍有大文档阻塞的成本。正常 Worker 模式中,接收编译结果后的 React 渲染、排版与绘制仍在主线程执行。
|
|
48
|
-
|
|
49
|
-
语言包的同步编译 API 和 `LocalReactiveDocument` 保持原有行为。其他宿主可以参考 `demo/src/local-compile-worker.ts` 与调度器,将编译放到自己管理的 Worker。
|
|
50
|
-
|
|
51
|
-
### 复测
|
|
52
|
-
|
|
53
|
-
在仓库根目录构建语言包后执行:
|
|
54
|
-
|
|
55
|
-
```sh
|
|
56
|
-
node scripts/benchmark-large-documents.mjs
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
脚本预热 3 次、测量 20 次,检查 10、100、300、600 节文章编译结果并保存中位数和 P95。启动 Playground 后,可以从仓库根目录执行以下浏览器检查;默认服务器为 `http://127.0.0.1:5184`,可用 `DEMO_URL` 覆盖。
|
|
60
|
-
|
|
61
|
-
```sh
|
|
62
|
-
node demo/scripts/verify-editing.mjs
|
|
63
|
-
node demo/scripts/benchmark-editing.mjs
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
编辑基准在 300 节、约 47,000 字符的文章末尾连续键入 10 个字符,按键间隔为 20 ms,记录输入事件到下一次 `requestAnimationFrame` 回调的延迟和主线程长任务。该指标用于观察输入响应,不等同于画面完成绘制的时间;长任务统计包含最终预览渲染。`EDITING_SECTIONS` 可调整节数,`EDITING_REPORT` 可指定报告路径。所有报告写入忽略目录 `artifacts/`。
|
|
67
|
-
|
|
68
|
-
2026-10-22,在上述 Windows 机器上用本机 Edge 对同一份 46,969 字符文章进行一次前后对比。两边均使用 Vite 开发服务、1440 × 1000 视口,原版为 `94fd72e`,优化版包含本节描述的 Worker 调度与预览复用。
|
|
69
|
-
|
|
70
|
-
| 指标 | 原版 | 优化版 |
|
|
71
|
-
| --- | ---: | ---: |
|
|
72
|
-
| 输入到下一帧回调的中位延迟 | 147.3 ms | 9.5 ms |
|
|
73
|
-
| 输入到下一帧回调的最大延迟 | 157.9 ms | 36.9 ms |
|
|
74
|
-
| 连续键入 10 个字符的总耗时 | 2,302 ms | 538 ms |
|
|
75
|
-
|
|
76
|
-
原始报告分别为 `artifacts/benchmark-editing-before.json` 和 `artifacts/benchmark-editing-after.json`。这是一次本机观测,机器负载会影响数值。优化主要减少按键触发的主线程工作,同步 `compileLocal` 本身的算法和单次编译速度保持原样。
|
|
1
|
+
# 性能测量
|
|
2
|
+
|
|
3
|
+
在源码仓库根目录构建语言包,然后运行:
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm run build
|
|
7
|
+
npm run benchmark
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
脚本对每个场景预热 3 次、测量 20 次,报告中位数和 P95,原始结果写入 `artifacts/benchmark.json`。可用 `npm run benchmark -- --iterations 50 --output artifacts/benchmark-50.json` 改变次数和输出位置。报告包含包版本、Node 版本、操作系统和 CPU 信息。
|
|
11
|
+
|
|
12
|
+
## 本地基线
|
|
13
|
+
|
|
14
|
+
2026-10-22,Reactive MD 0.3.0,Node 22.17.0,Windows x64,Intel Core Ultra 5 125H。测量时机器上也有其他开发进程运行。该基线早于 0.4.0 发布;作为发布对比前应重新运行基准。
|
|
15
|
+
|
|
16
|
+
| 场景 | 中位数 | P95 |
|
|
17
|
+
| --- | ---: | ---: |
|
|
18
|
+
| 编译费用示例,378 字符 | 2.51 ms | 5.83 ms |
|
|
19
|
+
| 编译 250 行响应式表格,7,161 字符 | 17.04 ms | 28.05 ms |
|
|
20
|
+
| 编译 100 节文章,15,550 字符 | 45.34 ms | 59.81 ms |
|
|
21
|
+
| 连续 100 次状态写入与表达式求值 | 0.20 ms | 0.34 ms |
|
|
22
|
+
| 三条曲线,每条 200 个采样点 | 0.55 ms | 1.61 ms |
|
|
23
|
+
|
|
24
|
+
计时包含正确性断言,运行时场景的一次测量包含 100 次更新。绘图场景包含正常函数与非网格渐近线的断点检查。
|
|
25
|
+
|
|
26
|
+
这些数据测量 Node 中的编译、求值和采样,不包含浏览器排版、绘制或输入到画面的延迟。数值用于同条件下比较版本,不设置跨机器通过阈值,也不代表源码上限内的所有文档都有相同耗时。CI 保存 Node 24 的测量报告;[首轮 CI](https://github.com/yao1145/ReactiveMD/actions/runs/39782886373) 已通过并生成报告。
|
|
27
|
+
|
|
28
|
+
## 宿主中的大文档
|
|
29
|
+
|
|
30
|
+
文档源码上限为 1,000,000 个 UTF-16 代码单元,绘图和表达式还有独立计算预算,详见[安全策略](../../SECURITY-ch.md)。资源上限控制工作量,编译 API 仍是同步调用。编辑器可以合并连续输入触发的编译;处理来源不可信或较大的文档时,可以在宿主 Worker 或独立进程中编译,并由宿主控制并发和超时。
|
|
31
|
+
|
|
32
|
+
语法节点预算默认 10,000,宿主可用 `compileLocal(source, { limits: { maxSyntaxNodes: 50_000 } })` 按次调整,见[核心 API](../integration/local-integration-ch.md#核心-api)。提高预算后应同时测量编译、内存和最终预览渲染成本。
|
|
33
|
+
|
|
34
|
+
## 渲染优化契约
|
|
35
|
+
|
|
36
|
+
参考渲染器使用编译器产出的依赖信息,跳过不可能读取已变化参数的子树。这是内部渲染优化,不是作者可见功能,也不是新的公开 API。
|
|
37
|
+
|
|
38
|
+
- 公开契约是语义等价:状态值、渲染文字、诊断、可访问属性、静态 SSR 输出和交互行为与不做条件渲染时一致,只有重新计算的范围变化。
|
|
39
|
+
- `document.dependencies` 是冻结、可序列化的内部映射。无法静态判断读取范围的子树标记为 `null`,对这些子树保守渲染。宿主和其他渲染器不得依赖其结构,可以完全忽略。
|
|
40
|
+
- 源码变化、实例销毁、面板重置,以及可能改变隐藏状态的可见性变化,仍会更新受影响的子树。优化不会抑制诊断或校验提示。
|
|
41
|
+
- `npm run verify:memo` 在相同文档和状态修订上比较优化渲染与无条件基线;`npm run verify:release` 包含该检查。只有两者产生等价的可观察输出,渲染优化才可接受。
|
|
42
|
+
|
|
43
|
+
## Playground 实时编辑
|
|
44
|
+
|
|
45
|
+
Playground 在独立的模块 Worker 中调用公开的 `compileLocal`,将连续 150 ms 内的编辑合并。调度器最多保留一个正在编译的任务和一份最新待编译源码;过期结果不会替换当前预览或诊断。输入框和导出始终使用最新源码,等待编译时显示“编译中”并保留上一次预览。预览组件复用相同文档,避免每次按键重建整个预览。
|
|
46
|
+
|
|
47
|
+
源码保存延后执行,切换示例或离开页面时保存待写入的内容。Worker 无法使用或运行失败时,页面提示降级,并合并编辑后在主线程编译;该模式仍有大文档阻塞的成本。正常 Worker 模式中,接收编译结果后的 React 渲染、排版与绘制仍在主线程执行。
|
|
48
|
+
|
|
49
|
+
语言包的同步编译 API 和 `LocalReactiveDocument` 保持原有行为。其他宿主可以参考 `demo/src/local-compile-worker.ts` 与调度器,将编译放到自己管理的 Worker。
|
|
50
|
+
|
|
51
|
+
### 复测
|
|
52
|
+
|
|
53
|
+
在仓库根目录构建语言包后执行:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
node scripts/benchmark-large-documents.mjs
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
脚本预热 3 次、测量 20 次,检查 10、100、300、600 节文章编译结果并保存中位数和 P95。启动 Playground 后,可以从仓库根目录执行以下浏览器检查;默认服务器为 `http://127.0.0.1:5184`,可用 `DEMO_URL` 覆盖。
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
node demo/scripts/verify-editing.mjs
|
|
63
|
+
node demo/scripts/benchmark-editing.mjs
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
编辑基准在 300 节、约 47,000 字符的文章末尾连续键入 10 个字符,按键间隔为 20 ms,记录输入事件到下一次 `requestAnimationFrame` 回调的延迟和主线程长任务。该指标用于观察输入响应,不等同于画面完成绘制的时间;长任务统计包含最终预览渲染。`EDITING_SECTIONS` 可调整节数,`EDITING_REPORT` 可指定报告路径。所有报告写入忽略目录 `artifacts/`。
|
|
67
|
+
|
|
68
|
+
2026-10-22,在上述 Windows 机器上用本机 Edge 对同一份 46,969 字符文章进行一次前后对比。两边均使用 Vite 开发服务、1440 × 1000 视口,原版为 `94fd72e`,优化版包含本节描述的 Worker 调度与预览复用。
|
|
69
|
+
|
|
70
|
+
| 指标 | 原版 | 优化版 |
|
|
71
|
+
| --- | ---: | ---: |
|
|
72
|
+
| 输入到下一帧回调的中位延迟 | 147.3 ms | 9.5 ms |
|
|
73
|
+
| 输入到下一帧回调的最大延迟 | 157.9 ms | 36.9 ms |
|
|
74
|
+
| 连续键入 10 个字符的总耗时 | 2,302 ms | 538 ms |
|
|
75
|
+
|
|
76
|
+
原始报告分别为 `artifacts/benchmark-editing-before.json` 和 `artifacts/benchmark-editing-after.json`。这是一次本机观测,机器负载会影响数值。优化主要减少按键触发的主线程工作,同步 `compileLocal` 本身的算法和单次编译速度保持原样。
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
# Performance measurements
|
|
2
|
-
|
|
3
|
-
Build the language package in the source repository root, then run:
|
|
4
|
-
|
|
5
|
-
```sh
|
|
6
|
-
npm run build
|
|
7
|
-
npm run benchmark
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
The script warms up 3 times and measures 20 times per scenario, reporting the median and P95; raw results are written to `artifacts/benchmark.json`. Use `npm run benchmark -- --iterations 50 --output artifacts/benchmark-50.json` to change the iteration count and output location. The report includes the package version, Node version, operating system and CPU information.
|
|
11
|
-
|
|
12
|
-
## Local baseline
|
|
13
|
-
|
|
14
|
-
2026-10-22, Reactive MD 0.3.0, Node 22.17.0, Windows x64, Intel Core Ultra 5 125H. Other development processes were running on the machine during measurement. This baseline predates the 0.4.0 release; re-run the benchmark before using it as a release comparison.
|
|
15
|
-
|
|
16
|
-
| Scenario | Median | P95 |
|
|
17
|
-
| --- | ---: | ---: |
|
|
18
|
-
| Compile the cost example, 378 characters | 2.51 ms | 5.83 ms |
|
|
19
|
-
| Compile a 250-row responsive table, 7,161 characters | 17.04 ms | 28.05 ms |
|
|
20
|
-
| Compile a 100-section article, 15,550 characters | 45.34 ms | 59.81 ms |
|
|
21
|
-
| 100 consecutive state writes and expression evaluations | 0.20 ms | 0.34 ms |
|
|
22
|
-
| Three curves, 200 sample points each | 0.55 ms | 1.61 ms |
|
|
23
|
-
|
|
24
|
-
Timing includes correctness assertions; one measurement of a runtime scenario includes 100 updates. The plotting scenario includes breakpoint checks for regular functions and non-grid asymptotes.
|
|
25
|
-
|
|
26
|
-
These numbers measure compilation, evaluation and sampling in Node; they do not include browser layout, painting or input-to-frame latency. Use them to compare versions under the same conditions; they set no cross-machine pass thresholds and do not imply that every document within the source limit takes the same time. CI saves measurement reports for Node 24; the [first CI run](https://github.com/yao1145/ReactiveMD/actions/runs/39782886373) passed and produced a report.
|
|
27
|
-
|
|
28
|
-
## Large documents in the host
|
|
29
|
-
|
|
30
|
-
Document source is limited to 1,000,000 UTF-16 code units, and plotting and expressions have separate computation budgets; see the [security policy](../../SECURITY.md) for details. Resource limits bound the work, but the compile API remains synchronous. Editors can coalesce compilations triggered by consecutive input; when handling untrusted or large documents, compile in a host Worker or a separate process, with the host controlling concurrency and timeouts.
|
|
31
|
-
|
|
32
|
-
The syntax node budget defaults to 10,000, and hosts can adjust it per call with `compileLocal(source, { limits: { maxSyntaxNodes: 50_000 } })`, see the [Core API](../integration/local-integration-en.md#core-api). After raising the budget, measure compilation, memory and final preview rendering costs together.
|
|
33
|
-
|
|
34
|
-
## Rendering optimization contract
|
|
35
|
-
|
|
36
|
-
The reference renderer uses dependency information produced by the compiler to skip subtrees that cannot read a changed parameter. This is an internal rendering optimization, not an author-visible feature or a new public API.
|
|
37
|
-
|
|
38
|
-
- The public contract is semantic: state values, rendered text, diagnostics, accessibility attributes, static SSR output and interactive behavior remain the same as an unconditioned render. Only the amount of recomputation changes.
|
|
39
|
-
- `document.dependencies` is a frozen, serializable internal map. It marks subtrees whose reads cannot be decided statically as `null`; those subtrees are rendered conservatively. Hosts and alternative renderers must not depend on its shape, and may ignore it.
|
|
40
|
-
- Source changes, instance disposal, panel reset and visibility changes that can alter hidden state still update the affected subtrees. The optimization never suppresses a diagnostic or a validation hint.
|
|
41
|
-
- `npm run verify:memo` compares the optimized renderer with the unconditioned baseline on the same documents and state revisions. `npm run verify:release` includes that check. A rendering optimization is acceptable only when both produce equivalent observable output.
|
|
42
|
-
|
|
43
|
-
## Playground live editing
|
|
44
|
-
|
|
45
|
-
The Playground calls the public `compileLocal` in a separate module Worker and coalesces edits within 150 ms. The scheduler keeps at most one task being compiled and one latest source waiting to compile; stale results never replace the current preview or diagnostics. The editor and export always use the latest source; while waiting for compilation, the preview shows "Compiling" and keeps the previous preview. The preview component reuses the same document, avoiding a full preview rebuild on every keystroke.
|
|
46
|
-
|
|
47
|
-
Source persistence is deferred, and pending writes are flushed when switching examples or leaving the page. If the Worker is unavailable or fails, the page shows a fallback notice and compiles on the main thread after coalescing edits; that mode still has the cost of blocking on large documents. In normal Worker mode, React rendering, layout and painting after receiving compile results still run on the main thread.
|
|
48
|
-
|
|
49
|
-
The synchronous compile API and `LocalReactiveDocument` keep their existing behavior. Other hosts can refer to `demo/src/local-compile-worker.ts` and the scheduler to move compilation into a Worker they control.
|
|
50
|
-
|
|
51
|
-
### Re-measurement
|
|
52
|
-
|
|
53
|
-
After building the language package in the repository root, run:
|
|
54
|
-
|
|
55
|
-
```sh
|
|
56
|
-
node scripts/benchmark-large-documents.mjs
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
The script warms up 3 times, measures 20 times, checks compilation results for 10-, 100-, 300- and 600-section articles and saves the median and P95. With the Playground running, run the following browser checks from the repository root; the default server is `http://127.0.0.1:5184`, which `DEMO_URL` can override.
|
|
60
|
-
|
|
61
|
-
```sh
|
|
62
|
-
node demo/scripts/verify-editing.mjs
|
|
63
|
-
node demo/scripts/benchmark-editing.mjs
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
The editing benchmark types 10 consecutive characters at the end of a 300-section article of about 47,000 characters, with a 20 ms interval between keystrokes, and records the latency from the input event to the next `requestAnimationFrame` callback plus main-thread long tasks. This metric observes input responsiveness and is not the time until painting completes; long-task statistics include the final preview render. `EDITING_SECTIONS` adjusts the number of sections and `EDITING_REPORT` sets the report path. All reports are written to the ignored `artifacts/` directory.
|
|
67
|
-
|
|
68
|
-
On 2026-10-22, a before/after comparison was run on the same 46,969-character article on the Windows machine above with local Edge. Both sides used the Vite development server and a 1440 × 1000 viewport; the original version was `94fd72e`, and the optimized version includes the Worker scheduling and preview reuse described in this section.
|
|
69
|
-
|
|
70
|
-
| Metric | Original | Optimized |
|
|
71
|
-
| --- | ---: | ---: |
|
|
72
|
-
| Median latency from input to next frame callback | 147.3 ms | 9.5 ms |
|
|
73
|
-
| Maximum latency from input to next frame callback | 157.9 ms | 36.9 ms |
|
|
74
|
-
| Total time to type 10 consecutive characters | 2,302 ms | 538 ms |
|
|
75
|
-
|
|
76
|
-
The raw reports are `artifacts/benchmark-editing-before.json` and `artifacts/benchmark-editing-after.json`. This is a single local observation; machine load affects the numbers. The optimization mainly reduces main-thread work triggered by keystrokes; the algorithm and single-compile speed of synchronous `compileLocal` itself are unchanged.
|
|
1
|
+
# Performance measurements
|
|
2
|
+
|
|
3
|
+
Build the language package in the source repository root, then run:
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm run build
|
|
7
|
+
npm run benchmark
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
The script warms up 3 times and measures 20 times per scenario, reporting the median and P95; raw results are written to `artifacts/benchmark.json`. Use `npm run benchmark -- --iterations 50 --output artifacts/benchmark-50.json` to change the iteration count and output location. The report includes the package version, Node version, operating system and CPU information.
|
|
11
|
+
|
|
12
|
+
## Local baseline
|
|
13
|
+
|
|
14
|
+
2026-10-22, Reactive MD 0.3.0, Node 22.17.0, Windows x64, Intel Core Ultra 5 125H. Other development processes were running on the machine during measurement. This baseline predates the 0.4.0 release; re-run the benchmark before using it as a release comparison.
|
|
15
|
+
|
|
16
|
+
| Scenario | Median | P95 |
|
|
17
|
+
| --- | ---: | ---: |
|
|
18
|
+
| Compile the cost example, 378 characters | 2.51 ms | 5.83 ms |
|
|
19
|
+
| Compile a 250-row responsive table, 7,161 characters | 17.04 ms | 28.05 ms |
|
|
20
|
+
| Compile a 100-section article, 15,550 characters | 45.34 ms | 59.81 ms |
|
|
21
|
+
| 100 consecutive state writes and expression evaluations | 0.20 ms | 0.34 ms |
|
|
22
|
+
| Three curves, 200 sample points each | 0.55 ms | 1.61 ms |
|
|
23
|
+
|
|
24
|
+
Timing includes correctness assertions; one measurement of a runtime scenario includes 100 updates. The plotting scenario includes breakpoint checks for regular functions and non-grid asymptotes.
|
|
25
|
+
|
|
26
|
+
These numbers measure compilation, evaluation and sampling in Node; they do not include browser layout, painting or input-to-frame latency. Use them to compare versions under the same conditions; they set no cross-machine pass thresholds and do not imply that every document within the source limit takes the same time. CI saves measurement reports for Node 24; the [first CI run](https://github.com/yao1145/ReactiveMD/actions/runs/39782886373) passed and produced a report.
|
|
27
|
+
|
|
28
|
+
## Large documents in the host
|
|
29
|
+
|
|
30
|
+
Document source is limited to 1,000,000 UTF-16 code units, and plotting and expressions have separate computation budgets; see the [security policy](../../SECURITY.md) for details. Resource limits bound the work, but the compile API remains synchronous. Editors can coalesce compilations triggered by consecutive input; when handling untrusted or large documents, compile in a host Worker or a separate process, with the host controlling concurrency and timeouts.
|
|
31
|
+
|
|
32
|
+
The syntax node budget defaults to 10,000, and hosts can adjust it per call with `compileLocal(source, { limits: { maxSyntaxNodes: 50_000 } })`, see the [Core API](../integration/local-integration-en.md#core-api). After raising the budget, measure compilation, memory and final preview rendering costs together.
|
|
33
|
+
|
|
34
|
+
## Rendering optimization contract
|
|
35
|
+
|
|
36
|
+
The reference renderer uses dependency information produced by the compiler to skip subtrees that cannot read a changed parameter. This is an internal rendering optimization, not an author-visible feature or a new public API.
|
|
37
|
+
|
|
38
|
+
- The public contract is semantic: state values, rendered text, diagnostics, accessibility attributes, static SSR output and interactive behavior remain the same as an unconditioned render. Only the amount of recomputation changes.
|
|
39
|
+
- `document.dependencies` is a frozen, serializable internal map. It marks subtrees whose reads cannot be decided statically as `null`; those subtrees are rendered conservatively. Hosts and alternative renderers must not depend on its shape, and may ignore it.
|
|
40
|
+
- Source changes, instance disposal, panel reset and visibility changes that can alter hidden state still update the affected subtrees. The optimization never suppresses a diagnostic or a validation hint.
|
|
41
|
+
- `npm run verify:memo` compares the optimized renderer with the unconditioned baseline on the same documents and state revisions. `npm run verify:release` includes that check. A rendering optimization is acceptable only when both produce equivalent observable output.
|
|
42
|
+
|
|
43
|
+
## Playground live editing
|
|
44
|
+
|
|
45
|
+
The Playground calls the public `compileLocal` in a separate module Worker and coalesces edits within 150 ms. The scheduler keeps at most one task being compiled and one latest source waiting to compile; stale results never replace the current preview or diagnostics. The editor and export always use the latest source; while waiting for compilation, the preview shows "Compiling" and keeps the previous preview. The preview component reuses the same document, avoiding a full preview rebuild on every keystroke.
|
|
46
|
+
|
|
47
|
+
Source persistence is deferred, and pending writes are flushed when switching examples or leaving the page. If the Worker is unavailable or fails, the page shows a fallback notice and compiles on the main thread after coalescing edits; that mode still has the cost of blocking on large documents. In normal Worker mode, React rendering, layout and painting after receiving compile results still run on the main thread.
|
|
48
|
+
|
|
49
|
+
The synchronous compile API and `LocalReactiveDocument` keep their existing behavior. Other hosts can refer to `demo/src/local-compile-worker.ts` and the scheduler to move compilation into a Worker they control.
|
|
50
|
+
|
|
51
|
+
### Re-measurement
|
|
52
|
+
|
|
53
|
+
After building the language package in the repository root, run:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
node scripts/benchmark-large-documents.mjs
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The script warms up 3 times, measures 20 times, checks compilation results for 10-, 100-, 300- and 600-section articles and saves the median and P95. With the Playground running, run the following browser checks from the repository root; the default server is `http://127.0.0.1:5184`, which `DEMO_URL` can override.
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
node demo/scripts/verify-editing.mjs
|
|
63
|
+
node demo/scripts/benchmark-editing.mjs
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The editing benchmark types 10 consecutive characters at the end of a 300-section article of about 47,000 characters, with a 20 ms interval between keystrokes, and records the latency from the input event to the next `requestAnimationFrame` callback plus main-thread long tasks. This metric observes input responsiveness and is not the time until painting completes; long-task statistics include the final preview render. `EDITING_SECTIONS` adjusts the number of sections and `EDITING_REPORT` sets the report path. All reports are written to the ignored `artifacts/` directory.
|
|
67
|
+
|
|
68
|
+
On 2026-10-22, a before/after comparison was run on the same 46,969-character article on the Windows machine above with local Edge. Both sides used the Vite development server and a 1440 × 1000 viewport; the original version was `94fd72e`, and the optimized version includes the Worker scheduling and preview reuse described in this section.
|
|
69
|
+
|
|
70
|
+
| Metric | Original | Optimized |
|
|
71
|
+
| --- | ---: | ---: |
|
|
72
|
+
| Median latency from input to next frame callback | 147.3 ms | 9.5 ms |
|
|
73
|
+
| Maximum latency from input to next frame callback | 157.9 ms | 36.9 ms |
|
|
74
|
+
| Total time to type 10 consecutive characters | 2,302 ms | 538 ms |
|
|
75
|
+
|
|
76
|
+
The raw reports are `artifacts/benchmark-editing-before.json` and `artifacts/benchmark-editing-after.json`. This is a single local observation; machine load affects the numbers. The optimization mainly reduces main-thread work triggered by keystrokes; the algorithm and single-compile speed of synchronous `compileLocal` itself are unchanged.
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
# 发布清单
|
|
2
|
-
|
|
3
|
-
本文件是维护者的手动发布流程。本清单覆盖 `0.6.
|
|
4
|
-
|
|
5
|
-
## 发布前确认
|
|
6
|
-
|
|
7
|
-
### 包身份与元数据
|
|
8
|
-
|
|
9
|
-
非 scope 名称 `reactive-md` 已由已发布的 `0.3.0`、`0.3.1` 建立,`reactive-md/react` 和 `reactive-md/styles.css` 子路径也随这些版本生效。`0.5.0` 新增 `reactive-md/editor` 和 `reactive-md/editor/styles.css`,`0.5.1` 至 `0.6.
|
|
10
|
-
|
|
11
|
-
1. 除非维护者明确决定改用 scope,否则保持 `reactive-md`。scope 需要对应的 npm 账号或组织权限。
|
|
12
|
-
2. 如果改名,同时更新 `package.json` 的 `name`、文档中的导入语句、tarball 文件名说明、示例和相关子路径,并在变更记录中按破坏性变更说明。
|
|
13
|
-
3. 核对 `package.json` 的 `repository`、`homepage`、`bugs`、`license`、`engines` 等发布元数据;当前已设置,发布前确认 URL 和最低 Node 版本仍然正确,并确认 `private` 保持移除状态。
|
|
14
|
-
4. 确认 `files` 覆盖发布所需内容。当前包含 `dist-library`、`dist-standalone`、`bin`、`cli`、README(`README.md`、`README-en.md`、`README-ch.md`)、中英文贡献指南、变更记录与安全策略、`THIRD_PARTY_NOTICES.md`、`docs` 和 `examples`;新增文档或 notice 时同步加入 `files`。
|
|
15
|
-
|
|
16
|
-
包名和版本决定 tarball 名称。当前 `0.6.
|
|
17
|
-
|
|
18
|
-
### 第三方 notice
|
|
19
|
-
|
|
20
|
-
库产物打包了 `remark-gfm@4.0.1`、`remark-parse@11.0.0`、`unified@11.0.5`、`elkjs@0.12.0`、`
|
|
21
|
-
|
|
22
|
-
维护者在发布前:
|
|
23
|
-
|
|
24
|
-
1. 运行 `npm run notices`,从已安装依赖重新生成 `THIRD_PARTY_NOTICES.md`。生成脚本覆盖 `remark-gfm`、`remark-parse`、`unified`、`parse5`、`lowlight`、`elkjs`、`
|
|
25
|
-
2. 确认 `package.json` 的 `files` 包含 `THIRD_PARTY_NOTICES.md`,并随 tarball 分发。
|
|
26
|
-
3. 检查 `npm pack --dry-run` 的输出,确认没有 `node_modules`、`demo/`、`demo/artifacts/`、测试产物或本地缓存。
|
|
27
|
-
4. 核对依赖许可证与打包内容一致;新增或升级 Markdown 依赖后重新生成 notice。
|
|
28
|
-
|
|
29
|
-
## 本地 tarball 安装
|
|
30
|
-
|
|
31
|
-
完整的本地门禁是:
|
|
32
|
-
|
|
33
|
-
```sh
|
|
34
|
-
npm ci
|
|
35
|
-
npm run verify:release
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
`verify:release` 运行 Node 端与浏览器检查,构建包,在仓库外安装真实 tarball,并验证多份能力组合后的文档行为;它自行管理预览服务和浏览器生命周期。门禁同时覆盖编辑器入口、其样式表及同一页面的两个编辑器实例。CI 通过 `verify:release:node` 和 `verify:release:browser` 分片运行同一门禁。本机需已安装浏览器。
|
|
39
|
-
|
|
40
|
-
packed 检查会在 `artifacts/release-package/` 保留经过验证的原始安装包,并在同目录的 `package-verification.json` 记录 SHA256 与 npm integrity。完整门禁通过后发布这一安装包;源码、包元数据或随包文档变化后重新验证。
|
|
41
|
-
|
|
42
|
-
需要手工检查包内容时,直接使用 tarball。在仓库根目录:
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
npm pack
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
`npm pack` 会通过 `prepack` 先运行构建和 `npm run notices`,生成 `dist-library/` 与 `THIRD_PARTY_NOTICES.md`。`dist-library/` 是 `package.json` 的 `exports` 指向的目录。随后在一个空目录中验证安装:
|
|
49
|
-
|
|
50
|
-
```sh
|
|
51
|
-
mkdir /tmp/reactive-md-consumer
|
|
52
|
-
cd /tmp/reactive-md-consumer
|
|
53
|
-
npm init -y
|
|
54
|
-
npm install /path/to/reactive-md-0.6.
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
核心入口可在 Node 中直接检查:
|
|
58
|
-
|
|
59
|
-
```sh
|
|
60
|
-
node --input-type=module -e "import { compileLocal, LOCAL_SYNTAX_VERSION } from 'reactive-md'; console.log(LOCAL_SYNTAX_VERSION, compileLocal('# ok').ok)"
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
React 入口需要另装 React 19:
|
|
64
|
-
|
|
65
|
-
```sh
|
|
66
|
-
npm install react@19 react-dom@19
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
```tsx
|
|
70
|
-
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
71
|
-
import 'reactive-md/styles.css';
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
编辑器入口使用相同的 React peer 和独立样式表:
|
|
75
|
-
|
|
76
|
-
```tsx
|
|
77
|
-
import { ReactiveMarkdownEditor } from 'reactive-md/editor';
|
|
78
|
-
import 'reactive-md/editor/styles.css';
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
静态 SSR 渲染由 packed 检查覆盖。编辑器入口在服务端渲染检查中导入,并在浏览器检查中运行。单文件导出的静态首屏水合由 Playwright Chromium 和本地 Edge 浏览器检查覆盖;该路径之外的通用 SSR 水合尚未验证。安装验证还应确认 tarball 中的 `dist-library/types`(包括编辑器入口和样式表)、`dist-standalone`、`bin`、`cli`、`README.md`、`README-en.md`、`README-ch.md`、`CHANGELOG-ch.md`、`SECURITY-ch.md`、`THIRD_PARTY_NOTICES.md`、`docs` 和 `examples` 完整,并检查 `docs` 中没有指向未打包 `demo/`、`src/`、`tests/` 或 `.tasks/` 文件的本地链接。
|
|
82
|
-
|
|
83
|
-
## 发布说明
|
|
84
|
-
|
|
85
|
-
发布说明面向使用者,至少包含:
|
|
86
|
-
|
|
87
|
-
- 包版本、`LOCAL_SYNTAX_VERSION`、组块协议修订与主题协议修订;这些不是同一个版本号。
|
|
88
|
-
- 安装方式:`npm install reactive-md`、`npm install reactive-md@next`,或使用 `npm install reactive-md@<version>` 固定版本;并提供可下载 tarball 作为离线安装选项。
|
|
89
|
-
- 用户可见变化、破坏性变更和迁移步骤;直接链接[变更记录](../../CHANGELOG-ch.md),本轮同时链接[0.5.0 发布说明](../releases/release-0.5.0-ch.md)。
|
|
90
|
-
- 已验证的平台,以及未验证的浏览器、通用 SSR 水合等范围。
|
|
91
|
-
- 已知限制和安全说明链接 [SECURITY-ch.md](../../SECURITY-ch.md)。
|
|
92
|
-
|
|
93
|
-
不要写尚未执行的检查结果,也不要把 CI 配置存在写成 CI 已通过。
|
|
94
|
-
|
|
95
|
-
## 人工发布清单
|
|
96
|
-
|
|
97
|
-
1. 确认工作区干净,变更已审查;`npm ci` 从锁文件安装成功。
|
|
98
|
-
2. 在 Node 22.12 和受支持的较新 LTS(当前为 24)上运行 `npm run verify:release`。这是维护者和 CI 共用的完整门禁,不要用一组自行挑选的命令代替。
|
|
99
|
-
3. 确认版本号、`CHANGELOG-ch.md` 和发布说明一致。`0.6.
|
|
100
|
-
4. 检查门禁保留的安装包,包括文件列表、大小和许可文件。手动重新运行 `npm pack` 会产生新候选包,需要单独完成安装验证。
|
|
101
|
-
5. 核对安装包的 SHA256 与 `artifacts/release-package/package-verification.json` 一致,并记录到发布说明或内部发布记录。
|
|
102
|
-
6. 合并发布提交,等待 `main` 上的 CI 全部通过。
|
|
103
|
-
7. 手动创建并推送 tag,例如 `v0.6.
|
|
104
|
-
8.
|
|
105
|
-
9. 在 npm 和 GitHub Releases 上核对包内容、版本、README、许可与发布说明;从公开 registry 重新安装一次。
|
|
106
|
-
10. 从 registry 验证 README 中的安装命令可用,核对 registry 的完整性摘要与发布 tarball 一致。
|
|
107
|
-
|
|
108
|
-
README 中的版本与安装命令应在打包前准备好,并在发布后验证。发布过程中不要提交 token、`.npmrc` 凭据或本机路径。
|
|
1
|
+
# 发布清单
|
|
2
|
+
|
|
3
|
+
本文件是维护者的手动发布流程。本清单覆盖 `0.6.1`,同时更新 `latest` 与 `next`。版本规则见[版本与兼容性](../compatibility/compatibility-ch.md),面向使用者的说明见[0.6.1 发布说明](../releases/release-0.6.1-ch.md)。
|
|
4
|
+
|
|
5
|
+
## 发布前确认
|
|
6
|
+
|
|
7
|
+
### 包身份与元数据
|
|
8
|
+
|
|
9
|
+
非 scope 名称 `reactive-md` 已由已发布的 `0.3.0`、`0.3.1` 建立,`reactive-md/react` 和 `reactive-md/styles.css` 子路径也随这些版本生效。`0.5.0` 新增 `reactive-md/editor` 和 `reactive-md/editor/styles.css`,`0.5.1` 至 `0.6.1` 保持这些入口。不要把改名当作常规发布准备:改名会破坏导入、状态工具和文档。
|
|
10
|
+
|
|
11
|
+
1. 除非维护者明确决定改用 scope,否则保持 `reactive-md`。scope 需要对应的 npm 账号或组织权限。
|
|
12
|
+
2. 如果改名,同时更新 `package.json` 的 `name`、文档中的导入语句、tarball 文件名说明、示例和相关子路径,并在变更记录中按破坏性变更说明。
|
|
13
|
+
3. 核对 `package.json` 的 `repository`、`homepage`、`bugs`、`license`、`engines` 等发布元数据;当前已设置,发布前确认 URL 和最低 Node 版本仍然正确,并确认 `private` 保持移除状态。
|
|
14
|
+
4. 确认 `files` 覆盖发布所需内容。当前包含 `dist-library`、`dist-standalone`、`bin`、`cli`、README(`README.md`、`README-en.md`、`README-ch.md`)、中英文贡献指南、变更记录与安全策略、`THIRD_PARTY_NOTICES.md`、`docs` 和 `examples`;新增文档或 notice 时同步加入 `files`。
|
|
15
|
+
|
|
16
|
+
包名和版本决定 tarball 名称。当前 `0.6.1` 的预期文件名是 `reactive-md-0.6.1.tgz`;改名或改版本后以 `npm pack` 的实际输出为准。
|
|
17
|
+
|
|
18
|
+
### 第三方 notice
|
|
19
|
+
|
|
20
|
+
库产物打包了 `remark-gfm@4.0.1`、`remark-parse@11.0.0`、`unified@11.0.5`、`elkjs@0.12.0`、`katex@0.19.1` 及其依赖。KaTeX 包含数学字体和 mhchem 扩展。独立 HTML 运行时还打包了 React、React DOM 和 scheduler;库的 React 入口使用宿主提供的 peer dependency。`THIRD_PARTY_NOTICES.md` 保留这些打包依赖的版权和许可声明。
|
|
21
|
+
|
|
22
|
+
维护者在发布前:
|
|
23
|
+
|
|
24
|
+
1. 运行 `npm run notices`,从已安装依赖重新生成 `THIRD_PARTY_NOTICES.md`。生成脚本覆盖 `remark-gfm`、`remark-parse`、`unified`、`parse5`、`lowlight`、`elkjs`、`katex`、`react`、`react-dom` 的依赖树和实际许可证文本,包括 scheduler,以及 mhchem 的上游声明和 Apache-2.0 许可。
|
|
25
|
+
2. 确认 `package.json` 的 `files` 包含 `THIRD_PARTY_NOTICES.md`,并随 tarball 分发。
|
|
26
|
+
3. 检查 `npm pack --dry-run` 的输出,确认没有 `node_modules`、`demo/`、`demo/artifacts/`、测试产物或本地缓存。
|
|
27
|
+
4. 核对依赖许可证与打包内容一致;新增或升级 Markdown 依赖后重新生成 notice。
|
|
28
|
+
|
|
29
|
+
## 本地 tarball 安装
|
|
30
|
+
|
|
31
|
+
完整的本地门禁是:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm ci
|
|
35
|
+
npm run verify:release
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`verify:release` 运行 Node 端与浏览器检查,构建包,在仓库外安装真实 tarball,并验证多份能力组合后的文档行为;它自行管理预览服务和浏览器生命周期。门禁同时覆盖编辑器入口、其样式表及同一页面的两个编辑器实例。CI 通过 `verify:release:node` 和 `verify:release:browser` 分片运行同一门禁。本机需已安装浏览器。
|
|
39
|
+
|
|
40
|
+
packed 检查会在 `artifacts/release-package/` 保留经过验证的原始安装包,并在同目录的 `package-verification.json` 记录 SHA256 与 npm integrity。完整门禁通过后发布这一安装包;源码、包元数据或随包文档变化后重新验证。
|
|
41
|
+
|
|
42
|
+
需要手工检查包内容时,直接使用 tarball。在仓库根目录:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm pack
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`npm pack` 会通过 `prepack` 先运行构建和 `npm run notices`,生成 `dist-library/` 与 `THIRD_PARTY_NOTICES.md`。`dist-library/` 是 `package.json` 的 `exports` 指向的目录。随后在一个空目录中验证安装:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
mkdir /tmp/reactive-md-consumer
|
|
52
|
+
cd /tmp/reactive-md-consumer
|
|
53
|
+
npm init -y
|
|
54
|
+
npm install /path/to/reactive-md-0.6.1.tgz
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
核心入口可在 Node 中直接检查:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
node --input-type=module -e "import { compileLocal, LOCAL_SYNTAX_VERSION } from 'reactive-md'; console.log(LOCAL_SYNTAX_VERSION, compileLocal('# ok').ok)"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
React 入口需要另装 React 19:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
npm install react@19 react-dom@19
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
71
|
+
import 'reactive-md/styles.css';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
编辑器入口使用相同的 React peer 和独立样式表:
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { ReactiveMarkdownEditor } from 'reactive-md/editor';
|
|
78
|
+
import 'reactive-md/editor/styles.css';
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
静态 SSR 渲染由 packed 检查覆盖。编辑器入口在服务端渲染检查中导入,并在浏览器检查中运行。单文件导出的静态首屏水合由 Playwright Chromium 和本地 Edge 浏览器检查覆盖;该路径之外的通用 SSR 水合尚未验证。安装验证还应确认 tarball 中的 `dist-library/types`(包括编辑器入口和样式表)、`dist-standalone`、`bin`、`cli`、`README.md`、`README-en.md`、`README-ch.md`、`CHANGELOG-ch.md`、`SECURITY-ch.md`、`THIRD_PARTY_NOTICES.md`、`docs` 和 `examples` 完整,并检查 `docs` 中没有指向未打包 `demo/`、`src/`、`tests/` 或 `.tasks/` 文件的本地链接。
|
|
82
|
+
|
|
83
|
+
## 发布说明
|
|
84
|
+
|
|
85
|
+
发布说明面向使用者,至少包含:
|
|
86
|
+
|
|
87
|
+
- 包版本、`LOCAL_SYNTAX_VERSION`、组块协议修订与主题协议修订;这些不是同一个版本号。
|
|
88
|
+
- 安装方式:`npm install reactive-md`、`npm install reactive-md@next`,或使用 `npm install reactive-md@<version>` 固定版本;并提供可下载 tarball 作为离线安装选项。
|
|
89
|
+
- 用户可见变化、破坏性变更和迁移步骤;直接链接[变更记录](../../CHANGELOG-ch.md),本轮同时链接[0.5.0 发布说明](../releases/release-0.5.0-ch.md)。
|
|
90
|
+
- 已验证的平台,以及未验证的浏览器、通用 SSR 水合等范围。
|
|
91
|
+
- 已知限制和安全说明链接 [SECURITY-ch.md](../../SECURITY-ch.md)。
|
|
92
|
+
|
|
93
|
+
不要写尚未执行的检查结果,也不要把 CI 配置存在写成 CI 已通过。
|
|
94
|
+
|
|
95
|
+
## 人工发布清单
|
|
96
|
+
|
|
97
|
+
1. 确认工作区干净,变更已审查;`npm ci` 从锁文件安装成功。
|
|
98
|
+
2. 在 Node 22.12 和受支持的较新 LTS(当前为 24)上运行 `npm run verify:release`。这是维护者和 CI 共用的完整门禁,不要用一组自行挑选的命令代替。
|
|
99
|
+
3. 确认版本号、`CHANGELOG-ch.md` 和发布说明一致。`0.6.1` 将公式展示改为 KaTeX,并内嵌数学字体;语法修订 `local-draft-2`、组块协议 `component-protocol-2` 和主题协议 `reactive-md-theme-1` 均保持不变。仅在某条版本轴自身的契约变化时更新它。
|
|
100
|
+
4. 检查门禁保留的安装包,包括文件列表、大小和许可文件。手动重新运行 `npm pack` 会产生新候选包,需要单独完成安装验证。
|
|
101
|
+
5. 核对安装包的 SHA256 与 `artifacts/release-package/package-verification.json` 一致,并记录到发布说明或内部发布记录。
|
|
102
|
+
6. 合并发布提交,等待 `main` 上的 CI 全部通过。
|
|
103
|
+
7. 手动创建并推送 tag,例如 `v0.6.1`。不要在自动发布工作流中保存 npm token。
|
|
104
|
+
8. 为标签创建草稿 GitHub Release,附上已验证的 tarball、`package-verification.json` 和包含 `version`、源码 `commit`、`sha256`、`integrity` 的 `release-manifest.json`。触发 `publish.yml`,传入 `ref=v0.6.1`、`dist_tag=next`、`update_latest=true`、`use_verified_release=true`。npm trusted publishing 通过 OIDC 发包,无需本机 npm 登录或验证码;工作流先核对源码提交与文件摘要,再发布附件中的原始包。等待成功后确认两个渠道。`latest` 不在授权范围内时,传入 `update_latest=false`。
|
|
105
|
+
9. 在 npm 和 GitHub Releases 上核对包内容、版本、README、许可与发布说明;从公开 registry 重新安装一次。
|
|
106
|
+
10. 从 registry 验证 README 中的安装命令可用,核对 registry 的完整性摘要与发布 tarball 一致。
|
|
107
|
+
|
|
108
|
+
README 中的版本与安装命令应在打包前准备好,并在发布后验证。发布过程中不要提交 token、`.npmrc` 凭据或本机路径。
|