reactive-md 0.3.1 → 0.4.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 (177) hide show
  1. package/CHANGELOG-ch.md +113 -0
  2. package/CHANGELOG.md +113 -53
  3. package/CONTRIBUTING-ch.md +62 -0
  4. package/CONTRIBUTING.md +64 -65
  5. package/LICENSE +21 -21
  6. package/README-ch.md +123 -0
  7. package/README-en.md +147 -0
  8. package/README.md +96 -38
  9. package/SECURITY-ch.md +80 -0
  10. package/SECURITY.md +58 -49
  11. package/THIRD_PARTY_NOTICES.md +85 -1
  12. package/bin/reactive-md.mjs +40 -0
  13. package/cli/args.mjs +181 -0
  14. package/cli/assets.mjs +390 -0
  15. package/cli/build.mjs +268 -0
  16. package/cli/document.mjs +130 -0
  17. package/cli/errors.mjs +61 -0
  18. package/cli/fs-utils.mjs +133 -0
  19. package/cli/glob.mjs +203 -0
  20. package/cli/help.mjs +138 -0
  21. package/cli/lint.mjs +177 -0
  22. package/cli/main.mjs +55 -0
  23. package/cli/migrate.mjs +368 -0
  24. package/cli/package.mjs +209 -0
  25. package/dist-library/reactive-md-react.js +3525 -1651
  26. package/dist-library/reactive-md.css +1 -1
  27. package/dist-library/reactive-md.js +1798 -4
  28. package/dist-library/runtime-D3QTVYaz.js +15410 -0
  29. package/dist-library/types/index.d.ts +1 -0
  30. package/dist-library/types/local/LocalDocumentView.d.ts +66 -3
  31. package/dist-library/types/local/authoring.d.ts +63 -0
  32. package/dist-library/types/local/collection-functions.d.ts +4 -0
  33. package/dist-library/types/local/colors.d.ts +2 -0
  34. package/dist-library/types/local/computations.d.ts +53 -0
  35. package/dist-library/types/local/data-functions.d.ts +22 -0
  36. package/dist-library/types/local/data-table.d.ts +65 -0
  37. package/dist-library/types/local/dates.d.ts +2 -0
  38. package/dist-library/types/local/dependencies.d.ts +31 -0
  39. package/dist-library/types/local/diagnostics.d.ts +1450 -0
  40. package/dist-library/types/local/expression.d.ts +13 -3
  41. package/dist-library/types/local/formatting.d.ts +41 -0
  42. package/dist-library/types/local/heading-anchors.d.ts +13 -2
  43. package/dist-library/types/local/i18n.d.ts +18 -0
  44. package/dist-library/types/local/index.d.ts +18 -1
  45. package/dist-library/types/local/limits.d.ts +32 -1
  46. package/dist-library/types/local/locale.d.ts +1 -0
  47. package/dist-library/types/local/math.d.ts +6 -1
  48. package/dist-library/types/local/parser.d.ts +10 -4
  49. package/dist-library/types/local/render-types.d.ts +5 -1
  50. package/dist-library/types/local/retention.d.ts +23 -0
  51. package/dist-library/types/local/schema.d.ts +25 -3
  52. package/dist-library/types/local/source-migration.d.ts +35 -0
  53. package/dist-library/types/local/state.d.ts +80 -0
  54. package/dist-library/types/local/text-length.d.ts +13 -0
  55. package/dist-library/types/local/theme.d.ts +30 -0
  56. package/dist-library/types/local/types.d.ts +112 -4
  57. package/dist-library/types/local/validation.d.ts +32 -0
  58. package/dist-library/types/local/version.d.ts +1 -1
  59. package/dist-library/types/local/worker.d.ts +82 -0
  60. package/dist-library/types/react/index.d.ts +4 -1
  61. package/dist-library/types/shareable.d.ts +64 -0
  62. package/dist-standalone/reactive-md-standalone.css +2 -0
  63. package/dist-standalone/reactive-md-standalone.js +57 -0
  64. package/docs/author-tools-ch.md +56 -0
  65. package/docs/author-tools-en.md +56 -0
  66. package/docs/compatibility-ch.md +103 -0
  67. package/docs/compatibility-en.md +103 -0
  68. package/docs/{component-development.md → component-development-ch.md} +210 -206
  69. package/docs/component-development-en.md +210 -0
  70. package/docs/{component-protocol.md → component-protocol-ch.md} +710 -685
  71. package/docs/component-protocol-en.md +710 -0
  72. package/docs/computations-formatting-ch.md +87 -0
  73. package/docs/computations-formatting-en.md +87 -0
  74. package/docs/constraints-collections-ch.md +84 -0
  75. package/docs/constraints-collections-en.md +84 -0
  76. package/docs/diagnostics-counting-ch.md +84 -0
  77. package/docs/diagnostics-counting-en.md +84 -0
  78. package/docs/local-components-v2-ch.md +138 -0
  79. package/docs/local-components-v2-en.md +104 -0
  80. package/docs/{local-guide.md → local-guide-ch.md} +28 -8
  81. package/docs/local-guide-en.md +961 -0
  82. package/docs/local-integration-ch.md +363 -0
  83. package/docs/local-integration-en.md +363 -0
  84. package/docs/{local-interaction-syntax.md → local-interaction-syntax-ch.md} +66 -20
  85. package/docs/local-interaction-syntax-en.md +483 -0
  86. package/docs/{performance.md → performance-ch.md} +12 -3
  87. package/docs/performance-en.md +76 -0
  88. package/docs/release-0.4.0-ch.md +89 -0
  89. package/docs/release-0.4.0-en.md +89 -0
  90. package/docs/release-0.4.1-ch.md +23 -0
  91. package/docs/release-0.4.1-en.md +23 -0
  92. package/docs/releasing-ch.md +101 -0
  93. package/docs/releasing-en.md +101 -0
  94. package/docs/shareable-export-ch.md +205 -0
  95. package/docs/shareable-export-en.md +207 -0
  96. package/docs/source-versioning-ch.md +159 -0
  97. package/docs/source-versioning-en.md +159 -0
  98. package/docs/theme-protocol-ch.md +107 -0
  99. package/docs/theme-protocol-en.md +107 -0
  100. package/examples/conformance/README.md +33 -31
  101. package/examples/conformance/component-protocol-1.json +482 -194
  102. package/examples/conformance/component-protocol-1.schema.json +76 -76
  103. package/examples/conformance/history/v0.3.1/catalog.reactive.md +20 -0
  104. package/examples/conformance/history/v0.3.1/charts.reactive.md +73 -0
  105. package/examples/conformance/history/v0.3.1/checklist.reactive.md +32 -0
  106. package/examples/conformance/history/v0.3.1/comparison.reactive.md +47 -0
  107. package/examples/conformance/history/v0.3.1/components.reactive.md +44 -0
  108. package/examples/conformance/history/v0.3.1/counter.reactive.md +7 -0
  109. package/examples/conformance/history/v0.3.1/diagnostics.reactive.md +54 -0
  110. package/examples/conformance/history/v0.3.1/diagram.reactive.md +44 -0
  111. package/examples/conformance/history/v0.3.1/gallery.reactive.md +61 -0
  112. package/examples/conformance/history/v0.3.1/local-draft-1.json +50 -0
  113. package/examples/conformance/history/v0.3.1/parameters.reactive.md +36 -0
  114. package/examples/conformance/history/v0.3.1/planning.reactive.md +24 -0
  115. package/examples/conformance/history/v0.3.1/pricing.reactive.md +20 -0
  116. package/examples/conformance/history/v0.3.1/provenance.json +72 -0
  117. package/examples/conformance/local-draft-2.json +212 -0
  118. package/examples/integration/README.md +45 -29
  119. package/examples/integration/core/index.mjs +32 -19
  120. package/examples/integration/core/package.json +7 -7
  121. package/examples/integration/react/index.html +12 -12
  122. package/examples/integration/react/main.jsx +21 -21
  123. package/examples/integration/react/package.json +9 -9
  124. package/examples/integration/worker/index.html +19 -0
  125. package/examples/integration/worker/main.js +61 -0
  126. package/examples/integration/worker/package.json +13 -0
  127. package/examples/integration/worker/worker.js +3 -0
  128. package/examples/local/README.md +64 -58
  129. package/examples/local/catalog.reactive.md +20 -20
  130. package/examples/local/charts.reactive.md +34 -34
  131. package/examples/local/checklist.reactive.md +32 -32
  132. package/examples/local/comparison.reactive.md +47 -47
  133. package/examples/local/components.reactive.md +44 -44
  134. package/examples/local/counter.reactive.md +7 -7
  135. package/examples/local/diagnostics.reactive.md +54 -54
  136. package/examples/local/diagram.reactive.md +44 -44
  137. package/examples/local/gallery.reactive.md +61 -61
  138. package/examples/local/parameters.reactive.md +36 -36
  139. package/examples/local/planning.reactive.md +24 -24
  140. package/examples/local/pricing.reactive.md +20 -20
  141. package/examples/local/recipes/invoice-zh.reactive.md +36 -0
  142. package/examples/local/recipes/invoice.reactive.md +36 -0
  143. package/examples/local/recipes/workshop-zh.reactive.md +33 -0
  144. package/examples/local/recipes/workshop.reactive.md +33 -0
  145. package/examples/local/showcase/README.md +25 -0
  146. package/examples/local/showcase/explore.reactive.md +102 -0
  147. package/examples/local/showcase/flow.reactive.md +86 -0
  148. package/examples/local/showcase/forms.reactive.md +126 -0
  149. package/examples/local/showcase/functions.reactive.md +119 -0
  150. package/examples/local/showcase/layout.reactive.md +100 -0
  151. package/examples/local/showcase/statistics.reactive.md +108 -0
  152. package/examples/local/showcase/tasks.reactive.md +89 -0
  153. package/examples/local/showcase/zh/explore.reactive.md +102 -0
  154. package/examples/local/showcase/zh/flow.reactive.md +86 -0
  155. package/examples/local/showcase/zh/forms.reactive.md +126 -0
  156. package/examples/local/showcase/zh/functions.reactive.md +119 -0
  157. package/examples/local/showcase/zh/layout.reactive.md +100 -0
  158. package/examples/local/showcase/zh/statistics.reactive.md +108 -0
  159. package/examples/local/showcase/zh/tasks.reactive.md +89 -0
  160. package/examples/local/zh/catalog.reactive.md +20 -0
  161. package/examples/local/zh/charts.reactive.md +73 -0
  162. package/examples/local/zh/checklist.reactive.md +32 -0
  163. package/examples/local/zh/comparison.reactive.md +47 -0
  164. package/examples/local/zh/components.reactive.md +44 -0
  165. package/examples/local/zh/counter.reactive.md +7 -0
  166. package/examples/local/zh/diagnostics.reactive.md +54 -0
  167. package/examples/local/zh/diagram.reactive.md +44 -0
  168. package/examples/local/zh/gallery.reactive.md +61 -0
  169. package/examples/local/zh/parameters.reactive.md +36 -0
  170. package/examples/local/zh/planning.reactive.md +24 -0
  171. package/examples/local/zh/pricing.reactive.md +20 -0
  172. package/package.json +91 -77
  173. package/README.en.md +0 -76
  174. package/dist-library/runtime-CPzMEMcW.js +0 -11111
  175. package/docs/compatibility.md +0 -68
  176. package/docs/local-integration.md +0 -218
  177. package/docs/releasing.md +0 -92
