reactive-md 0.5.3 → 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 +195 -165
- package/CHANGELOG.md +195 -165
- package/CONTRIBUTING-ch.md +67 -62
- package/CONTRIBUTING.md +69 -64
- package/README-ch.md +157 -155
- package/README-en.md +184 -181
- package/README.md +184 -181
- package/SECURITY-ch.md +81 -81
- package/SECURITY.md +81 -81
- package/THIRD_PARTY_NOTICES.md +585 -1
- 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-DJJjKYg9.js → authoring-BEVyth5X.js} +58 -58
- package/dist-library/compiler-Cm3ppMxG.js +46044 -0
- package/dist-library/react-Bh7_oxZp.js +59655 -0
- package/dist-library/reactive-md-authoring.js +2 -2
- package/dist-library/reactive-md-editor.js +13 -0
- 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 +123 -123
- package/dist-library/{runtime-DXtle_6c.js → runtime-DlFYQ4s_.js} +151 -151
- package/dist-library/types/editor/types.d.ts +2 -0
- package/dist-library/types/local/code-block.d.ts +3 -1
- package/dist-library/types/local/code-languages.d.ts +7 -0
- package/dist-library/types/local/compiled-data.d.ts +6 -0
- package/dist-library/types/local/compiler.d.ts +1 -0
- package/dist-library/types/local/diagnostics.d.ts +31 -0
- package/dist-library/types/local/diagram-layout.d.ts +69 -0
- package/dist-library/types/local/html-names.d.ts +6 -0
- package/dist-library/types/local/html-table.d.ts +25 -0
- package/dist-library/types/local/math-display.d.ts +22 -22
- package/dist-library/types/local/math-view.d.ts +6 -7
- package/dist-library/types/local/table-surface.d.ts +10 -0
- package/dist-library/types/local/types.d.ts +2 -0
- package/dist-library/types/local/visuals.d.ts +9 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +331 -51
- package/docs/README.md +84 -0
- package/docs/{compatibility-ch.md → compatibility/compatibility-ch.md} +121 -109
- package/docs/{compatibility-en.md → compatibility/compatibility-en.md} +121 -109
- package/docs/{source-versioning-ch.md → compatibility/source-versioning-ch.md} +159 -159
- package/docs/{source-versioning-en.md → compatibility/source-versioning-en.md} +159 -159
- package/docs/{component-development-ch.md → development/component-development-ch.md} +210 -210
- package/docs/{component-development-en.md → development/component-development-en.md} +210 -210
- package/docs/{component-protocol-ch.md → development/component-protocol-ch.md} +747 -747
- package/docs/{component-protocol-en.md → development/component-protocol-en.md} +747 -747
- package/docs/{performance-ch.md → development/performance-ch.md} +76 -76
- package/docs/{performance-en.md → development/performance-en.md} +76 -76
- package/docs/{releasing-ch.md → development/releasing-ch.md} +108 -108
- package/docs/{releasing-en.md → development/releasing-en.md} +108 -108
- package/docs/guides/local-guide-ch.md +513 -0
- package/docs/guides/local-guide-en.md +513 -0
- package/docs/{author-tools-ch.md → integration/author-tools-ch.md} +57 -57
- package/docs/{author-tools-en.md → integration/author-tools-en.md} +57 -57
- package/docs/{editor-ch.md → integration/editor-ch.md} +7 -6
- package/docs/{editor-en.md → integration/editor-en.md} +7 -6
- package/docs/{local-integration-ch.md → integration/local-integration-ch.md} +33 -15
- package/docs/{local-integration-en.md → integration/local-integration-en.md} +33 -15
- package/docs/{shareable-export-ch.md → integration/shareable-export-ch.md} +221 -209
- package/docs/{shareable-export-en.md → integration/shareable-export-en.md} +223 -211
- package/docs/{computations-formatting-ch.md → reference/computations-formatting-ch.md} +87 -87
- package/docs/{computations-formatting-en.md → reference/computations-formatting-en.md} +87 -87
- package/docs/{constraints-collections-ch.md → reference/constraints-collections-ch.md} +84 -84
- package/docs/{constraints-collections-en.md → reference/constraints-collections-en.md} +84 -84
- package/docs/{diagnostics-counting-ch.md → reference/diagnostics-counting-ch.md} +104 -84
- package/docs/{diagnostics-counting-en.md → reference/diagnostics-counting-en.md} +104 -84
- package/docs/{html-compatibility-ch.md → reference/html-compatibility-ch.md} +42 -4
- package/docs/{html-compatibility-en.md → reference/html-compatibility-en.md} +42 -4
- package/docs/{local-components-v2-ch.md → reference/local-components-v2-ch.md} +138 -138
- package/docs/{local-components-v2-en.md → reference/local-components-v2-en.md} +104 -104
- package/docs/{local-interaction-syntax-ch.md → reference/local-interaction-syntax-ch.md} +515 -492
- package/docs/{local-interaction-syntax-en.md → reference/local-interaction-syntax-en.md} +511 -488
- package/docs/{theme-protocol-ch.md → reference/theme-protocol-ch.md} +107 -107
- package/docs/{theme-protocol-en.md → reference/theme-protocol-en.md} +107 -107
- package/docs/{release-0.4.0-ch.md → releases/release-0.4.0-ch.md} +89 -89
- package/docs/{release-0.4.0-en.md → releases/release-0.4.0-en.md} +89 -89
- package/docs/{release-0.4.1-ch.md → releases/release-0.4.1-ch.md} +23 -23
- package/docs/{release-0.4.1-en.md → releases/release-0.4.1-en.md} +23 -23
- package/docs/{release-0.5.0-ch.md → releases/release-0.5.0-ch.md} +4 -4
- package/docs/{release-0.5.0-en.md → releases/release-0.5.0-en.md} +4 -4
- package/docs/{release-0.5.1-ch.md → releases/release-0.5.1-ch.md} +4 -4
- package/docs/{release-0.5.1-en.md → releases/release-0.5.1-en.md} +4 -4
- package/docs/{release-0.5.2-ch.md → releases/release-0.5.2-ch.md} +3 -3
- package/docs/{release-0.5.2-en.md → releases/release-0.5.2-en.md} +3 -3
- package/docs/{release-0.5.3-ch.md → releases/release-0.5.3-ch.md} +1 -1
- package/docs/{release-0.5.3-en.md → releases/release-0.5.3-en.md} +1 -1
- package/docs/releases/release-0.6.0-ch.md +57 -0
- package/docs/releases/release-0.6.0-en.md +57 -0
- 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 -45
- 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/html-compat.reactive.md +19 -0
- 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 -145
- package/dist-library/compiler-UyPwGzJZ.js +0 -22109
- package/dist-library/react-fizgU3i8.js +0 -12764
- package/docs/local-guide-ch.md +0 -967
- package/docs/local-guide-en.md +0 -967
|
@@ -1,109 +1,121 @@
|
|
|
1
|
-
# Versions and compatibility
|
|
2
|
-
|
|
3
|
-
Reactive MD is currently a 0.x preview. This page covers package versions, syntax versions, what can be persisted, the diagnostics contract and the current platform scope. See [Source revisions and migration](source-versioning-en.md) for explicit revision declarations, the migration API and `reactive-md migrate`, [Local mode integration](local-integration-en.md) for the public API and style integration, [0.
|
|
4
|
-
|
|
5
|
-
## Version mapping
|
|
6
|
-
|
|
7
|
-
| Item | Current value | Notes |
|
|
8
|
-
| --- | --- | --- |
|
|
9
|
-
| Package version | `0.
|
|
10
|
-
| Distribution tags | `latest` → `0.
|
|
11
|
-
| Syntax version | `local-draft-2` | `LOCAL_SYNTAX_VERSION`; the current build accepts only this revision |
|
|
12
|
-
| Source revision directive | Optional `<!-- reactive-md: local-draft-2 -->` | One line in the document prologue; unversioned source keeps current-revision behavior |
|
|
13
|
-
| Component protocol | `component-protocol-2` | Contribution and acceptance contract, see [Component protocol](component-protocol-en.md); not a runtime version selection parameter |
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
1
|
+
# Versions and compatibility
|
|
2
|
+
|
|
3
|
+
Reactive MD is currently a 0.x preview. This page covers package versions, syntax versions, what can be persisted, the diagnostics contract and the current platform scope. See [Source revisions and migration](source-versioning-en.md) for explicit revision declarations, the migration API and `reactive-md migrate`, [Local mode integration](../integration/local-integration-en.md) for the public API and style integration, the [0.6.1 release notes](../releases/release-0.6.1-en.md) for the current release, and [0.4.0 release and migration](../releases/release-0.4.0-en.md) for that minor series.
|
|
4
|
+
|
|
5
|
+
## Version mapping
|
|
6
|
+
|
|
7
|
+
| Item | Current value | Notes |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| Package version | `0.6.1` | 0.x preview; 0.6.1 is available on both `latest` and `next` |
|
|
10
|
+
| Distribution tags | `latest` → `0.6.1`; `next` → `0.6.1` | Default installs use `latest` |
|
|
11
|
+
| Syntax version | `local-draft-2` | `LOCAL_SYNTAX_VERSION`; the current build accepts only this revision |
|
|
12
|
+
| Source revision directive | Optional `<!-- reactive-md: local-draft-2 -->` | One line in the document prologue; unversioned source keeps current-revision behavior |
|
|
13
|
+
| Component protocol | `component-protocol-2` | Contribution and acceptance contract, see [Component protocol](../development/component-protocol-en.md); not a runtime version selection parameter |
|
|
14
|
+
| Theme protocol | `reactive-md-theme-1` | Document themes and host CSS integration |
|
|
15
|
+
| Authoring entry | `reactive-md/authoring` | Schema, catalog and editor helpers, without React or CSS |
|
|
16
|
+
| Unstyled React entry | `reactive-md/react/unstyled` | React renderer without a stylesheet dependency |
|
|
17
|
+
| Core entry | `reactive-md` | Compilation, expressions and runtime, without loading React |
|
|
18
|
+
| React entry | `reactive-md/react` | `LocalReactiveDocument`, `LocalDocumentView` |
|
|
19
|
+
| Editor entry | `reactive-md/editor` | `ReactiveMarkdownEditor` and its types; requires React 19 |
|
|
20
|
+
| Renderer style entry | `reactive-md/styles.css` | Document and component styles, explicitly imported by the host |
|
|
21
|
+
| Screen style entry | `reactive-md/screen.css` | Alias of `reactive-md/styles.css` |
|
|
22
|
+
| Print style entry | `reactive-md/print.css` | Optional document print layout and page margins |
|
|
23
|
+
| Editor style entry | `reactive-md/editor/styles.css` | Independent editor styles, scoped to the editor root |
|
|
24
|
+
|
|
25
|
+
One package version corresponds to exactly one syntax revision. Before upgrading the package, record the `LOCAL_SYNTAX_VERSION` your application uses. If document sources come from another syntax revision, keep rendering them with the old package version or rewrite them according to the migration notes below. `compileLocal(source, options?)` has no syntax version parameter; hosts can adjust the syntax node budget for a single compilation through `options.limits.maxSyntaxNodes`, see [Local mode integration](../integration/local-integration-en.md).
|
|
26
|
+
|
|
27
|
+
## Explicit source revisions
|
|
28
|
+
|
|
29
|
+
A source may declare its revision with one `<!-- reactive-md: local-draft-2 -->` line in the prologue. Unversioned source is read as the current revision, without a new warning. An explicit `local-draft-1` or unknown revision is rejected with a `local.version.*` diagnostic and no runtime is created; declaring an old revision does not select an old parser. Malformed, duplicate and misplaced directives are rejected the same way.
|
|
30
|
+
|
|
31
|
+
Readers built before this directive existed, including `0.3.1`, treat it as an ordinary comment and do not enforce the check. Migrate old documents before relying on it. `inspectLocalSourceVersion`, `checkLocalUpgrade` and `migrateLocalSource` expose the declaration outside the compiler, and `reactive-md migrate` performs the single-source metadata migration. See [Source revisions and migration](source-versioning-en.md).
|
|
32
|
+
|
|
33
|
+
## Compatibility rules for 0.x
|
|
34
|
+
|
|
35
|
+
- Minor versions (`0.3` to `0.4`) may contain breaking changes; patch versions contain only compatibility and security fixes.
|
|
36
|
+
- The 0.x phase does not promise a fixed deprecation period. Every breaking change is recorded in the [changelog](../../CHANGELOG.md), with the old form, new form and migration steps.
|
|
37
|
+
- Before 1.0, treat every upgrade as potentially requiring changes to document sources or host code.
|
|
38
|
+
- Applications should pin the package version, keep the original `.reactive.md` sources, and rerun compile and render checks with their own documents and examples after upgrading.
|
|
39
|
+
|
|
40
|
+
## Core semantic compatibility
|
|
41
|
+
|
|
42
|
+
Within a syntax revision, compatible package updates preserve the meaning of accepted source:
|
|
43
|
+
|
|
44
|
+
- Controls keep their public value types, initial-value rules, shared-binding constraints and validation rules. Hidden controls still initialize, and showing them again does not reset their values.
|
|
45
|
+
- Expressions keep strict operand types, operator precedence, short-circuit evaluation and finite-number rules. A failed local calculation does not replace a valid input or stop unrelated content.
|
|
46
|
+
- Invalid parameter writes leave the last valid state unchanged; multi-value writes commit atomically. Panel reset restores its own controls and component state, and dependent content updates consistently.
|
|
47
|
+
- Prose, formulas and visualizations read the same parameter values. Code and inert fallback regions stay literal. Source locations remain one-based with UTF-16 offsets and half-open ranges.
|
|
48
|
+
- Rendered content, control labels and interactions are semantic outputs. Generated node/DOM IDs, internal `@` keys, AST layout, caches, pixel layout and diagnostic wording are outside the stable source contract.
|
|
49
|
+
|
|
50
|
+
From `local-draft-1` to `local-draft-2`, this promise covers the common supported language after upgrade checks. New reserved identifiers and newly active tags require manual source changes. Text-length counting is an explicit compatibility exception that the migrator requires you to accept; completed-checklist styling is a visual exception. A semantic change outside these recorded exceptions requires a syntax revision and migration notes.
|
|
51
|
+
|
|
52
|
+
Regression data in [the historical corpus](../../examples/conformance/history/v0.3.1/provenance.json) preserves actual `v0.3.1` sources, their source commit and SHA256 digests. The regression suite checks the original conformance expectations, public values, rejected writes, initialization, resets and migration rendering. Internal IDs are excluded from comparisons.
|
|
53
|
+
|
|
54
|
+
## Breaking changes and migration
|
|
55
|
+
|
|
56
|
+
`0.5.0` added the `reactive-md/editor` entry and its independent stylesheet. `0.5.1` adds editor views, theme palettes and HTML compatibility. They keep `local-draft-2`, `component-protocol-1` and `reactive-md-theme-1`. Existing `reactive-md`, `reactive-md/react` and `reactive-md/styles.css` imports keep working, and documents written for 0.4.x need no migration. The editor requires React 19; see the [editor guide](../integration/editor-en.md) for its history and rendering boundaries.
|
|
57
|
+
|
|
58
|
+
`0.6.1` switches formula display to KaTeX with bundled WOFF2 fonts and accessible MathML. Plot evaluation and protocol revisions are unchanged. Invalid formulas fall back to bounded source text with a warning. `align` now numbers rows; use `align*` or `aligned` to omit automatic numbers. See the [0.6.1 release notes](../releases/release-0.6.1-en.md).
|
|
59
|
+
|
|
60
|
+
`0.6.0` adds native HTML tables, `align` and link `target`/`rel`, more math environments and commands, mhchem chemistry and expanded code highlighting, and switches diagrams to a layered layout. Unparseable native HTML now falls back to source. `compileLocal` returns only plain objects and arrays, and the editor adds `insertText`. Syntax, component and theme revisions remain unchanged, and existing imports keep working. See the [0.6.0 release notes](../releases/release-0.6.0-en.md).
|
|
61
|
+
|
|
62
|
+
`0.5.3` adds host authoring tools, consistent compile options, math fallback diagnostics and separate screen/print stylesheets. Existing entries remain available; import `reactive-md/print.css` explicitly for document print layout. Syntax, component and theme revisions remain unchanged. See the [0.5.3 release notes](../releases/release-0.5.3-en.md).
|
|
63
|
+
|
|
64
|
+
`0.5.2` adds the opt-in host component extension axis and raises the component protocol to `component-protocol-2`. The syntax revision and theme protocol remain unchanged, existing imports keep working, and documents written for 0.5.x need no migration. See the [0.5.2 release notes](../releases/release-0.5.2-en.md).
|
|
65
|
+
|
|
66
|
+
`0.4.0` adds [constraints and collections](../reference/constraints-collections-en.md): `LocalRuntime.validate()`, serializable `LocalValidation` rules, numeric arrays and generated tables. Hosts implementing a runtime adapter need the new `validate()` method; exhaustive value-kind checks need `number-array`. Rename bindings colliding with `sum`, `average`, `minOf` or `maxOf`.
|
|
67
|
+
|
|
68
|
+
`0.4.0` adds [named calculations and formatting functions](../reference/computations-formatting-en.md). `computed`/`const` use the existing local tag syntax. The new built-in function names become reserved; rename colliding input bindings and their references before using this release. `document.bindings` and `initialState` still contain writable controls; snapshots also expose successful calculated values.
|
|
69
|
+
|
|
70
|
+
`0.4.0` establishes `local-draft-2`. Unversioned source that uses supported `local-draft-1` forms remains valid; an explicit `local-draft-1` declaration is rejected until migrated. The build now recognizes 15 additional tag names: the ten `local-draft-2` components plus `computed`, `const`, `validation`, `data-table` and `column`. Text that previously displayed as an unknown or literal tag now parses as a component or declaration; move literal examples into code spans or fences. The leading `<theme>` declaration is document metadata and is not counted as a component. See [0.4.0 release and migration](../releases/release-0.4.0-en.md) for the complete rename and upgrade checklist.
|
|
71
|
+
|
|
72
|
+
Author-visible syntax changes establish a new syntax revision, such as `local-draft-2`, and raise the minor version and update `LOCAL_SYNTAX_VERSION`. Changes to the core or React API are also recorded in the changelog. The project does not rewrite document bodies automatically. `reactive-md migrate` moves one source's metadata declaration and blocks body-level conflicts; after upgrading, authors or hosts complete any remaining source changes according to the record.
|
|
73
|
+
|
|
74
|
+
Legacy configuration syntax is not part of `local-draft-2`. Common replacements:
|
|
75
|
+
|
|
76
|
+
| Old form | What to do in `local-draft-2` |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| Directives such as `:::card`, `:::row` | Tags such as `<card>`, `<grid>` |
|
|
79
|
+
| YAML `state:` declaring parameters | `bind` and `initial` on controls |
|
|
80
|
+
| YAML `computed:` | `{{ expression }}` in the prose |
|
|
81
|
+
| `actions:`, button actions, `on-*` events | No equivalent entry point; use component built-in interactions and panel reset |
|
|
82
|
+
| `data:` or external API data | Markdown tables written directly in the prose; parameters are declared by controls |
|
|
83
|
+
| Persisted runtime state | The host saves the original source. Public parameters may additionally be exported as a validated `reactive-md-state/v1` file; it is tied to the source digest, syntax revision and exact public parameter set and is not a document format. |
|
|
84
|
+
|
|
85
|
+
## What to persist
|
|
86
|
+
|
|
87
|
+
Persist the original `.reactive.md` source. A `reactive-md-state/v1` file may preserve public parameter values for the same source and syntax revision; it is rejected when the digest, revision or parameter set differs. Migration changes the source digest, so export a fresh state file after migrating; migration never rewrites state files. Do not persist `LocalDocument`, `LocalNode`, `node.id`, `initialState`, `LocalSnapshot` or internal `@` runtime keys: they belong to the current runtime object and their structure and field meanings are not guaranteed across versions. `node.id` is regenerated when the source changes. Diagnostic line numbers, columns and offsets locate the current source and are not stable persistence identifiers.
|
|
88
|
+
|
|
89
|
+
## Diagnostics contract
|
|
90
|
+
|
|
91
|
+
`Diagnostic` contains `code`, `message`, `severity`, `range`, `line` and `column`.
|
|
92
|
+
|
|
93
|
+
- Lines and columns are one-based. Columns and half-open ranges count UTF-16 code units in the original source.
|
|
94
|
+
- `line`, `column` and `range` can be used for programmatic location and editor jumps.
|
|
95
|
+
- `code` is a string identifier, such as `local.type`, `expression-type` or `latex-plot-range`. Existing codes keep their meaning within one 0.x minor series. New codes may be added; removal, renaming or a change of meaning requires a new minor version and migration notes.
|
|
96
|
+
- `message` contains default English display text. Use `formatLocalDiagnostic(diagnostic, 'zh')` for Chinese. Wording may improve; do not parse messages or make business decisions based on their complete text. Language changes preserve machine fields.
|
|
97
|
+
- `severity` is `warning` or `error`. Structurally complete unknown tags keep their source and produce fallback warnings, and compilation can still succeed; footnotes render normally. Compile errors make `result.ok` `false` and disable the preview. Runtime local errors affect only the corresponding content.
|
|
98
|
+
|
|
99
|
+
See [Diagnostics and counting rules](../reference/diagnostics-counting-en.md) for units and resource-budget scopes.
|
|
100
|
+
|
|
101
|
+
## Platforms and runtimes
|
|
102
|
+
|
|
103
|
+
| Environment | Current status |
|
|
104
|
+
| --- | --- |
|
|
105
|
+
| Node.js 22.12+ | Minimum for development and Node-side consumption; CI targets both 22.12 and 24 |
|
|
106
|
+
| ESM | The only module format; no CommonJS entry |
|
|
107
|
+
| React 19 | Required by `reactive-md/react` and `reactive-md/editor`; the core entry does not depend on React |
|
|
108
|
+
| Microsoft Edge (Chromium-based) | Local browser verification has used Edge |
|
|
109
|
+
| Playwright Chromium | Full Linux CI browser suite |
|
|
110
|
+
| Playwright Firefox and WebKit | Core workflows at 1280px and 375px, including personal documents and interactive HTML export; included in the browser release gate and CI |
|
|
111
|
+
| Safari on Apple devices | Device testing remains separate from Playwright WebKit engine checks |
|
|
112
|
+
| Shareable state format | `reactive-md-state/v1`: public parameter values with a syntax version and source digest; see [Shareable documents](../integration/shareable-export-en.md) |
|
|
113
|
+
| Single-file HTML format | `reactive-md-html/v1`: interactive or static export, with an inline standalone runtime only in interactive mode |
|
|
114
|
+
| SSR | `react-dom/server` static rendering is covered by the packed check. The editor entry has no top-level DOM access and can be imported and rendered on the server; editing interactions run on the client. Static-first hydration of the single-file export is covered in Playwright Chromium/Edge; general SSR hydration is unverified and should be checked before use |
|
|
115
|
+
|
|
116
|
+
Node-side consumption means importing `reactive-md` in Node and calling `compileLocal` and `createLocalRuntime` without a DOM. React rendering requires a browser environment, or the host must handle server output itself.
|
|
117
|
+
|
|
118
|
+
See the [syntax specification](../reference/local-interaction-syntax-en.md) for the language scope, and the [security policy](../../SECURITY.md) for the security boundary and host responsibilities.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
See [local-draft-2 components and migration](../reference/local-components-v2-en.md) for new tags, colors and slot state, and [0.4.0 release and migration](../releases/release-0.4.0-en.md) for the upgrade checklist. 0.6.1 is available on both `latest` and `next`.
|
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
# 源码修订与迁移
|
|
2
|
-
|
|
3
|
-
本文说明 `0.4.0` 中的显式源码修订、编译器的处理方式,以及纯核心 API 与 CLI 迁移工具。语法规则见[语法规范](local-interaction-syntax-ch.md),包版本与 API 兼容规则见[版本与兼容性](compatibility-ch.md),组块升级清单见[0.4.0 发布与迁移](release-0.4.0-ch.md)。
|
|
4
|
-
|
|
5
|
-
## 声明修订
|
|
6
|
-
|
|
7
|
-
源码用一行 HTML 注释声明修订:
|
|
8
|
-
|
|
9
|
-
```markdown
|
|
10
|
-
<!-- reactive-md: local-draft-2 -->
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
该指令属于文档前导区,位于 `<theme>` 声明和正文之前。BOM、空行和普通 Markdown 注释可以出现在它前面。只允许一条指令。
|
|
14
|
-
|
|
15
|
-
行内代码、代码围栏、数学区域和按原文显示的未知标签示例都不是指令。在文档里展示这一行,不会为周围文档声明版本。
|
|
16
|
-
|
|
17
|
-
编译行为:
|
|
18
|
-
|
|
19
|
-
| 源码 | 结果 |
|
|
20
|
-
| --- | --- |
|
|
21
|
-
| 没有指令 | 按当前修订 `local-draft-2` 解析,与之前一致;不新增警告 |
|
|
22
|
-
| `local-draft-2` | 正常解析 |
|
|
23
|
-
| `local-draft-1` 或其他显式旧修订 | 以 `local.version.*` 诊断拒绝 |
|
|
24
|
-
| 未知、格式错误、重复或位置错误的指令 | 以 `local.version.*` 诊断拒绝 |
|
|
25
|
-
|
|
26
|
-
版本声明被拒绝时不创建运行时。声明旧修订不会选择旧解析器,也不会让文档在现行规则下可读;必须先迁移源码。
|
|
27
|
-
|
|
28
|
-
在这一声明出现之前构建的读者(包括 `0.3.1`)会把这条注释当作普通 HTML 注释。它们不校验声明,不拒绝旧修订,也不执行这项检查。声明保护的是在本版本及后续版本中打开的文档;依赖这项检查前,先迁移旧文档。
|
|
29
|
-
|
|
30
|
-
## 查看声明的修订
|
|
31
|
-
|
|
32
|
-
`inspectLocalSourceVersion` 从 `reactive-md` 导出,不编译,也不创建运行时:
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
import { inspectLocalSourceVersion } from 'reactive-md';
|
|
36
|
-
|
|
37
|
-
const info = inspectLocalSourceVersion(source);
|
|
38
|
-
// {
|
|
39
|
-
// declaredVersion: string | null,
|
|
40
|
-
// effectiveVersion: string,
|
|
41
|
-
// supported: boolean,
|
|
42
|
-
// range: SourceRange | null,
|
|
43
|
-
// diagnostics: Diagnostic[]
|
|
44
|
-
// }
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
- `declaredVersion` 是指令声明的修订;无指令时为 `null`。
|
|
48
|
-
- `effectiveVersion` 是用于解释判定的修订:有声明时取声明值,否则取当前修订。`supported` 为 `false` 时不进行解释。
|
|
49
|
-
- `supported` 表示当前编译器是否接受该修订。
|
|
50
|
-
- `range` 指向原始源码中的指令;没有指令时为 `null`。
|
|
51
|
-
- `diagnostics` 使用 `local.version.*` 前缀报告格式错误、重复、位置错误、旧修订或未知声明。
|
|
52
|
-
|
|
53
|
-
无指令源码返回 `declaredVersion: null`、`effectiveVersion: 'local-draft-2'`、`supported: true`,不产生版本诊断。
|
|
54
|
-
|
|
55
|
-
## 检查升级
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
import { checkLocalUpgrade } from 'reactive-md';
|
|
59
|
-
|
|
60
|
-
const check = checkLocalUpgrade(source);
|
|
61
|
-
// {
|
|
62
|
-
// ok: boolean,
|
|
63
|
-
// fromVersion: string,
|
|
64
|
-
// toVersion: 'local-draft-2',
|
|
65
|
-
// needsMigration: boolean,
|
|
66
|
-
// diagnostics: Diagnostic[]
|
|
67
|
-
// }
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
`fromVersion` 默认取声明的修订;源码没有声明时取当前修订。可以用 `LocalUpgradeOptions` 覆盖:
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
type LocalUpgradeOptions = {
|
|
74
|
-
fromVersion?: string;
|
|
75
|
-
allowSemanticChanges?: boolean;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const check = checkLocalUpgrade(oldSource, { fromVersion: 'local-draft-1' });
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
无版本声明的历史文档需要传入 `fromVersion: 'local-draft-1'`,才会执行 draft-1 检查。显式 `fromVersion` 与声明不一致时,检查被拒绝。迁移源只接受 `local-draft-1` 和当前的 `local-draft-2`;旧版 YAML 修订和未知名称会被拒绝。
|
|
82
|
-
|
|
83
|
-
`needsMigration` 表示源码需要写入或替换声明:无声明源码需要补上当前指令,当前源码已经完整,draft-1 源码需要替换指令。版本变化本身可以识别、但存在阻止安全迁移的条件时,`ok` 为 `false`。
|
|
84
|
-
|
|
85
|
-
## 迁移源码
|
|
86
|
-
|
|
87
|
-
```ts
|
|
88
|
-
import { migrateLocalSource } from 'reactive-md';
|
|
89
|
-
|
|
90
|
-
const result = migrateLocalSource(oldSource, { fromVersion: 'local-draft-1' });
|
|
91
|
-
// {
|
|
92
|
-
// ok: boolean,
|
|
93
|
-
// fromVersion: string,
|
|
94
|
-
// toVersion: 'local-draft-2',
|
|
95
|
-
// needsMigration: boolean,
|
|
96
|
-
// diagnostics: Diagnostic[],
|
|
97
|
-
// source: string,
|
|
98
|
-
// changed: boolean,
|
|
99
|
-
// edits: { range: SourceRange; text: string }[]
|
|
100
|
-
// }
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
迁移只写入或替换元数据注释,保留正文。正文原始字节、UTF-8 BOM 和 CRLF 换行保持不变;操作幂等,已迁移到当前版本的源码返回 `changed: false` 和相同文本。`edits` 定位每处替换。迁移被阻止时不产生迁移结果,调用方传入的内容保持不变。
|
|
104
|
-
|
|
105
|
-
把 `local-draft-1` 源码迁移到 `local-draft-2` 之前,迁移会阻止:
|
|
106
|
-
|
|
107
|
-
- 使用 17 个新增保留表达式名的绑定:`sum`、`average`、`minOf`、`maxOf`、`formatNumber`、`formatPercent`、`formatScientific`、`formatCurrency`、`trim`、`lower`、`upper`、`startsWith`、`endsWith`、`replace`、`slice`、`dateCompare`、`dateDiff`;
|
|
108
|
-
- 代码之外出现的 15 个新增可识别标签名:`jump`、`anchor`、`text`、`section`、`multi-select`、`range-slider`、`coordinate`、`quiz`、`steps`、`step`、`computed`、`const`、`validation`、`data-table`、`column`;
|
|
109
|
-
- 表达式中的数组语法或新增内置函数调用;字符串字面量中的文本不触发此检查;
|
|
110
|
-
- 源码当前的编译错误。
|
|
111
|
-
|
|
112
|
-
诊断给出准确位置。迁移不重命名标识符、不改写表达式,也不激活原先按原文显示的标签;这些属于作者对源码的修改。
|
|
113
|
-
|
|
114
|
-
文本控件需要一次明确的兼容决定。`input` 或 `textarea` 带大于零的 `min-length`,或带 `max-length` 时,astral Unicode 的读者语义会改变:draft-2 按 Unicode 码点计数,draft-1 按 UTF-16 代码单元计数。除非允许语义变化,迁移会阻止这些控件:
|
|
115
|
-
|
|
116
|
-
```ts
|
|
117
|
-
migrateLocalSource(oldSource, {
|
|
118
|
-
fromVersion: 'local-draft-1',
|
|
119
|
-
allowSemanticChanges: true,
|
|
120
|
-
});
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
开启后迁移继续,并为每个受影响的控件返回警告。新的码点上限就是预期读者行为时使用该选项。
|
|
124
|
-
|
|
125
|
-
清单完成样式是有记录的兼容例外。这项视觉变化本身不阻止迁移,也不按核心运行时语义失败处理。
|
|
126
|
-
|
|
127
|
-
迁移会改变源码摘要。现有 `reactive-md-state/v1` 文件随后无法通过摘要校验,迁移后应重新导出状态文件。迁移不会改写状态文件。
|
|
128
|
-
|
|
129
|
-
## CLI
|
|
130
|
-
|
|
131
|
-
```sh
|
|
132
|
-
reactive-md migrate doc.reactive.md
|
|
133
|
-
reactive-md migrate - --from local-draft-1 -o doc.reactive.md
|
|
134
|
-
reactive-md migrate doc.reactive.md --check
|
|
135
|
-
reactive-md migrate doc.reactive.md --check --json
|
|
136
|
-
reactive-md migrate old.reactive.md --from local-draft-1 --accept-semantic-changes -o new.reactive.md
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
| 选项 | 含义 |
|
|
140
|
-
| --- | --- |
|
|
141
|
-
| `[file\|-]` | 输入文件;`-` 表示标准输入 |
|
|
142
|
-
| `--from local-draft-1\|local-draft-2` | 源修订;默认取声明或当前修订 |
|
|
143
|
-
| `--check` | 只报告是否需要迁移,从不写入 |
|
|
144
|
-
| `--json` | 标准输出结构化报告,且是唯一的 stdout 内容 |
|
|
145
|
-
| `-o, --output <file>` | 新建文件;拒绝任何已存在的路径,包括输入文件本身 |
|
|
146
|
-
| `--accept-semantic-changes` | 允许文本控件长度语义变化,并报告警告 |
|
|
147
|
-
| `--locale en\|zh` | 诊断和摘要的显示语言 |
|
|
148
|
-
|
|
149
|
-
默认把迁移后的源码写到标准输出。输入文件不会被覆盖;`-o` 使用独占创建,目标已存在即报错。没有 `-o` 时,请重定向 stdout 保存结果。
|
|
150
|
-
|
|
151
|
-
`--check` 从不写入。它输出诊断和摘要;带 `--json` 时输出 JSON 报告。需要迁移或被阻止时退出 `1`,源码已是当前版本时退出 `0`。普通迁移被阻止时退出 `1`,成功时退出 `0`。用法和 I/O 错误退出 `2`。不要把源码文本混入 JSON 报告。
|
|
152
|
-
|
|
153
|
-
命令一次迁移一份源码。本版本不提供 `--write`、不就地覆盖,也不提供破坏性批量操作。
|
|
154
|
-
|
|
155
|
-
## 范围
|
|
156
|
-
|
|
157
|
-
迁移处理声明的元数据变化,并检查正文能否跨越修订边界。它不是旧版读取器:不解释 YAML `state`/`data`/`computed`/`actions` 配置块、directive 或其他 draft 之前的语法,也不改写正文。在 `local-draft-2` 下已经无法编译的源码会保持阻止状态,直到作者修复报告的位置。
|
|
158
|
-
|
|
159
|
-
`0.
|
|
1
|
+
# 源码修订与迁移
|
|
2
|
+
|
|
3
|
+
本文说明 `0.4.0` 中的显式源码修订、编译器的处理方式,以及纯核心 API 与 CLI 迁移工具。语法规则见[语法规范](../reference/local-interaction-syntax-ch.md),包版本与 API 兼容规则见[版本与兼容性](compatibility-ch.md),组块升级清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。
|
|
4
|
+
|
|
5
|
+
## 声明修订
|
|
6
|
+
|
|
7
|
+
源码用一行 HTML 注释声明修订:
|
|
8
|
+
|
|
9
|
+
```markdown
|
|
10
|
+
<!-- reactive-md: local-draft-2 -->
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
该指令属于文档前导区,位于 `<theme>` 声明和正文之前。BOM、空行和普通 Markdown 注释可以出现在它前面。只允许一条指令。
|
|
14
|
+
|
|
15
|
+
行内代码、代码围栏、数学区域和按原文显示的未知标签示例都不是指令。在文档里展示这一行,不会为周围文档声明版本。
|
|
16
|
+
|
|
17
|
+
编译行为:
|
|
18
|
+
|
|
19
|
+
| 源码 | 结果 |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| 没有指令 | 按当前修订 `local-draft-2` 解析,与之前一致;不新增警告 |
|
|
22
|
+
| `local-draft-2` | 正常解析 |
|
|
23
|
+
| `local-draft-1` 或其他显式旧修订 | 以 `local.version.*` 诊断拒绝 |
|
|
24
|
+
| 未知、格式错误、重复或位置错误的指令 | 以 `local.version.*` 诊断拒绝 |
|
|
25
|
+
|
|
26
|
+
版本声明被拒绝时不创建运行时。声明旧修订不会选择旧解析器,也不会让文档在现行规则下可读;必须先迁移源码。
|
|
27
|
+
|
|
28
|
+
在这一声明出现之前构建的读者(包括 `0.3.1`)会把这条注释当作普通 HTML 注释。它们不校验声明,不拒绝旧修订,也不执行这项检查。声明保护的是在本版本及后续版本中打开的文档;依赖这项检查前,先迁移旧文档。
|
|
29
|
+
|
|
30
|
+
## 查看声明的修订
|
|
31
|
+
|
|
32
|
+
`inspectLocalSourceVersion` 从 `reactive-md` 导出,不编译,也不创建运行时:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { inspectLocalSourceVersion } from 'reactive-md';
|
|
36
|
+
|
|
37
|
+
const info = inspectLocalSourceVersion(source);
|
|
38
|
+
// {
|
|
39
|
+
// declaredVersion: string | null,
|
|
40
|
+
// effectiveVersion: string,
|
|
41
|
+
// supported: boolean,
|
|
42
|
+
// range: SourceRange | null,
|
|
43
|
+
// diagnostics: Diagnostic[]
|
|
44
|
+
// }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- `declaredVersion` 是指令声明的修订;无指令时为 `null`。
|
|
48
|
+
- `effectiveVersion` 是用于解释判定的修订:有声明时取声明值,否则取当前修订。`supported` 为 `false` 时不进行解释。
|
|
49
|
+
- `supported` 表示当前编译器是否接受该修订。
|
|
50
|
+
- `range` 指向原始源码中的指令;没有指令时为 `null`。
|
|
51
|
+
- `diagnostics` 使用 `local.version.*` 前缀报告格式错误、重复、位置错误、旧修订或未知声明。
|
|
52
|
+
|
|
53
|
+
无指令源码返回 `declaredVersion: null`、`effectiveVersion: 'local-draft-2'`、`supported: true`,不产生版本诊断。
|
|
54
|
+
|
|
55
|
+
## 检查升级
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { checkLocalUpgrade } from 'reactive-md';
|
|
59
|
+
|
|
60
|
+
const check = checkLocalUpgrade(source);
|
|
61
|
+
// {
|
|
62
|
+
// ok: boolean,
|
|
63
|
+
// fromVersion: string,
|
|
64
|
+
// toVersion: 'local-draft-2',
|
|
65
|
+
// needsMigration: boolean,
|
|
66
|
+
// diagnostics: Diagnostic[]
|
|
67
|
+
// }
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`fromVersion` 默认取声明的修订;源码没有声明时取当前修订。可以用 `LocalUpgradeOptions` 覆盖:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
type LocalUpgradeOptions = {
|
|
74
|
+
fromVersion?: string;
|
|
75
|
+
allowSemanticChanges?: boolean;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const check = checkLocalUpgrade(oldSource, { fromVersion: 'local-draft-1' });
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
无版本声明的历史文档需要传入 `fromVersion: 'local-draft-1'`,才会执行 draft-1 检查。显式 `fromVersion` 与声明不一致时,检查被拒绝。迁移源只接受 `local-draft-1` 和当前的 `local-draft-2`;旧版 YAML 修订和未知名称会被拒绝。
|
|
82
|
+
|
|
83
|
+
`needsMigration` 表示源码需要写入或替换声明:无声明源码需要补上当前指令,当前源码已经完整,draft-1 源码需要替换指令。版本变化本身可以识别、但存在阻止安全迁移的条件时,`ok` 为 `false`。
|
|
84
|
+
|
|
85
|
+
## 迁移源码
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { migrateLocalSource } from 'reactive-md';
|
|
89
|
+
|
|
90
|
+
const result = migrateLocalSource(oldSource, { fromVersion: 'local-draft-1' });
|
|
91
|
+
// {
|
|
92
|
+
// ok: boolean,
|
|
93
|
+
// fromVersion: string,
|
|
94
|
+
// toVersion: 'local-draft-2',
|
|
95
|
+
// needsMigration: boolean,
|
|
96
|
+
// diagnostics: Diagnostic[],
|
|
97
|
+
// source: string,
|
|
98
|
+
// changed: boolean,
|
|
99
|
+
// edits: { range: SourceRange; text: string }[]
|
|
100
|
+
// }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
迁移只写入或替换元数据注释,保留正文。正文原始字节、UTF-8 BOM 和 CRLF 换行保持不变;操作幂等,已迁移到当前版本的源码返回 `changed: false` 和相同文本。`edits` 定位每处替换。迁移被阻止时不产生迁移结果,调用方传入的内容保持不变。
|
|
104
|
+
|
|
105
|
+
把 `local-draft-1` 源码迁移到 `local-draft-2` 之前,迁移会阻止:
|
|
106
|
+
|
|
107
|
+
- 使用 17 个新增保留表达式名的绑定:`sum`、`average`、`minOf`、`maxOf`、`formatNumber`、`formatPercent`、`formatScientific`、`formatCurrency`、`trim`、`lower`、`upper`、`startsWith`、`endsWith`、`replace`、`slice`、`dateCompare`、`dateDiff`;
|
|
108
|
+
- 代码之外出现的 15 个新增可识别标签名:`jump`、`anchor`、`text`、`section`、`multi-select`、`range-slider`、`coordinate`、`quiz`、`steps`、`step`、`computed`、`const`、`validation`、`data-table`、`column`;
|
|
109
|
+
- 表达式中的数组语法或新增内置函数调用;字符串字面量中的文本不触发此检查;
|
|
110
|
+
- 源码当前的编译错误。
|
|
111
|
+
|
|
112
|
+
诊断给出准确位置。迁移不重命名标识符、不改写表达式,也不激活原先按原文显示的标签;这些属于作者对源码的修改。
|
|
113
|
+
|
|
114
|
+
文本控件需要一次明确的兼容决定。`input` 或 `textarea` 带大于零的 `min-length`,或带 `max-length` 时,astral Unicode 的读者语义会改变:draft-2 按 Unicode 码点计数,draft-1 按 UTF-16 代码单元计数。除非允许语义变化,迁移会阻止这些控件:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
migrateLocalSource(oldSource, {
|
|
118
|
+
fromVersion: 'local-draft-1',
|
|
119
|
+
allowSemanticChanges: true,
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
开启后迁移继续,并为每个受影响的控件返回警告。新的码点上限就是预期读者行为时使用该选项。
|
|
124
|
+
|
|
125
|
+
清单完成样式是有记录的兼容例外。这项视觉变化本身不阻止迁移,也不按核心运行时语义失败处理。
|
|
126
|
+
|
|
127
|
+
迁移会改变源码摘要。现有 `reactive-md-state/v1` 文件随后无法通过摘要校验,迁移后应重新导出状态文件。迁移不会改写状态文件。
|
|
128
|
+
|
|
129
|
+
## CLI
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
reactive-md migrate doc.reactive.md
|
|
133
|
+
reactive-md migrate - --from local-draft-1 -o doc.reactive.md
|
|
134
|
+
reactive-md migrate doc.reactive.md --check
|
|
135
|
+
reactive-md migrate doc.reactive.md --check --json
|
|
136
|
+
reactive-md migrate old.reactive.md --from local-draft-1 --accept-semantic-changes -o new.reactive.md
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
| 选项 | 含义 |
|
|
140
|
+
| --- | --- |
|
|
141
|
+
| `[file\|-]` | 输入文件;`-` 表示标准输入 |
|
|
142
|
+
| `--from local-draft-1\|local-draft-2` | 源修订;默认取声明或当前修订 |
|
|
143
|
+
| `--check` | 只报告是否需要迁移,从不写入 |
|
|
144
|
+
| `--json` | 标准输出结构化报告,且是唯一的 stdout 内容 |
|
|
145
|
+
| `-o, --output <file>` | 新建文件;拒绝任何已存在的路径,包括输入文件本身 |
|
|
146
|
+
| `--accept-semantic-changes` | 允许文本控件长度语义变化,并报告警告 |
|
|
147
|
+
| `--locale en\|zh` | 诊断和摘要的显示语言 |
|
|
148
|
+
|
|
149
|
+
默认把迁移后的源码写到标准输出。输入文件不会被覆盖;`-o` 使用独占创建,目标已存在即报错。没有 `-o` 时,请重定向 stdout 保存结果。
|
|
150
|
+
|
|
151
|
+
`--check` 从不写入。它输出诊断和摘要;带 `--json` 时输出 JSON 报告。需要迁移或被阻止时退出 `1`,源码已是当前版本时退出 `0`。普通迁移被阻止时退出 `1`,成功时退出 `0`。用法和 I/O 错误退出 `2`。不要把源码文本混入 JSON 报告。
|
|
152
|
+
|
|
153
|
+
命令一次迁移一份源码。本版本不提供 `--write`、不就地覆盖,也不提供破坏性批量操作。
|
|
154
|
+
|
|
155
|
+
## 范围
|
|
156
|
+
|
|
157
|
+
迁移处理声明的元数据变化,并检查正文能否跨越修订边界。它不是旧版读取器:不解释 YAML `state`/`data`/`computed`/`actions` 配置块、directive 或其他 draft 之前的语法,也不改写正文。在 `local-draft-2` 下已经无法编译的源码会保持阻止状态,直到作者修复报告的位置。
|
|
158
|
+
|
|
159
|
+
`0.6.0` 同时提供于 `latest` 与 `next` 渠道。本页说明从 `0.4.0` 起提供的迁移工具。
|