reactive-md 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG-ch.md +47 -15
- package/CHANGELOG.md +47 -15
- package/CONTRIBUTING-ch.md +10 -5
- package/CONTRIBUTING.md +10 -5
- package/README-ch.md +38 -36
- package/README-en.md +45 -42
- package/README.md +45 -42
- package/SECURITY-ch.md +1 -1
- package/SECURITY.md +1 -1
- package/THIRD_PARTY_NOTICES.md +481 -1
- package/cli/build.mjs +1 -1
- package/cli/package.mjs +1 -0
- package/dist-library/authoring-DSC0VsNK.js +842 -0
- package/dist-library/{runtime-UiQPz5ZV.js → compiler-CRD88BMt.js} +8944 -5847
- package/dist-library/react-Dk94rcOp.js +59658 -0
- package/dist-library/reactive-md-authoring.js +1514 -0
- package/dist-library/reactive-md-editor.js +589 -570
- package/dist-library/reactive-md-print.css +284 -0
- package/dist-library/reactive-md-react-unstyled.js +1 -0
- package/dist-library/reactive-md-react.js +1 -13208
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +308 -1126
- package/dist-library/runtime-D8KbnCd0.js +498 -0
- package/dist-library/types/authoring/index.d.ts +24 -0
- package/dist-library/types/editor/command-types.d.ts +10 -0
- package/dist-library/types/editor/editor-commands.d.ts +2 -2
- package/dist-library/types/editor/editor-i18n.d.ts +1 -1
- package/dist-library/types/editor/native-components.d.ts +1 -1
- package/dist-library/types/editor/source-authoring.d.ts +5 -3
- package/dist-library/types/editor/types.d.ts +7 -10
- package/dist-library/types/local/LocalDocumentView.d.ts +4 -2
- package/dist-library/types/local/authoring.d.ts +9 -5
- 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 +71 -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/index.d.ts +1 -0
- package/dist-library/types/local/math-display.d.ts +73 -0
- package/dist-library/types/local/math-view.d.ts +2 -0
- package/dist-library/types/local/options.d.ts +3 -1
- package/dist-library/types/local/table-surface.d.ts +10 -0
- package/dist-library/types/local/types.d.ts +12 -0
- package/dist-library/types/local/visuals.d.ts +9 -0
- package/dist-library/types/local/worker.d.ts +3 -2
- package/dist-library/types/react/index.d.ts +1 -1
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +79 -51
- package/docs/README.md +84 -0
- package/docs/{compatibility-ch.md → compatibility/compatibility-ch.md} +28 -18
- package/docs/{compatibility-en.md → compatibility/compatibility-en.md} +28 -18
- package/docs/{source-versioning-ch.md → compatibility/source-versioning-ch.md} +2 -2
- package/docs/{source-versioning-en.md → compatibility/source-versioning-en.md} +2 -2
- package/docs/{component-development-ch.md → development/component-development-ch.md} +7 -7
- package/docs/{component-development-en.md → development/component-development-en.md} +7 -7
- package/docs/{component-protocol-ch.md → development/component-protocol-ch.md} +17 -17
- package/docs/{component-protocol-en.md → development/component-protocol-en.md} +17 -17
- package/docs/{performance-ch.md → development/performance-ch.md} +2 -2
- package/docs/{performance-en.md → development/performance-en.md} +2 -2
- package/docs/{releasing-ch.md → development/releasing-ch.md} +12 -12
- package/docs/{releasing-en.md → development/releasing-en.md} +12 -12
- 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} +13 -7
- package/docs/{author-tools-en.md → integration/author-tools-en.md} +13 -7
- package/docs/{editor-ch.md → integration/editor-ch.md} +238 -235
- package/docs/{editor-en.md → integration/editor-en.md} +238 -235
- package/docs/{local-integration-ch.md → integration/local-integration-ch.md} +410 -390
- package/docs/{local-integration-en.md → integration/local-integration-en.md} +410 -390
- package/docs/{shareable-export-ch.md → integration/shareable-export-ch.md} +16 -4
- package/docs/{shareable-export-en.md → integration/shareable-export-en.md} +16 -4
- package/docs/{computations-formatting-ch.md → reference/computations-formatting-ch.md} +2 -2
- package/docs/{computations-formatting-en.md → reference/computations-formatting-en.md} +2 -2
- package/docs/{constraints-collections-ch.md → reference/constraints-collections-ch.md} +2 -2
- package/docs/{constraints-collections-en.md → reference/constraints-collections-en.md} +2 -2
- package/docs/{diagnostics-counting-ch.md → reference/diagnostics-counting-ch.md} +22 -2
- package/docs/{diagnostics-counting-en.md → reference/diagnostics-counting-en.md} +22 -2
- 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} +2 -2
- package/docs/{local-components-v2-en.md → reference/local-components-v2-en.md} +2 -2
- package/docs/{local-interaction-syntax-ch.md → reference/local-interaction-syntax-ch.md} +26 -7
- package/docs/{local-interaction-syntax-en.md → reference/local-interaction-syntax-en.md} +26 -7
- package/docs/{theme-protocol-ch.md → reference/theme-protocol-ch.md} +1 -1
- package/docs/{theme-protocol-en.md → reference/theme-protocol-en.md} +1 -1
- package/docs/{release-0.4.0-ch.md → releases/release-0.4.0-ch.md} +6 -6
- package/docs/{release-0.4.0-en.md → releases/release-0.4.0-en.md} +6 -6
- package/docs/{release-0.4.1-ch.md → releases/release-0.4.1-ch.md} +2 -2
- package/docs/{release-0.4.1-en.md → releases/release-0.4.1-en.md} +2 -2
- 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/releases/release-0.5.3-ch.md +25 -0
- package/docs/releases/release-0.5.3-en.md +25 -0
- package/docs/releases/release-0.6.0-ch.md +57 -0
- package/docs/releases/release-0.6.0-en.md +57 -0
- package/examples/conformance/README.md +4 -4
- package/examples/integration/README.md +10 -8
- package/examples/integration/worker/package.json +1 -1
- package/examples/local/README.md +5 -5
- package/examples/local/html-compat.reactive.md +19 -0
- package/package.json +20 -3
- package/docs/local-guide-ch.md +0 -967
- package/docs/local-guide-en.md +0 -967
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Diagnostic, SourceRange } from './types.js';
|
|
1
|
+
import type { Diagnostic, LocalCompileOptions, SourceRange } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* DOM-free authoring services for the local interaction syntax.
|
|
4
4
|
*
|
|
@@ -7,6 +7,10 @@ import type { Diagnostic, SourceRange } from './types.js';
|
|
|
7
7
|
* syntax is taken from `parseLocal`. Code, display math, comments, escaped
|
|
8
8
|
* syntax, footnotes and unknown/fallback regions produce no binding reads or
|
|
9
9
|
* formatting edits; computable plot parameters use the LaTeX AST.
|
|
10
|
+
*
|
|
11
|
+
* Every entry point accepts the same optional `LocalCompileOptions` as the
|
|
12
|
+
* preview compiler. Host components and syntax limits therefore shape analysis
|
|
13
|
+
* exactly as they shape rendering, and HTML mode is treated as opaque.
|
|
10
14
|
*/
|
|
11
15
|
export interface AuthorToken {
|
|
12
16
|
kind: string;
|
|
@@ -38,13 +42,13 @@ export interface AuthorRename {
|
|
|
38
42
|
}[];
|
|
39
43
|
}
|
|
40
44
|
/** Analyze active syntax, binding declarations/references and compile diagnostics. */
|
|
41
|
-
export declare function analyzeLocalSource(source: string): AuthorAnalysis;
|
|
45
|
+
export declare function analyzeLocalSource(source: string, options?: LocalCompileOptions): AuthorAnalysis;
|
|
42
46
|
/**
|
|
43
47
|
* Complete tags, schema attributes, enum values and declared binding names at
|
|
44
48
|
* `offset`. Replacement ranges cover an already-typed valid suffix so applying
|
|
45
49
|
* a suggestion never duplicates letters. Inactive regions yield no results.
|
|
46
50
|
*/
|
|
47
|
-
export declare function completeLocalSource(source: string, offset: number): AuthorCompletion[];
|
|
51
|
+
export declare function completeLocalSource(source: string, offset: number, options?: LocalCompileOptions): AuthorCompletion[];
|
|
48
52
|
/**
|
|
49
53
|
* Rename a declared binding and every active reference. Literal attribute
|
|
50
54
|
* text, Markdown text, strings inside expressions, code, display math, comments
|
|
@@ -52,7 +56,7 @@ export declare function completeLocalSource(source: string, offset: number): Aut
|
|
|
52
56
|
* meaning. Invalid names, collisions and structural
|
|
53
57
|
* parse failures are rejected.
|
|
54
58
|
*/
|
|
55
|
-
export declare function renameLocalBinding(source: string, oldName: string, newName: string): AuthorRename;
|
|
59
|
+
export declare function renameLocalBinding(source: string, oldName: string, newName: string, options?: LocalCompileOptions): AuthorRename;
|
|
56
60
|
/**
|
|
57
61
|
* Conservatively normalize whitespace inside recognized reactive tags:
|
|
58
62
|
* single spaces between attributes, no spaces around `=`, no space before `>`,
|
|
@@ -60,4 +64,4 @@ export declare function renameLocalBinding(source: string, oldName: string, newN
|
|
|
60
64
|
* Markdown, newlines, indentation, code, math and fallback regions are not
|
|
61
65
|
* modified. Any compile error leaves the document unchanged.
|
|
62
66
|
*/
|
|
63
|
-
export declare function formatLocalSource(source: string): string;
|
|
67
|
+
export declare function formatLocalSource(source: string, options?: LocalCompileOptions): string;
|
|
@@ -13,8 +13,10 @@ export interface CodeHighlight {
|
|
|
13
13
|
/** Highlighted children, or `null` when the source should render verbatim. */
|
|
14
14
|
nodes: ReactNode[] | null;
|
|
15
15
|
highlighted: boolean;
|
|
16
|
+
/** Resolved grammar, including the detected language for unlabeled blocks. */
|
|
17
|
+
language?: string;
|
|
16
18
|
}
|
|
17
|
-
/** Highlight
|
|
19
|
+
/** Highlight explicit languages, or detect unlabeled code with bounded grammars. */
|
|
18
20
|
export declare function highlightCode(value: string, language?: string): CodeHighlight;
|
|
19
21
|
export interface CodeBlockViewProps {
|
|
20
22
|
value: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LanguageFn } from 'highlight.js';
|
|
2
|
+
/** Cattca embeds command blocks in Markdown narrative. */
|
|
3
|
+
export declare const cattca: LanguageFn;
|
|
4
|
+
/** Highlight Mermaid source as code; rendering diagrams is a separate feature. */
|
|
5
|
+
export declare const mermaid: LanguageFn;
|
|
6
|
+
/** Vue SFCs combine HTML templates, JavaScript/TypeScript and CSS/SCSS. */
|
|
7
|
+
export declare const vue: LanguageFn;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publish compiler-owned data as ordinary records and arrays. Internal maps can
|
|
3
|
+
* keep null prototypes; React Server Component props require ordinary records.
|
|
4
|
+
* Keep undefined fields, shared references and existing frozen metadata intact.
|
|
5
|
+
*/
|
|
6
|
+
export declare function plainCompiledData<T>(value: T): T;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { LocalCompileOptions, LocalCompileResult } from './types.js';
|
|
2
|
+
/** Compile to plain data that can cross a React Server Component boundary. */
|
|
2
3
|
export declare function compileLocal(source: string, options?: LocalCompileOptions): LocalCompileResult;
|
|
3
4
|
export declare function compileLocalDocument(source: string, options?: LocalCompileOptions): LocalCompileResult;
|
|
@@ -230,6 +230,34 @@ export declare const LOCAL_DIAGNOSTIC_MESSAGES: {
|
|
|
230
230
|
readonly en: 'Raw HTML is not part of the local interaction syntax.';
|
|
231
231
|
readonly zh: '原始 HTML 不属于本地交互语法。';
|
|
232
232
|
};
|
|
233
|
+
readonly 'html.fallback': {
|
|
234
|
+
readonly en: 'Native HTML was safely converted to inert source text.';
|
|
235
|
+
readonly zh: '原生 HTML 已安全回退为惰性源码文本。';
|
|
236
|
+
};
|
|
237
|
+
readonly 'html.fallbackAttribute': {
|
|
238
|
+
readonly en: 'Native HTML attribute {name} is unsupported; the element was safely converted to inert source text.';
|
|
239
|
+
readonly zh: '原生 HTML 属性 {name} 不受支持;该元素已安全回退为惰性源码文本。';
|
|
240
|
+
};
|
|
241
|
+
readonly 'html.table.structure': {
|
|
242
|
+
readonly en: 'Invalid native HTML table structure in <{tag}>.';
|
|
243
|
+
readonly zh: '原生 HTML 表格的 <{tag}> 结构无效。';
|
|
244
|
+
};
|
|
245
|
+
readonly 'html.table.mixed': {
|
|
246
|
+
readonly en: 'Keep text and Markdown inside cells or captions; native HTML table structure cannot mix with Markdown table rows.';
|
|
247
|
+
readonly zh: '文字和 Markdown 应写在单元格或标题内;原生 HTML 表格结构不能混用 Markdown 表格行。';
|
|
248
|
+
};
|
|
249
|
+
readonly 'html.table.attribute': {
|
|
250
|
+
readonly en: 'Attribute {name} is not supported on native HTML <{tag}>. ReactiveMD table options require a Markdown table body.';
|
|
251
|
+
readonly zh: '原生 HTML <{tag}> 不支持属性 {name}。ReactiveMD 表格选项只适用于 Markdown 表格正文。';
|
|
252
|
+
};
|
|
253
|
+
readonly 'html.table.value': {
|
|
254
|
+
readonly en: 'Invalid value for {name} on native HTML <{tag}>.';
|
|
255
|
+
readonly zh: '原生 HTML <{tag}> 的 {name} 属性值无效。';
|
|
256
|
+
};
|
|
257
|
+
readonly 'html.table.unclosed': {
|
|
258
|
+
readonly en: 'Native HTML table is missing </table>.';
|
|
259
|
+
readonly zh: '原生 HTML 表格缺少 </table>。';
|
|
260
|
+
};
|
|
233
261
|
readonly 'html.extended': {
|
|
234
262
|
readonly en: 'HTML element <{name}> requires enableExtendedHtml in this mode; it is shown as source.';
|
|
235
263
|
readonly zh: '此模式下 HTML 元素 <{name}> 需要启用 enableExtendedHtml;已按源码显示。';
|
|
@@ -250,6 +278,10 @@ export declare const LOCAL_DIAGNOSTIC_MESSAGES: {
|
|
|
250
278
|
readonly en: 'Compile option {name} must be a boolean.';
|
|
251
279
|
readonly zh: '编译选项 {name} 必须是布尔值。';
|
|
252
280
|
};
|
|
281
|
+
readonly 'options.markdownBreaks': {
|
|
282
|
+
readonly en: 'Compile option markdownBreaks must be a boolean.';
|
|
283
|
+
readonly zh: '编译选项 markdownBreaks 必须为布尔值。';
|
|
284
|
+
};
|
|
253
285
|
readonly 'component.unknownSuggestion': {
|
|
254
286
|
readonly en: 'Unknown component <{name}>. Did you mean <{suggestion}>?';
|
|
255
287
|
readonly zh: '未知组件 <{name}>。是否想使用 <{suggestion}>?';
|
|
@@ -806,6 +838,34 @@ export declare const LOCAL_DIAGNOSTIC_MESSAGES: {
|
|
|
806
838
|
readonly en: 'Plot parameter "{name}" must be a number, but is {kind}.';
|
|
807
839
|
readonly zh: '绘图参数“{name}”必须是数字,但当前为 {kind}。';
|
|
808
840
|
};
|
|
841
|
+
readonly 'math.displayUnsupportedCommand': {
|
|
842
|
+
readonly en: 'Formula command \\{name} is not supported; it is displayed as literal text.';
|
|
843
|
+
readonly zh: '公式命令 \\{name} 不受支持;已按原文显示。';
|
|
844
|
+
};
|
|
845
|
+
readonly 'math.displayUnsupportedEnvironment': {
|
|
846
|
+
readonly en: 'Formula environment {name} is not supported; it is displayed as literal text.';
|
|
847
|
+
readonly zh: '公式环境 {name} 不受支持;已按原文显示。';
|
|
848
|
+
};
|
|
849
|
+
readonly 'math.displayBudget': {
|
|
850
|
+
readonly en: 'Formula exceeds a display resource limit ({limit}); it is displayed as literal text.';
|
|
851
|
+
readonly zh: '公式超过显示资源上限({limit});已按原文显示。';
|
|
852
|
+
};
|
|
853
|
+
readonly 'math.displayStrayEnd': {
|
|
854
|
+
readonly en: 'Formula has an unmatched \\end; it is displayed as literal text.';
|
|
855
|
+
readonly zh: '公式中存在未匹配的 \\end;已按原文显示。';
|
|
856
|
+
};
|
|
857
|
+
readonly 'math.displayEnvironmentUnclosed': {
|
|
858
|
+
readonly en: 'Formula environment {name} is missing its closing brace; it is displayed as literal text.';
|
|
859
|
+
readonly zh: '公式环境 {name} 缺少结束花括号;已按原文显示。';
|
|
860
|
+
};
|
|
861
|
+
readonly 'math.displayEnvironmentMissingName': {
|
|
862
|
+
readonly en: 'Formula environment is missing its name; \\begin is displayed as literal text.';
|
|
863
|
+
readonly zh: '公式环境缺少名称;\\begin 已按原文显示。';
|
|
864
|
+
};
|
|
865
|
+
readonly 'math.displaySyntax': {
|
|
866
|
+
readonly en: 'Formula structure cannot be displayed and is shown as literal text.';
|
|
867
|
+
readonly zh: '公式结构无法显示,已按原文显示。';
|
|
868
|
+
};
|
|
809
869
|
readonly 'table.missingHeader': {
|
|
810
870
|
readonly en: 'The table for <{name}> is missing a header.';
|
|
811
871
|
readonly zh: '<{name}> 的表格缺少表头。';
|
|
@@ -1294,11 +1354,15 @@ declare const LOCAL_DIAGNOSTIC_TEMPLATE_ALIASES: {
|
|
|
1294
1354
|
readonly 'local.math.whitespace': 'math.whitespace';
|
|
1295
1355
|
readonly 'local.footnote.unsupported': 'footnote.unsupported';
|
|
1296
1356
|
readonly 'local.html': 'html.raw';
|
|
1357
|
+
readonly 'local.html.fallback': 'html.fallback';
|
|
1358
|
+
readonly 'local.html.fallback.attribute': 'html.fallbackAttribute';
|
|
1359
|
+
readonly 'local.html.table': 'html.table.structure';
|
|
1297
1360
|
readonly 'local.html.extended': 'html.extended';
|
|
1298
1361
|
readonly 'local.html.attribute': 'html.attribute';
|
|
1299
1362
|
readonly 'local.html.unsafe-url': 'html.unsafeUrl';
|
|
1300
1363
|
readonly 'local.html.capability': 'html.capability';
|
|
1301
1364
|
readonly 'local.options.invalid.html-flag': 'options.htmlFlag';
|
|
1365
|
+
readonly 'local.options.invalid.markdown-breaks': 'options.markdownBreaks';
|
|
1302
1366
|
readonly 'local.component.unknown.suggestion': 'component.unknownSuggestion';
|
|
1303
1367
|
readonly 'local.component.unknown': 'component.unknownPlain';
|
|
1304
1368
|
readonly 'local.attribute.format': 'attribute.lowercase';
|
|
@@ -1444,6 +1508,13 @@ declare const LOCAL_DIAGNOSTIC_TEMPLATE_ALIASES: {
|
|
|
1444
1508
|
readonly 'local.math.compute': 'math.computeFailed';
|
|
1445
1509
|
readonly 'local.math.binding.unknown': 'math.bindingUnknown';
|
|
1446
1510
|
readonly 'local.math.binding.type': 'math.bindingType';
|
|
1511
|
+
readonly 'local.math.display.unsupported-command': 'math.displayUnsupportedCommand';
|
|
1512
|
+
readonly 'local.math.display.unsupported-environment': 'math.displayUnsupportedEnvironment';
|
|
1513
|
+
readonly 'local.math.display.budget': 'math.displayBudget';
|
|
1514
|
+
readonly 'local.math.display.stray-end': 'math.displayStrayEnd';
|
|
1515
|
+
readonly 'local.math.display.environment-unclosed': 'math.displayEnvironmentUnclosed';
|
|
1516
|
+
readonly 'local.math.display.environment-missing-name': 'math.displayEnvironmentMissingName';
|
|
1517
|
+
readonly 'local.math.display.syntax': 'math.displaySyntax';
|
|
1447
1518
|
readonly 'local.table.header.missing': 'table.missingHeader';
|
|
1448
1519
|
readonly 'local.table.header.interpolation': 'table.headerInterpolation';
|
|
1449
1520
|
readonly 'local.table.header.empty': 'table.headerEmpty';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type DiagramDirection = 'right' | 'down';
|
|
2
|
+
export interface DiagramLayoutNodeInput {
|
|
3
|
+
id: string;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export interface DiagramLayoutEdgeInput {
|
|
8
|
+
id: string;
|
|
9
|
+
from: string;
|
|
10
|
+
to: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
labelWidth?: number;
|
|
13
|
+
labelHeight?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface DiagramLayoutInput {
|
|
16
|
+
direction: DiagramDirection;
|
|
17
|
+
nodes: DiagramLayoutNodeInput[];
|
|
18
|
+
edges: DiagramLayoutEdgeInput[];
|
|
19
|
+
}
|
|
20
|
+
export interface DiagramPoint {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
}
|
|
24
|
+
export interface DiagramEdgeSection {
|
|
25
|
+
startPoint: DiagramPoint;
|
|
26
|
+
endPoint: DiagramPoint;
|
|
27
|
+
bendPoints: DiagramPoint[];
|
|
28
|
+
/** ELK spline points are cubic controls, not polyline vertices. */
|
|
29
|
+
cubic?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Round routed corners without moving ports or leaving the routing corridor. */
|
|
32
|
+
export declare function diagramEdgePath(sections: DiagramEdgeSection[], radius?: number): string;
|
|
33
|
+
export interface DiagramLabelRect {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
}
|
|
39
|
+
export interface DiagramEdgeLayout {
|
|
40
|
+
sections: DiagramEdgeSection[];
|
|
41
|
+
label?: DiagramLabelRect;
|
|
42
|
+
}
|
|
43
|
+
export interface DiagramNodeLayout {
|
|
44
|
+
/** Node centre, matching the SVG translate used for node cards. */
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
}
|
|
50
|
+
export interface DiagramLayoutResult {
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
nodes: Map<string, DiagramNodeLayout>;
|
|
54
|
+
edges: Map<string, DiagramEdgeLayout>;
|
|
55
|
+
source: 'elk' | 'fallback';
|
|
56
|
+
}
|
|
57
|
+
/** Every value that can change geometry; selection, tone and body do not. */
|
|
58
|
+
export declare function diagramLayoutKey(input: DiagramLayoutInput): string;
|
|
59
|
+
/**
|
|
60
|
+
* Resolves the layered layout. Failures (including an unsupported runtime)
|
|
61
|
+
* degrade to the synchronous fallback instead of breaking the diagram.
|
|
62
|
+
*/
|
|
63
|
+
export declare function layoutDiagram(input: DiagramLayoutInput): Promise<DiagramLayoutResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Deterministic layered layout used before ELK resolves (SSR, static export
|
|
66
|
+
* and first paint). Cycle-closing edges found by a declaration-order DFS are
|
|
67
|
+
* ignored for layering and routed outside the node band.
|
|
68
|
+
*/
|
|
69
|
+
export declare function createDiagramLayoutFallback(input: DiagramLayoutInput): DiagramLayoutResult;
|
|
@@ -4,3 +4,9 @@
|
|
|
4
4
|
* never dispatch such a tag to a host component.
|
|
5
5
|
*/
|
|
6
6
|
export declare const LOCAL_HTML_NAMES: ReadonlySet<string>;
|
|
7
|
+
/** Legacy text alignment accepted as a bounded HTML attribute, without CSS. */
|
|
8
|
+
export declare const LOCAL_HTML_ALIGN_ELEMENTS: ReadonlySet<string>;
|
|
9
|
+
export declare function localHtmlAlign(value: string): 'left' | 'center' | 'right' | 'justify' | null;
|
|
10
|
+
export declare const LOCAL_HTML_ANCHOR_ATTRIBUTES: ReadonlySet<string>;
|
|
11
|
+
/** Preserve author relationship tokens while retaining blank-link isolation. */
|
|
12
|
+
export declare function localHtmlLinkRel(rel: string | undefined, target: string | undefined): string | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LocalNode } from './types.js';
|
|
2
|
+
/** Contextual names: they do not reserve new component names globally. */
|
|
3
|
+
export declare const HTML_TABLE_NAMES: ReadonlySet<string>;
|
|
4
|
+
export declare const HTML_TABLE_ATTRIBUTES: Readonly<Record<string, ReadonlySet<string>>>;
|
|
5
|
+
export declare function validHtmlTableValue(name: string, value: string): boolean;
|
|
6
|
+
export type HtmlTableProblem = 'structure' | 'mixed' | 'attribute' | 'value' | 'unclosed';
|
|
7
|
+
interface Hooks {
|
|
8
|
+
shield(offset: number, end: number): number | null;
|
|
9
|
+
budget(offset: number, tokens: number): void;
|
|
10
|
+
node(type: string, start: number, end: number, extra: Partial<LocalNode>): LocalNode;
|
|
11
|
+
attributes(tag: string, start: number, end: number): Record<string, string>;
|
|
12
|
+
content(start: number, end: number): LocalNode[];
|
|
13
|
+
problem(kind: HtmlTableProblem, start: number, end: number, tag?: string, name?: string): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse only the table skeleton with the HTML parser. Cell/caption bodies are
|
|
17
|
+
* opaque spaces of equal length, then parsed from the original source through
|
|
18
|
+
* the normal ReactiveMD pipeline. This preserves offsets and avoids HTML's
|
|
19
|
+
* foster-parenting of Markdown, custom controls or example tags in code.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readHtmlTable(source: string, start: number, limit: number, hooks: Hooks): {
|
|
22
|
+
node: LocalNode;
|
|
23
|
+
end: number;
|
|
24
|
+
} | null;
|
|
25
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { analyzeLocalSource, completeLocalSource, renameLocalBinding, formatLocalSource } from './authoring.js';
|
|
2
2
|
export type { AuthorToken, AuthorBinding, AuthorAnalysis, AuthorCompletion, AuthorCompletionKind, AuthorRename } from './authoring.js';
|
|
3
3
|
export { compileLocal } from './compiler.js';
|
|
4
|
+
export { localCompileOptionsKey } from './options.js';
|
|
4
5
|
export { formatLocalDiagnostic, LOCAL_DIAGNOSTIC_CODES, isLocalDiagnosticCode, localDiagnosticTemplate, localDiagnosticTemplateKeys, } from './diagnostics.js';
|
|
5
6
|
export type { LocalDiagnosticDetails } from './diagnostics.js';
|
|
6
7
|
export { countLocalCodePoints } from './text-length.js';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure-TypeScript MathML parser for local LaTeX display.
|
|
3
|
+
*
|
|
4
|
+
* This module owns the single parsing implementation used by the React view
|
|
5
|
+
* (`math-view.tsx`) and by display diagnostics. It must stay React-free so the
|
|
6
|
+
* compiler can inspect formulas without importing the renderer.
|
|
7
|
+
*
|
|
8
|
+
* Parsing never throws: unsupported constructs are represented as literal
|
|
9
|
+
* MathML text, and the same constructs are reported as source-ranged issues.
|
|
10
|
+
* That keeps "rendered as literal text" and "reported as a warning" in sync.
|
|
11
|
+
*/
|
|
12
|
+
import type { LocalDiagnosticParams } from './types.js';
|
|
13
|
+
export type LocalMathDisplayIssueReason = 'unsupported-command' | 'unsupported-environment' | 'budget' | 'syntax';
|
|
14
|
+
/** One display-compatibility issue; offsets are relative to the formula body. */
|
|
15
|
+
export interface LocalMathDisplayIssue {
|
|
16
|
+
/** Inclusive UTF-16 offset into the formula body. */
|
|
17
|
+
start: number;
|
|
18
|
+
/** Exclusive UTF-16 offset into the formula body. */
|
|
19
|
+
end: number;
|
|
20
|
+
reason: LocalMathDisplayIssueReason;
|
|
21
|
+
/** English message for the issue (localize with `messageKey`/`params`). */
|
|
22
|
+
message: string;
|
|
23
|
+
/** Coarse machine code reported on `Diagnostic.code`. */
|
|
24
|
+
code: string;
|
|
25
|
+
/** Template key registered in `diagnostics.ts`. */
|
|
26
|
+
messageKey: string;
|
|
27
|
+
params?: LocalDiagnosticParams;
|
|
28
|
+
}
|
|
29
|
+
/** Lightweight MathML tree consumed by the React view. */
|
|
30
|
+
export interface MathNode {
|
|
31
|
+
tag: string;
|
|
32
|
+
attrs?: Readonly<Record<string, string>>;
|
|
33
|
+
style?: Readonly<Record<string, string>>;
|
|
34
|
+
text?: string;
|
|
35
|
+
children?: MathNode[];
|
|
36
|
+
}
|
|
37
|
+
export interface LocalMathDisplayParse {
|
|
38
|
+
/** `null` means the whole formula must be shown as bounded literal text. */
|
|
39
|
+
node: MathNode | null;
|
|
40
|
+
issues: LocalMathDisplayIssue[];
|
|
41
|
+
}
|
|
42
|
+
/** Diagnostic code emitted for every display-compatibility issue. */
|
|
43
|
+
export declare const MATH_DISPLAY_DIAGNOSTIC_CODE = "local.math.display";
|
|
44
|
+
export declare const MATH_DISPLAY_MESSAGE_KEYS: {
|
|
45
|
+
readonly 'unsupported-command': 'local.math.display.unsupported-command';
|
|
46
|
+
readonly 'unsupported-environment': 'local.math.display.unsupported-environment';
|
|
47
|
+
readonly budget: 'local.math.display.budget';
|
|
48
|
+
readonly 'stray-end': 'local.math.display.stray-end';
|
|
49
|
+
readonly 'environment-unclosed': 'local.math.display.environment-unclosed';
|
|
50
|
+
readonly 'environment-missing-name': 'local.math.display.environment-missing-name';
|
|
51
|
+
readonly syntax: 'local.math.display.syntax';
|
|
52
|
+
};
|
|
53
|
+
export declare const MAX_LOCAL_MATH_DISPLAY_SOURCE = 50000;
|
|
54
|
+
export declare const MAX_LOCAL_MATH_DISPLAY_TOKENS = 20000;
|
|
55
|
+
export declare const MAX_LOCAL_MATH_DISPLAY_DEPTH = 120;
|
|
56
|
+
export declare const MAX_LOCAL_MATH_DISPLAY_FALLBACK = 2000;
|
|
57
|
+
/** Bounded literal text used when the whole formula cannot be rendered. */
|
|
58
|
+
export declare function boundedLocalMathLiteral(source: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Parse the formula body once for both rendering and diagnostics.
|
|
61
|
+
*
|
|
62
|
+
* `node === null` means the renderer must fall back to bounded literal text;
|
|
63
|
+
* `issues` then contains exactly one budget or syntax issue.
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseLocalMathDisplay(source: string): LocalMathDisplayParse;
|
|
66
|
+
/**
|
|
67
|
+
* Report every construct that the display renderer degrades to literal text.
|
|
68
|
+
*
|
|
69
|
+
* Offsets are relative to the formula body (`LocalNode.value`). Compute-only
|
|
70
|
+
* limitations (for example `\int` in `<plot>`) are intentionally not reported:
|
|
71
|
+
* they do not affect display.
|
|
72
|
+
*/
|
|
73
|
+
export declare function inspectLocalMathDisplay(source: string): LocalMathDisplayIssue[];
|
|
@@ -2,6 +2,8 @@ import { type ReactElement } from 'react';
|
|
|
2
2
|
/**
|
|
3
3
|
* Safe native MathML rendering for local LaTeX.
|
|
4
4
|
*
|
|
5
|
+
* Parsing and support detection live in the React-free `math-display` module,
|
|
6
|
+
* so compile-time diagnostics use exactly the same rules as this renderer.
|
|
5
7
|
* The renderer never interprets HTML, styles, macros, files or links from the
|
|
6
8
|
* source. Unknown commands are shown as literal text, so a formula that cannot
|
|
7
9
|
* be computed still remains readable. All source text passes through React as
|
|
@@ -10,6 +10,8 @@ export type LocalOptionCheck = {
|
|
|
10
10
|
html: LocalHtmlPolicy;
|
|
11
11
|
/** True when at least one capability flag is enabled. */
|
|
12
12
|
htmlActive: boolean;
|
|
13
|
+
/** Render ordinary Markdown soft line breaks as `break` nodes. */
|
|
14
|
+
markdownBreaks: boolean;
|
|
13
15
|
/** Validated host component schemas; empty when the option is absent. */
|
|
14
16
|
hostComponents: readonly LocalHostComponentSchema[];
|
|
15
17
|
/** Host tag name lookup; names are already lowercase kebab-case. */
|
|
@@ -31,4 +33,4 @@ export declare function readLocalCompileOptions(options: LocalCompileOptions | u
|
|
|
31
33
|
* recompile on flag/limit changes and to keep worker races keyed by more than
|
|
32
34
|
* the source text. Unknown keys are deliberately ignored.
|
|
33
35
|
*/
|
|
34
|
-
export declare function localCompileOptionsKey(options
|
|
36
|
+
export declare function localCompileOptionsKey(options?: LocalCompileOptions): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
/** The same table/scroll surface for Markdown-backed and native HTML tables. */
|
|
3
|
+
export declare function TableSurface({ children, className, scrollClassName, tableProps }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
scrollClassName?: string;
|
|
7
|
+
tableProps?: HTMLAttributes<HTMLTableElement> & {
|
|
8
|
+
'data-merged'?: string;
|
|
9
|
+
};
|
|
10
|
+
}): import("react").JSX.Element;
|
|
@@ -103,6 +103,7 @@ export interface LocalValidation {
|
|
|
103
103
|
fields: string[];
|
|
104
104
|
range: SourceRange;
|
|
105
105
|
}
|
|
106
|
+
/** Compiler-produced documents contain only plain records, arrays and primitives. */
|
|
106
107
|
export interface LocalDocument {
|
|
107
108
|
syntax: 'local';
|
|
108
109
|
source: string;
|
|
@@ -205,9 +206,20 @@ export interface LocalHostComponentSchema {
|
|
|
205
206
|
}
|
|
206
207
|
export interface LocalCompileOptions extends LocalHtmlOptions {
|
|
207
208
|
readonly limits?: LocalCompileLimits;
|
|
209
|
+
/**
|
|
210
|
+
* Render ordinary Markdown soft line breaks as `<br>`.
|
|
211
|
+
*
|
|
212
|
+
* Defaults to `false`, which keeps the historical behavior where a soft
|
|
213
|
+
* break is ordinary collapsible whitespace. When `true`, each source soft
|
|
214
|
+
* break becomes a `break` node; explicit hard breaks, code, formulas and
|
|
215
|
+
* native HTML are left untouched. The source text is never rewritten, so
|
|
216
|
+
* every node keeps its original offsets.
|
|
217
|
+
*/
|
|
218
|
+
readonly markdownBreaks?: boolean;
|
|
208
219
|
/** Host-defined leaf components recognized alongside the built-in schema. */
|
|
209
220
|
readonly hostComponents?: readonly LocalHostComponentSchema[];
|
|
210
221
|
}
|
|
222
|
+
/** Public compiler output is plain data, including nested attributes and dependencies. */
|
|
211
223
|
export type LocalCompileResult = {
|
|
212
224
|
ok: true;
|
|
213
225
|
document: LocalDocument;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import type { LocalNode, LocalRuntime } from './types.js';
|
|
2
3
|
import type { LocalVisualProps } from './render-types.js';
|
|
4
|
+
import { type Localize } from './i18n.js';
|
|
5
|
+
/** Shared scalar classification for plain native cells and Markdown cells. */
|
|
6
|
+
export declare function tableNumericColumns(rows: readonly LocalNode[][], runtime: LocalRuntime, t: Localize): boolean[];
|
|
7
|
+
export declare function VisualFrame({ className, label, children, }: {
|
|
8
|
+
className: string;
|
|
9
|
+
label: ReactNode;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
3
12
|
export declare function LocalVisual(props: LocalVisualProps): ReactNode;
|
|
@@ -5,8 +5,9 @@ export interface LocalCompileRequest {
|
|
|
5
5
|
id: number;
|
|
6
6
|
source: string;
|
|
7
7
|
/**
|
|
8
|
-
* Capability flags, limits and host component
|
|
9
|
-
* `hostComponents` selects the host leaf tags the
|
|
8
|
+
* Capability flags, Markdown break handling, limits and host component
|
|
9
|
+
* schemas for this compile. `hostComponents` selects the host leaf tags the
|
|
10
|
+
* parser may build; `markdownBreaks` turns soft breaks into `break` nodes.
|
|
10
11
|
*/
|
|
11
12
|
options?: LocalCompileOptions;
|
|
12
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { LocalDocumentView, LocalReactiveDocument } from '../local/LocalDocumentView.js';
|
|
2
2
|
export type { LocalDocumentViewProps, LocalReactiveDocumentProps, LocalUrlPolicy, LocalImageResolver, } from '../local/LocalDocumentView.js';
|
|
3
|
-
export type { LocalRenderMode, LocalHostData, LocalHostRenderer } from '../local/render-types.js';
|
|
3
|
+
export type { LocalRenderMode, LocalRenderContext, LocalHostData, LocalHostRenderer } from '../local/render-types.js';
|
|
4
4
|
export type { LocalLocale } from '../local/locale.js';
|
|
5
5
|
export type { LocalColorScheme, LocalThemeDefinition } from '../local/theme.js';
|