package/SECURITY.md CHANGED
@@ -1,71 +1,80 @@
1
- # 安全策略
1
+ # Security policy
2
2
 
3
- Reactive MD 渲染作者编写的本地交互文档。文档是不可信输入时,渲染器、表达式和数学求值都按下面的边界处理。宿主仍然负责授权、网络策略和服务端数据。
3
+ Reactive MD renders local interactive documents written by authors. When document content is untrusted input, the renderer, expressions and math evaluation all stay within the boundaries below. The host remains responsible for authorization, network policy and server-side data.
4
4
 
5
- ## 支持范围
5
+ ## Supported versions
6
6
 
7
- 当前维护最新的 0.x 预览版本。安全修复可能随次版本发布,并在[变更记录](CHANGELOG.md)中说明影响和迁移步骤。
7
+ Current maintenance covers the latest 0.x preview. Security fixes may ship in minor releases and are described in the [changelog](CHANGELOG.md) with impact and migration steps.
8
8
 
9
- ## 威胁边界
9
+ ## Threat boundary
10
10
 
11
- 以下保证有编译器、运行时和渲染器测试覆盖;未列出的能力不做承诺。
11
+ The guarantees below are covered by compiler, runtime and renderer tests; capabilities not listed here are not promised.
12
12
 
13
- ### 文档内容
13
+ ### Document content
14
14
 
15
- - 作者不能执行脚本。`<script>`、原始 HTML、`on-*` 事件属性和作者 CSS 不属于 `local-draft-1`,会作为语法诊断或文本处理,不会作为 HTML 执行。
16
- - React 渲染器不调用 `dangerouslySetInnerHTML`,也不把文档内容写入 `innerHTML`。
17
- - 表达式使用自己的解析器和 AST 求值器,不使用 `eval`、`new Function`,不支持赋值、方法调用、属性访问、原型路径或导入。表达式只能读取文档声明的参数和内置函数。
18
- - LaTeX 通过受预算限制的解析器计算,并由原生 MathML 渲染;渲染器不执行宏、文件、网络或 HTML 入口。未知命令显示为文本。
19
- - 表达式、模板、表格和图表不会发起网络请求;图表数据必须写在文档里。
15
+ - Authors cannot execute scripts. `<script>`, raw HTML, `on-*` event attributes and author CSS are not part of `local-draft-2`; they are treated as syntax diagnostics or text, never executed as HTML.
16
+ - The React renderer does not call `dangerouslySetInnerHTML` and does not write document content into `innerHTML`.
17
+ - Expressions use their own parser and AST evaluator, with no `eval` or `new Function`, and no support for assignment, method calls, property access, prototype paths or imports. Expressions can only read parameters declared by the document and built-in functions.
18
+ - LaTeX is evaluated by a budget-limited parser and rendered as native MathML; the renderer does not execute macros, files, network or HTML entry points. Unknown commands are displayed as text.
19
+ - Expressions, templates, tables and charts do not make network requests; chart data must be written in the document.
20
20
 
21
- ### URL 与网络
21
+ ### URLs and networking
22
22
 
23
- - 图片默认全部拒绝,包括相对路径和协议相对地址,因此加载文档本身不会触发图片请求。
24
- - 只有宿主传入 `urlPolicy` 且策略返回 `true` 时,图片才会加载。带协议的图片地址仍先检查协议,只允许 `http:` 和 `https:`;相对地址则由策略决定。`javascript:`、危险的 `data:` 等地址即使策略放行也会被拒绝。
25
- - 链接默认允许相对地址和 `http:`、`https:`、`mailto:`、`tel:`;外部 HTTP 链接以新标签打开并带 `noopener noreferrer`。危险协议始终拒绝。
26
- - 策略抛出异常时拒绝该地址。获准加载的图片使用 `referrerPolicy="no-referrer"`;同源图片仍可能携带 Cookie,图片白名单应避开业务 API。
27
- - `urlPolicy` 是 URL 允许列表,不是服务端授权。宿主仍需配置 CSP、网络出口、图片代理或沙箱 iframe(当作者完全不可信时)。
23
+ - All images are rejected by default, including relative paths and protocol-relative addresses, so loading the document itself triggers no image requests.
24
+ - Images load only when the host passes `urlPolicy` and the policy returns `true`. Images with a protocol still have that protocol checked first: only `http:` and `https:` are allowed. Relative addresses are decided by the policy. Addresses such as `javascript:` or dangerous `data:` URLs are rejected even if the policy allows them.
25
+ - Links allow relative addresses and `http:`, `https:`, `mailto:` and `tel:` by default; external HTTP links open in a new tab with `noopener noreferrer`. Dangerous protocols are always rejected.
26
+ - If the policy throws, the address is rejected. Images that are allowed to load use `referrerPolicy="no-referrer"`; same-origin images may still carry cookies, so image allowlists should avoid business APIs.
27
+ - A trusted `imageResolver` runs only after the image URL passes protocol checks and `urlPolicy`. It maps an accepted URL to host-controlled output; exported files use only verified `data:image/png|jpeg|gif|webp;base64` values, and links never reach it.
28
+ - `urlPolicy` is a URL allowlist, not server-side authorization. The host still needs to configure CSP, network egress, an image proxy or a sandboxed iframe (when authors are fully untrusted).
28
29
 
29
- ### 资源上限
30
+ ### Resource limits
30
31
 
31
- `src/local/limits.ts` 定义共享上限,编译、运行时和可视化共同使用:
32
+ `src/local/limits.ts` defines shared limits used by compilation, the runtime and visualizations:
32
33
 
33
- | 限制 | 值 |
34
+ | Limit | Value |
34
35
  | --- | --- |
35
- | 单份文档源码 | 1,000,000 字符 |
36
- | 解析期间累计创建的语法节点 | 默认 10,000,由宿主按次配置 |
37
- | 单个字符串值或模板 | 100,000 字符 |
38
- | 单个数组 | 10,000 项 |
39
- | 数组内字符串总长度 | 100,000 字符 |
40
- | 邮箱地址 | 254 字符,线性校验 |
41
- | 诊断数量 | 100 条 |
42
- | 单条诊断文本 | 2,000 字符 |
43
- | 每个绘图组件的曲线数 | 16 |
44
- | 整篇文档请求的曲线采样点 | 20,000 |
45
- | 绘图共享计算步数 | 2,000,000 |
36
+ | Source per document | 1,000,000 characters |
37
+ | Syntax nodes created cumulatively during parsing | 10,000 by default, configured per call by the host |
38
+ | A single string value or template | 100,000 characters |
39
+ | A single array | 10,000 items |
40
+ | Total string length within an array | 100,000 characters |
41
+ | Email address | 254 characters, validated in linear time |
42
+ | Number of diagnostics | 100 |
43
+ | Text of a single diagnostic | 2,000 characters |
44
+ | Curves per plot component | 16 |
45
+ | Curve sample points requested by the whole document | 20,000 |
46
+ | Shared computation steps for plotting | 2,000,000 |
46
47
 
47
- 超限写入会被拒绝,运行时保持上一次合法状态;编译期超限返回诊断。绘图和数学计算还有各自的深度、记号和节点预算。预算用于限制单个文档的工作量,不替代宿主对请求大小、并发和超时的控制。
48
+ Writes over a limit are rejected and the runtime keeps the last valid state; compile-time overruns return diagnostics. Plotting and math evaluation also have their own depth, token and node budgets. Budgets bound the work for a single document; they do not replace host control over request size, concurrency and timeouts.
48
49
 
49
- 宿主通过 `compileLocal(source, { limits: { maxSyntaxNodes } })` 为单次编译调整语法节点预算,取值必须是正的安全整数。文档内容不能修改该设置。省略时保留 10,000 的默认预算;提高节点预算不会改变源码长度、数组、表达式或绘图的其他上限。计数覆盖解析中创建的全部 `LocalNode`,包含部分最终未保留的中间节点。
50
+ Hosts can adjust the syntax node budget for a single compilation with `compileLocal(source, { limits: { maxSyntaxNodes } })`; the value must be a positive safe integer. Document content cannot change this setting. When omitted, the default budget of 10,000 applies; raising the node budget does not change the source length, array, expression or plotting limits. The count covers every `LocalNode` created during parsing, including intermediate nodes that are not kept in the final tree.
50
51
 
51
- ### 状态与隔离
52
+ ### State and isolation
52
53
 
53
- - 参数状态只存在于当前文档实例的内存中。每个 `LocalReactiveDocument` 或 `LocalDocumentView` 实例独立;销毁时会清理订阅、表达式缓存和计时器。
54
- - `createLocalRuntime` 会校验初值和共享控件的约束;`set` 以文档中登记的控件为准,忽略调用方伪造的节点元数据,并且只有在所有共享控件都接受时才原子提交。
55
- - `snapshot()` 返回稳定的冻结快照,其中的数组也被冻结;`get()` 和 `evaluate()` 返回数组副本。状态更新通过 `set()` 校验后提交。
56
- - `disabled` 和 `if` 只是界面展示状态,不是权限控制。业务权限和值校验必须由宿主在提交到服务端时执行。
54
+ - Parameter state exists only in the memory of the current document instance. Each `LocalReactiveDocument` or `LocalDocumentView` instance is independent; disposal clears subscriptions, expression caches and timers.
55
+ - `createLocalRuntime` validates initial values and constraints on shared controls; `set` relies on the controls registered in the document, ignores forged node metadata from the caller, and commits atomically only when every shared control accepts the write.
56
+ - `snapshot()` returns a stable frozen snapshot, including frozen arrays; `get()` and `evaluate()` return array copies. State updates are committed through validated `set()` calls.
57
+ - `disabled` and `if` are display states only, not permission control. Business permissions and value validation must be enforced by the host when submitting to the server.
57
58
 
58
- ## 宿主责任
59
+ ### Shareable HTML export
59
60
 
60
- - 决定谁可以编写、提交和分享文档;限制不可信作者的请求大小、并发和执行时间。编译 1,000,000 字符的文档仍是真实的 CPU 工作。
61
- - 为图片和链接配置 `urlPolicy`;维持 CSP、网络出口控制和图片白名单。
62
- - 在服务端重新校验表单值、权限和业务约束,不信任文档中的 `disabled`、条件显示或客户端状态。
63
- - 需要持久化时,安全地保存原始 `.reactive.md` 源码;运行时状态和 `LocalDocument` 不应当作持久化格式。
64
- - 在服务端静态渲染不可信文档之前,评估渲染进程的资源上限;水合行为未验证,不应作为安全边界。
65
- - 第三方依赖漏洞应同时报告给上游项目;本包只负责自身集成代码。
61
+ - `reactive-md-state/v1` stores only public binding names and serializable values. It excludes `@` internal bindings, revisions, node IDs, AST data, UI state and timers. Source digest, syntax, parameter set and every value are validated before import; unknown or conflicting keys reject the whole file.
62
+ - Interactive HTML embeds a fixed standalone runtime and a CSP with no network connections, frames, objects, base injection or form submission. Only inline styles/runtime and `data:` images are allowed. JSON, source, titles and notices are escaped for their HTML/script context.
63
+ - The CLI inlines only relative raster files that resolve inside the document directory or an explicit asset root. It rejects remote images, URL schemes, absolute paths, traversal, symlink escapes, SVG, forged formats and oversized assets. The demo export dialog disables HTML export when images are present.
64
+ - Static HTML contains no runtime script or auto-mount payload. Static-first hydration is covered only in the single-file Chromium/Edge path; it is not a general hydration or sandboxing guarantee. Use a sandboxed iframe for fully untrusted authors.
65
+ - Exporting current parameters is an explicit host/reader action. Treat the generated state file and HTML as potentially sensitive; choose initial values unless current values are intentionally meant to be shared.
66
66
 
67
- ## 报告漏洞
67
+ ## Host responsibilities
68
68
 
69
- 仓库已启用 GitHub 私密漏洞报告。请通过 [Report a vulnerability](https://github.com/yao1145/ReactiveMD/security/advisories/new) 提交受影响版本、最小复现、预期影响和修复建议。
69
+ - Decide who may write, submit and share documents; limit request size, concurrency and execution time for untrusted authors. Compiling a 1,000,000-character document is still real CPU work.
70
+ - Configure `urlPolicy` for images and links; maintain CSP, network egress control and image allowlists.
71
+ - Revalidate form values, permissions and business constraints on the server; do not trust `disabled`, conditional visibility or client state inside the document.
72
+ - When persistence is needed, store the original `.reactive.md` source securely; runtime state and `LocalDocument` should not be treated as a persistence format.
73
+ - Before statically rendering untrusted documents on the server, assess the resource limits of the rendering process. General SSR hydration remains unverified; only the single-file static-first path has Chromium/Edge coverage. Hydration is not a security boundary.
74
+ - Report vulnerabilities in third-party dependencies upstream as well; this package is responsible only for its own integration code.
70
75
 
71
- 使用私密渠道报告漏洞细节;公开 issue 和 PR 中请移除利用代码、凭据、用户数据及受影响部署的信息。
76
+ ## Reporting vulnerabilities
77
+
78
+ The repository has GitHub private vulnerability reporting enabled. Submit affected versions, a minimal reproduction, expected impact and remediation suggestions through [Report a vulnerability](https://github.com/yao1145/ReactiveMD/security/advisories/new).
79
+
80
+ Use the private channel to report vulnerability details; remove exploit code, credentials, user data and information about affected deployments from public issues and PRs.
@@ -1,6 +1,6 @@
1
1
  # Third-party notices
2
2
 
3
- Reactive MD bundles its Markdown dependencies. This file preserves license texts for the installed dependency trees of remark-gfm, remark-parse and unified, including supporting type packages. React and React DOM are host-provided peer dependencies and are distributed separately.
3
+ Reactive MD bundles its Markdown dependencies. The standalone HTML runtime also bundles React, React DOM and scheduler. This file preserves license texts for those installed dependency trees, including supporting type packages. The library React entry uses host-provided React and React DOM peers.
4
4
 
5
5
  Regenerate after dependency updates with `node scripts/generate-notices.mjs`.
6
6
 
@@ -1623,6 +1623,62 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1623
1623
  SOFTWARE.
1624
1624
  ```
1625
1625
 
1626
+ ## react-dom@19.3.1
1627
+
1628
+ Declared license: MIT
1629
+
1630
+ ```text
1631
+ MIT License
1632
+
1633
+ Copyright (c) Meta Platforms, Inc. and affiliates.
1634
+
1635
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1636
+ of this software and associated documentation files (the "Software"), to deal
1637
+ in the Software without restriction, including without limitation the rights
1638
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1639
+ copies of the Software, and to permit persons to whom the Software is
1640
+ furnished to do so, subject to the following conditions:
1641
+
1642
+ The above copyright notice and this permission notice shall be included in all
1643
+ copies or substantial portions of the Software.
1644
+
1645
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1646
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1647
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1648
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1649
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1650
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1651
+ SOFTWARE.
1652
+ ```
1653
+
1654
+ ## react@19.3.1
1655
+
1656
+ Declared license: MIT
1657
+
1658
+ ```text
1659
+ MIT License
1660
+
1661
+ Copyright (c) Meta Platforms, Inc. and affiliates.
1662
+
1663
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1664
+ of this software and associated documentation files (the "Software"), to deal
1665
+ in the Software without restriction, including without limitation the rights
1666
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1667
+ copies of the Software, and to permit persons to whom the Software is
1668
+ furnished to do so, subject to the following conditions:
1669
+
1670
+ The above copyright notice and this permission notice shall be included in all
1671
+ copies or substantial portions of the Software.
1672
+
1673
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1674
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1675
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1676
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1677
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1678
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1679
+ SOFTWARE.
1680
+ ```
1681
+
1626
1682
  ## remark-gfm@4.0.1
1627
1683
 
1628
1684
  Declared license: MIT
@@ -1708,6 +1764,34 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1708
1764
  THE SOFTWARE.
1709
1765
  ```
1710
1766
 
1767
+ ## scheduler@0.28.0
1768
+
1769
+ Declared license: MIT
1770
+
1771
+ ```text
1772
+ MIT License
1773
+
1774
+ Copyright (c) Meta Platforms, Inc. and affiliates.
1775
+
1776
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1777
+ of this software and associated documentation files (the "Software"), to deal
1778
+ in the Software without restriction, including without limitation the rights
1779
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1780
+ copies of the Software, and to permit persons to whom the Software is
1781
+ furnished to do so, subject to the following conditions:
1782
+
1783
+ The above copyright notice and this permission notice shall be included in all
1784
+ copies or substantial portions of the Software.
1785
+
1786
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1787
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1788
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1789
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1790
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1791
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1792
+ SOFTWARE.
1793
+ ```
1794
+
1711
1795
  ## trough@2.2.0
1712
1796
 
1713
1797
  Declared license: MIT
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * reactive-md command-line interface.
4
+ *
5
+ * Exit codes:
6
+ * 0 success
7
+ * 2 usage or argument error
8
+ * 3 document compile, render, React or build-artifact error
9
+ * 4 input or output file I/O error
10
+ * 5 asset or security policy error
11
+ *
12
+ * Build artifacts and the package metadata are located relative to this file's
13
+ * installed package root (bin/..), never the current working directory.
14
+ */
15
+ import path from 'node:path';
16
+ import { fileURLToPath } from 'node:url';
17
+ import { CliError, EXIT } from '../cli/errors.mjs';
18
+ import { runCli } from '../cli/main.mjs';
19
+
20
+ const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
21
+ const context = {
22
+ packageRoot,
23
+ stdout: process.stdout,
24
+ stderr: process.stderr,
25
+ };
26
+
27
+ try {
28
+ process.exitCode = await runCli(process.argv.slice(2), context);
29
+ } catch (error) {
30
+ if (error instanceof CliError) {
31
+ if (!error.reported) {
32
+ context.stderr.write(`reactive-md: ${error.message}\n`);
33
+ }
34
+ process.exitCode = error.exitCode;
35
+ } else {
36
+ const message = error instanceof Error ? error.message : String(error);
37
+ context.stderr.write(`reactive-md: unexpected error: ${message}\n`);
38
+ process.exitCode = EXIT.DOCUMENT;
39
+ }
40
+ }
package/cli/args.mjs ADDED
@@ -0,0 +1,181 @@
1
+ import { usageError } from './errors.mjs';
2
+
3
+ /** A local asset root may be a Windows drive path; it must never be a URL. */
4
+ function isUrlLike(value) {
5
+ const match = /^([a-z][a-z0-9+.-]*):/i.exec(value);
6
+ if (!match) return false;
7
+ // C:\docs and C:/docs are local drive paths, not URL schemes.
8
+ if (match[1].length === 1 && /^[a-z]:[\\/]/i.test(value)) return false;
9
+ return true;
10
+ }
11
+
12
+ /**
13
+ * @param {string[]} argv
14
+ * @param {Map<string, {key: string, boolean?: boolean}>} spec
15
+ * @returns {{positionals: string[], options: Record<string, string | boolean>}}
16
+ */
17
+ function parseOptions(argv, spec) {
18
+ const positionals = [];
19
+ const options = {};
20
+ let literal = false;
21
+
22
+ for (let index = 0; index < argv.length; index += 1) {
23
+ const token = argv[index];
24
+ if (literal) {
25
+ positionals.push(token);
26
+ continue;
27
+ }
28
+ if (token === '--') {
29
+ literal = true;
30
+ continue;
31
+ }
32
+ if (token === '-' || !token.startsWith('-')) {
33
+ positionals.push(token);
34
+ continue;
35
+ }
36
+
37
+ let name = token;
38
+ let inlineValue;
39
+ if (token.startsWith('--')) {
40
+ const equals = token.indexOf('=');
41
+ if (equals > 2) {
42
+ name = token.slice(0, equals);
43
+ inlineValue = token.slice(equals + 1);
44
+ }
45
+ }
46
+ const entry = spec.get(name);
47
+ if (!entry) {
48
+ throw usageError(`Unknown option "${name}". Run "reactive-md build --help" or "reactive-md lint --help" for usage.`);
49
+ }
50
+ if (entry.boolean) {
51
+ if (inlineValue !== undefined) throw usageError(`Option "${name}" does not take a value.`);
52
+ options[entry.key] = true;
53
+ continue;
54
+ }
55
+ let value = inlineValue;
56
+ if (value === undefined) {
57
+ if (index + 1 >= argv.length) throw usageError(`Option "${name}" requires a value.`);
58
+ value = argv[index + 1];
59
+ index += 1;
60
+ }
61
+ options[entry.key] = value;
62
+ }
63
+
64
+ return { positionals, options };
65
+ }
66
+
67
+ /** @param {unknown} value */
68
+ function requireText(value, option) {
69
+ if (typeof value !== 'string' || value.trim() === '') {
70
+ throw usageError(`Option "${option}" requires a non-empty value.`);
71
+ }
72
+ return value;
73
+ }
74
+
75
+ /** @param {unknown} value @param {string} option @param {readonly string[]} choices */
76
+ function choice(value, option, choices) {
77
+ const normalized = String(value).toLowerCase();
78
+ if (!choices.includes(normalized)) {
79
+ throw usageError(`Invalid value for "${option}": "${value}". Expected ${choices.join(' or ')}.`);
80
+ }
81
+ return normalized;
82
+ }
83
+
84
+ const BUILD_SPEC = new Map([
85
+ ['-o', { key: 'output' }],
86
+ ['--output', { key: 'output' }],
87
+ ['--mode', { key: 'mode' }],
88
+ ['--state-file', { key: 'stateFile' }],
89
+ ['--assets', { key: 'assets' }],
90
+ ['--asset-root', { key: 'assetRoot' }],
91
+ ['--locale', { key: 'locale' }],
92
+ ['--color-scheme', { key: 'colorScheme' }],
93
+ ['--title', { key: 'title' }],
94
+ ['--strict', { key: 'strict', boolean: true }],
95
+ ['-h', { key: 'help', boolean: true }],
96
+ ['--help', { key: 'help', boolean: true }],
97
+ ]);
98
+
99
+ const LINT_SPEC = new Map([
100
+ ['--json', { key: 'json', boolean: true }],
101
+ ['--strict', { key: 'strict', boolean: true }],
102
+ ['-h', { key: 'help', boolean: true }],
103
+ ['--help', { key: 'help', boolean: true }],
104
+ ]);
105
+
106
+ /**
107
+ * @param {string[]} argv
108
+ * @returns {{
109
+ * help: boolean, input?: string, output?: string, mode?: 'interactive'|'static',
110
+ * stateFile?: string, assets?: 'inline'|'omit', assetRoot?: string,
111
+ * locale?: 'en'|'zh', colorScheme?: 'auto'|'light'|'dark', title?: string,
112
+ * strict?: boolean
113
+ * }}
114
+ */
115
+ export function parseBuildArgs(argv) {
116
+ const { positionals, options } = parseOptions(argv, BUILD_SPEC);
117
+ if (options.help) return { help: true };
118
+
119
+ if (positionals.length === 0) {
120
+ throw usageError('Missing input document. Usage: reactive-md build <doc.reactive.md> -o <doc.html>.');
121
+ }
122
+ if (positionals.length > 1) {
123
+ throw usageError(`Expected one input document, received ${positionals.length}: ${positionals.join(', ')}.`);
124
+ }
125
+ const input = requireText(positionals[0], 'input');
126
+ if (options.output === undefined) {
127
+ throw usageError('Missing required option "--output" (-o). Usage: reactive-md build <doc.reactive.md> -o <doc.html>.');
128
+ }
129
+ const output = requireText(options.output, '--output');
130
+ const mode = options.mode === undefined ? 'interactive' : choice(options.mode, '--mode', ['interactive', 'static']);
131
+ const assets = options.assets === undefined ? 'inline' : choice(options.assets, '--assets', ['inline', 'omit']);
132
+ const locale = options.locale === undefined ? 'en' : choice(options.locale, '--locale', ['en', 'zh']);
133
+ const colorScheme = options.colorScheme === undefined
134
+ ? 'auto'
135
+ : choice(options.colorScheme, '--color-scheme', ['auto', 'light', 'dark']);
136
+
137
+ let stateFile;
138
+ if (options.stateFile !== undefined) stateFile = requireText(options.stateFile, '--state-file');
139
+ let assetRoot;
140
+ if (options.assetRoot !== undefined) {
141
+ assetRoot = requireText(options.assetRoot, '--asset-root');
142
+ if (isUrlLike(assetRoot)) {
143
+ throw usageError('Option "--asset-root" must be a local directory path; URLs are not supported.');
144
+ }
145
+ }
146
+
147
+ return {
148
+ help: false,
149
+ input,
150
+ output,
151
+ mode,
152
+ stateFile,
153
+ assets,
154
+ assetRoot,
155
+ locale,
156
+ colorScheme,
157
+ title: typeof options.title === 'string' ? options.title : undefined,
158
+ strict: options.strict === true,
159
+ };
160
+ }
161
+
162
+ /**
163
+ * @param {string[]} argv
164
+ * @returns {{help: boolean, inputs?: string[], json?: boolean, strict?: boolean}}
165
+ */
166
+ export function parseLintArgs(argv) {
167
+ const { positionals, options } = parseOptions(argv, LINT_SPEC);
168
+ if (options.help) return { help: true };
169
+ if (positionals.length === 0) {
170
+ throw usageError('Missing lint inputs. Usage: reactive-md lint <files-or-dirs-or-globs...>.');
171
+ }
172
+ if (positionals.some((input) => input.trim() === '')) {
173
+ throw usageError('Lint input paths must not be empty.');
174
+ }
175
+ return {
176
+ help: false,
177
+ inputs: positionals,
178
+ json: options.json === true,
179
+ strict: options.strict === true,
180
+ };
181
+ }